From: Andrew Morton <akpm@osdl.org>
To: thockin@sun.com
Cc: torvalds@osdl.org, viro@parcelfarce.linux.theplanet.co.uk,
linux-kernel@vger.kernel.org
Subject: Re: PATCH - raise max_anon limit
Date: Wed, 11 Feb 2004 13:53:25 -0800 [thread overview]
Message-ID: <20040211135325.7b4b5020.akpm@osdl.org> (raw)
In-Reply-To: <20040211210930.GJ9155@sun.com>
Tim Hockin <thockin@sun.com> wrote:
>
> > I'd suggest just raising it to 64k or so, that's likely to be acceptable,
> > and it's a static 8kB array. That's likely not much more than the code
> > needed to worry about dynamic entries, yet I'd assume that changing it
> > from 256 to 64k is going to make most people say "enough".
>
> How's this then? It doesn't get any simpler..
Well it is lazy, wastes 0.4% of a 2M machine's memory and still has a
hard-wired limit.
Wanna test this?
25-akpm/fs/super.c | 38 +++++++++++++++++++++++---------------
1 files changed, 23 insertions(+), 15 deletions(-)
diff -puN fs/super.c~max_anon-use-idr fs/super.c
--- 25/fs/super.c~max_anon-use-idr Wed Feb 11 13:41:57 2004
+++ 25-akpm/fs/super.c Wed Feb 11 13:50:16 2004
@@ -23,6 +23,8 @@
#include <linux/config.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/init.h>
+#include <asm/semaphore.h>
#include <linux/smp_lock.h>
#include <linux/acct.h>
#include <linux/blkdev.h>
@@ -33,6 +35,7 @@
#include <linux/security.h>
#include <linux/vfs.h>
#include <linux/writeback.h> /* for the emergency remount stuff */
+#include <linux/idr.h>
#include <asm/uaccess.h>
@@ -536,38 +539,43 @@ void emergency_remount(void)
* filesystems which don't use real block-devices. -- jrs
*/
-enum {Max_anon = 256};
-static unsigned long unnamed_dev_in_use[Max_anon/(8*sizeof(unsigned long))];
-static spinlock_t unnamed_dev_lock = SPIN_LOCK_UNLOCKED;/* protects the above */
+static struct idr unnamed_dev_idr;
+static DECLARE_MUTEX(unnamed_dev_sem);
int set_anon_super(struct super_block *s, void *data)
{
int dev;
- spin_lock(&unnamed_dev_lock);
- dev = find_first_zero_bit(unnamed_dev_in_use, Max_anon);
- if (dev == Max_anon) {
- spin_unlock(&unnamed_dev_lock);
- return -EMFILE;
+
+ down(&unnamed_dev_sem);
+ if (idr_pre_get(&unnamed_dev_idr) == 0) {
+ up(&unnamed_dev_sem);
+ return -ENOMEM;
}
- set_bit(dev, unnamed_dev_in_use);
- spin_unlock(&unnamed_dev_lock);
+ dev = idr_get_new(&unnamed_dev_idr, NULL);
+ up(&unnamed_dev_sem);
s->s_dev = MKDEV(0, dev);
return 0;
}
-
EXPORT_SYMBOL(set_anon_super);
void kill_anon_super(struct super_block *sb)
{
int slot = MINOR(sb->s_dev);
+
generic_shutdown_super(sb);
- spin_lock(&unnamed_dev_lock);
- clear_bit(slot, unnamed_dev_in_use);
- spin_unlock(&unnamed_dev_lock);
+ down(&unnamed_dev_sem);
+ idr_remove(&unnamed_dev_idr, slot);
+ up(&unnamed_dev_sem);
}
-
EXPORT_SYMBOL(kill_anon_super);
+static int __init unnamed_dev_idr_init(void)
+{
+ idr_init(&unnamed_dev_idr);
+ return 0;
+}
+core_initcall(unnamed_dev_idr_init);
+
void kill_litter_super(struct super_block *sb)
{
if (sb->s_root)
_
next prev parent reply other threads:[~2004-02-11 21:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-06 22:15 Tim Hockin
2004-02-07 8:55 ` Andrew Morton
2004-02-07 9:48 ` viro
2004-02-11 20:33 ` Tim Hockin
2004-02-11 20:38 ` Linus Torvalds
2004-02-11 21:09 ` Tim Hockin
2004-02-11 21:53 ` Andrew Morton [this message]
2004-02-11 22:28 ` Tim Hockin
2004-02-11 22:48 ` Andrew Morton
[not found] ` <20040211233852.GN9155@sun.com>
[not found] ` <20040211155754.5068332c.akpm@osdl.org>
[not found] ` <20040212003840.GO9155@sun.com>
[not found] ` <20040211164233.5f233595.akpm@osdl.org>
2004-02-12 1:08 ` Tim Hockin
2004-02-12 1:20 ` Andrew Morton
2004-02-12 2:22 ` Tim Hockin
2004-02-12 17:26 ` Jim Houston
2004-02-12 18:49 ` Tim Hockin
2004-02-13 2:01 ` Jamie Lokier
2004-02-12 22:03 ` Andrew Morton
2004-02-13 1:12 ` George Anzinger
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=20040211135325.7b4b5020.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thockin@sun.com \
--cc=torvalds@osdl.org \
--cc=viro@parcelfarce.linux.theplanet.co.uk \
/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
all inboxes | Powered by JetHome®