LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Alexey Dobriyan <adobriyan@openvz.org>
Cc: viro@ftp.linux.org.uk, linux-kernel@vger.kernel.org,
duncan.sands@math.u-psud.fr
Subject: Re: [PATCH v3] Fix rmmod/read/write races in /proc entries
Date: Fri, 9 Feb 2007 01:00:37 -0800 [thread overview]
Message-ID: <20070209010037.7f4393c5.akpm@linux-foundation.org> (raw)
In-Reply-To: <20070208132012.GA6041@localhost.sw.ru>
On Thu, 8 Feb 2007 16:20:12 +0300 Alexey Dobriyan <adobriyan@openvz.org> wrote:
> +again:
> spin_lock(&proc_subdir_lock);
> for (p = &parent->subdir; *p; p=&(*p)->next ) {
> if (!proc_match(len, fn, *p))
> continue;
> de = *p;
> +
> + /*
> + * Stop accepting new readers/writers. If you're dynamically
> + * allocating ->proc_fops, save a pointer somewhere.
> + */
> + spin_lock(&de->pde_unload_lock);
> + de->proc_fops = NULL;
> + /* Wait until all readers/writers are done. */
> + if (de->pde_users > 0) {
> + spin_unlock(&de->pde_unload_lock);
> + spin_unlock(&proc_subdir_lock);
> + schedule();
> + goto again;
> + }
> + spin_unlock(&de->pde_unload_lock);
aergh. This will devolve into busy-wait-until-we-expire-our-timeslice.
Would be nicer to do this with a wait_for_completion().
I guess it doesn't happen very often - if another process happens to
be in the middle or a read or write syscall to that /proc file.
next prev parent reply other threads:[~2007-02-09 9:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-08 13:20 Alexey Dobriyan
2007-02-09 9:00 ` Andrew Morton [this message]
2007-02-11 20:23 ` [PATCH v4] " Alexey Dobriyan
2007-02-11 20:34 ` Al Viro
2007-02-13 6:35 ` Andrew Morton
2007-02-13 16:16 ` Alexey Dobriyan
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=20070209010037.7f4393c5.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=adobriyan@openvz.org \
--cc=duncan.sands@math.u-psud.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ftp.linux.org.uk \
--subject='Re: [PATCH v3] Fix rmmod/read/write races in /proc entries' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).