mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Phillips <phillips@arcor.de>
To: Jamie Lokier <lk@tantalophile.demon.co.uk>
Cc: Alexander Viro <viro@math.psu.edu>,
	Rusty Russell <rusty@rustcorp.com.au>,
	linux-kernel@vger.kernel.org
Subject: Re: Question about pseudo filesystems
Date: Tue, 10 Sep 2002 05:47:21 +0200	[thread overview]
Message-ID: <E17obzl-0006yI-00@starship> (raw)
In-Reply-To: <20020910042622.A6616@kushida.apsleyroad.org>

On Tuesday 10 September 2002 05:26, Jamie Lokier wrote:
> Daniel Phillips wrote:
> > Locking
> > has been arranged by module.c such that this won't increase during the
> > course of the cleanup_module call.  The module exit routine does:
> > 
> > 	if (module->count)
> > 		return module->count;
> > 
> > 	return clean_up_whatever();
> 
> If any code within the module does `MOD_DEC_USE_COUNT; return;', you
> have a race condition.
> 
> That's why nowadays you shouldn't see this.  The main reference points
> to a module are either function calls from another module (already count
> as references), or a file/filesystem/blockdev/netdevice: these all have
> an `owner' field now, so that the MOD_DEC_USE_COUNT can take place
> outside their modules.

Thanks for telling me this, but I know it.  The manner in which the
module use count is protected is completely irrelvant to the code I
showed.  The cleanup_module just knows the count is protected and
stable.

> If you do still see MOD_DEC_USE_COUNT in a module, then there's a race
> condition.  Some task calls the function which does MOD_DEC_USE_COUNT,
> and some _other_ task calls sys_delete_module().  Lo, the module is
> cleaned up and destroyed by the second task while it's in the small
> window just before `return' in the first task.
> 
> Given that, you need to either (a) not call MOD_DEC_USE_COUNT in the
> module, and use the `owner' fields of various structures instead, or (b)
> something quite clever involving a quiescent state and some flags.
> 
> Note that (b) is not trivial, as you can't just do
> `wait_for_quiescent_state()' followed by `if (module->count)': it's
> possible that someone may call MOD_INC_USE_COUNT after the quiescent
> state has passed, but before you finish cleaning up.

You promised to find a race or some other deficiency in my code and
you pointed out some other interesting, but incidental fact.

If you look at my code snippet for cleanup_module, you'll see it
doesn't decrement anything, though it could if it wanted to, because
it's called under protection provided by module.c.

The way the module keeps track of its unloadable/not unloadable
state is up to it, which makes sense, n'est-ce pas?  Given that
there is no way you can make the MOD_DEC_USE_COUNT concept work
for SCM, for example.

There is in fact no choice other than to bite the bullet and
implement some form of magic_wait_for_quiescent_state(), however
hard that may be, to be used in the cases where some precise
accounting method simply isn't possible.  The alternative is to
forbid unloading of some types of modules, and I hope you
realize what kind of criticism that would invite.

Anyway, solutions to the difficulties are known.  We are simply
quibbling over whether we should use an obscure interface or a
simple, transparent one.

-- 
Daniel

  reply	other threads:[~2002-09-10  3:40 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-04 18:02 Jamie Lokier
2002-09-07 12:00 ` Daniel Phillips
2002-09-07 13:36   ` Alexander Viro
2002-09-07 18:27     ` Jamie Lokier
2002-09-07 19:47       ` Alexander Viro
2002-09-08  2:21         ` Jamie Lokier
2002-09-08  2:43           ` Alexander Viro
2002-09-15  1:41             ` Moving a mount point (was Re: Question about pseudo filesystems) Rob Landley
2002-09-08 16:00           ` Question about pseudo filesystems Daniel Phillips
2002-09-09 19:48             ` Jamie Lokier
2002-09-09 20:06               ` Daniel Phillips
2002-09-10  0:44                 ` Jamie Lokier
2002-09-10  1:40                   ` Daniel Phillips
2002-09-10  1:56                     ` Jamie Lokier
2002-09-10  2:53                       ` Daniel Phillips
2002-09-10  3:26                         ` Jamie Lokier
2002-09-10  3:47                           ` Daniel Phillips [this message]
2002-09-10  9:15                   ` Daniel Phillips
2002-09-10 10:17                     ` Roman Zippel
2002-09-11 18:35                       ` [RFC] Raceless module interface Daniel Phillips
2002-09-11 18:53                         ` Oliver Neukum
2002-09-11 19:20                           ` Daniel Phillips
2002-09-11 20:29                             ` Oliver Neukum
2002-09-11 21:15                               ` Daniel Phillips
2002-09-11 21:26                                 ` Jamie Lokier
2002-09-11 21:47                                   ` Daniel Phillips
2002-09-12  1:42                                     ` Rusty Russell
2002-09-12  2:09                                       ` Jamie Lokier
2002-09-12  3:13                                         ` Rusty Russell
2002-09-12  3:47                                           ` Daniel Phillips
2002-09-12  3:53                                             ` Alexander Viro
2002-09-12  4:11                                               ` Daniel Phillips
2002-09-12  4:40                                                 ` Rusty Russell
2002-09-12  5:27                                                   ` Daniel Phillips
2002-09-12 14:46                                                   ` Gerhard Mack
2002-09-13  0:39                                                     ` Rusty Russell
2002-09-13  2:23                                                       ` Daniel Phillips
2002-09-12  5:35                                                 ` Rusty Russell
2002-09-12  4:52                                             ` Rusty Russell
2002-09-12  5:58                                               ` Daniel Phillips
2002-09-12  7:00                                                 ` Rusty Russell
2002-09-13  8:18                                           ` Helge Hafting
2002-09-12  3:32                                         ` Daniel Phillips
2002-09-12  1:31                         ` Rusty Russell
2002-09-12  9:10                         ` Oliver Neukum
2002-09-12 11:27                         ` Roman Zippel
2002-09-12 13:03                           ` Rusty Russell
2002-09-12 13:44                             ` Roman Zippel
2002-09-13  1:30                               ` Rusty Russell
2002-09-13  2:19                                 ` Daniel Phillips
2002-09-13  6:51                                   ` Rusty Russell
2002-09-13 13:34                                     ` Daniel Phillips
2002-09-13 13:52                                       ` Thunder from the hill
2002-09-13 14:09                                         ` Daniel Phillips
2002-09-13 14:33                                           ` Thunder from the hill
2002-09-13 14:44                                             ` Daniel Phillips
2002-09-13 14:59                                               ` Thunder from the hill
2002-09-13 15:17                                                 ` Daniel Phillips
2002-09-13 15:27                                                   ` Thunder from the hill
2002-09-13 15:37                                                     ` Daniel Phillips
2002-09-16  2:17                                       ` Rusty Russell
2002-09-16 16:13                                         ` Daniel Phillips
2002-09-16 16:36                                         ` Understanding the Principles of Argumentation #3 Daniel Phillips
2002-09-16 16:42                                           ` Robinson Maureira Castillo
2002-09-16 17:29                                           ` Cort Dougan
2002-09-16 22:31                                         ` David Woodhouse
2002-10-01 14:13                                           ` Daniel Phillips
2002-10-01 14:27                                           ` David Woodhouse
2002-09-13 15:59                                     ` [RFC] Raceless module interface Daniel Phillips
2002-09-13  3:14                                 ` David Gibson
2002-09-13 10:35                                 ` Roman Zippel
2002-09-13 13:53                                   ` Daniel Phillips
2002-09-13 15:13                                     ` Roman Zippel
2002-09-13 15:30                                       ` Daniel Phillips
2002-09-13 15:55                                         ` Roman Zippel
2002-09-13 16:09                                           ` Daniel Phillips
2002-09-13 16:39                                         ` Thunder from the hill
2002-09-13 17:12                                           ` Daniel Phillips
2002-09-16  0:24                                         ` Bill Davidsen
2002-09-16  1:49                                   ` Rusty Russell
2002-09-16 21:36                                     ` Roman Zippel
2002-09-16 21:48                                       ` Daniel Phillips
2002-09-16 22:44                                         ` Roman Zippel
2002-09-11 15:28                 ` Question about pseudo filesystems Bill Davidsen
2002-09-11 19:36                   ` Daniel Phillips
2002-09-09 20:12               ` Daniel Phillips
2002-09-09 22:56                 ` Jamie Lokier
2002-09-10  1:39                   ` Alexander Viro
2002-09-09 20:18               ` Daniel Phillips
2002-09-10  6:48                 ` Kai Henningsen

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=E17obzl-0006yI-00@starship \
    --to=phillips@arcor.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lk@tantalophile.demon.co.uk \
    --cc=rusty@rustcorp.com.au \
    --cc=viro@math.psu.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

all inboxes | Powered by JetHome®