From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Zhang Rui <rui.zhang@intel.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-pm <linux-pm@lists.linux-foundation.org>,
linux-acpi <linux-acpi@vger.kernel.org>,
Pavel Machek <pavel@ucw.cz>, Len Brown <lenb@kernel.org>,
Arjan van de Ven <arjan@linux.intel.com>,
"dtor@mail.ru" <dtor@mail.ru>
Subject: Re: [PATCH V2 0/4] introduce device async actions mechanism
Date: Tue, 11 Aug 2009 20:12:13 +0200 [thread overview]
Message-ID: <200908112012.13361.rjw@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0908111148060.2562-100000@iolanthe.rowland.org>
On Tuesday 11 August 2009, Alan Stern wrote:
> On Tue, 11 Aug 2009, Rafael J. Wysocki wrote:
>
> > In fact, we don't need the layers at all. The only thing we have to assure is
> > that, during resume, the devices given device depends on will be handled
> > before we start to handle this particular device (inversely during suspend).
> >
> > Please note that we're not even allowed to start executing the device's
> > resume callback before the callbacks of the devices it depends on have
> > returned (the same applies to the suspend callbacks, but the other way around).
>
> The general algorithm for maximum parallelism goes as follows: Start by
> resuming (in parallel) all the devices which don't depend on anything
> else. Each time a resume finishes, you go on to resume (in parallel)
> all the devices which depend only on resumed devices and which haven't
> yet started to resume.
>
> As described, this can require a large number of threads. It also
> requires detailed knowledge of which devices depend on others, which we
> don't have.
It's even more complicated than that.
Assume we have 7 devices, A-G, such that A is the parent of B and C,
B is the parent of D and E, and C is the parent of F and G. Assume in addition
that the PM dependencies between the devices are fully reflected by the
device tree structure (ie. there are no dependencies that aren't reflected
parent-child relationships) and that B and G take 0.5 s to resume while the
others take < 1 ms each. So, the total sequential resume time is
2 s + O(1 ms).
Now, if we used the above algorithm, we'd first resume DEFG which would take
1 s because of G, then we'd resume BC which would take 1 s because of B and
the total resume time is again 2 s + O(1 ms).
However, one can observe that B doesn't need to wait for G to resume, because
they are independent of each other. So, we can resume BDE in parallel with
CFG, while of course DE have to wait for B and so on, but this way we can
theoretically reduce the total resume time to 1 s + O(1 ms).
The question is how to do that and it seems to me that we can use completions
for this purpose. Namely, add a completion to each device with the following
rules:
1) all completions are reset before dpm_resume(),
2) before executing the ->resume() callback for device D, we wait for the
completion of the D's parent,
3) we complete the D's completion after executing its ->resume() callback.
Also, the items executed in parallel are now the "wait for the parent's
completion, run our callback and complete our completion" things.
At first sight I don't see anything fundamentally wrong with this approach.
Thanks,
Rafael
next prev parent reply other threads:[~2009-08-11 18:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-24 3:01 [PATCH V2 0/4] introduce device async actions mechanism Zhang Rui
2009-08-03 21:18 ` Rafael J. Wysocki
2009-08-04 3:35 ` Zhang Rui
2009-08-04 16:21 ` Rafael J. Wysocki
2009-08-04 17:33 ` Alan Stern
2009-08-04 18:44 ` Rafael J. Wysocki
2009-08-05 1:47 ` Zhang Rui
2009-08-07 23:42 ` Rafael J. Wysocki
2009-08-05 2:24 ` Zhang Rui
2009-08-08 0:22 ` Rafael J. Wysocki
2009-08-08 0:29 ` Dmitry Torokhov
2009-08-08 12:53 ` Rafael J. Wysocki
2009-08-11 6:22 ` Zhang Rui
2009-08-11 15:34 ` Rafael J. Wysocki
2009-08-11 15:53 ` Alan Stern
2009-08-11 18:12 ` Rafael J. Wysocki [this message]
2009-08-11 18:59 ` Alan Stern
2009-08-11 23:17 ` Rafael J. Wysocki
2009-08-12 14:03 ` Alan Stern
2009-08-12 20:10 ` Rafael J. Wysocki
2009-08-12 20:34 ` Alan Stern
2009-08-12 21:18 ` Rafael J. Wysocki
2009-08-13 14:30 ` Alan Stern
2009-08-13 17:53 ` 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=200908112012.13361.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=arjan@linux.intel.com \
--cc=dtor@mail.ru \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=pavel@ucw.cz \
--cc=rui.zhang@intel.com \
--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