From: Andreas Gruenbacher <agruen@suse.de>
To: tytso@mit.edu
Cc: linux-kernel@vger.kernel.org, <ext2-devel@lists.sourceforge.net>,
Rik van Riel <riel@conectiva.com.br>
Subject: Re: [Ext2-devel] Re: [RFC] [PATCH 1/4] Add extended attributes to ext2/3
Date: Tue, 8 Oct 2002 20:59:21 +0200 [thread overview]
Message-ID: <200210082059.21556.agruen@suse.de> (raw)
In-Reply-To: <Pine.LNX.4.44L.0210081519490.1648-100000@duckman.distro.conectiva>
On Tuesday 08 October 2002 20:21, Rik van Riel wrote:
> On Tue, 8 Oct 2002 tytso@mit.edu wrote:
> > This first patch creates a generic interface for registering caches with
> > the VM subsystem so that they can react appropriately to memory
> > pressure.
> >
> > +/* BKL must be held */
>
> ... but it isn't. Also, kswapd isn't holding the bkl while
> traversing the list.
>
> > +void register_cache(struct cache_definition *cache)
> > +{
> > + list_add(&cache->link, &cache_definitions);
> > +}
>
> I suspect you'll want a semaphore for the cache_definitions
> list.
My apologies. This has slipped me; I had in fact added a semaphore in a
different branch. Here is a fixed version.
--Andreas.
diff -Nru a/include/linux/cache_def.h b/include/linux/cache_def.h
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/include/linux/cache_def.h Tue Oct 8 13:52:08 2002
@@ -0,0 +1,15 @@
+/*
+ * 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;
+ void (*shrink)(int, unsigned int);
+ struct list_head link;
+};
+
+extern void register_cache(struct cache_definition *);
+extern void unregister_cache(struct cache_definition *);
--- a/kernel/ksyms.c Tue Oct 8 13:52:08 2002
+++ b/kernel/ksyms.c Tue Oct 8 13:52:08 2002
@@ -31,6 +31,7 @@
#include <linux/genhd.h>
#include <linux/blkpg.h>
#include <linux/swap.h>
+#include <linux/cache_def.h>
#include <linux/ctype.h>
#include <linux/file.h>
#include <linux/iobuf.h>
@@ -106,6 +107,8 @@
EXPORT_SYMBOL(kmem_cache_alloc);
EXPORT_SYMBOL(kmem_cache_free);
EXPORT_SYMBOL(kmem_cache_size);
+EXPORT_SYMBOL(register_cache);
+EXPORT_SYMBOL(unregister_cache);
EXPORT_SYMBOL(kmalloc);
EXPORT_SYMBOL(kfree);
EXPORT_SYMBOL(vfree);
--- a/mm/vmscan.c Tue Oct 8 13:52:08 2002
+++ b/mm/vmscan.c Tue Oct 8 13:52:08 2002
@@ -15,6 +15,7 @@
#include <linux/slab.h>
#include <linux/kernel_stat.h>
#include <linux/swap.h>
+#include <linux/cache_def.h>
#include <linux/pagemap.h>
#include <linux/init.h>
#include <linux/highmem.h>
@@ -76,6 +77,39 @@
#define shrink_dqcache_memory(ratio, gfp_mask) do { } while (0)
#endif
+static DECLARE_MUTEX(other_caches_sem);
+static LIST_HEAD(cache_definitions);
+
+void register_cache(struct cache_definition *cache)
+{
+ down(&other_caches_sem);
+ list_add(&cache->link, &cache_definitions);
+ up(&other_caches_sem);
+}
+
+void unregister_cache(struct cache_definition *cache)
+{
+ down(&other_caches_sem);
+ list_del(&cache->link);
+ up(&other_caches_sem);
+}
+
+static void shrink_other_caches(int ratio, int gfp_mask)
+{
+ struct list_head *p;
+
+ down(&other_caches_sem);
+ p = cache_definitions.prev;
+ while (p != &cache_definitions) {
+ struct cache_definition *cache =
+ list_entry(p, struct cache_definition, link);
+
+ cache->shrink(ratio, gfp_mask);
+ p = p->prev;
+ }
+ up(&other_caches_sem);
+}
+
/* Must be called with page's pte_chain_lock held. */
static inline int page_mapping_inuse(struct page * page)
{
@@ -614,6 +648,7 @@
shrink_dcache_memory(ratio, gfp_mask);
shrink_icache_memory(ratio, gfp_mask);
shrink_dqcache_memory(ratio, gfp_mask);
+ shrink_other_caches(ratio, gfp_mask);
return nr_pages;
}
prev parent reply other threads:[~2002-10-08 18:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-08 18:08 [RFC] [PATCH 1/4] Add extended attributes to ext2/3 tytso
2002-10-08 18:19 ` [Ext2-devel] " Christoph Hellwig
2002-10-08 18:38 ` Andrew Morton
2002-10-08 18:47 ` Andreas Gruenbacher
2002-10-08 19:10 ` Rik van Riel
2002-10-10 6:56 ` Andrew Morton
2002-10-08 18:40 ` Theodore Ts'o
2002-10-08 18:50 ` Christoph Hellwig
2002-10-08 22:37 ` Ed Tomlinson
2002-10-08 18:21 ` Rik van Riel
2002-10-08 18:59 ` Andreas Gruenbacher [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200210082059.21556.agruen@suse.de \
--to=agruen@suse.de \
--cc=ext2-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=riel@conectiva.com.br \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox