From: Paul Jackson <pj@sgi.com>
To: Simon Derr <Simon.Derr@bull.net>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [Patch] cpusets: fix race in cpuset_add_file()
Date: Fri, 17 Sep 2004 00:22:32 -0700 [thread overview]
Message-ID: <20040917002232.7b4135f5.pj@sgi.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0409161715550.5423@openx3.frec.bull.fr>
You can continue to ignore this patch, Andrew. I'm still thinking it
through with Simon.
Here's another possible way to skin this cat, Simon.
Instead of adding an inode lock, how about just extending the cpuset_sem
window. If we hold cpuset_sem for the entire cpuset_mkdir() operation,
then no other cpuset_mkdir can overlap, and there should be no
confused overlapping directory creations.
This reduces the risks of unrecognized A-B-A deadlocks, and it removes
the concern I have that dropping the cpuset_sem before we're done opens
the way for more inconsistencies.
This needs to be tested before it goes in - there is a non-zero risk
that I made a stupid mistake and it locks up or something.
Signed-off-by: Paul Jackson <pj@sgi.com>
Index: 2.6.9-rc2-mm1/kernel/cpuset.c
===================================================================
--- 2.6.9-rc2-mm1.orig/kernel/cpuset.c 2004-09-16 23:46:01.000000000 -0700
+++ 2.6.9-rc2-mm1/kernel/cpuset.c 2004-09-17 00:19:02.000000000 -0700
@@ -1235,7 +1235,6 @@ static long cpuset_create(struct cpuset
if (!cs)
return -ENOMEM;
- down(&cpuset_sem);
cs->flags = 0;
if (notify_on_release(parent))
set_bit(CS_NOTIFY_ON_RELEASE, &cs->flags);
@@ -1256,22 +1255,23 @@ static long cpuset_create(struct cpuset
goto err;
err = cpuset_populate_dir(cs->dentry);
/* If err < 0, we have a half-filled directory - oh well ;) */
- up(&cpuset_sem);
return 0;
err:
list_del(&cs->sibling);
- up(&cpuset_sem);
kfree(cs);
return err;
}
static int cpuset_mkdir(struct inode *dir, struct dentry *dentry, int mode)
{
- struct dentry *d_parent = dentry->d_parent;
- struct cpuset *c_parent = (struct cpuset *)d_parent->d_fsdata;
+ struct cpuset *c_parent;
+ int rc;
- /* the vfs holds inode->i_sem already */
- return cpuset_create(c_parent, dentry->d_name.name, mode | S_IFDIR);
+ down(&cpuset_sem);
+ c_parent = dentry->d_parent->d_fsdata;
+ rc = cpuset_create(c_parent, dentry->d_name.name, mode | S_IFDIR);
+ up(&cpuset_sem);
+ return rc;
}
static int cpuset_rmdir(struct inode *unused_dir, struct dentry *dentry)
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.650.933.1373
next prev parent reply other threads:[~2004-09-17 7:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-16 1:29 [Patch] cpusets: document proc status allowed fields Paul Jackson
2004-09-16 14:01 ` [Patch] cpusets: fix race in cpuset_add_file() Simon Derr
2004-09-16 14:55 ` Paul Jackson
2004-09-16 15:39 ` Simon Derr
2004-09-16 16:03 ` Paul Jackson
2004-09-17 7:22 ` Paul Jackson [this message]
2004-09-17 7:55 ` Simon Derr
2004-09-17 9:10 ` Paul Jackson
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=20040917002232.7b4135f5.pj@sgi.com \
--to=pj@sgi.com \
--cc=Simon.Derr@bull.net \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.