Index: 2.4.x-xfs/mm/Makefile
===================================================================
--- 2.4.x-xfs.orig/mm/Makefile Tue Apr 20 09:18:28 2004
+++ 2.4.x-xfs/mm/Makefile Mon May 3 17:33:57 2004
@@ -9,7 +9,7 @@
O_TARGET := mm.o
-export-objs := shmem.o filemap.o memory.o page_alloc.o
+export-objs := shmem.o filemap.o memory.o page_alloc.o vmscan.o
obj-y := memory.o mmap.o filemap.o mprotect.o mlock.o mremap.o \
vmalloc.o slab.o bootmem.o swap.o vmscan.o page_io.o \
Index: 2.4.x-xfs/mm/vmscan.c
===================================================================
--- 2.4.x-xfs.orig/mm/vmscan.c Tue Apr 20 09:18:29 2004
+++ 2.4.x-xfs/mm/vmscan.c Mon May 3 17:33:57 2004
@@ -18,15 +18,73 @@
#include <linux/kernel_stat.h>
#include <linux/swap.h>
#include <linux/swapctl.h>
+#include <linux/cache_def.h>
#include <linux/smp_lock.h>
#include <linux/pagemap.h>
#include <linux/init.h>
#include <linux/highmem.h>
#include <linux/file.h>
+#include <linux/module.h>
#include <asm/pgalloc.h>
/*
+ * Handling of caches defined in drivers, filesystems, ...
+ *
+ * The cache definition contains a callback for shrinking
+ * the cache.
+ *
+ * The [un]register_cache() functions may only be called when
+ * the kernel lock is held. The shrink() functions are also
+ * called with the kernel lock held.
+ */
+static DECLARE_MUTEX(other_caches_sem);
+static LIST_HEAD(other_caches);
+
+void register_cache(struct cache_definition *cache)
+{
+ down(&other_caches_sem);
+ list_add(&cache->link, &other_caches);
+ up(&other_caches_sem);
+}
+EXPORT_SYMBOL(register_cache);
+
+void unregister_cache(struct cache_definition *cache)
+{
+ down(&other_caches_sem);
+ list_del(&cache->link);
+ up(&other_caches_sem);
+}
+EXPORT_SYMBOL(unregister_cache);
+
+static void shrink_other_caches(int priority, unsigned int gfp_mask)
+{
+ struct list_head *p;
+
+ if (down_trylock(&other_caches_sem))
+ return;
+
+ list_for_each_prev(p, &other_caches) {
+ struct cache_definition *cache =
+ list_entry(p, struct cache_definition, link);
+
+ cache->shrink(priority, gfp_mask);
+ }
+ up(&other_caches_sem);
+}
+
+void shrink_slab_caches(int priority, unsigned int gfp_mask)
+{
+ shrink_dcache_memory(priority, gfp_mask);
+ shrink_icache_memory(priority, gfp_mask);
+#ifdef CONFIG_QUOTA
+ shrink_dqcache_memory(priority, gfp_mask);
+#endif
+ shrink_other_caches(priority, gfp_mask);
+}
+EXPORT_SYMBOL(shrink_other_caches);
+
+/*
* "vm_passes" is the number of vm passes before failing the
* memory balancing. Take into account 3 passes are needed
* for a flush/wait/free cycle and that we only scan 1/vm_cache_scan_ratio
@@ -517,12 +575,7 @@
nr_pages -= kmem_cache_reap(gfp_mask);
if (nr_pages <= 0)
goto out;
-
- shrink_dcache_memory(vm_vfs_scan_ratio, gfp_mask);
- shrink_icache_memory(vm_vfs_scan_ratio, gfp_mask);
-#ifdef CONFIG_QUOTA
- shrink_dqcache_memory(vm_vfs_scan_ratio, gfp_mask);
-#endif
+ shrink_slab_caches(vm_vfs_scan_ratio, gfp_mask);
if (!*failed_swapout)
*failed_swapout = !swap_out(classzone);
Index: 2.4.x-xfs/include/linux/cache_def.h
===================================================================
--- 2.4.x-xfs.orig/include/linux/cache_def.h Thu Jan 1 10:00:00 1970
+++ 2.4.x-xfs/include/linux/cache_def.h Mon May 3 17:33:57 2004
@@ -0,0 +1,17 @@
+/*
+ * linux/cache_def.h
+ * Handling of caches defined in drivers, filesystems, ...
+ *
+ * Copyright (C) 2002 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
+ */
+
+struct cache_definition {
+ const char *name;
+ int (*shrink)(int, unsigned int);
+ struct list_head link;
+};
+
+extern void register_cache(struct cache_definition *);
+extern void unregister_cache(struct cache_definition *);
+
+extern void shrink_slab_caches(int, unsigned int);