From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Nigel Cunningham <nigel@nigel.suspend2.net>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Pavel Machek <pavel@ucw.cz>, Uli Luckas <u.luckas@road.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH -mm] PM: Prevent frozen user mode helpers from failing the freezing of tasks
Date: Mon, 25 Jun 2007 17:03:42 +0200 [thread overview]
Message-ID: <200706251703.42979.rjw@sisk.pl> (raw)
In-Reply-To: <20070625104332.GA147@tv-sign.ru>
On Monday, 25 June 2007 12:43, Oleg Nesterov wrote:
> Rafael J. Wysocki wrote:
> >
> > static int usermodehelper_pm_callback(struct notifier_block *nfb,
> > unsigned long action,
> > void *ignored)
> > {
> > + long retval;
> > +
> > switch (action) {
> > case PM_HIBERNATION_PREPARE:
> > case PM_SUSPEND_PREPARE:
> > usermodehelper_disabled = 1;
> > - return NOTIFY_OK;
> > + /*
> > + * From now on call_usermodehelper_exec() won't start any new
> > + * helpers, so it is sufficient if running_helpers turns out to
> > + * be zero at one point (it may be increased later, but that
> > + * doesn't matter).
> > + */
> > + retval = wait_event_timeout(running_helpers_waitq,
> > + atomic_read(&running_helpers) == 0,
> > + RUNNING_HELPERS_TIMEOUT);
> > + if (retval) {
> > + return NOTIFY_OK;
> > + } else {
> > + usermodehelper_disabled = 0;
> > + return NOTIFY_BAD;
>
> I think this is racy. First, this needs smp_mb() between "usermodehelper_disabled = 1"
> and wait_event_timeout().
Yes ...
> Second, call_usermodehelper's path should first increment the counter, and only
> then check usermodehelper_disabled,
It does this already.
> and it needs an mb() in between too. Otherwise, the helper can see
> usermodehelper_disabled == 0, then PM_SUSPEND_PREPARE comes and
> returns NOTIFY_OK, then the helper increments the counter and starts application.
>
> Sadly, you can't use srcu/qrcu because it doesn't handle timeouts.
OK
If I understand that correctly, it should suffice to place smp_mb() after
usermodehelper_disabled = 1; in usermodehelper_pm_callback() and another
smp_mb() after atomic_inc(&running_helpers); in new_helper().
Is that correct?
Greetings,
Rafael
--
"Premature optimization is the root of all evil." - Donald Knuth
next prev parent reply other threads:[~2007-06-25 14:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-25 10:43 [PATCH -mm] PM: Prevent frozen user mode helpers from failing the freezing of tasks Oleg Nesterov
2007-06-25 14:58 ` Paul E. McKenney
2007-06-25 15:20 ` synchronize_qrcu_timeout() Oleg Nesterov
2007-06-25 15:49 ` synchronize_qrcu_timeout() Oleg Nesterov
2007-06-25 21:42 ` synchronize_qrcu_timeout() Pavel Machek
2007-06-26 14:53 ` synchronize_qrcu_timeout() Paul E. McKenney
2007-06-27 11:18 ` synchronize_qrcu_timeout() Oleg Nesterov
2007-06-27 20:52 ` synchronize_qrcu_timeout() Rafael J. Wysocki
2007-06-25 15:03 ` Rafael J. Wysocki [this message]
2007-06-25 15:27 ` [PATCH -mm] PM: Prevent frozen user mode helpers from failing the freezing of tasks Oleg Nesterov
-- strict thread matches above, loose matches on Subject: below --
2007-06-24 21:36 Rafael J. Wysocki
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=200706251703.42979.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nigel@nigel.suspend2.net \
--cc=oleg@tv-sign.ru \
--cc=paulmck@linux.vnet.ibm.com \
--cc=pavel@ucw.cz \
--cc=u.luckas@road.de \
/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