File: [Development] / linux-2.4-xfs / split-patches / cache_defs (download)
Revision 1.4, Thu Jan 20 13:59:19 2005 UTC (12 years, 9 months ago) by nathans.longdrop.melbourne.sgi.com
Branch: MAIN
Changes since 1.3: +7 -7
lines
Merge up to 2.4.29.
Merge of 2.4.x-xfs-melb:linux:21231a by kenmcd.
|
Index: 2.4.x-xfs/include/linux/cache_def.h
===================================================================
--- 2.4.x-xfs.orig/include/linux/cache_def.h 1970-01-01 10:00:00.000000000 +1000
+++ 2.4.x-xfs/include/linux/cache_def.h 2005-01-20 16:24:44.000000000 +1100
@@ -0,0 +1,19 @@
+/*
+ * linux/cache_def.h
+ * Handling of caches defined in drivers, filesystems, ...
+ *
+ * Copyright (C) 2002 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
+ */
+#ifndef _LINUX_CACHE_DEF_H
+#define _LINUX_CACHE_DEF_H
+
+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 *);
+
+#endif /* _LINUX_CACHE_DEF_H */
Index: 2.4.x-xfs/mm/Makefile
===================================================================
--- 2.4.x-xfs.orig/mm/Makefile 2004-11-22 13:47:15.000000000 +1100
+++ 2.4.x-xfs/mm/Makefile 2005-01-20 16:24:44.000000000 +1100
@@ -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 2005-01-20 16:15:43.000000000 +1100
+++ 2.4.x-xfs/mm/vmscan.c 2005-01-20 16:24:44.000000000 +1100
@@ -23,10 +23,61 @@
#include <linux/init.h>
#include <linux/highmem.h>
#include <linux/file.h>
+#include <linux/module.h>
+#include <linux/cache_def.h>
#include <asm/pgalloc.h>
/*
+ * Handling of caches defined in drivers, filesystems, ...
+ * The cache_definition contains a callback for shrinking the cache.
+ */
+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);
+}
+
+static 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);
+}
+
+/*
* "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
@@ -538,12 +589,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);