mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Werner Almesberger <wa@almesberger.net>
To: Helge Hafting <helgehaf@aitel.hist.no>
Cc: Keith Owens <kaos@ocs.com.au>, linux-kernel@vger.kernel.org
Subject: Re: RE2: [OKS] Module removal
Date: Tue, 2 Jul 2002 13:22:23 -0300	[thread overview]
Message-ID: <20020702132223.H2295@almesberger.net> (raw)
In-Reply-To: <3D2169CB.73126A47@aitel.hist.no>; from helgehaf@aitel.hist.no on Tue, Jul 02, 2002 at 10:52:27AM +0200

Helge Hafting wrote:
> decrement_usecount will return to the module _if_ the count
> didn't reach 0.  If it does, it goes straight to whatever 
> usually happens after the module returns.

This looks appealing, but you still need an unconditional
"decrement_module_count_and_return", like I proposed earlier,
because multiple decrement_usecount could race with removal,
so you'd still hit removed code.

Example:

	...
	decrement_usecount();
	return; /* unsafe */
}

Now we have two CPUs executing this, and the third one will
remove the module.

Use count	CPU 1		CPU 2		CPU 3
    2		decrement	...		...
    1		return 1x	decrement	...
    0		-		return 2x	remove
    0		*CRASH*		...		...

The only case where decrement_usecount would work is if all
possible callers of decrement_usecount are serialized. I
can't think of any case where this is true, and just moving
the decrementing before the return(s) would improve anything
but perhaps the code structure, so I'm not sure if this would
be worth the potential and easily overlooked problems.

- Werner

-- 
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina         wa@almesberger.net /
/_http://icapeople.epfl.ch/almesber/_____________________________________/

      reply	other threads:[~2002-07-02 16:15 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-01 20:21 Michael Nguyen
2002-07-02  1:40 ` Werner Almesberger
2002-07-02  2:25   ` Keith Owens
2002-07-02  3:11     ` Werner Almesberger
2002-07-02  3:42       ` Keith Owens
2002-07-02  4:11         ` Werner Almesberger
2002-07-02 22:23         ` Alexander Viro
2002-07-09 19:23         ` Russ Lewis
2002-07-02  4:08     ` Brian Gerst
2002-07-02  4:53       ` Keith Owens
2002-07-02  5:43         ` Werner Almesberger
2002-07-02 16:36           ` Werner Almesberger
2002-07-02 16:50             ` Benjamin Herrenschmidt
2002-07-02 18:05               ` Werner Almesberger
2002-07-03  3:50               ` Pavel Machek
2002-07-04  4:11             ` Bill Davidsen
2002-07-04  6:29               ` Werner Almesberger
2002-07-04  6:50                 ` Werner Almesberger
2002-07-07 21:09                   ` Jamie Lokier
2002-07-07 21:41                     ` Oliver Neukum
2002-07-08  0:31                       ` Jamie Lokier
2002-07-08  6:42                         ` Oliver Neukum
2002-07-08  0:18                     ` Bill Davidsen
2002-07-08  0:46                       ` Jamie Lokier
2002-07-08  6:22                         ` Daniel Phillips
2002-07-08 10:16                           ` Bill Davidsen
2002-07-09  0:07                         ` Werner Almesberger
2002-07-09  0:27                           ` Keith Owens
2002-07-09  3:09                             ` Werner Almesberger
2002-07-09  6:25                             ` Roman Zippel
2002-07-09  8:59                               ` Kai Germaschewski
2002-07-09 11:06                                 ` Roman Zippel
2002-07-04 12:29                 ` Bill Davidsen
2002-07-09  1:50                 ` Kevin O'Connor
2002-07-09  2:37                   ` Werner Almesberger
2002-07-02 23:35         ` Alexander Viro
2002-07-02 22:41       ` RE2: " Alexander Viro
2002-07-02  8:52     ` Helge Hafting
2002-07-02 16:22       ` Werner Almesberger [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=20020702132223.H2295@almesberger.net \
    --to=wa@almesberger.net \
    --cc=helgehaf@aitel.hist.no \
    --cc=kaos@ocs.com.au \
    --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 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®