From: Pavel Machek <pavel@ucw.cz>
To: Keith Owens <kaos@ocs.com.au>
Cc: Linux-Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: simple handling of module removals Re: [OKS] Module removal
Date: Mon, 8 Jul 2002 20:13:31 +0200 [thread overview]
Message-ID: <20020708181331.GD28335@atrey.karlin.mff.cuni.cz> (raw)
In-Reply-To: <9171.1026053813@ocs3.intra.ocs.com.au>
Hi!
> >> Modules can run their own kernel threads. When the module shuts down
> >> it terminates the threads but we must wait until the process entries
> >> for the threads have been reaped. If you are not careful, the zombie
> >> clean up code can refer to the module that no longer exists. You must
> >> not freeze any threads that belong to the module.
> >
> >Look at the code. freezer will try for 5 seconds, then give up. So, in
> >rare case module has some threads, rmmod will simply fail. I believe
> >we can fix rare remaining modules one by one.
>
> There is no failure path for rmmod. Once rmmod sees a use count of 0,
> it must succeed. Which is why both Rusty and I agree that rmmod must
> be split in two, one piece that is allowed to fail and a second piece
> that is not.
>
> BTW, freeze_processes() silently ignores zombie processes. The test is
> not obvious, it is hidden in the INTERESTING macro which has an
> embedded 'continue' to break out of the loop. Easy to miss.
Is there problems? Zombie processes are basically dead, not
interesting, processes.
> >> You must not freeze any process that has entered the module but not yet
> >> incremented the use count, nor any process that has decremented the use
> >> count but not yet left the module. Simply looking at the EIP after
> >
> >Look how freezer works. refrigerator() is blocking, by definition. So
> >if all processes reach refrigerator(), and the use count == 0, it is
> >indeed safe to unload.
>
> freeze_processes()
> signal_wake_up() - sets TIF_SIGPENDING for other task
> kick_if_running()
> resched_task() - calls preempt_disable() for this cpu
> smp_send_reschedule()
> smp_reschedule_interrupt() - now on another cpu
> ret_from_intr
> resume_kernel - on other cpu
>
> With CONFIG_PREEMPT, a process running on another cpu without a lock
> when freeze_processes() is called should immediately end up in
> schedule. I don't see anything in that code path that disables
> preemption on other cpus. If I am right, then a second cpu could be in
> this window when freeze_processes is called
>
> if (xxx->func)
> xxx->func()
okay, so we have
if (xxx->func)
interrupt
schedule()
but schedule at this point is certainly not going to enter signal
handling code, so refrigerator is deffered at run to userspace, so it
continues with
interrupt return
xxx->func()
...
attempt to return to userspace
signal code
refrigerator().
So I believe that is safe.
> where func is a module function. There is still a window from loading
> the function address, through calling the function and up to the point
> where the function does MOD_INC_USE_COUNT. Any reschedule in that
> window opens a race with rmmod. Without preemption, freeze might be
> safe, with preemption the race is back again.
Pavel
--
Casualities in World Trade Center: ~3k dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.
next prev parent reply other threads:[~2002-07-08 18:10 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-01 17:48 Bill Davidsen
2002-07-01 18:35 ` Richard B. Johnson
2002-07-01 18:42 ` Jose Luis Domingo Lopez
2002-07-01 18:45 ` Shawn
2002-07-01 19:57 ` Diego Calleja
2002-07-01 20:03 ` Diego Calleja
2002-07-01 22:20 ` Jose Luis Domingo Lopez
2002-07-01 22:56 ` Ryan Anderson
2002-07-02 11:37 ` Stephen C. Tweedie
2002-07-02 12:04 ` Richard B. Johnson
2002-07-02 13:13 ` jlnance
2002-07-03 3:48 ` simple handling of module removals " Pavel Machek
2002-07-03 17:25 ` Richard B. Johnson
2002-07-03 23:46 ` Daniel Phillips
2002-07-08 12:21 ` Richard B. Johnson
2002-07-08 12:41 ` Thunder from the hill
2002-07-08 12:57 ` Richard B. Johnson
2002-07-08 13:58 ` Thunder from the hill
2002-07-08 15:48 ` Daniel Gryniewicz
2002-07-08 17:23 ` Thunder from the hill
2002-07-08 13:06 ` Keith Owens
2002-07-08 13:15 ` Keith Owens
2002-07-03 23:48 ` Daniel Phillips
2002-07-05 9:40 ` Stephen Tweedie
2002-07-06 19:40 ` Daniel Phillips
2002-07-06 19:47 ` Pavel Machek
2002-07-04 1:18 ` Keith Owens
2002-07-04 1:53 ` Andrew Morton
2002-07-04 4:00 ` Keith Owens
2002-07-04 2:25 ` Brian Gerst
2002-07-04 3:54 ` David Gibson
2002-07-04 4:08 ` Keith Owens
2002-07-04 15:02 ` Brian Gerst
2002-07-04 19:18 ` Werner Almesberger
2002-07-05 13:48 ` Pavel Machek
2002-07-07 14:56 ` Keith Owens
2002-07-07 22:36 ` Roman Zippel
2002-07-08 1:09 ` Daniel Mose
2002-07-09 17:07 ` Daniel Mose
2002-07-08 18:13 ` Pavel Machek [this message]
2002-07-08 22:43 ` Keith Owens
2002-07-09 14:00 ` Pavel Machek
2002-07-02 15:20 ` Bill Davidsen
2002-07-02 15:53 ` Jonathan Corbet
2002-07-02 16:07 ` Oliver Neukum
2002-07-02 17:48 ` Tom Rini
2002-07-02 18:10 ` Oliver Neukum
2002-07-02 21:50 ` Ryan Anderson
2002-07-03 22:26 ` Diego Calleja
2002-07-04 0:00 ` Keith Owens
2002-07-04 8:04 ` Helge Hafting
2002-07-02 16:08 ` Werner Almesberger
[not found] ` <Pine.LNX.3.95.1020702075957.24872A-100000@chaos.analogic.c om>
2002-07-04 8:36 ` Mike Galbraith
2002-07-03 0:09 ` Vojtech Pavlik
2002-07-12 21:51 ` David Lang
[not found] <0C01A29FBAE24448A792F5C68F5EA47D2B0A8A@nasdaq.ms.ensim.com>
2002-07-04 0:29 ` simple handling of module removals " pmenage
2002-07-04 0:59 ` Daniel Phillips
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=20020708181331.GD28335@atrey.karlin.mff.cuni.cz \
--to=pavel@ucw.cz \
--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®