aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/shrinker.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/shrinker.h')
-rw-r--r--include/linux/shrinker.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h
new file mode 100644
index 00000000000..a83833a1f7a
--- /dev/null
+++ b/include/linux/shrinker.h
@@ -0,0 +1,43 @@
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 */
8struct 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 * The callback must not return -1 if nr_to_scan is zero.
24 *
25 * The 'gfpmask' refers to the allocation we are currently trying to
26 * fulfil.
27 *
28 * Note that 'shrink' will be passed nr_to_scan == 0 when the VM is
29 * querying the cache size, so a fastpath for that case is appropriate.
30 */
31struct shrinker {
32 int (*shrink)(struct shrinker *, struct shrink_control *sc);
33 int seeks; /* seeks to recreate an obj */
34 long batch; /* reclaim batch size, 0 = default */
35
36 /* These are for internal use */
37 struct list_head list;
38 long nr; /* objs pending delete */
39};
40#define DEFAULT_SEEKS 2 /* A good number if you don't know better. */
41extern void register_shrinker(struct shrinker *);
42extern void unregister_shrinker(struct shrinker *);
43#endif