diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/fs.h | 7 | ||||
-rw-r--r-- | include/linux/mm.h | 40 | ||||
-rw-r--r-- | include/linux/shrinker.h | 42 |
3 files changed, 50 insertions, 39 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 460d2cc21ec6..d7f35e90b84a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -393,6 +393,7 @@ struct inodes_stat_t { | |||
393 | #include <linux/semaphore.h> | 393 | #include <linux/semaphore.h> |
394 | #include <linux/fiemap.h> | 394 | #include <linux/fiemap.h> |
395 | #include <linux/rculist_bl.h> | 395 | #include <linux/rculist_bl.h> |
396 | #include <linux/shrinker.h> | ||
396 | #include <linux/atomic.h> | 397 | #include <linux/atomic.h> |
397 | 398 | ||
398 | #include <asm/byteorder.h> | 399 | #include <asm/byteorder.h> |
@@ -1444,8 +1445,14 @@ struct super_block { | |||
1444 | * Saved pool identifier for cleancache (-1 means none) | 1445 | * Saved pool identifier for cleancache (-1 means none) |
1445 | */ | 1446 | */ |
1446 | int cleancache_poolid; | 1447 | int cleancache_poolid; |
1448 | |||
1449 | struct shrinker s_shrink; /* per-sb shrinker handle */ | ||
1447 | }; | 1450 | }; |
1448 | 1451 | ||
1452 | /* superblock cache pruning functions */ | ||
1453 | extern void prune_icache_sb(struct super_block *sb, int nr_to_scan); | ||
1454 | extern void prune_dcache_sb(struct super_block *sb, int nr_to_scan); | ||
1455 | |||
1449 | extern struct timespec current_fs_time(struct super_block *sb); | 1456 | extern struct timespec current_fs_time(struct super_block *sb); |
1450 | 1457 | ||
1451 | /* | 1458 | /* |
diff --git a/include/linux/mm.h b/include/linux/mm.h index 9b9777ac726d..e3a1a9eec0b1 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/range.h> | 15 | #include <linux/range.h> |
16 | #include <linux/pfn.h> | 16 | #include <linux/pfn.h> |
17 | #include <linux/bit_spinlock.h> | 17 | #include <linux/bit_spinlock.h> |
18 | #include <linux/shrinker.h> | ||
18 | 19 | ||
19 | struct mempolicy; | 20 | struct mempolicy; |
20 | struct anon_vma; | 21 | struct anon_vma; |
@@ -1121,45 +1122,6 @@ static inline void sync_mm_rss(struct task_struct *task, struct mm_struct *mm) | |||
1121 | } | 1122 | } |
1122 | #endif | 1123 | #endif |
1123 | 1124 | ||
1124 | /* | ||
1125 | * This struct is used to pass information from page reclaim to the shrinkers. | ||
1126 | * We consolidate the values for easier extention later. | ||
1127 | */ | ||
1128 | struct shrink_control { | ||
1129 | gfp_t gfp_mask; | ||
1130 | |||
1131 | /* How many slab objects shrinker() should scan and try to reclaim */ | ||
1132 | unsigned long nr_to_scan; | ||
1133 | }; | ||
1134 | |||
1135 | /* | ||
1136 | * A callback you can register to apply pressure to ageable caches. | ||
1137 | * | ||
1138 | * 'sc' is passed shrink_control which includes a count 'nr_to_scan' | ||
1139 | * and a 'gfpmask'. It should look through the least-recently-used | ||
1140 | * 'nr_to_scan' entries and attempt to free them up. It should return | ||
1141 | * the number of objects which remain in the cache. If it returns -1, it means | ||
1142 | * it cannot do any scanning at this time (eg. there is a risk of deadlock). | ||
1143 | * | ||
1144 | * The 'gfpmask' refers to the allocation we are currently trying to | ||
1145 | * fulfil. | ||
1146 | * | ||
1147 | * Note that 'shrink' will be passed nr_to_scan == 0 when the VM is | ||
1148 | * querying the cache size, so a fastpath for that case is appropriate. | ||
1149 | */ | ||
1150 | struct shrinker { | ||
1151 | int (*shrink)(struct shrinker *, struct shrink_control *sc); | ||
1152 | int seeks; /* seeks to recreate an obj */ | ||
1153 | long batch; /* reclaim batch size, 0 = default */ | ||
1154 | |||
1155 | /* These are for internal use */ | ||
1156 | struct list_head list; | ||
1157 | long nr; /* objs pending delete */ | ||
1158 | }; | ||
1159 | #define DEFAULT_SEEKS 2 /* A good number if you don't know better. */ | ||
1160 | extern void register_shrinker(struct shrinker *); | ||
1161 | extern void unregister_shrinker(struct shrinker *); | ||
1162 | |||
1163 | int vma_wants_writenotify(struct vm_area_struct *vma); | 1125 | int vma_wants_writenotify(struct vm_area_struct *vma); |
1164 | 1126 | ||
1165 | extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr, | 1127 | extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr, |
diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h new file mode 100644 index 000000000000..790651b4e5ba --- /dev/null +++ b/include/linux/shrinker.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #ifndef _LINUX_SHRINKER_H | ||
2 | #define _LINUX_SHRINKER_H | ||
3 | |||
4 | /* | ||
5 | * This struct is used to pass information from page reclaim to the shrinkers. | ||
6 | * We consolidate the values for easier extention later. | ||
7 | */ | ||
8 | struct shrink_control { | ||
9 | gfp_t gfp_mask; | ||
10 | |||
11 | /* How many slab objects shrinker() should scan and try to reclaim */ | ||
12 | unsigned long nr_to_scan; | ||
13 | }; | ||
14 | |||
15 | /* | ||
16 | * A callback you can register to apply pressure to ageable caches. | ||
17 | * | ||
18 | * 'sc' is passed shrink_control which includes a count 'nr_to_scan' | ||
19 | * and a 'gfpmask'. It should look through the least-recently-used | ||
20 | * 'nr_to_scan' entries and attempt to free them up. It should return | ||
21 | * the number of objects which remain in the cache. If it returns -1, it means | ||
22 | * it cannot do any scanning at this time (eg. there is a risk of deadlock). | ||
23 | * | ||
24 | * The 'gfpmask' refers to the allocation we are currently trying to | ||
25 | * fulfil. | ||
26 | * | ||
27 | * Note that 'shrink' will be passed nr_to_scan == 0 when the VM is | ||
28 | * querying the cache size, so a fastpath for that case is appropriate. | ||
29 | */ | ||
30 | struct shrinker { | ||
31 | int (*shrink)(struct shrinker *, struct shrink_control *sc); | ||
32 | int seeks; /* seeks to recreate an obj */ | ||
33 | long batch; /* reclaim batch size, 0 = default */ | ||
34 | |||
35 | /* These are for internal use */ | ||
36 | struct list_head list; | ||
37 | long nr; /* objs pending delete */ | ||
38 | }; | ||
39 | #define DEFAULT_SEEKS 2 /* A good number if you don't know better. */ | ||
40 | extern void register_shrinker(struct shrinker *); | ||
41 | extern void unregister_shrinker(struct shrinker *); | ||
42 | #endif | ||