On Monday 14 December 2009, Linus Torvalds wrote:> > On Mon, 14 Dec 2009, Rafael J. Wysocki wrote:> >> > OK, what about a two-pass approach in which the first pass only inits the> > completions and starts async threads for leaf "async" devices? I think leaf> > devices are most likely to take much time to suspend, so this will give us> > a chance to save quite some time.> > Why?> > Really.

Because the PCI bridges are not the only case where it matters (I'd say theyare really a corner case). Basically, any two async devices separeted by aseries of sync ones are likely not to be suspended (or resumed) in parallelwith each other, because the parent is usually next to its children in dpm_list.So, if the first device suspends, its "synchronous" parent waits for it and thesuspend of the second async device won't be started until the first one'ssuspend has returned. And it doesn't matter at what level we do the asyncthing, because dpm_list is there anyway.

As Alan said, the real problem is that we generally can't change the orderingof dpm_list arbitrarily, because we don't know what's going to happen as aresult. The async_suspend flag tells us, basically, what devices can be safelymoved to different positions in dpm_list without breaking things, as long asthey are not moved behind their parents or in front of their children.

Starting the async suspends upfront would effectively work in the same way asmoving those devices to the beginning of dpm_list without breaking theparent-child chains, which in turn is likely to allow us to save some extratime.

That's not only about the PCI bridges, it's more general. As far as yourone-liner is concerned, I'm going to test it, because I think we could use itanyway.