public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Jonathan Corbet <corbet@lwn.net>,
	ebiederm@xmission.com, cornelia.huck@de.ibm.com, greg@kroah.com,
	kay.sievers@vrfy.org, linux-kernel@vger.kernel.org,
	rusty@rustcorp.com.au
Subject: Re: [PATCH 1/4] module: implement module_inhibit_unload()
Date: Wed, 26 Sep 2007 08:15:57 +0900	[thread overview]
Message-ID: <46F996AD.2070107@gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0709251105540.3909-100000@iolanthe.rowland.org>

Alan Stern wrote:
> On Tue, 25 Sep 2007, Tejun Heo wrote:
> 
>> Alan Stern wrote:
>>>> The unloading can proceed once module_unload_inhibit_cnt reaches zero.
>>>> An unloading thread only has to care about inhibition put in effect
>>>> before unloading has started, so there's no need to check again.
>>> You haven't fully answered Jon's question.  Suppose
>>> module_unload_inhibit_cnt is nonzero, so the task adds itself to the
>>> module_unload_wait queue, changes to TASK_UNINTERRUPTIBLE, and calls
>>> schedule.  There's nothing to prevent somebody else from waking the
>>> task back up before the original inhibition has been lifted.
>> Hmmm... I might be missing something here.  Who else can wake up a
>> thread in uninterruptible sleep?
> 
> In principle, anything can.  There has never been any guarantee in the 
> kernel that a task sleeping on a waitqueue will remain asleep until 
> the waitqueue is signalled.  That's part of the reason why things like 
> __wait_event() are coded as loops.

Hmmm... I always thought the queue was because the condition can change
inbetween waking up and actually running.  For example, if the condition
is !(queue empty), another task can enter the critical section and
consume the element which triggered wake up before the woken up task do.

I have no problem with changing the condition check to loop but it would
be great if someone can point me to a code where this unexpected wake up
is used.

Thanks.

-- 
tejun

  reply	other threads:[~2007-09-25 23:17 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-20  7:26 [PATCHSET 2/4] sysfs: allow suicide Tejun Heo
2007-09-20  7:26 ` [PATCH 1/4] module: implement module_inhibit_unload() Tejun Heo
2007-09-24 22:00   ` Jonathan Corbet
2007-09-24 23:18     ` Tejun Heo
2007-09-24 23:42       ` Rusty Russell
2007-09-25  1:40         ` Tejun Heo
2007-09-25  2:12           ` Rusty Russell
2007-09-25  2:39             ` Tejun Heo
2007-09-25  3:21               ` Rusty Russell
2007-09-25  3:36                 ` Tejun Heo
2007-09-25  4:38                   ` Rusty Russell
2007-09-25  8:01                     ` Cornelia Huck
2007-09-25  8:25                     ` Tejun Heo
2007-09-25  8:36                       ` Tejun Heo
2007-09-25  8:50                         ` Rusty Russell
2007-09-25 14:05                           ` Tejun Heo
2007-09-25 14:24       ` Alan Stern
2007-09-25 14:30         ` Tejun Heo
2007-09-25 15:09           ` Alan Stern
2007-09-25 23:15             ` Tejun Heo [this message]
2007-09-25 23:41               ` Rusty Russell
2007-09-26  1:42                 ` Tejun Heo
2007-09-26 14:39               ` Alan Stern
2007-09-20  7:26 ` [PATCH 4/4] sysfs: make suicidal nodes just do it directly Tejun Heo
2007-09-20  9:24   ` Cornelia Huck
2007-09-20  9:43     ` Tejun Heo
2007-09-28 13:54   ` Cornelia Huck
2007-09-28 14:27     ` Tejun Heo
2007-09-20  7:26 ` [PATCH 2/4] sysfs: make the sysfs_addrm_cxt->removed list FIFO Tejun Heo
2007-09-20  7:26 ` [PATCH 3/4] sysfs: care-free suicide for sysfs files Tejun Heo
2007-09-25 22:02 ` [PATCHSET 2/4] sysfs: allow suicide Greg KH

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=46F996AD.2070107@gmail.com \
    --to=htejun@gmail.com \
    --cc=corbet@lwn.net \
    --cc=cornelia.huck@de.ibm.com \
    --cc=ebiederm@xmission.com \
    --cc=greg@kroah.com \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=stern@rowland.harvard.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