aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mm.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/mm.h')
-rw-r--r--include/linux/mm.h38
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 *
823typedef 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 */
827struct 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 */
831struct shrinker; 832 struct list_head list;
832extern struct shrinker *set_shrinker(int, shrinker_t); 833 long nr; /* objs pending delete */
833extern void remove_shrinker(struct shrinker *shrinker); 834};
835#define DEFAULT_SEEKS 2 /* A good number if you don't know better. */
836extern void register_shrinker(struct shrinker *);
837extern 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