| 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 |
|
| 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;
|
| 33 | long batch;
|
| 34 |
|
| 35 |
|
| 36 | struct list_head list;
|
| 37 | atomic_long_t nr_in_batch;
|
| 38 | };
|
| 39 | #define DEFAULT_SEEKS 2
|
| 40 | extern void register_shrinker(struct shrinker *);
|
| 41 | extern void unregister_shrinker(struct shrinker *);
|
| 42 | #endif
|