All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: mark gross <640e9920@gmail.com>, Neil Brown <neilb@suse.de>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Arve@smtp1.linux-foundation.org,
	Florian Mickler <florian@mickler.org>,
	Linux-pm mailing list <linux-pm@lists.linux-foundation.org>
Subject: Re: [update] Re: [RFC][PATCH] PM: Avoid losing wakeup events during suspend
Date: Wed, 23 Jun 2010 12:09:08 +0200	[thread overview]
Message-ID: <201006231209.09187.rjw__14718.7857692645$1277288031$gmane$org@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1006222203070.10376-100000@netrider.rowland.org>

On Wednesday, June 23, 2010, Alan Stern wrote:
> On Tue, 22 Jun 2010, Rafael J. Wysocki wrote:
> 
> > > > Please tell me what you think.
> > > 
> > > I like it a lot.  It addresses the main weakness in the earlier 
> > > version.  With this, you could essentially duplicate the in-kernel part 
> > > of the wakelocks/suspend blockers stuff.  All except the timed 
> > > wakelocks -- you might want to consider adding a 
> > > pm_wakeup_begin_timeout() convenience routine.
> > 
> > That may be added in future quite easily if it really turns out to be necessary.
> > IIRC Arve said Android only used timeouts in user space wakelocks, not in the
> > kernel ones.
> 
> Didn't we agree that timeouts would be needed for Wake-on-LAN?

Yes, we did, but in the WoL case the timeout will have to be used by the user
space rather than the kernel IMO.

It would make sense to add a timeout argument to pm_wakeup_event() that would
make the system stay in the working state long enough for the driver wakeup
code to start in the PCIe case.  I think pm_wakeup_event() mght just increment
events_in_progress and the timer might simply decrement it.

So, maybe it's just better to have pm_wakeup_event(dev, timeout) that will
increment events_in_progress and set up a timer and pm_wakeup_commit(dev) that
will delete the timer, decrement events_in_progress and increment event_count
(unless the timer has already expired before).

That would cost us a (one more) timer in struct dev_pm_info, but it would
allow us to cover all of the cases identified so far.  So, if a wakeup event is
handled within one functional unit that both detects it and delivers it to
user space, it would call pm_wakeup_event(dev, 0) (ie. infinite timeout) at the
beginning and then pm_wakeup_commit(dev) when it's done with the event.
If a wakeup event it's just detected by one piece of code and is going to
be handled by another, the first one could call pm_wakeup_event(dev, tm) and
allow the other one to call pm_wakeup_commit(dev) when it's done.  However,
calling pm_wakeup_commit(dev) is not mandatory, so the second piece of code
(eg. a PCI driver) doesn't really need to do anything in the simplest case.

> > > Here's another possible enhancement (if you can figure out a way to do
> > > it without too much effort): After a suspend begins, keep track of the
> > > first wakeup event you get.  Then when the suspend is aborted, print a
> > > log message saying why and indicating which device was responsible for
> > > the wakeup.
> > 
> > Good idea, but I'd prefer to add it in a separate patch not to complicate
> > things too much to start with.
> 
> Okay.  Another thing to be considered later is whether there should be
> a way to write to /sys/power/state that would block until the active
> wakeup count drops to 0.  On the other hand polling maybe once per
> second wouldn't be so bad.  It would happen only when the kernel had
> some events outstanding and userspace didn't.

Blocking on a write to /sys/power/state wouldn't help, because if the active
wakeup count is nonzero at this point, the suspend should be aborted anyway,
so there's no need to wait.  The same applies to writing to
/sys/power/wakeup_count.  However, blocking a read from /sys/power/wakeup_count
instead of failing it when the active wakeup count is nonzero would make sense.

> One thing that stands out is the new spinlock.  It could potentially be
> a big source of contention.  Any wakeup-enabled device is liable to
> need it during every interrupt.  Do you think this could cause a
> noticeable slowdown?

That really depends on the number of wakeup devices.  However, ISTR the
original wakelocks code had exactly the same issue (it used a spinlock to
protect the lists of wakelocks).

Rafael

  reply	other threads:[~2010-06-23 10:09 UTC|newest]

Thread overview: 150+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-19 22:05 [RFC][PATCH] PM: Avoid losing wakeup events during suspend Rafael J. Wysocki
2010-06-20  5:52 ` mark gross
2010-06-20  5:52 ` mark gross
2010-06-20 12:49   ` Rafael J. Wysocki
2010-06-20 23:13     ` mark gross
2010-06-20 23:13     ` mark gross
2010-06-20 12:49   ` Rafael J. Wysocki
2010-06-20 16:28 ` Alan Stern
2010-06-20 16:28 ` Alan Stern
2010-06-20 21:50   ` Rafael J. Wysocki
2010-06-21  2:23     ` Alan Stern
2010-06-21  2:23     ` Alan Stern
2010-06-21  5:32       ` Florian Mickler
2010-06-21  5:32       ` Florian Mickler
2010-06-21 15:23         ` Alan Stern
2010-06-21 20:38           ` Florian Mickler
2010-06-21 22:18             ` Alan Stern
2010-06-21 22:18             ` Alan Stern
2010-06-21 22:40               ` Rafael J. Wysocki
2010-06-21 22:48                 ` Rafael J. Wysocki
2010-06-21 22:48                 ` Rafael J. Wysocki
2010-06-22  0:50                 ` Arve Hjønnevåg
2010-06-22  0:50                 ` Arve Hjønnevåg
2010-06-22 10:21                 ` Rafael J. Wysocki
2010-06-22 10:21                 ` Rafael J. Wysocki
2010-06-22 14:35                   ` Alan Stern
2010-06-22 15:35                     ` Rafael J. Wysocki
2010-06-22 19:55                       ` Alan Stern
2010-06-22 19:55                       ` Alan Stern
2010-06-22 20:58                         ` Rafael J. Wysocki
2010-06-22 20:58                         ` Rafael J. Wysocki
2010-06-22 19:59                       ` [update] " Rafael J. Wysocki
2010-06-24 14:16                         ` Andy Lutomirski
2010-06-24 14:16                         ` Andy Lutomirski
2010-06-24 14:45                           ` Alan Stern
2010-06-24 14:45                           ` Alan Stern
2010-06-24 14:48                           ` Rafael J. Wysocki
2010-06-24 15:21                             ` Andy Lutomirski
2010-06-24 15:21                             ` Andy Lutomirski
2010-06-24 14:48                           ` Rafael J. Wysocki
2010-06-22 19:59                       ` Rafael J. Wysocki
2010-06-22 20:34                         ` Alan Stern
2010-06-22 20:34                         ` Alan Stern
2010-06-22 21:41                           ` Rafael J. Wysocki
2010-06-23  2:12                             ` Alan Stern
2010-06-23  2:12                             ` Alan Stern
2010-06-23 10:09                               ` Rafael J. Wysocki [this message]
2010-06-23 10:09                               ` Rafael J. Wysocki
2010-06-23 15:21                                 ` Alan Stern
2010-06-23 15:21                                 ` Alan Stern
2010-06-23 22:17                                   ` Rafael J. Wysocki
2010-06-23 22:17                                   ` Rafael J. Wysocki
2010-06-24 13:13                                     ` [update 2] " Rafael J. Wysocki
2010-06-24 15:06                                       ` Rafael J. Wysocki
2010-06-24 15:35                                         ` Alan Stern
2010-06-24 15:35                                         ` Alan Stern
2010-06-24 23:00                                           ` [update 3] " Rafael J. Wysocki
2010-06-24 23:00                                           ` Rafael J. Wysocki
2010-06-25 14:42                                             ` Alan Stern
2010-06-25 14:42                                             ` Alan Stern
2010-06-25 20:33                                               ` Rafael J. Wysocki
2010-06-25 20:33                                               ` Rafael J. Wysocki
2010-06-24 15:06                                       ` [update 2] " Rafael J. Wysocki
2010-06-24 15:44                                       ` Alan Stern
2010-06-24 15:44                                       ` Alan Stern
2010-06-24 16:19                                         ` Rafael J. Wysocki
2010-06-24 17:09                                           ` Alan Stern
2010-06-24 23:06                                             ` Rafael J. Wysocki
2010-06-24 23:06                                             ` Rafael J. Wysocki
2010-06-25 15:09                                               ` Alan Stern
2010-06-25 15:09                                               ` Alan Stern
2010-06-25 20:37                                                 ` Rafael J. Wysocki
2010-06-25 20:57                                                   ` Alan Stern
2010-06-25 20:57                                                   ` Alan Stern
2010-06-25 20:37                                                 ` Rafael J. Wysocki
2010-06-25  6:40                                             ` Florian Mickler
2010-06-25  6:40                                             ` Florian Mickler
2010-06-25 13:28                                               ` Rafael J. Wysocki
2010-06-25 13:28                                               ` Rafael J. Wysocki
2010-06-24 17:09                                           ` Alan Stern
2010-06-24 16:19                                         ` Rafael J. Wysocki
2010-06-24 13:13                                     ` Rafael J. Wysocki
2010-06-22 21:41                           ` [update] " Rafael J. Wysocki
2010-06-22 15:35                     ` Rafael J. Wysocki
2010-06-22 14:35                   ` Alan Stern
2010-06-22 23:00                   ` mark gross
2010-06-22 23:00                     ` mark gross
2010-06-21 22:40               ` Rafael J. Wysocki
2010-06-21 20:38           ` Florian Mickler
2010-06-21 15:23         ` Alan Stern
2010-06-21 16:54         ` Alan Stern
2010-06-21 20:40           ` Florian Mickler
2010-06-21 20:40           ` Florian Mickler
2010-06-21 21:18           ` Rafael J. Wysocki
2010-06-21 21:18           ` Rafael J. Wysocki
2010-06-21 22:27             ` Alan Stern
2010-06-21 22:27             ` Alan Stern
2010-06-21 16:54         ` Alan Stern
2010-06-21  6:13       ` mark gross
2010-06-21  6:13       ` mark gross
2010-06-21 12:10         ` tytso
2010-06-21 12:10         ` tytso
2010-06-21 12:22           ` Alan Cox
2010-06-21 12:22             ` Alan Cox
2010-06-21 12:26             ` Florian Mickler
2010-06-21 12:26             ` Florian Mickler
2010-06-21 12:26             ` Florian Mickler
2010-06-21 13:42             ` tytso
2010-06-21 14:01               ` Alan Cox
2010-06-21 14:01                 ` Alan Cox
2010-06-21 13:42             ` tytso
2010-06-22  1:07           ` mark gross
2010-06-22  1:07           ` mark gross
2010-06-21 16:01         ` Alan Stern
2010-06-21 16:01         ` Alan Stern
2010-06-22  1:25           ` mark gross
2010-06-22  2:24             ` Alan Stern
2010-06-22  2:24             ` Alan Stern
2010-06-22  1:25           ` mark gross
2010-06-21 21:58       ` Rafael J. Wysocki
2010-06-21 21:58       ` Rafael J. Wysocki
2010-06-20 21:50   ` Rafael J. Wysocki
2010-06-20 22:58   ` mark gross
2010-06-21  2:33     ` Alan Stern
2010-06-21  2:33     ` Alan Stern
2010-06-21  4:04       ` [linux-pm] " David Brownell
2010-06-21  4:04         ` David Brownell
2010-06-21  6:02         ` [linux-pm] " David Brownell
2010-06-21  6:02         ` David Brownell
2010-06-21 15:06         ` Alan Stern
2010-06-21 15:06         ` [linux-pm] " Alan Stern
2010-06-21  5:55       ` mark gross
2010-06-21 12:39         ` Florian Mickler
2010-06-21 12:39         ` Florian Mickler
2010-06-21 15:57         ` Alan Stern
2010-06-21 15:57         ` Alan Stern
2010-06-22  1:58           ` mark gross
2010-06-22  2:46             ` Alan Stern
2010-06-22  2:46             ` Alan Stern
2010-06-22  9:24               ` Rafael J. Wysocki
2010-06-22  9:24               ` Rafael J. Wysocki
2010-06-22  6:18             ` Florian Mickler
2010-06-22  6:18             ` Florian Mickler
2010-06-22 23:22               ` mark gross
2010-06-22 23:22               ` mark gross
2010-06-22  9:29             ` Rafael J. Wysocki
2010-06-22  9:29               ` Rafael J. Wysocki
2010-06-22  1:58           ` mark gross
2010-06-21  5:55       ` mark gross
2010-06-20 22:58   ` mark gross

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='201006231209.09187.rjw__14718.7857692645$1277288031$gmane$org@sisk.pl' \
    --to=rjw@sisk.pl \
    --cc=640e9920@gmail.com \
    --cc=Arve@smtp1.linux-foundation.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=florian@mickler.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=neilb@suse.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.