diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2007-07-17 07:03:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-17 13:23:00 -0400 |
commit | 8e1f936b73150f5095448a0fee6d4f30a1f9001d (patch) | |
tree | 0996203e35c629e2ec243d128c7bd91ecd74d24a /include | |
parent | 5ad333eb66ff1e52a87639822ae088577669dcf9 (diff) |
mm: clean up and kernelify shrinker registration
I can never remember what the function to register to receive VM pressure
is called. I have to trace down from __alloc_pages() to find it.
It's called "set_shrinker()", and it needs Your Help.
1) Don't hide struct shrinker. It contains no magic.
2) Don't allocate "struct shrinker". It's not helpful.
3) Call them "register_shrinker" and "unregister_shrinker".
4) Call the function "shrink" not "shrinker".
5) Reduce the 17 lines of waffly comments to 13, but document it properly.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: David Chinner <dgc@sgi.com>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/mm.h | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 97d0cddfd223..4c482a3ee870 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -810,27 +810,31 @@ extern unsigned long do_mremap(unsigned long addr, | |||
810 | unsigned long flags, unsigned long new_addr); | 810 | unsigned long flags, unsigned long new_addr); |
811 | 811 | ||
812 | /* | 812 | /* |
813 | * Prototype to add a shrinker callback for ageable caches. | 813 | * A callback you can register to apply pressure to ageable caches. |
814 | * | ||
815 | * These functions are passed a count `nr_to_scan' and a gfpmask. They should | ||
816 | * scan `nr_to_scan' objects, attempting to free them. | ||
817 | * | 814 | * |
818 | * The callback must return the number of objects which remain in the cache. | 815 | * 'shrink' is passed a count 'nr_to_scan' and a 'gfpmask'. It should |
816 | * look through the least-recently-used 'nr_to_scan' entries and | ||
817 | * attempt to free them up. It should return the number of objects | ||
818 | * which remain in the cache. If it returns -1, it means it cannot do | ||
819 | * any scanning at this time (eg. there is a risk of deadlock). | ||
819 | * | 820 | * |
820 | * The callback will be passed nr_to_scan == 0 when the VM is querying the | 821 | * The 'gfpmask' refers to the allocation we are currently trying to |
821 | * cache size, so a fastpath for that case is appropriate. | 822 | * fulfil. |
822 | */ | 823 | * |
823 | typedef int (*shrinker_t)(int nr_to_scan, gfp_t gfp_mask); | 824 | * Note that 'shrink' will be passed nr_to_scan == 0 when the VM is |
824 | 825 | * querying the cache size, so a fastpath for that case is appropriate. | |
825 | /* | ||
826 | * Add an aging callback. The int is the number of 'seeks' it takes | ||
827 | * to recreate one of the objects that these functions age. | ||
828 | */ | 826 | */ |
827 | struct shrinker { | ||
828 | int (*shrink)(int nr_to_scan, gfp_t gfp_mask); | ||
829 | int seeks; /* seeks to recreate an obj */ | ||
829 | 830 | ||
830 | #define DEFAULT_SEEKS 2 | 831 | /* These are for internal use */ |
831 | struct shrinker; | 832 | struct list_head list; |
832 | extern struct shrinker *set_shrinker(int, shrinker_t); | 833 | long nr; /* objs pending delete */ |
833 | extern void remove_shrinker(struct shrinker *shrinker); | 834 | }; |
835 | #define DEFAULT_SEEKS 2 /* A good number if you don't know better. */ | ||
836 | extern void register_shrinker(struct shrinker *); | ||
837 | extern void unregister_shrinker(struct shrinker *); | ||
834 | 838 | ||
835 | /* | 839 | /* |
836 | * Some shared mappigns will want the pages marked read-only | 840 | * Some shared mappigns will want the pages marked read-only |