~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to include/linux/swap.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#define SWAP_FLAG_PREFER        0x8000  /* set if swap priority specified */
20
20
#define SWAP_FLAG_PRIO_MASK     0x7fff
21
21
#define SWAP_FLAG_PRIO_SHIFT    0
 
22
#define SWAP_FLAG_DISCARD       0x10000 /* discard swap cluster after use */
22
23
 
23
24
static inline int current_is_kswapd(void)
24
25
{
142
143
enum {
143
144
        SWP_USED        = (1 << 0),     /* is slot in swap_info[] used? */
144
145
        SWP_WRITEOK     = (1 << 1),     /* ok to write to this swap?    */
145
 
        SWP_DISCARDABLE = (1 << 2),     /* blkdev supports discard */
 
146
        SWP_DISCARDABLE = (1 << 2),     /* swapon+blkdev support discard */
146
147
        SWP_DISCARDING  = (1 << 3),     /* now discarding a free cluster */
147
148
        SWP_SOLIDSTATE  = (1 << 4),     /* blkdev seeks are cheap */
 
149
        SWP_CONTINUED   = (1 << 5),     /* swap_map has count continuation */
 
150
        SWP_BLKDEV      = (1 << 6),     /* its a block device */
148
151
                                        /* add others here before... */
149
152
        SWP_SCANNING    = (1 << 8),     /* refcount in scan_swap_map */
150
153
};
151
154
 
152
155
#define SWAP_CLUSTER_MAX 32
153
 
 
154
 
#define SWAP_MAP_MAX    0x7ffe
155
 
#define SWAP_MAP_BAD    0x7fff
156
 
#define SWAP_HAS_CACHE  0x8000          /* There is a swap cache of entry. */
157
 
#define SWAP_COUNT_MASK (~SWAP_HAS_CACHE)
 
156
#define COMPACT_CLUSTER_MAX SWAP_CLUSTER_MAX
 
157
 
 
158
#define SWAP_MAP_MAX    0x3e    /* Max duplication count, in first swap_map */
 
159
#define SWAP_MAP_BAD    0x3f    /* Note pageblock is bad, in first swap_map */
 
160
#define SWAP_HAS_CACHE  0x40    /* Flag page is cached, in first swap_map */
 
161
#define SWAP_CONT_MAX   0x7f    /* Max count, in each swap_map continuation */
 
162
#define COUNT_CONTINUED 0x80    /* See swap_map continuation for full count */
 
163
#define SWAP_MAP_SHMEM  0xbf    /* Owned by shmem/tmpfs, in first swap_map */
 
164
 
158
165
/*
159
166
 * The in-memory structure used to track swap areas.
160
167
 */
161
168
struct swap_info_struct {
162
 
        unsigned long flags;
163
 
        int prio;                       /* swap priority */
164
 
        int next;                       /* next entry on swap list */
165
 
        struct file *swap_file;
166
 
        struct block_device *bdev;
167
 
        struct list_head extent_list;
168
 
        struct swap_extent *curr_swap_extent;
169
 
        unsigned short *swap_map;
170
 
        unsigned int lowest_bit;
171
 
        unsigned int highest_bit;
 
169
        unsigned long   flags;          /* SWP_USED etc: see above */
 
170
        signed short    prio;           /* swap priority of this type */
 
171
        signed char     type;           /* strange name for an index */
 
172
        signed char     next;           /* next type on the swap list */
 
173
        unsigned int    max;            /* extent of the swap_map */
 
174
        unsigned char *swap_map;        /* vmalloc'ed array of usage counts */
 
175
        unsigned int lowest_bit;        /* index of first free in swap_map */
 
176
        unsigned int highest_bit;       /* index of last free in swap_map */
 
177
        unsigned int pages;             /* total of usable pages of swap */
 
178
        unsigned int inuse_pages;       /* number of those currently in use */
 
179
        unsigned int cluster_next;      /* likely index for next allocation */
 
180
        unsigned int cluster_nr;        /* countdown to next cluster search */
172
181
        unsigned int lowest_alloc;      /* while preparing discard cluster */
173
182
        unsigned int highest_alloc;     /* while preparing discard cluster */
174
 
        unsigned int cluster_next;
175
 
        unsigned int cluster_nr;
176
 
        unsigned int pages;
177
 
        unsigned int max;
178
 
        unsigned int inuse_pages;
179
 
        unsigned int old_block_size;
 
183
        struct swap_extent *curr_swap_extent;
 
184
        struct swap_extent first_swap_extent;
 
185
        struct block_device *bdev;      /* swap device or bdev of swap file */
 
186
        struct file *swap_file;         /* seldom referenced */
 
187
        unsigned int old_block_size;    /* seldom referenced */
180
188
};
181
189
 
182
190
struct swap_list_t {
200
208
/* linux/mm/swap.c */
201
209
extern void __lru_cache_add(struct page *, enum lru_list lru);
202
210
extern void lru_cache_add_lru(struct page *, enum lru_list lru);
 
211
extern void lru_add_page_tail(struct zone* zone,
 
212
                              struct page *page, struct page *page_tail);
203
213
extern void activate_page(struct page *);
204
214
extern void mark_page_accessed(struct page *);
205
215
extern void lru_add_drain(void);
218
228
        __lru_cache_add(page, LRU_INACTIVE_ANON);
219
229
}
220
230
 
221
 
static inline void lru_cache_add_active_anon(struct page *page)
222
 
{
223
 
        __lru_cache_add(page, LRU_ACTIVE_ANON);
224
 
}
225
 
 
226
231
static inline void lru_cache_add_file(struct page *page)
227
232
{
228
233
        __lru_cache_add(page, LRU_INACTIVE_FILE);
229
234
}
230
235
 
231
 
static inline void lru_cache_add_active_file(struct page *page)
232
 
{
233
 
        __lru_cache_add(page, LRU_ACTIVE_FILE);
234
 
}
 
236
/* LRU Isolation modes. */
 
237
#define ISOLATE_INACTIVE 0      /* Isolate inactive pages. */
 
238
#define ISOLATE_ACTIVE 1        /* Isolate active pages. */
 
239
#define ISOLATE_BOTH 2          /* Isolate both active and inactive pages. */
235
240
 
236
241
/* linux/mm/vmscan.c */
237
242
extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
242
247
extern unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
243
248
                                                gfp_t gfp_mask, bool noswap,
244
249
                                                unsigned int swappiness,
245
 
                                                struct zone *zone,
246
 
                                                int nid);
 
250
                                                struct zone *zone);
247
251
extern int __isolate_lru_page(struct page *page, int mode, int file);
248
252
extern unsigned long shrink_all_memory(unsigned long nr_pages);
249
253
extern int vm_swappiness;
269
273
extern unsigned long scan_unevictable_pages;
270
274
extern int scan_unevictable_handler(struct ctl_table *, int,
271
275
                                        void __user *, size_t *, loff_t *);
 
276
#ifdef CONFIG_NUMA
272
277
extern int scan_unevictable_register_node(struct node *node);
273
278
extern void scan_unevictable_unregister_node(struct node *node);
 
279
#else
 
280
static inline int scan_unevictable_register_node(struct node *node)
 
281
{
 
282
        return 0;
 
283
}
 
284
static inline void scan_unevictable_unregister_node(struct node *node)
 
285
{
 
286
}
 
287
#endif
274
288
 
275
289
extern int kswapd_run(int nid);
 
290
extern void kswapd_stop(int nid);
276
291
 
277
292
#ifdef CONFIG_MMU
278
293
/* linux/mm/shmem.c */
279
294
extern int shmem_unuse(swp_entry_t entry, struct page *page);
280
295
#endif /* CONFIG_MMU */
281
296
 
 
297
#ifdef CONFIG_CGROUP_MEM_RES_CTLR
 
298
extern void mem_cgroup_get_shmem_target(struct inode *inode, pgoff_t pgoff,
 
299
                                        struct page **pagep, swp_entry_t *ent);
 
300
#endif
 
301
 
282
302
extern void swap_unplug_io_fn(struct backing_dev_info *, struct page *);
283
303
 
284
304
#ifdef CONFIG_SWAP
309
329
extern void si_swapinfo(struct sysinfo *);
310
330
extern swp_entry_t get_swap_page(void);
311
331
extern swp_entry_t get_swap_page_of_type(int);
312
 
extern void swap_duplicate(swp_entry_t);
 
332
extern int valid_swaphandles(swp_entry_t, unsigned long *);
 
333
extern int add_swap_count_continuation(swp_entry_t, gfp_t);
 
334
extern void swap_shmem_alloc(swp_entry_t);
 
335
extern int swap_duplicate(swp_entry_t);
313
336
extern int swapcache_prepare(swp_entry_t);
314
 
extern int valid_swaphandles(swp_entry_t, unsigned long *);
315
337
extern void swap_free(swp_entry_t);
316
338
extern void swapcache_free(swp_entry_t, struct page *page);
317
339
extern int free_swap_and_cache(swp_entry_t);
318
340
extern int swap_type_of(dev_t, sector_t, struct block_device **);
319
341
extern unsigned int count_swap_pages(int, int);
320
 
extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t);
 
342
extern sector_t map_swap_page(struct page *, struct block_device **);
321
343
extern sector_t swapdev_block(int, pgoff_t);
322
 
extern struct swap_info_struct *get_swap_info_struct(unsigned);
323
344
extern int reuse_swap_page(struct page *);
324
345
extern int try_to_free_swap(struct page *);
325
346
struct backing_dev_info;
348
369
#ifdef CONFIG_CGROUP_MEM_RES_CTLR
349
370
extern void
350
371
mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout);
 
372
extern int mem_cgroup_count_swap_user(swp_entry_t ent, struct page **pagep);
351
373
#else
352
374
static inline void
353
375
mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
384
406
#define free_swap_and_cache(swp)        is_migration_entry(swp)
385
407
#define swapcache_prepare(swp)          is_migration_entry(swp)
386
408
 
387
 
static inline void swap_duplicate(swp_entry_t swp)
388
 
{
 
409
static inline int add_swap_count_continuation(swp_entry_t swp, gfp_t gfp_mask)
 
410
{
 
411
        return 0;
 
412
}
 
413
 
 
414
static inline void swap_shmem_alloc(swp_entry_t swp)
 
415
{
 
416
}
 
417
 
 
418
static inline int swap_duplicate(swp_entry_t swp)
 
419
{
 
420
        return 0;
389
421
}
390
422
 
391
423
static inline void swap_free(swp_entry_t swp)
468
500
{
469
501
}
470
502
 
 
503
#ifdef CONFIG_CGROUP_MEM_RES_CTLR
 
504
static inline int
 
505
mem_cgroup_count_swap_user(swp_entry_t ent, struct page **pagep)
 
506
{
 
507
        return 0;
 
508
}
 
509
#endif
 
510
 
471
511
#endif /* CONFIG_SWAP */
472
512
#endif /* __KERNEL__*/
473
513
#endif /* _LINUX_SWAP_H */