Skip to contentSkip to conversation

Attempted summary of suspend-blockers LKML thread

RFC PATCH New Paul E. McKenney 32 participants 817 messages Jul 31, 2010 – Sep 17, 2010 Page 5 of 6

Subsystems (4)
lore
Share & tools
lore
#622 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Alan Cox
Quoted 7 lines · Alan Cox
Quoted 2 lines

situation you call out can occur with manual suspend-to-RAM already:
the fact is that this is a design choice. You could indeed make a

Losing data is a design choice ? The application set a timer, the OS shouldn't be ignoring it in that situation. It might want to delay it, it might want to warn the user its hogging things it shouldnt (powertop, battery usage monitors in Android etc)

Hmmm... Let's put the two approaches side by side so that we can compare them more easily:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Resume OS continues delaying timer
Timer fires Timer fires

These two cases look quite similar to me.

But as you say, the battery can run out. So let's add that to the comparison:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Battery runs out Battery runs out
Data loss Data loss

The two cases still look quite similar. You might note, quite correctly, that the time between suspend and resume might be quite a bit longer than the typical time that the OS delays a timer. But the power consumption on some platforms is quite a bit lower in the suspend case than it is in the delayed-timer case.

Quoted 8 lines
Quoted 3 lines

will by definition be the only user of that mechanism. So the fact that Android is most probably the only user of suspend blockers does not prove anything about whether or not suspend blockers are sensible.

They don't appear to solve the constraints on power management that you have in other environments, nor do they happen to be conveniently backward compatible or available on other platforms - which makes code hard to port.

There does seem to be some debate (if you can call it that) over whether suspend blockers (or something like them) apply to non-Android environments, though I do understand that you believe that suspend blockers are relevant only to Android. And indeed, adding features to a particular platform can degrade portability, but the same is true of any number of pre-existing Linux-specific features.

Quoted 7 lines
Quoted 2 lines

But that doesn't guarantee that solutions developed for PCs and laptops will be optimal (or even usable) on cellphones. Sufficient difference

Your cellphone is to all intents a laptop from ten years ago, it even has a similar display resolution and internet availability. The underlying difference between the two is solely form factor - the laptop had a better keyboard.

There are similarities and differences. You have called out some of the similarities. Differences include the more-aggressive hardware power management on cellphones, the greater number and variety of hardware accelerators on cellphones, battery capacity, and, as you say, physical size. People currently use cellphones differently than they do laptops or desktops. The usage might converge, but we will see. There is as much reason to expect increasing specialization as there is to expect increasing convergence.

Quoted 5 lines
Quoted 4 lines

I hope that no one is arguing that Android will remain unchanged, just as I hope no one would argue that Linux will remain unchanged. In fact, I am quite confident that both Linux and Android will continue to change. So exactly what point were you attempting to make here?

Quoted 7 lines

That anything which ties to a particular style of behaviour and set of current usage assumptions is broken. If you rewrite all the apps to Android 2.1 and design in a single tasking model then you'll have to unrewrite half of it again when Android grows up. Ditto suspend blockers
- encode too much policy in your apps and you lose the ability to change the environment under them. See the mess Microsoft got into with Win16 on Win32. Compare with Linux 32bit on Linux 64bit.

Yes, sooner or later, changes in environment and usage will break our assumptions. This includes your assumptions, my assumptions, the Android folks' assumptions, and everyone else's assumptions. We nevertheless build things anyway.

A better comparison for Win16->Win32 would be UNIX's move from 16-bit PDP-11 to 32-bit VAX. There was plenty of screaming over that one.

Quoted 9 lines
Quoted 4 lines

As to busting all apps, lthough there have been situations where busting all the apps turned out to be the right thing to do, I agree that these situations are extremely rare. Such situations are usually associated with the emergence of a new high-volume platform.

Like Microsoft Windows 16bit co-operative multi-tasking ? It's rarely right. It's merely that in certain cases the value in the market is large enough that it can be used as a big stick to beat people into doing lots of usually wasted work.

Interesting choice of example. I do well remember the Sequent hardware guys' frustration when the old printer driver would monopolize the desktop while printing their large documents. The fact was that Microsoft's co-operative multi-tasking required all applications to be well behaved, just as does your approach to power efficiency.

Quoted 11 lines
Quoted 6 lines

Hmmm... Exactly which part do you consider flawed? Let's take it one sentence at a time. The devices that I know of that lack suspend blockers also lack opportunistic suspend. Therefore, all applications on such devices run as would an application that acquired a suspend blocker when it started and did not release that suspend blocker until it exited. Pretty straightforward.

What do you mean by "opportunistic suspend", lots of systems drop into lowest power states whenever they can. "Suspend is different" is a bit of Android religion that I am dubious has any basis in reality as seen from the application end of the universe.

Opportunistic suspend has been well defined in this discussion. I do understand that you don't like opportunistic suspend, but your distaste for it does not undefine it.

Quoted 10 lines

You may also wish to review the earlier parts of the discussion where it was explicitly stated by several developers that they were using "suspend" type modes as power states already and not using suspend blockers. So it's being done, today on ARM and your statement is directly contradicting the code. Modern ARM processors and x86 MID devices can suspend and resume extremely fast (fast enough that the fact Linux x86 rewriting all the SMP alternatives on suspend/resume is a measurable problem). If this same property doesn't end up on big PC boxes in time then I'd be very surprised. At that point the openoffice with suspend blockers or oracle with suspend blockers question becomes rather relevant.

Here is the list of properties distinguishing idle from suspend:

1. Idle states are entered by a given CPU only there are no runnable
tasks for that CPU. In contrast, opportunistic suspend can halt the entire system even when there are tasks that are ready, willing, and able to run. (But please note that this might not apply to real-time tasks.)

2. There can be a set of input events that do not bring the system
out of suspend, but which would bring the system out of idle. Exactly which events are in this set depends both on hardware capabilities and on the platform/application policy. For example, on one of the Android-based smartphones, touchscreen input is ignored when the system is suspended, but is handled when idle.

3. The system comes out of idle when a timer expires. In contrast,
timers might or might not bring the system out of suspend, depending on both hardware capabilities and platform/application policy.

4. Suspend generally forces devices to go into their low-power
states immediately. In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices. Idle thus has shorter average wakeup latencies, but worse energy efficiency.

5. Suspend usually has longer wakeup latency than does idle.

This list was compiled from this thread.

It is the above semantics rather than the particular C-state that makes the difference between idle and suspend. Yes, you have claimed that idle will render suspend obsolete, but you have not yet convinced me.

Quoted 7 lines
Quoted 3 lines

As for the first part of the second sentence, you yourself have argued that each and every application should be carefully written to avoid battery drain (or, equivalently, to promote energy efficiency), so

No. I've argued that applications need to be generally well behaved, not keep waking up, not burn cpu - which is a generic property applicable on all environments not a specialisation.

Either way you prefer to word it is fine by me -- I am fine with either "carefully written" or "generally well behaved". Alternatively, if you were trying to say something different than what I said, I failed to spot the difference.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

OpenOffice runs on netbooks, laptops, servers, even big non x86 boxes. It runs on virtual machines, it runs in power sensitive environments, it runs in thermally constrained environments, it runs in I/O constrained environments, it runs in latency constrained environments etc etc

And there are numerous environments in which it will not run. So what?

It's one codebase for all of them

Yes, and there are still numerous environments where it does not run.

Quoted 5 lines

and furthermore almost all of that was
done by modifying only the OS. Linux learned to do power throttling without the app being involved, it learned to do virtualisation without the app being changed, it is learning (with -rt) to handle to do real time this way.

Except that you do modify the app to more effectively throttle power. Which is fine; I have no problem with that. I also have no problem with things that reduce the need to modify the apps to more effectively throttle power.

Real time indeed allows unmodified non-real-time apps to stay out of the way of very carefully written real-time apps, so I do like that example.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

All the same code, true some work has been done to make it behave politely but the rest is down to the OS doing its job - deploying the resources available while considering and obeying the constraints present, in a manner which makes best use of the resources to achieve the policy goals of the system.

Quoted 8 lines
Quoted 2 lines

And if the work has not been done on the application, and if there is nothing like suspend blockers, the OS cannot do its job.

I don't see any evidence to support that claim. I see evidence that there are cases where apps wish to communicate their intentions around power more clearly but a suspend blocker is a crude single case hammer. Today most applications communicate their sleep/wake requirements fairly well by sleeping, by executing code and by setting timers/alarms.

I will take your "there are cases where apps wish to communicate their intentions around power more clearly", thank you very much. And yes, there is much debate over exactly what form that communication might take.

Quoted 15 lines
Quoted 9 lines

Given this context, are you sure that suspend blockers are not the next step in the Real OS progression? Or some QoS mechanism that subsumes suspend blockers? However, there is a lot of negative experience around general-purpose QoS mechanisms -- you have to be quite careful in order to avoid spending more energy computing QoS than you would otherwise spend on the application's computations. The usual way out of this trap is to abandon generality in favor of exploiting the commonly occurring special cases. For all I know, raw suspend blockers might be the appropriate special case.

For Android possibly and I've never had any objection to Android keeping suspend blockers in private patches. The claim is only a small number are needed in their kernel so its a tiddly patch and the patch context will no doubt keep it applying between releases and easy for them to maintain.

Quoted 5 lines

For the rest of us - I see no evidence it's generally useful. A QoS API does appear to be generally useful but as you say you need to get the performance right. However you can also tackle that the way we tackle several other examples of one interface/many needs - such as schedulers, security models and the like.

No one will know whether or not suspend blockers are generally useful until they are willing to try them.

Quoted 8 lines

One interface to applications and one interface to drivers so that its easy to maintain and you don't end up with hooks all over the place for different things, then if it proves neccessary different implementations. So yes maybe Android would use a "qos_basic" which returns -EOPNOTSUPP to anything but a suspend blocker behaviour. The important thing about that is that my device drivers, my applications and my other platforms don't have to care that Android made this choice - they can still be generic code.

If this can actually happen, I would consider it a good thing.

Of course, we might well find out some years down the road that the qos_basic piece is the only part that was actually in common use. Then again, it would not be the first time. System-V semaphores, anyone? ;-)

Quoted 4 lines

That is why I used the Win16 example. The Win16 model encapsulated an implementation into the API. Had they followed a more conventional interface based around yielding then like MacOS they'd have had a far smoother move to pre-emptive MT.

I am certainly no fan of Win16. That said, if there is a qos_basic that maps nicely to suspend blockers, the risk of adding suspend blockers in their current form seems to me to be rather low.

Thanx, Paul

#613 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Alan Cox
Quoted 9 lines · Alan Cox

Which reminds me. I forgot a very important way that user space signals the kernel as to its intents.

The kernel can see whether code is sleeping by choice or sleeping because someone blocked it (eg a page fault). The kernel also knows a lot about the event being waited for (much more so in -rt than base).

We don't capture all of that info but it seems it would advance progress in the right direction to do so better.

As one approach of many, this makes a great deal of sense.

Thanx, Paul

#614 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Alan Cox
Quoted 9 lines · Alan Cox

Which reminds me. I forgot a very important way that user space signals the kernel as to its intents.

The kernel can see whether code is sleeping by choice or sleeping because someone blocked it (eg a page fault). The kernel also knows a lot about the event being waited for (much more so in -rt than base).

We don't capture all of that info but it seems it would advance progress in the right direction to do so better.

As one approach of many, this makes a great deal of sense.

Thanx, Paul

#623 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 31 lines · Paul E. McKenney
Quoted 7 lines · Alan Cox
Quoted 2 lines

situation you call out can occur with manual suspend-to-RAM already:
the fact is that this is a design choice. You could indeed make a

Losing data is a design choice ? The application set a timer, the OS shouldn't be ignoring it in that situation. It might want to delay it, it might want to warn the user its hogging things it shouldnt (powertop, battery usage monitors in Android etc)

Hmmm... Let's put the two approaches side by side so that we can compare them more easily:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Resume OS continues delaying timer
Timer fires Timer fires

These two cases look quite similar to me.

But as you say, the battery can run out. So let's add that to the comparison:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Battery runs out Battery runs out
Data loss Data loss

Quoted 5 lines

The two cases still look quite similar. You might note, quite correctly, that the time between suspend and resume might be quite a bit longer than the typical time that the OS delays a timer. But the power consumption on some platforms is quite a bit lower in the suspend case than it is in the delayed-timer case.

it has been stated that the android can hit the exact same power state either with sleep or suspend, and that the same clock can wake it up (it appears as a timer expiring for sleep, or an alarm for suspend, but it's the same clock firing the signal)

so in at least some cases the hardware supports doing both with equal efficiency.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

But that doesn't guarantee that solutions developed for PCs and laptops will be optimal (or even usable) on cellphones. Sufficient difference

Your cellphone is to all intents a laptop from ten years ago, it even has a similar display resolution and internet availability. The underlying difference between the two is solely form factor - the laptop had a better keyboard.

Quoted 8 lines

There are similarities and differences. You have called out some of the similarities. Differences include the more-aggressive hardware power management on cellphones, the greater number and variety of hardware accelerators on cellphones, battery capacity, and, as you say, physical size. People currently use cellphones differently than they do laptops or desktops. The usage might converge, but we will see. There is as much reason to expect increasing specialization as there is to expect increasing convergence.

You are talking about Android as if it was a cell phone only thing, it's not. there are shipping tablets (and I believe netbooks, i.e. laptops) running andoid.

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

As to busting all apps, lthough there have been situations where busting all the apps turned out to be the right thing to do, I agree that these situations are extremely rare. Such situations are usually associated with the emergence of a new high-volume platform.

Like Microsoft Windows 16bit co-operative multi-tasking ? It's rarely right. It's merely that in certain cases the value in the market is large enough that it can be used as a big stick to beat people into doing lots of usually wasted work.

Quoted 5 lines

Interesting choice of example. I do well remember the Sequent hardware guys' frustration when the old printer driver would monopolize the desktop while printing their large documents. The fact was that Microsoft's co-operative multi-tasking required all applications to be well behaved, just as does your approach to power efficiency.

and wakelocks require all applications that can take a wakelock be well behaved. and applications that do nt take a wakelock directly cannot expect to run unless something else takes a wakelock on their behalf

David Lang

#624 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 31 lines · Paul E. McKenney
Quoted 7 lines · Alan Cox
Quoted 2 lines

situation you call out can occur with manual suspend-to-RAM already:
the fact is that this is a design choice. You could indeed make a

Losing data is a design choice ? The application set a timer, the OS shouldn't be ignoring it in that situation. It might want to delay it, it might want to warn the user its hogging things it shouldnt (powertop, battery usage monitors in Android etc)

Hmmm... Let's put the two approaches side by side so that we can compare them more easily:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Resume OS continues delaying timer
Timer fires Timer fires

These two cases look quite similar to me.

But as you say, the battery can run out. So let's add that to the comparison:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Battery runs out Battery runs out
Data loss Data loss

Quoted 5 lines

The two cases still look quite similar. You might note, quite correctly, that the time between suspend and resume might be quite a bit longer than the typical time that the OS delays a timer. But the power consumption on some platforms is quite a bit lower in the suspend case than it is in the delayed-timer case.

it has been stated that the android can hit the exact same power state either with sleep or suspend, and that the same clock can wake it up (it appears as a timer expiring for sleep, or an alarm for suspend, but it's the same clock firing the signal)

so in at least some cases the hardware supports doing both with equal efficiency.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

But that doesn't guarantee that solutions developed for PCs and laptops will be optimal (or even usable) on cellphones. Sufficient difference

Your cellphone is to all intents a laptop from ten years ago, it even has a similar display resolution and internet availability. The underlying difference between the two is solely form factor - the laptop had a better keyboard.

Quoted 8 lines

There are similarities and differences. You have called out some of the similarities. Differences include the more-aggressive hardware power management on cellphones, the greater number and variety of hardware accelerators on cellphones, battery capacity, and, as you say, physical size. People currently use cellphones differently than they do laptops or desktops. The usage might converge, but we will see. There is as much reason to expect increasing specialization as there is to expect increasing convergence.

You are talking about Android as if it was a cell phone only thing, it's not. there are shipping tablets (and I believe netbooks, i.e. laptops) running andoid.

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

As to busting all apps, lthough there have been situations where busting all the apps turned out to be the right thing to do, I agree that these situations are extremely rare. Such situations are usually associated with the emergence of a new high-volume platform.

Like Microsoft Windows 16bit co-operative multi-tasking ? It's rarely right. It's merely that in certain cases the value in the market is large enough that it can be used as a big stick to beat people into doing lots of usually wasted work.

Quoted 5 lines

Interesting choice of example. I do well remember the Sequent hardware guys' frustration when the old printer driver would monopolize the desktop while printing their large documents. The fact was that Microsoft's co-operative multi-tasking required all applications to be well behaved, just as does your approach to power efficiency.

and wakelocks require all applications that can take a wakelock be well behaved. and applications that do nt take a wakelock directly cannot expect to run unless something else takes a wakelock on their behalf

David Lang

#280 lore raw
In reply to Arve Hjønnevåg
Quoted 2 lines · Arve Hjønnevåg

2010/8/9 Rafael J. Wysocki <[email protected]>:

Quoted 1 line · Arve Hjønnevåg

...

Quoted 9 lines
Quoted 5 lines

Anyway, as I said I'm not opposed to the idea of using a special type of objects for collecting debug information on wakeup events, so please free to submit patches modifying the current mainline kernel code in that direction.

How do you prefer to handle your pci wakeup events? Add a handle to every device or pci device? Or use a global handle to avoid the race and report wakeup events for debugging separately?

The latter, maybe?

Thanks,
Rafael

#281 lore raw
In reply to Arve Hjønnevåg
Quoted 2 lines · Arve Hjønnevåg

2010/8/9 Rafael J. Wysocki <[email protected]>:

Quoted 1 line · Arve Hjønnevåg

...

Quoted 9 lines
Quoted 5 lines

Anyway, as I said I'm not opposed to the idea of using a special type of objects for collecting debug information on wakeup events, so please free to submit patches modifying the current mainline kernel code in that direction.

How do you prefer to handle your pci wakeup events? Add a handle to every device or pci device? Or use a global handle to avoid the race and report wakeup events for debugging separately?

The latter, maybe?

Thanks,
Rafael

#625 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to [email protected]
Quoted 39 lines · On Tue, Aug 10, 2010 at 06:28:39PM -0700, [email protected] wrote:
Quoted 31 lines · Paul E. McKenney
Quoted 7 lines · Alan Cox
Quoted 2 lines

situation you call out can occur with manual suspend-to-RAM already:
the fact is that this is a design choice. You could indeed make a

Losing data is a design choice ? The application set a timer, the OS shouldn't be ignoring it in that situation. It might want to delay it, it might want to warn the user its hogging things it shouldnt (powertop, battery usage monitors in Android etc)

Hmmm... Let's put the two approaches side by side so that we can compare them more easily:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Resume OS continues delaying timer
Timer fires Timer fires

These two cases look quite similar to me.

But as you say, the battery can run out. So let's add that to the comparison:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Battery runs out Battery runs out
Data loss Data loss

Quoted 5 lines

The two cases still look quite similar. You might note, quite correctly, that the time between suspend and resume might be quite a bit longer than the typical time that the OS delays a timer. But the power consumption on some platforms is quite a bit lower in the suspend case than it is in the delayed-timer case.

Quoted 7 lines

it has been stated that the android can hit the exact same power state either with sleep or suspend, and that the same clock can wake it up (it appears as a timer expiring for sleep, or an alarm for suspend, but it's the same clock firing the signal)

so in at least some cases the hardware supports doing both with equal efficiency.

It indeed has been so stated. But in this section we were discussing data loss, not hardware power-state capabilities.

Quoted 17 lines
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

But that doesn't guarantee that solutions developed for PCs and laptops will be optimal (or even usable) on cellphones. Sufficient difference

Your cellphone is to all intents a laptop from ten years ago, it even has a similar display resolution and internet availability. The underlying difference between the two is solely form factor - the laptop had a better keyboard.

Quoted 8 lines

There are similarities and differences. You have called out some of the similarities. Differences include the more-aggressive hardware power management on cellphones, the greater number and variety of hardware accelerators on cellphones, battery capacity, and, as you say, physical size. People currently use cellphones differently than they do laptops or desktops. The usage might converge, but we will see. There is as much reason to expect increasing specialization as there is to expect increasing convergence.

Quoted 3 lines

You are talking about Android as if it was a cell phone only thing, it's not. there are shipping tablets (and I believe netbooks, i.e. laptops) running andoid.

I was talking about cellphones. But yes, Android (and thus suspend blockers) are used for tablets as well as cellphones, thank you for reminding me!

Quoted 16 lines
Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

As to busting all apps, lthough there have been situations where busting all the apps turned out to be the right thing to do, I agree that these situations are extremely rare. Such situations are usually associated with the emergence of a new high-volume platform.

Like Microsoft Windows 16bit co-operative multi-tasking ? It's rarely right. It's merely that in certain cases the value in the market is large enough that it can be used as a big stick to beat people into doing lots of usually wasted work.

Quoted 5 lines

Interesting choice of example. I do well remember the Sequent hardware guys' frustration when the old printer driver would monopolize the desktop while printing their large documents. The fact was that Microsoft's co-operative multi-tasking required all applications to be well behaved, just as does your approach to power efficiency.

Quoted 4 lines

and wakelocks require all applications that can take a wakelock be well behaved. and applications that do nt take a wakelock directly cannot expect to run unless something else takes a wakelock on their behalf

Almost. Suspend blockers require that only those portions of a PM-driving application that hold a suspend blocker be carefully written to avoid wasting power.

Thanx, Paul

#626 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to [email protected]
Quoted 39 lines · On Tue, Aug 10, 2010 at 06:28:39PM -0700, [email protected] wrote:
Quoted 31 lines · Paul E. McKenney
Quoted 7 lines · Alan Cox
Quoted 2 lines

situation you call out can occur with manual suspend-to-RAM already:
the fact is that this is a design choice. You could indeed make a

Losing data is a design choice ? The application set a timer, the OS shouldn't be ignoring it in that situation. It might want to delay it, it might want to warn the user its hogging things it shouldnt (powertop, battery usage monitors in Android etc)

Hmmm... Let's put the two approaches side by side so that we can compare them more easily:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Resume OS continues delaying timer
Timer fires Timer fires

These two cases look quite similar to me.

But as you say, the battery can run out. So let's add that to the comparison:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Battery runs out Battery runs out
Data loss Data loss

Quoted 5 lines

The two cases still look quite similar. You might note, quite correctly, that the time between suspend and resume might be quite a bit longer than the typical time that the OS delays a timer. But the power consumption on some platforms is quite a bit lower in the suspend case than it is in the delayed-timer case.

Quoted 7 lines

it has been stated that the android can hit the exact same power state either with sleep or suspend, and that the same clock can wake it up (it appears as a timer expiring for sleep, or an alarm for suspend, but it's the same clock firing the signal)

so in at least some cases the hardware supports doing both with equal efficiency.

It indeed has been so stated. But in this section we were discussing data loss, not hardware power-state capabilities.

Quoted 17 lines
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

But that doesn't guarantee that solutions developed for PCs and laptops will be optimal (or even usable) on cellphones. Sufficient difference

Your cellphone is to all intents a laptop from ten years ago, it even has a similar display resolution and internet availability. The underlying difference between the two is solely form factor - the laptop had a better keyboard.

Quoted 8 lines

There are similarities and differences. You have called out some of the similarities. Differences include the more-aggressive hardware power management on cellphones, the greater number and variety of hardware accelerators on cellphones, battery capacity, and, as you say, physical size. People currently use cellphones differently than they do laptops or desktops. The usage might converge, but we will see. There is as much reason to expect increasing specialization as there is to expect increasing convergence.

Quoted 3 lines

You are talking about Android as if it was a cell phone only thing, it's not. there are shipping tablets (and I believe netbooks, i.e. laptops) running andoid.

I was talking about cellphones. But yes, Android (and thus suspend blockers) are used for tablets as well as cellphones, thank you for reminding me!

Quoted 16 lines
Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

As to busting all apps, lthough there have been situations where busting all the apps turned out to be the right thing to do, I agree that these situations are extremely rare. Such situations are usually associated with the emergence of a new high-volume platform.

Like Microsoft Windows 16bit co-operative multi-tasking ? It's rarely right. It's merely that in certain cases the value in the market is large enough that it can be used as a big stick to beat people into doing lots of usually wasted work.

Quoted 5 lines

Interesting choice of example. I do well remember the Sequent hardware guys' frustration when the old printer driver would monopolize the desktop while printing their large documents. The fact was that Microsoft's co-operative multi-tasking required all applications to be well behaved, just as does your approach to power efficiency.

Quoted 4 lines

and wakelocks require all applications that can take a wakelock be well behaved. and applications that do nt take a wakelock directly cannot expect to run unless something else takes a wakelock on their behalf

Almost. Suspend blockers require that only those portions of a PM-driving application that hold a suspend blocker be carefully written to avoid wasting power.

Thanx, Paul

#627 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 47 lines · Paul E. McKenney

Subject: Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 44 lines · On Tue, Aug 10, 2010 at 06:28:39PM -0700, [email protected] wrote:
Quoted 31 lines · Paul E. McKenney
Quoted 7 lines · Alan Cox
Quoted 2 lines

situation you call out can occur with manual suspend-to-RAM already:
the fact is that this is a design choice. You could indeed make a

Losing data is a design choice ? The application set a timer, the OS shouldn't be ignoring it in that situation. It might want to delay it, it might want to warn the user its hogging things it shouldnt (powertop, battery usage monitors in Android etc)

Hmmm... Let's put the two approaches side by side so that we can compare them more easily:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Resume OS continues delaying timer
Timer fires Timer fires

These two cases look quite similar to me.

But as you say, the battery can run out. So let's add that to the comparison:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Battery runs out Battery runs out
Data loss Data loss

Quoted 5 lines

The two cases still look quite similar. You might note, quite correctly, that the time between suspend and resume might be quite a bit longer than the typical time that the OS delays a timer. But the power consumption on some platforms is quite a bit lower in the suspend case than it is in the delayed-timer case.

it has been stated that the android can hit the exact same power state either with sleep or suspend, and that the same clock can wake it up (it appears as a timer expiring for sleep, or an alarm for suspend, but it's the same clock firing the signal)

Quoted 5 lines
Quoted 2 lines

so in at least some cases the hardware supports doing both with equal efficiency.

It indeed has been so stated. But in this section we were discussing data loss, not hardware power-state capabilities.

you specifically stated that suspend would use less power. I am pointing out that ther is info posed in this thread to say that's not always the case.

in either case it is possible for the system to wake up again later to let the timer fire and the application save it's work. It's arguably easier in the idle case as it doesn't require application modification

for example

Idle + Timer Jitter
set timer
OS sets timer jitter to 1 hour
system sleeps for 1 hour with no wakeups timer fires, applications wake and process data system sleeps (for 1 hour or more with no wakeups)
(repeat as needed until battery runs out)

much less chance for data loss as there is _far_ more of a chance that the timer

waking up once per hour for a short time is not going to make a noticable difference in your total battery life of a cell phone due to the significant idle power draw needed for the cell circuitry. On something like a e-reader with no radio link and a month-long idle time it could make a difference.

note that this is with a badly written app running that is trying to wakeup repeatedly. If the app is well behaved and only schedule a timer when they will have work to do, they may not schedule a timer at all after the data is saved, and so would have the data safe and just as long a standby time.

Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 7 lines
Quoted 2 lines

But that doesn't guarantee that solutions developed for PCs and laptops will be optimal (or even usable) on cellphones. Sufficient difference

Your cellphone is to all intents a laptop from ten years ago, it even has a similar display resolution and internet availability. The underlying difference between the two is solely form factor - the laptop had a better keyboard.

There are similarities and differences. You have called out some of the similarities. Differences include the more-aggressive hardware power management on cellphones, the greater number and variety of hardware accelerators on cellphones, battery capacity, and, as you say, physical size. People currently use cellphones differently than they do laptops or desktops. The usage might converge, but we will see. There is as much reason to expect increasing specialization as there is to expect increasing convergence.

Quoted 7 lines
Quoted 3 lines

You are talking about Android as if it was a cell phone only thing, it's not. there are shipping tablets (and I believe netbooks, i.e. laptops) running andoid.

I was talking about cellphones. But yes, Android (and thus suspend blockers) are used for tablets as well as cellphones, thank you for reminding me!

the fact that it's used there means that you can't argue that it's difference because cell phones are so different (unless you are saying that Android is really not appropriate for those uses)

On the other hand, lots of things are used in places where it is inappropriate, Windows CE is used on phones, tablets, etc but I think most people would say that the use of windows there isn't appropriate.

David Lang

#797 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 6 lines · Ted Ts'o
Quoted 4 lines · Felipe Contreras

My guess is you haven't used a truly multi-tasking device like the N900; now that I've got used to it, I consider that functionality *essential*.

Quoted 8 lines

I've used an N800, and I wasn't impressed; if anything, the fact that I have to worry about manually killing off applications when memory gets low, I actually thought it was incredibly sucky.  It was a miniature, badly done laptop.

Maybe the N900 is different, but the bigger question is what do you mean by "multi-tasking"?  Definitions are critical here, which is why Paul was so careful in his definitions section of his document.

Yes, the N900 is drastically different, for starters, it has an actual window manager.

By multi-tasking I mean me (the user) being able to perform multiple tasks at the same time.

For example: writing an email, while browsing the web, while having IM conversations. Obviously not exactly at the same time; start writing an email, go browse for some url, copy, answer a pending IM message, go back to the mail, paste.

Quoted 10 lines
Quoted 10 lines

The argument in favor of suspend blockers is that you could take applications that are not designed for embedded, and make them run on an embedded device without draining excessive battery life; those applications would have to be background services not conflicting with Android's design.

I agree there probably would not be that many background apps, and probably even less ported background apps, but that is actually an argument against suspend blockers.

Quoted 8 lines
Quoted 3 lines

The rest of the apps (UI apps), cannot be ported, but have to be written specifically for Android, and therefore should have PM in mind, and not require suspend blockers to have good power usage.

If you are using a GUI framework which is optimized for a single- application-focus-at-a-time UI that isn't GNOME or KDE, then that will require the applications to be written.  However, that's not because of suspend-blockers.

Let's concentrate; Android is the only mobile platform that has expressed interested in suspend blockers. UI applications in Android are written specifically for Android. Period.

Other platforms, such as MeeGo, rely on Qt API, not suspend blockers.

Quoted 9 lines

If you assume a GUI framework which is flexible enough --- maybe Qt falls into this category, maybe not --- for the rest of the applications, they don't need to *know* about suspend blockers, and they certainly do't have to be rewritten or modified specifically for suspend blockers.  So if your argument is that applications that don't need bacground services (which you've admitted comprises majority of applicatios) need to be modified or written specifically to support suspend blockers, that's simply not true.  They don't need to be modified at all.

That's not my argument at all. I was talking about a counter-argument to "suspend blockers make porting desktop apps easer".

Android's UI applications are unimportant here because they have not been ported from the desktop realm; they were designed specifically for Android, including all its PM capabilities.

The only relevant applications are the ones designed for the desktop that are ported to Android, and thus might make assumptions that hurt battery life. These are background services.

If you are saying that there are few background apps, then that's an argument against suspend blockers:
1) few applications can be ported
2) the few applications that can be ported, being background
services, might miss timers and behave worst than _without_ suspend blockers

Quoted 11 lines

As far as whether they *should* require suspend blockers to be in the kernel to get power usage that is suitable for cell phone batteries, I would agree that in the ideal world, it would be nice if you could have applications that make the correct performance/battery utilization tradeoff for devices running on 800 mWh batteries, 94,000 mWh batteries, and while running on the AC mains.  But I don't believe that it's likely to be true, and if you want to try to beat up on application writers one at a time to be power optimized --- as far as I'm concerned, that's an argument *for* suspend blockers, since I'm not big believer in plans that begin, "First, you command the tides of the sea to go back", King Canute style.  :-)

Power is just like any other resource, why are desktop applications not using 100% CPU, or 100% of memory? Because if they did nobody would be using them. There's a social pressure to use less resources, or at least less resources than the competence. If an application uses too much battery time nobody would use it, unless perhaps if the functionality is too good and there are no alternatives.

I believe social forces already deal with this problem, all we need to do is provide better tools, not patronize user-space applications.

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#798 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 6 lines · Ted Ts'o
Quoted 4 lines · Felipe Contreras

My guess is you haven't used a truly multi-tasking device like the N900; now that I've got used to it, I consider that functionality *essential*.

Quoted 8 lines

I've used an N800, and I wasn't impressed; if anything, the fact that I have to worry about manually killing off applications when memory gets low, I actually thought it was incredibly sucky.  It was a miniature, badly done laptop.

Maybe the N900 is different, but the bigger question is what do you mean by "multi-tasking"?  Definitions are critical here, which is why Paul was so careful in his definitions section of his document.

Yes, the N900 is drastically different, for starters, it has an actual window manager.

By multi-tasking I mean me (the user) being able to perform multiple tasks at the same time.

For example: writing an email, while browsing the web, while having IM conversations. Obviously not exactly at the same time; start writing an email, go browse for some url, copy, answer a pending IM message, go back to the mail, paste.

Quoted 10 lines
Quoted 10 lines

The argument in favor of suspend blockers is that you could take applications that are not designed for embedded, and make them run on an embedded device without draining excessive battery life; those applications would have to be background services not conflicting with Android's design.

I agree there probably would not be that many background apps, and probably even less ported background apps, but that is actually an argument against suspend blockers.

Quoted 8 lines
Quoted 3 lines

The rest of the apps (UI apps), cannot be ported, but have to be written specifically for Android, and therefore should have PM in mind, and not require suspend blockers to have good power usage.

If you are using a GUI framework which is optimized for a single- application-focus-at-a-time UI that isn't GNOME or KDE, then that will require the applications to be written.  However, that's not because of suspend-blockers.

Let's concentrate; Android is the only mobile platform that has expressed interested in suspend blockers. UI applications in Android are written specifically for Android. Period.

Other platforms, such as MeeGo, rely on Qt API, not suspend blockers.

Quoted 9 lines

If you assume a GUI framework which is flexible enough --- maybe Qt falls into this category, maybe not --- for the rest of the applications, they don't need to *know* about suspend blockers, and they certainly do't have to be rewritten or modified specifically for suspend blockers.  So if your argument is that applications that don't need bacground services (which you've admitted comprises majority of applicatios) need to be modified or written specifically to support suspend blockers, that's simply not true.  They don't need to be modified at all.

That's not my argument at all. I was talking about a counter-argument to "suspend blockers make porting desktop apps easer".

Android's UI applications are unimportant here because they have not been ported from the desktop realm; they were designed specifically for Android, including all its PM capabilities.

The only relevant applications are the ones designed for the desktop that are ported to Android, and thus might make assumptions that hurt battery life. These are background services.

If you are saying that there are few background apps, then that's an argument against suspend blockers:
1) few applications can be ported
2) the few applications that can be ported, being background
services, might miss timers and behave worst than _without_ suspend blockers

Quoted 11 lines

As far as whether they *should* require suspend blockers to be in the kernel to get power usage that is suitable for cell phone batteries, I would agree that in the ideal world, it would be nice if you could have applications that make the correct performance/battery utilization tradeoff for devices running on 800 mWh batteries, 94,000 mWh batteries, and while running on the AC mains.  But I don't believe that it's likely to be true, and if you want to try to beat up on application writers one at a time to be power optimized --- as far as I'm concerned, that's an argument *for* suspend blockers, since I'm not big believer in plans that begin, "First, you command the tides of the sea to go back", King Canute style.  :-)

Power is just like any other resource, why are desktop applications not using 100% CPU, or 100% of memory? Because if they did nobody would be using them. There's a social pressure to use less resources, or at least less resources than the competence. If an application uses too much battery time nobody would use it, unless perhaps if the functionality is too good and there are no alternatives.

I believe social forces already deal with this problem, all we need to do is provide better tools, not patronize user-space applications.

Signature · 1 line
Felipe Contreras
#656 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 4 lines · Paul E. McKenney

But wouldn't an office suite run as a power-oblivious application on an Android device?  After all, office applications do not need to run when the screen is turned off, so these the applications do not need to use suspend blockers.

Ideally the system would be suspended even when the screen is on. If there are no "trusted" applications running at the same time, then openoffice wouldn't load at all. Right?

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#657 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 4 lines · Paul E. McKenney

But wouldn't an office suite run as a power-oblivious application on an Android device?  After all, office applications do not need to run when the screen is turned off, so these the applications do not need to use suspend blockers.

Ideally the system would be suspended even when the screen is on. If there are no "trusted" applications running at the same time, then openoffice wouldn't load at all. Right?

Signature · 1 line
Felipe Contreras
#651 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 11 lines · Paul E. McKenney
Quoted 3 lines · Alan Cox

You are tightly linking suspend blockers with Android. If they were a sensible general solution they would be generic not tied closely to Android

Android is certainly where suspend blockers originated, and is to the best of my knowledge is still the only platform that uses them.  But there is a first user of every new mechanism, and for some time that first user will by definition be the only user of that mechanism.  So the fact that Android is most probably the only user of suspend blockers does not prove anything about whether or not suspend blockers are sensible.

No, it's the fact that *nobody* else has said: hey, that looks like a good idea, we should use that in our mobile platform (or any platform).

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#652 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 11 lines · Paul E. McKenney
Quoted 3 lines · Alan Cox

You are tightly linking suspend blockers with Android. If they were a sensible general solution they would be generic not tied closely to Android

Android is certainly where suspend blockers originated, and is to the best of my knowledge is still the only platform that uses them.  But there is a first user of every new mechanism, and for some time that first user will by definition be the only user of that mechanism.  So the fact that Android is most probably the only user of suspend blockers does not prove anything about whether or not suspend blockers are sensible.

No, it's the fact that *nobody* else has said: hey, that looks like a good idea, we should use that in our mobile platform (or any platform).

Signature · 1 line
Felipe Contreras
#799 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 5 lines · Felipe Contreras

Let's concentrate; Android is the only mobile platform that has expressed interested in suspend blockers. UI applications in Android are written specifically for Android. Period.

Other platforms, such as MeeGo, rely on Qt API, not suspend blockers.

I think you're wrong that this will be sufficient, but I've already stated my position before, namely that what you do when you only have 800mWh has very different performance/battery tradeoffs than when you have 94,000mWh batteries. One of the reasons why my mail archive for this discussion has over 1800 messages and is close to 10MB is that everyone keeps saying the same thing over and over again. So I'm not going to say it again.

I was thinking that the only way we can tell is for us to go away and come back in two years, and we can see whether or not Meego is getting the same 200,000 activations per day that Android is, and maybe *then* people will understand.

However, earlier today, I had a very productive conversation with an engineer from Nokia who has had many years of experience of doing power management for cell phones, and who is now trying to make Meego power efficient enough for cell phones, and he seemed to think that problem which suspend blockers or wakelocks are trying to solve was valid.

I now believe that part of the problem is that is that many Meego folks only have an experience with Netbooks or Laptops, and don't appreciate that sometimes, when you make such a radical change in battery capacity to a mobile handset, things become qualitatively different, and not just quantitatively different. Put another way, a laptop has six hours of battery lifetime with 94,000 mWh worth of battery; a cell phone needs to be able to be usable over a 20-24 hour period of despite having a 800-1200 mWh battery --- and what you need do for these two are different.

This is very similar to how trying to make a kernel scale to 512 NUMA nodes is quite different to trying make a kernel work with 4-8 SMP cpu's. Until you've actually tried doing it, you might think that all you have to do is just throw in a bunch of spinlocks and rw spinlocks. But it turns out it's a lot harder than that --- but it's very hard to convince someone who hasn't had that experience to understand why that is true.

So it may very well be that we should just agree to disagree, and if there are one or more Nokia engineers who are interested in doing something that would help their cell phones (I will let them speak up and clarify their positions for themselves), that they work directly with those who agree that there _is_ a problem.

At that point, we can either keep these patches out of tree, much like how the SGI Altix has patches that are needed so that the Linux kernel scales enough so it will even successfully complete its kernel initialization successfully. Or if there is consensus between people who are interested at Linaro (if any), Nokia (if any), and Android (if any), maybe we take this directly to Linus, and he can say yes or no.

But for those who are unwilling to believe it isn't even a problem, I don't know that another 2000 e-mail messages, and another 10MB of mail archives, is going to achieve anything. Let's just agree to disagree.

- Ted

P.S. Just to make it clear, I am speaking only for myself, and not for the Android team and not for Google in any way, shape, or form. Nor was the person from Nokia who expressed to me his opinions was not necessarily expressing the opinions of Nokia or (obviously) Meego.

#800 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 5 lines · Felipe Contreras

Let's concentrate; Android is the only mobile platform that has expressed interested in suspend blockers. UI applications in Android are written specifically for Android. Period.

Other platforms, such as MeeGo, rely on Qt API, not suspend blockers.

I think you're wrong that this will be sufficient, but I've already stated my position before, namely that what you do when you only have 800mWh has very different performance/battery tradeoffs than when you have 94,000mWh batteries. One of the reasons why my mail archive for this discussion has over 1800 messages and is close to 10MB is that everyone keeps saying the same thing over and over again. So I'm not going to say it again.

I was thinking that the only way we can tell is for us to go away and come back in two years, and we can see whether or not Meego is getting the same 200,000 activations per day that Android is, and maybe *then* people will understand.

However, earlier today, I had a very productive conversation with an engineer from Nokia who has had many years of experience of doing power management for cell phones, and who is now trying to make Meego power efficient enough for cell phones, and he seemed to think that problem which suspend blockers or wakelocks are trying to solve was valid.

I now believe that part of the problem is that is that many Meego folks only have an experience with Netbooks or Laptops, and don't appreciate that sometimes, when you make such a radical change in battery capacity to a mobile handset, things become qualitatively different, and not just quantitatively different. Put another way, a laptop has six hours of battery lifetime with 94,000 mWh worth of battery; a cell phone needs to be able to be usable over a 20-24 hour period of despite having a 800-1200 mWh battery --- and what you need do for these two are different.

This is very similar to how trying to make a kernel scale to 512 NUMA nodes is quite different to trying make a kernel work with 4-8 SMP cpu's. Until you've actually tried doing it, you might think that all you have to do is just throw in a bunch of spinlocks and rw spinlocks. But it turns out it's a lot harder than that --- but it's very hard to convince someone who hasn't had that experience to understand why that is true.

So it may very well be that we should just agree to disagree, and if there are one or more Nokia engineers who are interested in doing something that would help their cell phones (I will let them speak up and clarify their positions for themselves), that they work directly with those who agree that there _is_ a problem.

At that point, we can either keep these patches out of tree, much like how the SGI Altix has patches that are needed so that the Linux kernel scales enough so it will even successfully complete its kernel initialization successfully. Or if there is consensus between people who are interested at Linaro (if any), Nokia (if any), and Android (if any), maybe we take this directly to Linus, and he can say yes or no.

But for those who are unwilling to believe it isn't even a problem, I don't know that another 2000 e-mail messages, and another 10MB of mail archives, is going to achieve anything. Let's just agree to disagree.

- Ted

P.S. Just to make it clear, I am speaking only for myself, and not for the Android team and not for Google in any way, shape, or form. Nor was the person from Nokia who expressed to me his opinions was not necessarily expressing the opinions of Nokia or (obviously) Meego.

#653 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 9 lines · Felipe Contreras

On Tue, Aug 10, 2010 at 7:45 AM, Paul E. McKenney

Quoted 6 lines

Android is certainly where suspend blockers originated, and is to the best of my knowledge is still the only platform that uses them. ??But there is a first user of every new mechanism, and for some time that first user will by definition be the only user of that mechanism. ??So the fact that Android is most probably the only user of suspend blockers does not prove anything about whether or not suspend blockers are sensible.

Quoted 3 lines

No, it's the fact that *nobody* else has said: hey, that looks like a good idea, we should use that in our mobile platform (or any platform).

I don't think lack of external adoption is a terribly useful data point either way at the minute. While the feature is controversial a lot of the OSs will probably hold off on it (because it's effort to handle out of tree stuff and folks are really busy) and there's not that many out there which support random externally written packages (which is the major push for exporting the feature to userspace) in the first place.

#654 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 9 lines · Felipe Contreras

On Tue, Aug 10, 2010 at 7:45 AM, Paul E. McKenney

Quoted 6 lines

Android is certainly where suspend blockers originated, and is to the best of my knowledge is still the only platform that uses them. ??But there is a first user of every new mechanism, and for some time that first user will by definition be the only user of that mechanism. ??So the fact that Android is most probably the only user of suspend blockers does not prove anything about whether or not suspend blockers are sensible.

Quoted 3 lines

No, it's the fact that *nobody* else has said: hey, that looks like a good idea, we should use that in our mobile platform (or any platform).

I don't think lack of external adoption is a terribly useful data point either way at the minute. While the feature is controversial a lot of the OSs will probably hold off on it (because it's effort to handle out of tree stuff and folks are really busy) and there's not that many out there which support random externally written packages (which is the major push for exporting the feature to userspace) in the first place.

#630 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 12 lines · Paul E. McKenney
Quoted 10 lines · Alan Cox

You may also wish to review the earlier parts of the discussion where it was explicitly stated by several developers that they were using "suspend" type modes as power states already and not using suspend blockers. So it's being done, today on ARM and your statement is directly contradicting the code. Modern ARM processors and x86 MID devices can suspend and resume extremely fast (fast enough that the fact Linux x86 rewriting all the SMP alternatives on suspend/resume is a measurable problem). If this same property doesn't end up on big PC boxes in time then I'd be very surprised. At that point the openoffice with suspend blockers or oracle with suspend blockers question becomes rather relevant.

Quoted 7 lines

Here is the list of properties distinguishing idle from suspend:

1.      Idle states are entered by a given CPU only there are no runnable tasks for that CPU.  In contrast, opportunistic suspend can halt the entire system even when there are tasks that are ready, willing, and able to run.  (But please note that this might not apply to real-time tasks.)

But if there are no runnable tasks (which is the target), they behave the same.

Quoted 6 lines

2.      There can be a set of input events that do not bring the system out of suspend, but which would bring the system out of idle. Exactly which events are in this set depends both on hardware capabilities and on the platform/application policy.  For example, on one of the Android-based smartphones, touchscreen input is ignored when the system is suspended, but is handled when idle.

And in N900 touching the screen doesn't bring the device out of idle, I guess because it's off.

What devices do what on which circumstances on what platform is completely irrelevant.

Quoted 4 lines

3.      The system comes out of idle when a timer expires.  In contrast, timers might or might not bring the system out of suspend, depending on both hardware capabilities and platform/application policy.

Isn't this solved by range timers?

Quoted 5 lines

4.      Suspend generally forces devices to go into their low-power states immediately.  In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices.  Idle thus has shorter average wakeup latencies, but worse energy efficiency.

Only if you make these assumptions
1) All the applications use suspend-blockers only when they absolutely must
2) The user has given the right applications the right access

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#631 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 12 lines · Paul E. McKenney
Quoted 10 lines · Alan Cox

You may also wish to review the earlier parts of the discussion where it was explicitly stated by several developers that they were using "suspend" type modes as power states already and not using suspend blockers. So it's being done, today on ARM and your statement is directly contradicting the code. Modern ARM processors and x86 MID devices can suspend and resume extremely fast (fast enough that the fact Linux x86 rewriting all the SMP alternatives on suspend/resume is a measurable problem). If this same property doesn't end up on big PC boxes in time then I'd be very surprised. At that point the openoffice with suspend blockers or oracle with suspend blockers question becomes rather relevant.

Quoted 7 lines

Here is the list of properties distinguishing idle from suspend:

1.      Idle states are entered by a given CPU only there are no runnable tasks for that CPU.  In contrast, opportunistic suspend can halt the entire system even when there are tasks that are ready, willing, and able to run.  (But please note that this might not apply to real-time tasks.)

But if there are no runnable tasks (which is the target), they behave the same.

Quoted 6 lines

2.      There can be a set of input events that do not bring the system out of suspend, but which would bring the system out of idle. Exactly which events are in this set depends both on hardware capabilities and on the platform/application policy.  For example, on one of the Android-based smartphones, touchscreen input is ignored when the system is suspended, but is handled when idle.

And in N900 touching the screen doesn't bring the device out of idle, I guess because it's off.

What devices do what on which circumstances on what platform is completely irrelevant.

Quoted 4 lines

3.      The system comes out of idle when a timer expires.  In contrast, timers might or might not bring the system out of suspend, depending on both hardware capabilities and platform/application policy.

Isn't this solved by range timers?

Quoted 5 lines

4.      Suspend generally forces devices to go into their low-power states immediately.  In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices.  Idle thus has shorter average wakeup latencies, but worse energy efficiency.

Only if you make these assumptions
1) All the applications use suspend-blockers only when they absolutely must
2) The user has given the right applications the right access

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

Signature · 1 line
Felipe Contreras
#801 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 7 lines · Ted Ts'o
Quoted 5 lines · Felipe Contreras

Let's concentrate; Android is the only mobile platform that has expressed interested in suspend blockers. UI applications in Android are written specifically for Android. Period.

Other platforms, such as MeeGo, rely on Qt API, not suspend blockers.

Quoted 7 lines

I think you're wrong that this will be sufficient, but I've already stated my position before, namely that what you do when you only have 800mWh has very different performance/battery tradeoffs than when you have 94,000mWh batteries.  One of the reasons why my mail archive for this discussion has over 1800 messages and is close to 10MB is that everyone keeps saying the same thing over and over again.  So I'm not going to say it again.

Applications need to take smart decisions to save power based on a number of things: is the screen on? is the ear close to the speaker? is there a network available? is it a cellular connection? has the user decided to automatically disconnect from the network after certain time, or at night? etc. I think that, and range timers / ip heartbeat is enough. But that, as you say has been discussed before.

Now, only Android has decided to use suspend blockers, that's a *fact*, and I wanted to narrow the discussion to Android in order to make it easier to understand that Android doesn't need suspend blockers, once we have agreed that, then I'd gladly discuss it's merits outside Android.

Quoted 4 lines

I was thinking that the only way we can tell is for us to go away and come back in two years, and we can see whether or not Meego is getting the same 200,000 activations per day that Android is, and maybe *then* people will understand.

Are you kidding? Even if MeeGo fails in being as popular as Android, that doesn't saying anything about whether suspend-blockers are sensible or not. Besides, there is also the possibility that Android people realize they don't need suspend-blockers.

Quoted 6 lines

However, earlier today, I had a very productive conversation with an engineer from Nokia who has had many years of experience of doing power management for cell phones, and who is now trying to make Meego power efficient enough for cell phones, and he seemed to think that problem which suspend blockers or wakelocks are trying to solve was valid.

So? I'm sure there's some people in Google that believe that suspend-blockers are not needed.

Quoted 9 lines

I now believe that part of the problem is that is that many Meego folks only have an experience with Netbooks or Laptops, and don't appreciate that sometimes, when you make such a radical change in battery capacity to a mobile handset, things become qualitatively different, and not just quantitatively different.  Put another way, a laptop has six hours of battery lifetime with 94,000 mWh worth of battery; a cell phone needs to be able to be usable over a 20-24 hour period of despite having a 800-1200 mWh battery --- and what you need do for these two are different.

Right. Nokia people only have experience with laptops. Surely my N900 lasts days because it's receiving energy from another dimension.

Quoted 7 lines

This is very similar to how trying to make a kernel scale to 512 NUMA nodes is quite different to trying make a kernel work with 4-8 SMP cpu's.  Until you've actually tried doing it, you might think that all you have to do is just throw in a bunch of spinlocks and rw spinlocks. But it turns out it's a lot harder than that --- but it's very hard to convince someone who hasn't had that experience to understand why that is true.

We are talking about user-space.

Quoted 5 lines

So it may very well be that we should just agree to disagree, and if there are one or more Nokia engineers who are interested in doing something that would help their cell phones (I will let them speak up and clarify their positions for themselves), that they work directly with those who agree that there _is_ a problem.

Yeah, there is a problem, and the solution doesn't require suspend-blockers.

Quoted 10 lines

At that point, we can either keep these patches out of tree, much like how the SGI Altix has patches that are needed so that the Linux kernel scales enough so it will even successfully complete its kernel initialization successfully.  Or if there is consensus between people who are interested at Linaro (if any), Nokia (if any), and Android (if any), maybe we take this directly to Linus, and he can say yes or no.

But for those who are unwilling to believe it isn't even a problem, I don't know that another 2000 e-mail messages, and another 10MB of mail archives, is going to achieve anything.  Let's just agree to disagree.

I argued to you that suspend-blockers are not required in Android, and suddenly you decide we should agree to disagree without arguing back? Well, suit yourself. I still maintain that suspend-blockers is just an expensive workaround, and in some cases actually degrades power consumption; the right solution is much more sophisticated.

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#802 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 7 lines · Ted Ts'o
Quoted 5 lines · Felipe Contreras

Let's concentrate; Android is the only mobile platform that has expressed interested in suspend blockers. UI applications in Android are written specifically for Android. Period.

Other platforms, such as MeeGo, rely on Qt API, not suspend blockers.

Quoted 7 lines

I think you're wrong that this will be sufficient, but I've already stated my position before, namely that what you do when you only have 800mWh has very different performance/battery tradeoffs than when you have 94,000mWh batteries.  One of the reasons why my mail archive for this discussion has over 1800 messages and is close to 10MB is that everyone keeps saying the same thing over and over again.  So I'm not going to say it again.

Applications need to take smart decisions to save power based on a number of things: is the screen on? is the ear close to the speaker? is there a network available? is it a cellular connection? has the user decided to automatically disconnect from the network after certain time, or at night? etc. I think that, and range timers / ip heartbeat is enough. But that, as you say has been discussed before.

Now, only Android has decided to use suspend blockers, that's a *fact*, and I wanted to narrow the discussion to Android in order to make it easier to understand that Android doesn't need suspend blockers, once we have agreed that, then I'd gladly discuss it's merits outside Android.

Quoted 4 lines

I was thinking that the only way we can tell is for us to go away and come back in two years, and we can see whether or not Meego is getting the same 200,000 activations per day that Android is, and maybe *then* people will understand.

Are you kidding? Even if MeeGo fails in being as popular as Android, that doesn't saying anything about whether suspend-blockers are sensible or not. Besides, there is also the possibility that Android people realize they don't need suspend-blockers.

Quoted 6 lines

However, earlier today, I had a very productive conversation with an engineer from Nokia who has had many years of experience of doing power management for cell phones, and who is now trying to make Meego power efficient enough for cell phones, and he seemed to think that problem which suspend blockers or wakelocks are trying to solve was valid.

So? I'm sure there's some people in Google that believe that suspend-blockers are not needed.

Quoted 9 lines

I now believe that part of the problem is that is that many Meego folks only have an experience with Netbooks or Laptops, and don't appreciate that sometimes, when you make such a radical change in battery capacity to a mobile handset, things become qualitatively different, and not just quantitatively different.  Put another way, a laptop has six hours of battery lifetime with 94,000 mWh worth of battery; a cell phone needs to be able to be usable over a 20-24 hour period of despite having a 800-1200 mWh battery --- and what you need do for these two are different.

Right. Nokia people only have experience with laptops. Surely my N900 lasts days because it's receiving energy from another dimension.

Quoted 7 lines

This is very similar to how trying to make a kernel scale to 512 NUMA nodes is quite different to trying make a kernel work with 4-8 SMP cpu's.  Until you've actually tried doing it, you might think that all you have to do is just throw in a bunch of spinlocks and rw spinlocks. But it turns out it's a lot harder than that --- but it's very hard to convince someone who hasn't had that experience to understand why that is true.

We are talking about user-space.

Quoted 5 lines

So it may very well be that we should just agree to disagree, and if there are one or more Nokia engineers who are interested in doing something that would help their cell phones (I will let them speak up and clarify their positions for themselves), that they work directly with those who agree that there _is_ a problem.

Yeah, there is a problem, and the solution doesn't require suspend-blockers.

Quoted 10 lines

At that point, we can either keep these patches out of tree, much like how the SGI Altix has patches that are needed so that the Linux kernel scales enough so it will even successfully complete its kernel initialization successfully.  Or if there is consensus between people who are interested at Linaro (if any), Nokia (if any), and Android (if any), maybe we take this directly to Linus, and he can say yes or no.

But for those who are unwilling to believe it isn't even a problem, I don't know that another 2000 e-mail messages, and another 10MB of mail archives, is going to achieve anything.  Let's just agree to disagree.

I argued to you that suspend-blockers are not required in Android, and suddenly you decide we should agree to disagree without arguing back? Well, suit yourself. I still maintain that suspend-blockers is just an expensive workaround, and in some cases actually degrades power consumption; the right solution is much more sophisticated.

Signature · 1 line
Felipe Contreras
#803 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 5 lines · Felipe Contreras

Now, only Android has decided to use suspend blockers, that's a *fact*, and I wanted to narrow the discussion to Android in order to make it easier to understand that Android doesn't need suspend blockers, once we have agreed that, then I'd gladly discuss it's merits outside Android.

On behalf of the Android folks, we don't agree with this. If you're going to wait until we suddenly change our minds, I think you're going to be in for a long wait.

Quoted 5 lines

I argued to you that suspend-blockers are not required in Android, and suddenly you decide we should agree to disagree without arguing back? Well, suit yourself. I still maintain that suspend-blockers is just an expensive workaround, and in some cases actually degrades power consumption; the right solution is much more sophisticated.

Once "the right solution" exists and solves our problems, we'll certainly look into switching over to it. I've yet to see a proposal in all this arguing that appears to me to be an improvement over what we have today with suspend blockers. I find the "don't do what you're doing because someday, somebody will do it better" to be an uncompelling argument.

Given your opinion that Android lacks multitasking (what? really?) and various other strange statements about the platform, I'm likely to be taking your suggestions with generous helping of skepticism.

Brian

#804 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 5 lines · Felipe Contreras

Now, only Android has decided to use suspend blockers, that's a *fact*, and I wanted to narrow the discussion to Android in order to make it easier to understand that Android doesn't need suspend blockers, once we have agreed that, then I'd gladly discuss it's merits outside Android.

On behalf of the Android folks, we don't agree with this. If you're going to wait until we suddenly change our minds, I think you're going to be in for a long wait.

Quoted 5 lines

I argued to you that suspend-blockers are not required in Android, and suddenly you decide we should agree to disagree without arguing back? Well, suit yourself. I still maintain that suspend-blockers is just an expensive workaround, and in some cases actually degrades power consumption; the right solution is much more sophisticated.

Once "the right solution" exists and solves our problems, we'll certainly look into switching over to it. I've yet to see a proposal in all this arguing that appears to me to be an improvement over what we have today with suspend blockers. I find the "don't do what you're doing because someday, somebody will do it better" to be an uncompelling argument.

Given your opinion that Android lacks multitasking (what? really?) and various other strange statements about the platform, I'm likely to be taking your suggestions with generous helping of skepticism.

Brian

#805 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 11 lines · Brian Swetland
Quoted 5 lines · Felipe Contreras

Now, only Android has decided to use suspend blockers, that's a *fact*, and I wanted to narrow the discussion to Android in order to make it easier to understand that Android doesn't need suspend blockers, once we have agreed that, then I'd gladly discuss it's merits outside Android.

On behalf of the Android folks, we don't agree with this.  If you're going to wait until we suddenly change our minds, I think you're going to be in for a long wait.

I'm sure as a team that's the case, but you can't know what's in the mind of everyone at Google (not Android).

Quoted 6 lines
Quoted 5 lines

I argued to you that suspend-blockers are not required in Android, and suddenly you decide we should agree to disagree without arguing back? Well, suit yourself. I still maintain that suspend-blockers is just an expensive workaround, and in some cases actually degrades power consumption; the right solution is much more sophisticated.

Quoted 6 lines

Once "the right solution" exists and solves our problems, we'll certainly look into switching over to it.  I've yet to see a proposal in all this arguing that appears to me to be an improvement over what we have today with suspend blockers.  I find the "don't do what you're doing because someday, somebody will do it better" to be an uncompelling argument.

That was not an argument, it was an opinion. If you want an argument go back to read this one:
http://article.gmane.org/gmane.linux.kernel/1021834

Quoted 1 line

Given your opinion that Android lacks multitasking (what? really?)

This is what I'm talking about when I say multi-tasking, Android certainly doesn't have anything remotely like that:
http://www.youtube.com/watch?v=7emvUBpEkbU

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#806 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Brian Swetland
Quoted 11 lines · Brian Swetland
Quoted 5 lines · Felipe Contreras

Now, only Android has decided to use suspend blockers, that's a *fact*, and I wanted to narrow the discussion to Android in order to make it easier to understand that Android doesn't need suspend blockers, once we have agreed that, then I'd gladly discuss it's merits outside Android.

On behalf of the Android folks, we don't agree with this.  If you're going to wait until we suddenly change our minds, I think you're going to be in for a long wait.

I'm sure as a team that's the case, but you can't know what's in the mind of everyone at Google (not Android).

Quoted 6 lines
Quoted 5 lines

I argued to you that suspend-blockers are not required in Android, and suddenly you decide we should agree to disagree without arguing back? Well, suit yourself. I still maintain that suspend-blockers is just an expensive workaround, and in some cases actually degrades power consumption; the right solution is much more sophisticated.

Quoted 6 lines

Once "the right solution" exists and solves our problems, we'll certainly look into switching over to it.  I've yet to see a proposal in all this arguing that appears to me to be an improvement over what we have today with suspend blockers.  I find the "don't do what you're doing because someday, somebody will do it better" to be an uncompelling argument.

That was not an argument, it was an opinion. If you want an argument go back to read this one:
http://article.gmane.org/gmane.linux.kernel/1021834

Quoted 1 line

Given your opinion that Android lacks multitasking (what? really?)

This is what I'm talking about when I say multi-tasking, Android certainly doesn't have anything remotely like that:
http://www.youtube.com/watch?v=7emvUBpEkbU

Signature · 1 line
Felipe Contreras
#807 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 11 lines · Felipe Contreras
Quoted 6 lines

Once "the right solution" exists and solves our problems, we'll certainly look into switching over to it.  I've yet to see a proposal in all this arguing that appears to me to be an improvement over what we have today with suspend blockers.  I find the "don't do what you're doing because someday, somebody will do it better" to be an uncompelling argument.

That was not an argument, it was an opinion. If you want an argument go back to read this one:
http://article.gmane.org/gmane.linux.kernel/1021834

Quoted 5 lines
Quoted 1 line

Given your opinion that Android lacks multitasking (what? really?)

This is what I'm talking about when I say multi-tasking, Android certainly doesn't have anything remotely like that:
http://www.youtube.com/watch?v=7emvUBpEkbU

Home + pick app -> switch to the app in whatever state it was in.

Home (longpress) -> recent app list + pick app from popup -> switch to recent app in whatever state it was in.

pull down alert windowshade + pick app from alerts list -> switch to that app

I routinely flip back and forth between email / browser / IM / musicplayer / etc

I have no problem with you perhaps liking the visuals of the N900 better, but to say Android lacks multitasking (as you explain it below) is incorrect:

Quoted 7 lines

By multi-tasking I mean me (the user) being able to perform multiple tasks at the same time.

For example: writing an email, while browsing the web, while having IM conversations. Obviously not exactly at the same time; start writing an email, go browse for some url, copy, answer a pending IM message, go back to the mail, paste.

As far as implementing app switching with a deck of cards metaphor, I've seen that done by some OEMs with Android, though it's not the default system UI.

Brian
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm

#808 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 11 lines · Felipe Contreras
Quoted 6 lines

Once "the right solution" exists and solves our problems, we'll certainly look into switching over to it.  I've yet to see a proposal in all this arguing that appears to me to be an improvement over what we have today with suspend blockers.  I find the "don't do what you're doing because someday, somebody will do it better" to be an uncompelling argument.

That was not an argument, it was an opinion. If you want an argument go back to read this one:
http://article.gmane.org/gmane.linux.kernel/1021834

Quoted 5 lines
Quoted 1 line

Given your opinion that Android lacks multitasking (what? really?)

This is what I'm talking about when I say multi-tasking, Android certainly doesn't have anything remotely like that:
http://www.youtube.com/watch?v=7emvUBpEkbU

Home + pick app -> switch to the app in whatever state it was in.

Home (longpress) -> recent app list + pick app from popup -> switch to recent app in whatever state it was in.

pull down alert windowshade + pick app from alerts list -> switch to that app

I routinely flip back and forth between email / browser / IM / musicplayer / etc

I have no problem with you perhaps liking the visuals of the N900 better, but to say Android lacks multitasking (as you explain it below) is incorrect:

Quoted 7 lines

By multi-tasking I mean me (the user) being able to perform multiple tasks at the same time.

For example: writing an email, while browsing the web, while having IM conversations. Obviously not exactly at the same time; start writing an email, go browse for some url, copy, answer a pending IM message, go back to the mail, paste.

As far as implementing app switching with a deck of cards metaphor, I've seen that done by some OEMs with Android, though it's not the default system UI.

Brian

#632 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 16 lines · Felipe Contreras
Quoted 14 lines · Paul E. McKenney
Quoted 10 lines · Alan Cox

You may also wish to review the earlier parts of the discussion where it was explicitly stated by several developers that they were using "suspend" type modes as power states already and not using suspend blockers. So it's being done, today on ARM and your statement is directly contradicting the code. Modern ARM processors and x86 MID devices can suspend and resume extremely fast (fast enough that the fact Linux x86 rewriting all the SMP alternatives on suspend/resume is a measurable problem). If this same property doesn't end up on big PC boxes in time then I'd be very surprised. At that point the openoffice with suspend blockers or oracle with suspend blockers question becomes rather relevant.

Here is the list of properties distinguishing idle from suspend:

Quoted 7 lines
Quoted 5 lines

1.      Idle states are entered by a given CPU only there are no runnable tasks for that CPU.  In contrast, opportunistic suspend can halt the entire system even when there are tasks that are ready, willing, and able to run.  (But please note that this might not apply to real-time tasks.)

But if there are no runnable tasks (which is the target), they behave the same.

And if there are runnable tasks, then then don't behave the same. Apparently different people in this debate have different targets.

Quoted 9 lines
Quoted 6 lines

2.      There can be a set of input events that do not bring the system out of suspend, but which would bring the system out of idle. Exactly which events are in this set depends both on hardware capabilities and on the platform/application policy.  For example, on one of the Android-based smartphones, touchscreen input is ignored when the system is suspended, but is handled when idle.

And in N900 touching the screen doesn't bring the device out of idle, I guess because it's off.

As long as touching the N900 screen doesn't bring the device out of suspend, its behavior is not a counterexample to #2 above.

Quoted 2 lines

What devices do what on which circumstances on what platform is completely irrelevant.

Do you -really- want me to start listing counterexamples to that brave statement? ;-)

Quoted 6 lines
Quoted 4 lines

3.      The system comes out of idle when a timer expires.  In contrast, timers might or might not bring the system out of suspend, depending on both hardware capabilities and platform/application policy.

Isn't this solved by range timers?

Ahem. This is a list of differences between idle and suspend, not a list of problems to be solved. But to answer your question, if a timer does not bring a given device out of suspend, then a range timer is not likely to, either. Don't get me wrong, I do believe that range timers have an important part to play in the energy-efficiency arena, but I have not been convinced that they are any kind of silver bullet.

Quoted 9 lines
Quoted 5 lines

4.      Suspend generally forces devices to go into their low-power states immediately.  In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices.  Idle thus has shorter average wakeup latencies, but worse energy efficiency.

Only if you make these assumptions
1) All the applications use suspend-blockers only when they absolutely must
2) The user has given the right applications the right access

You believe that these assumptions are unreasonable? Compared to the assumption that all applications are carefully written to conserve power? If so, on what grounds?

It seems to me that the same social-engineering approaches work in both cases.

Quoted 2 lines

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

Really? What makes you say that?

Thanx, Paul

#633 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 16 lines · Felipe Contreras
Quoted 14 lines · Paul E. McKenney
Quoted 10 lines · Alan Cox

You may also wish to review the earlier parts of the discussion where it was explicitly stated by several developers that they were using "suspend" type modes as power states already and not using suspend blockers. So it's being done, today on ARM and your statement is directly contradicting the code. Modern ARM processors and x86 MID devices can suspend and resume extremely fast (fast enough that the fact Linux x86 rewriting all the SMP alternatives on suspend/resume is a measurable problem). If this same property doesn't end up on big PC boxes in time then I'd be very surprised. At that point the openoffice with suspend blockers or oracle with suspend blockers question becomes rather relevant.

Here is the list of properties distinguishing idle from suspend:

Quoted 7 lines
Quoted 5 lines

1.      Idle states are entered by a given CPU only there are no runnable tasks for that CPU.  In contrast, opportunistic suspend can halt the entire system even when there are tasks that are ready, willing, and able to run.  (But please note that this might not apply to real-time tasks.)

But if there are no runnable tasks (which is the target), they behave the same.

And if there are runnable tasks, then then don't behave the same. Apparently different people in this debate have different targets.

Quoted 9 lines
Quoted 6 lines

2.      There can be a set of input events that do not bring the system out of suspend, but which would bring the system out of idle. Exactly which events are in this set depends both on hardware capabilities and on the platform/application policy.  For example, on one of the Android-based smartphones, touchscreen input is ignored when the system is suspended, but is handled when idle.

And in N900 touching the screen doesn't bring the device out of idle, I guess because it's off.

As long as touching the N900 screen doesn't bring the device out of suspend, its behavior is not a counterexample to #2 above.

Quoted 2 lines

What devices do what on which circumstances on what platform is completely irrelevant.

Do you -really- want me to start listing counterexamples to that brave statement? ;-)

Quoted 6 lines
Quoted 4 lines

3.      The system comes out of idle when a timer expires.  In contrast, timers might or might not bring the system out of suspend, depending on both hardware capabilities and platform/application policy.

Isn't this solved by range timers?

Ahem. This is a list of differences between idle and suspend, not a list of problems to be solved. But to answer your question, if a timer does not bring a given device out of suspend, then a range timer is not likely to, either. Don't get me wrong, I do believe that range timers have an important part to play in the energy-efficiency arena, but I have not been convinced that they are any kind of silver bullet.

Quoted 9 lines
Quoted 5 lines

4.      Suspend generally forces devices to go into their low-power states immediately.  In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices.  Idle thus has shorter average wakeup latencies, but worse energy efficiency.

Only if you make these assumptions
1) All the applications use suspend-blockers only when they absolutely must
2) The user has given the right applications the right access

You believe that these assumptions are unreasonable? Compared to the assumption that all applications are carefully written to conserve power? If so, on what grounds?

It seems to me that the same social-engineering approaches work in both cases.

Quoted 2 lines

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

Really? What makes you say that?

Thanx, Paul

#658 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 10 lines · Felipe Contreras
Quoted 4 lines · Paul E. McKenney

But wouldn't an office suite run as a power-oblivious application on an Android device?  After all, office applications do not need to run when the screen is turned off, so these the applications do not need to use suspend blockers.

Ideally the system would be suspended even when the screen is on. If there are no "trusted" applications running at the same time, then openoffice wouldn't load at all. Right?

My understanding is that Android systems in fact do not suspend when the screen is on, and that most (perhaps all) other systems do not opportunistically suspend at all. There has been some speculation about what a hypothetical Android having a non-volatile display might do, but as far as I know, this is just speculation.

Thanx, Paul

#659 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 10 lines · Felipe Contreras
Quoted 4 lines · Paul E. McKenney

But wouldn't an office suite run as a power-oblivious application on an Android device?  After all, office applications do not need to run when the screen is turned off, so these the applications do not need to use suspend blockers.

Ideally the system would be suspended even when the screen is on. If there are no "trusted" applications running at the same time, then openoffice wouldn't load at all. Right?

My understanding is that Android systems in fact do not suspend when the screen is on, and that most (perhaps all) other systems do not opportunistically suspend at all. There has been some speculation about what a hypothetical Android having a non-volatile display might do, but as far as I know, this is just speculation.

Thanx, Paul

#628 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to [email protected]
Quoted 52 lines · On Tue, Aug 10, 2010 at 08:00:53PM -0700, [email protected] wrote:
Quoted 50 lines · Paul E. McKenney

Subject: Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 46 lines · On Tue, Aug 10, 2010 at 06:28:39PM -0700, [email protected] wrote:
Quoted 31 lines · Paul E. McKenney
Quoted 7 lines · Alan Cox
Quoted 2 lines

situation you call out can occur with manual suspend-to-RAM already:
the fact is that this is a design choice. You could indeed make a

Losing data is a design choice ? The application set a timer, the OS shouldn't be ignoring it in that situation. It might want to delay it, it might want to warn the user its hogging things it shouldnt (powertop, battery usage monitors in Android etc)

Hmmm... Let's put the two approaches side by side so that we can compare them more easily:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Resume OS continues delaying timer
Timer fires Timer fires

These two cases look quite similar to me.

But as you say, the battery can run out. So let's add that to the comparison:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Battery runs out Battery runs out
Data loss Data loss

Quoted 5 lines

The two cases still look quite similar. You might note, quite correctly, that the time between suspend and resume might be quite a bit longer than the typical time that the OS delays a timer. But the power consumption on some platforms is quite a bit lower in the suspend case than it is in the delayed-timer case.

it has been stated that the android can hit the exact same power state either with sleep or suspend, and that the same clock can wake it up (it appears as a timer expiring for sleep, or an alarm for suspend, but it's the same clock firing the signal)

so in at least some cases the hardware supports doing both with equal efficiency.

Quoted 6 lines
Quoted 2 lines

It indeed has been so stated. But in this section we were discussing data loss, not hardware power-state capabilities.

you specifically stated that suspend would use less power. I am pointing out that ther is info posed in this thread to say that's not always the case.

I specifically stated something different, and if you specifically look up a few paragraph, you will specifically see that I specifically used a specific qualifier, which you specifically seem to have lost track of.

							;-), Paul
Quoted 65 lines

in either case it is possible for the system to wake up again later to let the timer fire and the application save it's work. It's arguably easier in the idle case as it doesn't require application modification

for example

Idle + Timer Jitter
set timer
OS sets timer jitter to 1 hour
system sleeps for 1 hour with no wakeups timer fires, applications wake and process data system sleeps (for 1 hour or more with no wakeups)
(repeat as needed until battery runs out)

much less chance for data loss as there is _far_ more of a chance that the timer

waking up once per hour for a short time is not going to make a noticable difference in your total battery life of a cell phone due to the significant idle power draw needed for the cell circuitry. On something like a e-reader with no radio link and a month-long idle time it could make a difference.

note that this is with a badly written app running that is trying to wakeup repeatedly. If the app is well behaved and only schedule a timer when they will have work to do, they may not schedule a timer at all after the data is saved, and so would have the data safe and just as long a standby time.

Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 7 lines
Quoted 2 lines

But that doesn't guarantee that solutions developed for PCs and laptops will be optimal (or even usable) on cellphones. Sufficient difference

Your cellphone is to all intents a laptop from ten years ago, it even has a similar display resolution and internet availability. The underlying difference between the two is solely form factor - the laptop had a better keyboard.

There are similarities and differences. You have called out some of the similarities. Differences include the more-aggressive hardware power management on cellphones, the greater number and variety of hardware accelerators on cellphones, battery capacity, and, as you say, physical size. People currently use cellphones differently than they do laptops or desktops. The usage might converge, but we will see. There is as much reason to expect increasing specialization as there is to expect increasing convergence.

Quoted 7 lines
Quoted 3 lines

You are talking about Android as if it was a cell phone only thing, it's not. there are shipping tablets (and I believe netbooks, i.e. laptops) running andoid.

I was talking about cellphones. But yes, Android (and thus suspend blockers) are used for tablets as well as cellphones, thank you for reminding me!

the fact that it's used there means that you can't argue that it's difference because cell phones are so different (unless you are saying that Android is really not appropriate for those uses)

On the other hand, lots of things are used in places where it is inappropriate, Windows CE is used on phones, tablets, etc but I think most people would say that the use of windows there isn't appropriate.

David Lang

#629 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to [email protected]
Quoted 52 lines · On Tue, Aug 10, 2010 at 08:00:53PM -0700, [email protected] wrote:
Quoted 50 lines · Paul E. McKenney

Subject: Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 46 lines · On Tue, Aug 10, 2010 at 06:28:39PM -0700, [email protected] wrote:
Quoted 31 lines · Paul E. McKenney
Quoted 7 lines · Alan Cox
Quoted 2 lines

situation you call out can occur with manual suspend-to-RAM already:
the fact is that this is a design choice. You could indeed make a

Losing data is a design choice ? The application set a timer, the OS shouldn't be ignoring it in that situation. It might want to delay it, it might want to warn the user its hogging things it shouldnt (powertop, battery usage monitors in Android etc)

Hmmm... Let's put the two approaches side by side so that we can compare them more easily:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Resume OS continues delaying timer
Timer fires Timer fires

These two cases look quite similar to me.

But as you say, the battery can run out. So let's add that to the comparison:

Opportunistic Suspend Idle + Timer Jitter

Set timer Set timer
Suspend OS delays timer
Battery runs out Battery runs out
Data loss Data loss

Quoted 5 lines

The two cases still look quite similar. You might note, quite correctly, that the time between suspend and resume might be quite a bit longer than the typical time that the OS delays a timer. But the power consumption on some platforms is quite a bit lower in the suspend case than it is in the delayed-timer case.

it has been stated that the android can hit the exact same power state either with sleep or suspend, and that the same clock can wake it up (it appears as a timer expiring for sleep, or an alarm for suspend, but it's the same clock firing the signal)

so in at least some cases the hardware supports doing both with equal efficiency.

Quoted 6 lines
Quoted 2 lines

It indeed has been so stated. But in this section we were discussing data loss, not hardware power-state capabilities.

you specifically stated that suspend would use less power. I am pointing out that ther is info posed in this thread to say that's not always the case.

I specifically stated something different, and if you specifically look up a few paragraph, you will specifically see that I specifically used a specific qualifier, which you specifically seem to have lost track of.

							;-), Paul
Quoted 65 lines

in either case it is possible for the system to wake up again later to let the timer fire and the application save it's work. It's arguably easier in the idle case as it doesn't require application modification

for example

Idle + Timer Jitter
set timer
OS sets timer jitter to 1 hour
system sleeps for 1 hour with no wakeups timer fires, applications wake and process data system sleeps (for 1 hour or more with no wakeups)
(repeat as needed until battery runs out)

much less chance for data loss as there is _far_ more of a chance that the timer

waking up once per hour for a short time is not going to make a noticable difference in your total battery life of a cell phone due to the significant idle power draw needed for the cell circuitry. On something like a e-reader with no radio link and a month-long idle time it could make a difference.

note that this is with a badly written app running that is trying to wakeup repeatedly. If the app is well behaved and only schedule a timer when they will have work to do, they may not schedule a timer at all after the data is saved, and so would have the data safe and just as long a standby time.

Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 7 lines
Quoted 2 lines

But that doesn't guarantee that solutions developed for PCs and laptops will be optimal (or even usable) on cellphones. Sufficient difference

Your cellphone is to all intents a laptop from ten years ago, it even has a similar display resolution and internet availability. The underlying difference between the two is solely form factor - the laptop had a better keyboard.

There are similarities and differences. You have called out some of the similarities. Differences include the more-aggressive hardware power management on cellphones, the greater number and variety of hardware accelerators on cellphones, battery capacity, and, as you say, physical size. People currently use cellphones differently than they do laptops or desktops. The usage might converge, but we will see. There is as much reason to expect increasing specialization as there is to expect increasing convergence.

Quoted 7 lines
Quoted 3 lines

You are talking about Android as if it was a cell phone only thing, it's not. there are shipping tablets (and I believe netbooks, i.e. laptops) running andoid.

I was talking about cellphones. But yes, Android (and thus suspend blockers) are used for tablets as well as cellphones, thank you for reminding me!

the fact that it's used there means that you can't argue that it's difference because cell phones are so different (unless you are saying that Android is really not appropriate for those uses)

On the other hand, lots of things are used in places where it is inappropriate, Windows CE is used on phones, tablets, etc but I think most people would say that the use of windows there isn't appropriate.

David Lang

#634 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 23 lines · Paul E. McKenney
Quoted 22 lines · Felipe Contreras
Quoted 19 lines · Paul E. McKenney
Quoted 10 lines · Alan Cox

You may also wish to review the earlier parts of the discussion where it was explicitly stated by several developers that they were using "suspend" type modes as power states already and not using suspend blockers. So it's being done, today on ARM and your statement is directly contradicting the code. Modern ARM processors and x86 MID devices can suspend and resume extremely fast (fast enough that the fact Linux x86 rewriting all the SMP alternatives on suspend/resume is a measurable problem). If this same property doesn't end up on big PC boxes in time then I'd be very surprised. At that point the openoffice with suspend blockers or oracle with suspend blockers question becomes rather relevant.

Here is the list of properties distinguishing idle from suspend:

1.      Idle states are entered by a given CPU only there are no runnable tasks for that CPU.  In contrast, opportunistic suspend can halt the entire system even when there are tasks that are ready, willing, and able to run.  (But please note that this might not apply to real-time tasks.)

Quoted 3 lines
Quoted 1 line

But if there are no runnable tasks (which is the target), they behave the same.

And if there are runnable tasks, then then don't behave the same.

Unless they have blocked suspend.

Anyway, Alan was picturing a hypothetical point in time when x86 can suspend/resume as fast as ARM, and thus the question of whether or not to enable suspend-blockers in a system that runs openoffice becomes relevant. If applications have been fixed by that time to not wake the system unnecessarily, as many of them have already been tanks to tools like powertop, then suspend-blockers would not make that much of a difference, therefore the effort required to implement suspend-blockers properly on all applications in the system, including openoffice might not be worth the gain.

Quoted 1 line

Apparently different people in this debate have different targets.

I remember clearly Android people explaining that dynamic PM is orthogonal to suspend-blockers; if a suspend is blocked, you still want dynamic PM to reach the lower power state. Therefore the target of not having unneeded runnable tasks is shared by Android folks.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

2.      There can be a set of input events that do not bring the system out of suspend, but which would bring the system out of idle. Exactly which events are in this set depends both on hardware capabilities and on the platform/application policy.  For example, on one of the Android-based smartphones, touchscreen input is ignored when the system is suspended, but is handled when idle.

Quoted 5 lines
Quoted 2 lines

And in N900 touching the screen doesn't bring the device out of idle, I guess because it's off.

As long as touching the N900 screen doesn't bring the device out of suspend, its behavior is not a counterexample to #2 above.

You said "there can be a set of input events that do not bring the system out of suspend, but which would bring the system out of idle". There's no suspend (in the Android sense) in N900, only idle, and the events that bring N900 out of idle can be mapped to the set of events that bring Android out of suspend.

IOW. Alan wasn't talking about idle vs suspend on the same device, he was talking about opportunistic suspend vs dynamic PM.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

3.      The system comes out of idle when a timer expires.  In contrast, timers might or might not bring the system out of suspend, depending on both hardware capabilities and platform/application policy.

Quoted 8 lines
Quoted 1 line

Isn't this solved by range timers?

Ahem.  This is a list of differences between idle and suspend, not a list of problems to be solved.  But to answer your question, if a timer does not bring a given device out of suspend, then a range timer is not likely to, either.  Don't get me wrong, I do believe that range timers have an important part to play in the energy-efficiency arena, but I have not been convinced that they are any kind of silver bullet.

Certainly, but the context is the set of differences that would aid in the decision of whether or not to go for suspend-blockers in a general purpose system where openoffice would run.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

4.      Suspend generally forces devices to go into their low-power states immediately.  In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices.  Idle thus has shorter average wakeup latencies, but worse energy efficiency.

Quoted 7 lines
Quoted 3 lines

Only if you make these assumptions
 1) All the applications use suspend-blockers only when they absolutely must
 2) The user has given the right applications the right access

You believe that these assumptions are unreasonable?  Compared to the assumption that all applications are carefully written to conserve power? If so, on what grounds?

No, I think both (for opportunistic suspend and dynamic PM) are completely reasonable. But think again; if you have the assumptions met on both, then both work fine, if you don't meet them, then both don't work correctly.

My point is that suspend-blockers don't magically reduce power usage, just like dynamic PM, it depends on what user-space actually does. You made it look as it *always* reached better energy efficiency.

Quoted 2 lines

It seems to me that the same social-engineering approaches work in both cases.

Yes, but if dynamic PM works as advertised, you don't need opportunistic suspend.

Quoted 4 lines
Quoted 2 lines

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

Really?  What makes you say that?

For starters an application might be holding the wakelock more than it should, also, an application might miss a timer due to not having PM permissions to hold the lock, and thus might need an expensive initialization when it runs again.

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#635 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 23 lines · Paul E. McKenney
Quoted 22 lines · Felipe Contreras
Quoted 19 lines · Paul E. McKenney
Quoted 10 lines · Alan Cox

You may also wish to review the earlier parts of the discussion where it was explicitly stated by several developers that they were using "suspend" type modes as power states already and not using suspend blockers. So it's being done, today on ARM and your statement is directly contradicting the code. Modern ARM processors and x86 MID devices can suspend and resume extremely fast (fast enough that the fact Linux x86 rewriting all the SMP alternatives on suspend/resume is a measurable problem). If this same property doesn't end up on big PC boxes in time then I'd be very surprised. At that point the openoffice with suspend blockers or oracle with suspend blockers question becomes rather relevant.

Here is the list of properties distinguishing idle from suspend:

1.      Idle states are entered by a given CPU only there are no runnable tasks for that CPU.  In contrast, opportunistic suspend can halt the entire system even when there are tasks that are ready, willing, and able to run.  (But please note that this might not apply to real-time tasks.)

Quoted 3 lines
Quoted 1 line

But if there are no runnable tasks (which is the target), they behave the same.

And if there are runnable tasks, then then don't behave the same.

Unless they have blocked suspend.

Anyway, Alan was picturing a hypothetical point in time when x86 can suspend/resume as fast as ARM, and thus the question of whether or not to enable suspend-blockers in a system that runs openoffice becomes relevant. If applications have been fixed by that time to not wake the system unnecessarily, as many of them have already been tanks to tools like powertop, then suspend-blockers would not make that much of a difference, therefore the effort required to implement suspend-blockers properly on all applications in the system, including openoffice might not be worth the gain.

Quoted 1 line

Apparently different people in this debate have different targets.

I remember clearly Android people explaining that dynamic PM is orthogonal to suspend-blockers; if a suspend is blocked, you still want dynamic PM to reach the lower power state. Therefore the target of not having unneeded runnable tasks is shared by Android folks.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

2.      There can be a set of input events that do not bring the system out of suspend, but which would bring the system out of idle. Exactly which events are in this set depends both on hardware capabilities and on the platform/application policy.  For example, on one of the Android-based smartphones, touchscreen input is ignored when the system is suspended, but is handled when idle.

Quoted 5 lines
Quoted 2 lines

And in N900 touching the screen doesn't bring the device out of idle, I guess because it's off.

As long as touching the N900 screen doesn't bring the device out of suspend, its behavior is not a counterexample to #2 above.

You said "there can be a set of input events that do not bring the system out of suspend, but which would bring the system out of idle". There's no suspend (in the Android sense) in N900, only idle, and the events that bring N900 out of idle can be mapped to the set of events that bring Android out of suspend.

IOW. Alan wasn't talking about idle vs suspend on the same device, he was talking about opportunistic suspend vs dynamic PM.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

3.      The system comes out of idle when a timer expires.  In contrast, timers might or might not bring the system out of suspend, depending on both hardware capabilities and platform/application policy.

Quoted 8 lines
Quoted 1 line

Isn't this solved by range timers?

Ahem.  This is a list of differences between idle and suspend, not a list of problems to be solved.  But to answer your question, if a timer does not bring a given device out of suspend, then a range timer is not likely to, either.  Don't get me wrong, I do believe that range timers have an important part to play in the energy-efficiency arena, but I have not been convinced that they are any kind of silver bullet.

Certainly, but the context is the set of differences that would aid in the decision of whether or not to go for suspend-blockers in a general purpose system where openoffice would run.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

4.      Suspend generally forces devices to go into their low-power states immediately.  In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices.  Idle thus has shorter average wakeup latencies, but worse energy efficiency.

Quoted 7 lines
Quoted 3 lines

Only if you make these assumptions
 1) All the applications use suspend-blockers only when they absolutely must
 2) The user has given the right applications the right access

You believe that these assumptions are unreasonable?  Compared to the assumption that all applications are carefully written to conserve power? If so, on what grounds?

No, I think both (for opportunistic suspend and dynamic PM) are completely reasonable. But think again; if you have the assumptions met on both, then both work fine, if you don't meet them, then both don't work correctly.

My point is that suspend-blockers don't magically reduce power usage, just like dynamic PM, it depends on what user-space actually does. You made it look as it *always* reached better energy efficiency.

Quoted 2 lines

It seems to me that the same social-engineering approaches work in both cases.

Yes, but if dynamic PM works as advertised, you don't need opportunistic suspend.

Quoted 4 lines
Quoted 2 lines

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

Really?  What makes you say that?

For starters an application might be holding the wakelock more than it should, also, an application might miss a timer due to not having PM permissions to hold the lock, and thus might need an expensive initialization when it runs again.

Signature · 1 line
Felipe Contreras
#458 lore raw
In reply to Mark Brown
Quoted 7 lines · Mark Brown
Quoted 5 lines · Felipe Contreras
Quoted 3 lines · Matthew Garrett

It's clearly possible for a pathological Android application to destroy the power management policy. But to do that, the author would have to explicitly take a wakelock. That's difficult to do by accident.

Quoted 6 lines
Quoted 4 lines

The writer can take a wakelock the whole time the application is running (isn't that the typical case?), because perhaps the author realizes that way the application works correctly, or he copy-pasted it from somewhere else.

That would be exceptionally unusual. A more common case is that the application will take a wakelock while performing some specific long running task which needs no user intervention such as downloading a file or displaying constantly update status that the user is not expected to respond to. There's no need for applications to take wakelocks while the user is directly interacting with them since the system will be kept awake as a result of the user interaction, the wakelocks are used to override the default suspend that occurs when the user is not interacting with the device.

Fair enough, but if that the case, if suspend blockers are to be used in desktop software, everything would need extensive modifications just to work. I remember somebody said that was not the case, I thought it was because the lock could be held the whole time the application is running.

Signature · 1 line
Felipe Contreras
#459 lore raw
In reply to Mark Brown
Quoted 7 lines · Mark Brown
Quoted 5 lines · Felipe Contreras
Quoted 3 lines · Matthew Garrett

It's clearly possible for a pathological Android application to destroy the power management policy. But to do that, the author would have to explicitly take a wakelock. That's difficult to do by accident.

Quoted 6 lines
Quoted 4 lines

The writer can take a wakelock the whole time the application is running (isn't that the typical case?), because perhaps the author realizes that way the application works correctly, or he copy-pasted it from somewhere else.

That would be exceptionally unusual. A more common case is that the application will take a wakelock while performing some specific long running task which needs no user intervention such as downloading a file or displaying constantly update status that the user is not expected to respond to. There's no need for applications to take wakelocks while the user is directly interacting with them since the system will be kept awake as a result of the user interaction, the wakelocks are used to override the default suspend that occurs when the user is not interacting with the device.

Fair enough, but if that the case, if suspend blockers are to be used in desktop software, everything would need extensive modifications just to work. I remember somebody said that was not the case, I thought it was because the lock could be held the whole time the application is running.

Signature · 1 line
Felipe Contreras
#660 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 12 lines · Paul E. McKenney
Quoted 10 lines · Felipe Contreras
Quoted 4 lines · Paul E. McKenney

But wouldn't an office suite run as a power-oblivious application on an Android device?  After all, office applications do not need to run when the screen is turned off, so these the applications do not need to use suspend blockers.

Ideally the system would be suspended even when the screen is on. If there are no "trusted" applications running at the same time, then openoffice wouldn't load at all. Right?

Quoted 5 lines

My understanding is that Android systems in fact do not suspend when the screen is on, and that most (perhaps all) other systems do not opportunistically suspend at all.  There has been some speculation about what a hypothetical Android having a non-volatile display might do, but as far as I know, this is just speculation.

I have a desktop system in mind. If opportunistic suspend is only triggered when the display is off, then it's no good for normal usage, and therefore dynamic PC needs to get its act together... specially for laptops.

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#661 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 12 lines · Paul E. McKenney
Quoted 10 lines · Felipe Contreras
Quoted 4 lines · Paul E. McKenney

But wouldn't an office suite run as a power-oblivious application on an Android device?  After all, office applications do not need to run when the screen is turned off, so these the applications do not need to use suspend blockers.

Ideally the system would be suspended even when the screen is on. If there are no "trusted" applications running at the same time, then openoffice wouldn't load at all. Right?

Quoted 5 lines

My understanding is that Android systems in fact do not suspend when the screen is on, and that most (perhaps all) other systems do not opportunistically suspend at all.  There has been some speculation about what a hypothetical Android having a non-volatile display might do, but as far as I know, this is just speculation.

I have a desktop system in mind. If opportunistic suspend is only triggered when the display is off, then it's no good for normal usage, and therefore dynamic PC needs to get its act together... specially for laptops.

Signature · 1 line
Felipe Contreras
#809 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Brian Swetland
Quoted 7 lines · Brian Swetland
Quoted 3 lines · Felipe Contreras

This is what I'm talking about when I say multi-tasking, Android certainly doesn't have anything remotely like that:
http://www.youtube.com/watch?v=7emvUBpEkbU

Home + pick app -> switch to the app in whatever state it was in.

If the app stops running, that's *fake* multi-tasking, and doesn't match my experience; I can't remember the details, but I tested it on a Nexus One, and the item I was looking at was gone, I had to scroll again.

Also, I cannot go to last.fm on the browser, play some music, and do other stuff at the same time, can I?

Anyway, what you do in Android is your problem. The point is that in Linux we need good PM *with* multi-tasking (not really an argument against opportunistic suspend, I think, but a clarification from Ted's comment)

Signature · 1 line
Felipe Contreras
#810 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Brian Swetland
Quoted 7 lines · Brian Swetland
Quoted 3 lines · Felipe Contreras

This is what I'm talking about when I say multi-tasking, Android certainly doesn't have anything remotely like that:
http://www.youtube.com/watch?v=7emvUBpEkbU

Home + pick app -> switch to the app in whatever state it was in.

If the app stops running, that's *fake* multi-tasking, and doesn't match my experience; I can't remember the details, but I tested it on a Nexus One, and the item I was looking at was gone, I had to scroll again.

Also, I cannot go to last.fm on the browser, play some music, and do other stuff at the same time, can I?

Anyway, what you do in Android is your problem. The point is that in Linux we need good PM *with* multi-tasking (not really an argument against opportunistic suspend, I think, but a clarification from Ted's comment)

Signature · 1 line
Felipe Contreras
#811 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 7 lines · Felipe Contreras
Quoted 6 lines · Brian Swetland
Quoted 3 lines · Felipe Contreras

This is what I'm talking about when I say multi-tasking, Android certainly doesn't have anything remotely like that:
http://www.youtube.com/watch?v=7emvUBpEkbU

Quoted 6 lines
Quoted 1 line

Home + pick app -> switch to the app in whatever state it was in.

If the app stops running, that's *fake* multi-tasking, and doesn't match my experience; I can't remember the details, but I tested it on a Nexus One, and the item I was looking at was gone, I had to scroll again.

That'd be surprise. Last I checked I was able to launch 40-50 apps on N1 before we even started getting low on memory and the system won't kill apps off unless we completely bottom out on memory. It's possible that some app might do the wrong thing when going to the background and back to the foreground but that'd be an app bug.

Quoted 2 lines

Also, I cannot go to last.fm on the browser, play some music, and do other stuff at the same time, can I?

I'm not sure off the top of my head if the browser will keep music/flash playing on pages when it's not the foreground app, but you can certainly run something like Pandora (or a number of other streaming music apps) in the background and play streaming music while you do other stuff. There's no reason the browser *couldn't* do this as well.

Quoted 4 lines

Anyway, what you do in Android is your problem. The point is that in Linux we need good PM *with* multi-tasking (not really an argument against opportunistic suspend, I think, but a clarification from Ted's comment)

Well I'm glad we agree that multitasking and PM are important.

Brian

#812 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 7 lines · Felipe Contreras
Quoted 6 lines · Brian Swetland
Quoted 3 lines · Felipe Contreras

This is what I'm talking about when I say multi-tasking, Android certainly doesn't have anything remotely like that:
http://www.youtube.com/watch?v=7emvUBpEkbU

Quoted 6 lines
Quoted 1 line

Home + pick app -> switch to the app in whatever state it was in.

If the app stops running, that's *fake* multi-tasking, and doesn't match my experience; I can't remember the details, but I tested it on a Nexus One, and the item I was looking at was gone, I had to scroll again.

That'd be surprise. Last I checked I was able to launch 40-50 apps on N1 before we even started getting low on memory and the system won't kill apps off unless we completely bottom out on memory. It's possible that some app might do the wrong thing when going to the background and back to the foreground but that'd be an app bug.

Quoted 2 lines

Also, I cannot go to last.fm on the browser, play some music, and do other stuff at the same time, can I?

I'm not sure off the top of my head if the browser will keep music/flash playing on pages when it's not the foreground app, but you can certainly run something like Pandora (or a number of other streaming music apps) in the background and play streaming music while you do other stuff. There's no reason the browser *couldn't* do this as well.

Quoted 4 lines

Anyway, what you do in Android is your problem. The point is that in Linux we need good PM *with* multi-tasking (not really an argument against opportunistic suspend, I think, but a clarification from Ted's comment)

Well I'm glad we agree that multitasking and PM are important.

Brian

#662 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 20 lines · Felipe Contreras
Quoted 12 lines · Paul E. McKenney
Quoted 10 lines · Felipe Contreras
Quoted 4 lines · Paul E. McKenney

But wouldn't an office suite run as a power-oblivious application on an Android device?  After all, office applications do not need to run when the screen is turned off, so these the applications do not need to use suspend blockers.

Ideally the system would be suspended even when the screen is on. If there are no "trusted" applications running at the same time, then openoffice wouldn't load at all. Right?

Quoted 5 lines

My understanding is that Android systems in fact do not suspend when the screen is on, and that most (perhaps all) other systems do not opportunistically suspend at all.  There has been some speculation about what a hypothetical Android having a non-volatile display might do, but as far as I know, this is just speculation.

Quoted 4 lines

I have a desktop system in mind. If opportunistic suspend is only triggered when the display is off, then it's no good for normal usage, and therefore dynamic PC needs to get its act together... specially for laptops.

If I understand you correctly, you are saying that both opportunistic suspend and dynamic power control should be used together, with dynamic power control being used for short non-busy periods (as in between keystrokes) and opportunistic suspend being used for longer non-busy periods (as in while grabbing a coffee). That combination of usage sounds promising to me.

That said, I don't know that anyone has really sat down and thought through how one might apply suspend blockers to a desktop system. I suspect that there are several ways to go about it.

Thanx, Paul

#663 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 20 lines · Felipe Contreras
Quoted 12 lines · Paul E. McKenney
Quoted 10 lines · Felipe Contreras
Quoted 4 lines · Paul E. McKenney

But wouldn't an office suite run as a power-oblivious application on an Android device?  After all, office applications do not need to run when the screen is turned off, so these the applications do not need to use suspend blockers.

Ideally the system would be suspended even when the screen is on. If there are no "trusted" applications running at the same time, then openoffice wouldn't load at all. Right?

Quoted 5 lines

My understanding is that Android systems in fact do not suspend when the screen is on, and that most (perhaps all) other systems do not opportunistically suspend at all.  There has been some speculation about what a hypothetical Android having a non-volatile display might do, but as far as I know, this is just speculation.

Quoted 4 lines

I have a desktop system in mind. If opportunistic suspend is only triggered when the display is off, then it's no good for normal usage, and therefore dynamic PC needs to get its act together... specially for laptops.

If I understand you correctly, you are saying that both opportunistic suspend and dynamic power control should be used together, with dynamic power control being used for short non-busy periods (as in between keystrokes) and opportunistic suspend being used for longer non-busy periods (as in while grabbing a coffee). That combination of usage sounds promising to me.

That said, I don't know that anyone has really sat down and thought through how one might apply suspend blockers to a desktop system. I suspect that there are several ways to go about it.

Thanx, Paul

#664 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 26 lines · Paul E. McKenney
Quoted 20 lines · Felipe Contreras
Quoted 12 lines · Paul E. McKenney
Quoted 10 lines · Felipe Contreras
Quoted 4 lines · Paul E. McKenney

But wouldn't an office suite run as a power-oblivious application on an Android device?  After all, office applications do not need to run when the screen is turned off, so these the applications do not need to use suspend blockers.

Ideally the system would be suspended even when the screen is on. If there are no "trusted" applications running at the same time, then openoffice wouldn't load at all. Right?

Quoted 5 lines

My understanding is that Android systems in fact do not suspend when the screen is on, and that most (perhaps all) other systems do not opportunistically suspend at all.  There has been some speculation about what a hypothetical Android having a non-volatile display might do, but as far as I know, this is just speculation.

Quoted 4 lines

I have a desktop system in mind. If opportunistic suspend is only triggered when the display is off, then it's no good for normal usage, and therefore dynamic PC needs to get its act together... specially for laptops.

Quoted 6 lines

If I understand you correctly, you are saying that both opportunistic suspend and dynamic power control should be used together, with dynamic power control being used for short non-busy periods (as in between keystrokes) and opportunistic suspend being used for longer non-busy periods (as in while grabbing a coffee).  That combination of usage sounds promising to me.

No. In the future x86 will be fixed, but for now let's imagine an ARM laptop.

Quoted 3 lines

That said, I don't know that anyone has really sat down and thought through how one might apply suspend blockers to a desktop system. I suspect that there are several ways to go about it.

Think in terms of an ARM laptop. What good is opportunistic suspend if it's not going to help when the laptop is being used?

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#665 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 26 lines · Paul E. McKenney
Quoted 20 lines · Felipe Contreras
Quoted 12 lines · Paul E. McKenney
Quoted 10 lines · Felipe Contreras
Quoted 4 lines · Paul E. McKenney

But wouldn't an office suite run as a power-oblivious application on an Android device?  After all, office applications do not need to run when the screen is turned off, so these the applications do not need to use suspend blockers.

Ideally the system would be suspended even when the screen is on. If there are no "trusted" applications running at the same time, then openoffice wouldn't load at all. Right?

Quoted 5 lines

My understanding is that Android systems in fact do not suspend when the screen is on, and that most (perhaps all) other systems do not opportunistically suspend at all.  There has been some speculation about what a hypothetical Android having a non-volatile display might do, but as far as I know, this is just speculation.

Quoted 4 lines

I have a desktop system in mind. If opportunistic suspend is only triggered when the display is off, then it's no good for normal usage, and therefore dynamic PC needs to get its act together... specially for laptops.

Quoted 6 lines

If I understand you correctly, you are saying that both opportunistic suspend and dynamic power control should be used together, with dynamic power control being used for short non-busy periods (as in between keystrokes) and opportunistic suspend being used for longer non-busy periods (as in while grabbing a coffee).  That combination of usage sounds promising to me.

No. In the future x86 will be fixed, but for now let's imagine an ARM laptop.

Quoted 3 lines

That said, I don't know that anyone has really sat down and thought through how one might apply suspend blockers to a desktop system. I suspect that there are several ways to go about it.

Think in terms of an ARM laptop. What good is opportunistic suspend if it's not going to help when the laptop is being used?

Signature · 1 line
Felipe Contreras
#666 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 28 lines · Felipe Contreras
Quoted 26 lines · Paul E. McKenney
Quoted 24 lines · Felipe Contreras
Quoted 12 lines · Paul E. McKenney
Quoted 10 lines · Felipe Contreras
Quoted 4 lines · Paul E. McKenney

But wouldn't an office suite run as a power-oblivious application on an Android device?  After all, office applications do not need to run when the screen is turned off, so these the applications do not need to use suspend blockers.

Ideally the system would be suspended even when the screen is on. If there are no "trusted" applications running at the same time, then openoffice wouldn't load at all. Right?

Quoted 5 lines

My understanding is that Android systems in fact do not suspend when the screen is on, and that most (perhaps all) other systems do not opportunistically suspend at all.  There has been some speculation about what a hypothetical Android having a non-volatile display might do, but as far as I know, this is just speculation.

I have a desktop system in mind. If opportunistic suspend is only triggered when the display is off, then it's no good for normal usage, and therefore dynamic PC needs to get its act together... specially for laptops.

Quoted 8 lines
Quoted 6 lines

If I understand you correctly, you are saying that both opportunistic suspend and dynamic power control should be used together, with dynamic power control being used for short non-busy periods (as in between keystrokes) and opportunistic suspend being used for longer non-busy periods (as in while grabbing a coffee).  That combination of usage sounds promising to me.

No. In the future x86 will be fixed, but for now let's imagine an ARM laptop.

Hmmm... OK...

Quoted 6 lines
Quoted 3 lines

That said, I don't know that anyone has really sat down and thought through how one might apply suspend blockers to a desktop system. I suspect that there are several ways to go about it.

Think in terms of an ARM laptop. What good is opportunistic suspend if it's not going to help when the laptop is being used?

For when the laptop is not being used, presumably.

Thanx, Paul

#667 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 28 lines · Felipe Contreras
Quoted 26 lines · Paul E. McKenney
Quoted 24 lines · Felipe Contreras
Quoted 12 lines · Paul E. McKenney
Quoted 10 lines · Felipe Contreras
Quoted 4 lines · Paul E. McKenney

But wouldn't an office suite run as a power-oblivious application on an Android device?  After all, office applications do not need to run when the screen is turned off, so these the applications do not need to use suspend blockers.

Ideally the system would be suspended even when the screen is on. If there are no "trusted" applications running at the same time, then openoffice wouldn't load at all. Right?

Quoted 5 lines

My understanding is that Android systems in fact do not suspend when the screen is on, and that most (perhaps all) other systems do not opportunistically suspend at all.  There has been some speculation about what a hypothetical Android having a non-volatile display might do, but as far as I know, this is just speculation.

I have a desktop system in mind. If opportunistic suspend is only triggered when the display is off, then it's no good for normal usage, and therefore dynamic PC needs to get its act together... specially for laptops.

Quoted 8 lines
Quoted 6 lines

If I understand you correctly, you are saying that both opportunistic suspend and dynamic power control should be used together, with dynamic power control being used for short non-busy periods (as in between keystrokes) and opportunistic suspend being used for longer non-busy periods (as in while grabbing a coffee).  That combination of usage sounds promising to me.

No. In the future x86 will be fixed, but for now let's imagine an ARM laptop.

Hmmm... OK...

Quoted 6 lines
Quoted 3 lines

That said, I don't know that anyone has really sat down and thought through how one might apply suspend blockers to a desktop system. I suspect that there are several ways to go about it.

Think in terms of an ARM laptop. What good is opportunistic suspend if it's not going to help when the laptop is being used?

For when the laptop is not being used, presumably.

Thanx, Paul

#668 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 5 lines · Paul E. McKenney
Quoted 2 lines · Felipe Contreras

Think in terms of an ARM laptop. What good is opportunistic suspend if it's not going to help when the laptop is being used?

For when the laptop is not being used, presumably.

Right, but if you have to optimize for dynamic PM anyway for normal usage, how much would you gain by opportunistic suspend?

As it has been explained before, there's a point of diminishing returns:
http://article.gmane.org/gmane.linux.kernel/995525
http://article.gmane.org/gmane.linux.ports.arm.omap/37982

Now, how much would dynamic PM have progressed by the time we start thinking on opportunistic suspend on laptops (ARM, or fixed PM), 10 seconds idle? 1 minute idle? Would it make sense to rewrite *all* user-space in order to archive that little extra performance, *or* would it make more sense to keep investing on dynamic PM which we have to do anyway?

All this has already been explained.

BTW, the gain is even less if you consider that laptops already automatically go to suspend after a while, so the gains of opportunistic suspend would have to be measured only for a small period of time (like 30 min or so).

Signature · 1 line
Felipe Contreras
#669 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 5 lines · Paul E. McKenney
Quoted 2 lines · Felipe Contreras

Think in terms of an ARM laptop. What good is opportunistic suspend if it's not going to help when the laptop is being used?

For when the laptop is not being used, presumably.

Right, but if you have to optimize for dynamic PM anyway for normal usage, how much would you gain by opportunistic suspend?

As it has been explained before, there's a point of diminishing returns:
http://article.gmane.org/gmane.linux.kernel/995525
http://article.gmane.org/gmane.linux.ports.arm.omap/37982

Now, how much would dynamic PM have progressed by the time we start thinking on opportunistic suspend on laptops (ARM, or fixed PM), 10 seconds idle? 1 minute idle? Would it make sense to rewrite *all* user-space in order to archive that little extra performance, *or* would it make more sense to keep investing on dynamic PM which we have to do anyway?

All this has already been explained.

BTW, the gain is even less if you consider that laptops already automatically go to suspend after a while, so the gains of opportunistic suspend would have to be measured only for a small period of time (like 30 min or so).

Signature · 1 line
Felipe Contreras
#670 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Felipe,

One thing I'm not clear on --- what's your goal? Is your goal to keep suspend-blockers out of the kernel? Is it to try to convince the android team suspend-blockers are a bad idea and to change Android to not use them? Is it to push some other agenda? Is it to discourage the Android team from trying to waste more time trying to get suspend-blockers (or equivalent functionality) from being added into the kernel?

You seem to be arguing quite passionately, but I'm not sure what you're trying to do.

-- Ted

#671 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras

Felipe,

One thing I'm not clear on --- what's your goal? Is your goal to keep suspend-blockers out of the kernel? Is it to try to convince the android team suspend-blockers are a bad idea and to change Android to not use them? Is it to push some other agenda? Is it to discourage the Android team from trying to waste more time trying to get suspend-blockers (or equivalent functionality) from being added into the kernel?

You seem to be arguing quite passionately, but I'm not sure what you're trying to do.

-- Ted

#672 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 1 line · Theodore Tso

One thing I'm not clear on --- what's your goal?   Is your goal to keep suspend-blockers out of the kernel?   Is it to try to convince the android team suspend-blockers are a bad idea and to change Android to not use them?  Is it to push some other agenda?  Is it to discourage the Android team from trying to waste more time trying to get suspend-blockers (or equivalent functionality) from being added into the kernel?

My goal is to shine light. I've heard many invalid arguments in favor of suspend blockers, I want to shut them down.

In my mind it's crystal clear that independently of what opportunistic suspend is supposed to be fixing, the fact of the matter is that it's not a silver bullet as it's claimed to be.

So far, nobody has refuted these:
1) opportunistic suspend needs a good behaved user-space to work properly
2) if suspend blockers are enabled in a system, *all* user-space must
implement them to work correctly
3) implementing suspend blockers in user-space is not a straight-forward task
4) there's a point where sleeping (not doing work) has diminished returns

So, as the length of this thread has shown, the benefits of opportunistic suspend are *dubious* at best, and more likely not worth the changes needed in user-space which eventually will get pretty close to what suspend blockers can achieve even in ideal circumstances by just doing dynamic PM.

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#673 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Theodore Tso
Quoted 1 line · Theodore Tso

One thing I'm not clear on --- what's your goal?   Is your goal to keep suspend-blockers out of the kernel?   Is it to try to convince the android team suspend-blockers are a bad idea and to change Android to not use them?  Is it to push some other agenda?  Is it to discourage the Android team from trying to waste more time trying to get suspend-blockers (or equivalent functionality) from being added into the kernel?

My goal is to shine light. I've heard many invalid arguments in favor of suspend blockers, I want to shut them down.

In my mind it's crystal clear that independently of what opportunistic suspend is supposed to be fixing, the fact of the matter is that it's not a silver bullet as it's claimed to be.

So far, nobody has refuted these:
1) opportunistic suspend needs a good behaved user-space to work properly
2) if suspend blockers are enabled in a system, *all* user-space must
implement them to work correctly
3) implementing suspend blockers in user-space is not a straight-forward task
4) there's a point where sleeping (not doing work) has diminished returns

So, as the length of this thread has shown, the benefits of opportunistic suspend are *dubious* at best, and more likely not worth the changes needed in user-space which eventually will get pretty close to what suspend blockers can achieve even in ideal circumstances by just doing dynamic PM.

Signature · 1 line
Felipe Contreras
#674 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 9 lines · Felipe Contreras

My goal is to shine light. I've heard many invalid arguments in favor of suspend blockers, I want to shut them down.

In my mind it's crystal clear that independently of what opportunistic suspend is supposed to be fixing, the fact of the matter is that it's not a silver bullet as it's claimed to be.

So far, nobody has refuted these:
1) opportunistic suspend needs a good behaved user-space to work properly

That seems entirely reasonable, since opportunistic suspend is essentially a userspace facility. Its in-kernel component is extremely small (and is already in mainline).

Quoted 2 lines

2) if suspend blockers are enabled in a system, *all* user-space must
implement them to work correctly

That isn't clear at all. Certainly they must be implemented correctly in some parts of userspace. But other parts can simply be denied permission to use them.

Quoted 1 line

3) implementing suspend blockers in user-space is not a straight-forward task

Perhaps so. Lots of things in userspace aren't straight-forward -- GUIs, for example. So what? That's not a proof they shouldn't be used.

Quoted 1 line

4) there's a point where sleeping (not doing work) has diminished returns

Agreed. It is platform dependent. The Google people seem to believe strongly they have not yet reached that point on their platforms.

Quoted 5 lines

So, as the length of this thread has shown, the benefits of opportunistic suspend are *dubious* at best, and more likely not worth the changes needed in user-space which eventually will get pretty close to what suspend blockers can achieve even in ideal circumstances by just doing dynamic PM.

You're ignoring the fact that Android has _already_ made the necessary userspace changes. Now you're going to ask them to change back, offering as motivation the loss of a real (albeit "dubious") power-saving advantage? Why should they accept your offer?

Alan Stern

#675 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 9 lines · Felipe Contreras

My goal is to shine light. I've heard many invalid arguments in favor of suspend blockers, I want to shut them down.

In my mind it's crystal clear that independently of what opportunistic suspend is supposed to be fixing, the fact of the matter is that it's not a silver bullet as it's claimed to be.

So far, nobody has refuted these:
1) opportunistic suspend needs a good behaved user-space to work properly

That seems entirely reasonable, since opportunistic suspend is essentially a userspace facility. Its in-kernel component is extremely small (and is already in mainline).

Quoted 2 lines

2) if suspend blockers are enabled in a system, *all* user-space must
implement them to work correctly

That isn't clear at all. Certainly they must be implemented correctly in some parts of userspace. But other parts can simply be denied permission to use them.

Quoted 1 line

3) implementing suspend blockers in user-space is not a straight-forward task

Perhaps so. Lots of things in userspace aren't straight-forward -- GUIs, for example. So what? That's not a proof they shouldn't be used.

Quoted 1 line

4) there's a point where sleeping (not doing work) has diminished returns

Agreed. It is platform dependent. The Google people seem to believe strongly they have not yet reached that point on their platforms.

Quoted 5 lines

So, as the length of this thread has shown, the benefits of opportunistic suspend are *dubious* at best, and more likely not worth the changes needed in user-space which eventually will get pretty close to what suspend blockers can achieve even in ideal circumstances by just doing dynamic PM.

You're ignoring the fact that Android has _already_ made the necessary userspace changes. Now you're going to ask them to change back, offering as motivation the loss of a real (albeit "dubious") power-saving advantage? Why should they accept your offer?

Alan Stern

#676 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 10 lines · Alan Stern
Quoted 8 lines · Felipe Contreras

My goal is to shine light. I've heard many invalid arguments in favor of suspend blockers, I want to shut them down.

In my mind it's crystal clear that independently of what opportunistic suspend is supposed to be fixing, the fact of the matter is that it's not a silver bullet as it's claimed to be.

So far, nobody has refuted these:

[...]

Quoted 6 lines
Quoted 2 lines

 2) if suspend blockers are enabled in a system, *all* user-space must implement them to work correctly

That isn't clear at all.  Certainly they must be implemented correctly in some parts of userspace.  But other parts can simply be denied permission to use them.

Yes, but all user-space needs to be considered. There certainly will be cases when people think a certain package doesn't need them, but it turns out they did. Firefox? Nah... oh, wait a second, I want my downloads to finish. Do you think there will be any linux desktop distro willing to attempt that?

Quoted 5 lines
Quoted 1 line

 3) implementing suspend blockers in user-space is not a straight-forward task

Perhaps so.  Lots of things in userspace aren't straight-forward -- GUIs, for example.  So what?  That's not a proof they shouldn't be used.

Certainly not, but it means when measuring against plain dynamic PM, opportunistic suspend is less attractive.

Quoted 4 lines
Quoted 1 line

 4) there's a point where sleeping (not doing work) has diminished returns

Agreed.  It is platform dependent.  The Google people seem to believe strongly they have not yet reached that point on their platforms.

Yes, and Nokia/Intel people believe they are close on their platforms.

Surely, at some point Android will reach that point too.

Quoted 10 lines
Quoted 5 lines

So, as the length of this thread has shown, the benefits of opportunistic suspend are *dubious* at best, and more likely not worth the changes needed in user-space which eventually will get pretty close to what suspend blockers can achieve even in ideal circumstances by just doing dynamic PM.

You're ignoring the fact that Android has _already_ made the necessary userspace changes.  Now you're going to ask them to change back, offering as motivation the loss of a real (albeit "dubious") power-saving advantage?  Why should they accept your offer?

Android people have been selling the idea that suspend blockers are not only for Android, but other platforms can benefit from them too. I am arguing in that context. Hopefully you agree that that claim is dubious at best.

Now, switching to Android... I'm sure if Android guys say their user-space is far from the dynamic PM sweet-spot, then that's the case. Surely, at some point they will reach it, so that they can minimize power usage even when the device is actively used (it has been explained that opportunistic suspend is not activated when screen is on), maybe it will take one year, maybe two. Will they keep opportunistic suspend around for those marginal gains? Maybe.

The question is why are we adding a user-space API that:
1) no user-space beside Android has expresses interest in implementing
2) is dubious whether the benefits are worth the pain for non-Android
user-space
3) will become less and less attractive as dynamic PM gets closer to
the sweet-spot, and then surpass it
4) Android can keep in a separate tree until it's clear in the linux
community that it's useful (if it ever happens)

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#677 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Alan Stern
Quoted 10 lines · Alan Stern
Quoted 8 lines · Felipe Contreras

My goal is to shine light. I've heard many invalid arguments in favor of suspend blockers, I want to shut them down.

In my mind it's crystal clear that independently of what opportunistic suspend is supposed to be fixing, the fact of the matter is that it's not a silver bullet as it's claimed to be.

So far, nobody has refuted these:

[...]

Quoted 6 lines
Quoted 2 lines

 2) if suspend blockers are enabled in a system, *all* user-space must implement them to work correctly

That isn't clear at all.  Certainly they must be implemented correctly in some parts of userspace.  But other parts can simply be denied permission to use them.

Yes, but all user-space needs to be considered. There certainly will be cases when people think a certain package doesn't need them, but it turns out they did. Firefox? Nah... oh, wait a second, I want my downloads to finish. Do you think there will be any linux desktop distro willing to attempt that?

Quoted 5 lines
Quoted 1 line

 3) implementing suspend blockers in user-space is not a straight-forward task

Perhaps so.  Lots of things in userspace aren't straight-forward -- GUIs, for example.  So what?  That's not a proof they shouldn't be used.

Certainly not, but it means when measuring against plain dynamic PM, opportunistic suspend is less attractive.

Quoted 4 lines
Quoted 1 line

 4) there's a point where sleeping (not doing work) has diminished returns

Agreed.  It is platform dependent.  The Google people seem to believe strongly they have not yet reached that point on their platforms.

Yes, and Nokia/Intel people believe they are close on their platforms.

Surely, at some point Android will reach that point too.

Quoted 10 lines
Quoted 5 lines

So, as the length of this thread has shown, the benefits of opportunistic suspend are *dubious* at best, and more likely not worth the changes needed in user-space which eventually will get pretty close to what suspend blockers can achieve even in ideal circumstances by just doing dynamic PM.

You're ignoring the fact that Android has _already_ made the necessary userspace changes.  Now you're going to ask them to change back, offering as motivation the loss of a real (albeit "dubious") power-saving advantage?  Why should they accept your offer?

Android people have been selling the idea that suspend blockers are not only for Android, but other platforms can benefit from them too. I am arguing in that context. Hopefully you agree that that claim is dubious at best.

Now, switching to Android... I'm sure if Android guys say their user-space is far from the dynamic PM sweet-spot, then that's the case. Surely, at some point they will reach it, so that they can minimize power usage even when the device is actively used (it has been explained that opportunistic suspend is not activated when screen is on), maybe it will take one year, maybe two. Will they keep opportunistic suspend around for those marginal gains? Maybe.

The question is why are we adding a user-space API that:
1) no user-space beside Android has expresses interest in implementing
2) is dubious whether the benefits are worth the pain for non-Android
user-space
3) will become less and less attractive as dynamic PM gets closer to
the sweet-spot, and then surpass it
4) Android can keep in a separate tree until it's clear in the linux
community that it's useful (if it ever happens)

Signature · 1 line
Felipe Contreras
#678 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 9 lines · Felipe Contreras

The question is why are we adding a user-space API that:
1) no user-space beside Android has expresses interest in implementing
2) is dubious whether the benefits are worth the pain for non-Android
user-space
3) will become less and less attractive as dynamic PM gets closer to
the sweet-spot, and then surpass it
4) Android can keep in a separate tree until it's clear in the linux
community that it's useful (if it ever happens)

So, Felipe,

Do you believe you speak for all of LKML?

Are you willing to tell ZDNet and the Slashdot fanboys that it's OK for Suspend blockers to live in a separate tree, and it's not a case of OMG! Google is forking the kernel?

If you could speak out a passionately on those forums as you have here, that would be great.

- Ted

#679 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 9 lines · Felipe Contreras

The question is why are we adding a user-space API that:
1) no user-space beside Android has expresses interest in implementing
2) is dubious whether the benefits are worth the pain for non-Android
user-space
3) will become less and less attractive as dynamic PM gets closer to
the sweet-spot, and then surpass it
4) Android can keep in a separate tree until it's clear in the linux
community that it's useful (if it ever happens)

So, Felipe,

Do you believe you speak for all of LKML?

Are you willing to tell ZDNet and the Slashdot fanboys that it's OK for Suspend blockers to live in a separate tree, and it's not a case of OMG! Google is forking the kernel?

If you could speak out a passionately on those forums as you have here, that would be great.

- Ted

#728 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 4 lines · Felipe Contreras

So far, nobody has refuted these:
1) opportunistic suspend needs a good behaved user-space to work properly
2) if suspend blockers are enabled in a system, *all* user-space must
implement them to work correctly

For this note that there's a fairly strong expectation that even in a phone type environment a sane userspace implementation will involve a very large portion of userspace just totally ignoring suspend blockers. This means that while it is true that userspace as a whole must have support for suspend blockers the changes required are substantially less invasive than you appear to expecting.

#729 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 4 lines · Felipe Contreras

So far, nobody has refuted these:
1) opportunistic suspend needs a good behaved user-space to work properly
2) if suspend blockers are enabled in a system, *all* user-space must
implement them to work correctly

For this note that there's a fairly strong expectation that even in a phone type environment a sane userspace implementation will involve a very large portion of userspace just totally ignoring suspend blockers. This means that while it is true that userspace as a whole must have support for suspend blockers the changes required are substantially less invasive than you appear to expecting.

#636 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 25 lines · Felipe Contreras
Quoted 23 lines · Paul E. McKenney
Quoted 22 lines · Felipe Contreras
Quoted 19 lines · Paul E. McKenney
Quoted 10 lines · Alan Cox

You may also wish to review the earlier parts of the discussion where it was explicitly stated by several developers that they were using "suspend" type modes as power states already and not using suspend blockers. So it's being done, today on ARM and your statement is directly contradicting the code. Modern ARM processors and x86 MID devices can suspend and resume extremely fast (fast enough that the fact Linux x86 rewriting all the SMP alternatives on suspend/resume is a measurable problem). If this same property doesn't end up on big PC boxes in time then I'd be very surprised. At that point the openoffice with suspend blockers or oracle with suspend blockers question becomes rather relevant.

Here is the list of properties distinguishing idle from suspend:

1.      Idle states are entered by a given CPU only there are no runnable tasks for that CPU.  In contrast, opportunistic suspend can halt the entire system even when there are tasks that are ready, willing, and able to run.  (But please note that this might not apply to real-time tasks.)

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

But if there are no runnable tasks (which is the target), they behave the same.

And if there are runnable tasks, then then don't behave the same.

Unless they have blocked suspend.

You are quite correct. I should have said something like "But if there are runnable tasks, none of which is holding a suspend blocker, then they don't behave the same."

Quoted 9 lines

Anyway, Alan was picturing a hypothetical point in time when x86 can suspend/resume as fast as ARM, and thus the question of whether or not to enable suspend-blockers in a system that runs openoffice becomes relevant. If applications have been fixed by that time to not wake the system unnecessarily, as many of them have already been tanks to tools like powertop, then suspend-blockers would not make that much of a difference, therefore the effort required to implement suspend-blockers properly on all applications in the system, including openoffice might not be worth the gain.

One more time, this time with feeling. ;-)

Only PM-driving applications need concern themselves with suspend blockers, and experience thus far indicates that PM-driving applications are a very small fraction of the total.

Quoted 6 lines
Quoted 1 line

Apparently different people in this debate have different targets.

I remember clearly Android people explaining that dynamic PM is orthogonal to suspend-blockers; if a suspend is blocked, you still want dynamic PM to reach the lower power state. Therefore the target of not having unneeded runnable tasks is shared by Android folks.

And I have not seen anyone argue that suspend blockers are a replacement for dynamic power management. Many people instead seem to be advocating using them both -- dynamic power management for when at least one PM-driving application or kernel driver is keeping the system awake, and suspend blockers for when only power-oblivious applications are running.

In contrast, you are advocating dynamic power management to the exclusion of other mechanisms.

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines

2.      There can be a set of input events that do not bring the system out of suspend, but which would bring the system out of idle. Exactly which events are in this set depends both on hardware capabilities and on the platform/application policy.  For example, on one of the Android-based smartphones, touchscreen input is ignored when the system is suspended, but is handled when idle.

And in N900 touching the screen doesn't bring the device out of idle, I guess because it's off.

Quoted 8 lines
Quoted 2 lines

As long as touching the N900 screen doesn't bring the device out of suspend, its behavior is not a counterexample to #2 above.

You said "there can be a set of input events that do not bring the system out of suspend, but which would bring the system out of idle". There's no suspend (in the Android sense) in N900, only idle, and the events that bring N900 out of idle can be mapped to the set of events that bring Android out of suspend.

We do seem to be in violent agreement.

Quoted 2 lines

IOW. Alan wasn't talking about idle vs suspend on the same device, he was talking about opportunistic suspend vs dynamic PM.

The most convincing comparisons will be of suspend vs. idle on the same device. If multiple devices are involved, then the most convincing experiments would compare suspend vs. idle separately on each device.

So, are you sure that you are correctly interpreting Alan's words?

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

3.      The system comes out of idle when a timer expires.  In contrast, timers might or might not bring the system out of suspend, depending on both hardware capabilities and platform/application policy.

Quoted 8 lines
Quoted 1 line

Isn't this solved by range timers?

Ahem.  This is a list of differences between idle and suspend, not a list of problems to be solved.  But to answer your question, if a timer does not bring a given device out of suspend, then a range timer is not likely to, either.  Don't get me wrong, I do believe that range timers have an important part to play in the energy-efficiency arena, but I have not been convinced that they are any kind of silver bullet.

Quoted 3 lines

Certainly, but the context is the set of differences that would aid in the decision of whether or not to go for suspend-blockers in a general purpose system where openoffice would run.

Again, I am in no way arguing for suspend blockers to the exclusion of other approaches. Heck, I am mostly just trying to get a clear statement of the problem. In contrast, you do seem to be advocating for dynamic power management to the exclusion of other approaches.

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

4.      Suspend generally forces devices to go into their low-power states immediately.  In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices.  Idle thus has shorter average wakeup latencies, but worse energy efficiency.

Only if you make these assumptions
 1) All the applications use suspend-blockers only when they absolutely must
 2) The user has given the right applications the right access

Quoted 8 lines
Quoted 3 lines

You believe that these assumptions are unreasonable?  Compared to the assumption that all applications are carefully written to conserve power? If so, on what grounds?

No, I think both (for opportunistic suspend and dynamic PM) are completely reasonable. But think again; if you have the assumptions met on both, then both work fine, if you don't meet them, then both don't work correctly.

That is true of any artifact, software or otherwise: if you don't meet the assumptions inherent in its design and construction, the artifact might fail. Of course, you argument also applies to dynamic power management:
and in fact it takes just one power-oblivious application to drain your battery -- especially if that application goes into an infinite loop. And if that application goes into an infinite loop only under some unusual set of conditions, it might have passed your test suite with flying colors, so that you might even have given it a power-management gold star, right?

And yes, you can get the same effect with an infinite loop in a PM-driving application that happens to be holding suspend blockers at the time. However, in the suspend-blocker case, one need only inspect that code that holds suspend blockers. In the dynamic power management case, one must inspect -all- the code. There is a very real difference between those two tasks.

So are you sure that dynamic power management will turn out to be the right tool for every job out there? If so, on what grounds?

Quoted 3 lines

My point is that suspend-blockers don't magically reduce power usage, just like dynamic PM, it depends on what user-space actually does. You made it look as it *always* reached better energy efficiency.

I do? Really??? Exactly what did I say to give you that impression?

I am not saying that suspend blockers are the right tool for every power management job, instead, I am asking whether there are some power management jobs for which it is the best tool.

Quoted 5 lines
Quoted 2 lines

It seems to me that the same social-engineering approaches work in both cases.

Yes, but if dynamic PM works as advertised, you don't need opportunistic suspend.

For dynamic power management to totally eliminate the need for something like suspend blockers, you are having to make some brave assumptions. Yes, dynamic power management is quite useful, but there is a big difference between something being useful and something doing everything for everyone. You have not yet convinced me that dynamic power management will make it to the "doing everything for everyone" stage.

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

Really?  What makes you say that?

For starters an application might be holding the wakelock more than it should, also, an application might miss a timer due to not having PM permissions to hold the lock, and thus might need an expensive initialization when it runs again.

Just as an application might run continuously without blocking, which would defeat the dynamic power management scheme that have thus far been put forward. And just as an application might miss a timer due to dynamic power management having decided that it didn't need that timer to fire at the desired time.

Thanx, Paul

#637 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 25 lines · Felipe Contreras
Quoted 23 lines · Paul E. McKenney
Quoted 22 lines · Felipe Contreras
Quoted 19 lines · Paul E. McKenney
Quoted 10 lines · Alan Cox

You may also wish to review the earlier parts of the discussion where it was explicitly stated by several developers that they were using "suspend" type modes as power states already and not using suspend blockers. So it's being done, today on ARM and your statement is directly contradicting the code. Modern ARM processors and x86 MID devices can suspend and resume extremely fast (fast enough that the fact Linux x86 rewriting all the SMP alternatives on suspend/resume is a measurable problem). If this same property doesn't end up on big PC boxes in time then I'd be very surprised. At that point the openoffice with suspend blockers or oracle with suspend blockers question becomes rather relevant.

Here is the list of properties distinguishing idle from suspend:

1.      Idle states are entered by a given CPU only there are no runnable tasks for that CPU.  In contrast, opportunistic suspend can halt the entire system even when there are tasks that are ready, willing, and able to run.  (But please note that this might not apply to real-time tasks.)

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

But if there are no runnable tasks (which is the target), they behave the same.

And if there are runnable tasks, then then don't behave the same.

Unless they have blocked suspend.

You are quite correct. I should have said something like "But if there are runnable tasks, none of which is holding a suspend blocker, then they don't behave the same."

Quoted 9 lines

Anyway, Alan was picturing a hypothetical point in time when x86 can suspend/resume as fast as ARM, and thus the question of whether or not to enable suspend-blockers in a system that runs openoffice becomes relevant. If applications have been fixed by that time to not wake the system unnecessarily, as many of them have already been tanks to tools like powertop, then suspend-blockers would not make that much of a difference, therefore the effort required to implement suspend-blockers properly on all applications in the system, including openoffice might not be worth the gain.

One more time, this time with feeling. ;-)

Only PM-driving applications need concern themselves with suspend blockers, and experience thus far indicates that PM-driving applications are a very small fraction of the total.

Quoted 6 lines
Quoted 1 line

Apparently different people in this debate have different targets.

I remember clearly Android people explaining that dynamic PM is orthogonal to suspend-blockers; if a suspend is blocked, you still want dynamic PM to reach the lower power state. Therefore the target of not having unneeded runnable tasks is shared by Android folks.

And I have not seen anyone argue that suspend blockers are a replacement for dynamic power management. Many people instead seem to be advocating using them both -- dynamic power management for when at least one PM-driving application or kernel driver is keeping the system awake, and suspend blockers for when only power-oblivious applications are running.

In contrast, you are advocating dynamic power management to the exclusion of other mechanisms.

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines

2.      There can be a set of input events that do not bring the system out of suspend, but which would bring the system out of idle. Exactly which events are in this set depends both on hardware capabilities and on the platform/application policy.  For example, on one of the Android-based smartphones, touchscreen input is ignored when the system is suspended, but is handled when idle.

And in N900 touching the screen doesn't bring the device out of idle, I guess because it's off.

Quoted 8 lines
Quoted 2 lines

As long as touching the N900 screen doesn't bring the device out of suspend, its behavior is not a counterexample to #2 above.

You said "there can be a set of input events that do not bring the system out of suspend, but which would bring the system out of idle". There's no suspend (in the Android sense) in N900, only idle, and the events that bring N900 out of idle can be mapped to the set of events that bring Android out of suspend.

We do seem to be in violent agreement.

Quoted 2 lines

IOW. Alan wasn't talking about idle vs suspend on the same device, he was talking about opportunistic suspend vs dynamic PM.

The most convincing comparisons will be of suspend vs. idle on the same device. If multiple devices are involved, then the most convincing experiments would compare suspend vs. idle separately on each device.

So, are you sure that you are correctly interpreting Alan's words?

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

3.      The system comes out of idle when a timer expires.  In contrast, timers might or might not bring the system out of suspend, depending on both hardware capabilities and platform/application policy.

Quoted 8 lines
Quoted 1 line

Isn't this solved by range timers?

Ahem.  This is a list of differences between idle and suspend, not a list of problems to be solved.  But to answer your question, if a timer does not bring a given device out of suspend, then a range timer is not likely to, either.  Don't get me wrong, I do believe that range timers have an important part to play in the energy-efficiency arena, but I have not been convinced that they are any kind of silver bullet.

Quoted 3 lines

Certainly, but the context is the set of differences that would aid in the decision of whether or not to go for suspend-blockers in a general purpose system where openoffice would run.

Again, I am in no way arguing for suspend blockers to the exclusion of other approaches. Heck, I am mostly just trying to get a clear statement of the problem. In contrast, you do seem to be advocating for dynamic power management to the exclusion of other approaches.

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

4.      Suspend generally forces devices to go into their low-power states immediately.  In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices.  Idle thus has shorter average wakeup latencies, but worse energy efficiency.

Only if you make these assumptions
 1) All the applications use suspend-blockers only when they absolutely must
 2) The user has given the right applications the right access

Quoted 8 lines
Quoted 3 lines

You believe that these assumptions are unreasonable?  Compared to the assumption that all applications are carefully written to conserve power? If so, on what grounds?

No, I think both (for opportunistic suspend and dynamic PM) are completely reasonable. But think again; if you have the assumptions met on both, then both work fine, if you don't meet them, then both don't work correctly.

That is true of any artifact, software or otherwise: if you don't meet the assumptions inherent in its design and construction, the artifact might fail. Of course, you argument also applies to dynamic power management:
and in fact it takes just one power-oblivious application to drain your battery -- especially if that application goes into an infinite loop. And if that application goes into an infinite loop only under some unusual set of conditions, it might have passed your test suite with flying colors, so that you might even have given it a power-management gold star, right?

And yes, you can get the same effect with an infinite loop in a PM-driving application that happens to be holding suspend blockers at the time. However, in the suspend-blocker case, one need only inspect that code that holds suspend blockers. In the dynamic power management case, one must inspect -all- the code. There is a very real difference between those two tasks.

So are you sure that dynamic power management will turn out to be the right tool for every job out there? If so, on what grounds?

Quoted 3 lines

My point is that suspend-blockers don't magically reduce power usage, just like dynamic PM, it depends on what user-space actually does. You made it look as it *always* reached better energy efficiency.

I do? Really??? Exactly what did I say to give you that impression?

I am not saying that suspend blockers are the right tool for every power management job, instead, I am asking whether there are some power management jobs for which it is the best tool.

Quoted 5 lines
Quoted 2 lines

It seems to me that the same social-engineering approaches work in both cases.

Yes, but if dynamic PM works as advertised, you don't need opportunistic suspend.

For dynamic power management to totally eliminate the need for something like suspend blockers, you are having to make some brave assumptions. Yes, dynamic power management is quite useful, but there is a big difference between something being useful and something doing everything for everyone. You have not yet convinced me that dynamic power management will make it to the "doing everything for everyone" stage.

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

Really?  What makes you say that?

For starters an application might be holding the wakelock more than it should, also, an application might miss a timer due to not having PM permissions to hold the lock, and thus might need an expensive initialization when it runs again.

Just as an application might run continuously without blocking, which would defeat the dynamic power management scheme that have thus far been put forward. And just as an application might miss a timer due to dynamic power management having decided that it didn't need that timer to fire at the desired time.

Thanx, Paul

#680 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 11 lines · Ted Ts'o
Quoted 9 lines · Felipe Contreras

The question is why are we adding a user-space API that:
 1) no user-space beside Android has expresses interest in implementing
 2) is dubious whether the benefits are worth the pain for non-Android user-space
 3) will become less and less attractive as dynamic PM gets closer to the sweet-spot, and then surpass it
 4) Android can keep in a separate tree until it's clear in the linux community that it's useful (if it ever happens)

Quoted 1 line

Do you believe you speak for all of LKML?

No. I'm speaking for myself, and that includes a lot of what people on LKML have already said.

Quoted 3 lines

Are you willing to tell ZDNet and the Slashdot fanboys that it's OK for Suspend blockers to live in a separate tree, and it's not a case of OMG!  Google is forking the kernel?

All the Android community had to do is push the drivers *without* suspend blockers, then the Android kernel wouldn't be so different and thus wouldn't be considered a fork. AFAIU the kernel side wakelocks are already in the kernel, so there's no excuse not to merge the drivers.

Then people would stop blaming Google for forking the kernel.

Nobody from the "media" cares about suspend blockers; they are a small patch which cannot be considered a fork, more like a hack, like many other platforms have.

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#681 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 11 lines · Ted Ts'o
Quoted 9 lines · Felipe Contreras

The question is why are we adding a user-space API that:
 1) no user-space beside Android has expresses interest in implementing
 2) is dubious whether the benefits are worth the pain for non-Android user-space
 3) will become less and less attractive as dynamic PM gets closer to the sweet-spot, and then surpass it
 4) Android can keep in a separate tree until it's clear in the linux community that it's useful (if it ever happens)

Quoted 1 line

Do you believe you speak for all of LKML?

No. I'm speaking for myself, and that includes a lot of what people on LKML have already said.

Quoted 3 lines

Are you willing to tell ZDNet and the Slashdot fanboys that it's OK for Suspend blockers to live in a separate tree, and it's not a case of OMG!  Google is forking the kernel?

All the Android community had to do is push the drivers *without* suspend blockers, then the Android kernel wouldn't be so different and thus wouldn't be considered a fork. AFAIU the kernel side wakelocks are already in the kernel, so there's no excuse not to merge the drivers.

Then people would stop blaming Google for forking the kernel.

Nobody from the "media" cares about suspend blockers; they are a small patch which cannot be considered a fork, more like a hack, like many other platforms have.

Signature · 1 line
Felipe Contreras
#730 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Mark Brown
Quoted 7 lines · Mark Brown
Quoted 4 lines · Felipe Contreras

So far, nobody has refuted these:
 1) opportunistic suspend needs a good behaved user-space to work properly
 2) if suspend blockers are enabled in a system, *all* user-space must implement them to work correctly

Quoted 6 lines

For this note that there's a fairly strong expectation that even in a phone type environment a sane userspace implementation will involve a very large portion of userspace just totally ignoring suspend blockers. This means that while it is true that userspace as a whole must have support for suspend blockers the changes required are substantially less invasive than you appear to expecting.

Correct, but still a considerable amount of changes would need to be done, which _nobody_ has expressed any intention to do.

Besides, IMO a good mobile platform would share as much as possible with desktop software. Say, the improvements Nokia has endorsed on the Telepathy IM framework can only help the people already using it on the desktop.

However, personally, if I ever have to do './configure --enable-suspend-blockers', I would think that something that just doesn't belong has creped by to user-space. I don't see why there should something particularly different between mobile phones and laptops, and I think this has been already expressed over, and over.

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#731 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Mark Brown
Quoted 7 lines · Mark Brown
Quoted 4 lines · Felipe Contreras

So far, nobody has refuted these:
 1) opportunistic suspend needs a good behaved user-space to work properly
 2) if suspend blockers are enabled in a system, *all* user-space must implement them to work correctly

Quoted 6 lines

For this note that there's a fairly strong expectation that even in a phone type environment a sane userspace implementation will involve a very large portion of userspace just totally ignoring suspend blockers. This means that while it is true that userspace as a whole must have support for suspend blockers the changes required are substantially less invasive than you appear to expecting.

Correct, but still a considerable amount of changes would need to be done, which _nobody_ has expressed any intention to do.

Besides, IMO a good mobile platform would share as much as possible with desktop software. Say, the improvements Nokia has endorsed on the Telepathy IM framework can only help the people already using it on the desktop.

However, personally, if I ever have to do './configure --enable-suspend-blockers', I would think that something that just doesn't belong has creped by to user-space. I don't see why there should something particularly different between mobile phones and laptops, and I think this has been already expressed over, and over.

Signature · 1 line
Felipe Contreras
#732 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 9 lines · Felipe Contreras

Correct, but still a considerable amount of changes would need to be done, which _nobody_ has expressed any intention to do.

Besides, IMO a good mobile platform would share as much as possible with desktop software. Say, the improvements Nokia has endorsed on the Telepathy IM framework can only help the people already using it on the desktop.

Quoted 5 lines

However, personally, if I ever have to do './configure --enable-suspend-blockers', I would think that something that just doesn't belong has creped by to user-space. I don't see why there should something particularly different between mobile phones and laptops, and I think this has been already expressed over, and over.

So, because you feel that phones should be little laptops you oppose providing (optional!) support for environments that take a different view to that?

I'll echo Ted's question -- is this the opinion of the kernel community at large? If so, there's not much point in continuing to have discussions around suspend blockers.

I think that we're still a ways away from a world where we can treat mobile devices the same as laptops and get reasonable user experiences. I think it's unfortunate if the attitude here is "wait and someday it won't matter", especially because I'm skeptical that we're likely to hit that "someday" any time soon.

Brian

#733 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 9 lines · Felipe Contreras

Correct, but still a considerable amount of changes would need to be done, which _nobody_ has expressed any intention to do.

Besides, IMO a good mobile platform would share as much as possible with desktop software. Say, the improvements Nokia has endorsed on the Telepathy IM framework can only help the people already using it on the desktop.

Quoted 5 lines

However, personally, if I ever have to do './configure --enable-suspend-blockers', I would think that something that just doesn't belong has creped by to user-space. I don't see why there should something particularly different between mobile phones and laptops, and I think this has been already expressed over, and over.

So, because you feel that phones should be little laptops you oppose providing (optional!) support for environments that take a different view to that?

I'll echo Ted's question -- is this the opinion of the kernel community at large? If so, there's not much point in continuing to have discussions around suspend blockers.

I think that we're still a ways away from a world where we can treat mobile devices the same as laptops and get reasonable user experiences. I think it's unfortunate if the attitude here is "wait and someday it won't matter", especially because I'm skeptical that we're likely to hit that "someday" any time soon.

Brian

#738 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 9 lines · Felipe Contreras
Quoted 1 line · Theodore Tso

One thing I'm not clear on --- what's your goal?   Is your goal to keep suspend-blockers out of the kernel?   Is it to try to convince the android team suspend-blockers are a bad idea and to change Android to not use them?  Is it to push some other agenda?  Is it to discourage the Android team from trying to waste more time trying to get suspend-blockers (or equivalent functionality) from being added into the kernel?

My goal is to shine light. I've heard many invalid arguments in favor of suspend blockers, I want to shut them down.

In my mind it's crystal clear that independently of what opportunistic suspend is supposed to be fixing, the fact of the matter is that it's not a silver bullet as it's claimed to be.

The question is not whether suspend blockers are a silver bullet (in my opinion there are no silver bullets), but rather whether or not suspend blockers are useful.

Quoted 2 lines

So far, nobody has refuted these:
1) opportunistic suspend needs a good behaved user-space to work properly

As does dynamic power management.

Quoted 2 lines

2) if suspend blockers are enabled in a system, *all* user-space must
implement them to work correctly

Really? From what I can see, only PM-driving applications need to use suspend blockers.

Quoted 1 line

3) implementing suspend blockers in user-space is not a straight-forward task

Fortunately, experience thus far has shown that only a small fraction of applications need to use suspend blockers. (Or perhaps you are instead saying that the implementation of the suspend-blocker infrastructure itself is not straightforward? It is not clear from your words.)

Quoted 1 line

4) there's a point where sleeping (not doing work) has diminished returns

This one I agree with.

Quoted 5 lines

So, as the length of this thread has shown, the benefits of opportunistic suspend are *dubious* at best, and more likely not worth the changes needed in user-space which eventually will get pretty close to what suspend blockers can achieve even in ideal circumstances by just doing dynamic PM.

The length of this thread (and the ones preceding it) is mostly due to people talking past each other. For example, the Android folks seem to believe that it is important that relatively unskilled people be able to write simple apps, and that the system nevertheless be able to run these apps in a relatively energy efficient manner. Your proposals do not address this issue. This might be because you are not aware of this desire, because you are not aware of the computing history that argues in favor of this requirement, or because you simply don't like this requirement. Whatever the reason, until you face this requirement head on, either addressing it or proving that it need not be addressed, you will continue to be talking past the Android folks.

Thanx, Paul

#739 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 9 lines · Felipe Contreras
Quoted 1 line · Theodore Tso

One thing I'm not clear on --- what's your goal?   Is your goal to keep suspend-blockers out of the kernel?   Is it to try to convince the android team suspend-blockers are a bad idea and to change Android to not use them?  Is it to push some other agenda?  Is it to discourage the Android team from trying to waste more time trying to get suspend-blockers (or equivalent functionality) from being added into the kernel?

My goal is to shine light. I've heard many invalid arguments in favor of suspend blockers, I want to shut them down.

In my mind it's crystal clear that independently of what opportunistic suspend is supposed to be fixing, the fact of the matter is that it's not a silver bullet as it's claimed to be.

The question is not whether suspend blockers are a silver bullet (in my opinion there are no silver bullets), but rather whether or not suspend blockers are useful.

Quoted 2 lines

So far, nobody has refuted these:
1) opportunistic suspend needs a good behaved user-space to work properly

As does dynamic power management.

Quoted 2 lines

2) if suspend blockers are enabled in a system, *all* user-space must
implement them to work correctly

Really? From what I can see, only PM-driving applications need to use suspend blockers.

Quoted 1 line

3) implementing suspend blockers in user-space is not a straight-forward task

Fortunately, experience thus far has shown that only a small fraction of applications need to use suspend blockers. (Or perhaps you are instead saying that the implementation of the suspend-blocker infrastructure itself is not straightforward? It is not clear from your words.)

Quoted 1 line

4) there's a point where sleeping (not doing work) has diminished returns

This one I agree with.

Quoted 5 lines

So, as the length of this thread has shown, the benefits of opportunistic suspend are *dubious* at best, and more likely not worth the changes needed in user-space which eventually will get pretty close to what suspend blockers can achieve even in ideal circumstances by just doing dynamic PM.

The length of this thread (and the ones preceding it) is mostly due to people talking past each other. For example, the Android folks seem to believe that it is important that relatively unskilled people be able to write simple apps, and that the system nevertheless be able to run these apps in a relatively energy efficient manner. Your proposals do not address this issue. This might be because you are not aware of this desire, because you are not aware of the computing history that argues in favor of this requirement, or because you simply don't like this requirement. Whatever the reason, until you face this requirement head on, either addressing it or proving that it need not be addressed, you will continue to be talking past the Android folks.

Thanx, Paul

#638 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 11 lines · Paul E. McKenney
Quoted 9 lines · Felipe Contreras

Anyway, Alan was picturing a hypothetical point in time when x86 can suspend/resume as fast as ARM, and thus the question of whether or not to enable suspend-blockers in a system that runs openoffice becomes relevant. If applications have been fixed by that time to not wake the system unnecessarily, as many of them have already been tanks to tools like powertop, then suspend-blockers would not make that much of a difference, therefore the effort required to implement suspend-blockers properly on all applications in the system, including openoffice might not be worth the gain.

Quoted 5 lines

One more time, this time with feeling.  ;-)

       Only PM-driving applications need concern themselves with suspend blockers, and experience thus far indicates that PM-driving applications are a very small fraction of the total.

There's no experience on this. Have you tried to run a small debian system with suspend blockers enabled? I can image at least all cron daemons need modifications, probably dbus, links, lftp, wget, rsync and a bunch of applications that download data too.

It's easy to speculate one way or the other, but the fact of the matter is that we don't really know how many changes are needed in order to have a functional system that actually benefits from suspend blockers.

What we know is that if an application is not analyzed to see if it needs suspend blockers, and implement them if needed, it might get broken.

Quoted 9 lines
Quoted 6 lines
Quoted 1 line

Apparently different people in this debate have different targets.

I remember clearly Android people explaining that dynamic PM is orthogonal to suspend-blockers; if a suspend is blocked, you still want dynamic PM to reach the lower power state. Therefore the target of not having unneeded runnable tasks is shared by Android folks.

And I have not seen anyone argue that suspend blockers are a replacement for dynamic power management.

That's exactly what I'm saying: they are orthogonal.

Quoted 2 lines

In contrast, you are advocating dynamic power management to the exclusion of other mechanisms.

* if dynamic PM was perfect, spend-blockers would *not* be not needed
* if suspend-blockers were perfect, dynamic *will* still be needed

All I said in that sentence you are replying is that dynamic PM will improve; it's a shared goal of everyone.

Quoted 8 lines
Quoted 2 lines

IOW. Alan wasn't talking about idle vs suspend on the same device, he was talking about opportunistic suspend vs dynamic PM.

The most convincing comparisons will be of suspend vs. idle on the same device.  If multiple devices are involved, then the most convincing experiments would compare suspend vs. idle separately on each device.

So, are you sure that you are correctly interpreting Alan's words?

The point you are trying to highlight is to which events the system reacts, that has nothing to do with dynamic PM vs opportunistic suspend.

Quoted 4 lines

Again, I am in no way arguing for suspend blockers to the exclusion of other approaches.  Heck, I am mostly just trying to get a clear statement of the problem.  In contrast, you do seem to be advocating for dynamic power management to the exclusion of other approaches.

What you are doing is copy pasting a definition of what is opportunistic suspend and making it pass as an advantage.

This particular point (3.) is not an advantage, over dynamic PM, it's just a difference.

Quoted 8 lines
Quoted 4 lines

No, I think both (for opportunistic suspend and dynamic PM) are completely reasonable. But think again; if you have the assumptions met on both, then both work fine, if you don't meet them, then both don't work correctly.

That is true of any artifact, software or otherwise: if you don't meet the assumptions inherent in its design and construction, the artifact might fail.

[...]

Quoted 2 lines

 There is
a very real difference between those two tasks.

I've cut most of your explanation. If I understand correctly what you are saying is that suspend blockers are harder to get wrong. I agree, but my point against 4. remains the same: suspend-blockers don't automatically get you more efficient power usage.

Quoted 2 lines

So are you sure that dynamic power management will turn out to be the right tool for every job out there?  If so, on what grounds?

I don't understand this question. Dynamic PM is needed regardless. We are discussing your point 4 where you say suspend blockers inevitably lead to more efficient power usage (I say not necessarily).

Quoted 5 lines
Quoted 3 lines

My point is that suspend-blockers don't magically reduce power usage, just like dynamic PM, it depends on what user-space actually does. You made it look as it *always* reached better energy efficiency.

I do?  Really???  Exactly what did I say to give you that impression?

Here's your point 4 again:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

4. Suspend generally forces devices to go into their low-power
states immediately. In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices. Idle thus has shorter average wakeup latencies, but worse energy efficiency.

Remove "but worse energy efficiency" and I think that point would be correct, albeit it's not really an argument in favor of opportunistic suspend.

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

It seems to me that the same social-engineering approaches work in both cases.

Yes, but if dynamic PM works as advertised, you don't need opportunistic suspend.

Quoted 6 lines

For dynamic power management to totally eliminate the need for something like suspend blockers, you are having to make some brave assumptions. Yes, dynamic power management is quite useful, but there is a big difference between something being useful and something doing everything for everyone.  You have not yet convinced me that dynamic power management will make it to the "doing everything for everyone" stage.

As it has been explained before, there's a sweet-spot of idleness:
http://article.gmane.org/gmane.linux.kernel/995525
http://article.gmane.org/gmane.linux.ports.arm.omap/37982

Do you agree that there's such a thing, and if so, do you agree that the benefits of opportunistic suspend are much less once that point is reached?

Quoted 15 lines
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

Really?  What makes you say that?

For starters an application might be holding the wakelock more than it should, also, an application might miss a timer due to not having PM permissions to hold the lock, and thus might need an expensive initialization when it runs again.

Just as an application might run continuously without blocking, which would defeat the dynamic power management scheme that have thus far been put forward.  And just as an application might miss a timer due to dynamic power management having decided that it didn't need that timer to fire at the desired time.

Quoted 2 lines · concentrate on what I
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

I just proved to you that in certain cases opportunistic suspend might actually hurt. Thus you should accept my premise that you can't say that in practice opportunistic suspend _always_ leads to better results, because that's not the case.

And in order to try to avoid going back to the same points:
1) yes, there are advantages of opportunistic suspend
2) yes, there are cases where it works as it should
3) no, it's not a silver bullet that will inevitably improve power usage
4) no, we can't say anything about what opportunistic suspend means in practice

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#639 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 11 lines · Paul E. McKenney
Quoted 9 lines · Felipe Contreras

Anyway, Alan was picturing a hypothetical point in time when x86 can suspend/resume as fast as ARM, and thus the question of whether or not to enable suspend-blockers in a system that runs openoffice becomes relevant. If applications have been fixed by that time to not wake the system unnecessarily, as many of them have already been tanks to tools like powertop, then suspend-blockers would not make that much of a difference, therefore the effort required to implement suspend-blockers properly on all applications in the system, including openoffice might not be worth the gain.

Quoted 5 lines

One more time, this time with feeling.  ;-)

       Only PM-driving applications need concern themselves with suspend blockers, and experience thus far indicates that PM-driving applications are a very small fraction of the total.

There's no experience on this. Have you tried to run a small debian system with suspend blockers enabled? I can image at least all cron daemons need modifications, probably dbus, links, lftp, wget, rsync and a bunch of applications that download data too.

It's easy to speculate one way or the other, but the fact of the matter is that we don't really know how many changes are needed in order to have a functional system that actually benefits from suspend blockers.

What we know is that if an application is not analyzed to see if it needs suspend blockers, and implement them if needed, it might get broken.

Quoted 9 lines
Quoted 6 lines
Quoted 1 line

Apparently different people in this debate have different targets.

I remember clearly Android people explaining that dynamic PM is orthogonal to suspend-blockers; if a suspend is blocked, you still want dynamic PM to reach the lower power state. Therefore the target of not having unneeded runnable tasks is shared by Android folks.

And I have not seen anyone argue that suspend blockers are a replacement for dynamic power management.

That's exactly what I'm saying: they are orthogonal.

Quoted 2 lines

In contrast, you are advocating dynamic power management to the exclusion of other mechanisms.

* if dynamic PM was perfect, spend-blockers would *not* be not needed
* if suspend-blockers were perfect, dynamic *will* still be needed

All I said in that sentence you are replying is that dynamic PM will improve; it's a shared goal of everyone.

Quoted 8 lines
Quoted 2 lines

IOW. Alan wasn't talking about idle vs suspend on the same device, he was talking about opportunistic suspend vs dynamic PM.

The most convincing comparisons will be of suspend vs. idle on the same device.  If multiple devices are involved, then the most convincing experiments would compare suspend vs. idle separately on each device.

So, are you sure that you are correctly interpreting Alan's words?

The point you are trying to highlight is to which events the system reacts, that has nothing to do with dynamic PM vs opportunistic suspend.

Quoted 4 lines

Again, I am in no way arguing for suspend blockers to the exclusion of other approaches.  Heck, I am mostly just trying to get a clear statement of the problem.  In contrast, you do seem to be advocating for dynamic power management to the exclusion of other approaches.

What you are doing is copy pasting a definition of what is opportunistic suspend and making it pass as an advantage.

This particular point (3.) is not an advantage, over dynamic PM, it's just a difference.

Quoted 8 lines
Quoted 4 lines

No, I think both (for opportunistic suspend and dynamic PM) are completely reasonable. But think again; if you have the assumptions met on both, then both work fine, if you don't meet them, then both don't work correctly.

That is true of any artifact, software or otherwise: if you don't meet the assumptions inherent in its design and construction, the artifact might fail.

[...]

Quoted 2 lines

 There is
a very real difference between those two tasks.

I've cut most of your explanation. If I understand correctly what you are saying is that suspend blockers are harder to get wrong. I agree, but my point against 4. remains the same: suspend-blockers don't automatically get you more efficient power usage.

Quoted 2 lines

So are you sure that dynamic power management will turn out to be the right tool for every job out there?  If so, on what grounds?

I don't understand this question. Dynamic PM is needed regardless. We are discussing your point 4 where you say suspend blockers inevitably lead to more efficient power usage (I say not necessarily).

Quoted 5 lines
Quoted 3 lines

My point is that suspend-blockers don't magically reduce power usage, just like dynamic PM, it depends on what user-space actually does. You made it look as it *always* reached better energy efficiency.

I do?  Really???  Exactly what did I say to give you that impression?

Here's your point 4 again:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

4. Suspend generally forces devices to go into their low-power
states immediately. In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices. Idle thus has shorter average wakeup latencies, but worse energy efficiency.

Remove "but worse energy efficiency" and I think that point would be correct, albeit it's not really an argument in favor of opportunistic suspend.

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

It seems to me that the same social-engineering approaches work in both cases.

Yes, but if dynamic PM works as advertised, you don't need opportunistic suspend.

Quoted 6 lines

For dynamic power management to totally eliminate the need for something like suspend blockers, you are having to make some brave assumptions. Yes, dynamic power management is quite useful, but there is a big difference between something being useful and something doing everything for everyone.  You have not yet convinced me that dynamic power management will make it to the "doing everything for everyone" stage.

As it has been explained before, there's a sweet-spot of idleness:
http://article.gmane.org/gmane.linux.kernel/995525
http://article.gmane.org/gmane.linux.ports.arm.omap/37982

Do you agree that there's such a thing, and if so, do you agree that the benefits of opportunistic suspend are much less once that point is reached?

Quoted 15 lines
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

Really?  What makes you say that?

For starters an application might be holding the wakelock more than it should, also, an application might miss a timer due to not having PM permissions to hold the lock, and thus might need an expensive initialization when it runs again.

Just as an application might run continuously without blocking, which would defeat the dynamic power management scheme that have thus far been put forward.  And just as an application might miss a timer due to dynamic power management having decided that it didn't need that timer to fire at the desired time.

Quoted 2 lines · concentrate on what I
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

I just proved to you that in certain cases opportunistic suspend might actually hurt. Thus you should accept my premise that you can't say that in practice opportunistic suspend _always_ leads to better results, because that's not the case.

And in order to try to avoid going back to the same points:
1) yes, there are advantages of opportunistic suspend
2) yes, there are cases where it works as it should
3) no, it's not a silver bullet that will inevitably improve power usage
4) no, we can't say anything about what opportunistic suspend means in practice

Signature · 1 line
Felipe Contreras
#682 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 5 lines · Felipe Contreras

All the Android community had to do is push the drivers *without* suspend blockers, then the Android kernel wouldn't be so different and thus wouldn't be considered a fork. AFAIU the kernel side wakelocks are already in the kernel, so there's no excuse not to merge the drivers.

What's there is not good enough, because it's missing the statistics and reporting so that badly behaved kernel and userspace drivers that take wakelocks can be found.

I have a similar problem with the whole pm_qos subsystem, as I've said earlier. If some badly behaved application claims to want 0us wireless latency, and keeps the radio on all the time, there is no way for me to find out which is the badly behaved application --- even though I'm the owner of the laptop, and at the end of the day *I* should be able to say, no, battery lifetime is more important than what the application might think is its "minimum wireless latency". Not only can I not override the application, I can't even find out
which application is at fault! ***FAIL***

In some ways, this is exactly the same problem as the "which badly Maemo application is causing my causing my N770 to have its battery laptop drop in half?".

- Ted

#683 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 5 lines · Felipe Contreras

All the Android community had to do is push the drivers *without* suspend blockers, then the Android kernel wouldn't be so different and thus wouldn't be considered a fork. AFAIU the kernel side wakelocks are already in the kernel, so there's no excuse not to merge the drivers.

What's there is not good enough, because it's missing the statistics and reporting so that badly behaved kernel and userspace drivers that take wakelocks can be found.

I have a similar problem with the whole pm_qos subsystem, as I've said earlier. If some badly behaved application claims to want 0us wireless latency, and keeps the radio on all the time, there is no way for me to find out which is the badly behaved application --- even though I'm the owner of the laptop, and at the end of the day *I* should be able to say, no, battery lifetime is more important than what the application might think is its "minimum wireless latency". Not only can I not override the application, I can't even find out
which application is at fault! ***FAIL***

In some ways, this is exactly the same problem as the "which badly Maemo application is causing my causing my N770 to have its battery laptop drop in half?".

- Ted

#640 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 2 lines · Felipe Contreras

On Thu, Aug 12, 2010 at 7:19 PM, Paul E. McKenney
<[email protected]> wrote:

[ . . . ] (For now, anyway. I might respond to the rest later.)

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

My point is that suspend-blockers don't magically reduce power usage, just like dynamic PM, it depends on what user-space actually does. You made it look as it *always* reached better energy efficiency.

I do?  Really???  Exactly what did I say to give you that impression?

Here's your point 4 again:

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

4. Suspend generally forces devices to go into their low-power
states immediately. In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices. Idle thus has shorter average wakeup latencies, but worse energy efficiency.

Remove "but worse energy efficiency" and I think that point would be correct,

Now this is much more like it!!! Thank you!!!

You are quite correct, my last sentence does in fact assume that suspend will always have lower power consumption than does the deepest idle state. This of course sentence must be fixed. How about the following, which makes this assumption explicit, and adds words ("often", "might") that indicate that one's mileage might vary?

4. Suspend generally forces devices to go into their
low-power states immediately. In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices. Idle thus often has shorter average wakeup latencies, but on systems where suspend can use deeper sleep states than can idle, idle might have worse energy efficiency.

Quoted 2 lines

albeit it's not really an argument in favor of opportunistic
suspend.

It never was intended to be an argument of any kind. It was instead supposed to help clarify the difference between idle and suspend, in response to people stating that there is no difference between suspend and idle. If my mistake in the wording of the last sentence made you think otherwise, please accept my apologies.

[ . . . ] (For now, anyway. I might respond to the rest later.)

Thanx, Paul

#641 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 2 lines · Felipe Contreras

On Thu, Aug 12, 2010 at 7:19 PM, Paul E. McKenney
<[email protected]> wrote:

[ . . . ] (For now, anyway. I might respond to the rest later.)

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

My point is that suspend-blockers don't magically reduce power usage, just like dynamic PM, it depends on what user-space actually does. You made it look as it *always* reached better energy efficiency.

I do?  Really???  Exactly what did I say to give you that impression?

Here's your point 4 again:

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

4. Suspend generally forces devices to go into their low-power
states immediately. In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices. Idle thus has shorter average wakeup latencies, but worse energy efficiency.

Remove "but worse energy efficiency" and I think that point would be correct,

Now this is much more like it!!! Thank you!!!

You are quite correct, my last sentence does in fact assume that suspend will always have lower power consumption than does the deepest idle state. This of course sentence must be fixed. How about the following, which makes this assumption explicit, and adds words ("often", "might") that indicate that one's mileage might vary?

4. Suspend generally forces devices to go into their
low-power states immediately. In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices. Idle thus often has shorter average wakeup latencies, but on systems where suspend can use deeper sleep states than can idle, idle might have worse energy efficiency.

Quoted 2 lines

albeit it's not really an argument in favor of opportunistic
suspend.

It never was intended to be an argument of any kind. It was instead supposed to help clarify the difference between idle and suspend, in response to people stating that there is no difference between suspend and idle. If my mistake in the wording of the last sentence made you think otherwise, please accept my apologies.

[ . . . ] (For now, anyway. I might respond to the rest later.)

Thanx, Paul

#734 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Brian Swetland

Hi Brian,

Quoted 17 lines · Brian Swetland
Quoted 9 lines · Felipe Contreras

Correct, but still a considerable amount of changes would need to be done, which _nobody_ has expressed any intention to do.

Besides, IMO a good mobile platform would share as much as possible with desktop software. Say, the improvements Nokia has endorsed on the Telepathy IM framework can only help the people already using it on the desktop.

Quoted 5 lines

However, personally, if I ever have to do './configure --enable-suspend-blockers', I would think that something that just doesn't belong has creped by to user-space. I don't see why there should something particularly different between mobile phones and laptops, and I think this has been already expressed over, and over.

Quoted 3 lines

So, because you feel that phones should be little laptops you oppose providing (optional!) support for environments that take a different view to that?

Look. I'll share with you a little experience.

For years I've been working on a piece of software to access Microsoft's WLM IM service on linux. I have high quality standards for my software, so I optimized algorithms and bandwith, I used valgrind to find memory leaks, OProfile for performance bottlenecks, and so on. All this on a laptop.

When I ported this code to the N900 it just worked, not more-or-less; perfectly. I could stay online the whole day without the battery running out, and I didn't have to make *any* change.

Then at some point people started complaining about battery usage, but lo and behold, on the desktop people started reporting too much bandwith/cpu usage as well. I tried on my laptop, and was able to reproduce, and fix (bug related to daylight savings time).

For years people have been trying to unify certain KDE/GNOME code, and freedesktop.org was born. Now the same technologies are used by Nokia on Maemo, and now MeeGo (DBus, Telepathy, GStreamer, tracker, etc.), so the optimizations done for mobile benefit everyone; desktop power usage also improves.

So, yeah, I think the fact that my laptop and phone share the same software is great, and that improvements in one benefit the other.

Quoted 3 lines

I think that we're still a ways away from a world where we can treat mobile devices the same as laptops and get reasonable user experiences.

Why do you keep ignoring the N900? It has a lot of components that come directly from the linux ecosystem and people are having more than reasonable experiences (some are ecstatic).

Quoted 3 lines

I think it's unfortunate if the attitude here is "wait and someday it won't matter", especially because I'm skeptical that we're likely to hit that "someday" any time soon.

Nobody is waiting for anything. There's hard work all over the place to improve power usage.

If you think suspend blockers are useful for you, great, use them. I just don't see why they should be merged if nobody is going to use them but you. But maybe you are right, and maybe dynamic PM alone never reaches the same levers of performance, then people would ask for it to be merged, and it will. No biggie.

In the meantime, it would be wise to remember that this is not Nokia/Intel vs Google. Nokia has invested a great deal in dynamic PM, and those changes have benefited Android products directly (I even remember somebody from Google directly thanking Nokia for that), and that will continue. So we are on the same team.

And finally, if they don't get merged, I hope you don't see that as a loss. At the very least I think you got a lot of review comments from the most qualified experts in the world _free of charge_, and as a result the code should be more robust.

Cheers.

Signature · 1 line
Felipe Contreras
#735 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Brian Swetland

Hi Brian,

Quoted 17 lines · Brian Swetland
Quoted 9 lines · Felipe Contreras

Correct, but still a considerable amount of changes would need to be done, which _nobody_ has expressed any intention to do.

Besides, IMO a good mobile platform would share as much as possible with desktop software. Say, the improvements Nokia has endorsed on the Telepathy IM framework can only help the people already using it on the desktop.

Quoted 5 lines

However, personally, if I ever have to do './configure --enable-suspend-blockers', I would think that something that just doesn't belong has creped by to user-space. I don't see why there should something particularly different between mobile phones and laptops, and I think this has been already expressed over, and over.

Quoted 3 lines

So, because you feel that phones should be little laptops you oppose providing (optional!) support for environments that take a different view to that?

Look. I'll share with you a little experience.

For years I've been working on a piece of software to access Microsoft's WLM IM service on linux. I have high quality standards for my software, so I optimized algorithms and bandwith, I used valgrind to find memory leaks, OProfile for performance bottlenecks, and so on. All this on a laptop.

When I ported this code to the N900 it just worked, not more-or-less; perfectly. I could stay online the whole day without the battery running out, and I didn't have to make *any* change.

Then at some point people started complaining about battery usage, but lo and behold, on the desktop people started reporting too much bandwith/cpu usage as well. I tried on my laptop, and was able to reproduce, and fix (bug related to daylight savings time).

For years people have been trying to unify certain KDE/GNOME code, and freedesktop.org was born. Now the same technologies are used by Nokia on Maemo, and now MeeGo (DBus, Telepathy, GStreamer, tracker, etc.), so the optimizations done for mobile benefit everyone; desktop power usage also improves.

So, yeah, I think the fact that my laptop and phone share the same software is great, and that improvements in one benefit the other.

Quoted 3 lines

I think that we're still a ways away from a world where we can treat mobile devices the same as laptops and get reasonable user experiences.

Why do you keep ignoring the N900? It has a lot of components that come directly from the linux ecosystem and people are having more than reasonable experiences (some are ecstatic).

Quoted 3 lines

I think it's unfortunate if the attitude here is "wait and someday it won't matter", especially because I'm skeptical that we're likely to hit that "someday" any time soon.

Nobody is waiting for anything. There's hard work all over the place to improve power usage.

If you think suspend blockers are useful for you, great, use them. I just don't see why they should be merged if nobody is going to use them but you. But maybe you are right, and maybe dynamic PM alone never reaches the same levers of performance, then people would ask for it to be merged, and it will. No biggie.

In the meantime, it would be wise to remember that this is not Nokia/Intel vs Google. Nokia has invested a great deal in dynamic PM, and those changes have benefited Android products directly (I even remember somebody from Google directly thanking Nokia for that), and that will continue. So we are on the same team.

And finally, if they don't get merged, I hope you don't see that as a loss. At the very least I think you got a lot of review comments from the most qualified experts in the world _free of charge_, and as a result the code should be more robust.

Cheers.

Signature · 1 line
Felipe Contreras
#684 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 11 lines · Ted Ts'o
Quoted 5 lines · Felipe Contreras

All the Android community had to do is push the drivers *without* suspend blockers, then the Android kernel wouldn't be so different and thus wouldn't be considered a fork. AFAIU the kernel side wakelocks are already in the kernel, so there's no excuse not to merge the drivers.

What's there is not good enough, because it's missing the statistics and reporting so that badly behaved kernel and userspace drivers that take wakelocks can be found.

You don't need to have all the code merged in, hell, you only needed wakelock stubs.

You should take the point of view of the community as a whole, and forget about Android for a second; the important thing is to bring the code-bases closer, and that means merging the drivers. For that, you don't need anything extra.

Signature · 1 line
Felipe Contreras
#685 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 11 lines · Ted Ts'o
Quoted 5 lines · Felipe Contreras

All the Android community had to do is push the drivers *without* suspend blockers, then the Android kernel wouldn't be so different and thus wouldn't be considered a fork. AFAIU the kernel side wakelocks are already in the kernel, so there's no excuse not to merge the drivers.

What's there is not good enough, because it's missing the statistics and reporting so that badly behaved kernel and userspace drivers that take wakelocks can be found.

You don't need to have all the code merged in, hell, you only needed wakelock stubs.

You should take the point of view of the community as a whole, and forget about Android for a second; the important thing is to bring the code-bases closer, and that means merging the drivers. For that, you don't need anything extra.

Signature · 1 line
Felipe Contreras
#686 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 13 lines · Felipe Contreras
Quoted 11 lines · Ted Ts'o
Quoted 5 lines · Felipe Contreras

All the Android community had to do is push the drivers *without* suspend blockers, then the Android kernel wouldn't be so different and thus wouldn't be considered a fork. AFAIU the kernel side wakelocks are already in the kernel, so there's no excuse not to merge the drivers.

What's there is not good enough, because it's missing the statistics and reporting so that badly behaved kernel and userspace drivers that take wakelocks can be found.

Quoted 7 lines

You don't need to have all the code merged in, hell, you only needed wakelock stubs.

You should take the point of view of the community as a whole, and forget about Android for a second; the important thing is to bring the code-bases closer, and that means merging the drivers. For that, you don't need anything extra.

Stubs would be 100% fine by me. Previous discussion has indicated that they are not acceptable without some firm timeline for removal. I don't think I can commit to a firm removal timeline while we're still making almost no forward progress.

If we don't have to commit to yanking them back out in two releases or whatnot, then awesome, let's drop some stubs in and off we go, worrying about merging drivers that everyone agrees they want.

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of? Seems like a chicken and egg problem. Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

Brian

#687 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 13 lines · Felipe Contreras
Quoted 11 lines · Ted Ts'o
Quoted 5 lines · Felipe Contreras

All the Android community had to do is push the drivers *without* suspend blockers, then the Android kernel wouldn't be so different and thus wouldn't be considered a fork. AFAIU the kernel side wakelocks are already in the kernel, so there's no excuse not to merge the drivers.

What's there is not good enough, because it's missing the statistics and reporting so that badly behaved kernel and userspace drivers that take wakelocks can be found.

Quoted 7 lines

You don't need to have all the code merged in, hell, you only needed wakelock stubs.

You should take the point of view of the community as a whole, and forget about Android for a second; the important thing is to bring the code-bases closer, and that means merging the drivers. For that, you don't need anything extra.

Stubs would be 100% fine by me. Previous discussion has indicated that they are not acceptable without some firm timeline for removal. I don't think I can commit to a firm removal timeline while we're still making almost no forward progress.

If we don't have to commit to yanking them back out in two releases or whatnot, then awesome, let's drop some stubs in and off we go, worrying about merging drivers that everyone agrees they want.

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of? Seems like a chicken and egg problem. Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

Brian

#736 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras

Felipe,

Quoted 3 lines

If you think suspend blockers are useful for you, great, use them. I just don't see why they should be merged if nobody is going to use them but you.

Aren't there many drivers in the kernel sources which are only used by very few users? Android is used by million users, albeit on one platform, but I don't see this to be a valid reason to keep this functionality out of the kernel.

Best,
Dominik

#737 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras

Felipe,

Quoted 3 lines

If you think suspend blockers are useful for you, great, use them. I just don't see why they should be merged if nobody is going to use them but you.

Aren't there many drivers in the kernel sources which are only used by very few users? Android is used by million users, albeit on one platform, but I don't see this to be a valid reason to keep this functionality out of the kernel.

Best,
Dominik

#740 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 5 lines · Paul E. McKenney
Quoted 2 lines · Felipe Contreras

So far, nobody has refuted these:
 1) opportunistic suspend needs a good behaved user-space to work properly

As does dynamic power management.

Thus remains unrefuted.

Quoted 5 lines
Quoted 2 lines

 2) if suspend blockers are enabled in a system, *all* user-space must implement them to work correctly

Really?  From what I can see, only PM-driving applications need to use suspend blockers.

"PM-driving applications" is a new invention, so how do you know if an application belongs to this category or not? Some application might be non-PM-driving most of the time, but suddenly become PM-driving. Well, you have to analyze *all* of them.

Think about this... is bash a PM driving application? No, but what if you run: 'sleep 3600 && alarm.sh'.

Perhaps I should rewrite that as:
2) if suspend blockers are enabled in the system; *all* user-space is affected

Quoted 4 lines
Quoted 1 line

 3) implementing suspend blockers in user-space is not a straight-forward task

Fortunately, experience thus far has shown that only a small fraction of applications need to use suspend blockers.

Wrong. We don't have any experience on that at all on typical linux ecosystems (remember that Android's user-space is very special).

Quoted 8 lines
Quoted 5 lines

So, as the length of this thread has shown, the benefits of opportunistic suspend are *dubious* at best, and more likely not worth the changes needed in user-space which eventually will get pretty close to what suspend blockers can achieve even in ideal circumstances by just doing dynamic PM.

The length of this thread (and the ones preceding it) is mostly due to people talking past each other.

Perhaps half of the thread, or even one quarter of the thread can be attributed to that, but still the rest I think it's because people keep pushing in, and people keep pushing out.

Quoted 10 lines

For example, the Android folks seem to
believe that it is important that relatively unskilled people be able to write simple apps, and that the system nevertheless be able to run these apps in a relatively energy efficient manner.  Your proposals do not address this issue.  This might be because you are not aware of this desire, because you are not aware of the computing history that argues in favor of this requirement, or because you simply don't like this requirement.  Whatever the reason, until you face this requirement head on, either addressing it or proving that it need not be addressed, you will continue to be talking past the Android folks.

This "requirement" is specific to Android's user-space, isn't it?

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#741 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 5 lines · Paul E. McKenney
Quoted 2 lines · Felipe Contreras

So far, nobody has refuted these:
 1) opportunistic suspend needs a good behaved user-space to work properly

As does dynamic power management.

Thus remains unrefuted.

Quoted 5 lines
Quoted 2 lines

 2) if suspend blockers are enabled in a system, *all* user-space must implement them to work correctly

Really?  From what I can see, only PM-driving applications need to use suspend blockers.

"PM-driving applications" is a new invention, so how do you know if an application belongs to this category or not? Some application might be non-PM-driving most of the time, but suddenly become PM-driving. Well, you have to analyze *all* of them.

Think about this... is bash a PM driving application? No, but what if you run: 'sleep 3600 && alarm.sh'.

Perhaps I should rewrite that as:
2) if suspend blockers are enabled in the system; *all* user-space is affected

Quoted 4 lines
Quoted 1 line

 3) implementing suspend blockers in user-space is not a straight-forward task

Fortunately, experience thus far has shown that only a small fraction of applications need to use suspend blockers.

Wrong. We don't have any experience on that at all on typical linux ecosystems (remember that Android's user-space is very special).

Quoted 8 lines
Quoted 5 lines

So, as the length of this thread has shown, the benefits of opportunistic suspend are *dubious* at best, and more likely not worth the changes needed in user-space which eventually will get pretty close to what suspend blockers can achieve even in ideal circumstances by just doing dynamic PM.

The length of this thread (and the ones preceding it) is mostly due to people talking past each other.

Perhaps half of the thread, or even one quarter of the thread can be attributed to that, but still the rest I think it's because people keep pushing in, and people keep pushing out.

Quoted 10 lines

For example, the Android folks seem to
believe that it is important that relatively unskilled people be able to write simple apps, and that the system nevertheless be able to run these apps in a relatively energy efficient manner.  Your proposals do not address this issue.  This might be because you are not aware of this desire, because you are not aware of the computing history that argues in favor of this requirement, or because you simply don't like this requirement.  Whatever the reason, until you face this requirement head on, either addressing it or proving that it need not be addressed, you will continue to be talking past the Android folks.

This "requirement" is specific to Android's user-space, isn't it?

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

Signature · 1 line
Felipe Contreras
#742 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 8 lines · Felipe Contreras

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

I'm curious, when does Android count as a user of the kernel? I gather that volume of sales or users doesn't count. Do we have to include some percentage of "desktop" Linux?

If we're an undesirable second-class citizen, why do people care that "android is forking the kernel"?

I guess I don't understand,

Brian

#743 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 8 lines · Felipe Contreras

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

I'm curious, when does Android count as a user of the kernel? I gather that volume of sales or users doesn't count. Do we have to include some percentage of "desktop" Linux?

If we're an undesirable second-class citizen, why do people care that "android is forking the kernel"?

I guess I don't understand,

Brian

#744 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 11 lines · Brian Swetland
Quoted 8 lines · Felipe Contreras

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

Quoted 8 lines

I'm curious, when does Android count as a user of the kernel? I gather that volume of sales or users doesn't count. Do we have to include some percentage of "desktop" Linux?

If we're an undesirable second-class citizen, why do people care that "android is forking the kernel"?

I guess I don't understand,

I guess I don't, either -- there are some parts of the kernel used by only a handful of users... and here we speak about million users...

Best,
Dominik

#745 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

In reply to Brian Swetland
Quoted 11 lines · Brian Swetland
Quoted 8 lines · Felipe Contreras

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

Quoted 8 lines

I'm curious, when does Android count as a user of the kernel? I gather that volume of sales or users doesn't count. Do we have to include some percentage of "desktop" Linux?

If we're an undesirable second-class citizen, why do people care that "android is forking the kernel"?

I guess I don't understand,

I guess I don't, either -- there are some parts of the kernel used by only a handful of users... and here we speak about million users...

Best,
Dominik

#688 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Brian Swetland
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of? Seems like a chicken and egg problem. Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions. We've merged code one release or more before the new code gets used for example, which is fine IMO. What we don't want to see is some new drop of code added and abandoned, but you already knew that.

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape. Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable. So where's the git pull request already? :)

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#689 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Brian Swetland
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of? Seems like a chicken and egg problem. Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions. We've merged code one release or more before the new code gets used for example, which is fine IMO. What we don't want to see is some new drop of code added and abandoned, but you already knew that.

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape. Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable. So where's the git pull request already? :)

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#690 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 15 lines · Jesse Barnes
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of? Seems like a chicken and egg problem. Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions. We've merged code one release or more before the new code gets used for example, which is fine IMO. What we don't want to see is some new drop of code added and abandoned, but you already knew that.

Quoted 6 lines

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape. Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable. So where's the git pull request already? :)

In fact my patch going in that direction has been merged already and that code will likely be extended to cover some needs and cases I didn't have in mind when I was preparing it.

However, having discussed the whole issue for many times and reconsidered it thoroughly, I think that it's inappropriate to identify the suspend blockers (or wakelocks) framework with the opportunistic suspend feature as proposed in the original submission of the "suspend blockers" patchset. IMO they really are not the same thing and while the suspend blockers framework is used by Android to implement opportunistic suspend, I don't really believe this is the right approach.

We really need something similar to suspend blockers to avoid races between a suspend process and wakeup events, but it isn't necessary to provide user space with an interface allowing it to use these things directly. Such an interface is only necessary in the specific implementation in which the system is suspended as soon as the number of "active" suspend blockers goes down to zero. Arguably, though, this isn't the only possible way to implement a mechanism allowing the system to be suspended automatically when it appears to be inactive.

Namely, one can use a user space power manager for this purpose and actually the OLPC project has been doing that successfully for some time, which clearly demonstrates that the Android approach to this problem is not the only one possible. Moreover, the kernel's system suspend (or hibernate for that matter) code has not been designed to be started from within the kernel. It's been designed to allow a privileged user space process to request the kernel to put the system into a sleep state at any given time regardless of what the other user space processes are doing. While it can be started from within the kernel, this isn't particularly nice and, in the Android case, starting it from within the kernel requires permission from multiple user space processes (given by not taking suspend blockers these processes are allowed to use).

Since, quite clearly, user space input is necessary to make the decision whether or not to suspend the system, I think it is more appropriate to allow user space to start the entire operation and provide the kernel with a means to abort it in the case of a wakeup event. Then, user space will be able to use arbitrary heuristics in deciding whether or not to suspend the system, possibly taking some kernel's input into account.

I'm not against the very idea of automatic system suspend, which IMO is a legitimate and reasonable thing to do in many usage scenarios, but I don't think that the kernel is the right place to start a suspend process. For this reason I'm not going to take any code trying to start a suspend process from within the kernel, regardless of that code's purpose, unless somebody makes a really convincing case for that to me (basically proving the need for such a solution). That said I'm willing to accept patches adding or improving code that will help us to avoid races between system suspend, initiated by user space, and wakeup events detected by the kernel.

I hope that makes things clear.

Thanks,
Rafael

#691 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Jesse Barnes
Quoted 15 lines · Jesse Barnes
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of? Seems like a chicken and egg problem. Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions. We've merged code one release or more before the new code gets used for example, which is fine IMO. What we don't want to see is some new drop of code added and abandoned, but you already knew that.

Quoted 6 lines

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape. Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable. So where's the git pull request already? :)

In fact my patch going in that direction has been merged already and that code will likely be extended to cover some needs and cases I didn't have in mind when I was preparing it.

However, having discussed the whole issue for many times and reconsidered it thoroughly, I think that it's inappropriate to identify the suspend blockers (or wakelocks) framework with the opportunistic suspend feature as proposed in the original submission of the "suspend blockers" patchset. IMO they really are not the same thing and while the suspend blockers framework is used by Android to implement opportunistic suspend, I don't really believe this is the right approach.

We really need something similar to suspend blockers to avoid races between a suspend process and wakeup events, but it isn't necessary to provide user space with an interface allowing it to use these things directly. Such an interface is only necessary in the specific implementation in which the system is suspended as soon as the number of "active" suspend blockers goes down to zero. Arguably, though, this isn't the only possible way to implement a mechanism allowing the system to be suspended automatically when it appears to be inactive.

Namely, one can use a user space power manager for this purpose and actually the OLPC project has been doing that successfully for some time, which clearly demonstrates that the Android approach to this problem is not the only one possible. Moreover, the kernel's system suspend (or hibernate for that matter) code has not been designed to be started from within the kernel. It's been designed to allow a privileged user space process to request the kernel to put the system into a sleep state at any given time regardless of what the other user space processes are doing. While it can be started from within the kernel, this isn't particularly nice and, in the Android case, starting it from within the kernel requires permission from multiple user space processes (given by not taking suspend blockers these processes are allowed to use).

Since, quite clearly, user space input is necessary to make the decision whether or not to suspend the system, I think it is more appropriate to allow user space to start the entire operation and provide the kernel with a means to abort it in the case of a wakeup event. Then, user space will be able to use arbitrary heuristics in deciding whether or not to suspend the system, possibly taking some kernel's input into account.

I'm not against the very idea of automatic system suspend, which IMO is a legitimate and reasonable thing to do in many usage scenarios, but I don't think that the kernel is the right place to start a suspend process. For this reason I'm not going to take any code trying to start a suspend process from within the kernel, regardless of that code's purpose, unless somebody makes a really convincing case for that to me (basically proving the need for such a solution). That said I'm willing to accept patches adding or improving code that will help us to avoid races between system suspend, initiated by user space, and wakeup events detected by the kernel.

I hope that makes things clear.

Thanks,
Rafael

#692 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

Quoted 44 lines · rafael j. wysocki
Quoted 15 lines · Jesse Barnes
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of? Seems like a chicken and egg problem. Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions. We've merged code one release or more before the new code gets used for example, which is fine IMO. What we don't want to see is some new drop of code added and abandoned, but you already knew that.

Quoted 6 lines

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape. Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable. So where's the git pull request already? :)

In fact my patch going in that direction has been merged already and that code will likely be extended to cover some needs and cases I didn't have in mind when I was preparing it.

However, having discussed the whole issue for many times and reconsidered it thoroughly, I think that it's inappropriate to identify the suspend blockers (or wakelocks) framework with the opportunistic suspend feature as proposed in the original submission of the "suspend blockers" patchset. IMO they really are not the same thing and while the suspend blockers framework is used by Android to implement opportunistic suspend, I don't really believe this is the right approach.

We really need something similar to suspend blockers to avoid races between a suspend process and wakeup events, but it isn't necessary to provide user space with an interface allowing it to use these things directly. Such an interface is only necessary in the specific implementation in which the system is suspended as soon as the number of "active" suspend blockers goes down to zero. Arguably, though, this isn't the only possible way to implement a mechanism allowing the system to be suspended automatically when it appears to be inactive.

Quoted 3 lines

Namely, one can use a user space power manager for this purpose and actually the OLPC project has been doing that successfully for some time, which clearly demonstrates that the Android approach to this problem is not the only one

hey! how did we get dragged into this? :-)

it's true that OLPC has a user-level power management daemon that implements our suspend policy. it uses various metrics and heuristics (i've been told that's latin for "hacks") to decide when the system is "idle enough" to suspend, along with whether to leave our independent display running or not, and whether to leave the wlan active, etc. it does a reasonable job for us for now, but being intimately familiar with the chewing gum and string that hold it together, i don't want anyone to think we've solved a Big Problem.

i do think that there's a place for a flexible user-level policy engine, no matter how the suspend blockers vs. whatever-else issue plays out. i guess i assumed that that was a given -- does android not have such a policy manager? surely there's more to it than just "last one out, turn out the lights"?

(i should also mention that we definitely see the suspend vs. wakeup events race issue, and are looking forward to ways to clean that up.)

paul

Quoted 26 lines

possible. Moreover, the kernel's system suspend (or hibernate for that matter) code has not been designed to be started from within the kernel. It's been designed to allow a privileged user space process to request the kernel to put the system into a sleep state at any given time regardless of what the other user space processes are doing. While it can be started from within the kernel, this isn't particularly nice and, in the Android case, starting it from within the kernel requires permission from multiple user space processes (given by not taking suspend blockers these processes are allowed to use).

Since, quite clearly, user space input is necessary to make the decision whether or not to suspend the system, I think it is more appropriate to allow user space to start the entire operation and provide the kernel with a means to abort it in the case of a wakeup event. Then, user space will be able to use arbitrary heuristics in deciding whether or not to suspend the system, possibly taking some kernel's input into account.

I'm not against the very idea of automatic system suspend, which IMO is a legitimate and reasonable thing to do in many usage scenarios, but I don't think that the kernel is the right place to start a suspend process. For this reason I'm not going to take any code trying to start a suspend process from within the kernel, regardless of that code's purpose, unless somebody makes a really convincing case for that to me (basically proving the need for such a solution). That said I'm willing to accept patches adding or improving code that will help us to avoid races between system suspend, initiated by user space, and wakeup events detected by the kernel.

Quoted 8 lines

I hope that makes things clear.

Thanks,
Rafael
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm

=---------------------
paul fox, [email protected]

#693 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Rafael J. Wysocki
Quoted 27 lines · Rafael J. Wysocki
Quoted 15 lines · Jesse Barnes
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of?  Seems like a chicken and egg problem.  Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions.  We've merged code one release or more before the new code gets used for example, which is fine IMO.  What we don't want to see is some new drop of code added and abandoned, but you already knew that.

Quoted 6 lines

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape.  Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable.  So where's the git pull request already? :)

In fact my patch going in that direction has been merged already and that code will likely be extended to cover some needs and cases I didn't have in mind when I was preparing it.

Quoted 8 lines

However, having discussed the whole issue for many times and reconsidered it thoroughly, I think that it's inappropriate to identify the suspend blockers (or wakelocks) framework with the opportunistic suspend feature as proposed in the original submission of the "suspend blockers" patchset.  IMO they really are not the same thing and while the suspend blockers framework is used by Android to implement opportunistic suspend, I don't really believe this is the right approach.

Can you clarify this? Do you not believe using opportunistic suspend is the right approach, or do you not believe linking suspend blockers with opportunistic suspend is the right approach?

Quoted 6 lines

We really need something similar to suspend blockers to avoid races between a suspend process and wakeup events, but it isn't necessary to provide user space with an interface allowing it to use these things directly.  Such an interface is only necessary in the specific implementation in which the system is suspended as soon as the number of "active" suspend blockers goes down to zero.

I don't think what you are saying here is correct. When you decide to suspend has no impact on whether a user space interface to block suspend is needed. The last suspend blocker patchset had this interface as a separate patch and the reasons for providing it have not changed with your interface. Android need the user space interface because low level services that handle wakeup events are started before the user space power manager. The other reason to have this interface in the mainline kernel is to provide a safe way to handle wakeup events on linux regardless of which user space power manager is used on the system. For instance some devices have a user space battery monitor, and there would be no need for this code to be android specific if the kernel provided all the functionality it needs.

Quoted 4 lines

 Arguably, though, this isn't the only possible way to implement a mechanism allowing the system to be suspended automatically when it appears to be inactive.

Quoted 12 lines

Namely, one can use a user space power manager for this purpose and actually the OLPC project has been doing that successfully for some time, which clearly demonstrates that the Android approach to this problem is not the only one possible.  Moreover, the kernel's system suspend (or hibernate for that matter) code has not been designed to be started from within the kernel.  It's been designed to allow a privileged user space process to request the kernel to put the system into a sleep state at any given time regardless of what the other user space processes are doing.  While it can be started from within the kernel, this isn't particularly nice and, in the Android case, starting it from within the kernel requires permission from multiple user space processes (given by not taking suspend blockers these processes are allowed to use).

Why is starting suspend from within the kernel not nice? Personally I think reentering suspend from within the kernel is nicer than being forced to wake up a user space thread for events that are fully handled within the kernel (for instance the battery monitor on the Nexus One).

Quoted 7 lines

Since, quite clearly, user space input is necessary to make the decision whether or not to suspend the system, I think it is more appropriate to allow user space to start the entire operation and provide the kernel with a means to abort it in the case of a wakeup event.  Then, user space will be able to use arbitrary heuristics in deciding whether or not to suspend the system, possibly taking some kernel's input into account.

When we don't need these heuristics, this is just a burden.

Quoted 7 lines

I'm not against the very idea of automatic system suspend, which IMO is a legitimate and reasonable thing to do in many usage scenarios, but I don't think that the kernel is the right place to start a suspend process.  For this reason I'm not going to take any code trying to start a suspend process from within the kernel, regardless of that code's purpose, unless somebody makes a really convincing case for that to me (basically proving the need for such a solution).

There is no absolute need to start the suspend process from within the kernel, but it makes the user space code much simpler for what we need.

Quoted 14 lines

 That said I'm willing to accept patches adding or improving code that will help us to avoid races between system suspend, initiated by user space, and wakeup events detected by the kernel.

I hope that makes things clear.

Thanks,
Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Signature · 1 line
Arve Hjønnevåg
#694 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Rafael J. Wysocki
Quoted 27 lines · Rafael J. Wysocki
Quoted 15 lines · Jesse Barnes
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of?  Seems like a chicken and egg problem.  Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions.  We've merged code one release or more before the new code gets used for example, which is fine IMO.  What we don't want to see is some new drop of code added and abandoned, but you already knew that.

Quoted 6 lines

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape.  Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable.  So where's the git pull request already? :)

In fact my patch going in that direction has been merged already and that code will likely be extended to cover some needs and cases I didn't have in mind when I was preparing it.

Quoted 8 lines

However, having discussed the whole issue for many times and reconsidered it thoroughly, I think that it's inappropriate to identify the suspend blockers (or wakelocks) framework with the opportunistic suspend feature as proposed in the original submission of the "suspend blockers" patchset.  IMO they really are not the same thing and while the suspend blockers framework is used by Android to implement opportunistic suspend, I don't really believe this is the right approach.

Can you clarify this? Do you not believe using opportunistic suspend is the right approach, or do you not believe linking suspend blockers with opportunistic suspend is the right approach?

Quoted 6 lines

We really need something similar to suspend blockers to avoid races between a suspend process and wakeup events, but it isn't necessary to provide user space with an interface allowing it to use these things directly.  Such an interface is only necessary in the specific implementation in which the system is suspended as soon as the number of "active" suspend blockers goes down to zero.

I don't think what you are saying here is correct. When you decide to suspend has no impact on whether a user space interface to block suspend is needed. The last suspend blocker patchset had this interface as a separate patch and the reasons for providing it have not changed with your interface. Android need the user space interface because low level services that handle wakeup events are started before the user space power manager. The other reason to have this interface in the mainline kernel is to provide a safe way to handle wakeup events on linux regardless of which user space power manager is used on the system. For instance some devices have a user space battery monitor, and there would be no need for this code to be android specific if the kernel provided all the functionality it needs.

Quoted 4 lines

 Arguably, though, this isn't the only possible way to implement a mechanism allowing the system to be suspended automatically when it appears to be inactive.

Quoted 12 lines

Namely, one can use a user space power manager for this purpose and actually the OLPC project has been doing that successfully for some time, which clearly demonstrates that the Android approach to this problem is not the only one possible.  Moreover, the kernel's system suspend (or hibernate for that matter) code has not been designed to be started from within the kernel.  It's been designed to allow a privileged user space process to request the kernel to put the system into a sleep state at any given time regardless of what the other user space processes are doing.  While it can be started from within the kernel, this isn't particularly nice and, in the Android case, starting it from within the kernel requires permission from multiple user space processes (given by not taking suspend blockers these processes are allowed to use).

Why is starting suspend from within the kernel not nice? Personally I think reentering suspend from within the kernel is nicer than being forced to wake up a user space thread for events that are fully handled within the kernel (for instance the battery monitor on the Nexus One).

Quoted 7 lines

Since, quite clearly, user space input is necessary to make the decision whether or not to suspend the system, I think it is more appropriate to allow user space to start the entire operation and provide the kernel with a means to abort it in the case of a wakeup event.  Then, user space will be able to use arbitrary heuristics in deciding whether or not to suspend the system, possibly taking some kernel's input into account.

When we don't need these heuristics, this is just a burden.

Quoted 7 lines

I'm not against the very idea of automatic system suspend, which IMO is a legitimate and reasonable thing to do in many usage scenarios, but I don't think that the kernel is the right place to start a suspend process.  For this reason I'm not going to take any code trying to start a suspend process from within the kernel, regardless of that code's purpose, unless somebody makes a really convincing case for that to me (basically proving the need for such a solution).

There is no absolute need to start the suspend process from within the kernel, but it makes the user space code much simpler for what we need.

Quoted 14 lines

 That said I'm willing to accept patches adding or improving code that will help us to avoid races between system suspend, initiated by user space, and wakeup events detected by the kernel.

I hope that makes things clear.

Thanks,
Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Signature · 1 line
Arve Hjønnevåg
#746 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

In reply to Dominik Brodowski
Quoted 2 lines

I guess I don't, either -- there are some parts of the kernel used by only a handful of users... and here we speak about million users...

Because in general the bits for a small user base don't leak out into other bits of the kernel. It's a much higher barrier if you want to affect other people's code because it is asking everyone else to help maintain stuff they don't need.

That's not to say sometimes its not the right choice, but I still find it remarkable that nobody else but Android seems to want it,. Alan

#749 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Brian Swetland
Quoted 1 line

Why do people care that "android is forking the kernel"?

A lot of us don't. That's what the GPL is about. It's a big pain if you start splitting it off into two entire things long term - because your maintenance grows harder exponentially but parallel forks are common
- SuSE and RHEL Enterprise type editions are forks for example.

As far as I can tell it all comes from one or two people with a big PR presence and almost no code in the kernel saying silly things years ago which the IT press see as a good way to create a 'we need a column, bash someone' story.

"What the junk press think" is a common but broken way to run national policy in some countries, and its just as broken for the kernel.

Alan

#710 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 4 lines

I have a similar problem with the whole pm_qos subsystem, as I've said earlier. If some badly behaved application claims to want 0us wireless latency, and keeps the radio on all the time, there is no way for me to find out which is the badly behaved application --- even

Well firstly you want limits so SELinux says "No" (or rlimit or similar) and secondly you want sysfs views.

This is like file permissions - its not hard

#747 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Dominik Brodowski
Quoted 5 lines · Dominik Brodowski
Quoted 1 line · Brian Swetland

I guess I don't understand,

I guess I don't, either -- there are some parts of the kernel used by only a handful of users... and here we speak about million users...

A driver that sits in a corner and doesn't show in the 'menuconfig' of most people and is used by small fraction of user-space applications (perhaps even 0) is just fine. But we are talking of something centric, that can be enabled on all systems, and that affects all user-space.

Signature · 1 line
Felipe Contreras
#748 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

In reply to Dominik Brodowski
Quoted 5 lines · Dominik Brodowski
Quoted 1 line · Brian Swetland

I guess I don't understand,

I guess I don't, either -- there are some parts of the kernel used by only a handful of users... and here we speak about million users...

A driver that sits in a corner and doesn't show in the 'menuconfig' of most people and is used by small fraction of user-space applications (perhaps even 0) is just fine. But we are talking of something centric, that can be enabled on all systems, and that affects all user-space.

Signature · 1 line
Felipe Contreras
#780 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 4 lines
Quoted 2 lines

Think in terms of an ARM laptop. What good is opportunistic suspend if it's not going to help when the laptop is being used?

For when the laptop is not being used, presumably.

Or in time between keystrokes for most of the platform (backlight excepted). The Intel MID x86 devices are at the point that suspend/resume time on x86 is being hurt by the kernel rewriting smp alternatives as we go from 2 processors live to 1 and back.

Alan

#750 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Brian Swetland
Quoted 11 lines · Brian Swetland
Quoted 8 lines · Felipe Contreras

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

Quoted 3 lines

I'm curious, when does Android count as a user of the kernel?  I gather that volume of sales or users doesn't count.  Do we have to include some percentage of "desktop" Linux?

You are *one* user of the kernel. Let's suppose Android wasn't using suspend-blockers, and there was another equally successful linux mobile platform, Foobingo, and they were using them, and they were the only ones interested on implementing them.

What does that change? Nothing. They still need to convince the community that what they are proposing to be merged is actually useful, and somebody will use it. If not, they can just keep the patch for themselves until they do. I don't see the big deal.

Quoted 2 lines

If we're an undesirable second-class citizen, why do people care that "android is forking the kernel"?

Nobody has expressed anything remotely like that (that you are a second-class citizen). Why makes you think so? Lots of people get patches denied. Like Nokia's u_char driver, which is *way* less controversial than this one.

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#751 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Brian Swetland
Quoted 11 lines · Brian Swetland
Quoted 8 lines · Felipe Contreras

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

Quoted 3 lines

I'm curious, when does Android count as a user of the kernel?  I gather that volume of sales or users doesn't count.  Do we have to include some percentage of "desktop" Linux?

You are *one* user of the kernel. Let's suppose Android wasn't using suspend-blockers, and there was another equally successful linux mobile platform, Foobingo, and they were using them, and they were the only ones interested on implementing them.

What does that change? Nothing. They still need to convince the community that what they are proposing to be merged is actually useful, and somebody will use it. If not, they can just keep the patch for themselves until they do. I don't see the big deal.

Quoted 2 lines

If we're an undesirable second-class citizen, why do people care that "android is forking the kernel"?

Nobody has expressed anything remotely like that (that you are a second-class citizen). Why makes you think so? Lots of people get patches denied. Like Nokia's u_char driver, which is *way* less controversial than this one.

Signature · 1 line
Felipe Contreras
#707 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Jesse Barnes
Quoted 9 lines · Jesse Barnes
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of?  Seems like a chicken and egg problem.  Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

Quoted 5 lines

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions.  We've merged code one release or more before the new code gets used for example, which is fine IMO.  What we don't want to see is some new drop of code added and abandoned, but you already knew that.

If Android guys provided a bare minimal Debian system with suspend blockers that people can take a look at and try, I think that would be a good proof of concept. And a bare minimum to get the patches merged.

Quoted 6 lines

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape.  Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable.  So where's the git pull request already? :)

I certainly have been the more vocal recently, but if that's confusing you, I can shut up and let others do the argumentation. I remember at least Alan Cox, Alan Stern, Thomas Gleixner, Kevin Hilman, Felipe Balbi, Tony Lindgren, and Igor Stopa against them.

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#708 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Jesse Barnes
Quoted 9 lines · Jesse Barnes
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of?  Seems like a chicken and egg problem.  Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

Quoted 5 lines

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions.  We've merged code one release or more before the new code gets used for example, which is fine IMO.  What we don't want to see is some new drop of code added and abandoned, but you already knew that.

If Android guys provided a bare minimal Debian system with suspend blockers that people can take a look at and try, I think that would be a good proof of concept. And a bare minimum to get the patches merged.

Quoted 6 lines

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape.  Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable.  So where's the git pull request already? :)

I certainly have been the more vocal recently, but if that's confusing you, I can shut up and let others do the argumentation. I remember at least Alan Cox, Alan Stern, Thomas Gleixner, Kevin Hilman, Felipe Balbi, Tony Lindgren, and Igor Stopa against them.

Signature · 1 line
Felipe Contreras
#752 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 21 lines · Felipe Contreras
Quoted 11 lines · Brian Swetland
Quoted 8 lines · Felipe Contreras

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

Quoted 3 lines

I'm curious, when does Android count as a user of the kernel?  I gather that volume of sales or users doesn't count.  Do we have to include some percentage of "desktop" Linux?

You are *one* user of the kernel. Let's suppose Android wasn't using suspend-blockers, and there was another equally successful linux mobile platform, Foobingo, and they were using them, and they were the only ones interested on implementing them.

Quoted 4 lines

What does that change? Nothing. They still need to convince the community that what they are proposing to be merged is actually useful, and somebody will use it. If not, they can just keep the patch for themselves until they do. I don't see the big deal.

So the current users of the Linux kernel are the following?

o GNU/Linux
o Android

Do any other distributions or devices with unusual user-space layouts qualify?

Thanx, Paul

Quoted 10 lines
Quoted 2 lines

If we're an undesirable second-class citizen, why do people care that "android is forking the kernel"?

Nobody has expressed anything remotely like that (that you are a second-class citizen). Why makes you think so? Lots of people get patches denied. Like Nokia's u_char driver, which is *way* less controversial than this one.

Signature · 1 line
Felipe Contreras
#753 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 21 lines · Felipe Contreras
Quoted 11 lines · Brian Swetland
Quoted 8 lines · Felipe Contreras

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

Quoted 3 lines

I'm curious, when does Android count as a user of the kernel?  I gather that volume of sales or users doesn't count.  Do we have to include some percentage of "desktop" Linux?

You are *one* user of the kernel. Let's suppose Android wasn't using suspend-blockers, and there was another equally successful linux mobile platform, Foobingo, and they were using them, and they were the only ones interested on implementing them.

Quoted 4 lines

What does that change? Nothing. They still need to convince the community that what they are proposing to be merged is actually useful, and somebody will use it. If not, they can just keep the patch for themselves until they do. I don't see the big deal.

So the current users of the Linux kernel are the following?

o GNU/Linux
o Android

Do any other distributions or devices with unusual user-space layouts qualify?

Thanx, Paul

Quoted 10 lines
Quoted 2 lines

If we're an undesirable second-class citizen, why do people care that "android is forking the kernel"?

Nobody has expressed anything remotely like that (that you are a second-class citizen). Why makes you think so? Lots of people get patches denied. Like Nokia's u_char driver, which is *way* less controversial than this one.

Signature · 1 line
Felipe Contreras
#695 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Arve Hjønnevåg
Quoted 37 lines · Arve Hjønnevåg
Quoted 27 lines · Rafael J. Wysocki
Quoted 15 lines · Jesse Barnes
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of? Seems like a chicken and egg problem. Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions. We've merged code one release or more before the new code gets used for example, which is fine IMO. What we don't want to see is some new drop of code added and abandoned, but you already knew that.

Quoted 6 lines

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape. Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable. So where's the git pull request already? :)

In fact my patch going in that direction has been merged already and that code will likely be extended to cover some needs and cases I didn't have in mind when I was preparing it.

Quoted 8 lines

However, having discussed the whole issue for many times and reconsidered it thoroughly, I think that it's inappropriate to identify the suspend blockers (or wakelocks) framework with the opportunistic suspend feature as proposed in the original submission of the "suspend blockers" patchset. IMO they really are not the same thing and while the suspend blockers framework is used by Android to implement opportunistic suspend, I don't really believe this is the right approach.

Quoted 3 lines

Can you clarify this? Do you not believe using opportunistic suspend is the right approach, or do you not believe linking suspend blockers with opportunistic suspend is the right approach?

The latter. That should be clear from the remaining part of my message.

Quoted 7 lines
Quoted 6 lines

We really need something similar to suspend blockers to avoid races between a suspend process and wakeup events, but it isn't necessary to provide user space with an interface allowing it to use these things directly. Such an interface is only necessary in the specific implementation in which the system is suspended as soon as the number of "active" suspend blockers goes down to zero.

Quoted 13 lines

I don't think what you are saying here is correct. When you decide to suspend has no impact on whether a user space interface to block suspend is needed. The last suspend blocker patchset had this interface as a separate patch and the reasons for providing it have not changed with your interface. Android need the user space interface because low level services that handle wakeup events are started before the user space power manager. The other reason to have this interface in the mainline kernel is to provide a safe way to handle wakeup events on linux regardless of which user space power manager is used on the system. For instance some devices have a user space battery monitor, and there would be no need for this code to be android specific if the kernel provided all the functionality it needs.

Well, the problem is, with your /dev/suspend_blocker interface, multiple user space processes are supposed to decide whether or not system suspend should be started and in general there don't seem to be any particularly good criteria for choosing these applications, in general. So, application writers may be tempted to use this interface in all programs and then the decision whether or not to allow these programs to affect system power management will be delegated to users. In turn, the users may not be technically qualified to make such a decision.

Also the fact that the same mechanism is used for handling wakeup events detected by the kernel and allowing user space programs to grant permission to suspend the system is somewhat confusing.

Quoted 17 lines
Quoted 4 lines

Arguably, though, this isn't the only possible way to implement a
mechanism allowing the system to be suspended automatically when it appears to be inactive.

Quoted 12 lines

Namely, one can use a user space power manager for this purpose and actually the OLPC project has been doing that successfully for some time, which clearly demonstrates that the Android approach to this problem is not the only one possible. Moreover, the kernel's system suspend (or hibernate for that matter) code has not been designed to be started from within the kernel. It's been designed to allow a privileged user space process to request the kernel to put the system into a sleep state at any given time regardless of what the other user space processes are doing. While it can be started from within the kernel, this isn't particularly nice and, in the Android case, starting it from within the kernel requires permission from multiple user space processes (given by not taking suspend blockers these processes are allowed to use).

Quoted 5 lines

Why is starting suspend from within the kernel not nice? Personally I think reentering suspend from within the kernel is nicer than being forced to wake up a user space thread for events that are fully handled within the kernel (for instance the battery monitor on the Nexus One).

For basically the same reason why the kernel generally doesn't use sys_open() for opening files. It is an interface provided for user space.

Quoted 8 lines
Quoted 7 lines

Since, quite clearly, user space input is necessary to make the decision whether or not to suspend the system, I think it is more appropriate to allow user space to start the entire operation and provide the kernel with a means to abort it in the case of a wakeup event. Then, user space will be able to use arbitrary heuristics in deciding whether or not to suspend the system, possibly taking some kernel's input into account.

When we don't need these heuristics, this is just a burden.

The word 'arbitrary' means in particular that you can implement a mechanism equivalent to the /dev/suspend_blocker entirely in user space. Someone else, though, can use a different approach.

By adding the /dev/suspend_blocker interface to the mainline kernel we would mandate that Linux applications use it on all platforms. Consequently, application writers would have the right to expect that all platforms would be using Android-alike opportunistic suspend, which may or may not be the case.

Quoted 11 lines
Quoted 7 lines

I'm not against the very idea of automatic system suspend, which IMO is a legitimate and reasonable thing to do in many usage scenarios, but I don't think that the kernel is the right place to start a suspend process. For this reason I'm not going to take any code trying to start a suspend process from within the kernel, regardless of that code's purpose, unless somebody makes a really convincing case for that to me (basically proving the need for such a solution).

There is no absolute need to start the suspend process from within the kernel, but it makes the user space code much simpler for what we need.

I'm entirely aware of that. Still, I think user space is the right place to initiate system suspend.

Thanks,
Rafael

#696 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Arve Hjønnevåg
Quoted 37 lines · Arve Hjønnevåg
Quoted 27 lines · Rafael J. Wysocki
Quoted 15 lines · Jesse Barnes
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of? Seems like a chicken and egg problem. Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions. We've merged code one release or more before the new code gets used for example, which is fine IMO. What we don't want to see is some new drop of code added and abandoned, but you already knew that.

Quoted 6 lines

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape. Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable. So where's the git pull request already? :)

In fact my patch going in that direction has been merged already and that code will likely be extended to cover some needs and cases I didn't have in mind when I was preparing it.

Quoted 8 lines

However, having discussed the whole issue for many times and reconsidered it thoroughly, I think that it's inappropriate to identify the suspend blockers (or wakelocks) framework with the opportunistic suspend feature as proposed in the original submission of the "suspend blockers" patchset. IMO they really are not the same thing and while the suspend blockers framework is used by Android to implement opportunistic suspend, I don't really believe this is the right approach.

Quoted 3 lines

Can you clarify this? Do you not believe using opportunistic suspend is the right approach, or do you not believe linking suspend blockers with opportunistic suspend is the right approach?

The latter. That should be clear from the remaining part of my message.

Quoted 7 lines
Quoted 6 lines

We really need something similar to suspend blockers to avoid races between a suspend process and wakeup events, but it isn't necessary to provide user space with an interface allowing it to use these things directly. Such an interface is only necessary in the specific implementation in which the system is suspended as soon as the number of "active" suspend blockers goes down to zero.

Quoted 13 lines

I don't think what you are saying here is correct. When you decide to suspend has no impact on whether a user space interface to block suspend is needed. The last suspend blocker patchset had this interface as a separate patch and the reasons for providing it have not changed with your interface. Android need the user space interface because low level services that handle wakeup events are started before the user space power manager. The other reason to have this interface in the mainline kernel is to provide a safe way to handle wakeup events on linux regardless of which user space power manager is used on the system. For instance some devices have a user space battery monitor, and there would be no need for this code to be android specific if the kernel provided all the functionality it needs.

Well, the problem is, with your /dev/suspend_blocker interface, multiple user space processes are supposed to decide whether or not system suspend should be started and in general there don't seem to be any particularly good criteria for choosing these applications, in general. So, application writers may be tempted to use this interface in all programs and then the decision whether or not to allow these programs to affect system power management will be delegated to users. In turn, the users may not be technically qualified to make such a decision.

Also the fact that the same mechanism is used for handling wakeup events detected by the kernel and allowing user space programs to grant permission to suspend the system is somewhat confusing.

Quoted 17 lines
Quoted 4 lines

Arguably, though, this isn't the only possible way to implement a
mechanism allowing the system to be suspended automatically when it appears to be inactive.

Quoted 12 lines

Namely, one can use a user space power manager for this purpose and actually the OLPC project has been doing that successfully for some time, which clearly demonstrates that the Android approach to this problem is not the only one possible. Moreover, the kernel's system suspend (or hibernate for that matter) code has not been designed to be started from within the kernel. It's been designed to allow a privileged user space process to request the kernel to put the system into a sleep state at any given time regardless of what the other user space processes are doing. While it can be started from within the kernel, this isn't particularly nice and, in the Android case, starting it from within the kernel requires permission from multiple user space processes (given by not taking suspend blockers these processes are allowed to use).

Quoted 5 lines

Why is starting suspend from within the kernel not nice? Personally I think reentering suspend from within the kernel is nicer than being forced to wake up a user space thread for events that are fully handled within the kernel (for instance the battery monitor on the Nexus One).

For basically the same reason why the kernel generally doesn't use sys_open() for opening files. It is an interface provided for user space.

Quoted 8 lines
Quoted 7 lines

Since, quite clearly, user space input is necessary to make the decision whether or not to suspend the system, I think it is more appropriate to allow user space to start the entire operation and provide the kernel with a means to abort it in the case of a wakeup event. Then, user space will be able to use arbitrary heuristics in deciding whether or not to suspend the system, possibly taking some kernel's input into account.

When we don't need these heuristics, this is just a burden.

The word 'arbitrary' means in particular that you can implement a mechanism equivalent to the /dev/suspend_blocker entirely in user space. Someone else, though, can use a different approach.

By adding the /dev/suspend_blocker interface to the mainline kernel we would mandate that Linux applications use it on all platforms. Consequently, application writers would have the right to expect that all platforms would be using Android-alike opportunistic suspend, which may or may not be the case.

Quoted 11 lines
Quoted 7 lines

I'm not against the very idea of automatic system suspend, which IMO is a legitimate and reasonable thing to do in many usage scenarios, but I don't think that the kernel is the right place to start a suspend process. For this reason I'm not going to take any code trying to start a suspend process from within the kernel, regardless of that code's purpose, unless somebody makes a really convincing case for that to me (basically proving the need for such a solution).

There is no absolute need to start the suspend process from within the kernel, but it makes the user space code much simpler for what we need.

I'm entirely aware of that. Still, I think user space is the right place to initiate system suspend.

Thanks,
Rafael

#642 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 15 lines · Felipe Contreras
Quoted 13 lines · Paul E. McKenney
Quoted 9 lines · Felipe Contreras

Anyway, Alan was picturing a hypothetical point in time when x86 can suspend/resume as fast as ARM, and thus the question of whether or not to enable suspend-blockers in a system that runs openoffice becomes relevant. If applications have been fixed by that time to not wake the system unnecessarily, as many of them have already been tanks to tools like powertop, then suspend-blockers would not make that much of a difference, therefore the effort required to implement suspend-blockers properly on all applications in the system, including openoffice might not be worth the gain.

One more time, this time with feeling.  ;-)

Quoted 8 lines
Quoted 3 lines

       Only PM-driving applications need concern themselves with suspend blockers, and experience thus far indicates that PM-driving applications are a very small fraction of the total.

There's no experience on this. Have you tried to run a small debian system with suspend blockers enabled? I can image at least all cron daemons need modifications, probably dbus, links, lftp, wget, rsync and a bunch of applications that download data too.

I have not. I would be surprised if anyone else did that work unless suspend blockers were in mainline. I would be very happy to be proven wrong, of course!

Quoted 8 lines

It's easy to speculate one way or the other, but the fact of the matter is that we don't really know how many changes are needed in order to have a functional system that actually benefits from suspend blockers.

What we know is that if an application is not analyzed to see if it needs suspend blockers, and implement them if needed, it might get broken.

That would be your speculation. Perhaps you are correct, but it seems more likely that some large sets applications can be considered as a group rather than one at a time.

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines
Quoted 1 line

Apparently different people in this debate have different targets.

I remember clearly Android people explaining that dynamic PM is orthogonal to suspend-blockers; if a suspend is blocked, you still want dynamic PM to reach the lower power state. Therefore the target of not having unneeded runnable tasks is shared by Android folks.

And I have not seen anyone argue that suspend blockers are a replacement for dynamic power management.

That's exactly what I'm saying: they are orthogonal.

OK, good to know! Please understand that your sentence "Therefore the target of not having unneeded runnable tasks is shared by Android folks" can be interpreted as meaning "the Android guys really don't need suspend blockers", which is how I interpreted it.

Quoted 8 lines
Quoted 2 lines

In contrast, you are advocating dynamic power management to the exclusion of other mechanisms.

* if dynamic PM was perfect, spend-blockers would *not* be not needed
* if suspend-blockers were perfect, dynamic *will* still be needed

All I said in that sentence you are replying is that dynamic PM will improve; it's a shared goal of everyone.

That is certainly not the way I read the sentence I was replying to, but I will accept that this was what you were really trying to say.

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

IOW. Alan wasn't talking about idle vs suspend on the same device, he was talking about opportunistic suspend vs dynamic PM.

The most convincing comparisons will be of suspend vs. idle on the same device.  If multiple devices are involved, then the most convincing experiments would compare suspend vs. idle separately on each device.

Quoted 5 lines
Quoted 1 line

So, are you sure that you are correctly interpreting Alan's words?

The point you are trying to highlight is to which events the system reacts, that has nothing to do with dynamic PM vs opportunistic suspend.

Ahem. I -do- know what -I- was trying to say. ;-)

Quoted 7 lines
Quoted 4 lines

Again, I am in no way arguing for suspend blockers to the exclusion of other approaches.  Heck, I am mostly just trying to get a clear statement of the problem.  In contrast, you do seem to be advocating for dynamic power management to the exclusion of other approaches.

What you are doing is copy pasting a definition of what is opportunistic suspend and making it pass as an advantage.

No, I was copy pasting a definition of a difference between idle and suspend and making it pass as a difference between idle and suspend.

Quoted 2 lines

This particular point (3.) is not an advantage, over dynamic PM, it's just a difference.

Yep. I never claimed otherwise.

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

No, I think both (for opportunistic suspend and dynamic PM) are completely reasonable. But think again; if you have the assumptions met on both, then both work fine, if you don't meet them, then both don't work correctly.

That is true of any artifact, software or otherwise: if you don't meet the assumptions inherent in its design and construction, the artifact might fail.

Quoted 6 lines

[...]

Quoted 2 lines

 There is
a very real difference between those two tasks.

I've cut most of your explanation.

Indeed you have! But you should be safe in doing so, as most people probably won't bother to do the web search that would lead them to
http://lkml.org/lkml/2010/8/12/198 and then search that page for the word "artifact". ;-)

Quoted 4 lines

If I understand correctly what you
are saying is that suspend blockers are harder to get wrong. I agree, but my point against 4. remains the same: suspend-blockers don't automatically get you more efficient power usage.

I am glad you agree that suspend blockers might be harder to get wrong. As to point #4, you were correct that I badly worded the last sentence, which is now hopefully fixed to your satisfaction.

Quoted 6 lines
Quoted 2 lines

So are you sure that dynamic power management will turn out to be the right tool for every job out there?  If so, on what grounds?

I don't understand this question. Dynamic PM is needed regardless. We are discussing your point 4 where you say suspend blockers inevitably lead to more efficient power usage (I say not necessarily).

But can dynamic power management do everything optimally? If not, some other approach may be needed in addition to dynamic power management. If you really are arguing that the Linux kernel should support no power-management mechanism other than dynamic power management, you should be prepared to justify that position.

Quoted 14 lines
Quoted 5 lines
Quoted 3 lines

My point is that suspend-blockers don't magically reduce power usage, just like dynamic PM, it depends on what user-space actually does. You made it look as it *always* reached better energy efficiency.

I do?  Really???  Exactly what did I say to give you that impression?

Here's your point 4 again:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

4. Suspend generally forces devices to go into their low-power
states immediately. In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices. Idle thus has shorter average wakeup latencies, but worse energy efficiency.

Quoted 3 lines

Remove "but worse energy efficiency" and I think that point would be correct, albeit it's not really an argument in favor of opportunistic suspend.

Fix put forward in earlier email. Again, thank you -- good catch!!!

Quoted 13 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

It seems to me that the same social-engineering approaches work in both cases.

Yes, but if dynamic PM works as advertised, you don't need opportunistic suspend.

Quoted 6 lines

For dynamic power management to totally eliminate the need for something like suspend blockers, you are having to make some brave assumptions. Yes, dynamic power management is quite useful, but there is a big difference between something being useful and something doing everything for everyone.  You have not yet convinced me that dynamic power management will make it to the "doing everything for everyone" stage.

Quoted 7 lines

As it has been explained before, there's a sweet-spot of idleness:
http://article.gmane.org/gmane.linux.kernel/995525
http://article.gmane.org/gmane.linux.ports.arm.omap/37982

Do you agree that there's such a thing, and if so, do you agree that the benefits of opportunistic suspend are much less once that point is reached?

I agree that there will be a sweet spot of idleness (though I would call it a "point of diminishing returns"), but only if all the applications are power-optimized. The advantage of opportunistic suspend is instead its tolerance of power-oblivious applications with minimal degradation of battery life.

Quoted 16 lines
Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

Really?  What makes you say that?

For starters an application might be holding the wakelock more than it should, also, an application might miss a timer due to not having PM permissions to hold the lock, and thus might need an expensive initialization when it runs again.

Quoted 5 lines

Just as an application might run continuously without blocking, which would defeat the dynamic power management scheme that have thus far been put forward.  And just as an application might miss a timer due to dynamic power management having decided that it didn't need that timer to fire at the desired time.

Quoted 8 lines
Quoted 2 lines · concentrate on what I
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

I just proved to you that in certain cases opportunistic suspend might actually hurt. Thus you should accept my premise that you can't say that in practice opportunistic suspend _always_ leads to better results, because that's not the case.

And in the paragraph above, I proved to you that relying solely on dynamic power management might actually hurt. And I am not trying to prove that opportunistic suspend always leads to better results -- that is a strawman that you set up. And yes, you might have been led to set up that strawman because I messed up the wording of one of the suspend-vs.-idle definitions. Of course, had you called out that sentence to start with, we would likely have spent much less time arguing generalities. ;-)

Quoted 2 lines

And in order to try to avoid going back to the same points:
1) yes, there are advantages of opportunistic suspend

Good, agreed.

Quoted 1 line

2) yes, there are cases where it works as it should

Good, agreed.

Quoted 1 line

3) no, it's not a silver bullet that will inevitably improve power usage

Agreed. This is no surprise, as there are very few silver bullets to be had in this field. Of course, dynamic power management is not a silver bullet, either.

Quoted 1 line

4) no, we can't say anything about what opportunistic suspend means in practice

Here I disagree. The Android folks have used it for quite some time. We might not be able to apply their experience directly to other software stacks, but we should nevertheless be able to learn quite a bit from it.

Thanx, Paul

#643 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 15 lines · Felipe Contreras
Quoted 13 lines · Paul E. McKenney
Quoted 9 lines · Felipe Contreras

Anyway, Alan was picturing a hypothetical point in time when x86 can suspend/resume as fast as ARM, and thus the question of whether or not to enable suspend-blockers in a system that runs openoffice becomes relevant. If applications have been fixed by that time to not wake the system unnecessarily, as many of them have already been tanks to tools like powertop, then suspend-blockers would not make that much of a difference, therefore the effort required to implement suspend-blockers properly on all applications in the system, including openoffice might not be worth the gain.

One more time, this time with feeling.  ;-)

Quoted 8 lines
Quoted 3 lines

       Only PM-driving applications need concern themselves with suspend blockers, and experience thus far indicates that PM-driving applications are a very small fraction of the total.

There's no experience on this. Have you tried to run a small debian system with suspend blockers enabled? I can image at least all cron daemons need modifications, probably dbus, links, lftp, wget, rsync and a bunch of applications that download data too.

I have not. I would be surprised if anyone else did that work unless suspend blockers were in mainline. I would be very happy to be proven wrong, of course!

Quoted 8 lines

It's easy to speculate one way or the other, but the fact of the matter is that we don't really know how many changes are needed in order to have a functional system that actually benefits from suspend blockers.

What we know is that if an application is not analyzed to see if it needs suspend blockers, and implement them if needed, it might get broken.

That would be your speculation. Perhaps you are correct, but it seems more likely that some large sets applications can be considered as a group rather than one at a time.

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines
Quoted 1 line

Apparently different people in this debate have different targets.

I remember clearly Android people explaining that dynamic PM is orthogonal to suspend-blockers; if a suspend is blocked, you still want dynamic PM to reach the lower power state. Therefore the target of not having unneeded runnable tasks is shared by Android folks.

And I have not seen anyone argue that suspend blockers are a replacement for dynamic power management.

That's exactly what I'm saying: they are orthogonal.

OK, good to know! Please understand that your sentence "Therefore the target of not having unneeded runnable tasks is shared by Android folks" can be interpreted as meaning "the Android guys really don't need suspend blockers", which is how I interpreted it.

Quoted 8 lines
Quoted 2 lines

In contrast, you are advocating dynamic power management to the exclusion of other mechanisms.

* if dynamic PM was perfect, spend-blockers would *not* be not needed
* if suspend-blockers were perfect, dynamic *will* still be needed

All I said in that sentence you are replying is that dynamic PM will improve; it's a shared goal of everyone.

That is certainly not the way I read the sentence I was replying to, but I will accept that this was what you were really trying to say.

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

IOW. Alan wasn't talking about idle vs suspend on the same device, he was talking about opportunistic suspend vs dynamic PM.

The most convincing comparisons will be of suspend vs. idle on the same device.  If multiple devices are involved, then the most convincing experiments would compare suspend vs. idle separately on each device.

Quoted 5 lines
Quoted 1 line

So, are you sure that you are correctly interpreting Alan's words?

The point you are trying to highlight is to which events the system reacts, that has nothing to do with dynamic PM vs opportunistic suspend.

Ahem. I -do- know what -I- was trying to say. ;-)

Quoted 7 lines
Quoted 4 lines

Again, I am in no way arguing for suspend blockers to the exclusion of other approaches.  Heck, I am mostly just trying to get a clear statement of the problem.  In contrast, you do seem to be advocating for dynamic power management to the exclusion of other approaches.

What you are doing is copy pasting a definition of what is opportunistic suspend and making it pass as an advantage.

No, I was copy pasting a definition of a difference between idle and suspend and making it pass as a difference between idle and suspend.

Quoted 2 lines

This particular point (3.) is not an advantage, over dynamic PM, it's just a difference.

Yep. I never claimed otherwise.

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

No, I think both (for opportunistic suspend and dynamic PM) are completely reasonable. But think again; if you have the assumptions met on both, then both work fine, if you don't meet them, then both don't work correctly.

That is true of any artifact, software or otherwise: if you don't meet the assumptions inherent in its design and construction, the artifact might fail.

Quoted 6 lines

[...]

Quoted 2 lines

 There is
a very real difference between those two tasks.

I've cut most of your explanation.

Indeed you have! But you should be safe in doing so, as most people probably won't bother to do the web search that would lead them to
http://lkml.org/lkml/2010/8/12/198 and then search that page for the word "artifact". ;-)

Quoted 4 lines

If I understand correctly what you
are saying is that suspend blockers are harder to get wrong. I agree, but my point against 4. remains the same: suspend-blockers don't automatically get you more efficient power usage.

I am glad you agree that suspend blockers might be harder to get wrong. As to point #4, you were correct that I badly worded the last sentence, which is now hopefully fixed to your satisfaction.

Quoted 6 lines
Quoted 2 lines

So are you sure that dynamic power management will turn out to be the right tool for every job out there?  If so, on what grounds?

I don't understand this question. Dynamic PM is needed regardless. We are discussing your point 4 where you say suspend blockers inevitably lead to more efficient power usage (I say not necessarily).

But can dynamic power management do everything optimally? If not, some other approach may be needed in addition to dynamic power management. If you really are arguing that the Linux kernel should support no power-management mechanism other than dynamic power management, you should be prepared to justify that position.

Quoted 14 lines
Quoted 5 lines
Quoted 3 lines

My point is that suspend-blockers don't magically reduce power usage, just like dynamic PM, it depends on what user-space actually does. You made it look as it *always* reached better energy efficiency.

I do?  Really???  Exactly what did I say to give you that impression?

Here's your point 4 again:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

4. Suspend generally forces devices to go into their low-power
states immediately. In contrast, idle generally leaves unused devices at full power, relying on timers to shut down these devices. Idle thus has shorter average wakeup latencies, but worse energy efficiency.

Quoted 3 lines

Remove "but worse energy efficiency" and I think that point would be correct, albeit it's not really an argument in favor of opportunistic suspend.

Fix put forward in earlier email. Again, thank you -- good catch!!!

Quoted 13 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

It seems to me that the same social-engineering approaches work in both cases.

Yes, but if dynamic PM works as advertised, you don't need opportunistic suspend.

Quoted 6 lines

For dynamic power management to totally eliminate the need for something like suspend blockers, you are having to make some brave assumptions. Yes, dynamic power management is quite useful, but there is a big difference between something being useful and something doing everything for everyone.  You have not yet convinced me that dynamic power management will make it to the "doing everything for everyone" stage.

Quoted 7 lines

As it has been explained before, there's a sweet-spot of idleness:
http://article.gmane.org/gmane.linux.kernel/995525
http://article.gmane.org/gmane.linux.ports.arm.omap/37982

Do you agree that there's such a thing, and if so, do you agree that the benefits of opportunistic suspend are much less once that point is reached?

I agree that there will be a sweet spot of idleness (though I would call it a "point of diminishing returns"), but only if all the applications are power-optimized. The advantage of opportunistic suspend is instead its tolerance of power-oblivious applications with minimal degradation of battery life.

Quoted 16 lines
Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

Really?  What makes you say that?

For starters an application might be holding the wakelock more than it should, also, an application might miss a timer due to not having PM permissions to hold the lock, and thus might need an expensive initialization when it runs again.

Quoted 5 lines

Just as an application might run continuously without blocking, which would defeat the dynamic power management scheme that have thus far been put forward.  And just as an application might miss a timer due to dynamic power management having decided that it didn't need that timer to fire at the desired time.

Quoted 8 lines
Quoted 2 lines · concentrate on what I
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

If not, you'll see much worst energy efficiency. So in theory maybe, but in practice you can't say that.

I just proved to you that in certain cases opportunistic suspend might actually hurt. Thus you should accept my premise that you can't say that in practice opportunistic suspend _always_ leads to better results, because that's not the case.

And in the paragraph above, I proved to you that relying solely on dynamic power management might actually hurt. And I am not trying to prove that opportunistic suspend always leads to better results -- that is a strawman that you set up. And yes, you might have been led to set up that strawman because I messed up the wording of one of the suspend-vs.-idle definitions. Of course, had you called out that sentence to start with, we would likely have spent much less time arguing generalities. ;-)

Quoted 2 lines

And in order to try to avoid going back to the same points:
1) yes, there are advantages of opportunistic suspend

Good, agreed.

Quoted 1 line

2) yes, there are cases where it works as it should

Good, agreed.

Quoted 1 line

3) no, it's not a silver bullet that will inevitably improve power usage

Agreed. This is no surprise, as there are very few silver bullets to be had in this field. Of course, dynamic power management is not a silver bullet, either.

Quoted 1 line

4) no, we can't say anything about what opportunistic suspend means in practice

Here I disagree. The Android folks have used it for quite some time. We might not be able to apply their experience directly to other software stacks, but we should nevertheless be able to learn quite a bit from it.

Thanx, Paul

#758 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 9 lines · Felipe Contreras
Quoted 5 lines · Paul E. McKenney
Quoted 2 lines · Felipe Contreras

So far, nobody has refuted these:
 1) opportunistic suspend needs a good behaved user-space to work properly

As does dynamic power management.

Thus remains unrefuted.

Glad we agree that both dynamic power management and opportunistic power management need applications to be written carefully. Of course, dynamic power management requires all of the code in those applications to be carefully written, while experience indicates that opportunistic suspend requires only a small fraction to be carefully written.

Quoted 10 lines
Quoted 5 lines
Quoted 2 lines

 2) if suspend blockers are enabled in a system, *all* user-space must implement them to work correctly

Really?  From what I can see, only PM-driving applications need to use suspend blockers.

"PM-driving applications" is a new invention, so how do you know if an application belongs to this category or not? Some application might be non-PM-driving most of the time, but suddenly become PM-driving. Well, you have to analyze *all* of them.

A PM-driving application is one that exerts control over the system's power state. In the case of Android, a PM-driving application is one that is permitted to acquire suspend blockers.

Quoted 2 lines

Think about this... is bash a PM driving application? No, but what if you run: 'sleep 3600 && alarm.sh'.

That is an excellent example, as it applies equally to dynamic power management. By how much are you allowed to delay the wakeup?

Quoted 2 lines

Perhaps I should rewrite that as:
2) if suspend blockers are enabled in the system; *all* user-space is affected

That is speculation on your part.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

 3) implementing suspend blockers in user-space is not a straight-forward task

Fortunately, experience thus far has shown that only a small fraction of applications need to use suspend blockers.

Wrong. We don't have any experience on that at all on typical linux ecosystems (remember that Android's user-space is very special).

Android's experience might not apply exactly to typical Linux ecosystems, but we really can learn quite a bit from it -- at least if we can bring ourselves to do so.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

So, as the length of this thread has shown, the benefits of opportunistic suspend are *dubious* at best, and more likely not worth the changes needed in user-space which eventually will get pretty close to what suspend blockers can achieve even in ideal circumstances by just doing dynamic PM.

Quoted 6 lines
Quoted 2 lines

The length of this thread (and the ones preceding it) is mostly due to people talking past each other.

Perhaps half of the thread, or even one quarter of the thread can be attributed to that, but still the rest I think it's because people keep pushing in, and people keep pushing out.

Fair enough. I wasn't differentiating between people mistakenly talking past each other and intentionally talking past each other, but if you want to differentiate, feel free to do so.

Quoted 11 lines
Quoted 10 lines

For example, the Android folks seem to
believe that it is important that relatively unskilled people be able to write simple apps, and that the system nevertheless be able to run these apps in a relatively energy efficient manner.  Your proposals do not address this issue.  This might be because you are not aware of this desire, because you are not aware of the computing history that argues in favor of this requirement, or because you simply don't like this requirement.  Whatever the reason, until you face this requirement head on, either addressing it or proving that it need not be addressed, you will continue to be talking past the Android folks.

Quoted 1 line

This "requirement" is specific to Android's user-space, isn't it?

That is your speculation.

Quoted 7 lines

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

At this point in the discussion, I am quite prepared to believe that you will avoid using suspend blockers, and that you will further do everything in your power to prevent anyone else from using suspend blockers. ;-)

Thanx, Paul

#759 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 9 lines · Felipe Contreras
Quoted 5 lines · Paul E. McKenney
Quoted 2 lines · Felipe Contreras

So far, nobody has refuted these:
 1) opportunistic suspend needs a good behaved user-space to work properly

As does dynamic power management.

Thus remains unrefuted.

Glad we agree that both dynamic power management and opportunistic power management need applications to be written carefully. Of course, dynamic power management requires all of the code in those applications to be carefully written, while experience indicates that opportunistic suspend requires only a small fraction to be carefully written.

Quoted 10 lines
Quoted 5 lines
Quoted 2 lines

 2) if suspend blockers are enabled in a system, *all* user-space must implement them to work correctly

Really?  From what I can see, only PM-driving applications need to use suspend blockers.

"PM-driving applications" is a new invention, so how do you know if an application belongs to this category or not? Some application might be non-PM-driving most of the time, but suddenly become PM-driving. Well, you have to analyze *all* of them.

A PM-driving application is one that exerts control over the system's power state. In the case of Android, a PM-driving application is one that is permitted to acquire suspend blockers.

Quoted 2 lines

Think about this... is bash a PM driving application? No, but what if you run: 'sleep 3600 && alarm.sh'.

That is an excellent example, as it applies equally to dynamic power management. By how much are you allowed to delay the wakeup?

Quoted 2 lines

Perhaps I should rewrite that as:
2) if suspend blockers are enabled in the system; *all* user-space is affected

That is speculation on your part.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

 3) implementing suspend blockers in user-space is not a straight-forward task

Fortunately, experience thus far has shown that only a small fraction of applications need to use suspend blockers.

Wrong. We don't have any experience on that at all on typical linux ecosystems (remember that Android's user-space is very special).

Android's experience might not apply exactly to typical Linux ecosystems, but we really can learn quite a bit from it -- at least if we can bring ourselves to do so.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

So, as the length of this thread has shown, the benefits of opportunistic suspend are *dubious* at best, and more likely not worth the changes needed in user-space which eventually will get pretty close to what suspend blockers can achieve even in ideal circumstances by just doing dynamic PM.

Quoted 6 lines
Quoted 2 lines

The length of this thread (and the ones preceding it) is mostly due to people talking past each other.

Perhaps half of the thread, or even one quarter of the thread can be attributed to that, but still the rest I think it's because people keep pushing in, and people keep pushing out.

Fair enough. I wasn't differentiating between people mistakenly talking past each other and intentionally talking past each other, but if you want to differentiate, feel free to do so.

Quoted 11 lines
Quoted 10 lines

For example, the Android folks seem to
believe that it is important that relatively unskilled people be able to write simple apps, and that the system nevertheless be able to run these apps in a relatively energy efficient manner.  Your proposals do not address this issue.  This might be because you are not aware of this desire, because you are not aware of the computing history that argues in favor of this requirement, or because you simply don't like this requirement.  Whatever the reason, until you face this requirement head on, either addressing it or proving that it need not be addressed, you will continue to be talking past the Android folks.

Quoted 1 line

This "requirement" is specific to Android's user-space, isn't it?

That is your speculation.

Quoted 7 lines

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

At this point in the discussion, I am quite prepared to believe that you will avoid using suspend blockers, and that you will further do everything in your power to prevent anyone else from using suspend blockers. ;-)

Thanx, Paul

#644 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 6 lines · Paul E. McKenney
Quoted 1 line · Felipe Contreras

 4) no, we can't say anything about what opportunistic suspend means in practice

Here I disagree.  The Android folks have used it for quite some time. We might not be able to apply their experience directly to other software stacks, but we should nevertheless be able to learn quite a bit from it.

So when it comes to practice you are relying solely on what Android people say.

If it's true that it's easy to spot the "PM-driving applications", then it shouldn't be hard for a guy from the Android team to assemble a basic typical system (X.org, dbus, etc.) with suspend-blockers in a couple of days.

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#645 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 6 lines · Paul E. McKenney
Quoted 1 line · Felipe Contreras

 4) no, we can't say anything about what opportunistic suspend means in practice

Here I disagree.  The Android folks have used it for quite some time. We might not be able to apply their experience directly to other software stacks, but we should nevertheless be able to learn quite a bit from it.

So when it comes to practice you are relying solely on what Android people say.

If it's true that it's easy to spot the "PM-driving applications", then it shouldn't be hard for a guy from the Android team to assemble a basic typical system (X.org, dbus, etc.) with suspend-blockers in a couple of days.

Signature · 1 line
Felipe Contreras
#781 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Alan Cox
Quoted 9 lines · Alan Cox
Quoted 4 lines
Quoted 2 lines

Think in terms of an ARM laptop. What good is opportunistic suspend if it's not going to help when the laptop is being used?

For when the laptop is not being used, presumably.

Or in time between keystrokes for most of the platform (backlight excepted). The Intel MID x86 devices are at the point that suspend/resume time on x86 is being hurt by the kernel rewriting smp alternatives as we go from 2 processors live to 1 and back.

Given that you are talking about going from 2 processors to 1 and back, I would guess that you are not actually talking about suspend/resume, which is a system-wide thing rather than a CPU-by-CPU thing. I am not sure whether you are using CPU hotplug or invoking SMP alternatives once all but one CPU is idle.

Can't say that I can tell exactly what pit you are digging for me here. ;-)

Thanx, Paul

#782 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Alan Cox
Quoted 9 lines · Alan Cox
Quoted 4 lines
Quoted 2 lines

Think in terms of an ARM laptop. What good is opportunistic suspend if it's not going to help when the laptop is being used?

For when the laptop is not being used, presumably.

Or in time between keystrokes for most of the platform (backlight excepted). The Intel MID x86 devices are at the point that suspend/resume time on x86 is being hurt by the kernel rewriting smp alternatives as we go from 2 processors live to 1 and back.

Given that you are talking about going from 2 processors to 1 and back, I would guess that you are not actually talking about suspend/resume, which is a system-wide thing rather than a CPU-by-CPU thing. I am not sure whether you are using CPU hotplug or invoking SMP alternatives once all but one CPU is idle.

Can't say that I can tell exactly what pit you are digging for me here. ;-)

Thanx, Paul

#760 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 9 lines · Paul E. McKenney
Quoted 4 lines · Felipe Contreras

"PM-driving applications" is a new invention, so how do you know if an application belongs to this category or not? Some application might be non-PM-driving most of the time, but suddenly become PM-driving. Well, you have to analyze *all* of them.

A PM-driving application is one that exerts control over the system's power state.  In the case of Android, a PM-driving application is one that is permitted to acquire suspend blockers.

I already mentioned that a "PM-driving application" might not have suspend-blockers; because the user denied them, or because the developer forgot them.

Quoted 5 lines
Quoted 2 lines

Think about this... is bash a PM driving application? No, but what if you run: 'sleep 3600 && alarm.sh'.

That is an excellent example, as it applies equally to dynamic power management.  By how much are you allowed to delay the wakeup?

Huh? Certainly not days, which if Android guys are right, might be how much the task will be delayed.

Quoted 4 lines
Quoted 2 lines

Perhaps I should rewrite that as:
2) if suspend blockers are enabled in the system; *all* user-space is affected

That is speculation on your part.

Not really. Say you have 100 packages in your system, how do you know which ones would be PM-driving? Can you grep for something, or see if they open certain file? No, you have to analyze them one by one; they *all* are affected, although not all might require modifications.

But assuming I'm wrong, that's precisely the reason why a practical exercise would help.

Quoted 3 lines
Quoted 1 line

This "requirement" is specific to Android's user-space, isn't it?

That is your speculation.

Which is why we need something practical.

Quoted 11 lines
Quoted 7 lines

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

At this point in the discussion, I am quite prepared to believe that you will avoid using suspend blockers, and that you will further do everything in your power to prevent anyone else from using suspend blockers.  ;-)

I'm not tying anybody's hands.

How are people using real-time linux if it's not on mainline? Well, duuh, you apply the patches. If say Fedora was interested on it, they could apply the patches, and see for themselves. People do that all the time, with the mm tree, with Con Koliva's patches, etc. Once people are happy with the results, things get merged. Why should this be any different?

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#761 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 9 lines · Paul E. McKenney
Quoted 4 lines · Felipe Contreras

"PM-driving applications" is a new invention, so how do you know if an application belongs to this category or not? Some application might be non-PM-driving most of the time, but suddenly become PM-driving. Well, you have to analyze *all* of them.

A PM-driving application is one that exerts control over the system's power state.  In the case of Android, a PM-driving application is one that is permitted to acquire suspend blockers.

I already mentioned that a "PM-driving application" might not have suspend-blockers; because the user denied them, or because the developer forgot them.

Quoted 5 lines
Quoted 2 lines

Think about this... is bash a PM driving application? No, but what if you run: 'sleep 3600 && alarm.sh'.

That is an excellent example, as it applies equally to dynamic power management.  By how much are you allowed to delay the wakeup?

Huh? Certainly not days, which if Android guys are right, might be how much the task will be delayed.

Quoted 4 lines
Quoted 2 lines

Perhaps I should rewrite that as:
2) if suspend blockers are enabled in the system; *all* user-space is affected

That is speculation on your part.

Not really. Say you have 100 packages in your system, how do you know which ones would be PM-driving? Can you grep for something, or see if they open certain file? No, you have to analyze them one by one; they *all* are affected, although not all might require modifications.

But assuming I'm wrong, that's precisely the reason why a practical exercise would help.

Quoted 3 lines
Quoted 1 line

This "requirement" is specific to Android's user-space, isn't it?

That is your speculation.

Which is why we need something practical.

Quoted 11 lines
Quoted 7 lines

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

At this point in the discussion, I am quite prepared to believe that you will avoid using suspend blockers, and that you will further do everything in your power to prevent anyone else from using suspend blockers.  ;-)

I'm not tying anybody's hands.

How are people using real-time linux if it's not on mainline? Well, duuh, you apply the patches. If say Fedora was interested on it, they could apply the patches, and see for themselves. People do that all the time, with the mm tree, with Con Koliva's patches, etc. Once people are happy with the results, things get merged. Why should this be any different?

Signature · 1 line
Felipe Contreras
#762 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 12 lines
Quoted 11 lines
Quoted 7 lines

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

At this point in the discussion, I am quite prepared to believe that you will avoid using suspend blockers, and that you will further do everything in your power to prevent anyone else from using suspend blockers.  ;-)

Quoted 8 lines

I'm not tying anybody's hands.

How are people using real-time linux if it's not on mainline? Well, duuh, you apply the patches. If say Fedora was interested on it, they could apply the patches, and see for themselves. People do that all the time, with the mm tree, with Con Koliva's patches, etc. Once people are happy with the results, things get merged. Why should this be any different?

Because millions of users are happy -- with Android, including suspend blockers.

Best,
Dominik

#763 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 12 lines
Quoted 11 lines
Quoted 7 lines

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

At this point in the discussion, I am quite prepared to believe that you will avoid using suspend blockers, and that you will further do everything in your power to prevent anyone else from using suspend blockers.  ;-)

Quoted 8 lines

I'm not tying anybody's hands.

How are people using real-time linux if it's not on mainline? Well, duuh, you apply the patches. If say Fedora was interested on it, they could apply the patches, and see for themselves. People do that all the time, with the mm tree, with Con Koliva's patches, etc. Once people are happy with the results, things get merged. Why should this be any different?

Because millions of users are happy -- with Android, including suspend blockers.

Best,
Dominik

#286 lore raw

Wakeup-events implementation

In reply to Arve Hjønnevåg

Since this area of the discussion has strayed away from the path of Paul McKenney's original summary, I'm starting a new email thread and drastically cutting the CC list.

Quoted 6 lines · Arve Hjønnevåg
Quoted 4 lines

Maybe.  There aren't enough examples coded up yet to be sure.  At this point we could easily make the device argument required instead of optional, and we could add a device argument to pm_relax.

I think that would be a good start. I can create dummy devices for now where I don't already have a device.

Rafael and I spent some time discussing all this during LinuxCon. Combining what he thought with my own ideas led us to decide that the wakeup information should be stored in a separate structure, not in dev_pm_info. These structures will be allocated dynamically when a device is enabled for remote wakeup (and presumably deallocated if a device is disabled for remote wakeup). A pointer to the new structure will be stored in dev_pm_info. We expect that most devices won't need a wakeup structure, because most devices aren't wakeup sources.

This new structure (as yet unnamed) will be a lot like your suspend_blocker structure, but with some differences. It won't need a name, since the device already has a name. It won't have a timer, if we can get away with leaving one out. But it will optionally contain various counters that can be used for statistics reporting and debugging. The API for exporting these fields to userspace has not yet been decided upon.

The device argument will become mandatory for pm_stay_awake, pm_relax, and pm_wakeup_event, so that the counter fields can be updated properly.

Quoted 9 lines
Quoted 8 lines

In the scheme we're talking about, the suspend-blocking interface for uesrspace would be located entirely in the power manager.  Hence it could maintain all the necessary statistics, without involving the kernel.  During early stages of system startup, before the power manager is running, lower-level services would not be able to block suspend.  This wouldn't matter because at those times the system simply would not ever suspend -- because suspends have to be initiated by the power manager.

Quoted 4 lines

If we do that, a low level process could try to block suspend while the power manager is not running. Then the power manager could start and decide to suspend not knowing that a low level process wanted to block suspend.

There's a simple solution: Put all this in a _new_, low-level power manager program that can be started very early during boot-up (before any of the other low-level services that need to block suspend). Then all the other programs would communicate their suspend-blocker requirements to this program instead of to the kernel.

You expressed concern about the new power manager deadlocking. This can be avoided by designing the program properly. It should run in two threads. Thread 1 will handle IPC, keeping track of userspace suspend-blocker requests, their statistics, and so on. Thread 2 will manage the PM interface to the kernel, and it will execute the following simple loop:

	for (;;) {
		read /sys/power/wakeup_count	/* blocking read */
		if (there are any active userspace suspend blockers) {
			wait until they are all deactivated
		} else {
			if (write to /sys/power/wakeup_count succeeds)
				write "mem" to /sys/power/state
		}
	}

I think this will resolve the problem you were worried about.

Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

I don't know if they are all kernel-internal but these drivers appear to use timeouts and active cancellation on the same wakelock:
wifi driver, mmc core, alarm driver, evdev (suspend blocker version removes the timeout).

Roughly speaking, what do the timings work out to be?  That is, how long are the timeouts for these wakelocks, how long does it usually take for one of them to be actively cancelled, and what percentage of them end up timing out?

Quoted 7 lines

The evdev timeout is a few seconds, and never timeout unless user space is misbehaving. I don't know how the wifi and mmc wakelocks are used. The alarm driver uses a 1 or 2 second timeout to abort suspend when an alarm is set to close to program an rtc alarm. I think this one is cancelled when the alarm triggers, and the timeout only handles the case where the client cancelled the alarm before it trigger, but I don't remember for sure.

Evdev turns out to be tricky for a couple of reasons. One is this business of combining active cancellation with timeouts (we might end up needing a special-purpose timer for this). Another is the way all input events funnel into a single event queue.

For example, suppose you want the keyboard to be a wakeup device but not the mouse. Once events get into the input queue, there's no way to tell where they came from. Hence mouse motion events would prevent the system from suspending, even though they weren't supposed to.

Quoted 3 lines

You cannot easily mix timeouts, cancellations and nesting. Wakelocks/suspend blockers allow you to mix timeouts and cancellations.

That's true. And it turns out that we do need to mix cancellations with nesting. For example, it may well happen that pm_request_resume gets called several times before the pm workqueue thread gets around to resuming the device. If each of those calls has a corresponding call to pm_stay_awake then we would like to cancel all of them with a single pm_relax after the driver's runtime_resume callback is finished.

On the other hand, the driver's runtime_resume routine might need to carry out some work in a different kernel thread. It would call pm_stay_awake, and we wouldn't want _this_ call to be cancelled until the other thread has run.

In the end, the best answer may be to keep a count of pending wakeup events in the new wakeup structure (as well as a global count of the number of devices whose pending count is > 0). Then pm_stay_awake would increment the count, pm_relax would decrement it, and there could be a variant of pm_stay_awake that would increment the count only if it was currently equal to 0.

Quoted 3 lines

The cleanup is a little simpler when you don't nest and there is less chance that a missed edge case prevents suspend forever (we had a few of those bugs in our userspace code that used nested wakelocks).

Bugs in the kernel can be tracked down and fixed.

Quoted 3 lines

If
the above is all you do, then you block suspend forever if someone closes an non-empty input device.

That sounds like a fixable bug. :-)

Alan Stern

#764 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Dominik Brodowski
Quoted 2 lines · Dominik Brodowski

Because millions of users are happy -- with Android, including suspend blockers.

I'd guess there are on the order of 20 users
that have built and deployed a kernel with
Android suspend blockers support.

The total deployed systems is relatively meaningless.

#765 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

In reply to Dominik Brodowski
Quoted 2 lines · Dominik Brodowski

Because millions of users are happy -- with Android, including suspend blockers.

I'd guess there are on the order of 20 users
that have built and deployed a kernel with
Android suspend blockers support.

The total deployed systems is relatively meaningless.

#766 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 7 lines · Joe Perches
Quoted 2 lines · Dominik Brodowski

Because millions of users are happy -- with Android, including suspend blockers.

I'd guess there are on the order of 20 users
that have built and deployed a kernel with
Android suspend blockers support.

You mean non-Google users?

Quoted 1 line

The total deployed systems is relatively meaningless.

Well, it wasn't meaningless wrt noveau:

"I've heard all the excuses. If it isn't ready, they shouldn't ship it to millions of people. And if it's ready, they should work on merging it.

No excuses.

Linus"

So let's get the suspend blockers to Linus.

Best
Dominik

#767 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

In reply to Joe Perches
Quoted 7 lines · Joe Perches
Quoted 2 lines · Dominik Brodowski

Because millions of users are happy -- with Android, including suspend blockers.

I'd guess there are on the order of 20 users
that have built and deployed a kernel with
Android suspend blockers support.

You mean non-Google users?

Quoted 1 line

The total deployed systems is relatively meaningless.

Well, it wasn't meaningless wrt noveau:

"I've heard all the excuses. If it isn't ready, they shouldn't ship it to millions of people. And if it's ready, they should work on merging it.

No excuses.

Linus"

So let's get the suspend blockers to Linus.

Best
Dominik

#768 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Dominik Brodowski
Quoted 21 lines · Dominik Brodowski
Quoted 12 lines
Quoted 11 lines
Quoted 7 lines

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

At this point in the discussion, I am quite prepared to believe that you will avoid using suspend blockers, and that you will further do everything in your power to prevent anyone else from using suspend blockers.  ;-)

Quoted 8 lines

I'm not tying anybody's hands.

How are people using real-time linux if it's not on mainline? Well, duuh, you apply the patches. If say Fedora was interested on it, they could apply the patches, and see for themselves. People do that all the time, with the mm tree, with Con Koliva's patches, etc. Once people are happy with the results, things get merged. Why should this be any different?

Quoted 2 lines

Because millions of users are happy -- with Android, including suspend blockers.

I explicitly said somebody besides Android, specifically, somebody with a typical linux ecosystem. You are not addressing the argument at hand, that nobody else wants to tackle the issue this way, thus only making the discussion more difficult.

Signature · 5 lines
Felipe Contreras
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#769 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

In reply to Dominik Brodowski
Quoted 21 lines · Dominik Brodowski
Quoted 12 lines
Quoted 11 lines
Quoted 7 lines

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

At this point in the discussion, I am quite prepared to believe that you will avoid using suspend blockers, and that you will further do everything in your power to prevent anyone else from using suspend blockers.  ;-)

Quoted 8 lines

I'm not tying anybody's hands.

How are people using real-time linux if it's not on mainline? Well, duuh, you apply the patches. If say Fedora was interested on it, they could apply the patches, and see for themselves. People do that all the time, with the mm tree, with Con Koliva's patches, etc. Once people are happy with the results, things get merged. Why should this be any different?

Quoted 2 lines

Because millions of users are happy -- with Android, including suspend blockers.

I explicitly said somebody besides Android, specifically, somebody with a typical linux ecosystem. You are not addressing the argument at hand, that nobody else wants to tackle the issue this way, thus only making the discussion more difficult.

Signature · 1 line
Felipe Contreras
#701 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Rafael J. Wysocki
Quoted 23 lines · On Fri, 13 Aug 2010 05:28:21 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 15 lines · Jesse Barnes
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of? Seems like a chicken and egg problem. Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions. We've merged code one release or more before the new code gets used for example, which is fine IMO. What we don't want to see is some new drop of code added and abandoned, but you already knew that.

Quoted 6 lines

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape. Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable. So where's the git pull request already? :)

Quoted 3 lines

In fact my patch going in that direction has been merged already and that code will likely be extended to cover some needs and cases I didn't have in mind when I was preparing it.

Yeah, I like what you've done with dynamic power management, really good stuff (the approach is very similar to the one I used for vblank interrupt management in the drm layer).

Ted's point about providing the user with a way of knowing which apps are blocking things is a good one though, and doesn't seem too hard to add. It might even be possible to do it largely with scripts wrapping fuser and such.

Quoted 17 lines

However, having discussed the whole issue for many times and reconsidered it thoroughly, I think that it's inappropriate to identify the suspend blockers (or wakelocks) framework with the opportunistic suspend feature as proposed in the original submission of the "suspend blockers" patchset. IMO they really are not the same thing and while the suspend blockers framework is used by Android to implement opportunistic suspend, I don't really believe this is the right approach.

We really need something similar to suspend blockers to avoid races between a suspend process and wakeup events, but it isn't necessary to provide user space with an interface allowing it to use these things directly. Such an interface is only necessary in the specific implementation in which the system is suspended as soon as the number of "active" suspend blockers goes down to zero. Arguably, though, this isn't the only possible way to implement a mechanism allowing the system to be suspended automatically when it appears to be inactive.

Quoted 11 lines

Namely, one can use a user space power manager for this purpose and actually the OLPC project has been doing that successfully for some time, which clearly demonstrates that the Android approach to this problem is not the only one possible. Moreover, the kernel's system suspend (or hibernate for that matter) code has not been designed to be started from within the kernel. It's been designed to allow a privileged user space process to request the kernel to put the system into a sleep state at any given time regardless of what the other user space processes are doing. While it can be started from within the kernel, this isn't particularly nice and, in the Android case, starting it from within the kernel requires permission from multiple user space processes (given by not taking suspend blockers these processes are allowed to use).

Yes, I see your point. But I actually think this is a fairly minor distinction. In one case, a privileged app decides when to suspend the system, in the other case, one or more of several privileged apps decide when a suspend should not be allowed to occur. It's just a matter of where you want to put the code and where you want the complexity. In general, we try to keep such complexity out of the kernel, but not always; there are compelling cases for putting complexity in the kernel to provide uniformity and flexibility (e.g. application state save/restore vs. system-wide checkpoints, the former preserves the "if it can be done outside the kernel, it should be", while the latter provides much greater flexibility and avoids the need to port applications to potentially incompatible or unportable state saves/restore libraries).

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#702 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Rafael J. Wysocki
Quoted 23 lines · On Fri, 13 Aug 2010 05:28:21 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 15 lines · Jesse Barnes
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of? Seems like a chicken and egg problem. Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions. We've merged code one release or more before the new code gets used for example, which is fine IMO. What we don't want to see is some new drop of code added and abandoned, but you already knew that.

Quoted 6 lines

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape. Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable. So where's the git pull request already? :)

Quoted 3 lines

In fact my patch going in that direction has been merged already and that code will likely be extended to cover some needs and cases I didn't have in mind when I was preparing it.

Yeah, I like what you've done with dynamic power management, really good stuff (the approach is very similar to the one I used for vblank interrupt management in the drm layer).

Ted's point about providing the user with a way of knowing which apps are blocking things is a good one though, and doesn't seem too hard to add. It might even be possible to do it largely with scripts wrapping fuser and such.

Quoted 17 lines

However, having discussed the whole issue for many times and reconsidered it thoroughly, I think that it's inappropriate to identify the suspend blockers (or wakelocks) framework with the opportunistic suspend feature as proposed in the original submission of the "suspend blockers" patchset. IMO they really are not the same thing and while the suspend blockers framework is used by Android to implement opportunistic suspend, I don't really believe this is the right approach.

We really need something similar to suspend blockers to avoid races between a suspend process and wakeup events, but it isn't necessary to provide user space with an interface allowing it to use these things directly. Such an interface is only necessary in the specific implementation in which the system is suspended as soon as the number of "active" suspend blockers goes down to zero. Arguably, though, this isn't the only possible way to implement a mechanism allowing the system to be suspended automatically when it appears to be inactive.

Quoted 11 lines

Namely, one can use a user space power manager for this purpose and actually the OLPC project has been doing that successfully for some time, which clearly demonstrates that the Android approach to this problem is not the only one possible. Moreover, the kernel's system suspend (or hibernate for that matter) code has not been designed to be started from within the kernel. It's been designed to allow a privileged user space process to request the kernel to put the system into a sleep state at any given time regardless of what the other user space processes are doing. While it can be started from within the kernel, this isn't particularly nice and, in the Android case, starting it from within the kernel requires permission from multiple user space processes (given by not taking suspend blockers these processes are allowed to use).

Yes, I see your point. But I actually think this is a fairly minor distinction. In one case, a privileged app decides when to suspend the system, in the other case, one or more of several privileged apps decide when a suspend should not be allowed to occur. It's just a matter of where you want to put the code and where you want the complexity. In general, we try to keep such complexity out of the kernel, but not always; there are compelling cases for putting complexity in the kernel to provide uniformity and flexibility (e.g. application state save/restore vs. system-wide checkpoints, the former preserves the "if it can be done outside the kernel, it should be", while the latter provides much greater flexibility and avoids the need to port applications to potentially incompatible or unportable state saves/restore libraries).

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#770 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 23 lines · Felipe Contreras
Quoted 21 lines · Dominik Brodowski
Quoted 20 lines
Quoted 11 lines
Quoted 7 lines

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

At this point in the discussion, I am quite prepared to believe that you will avoid using suspend blockers, and that you will further do everything in your power to prevent anyone else from using suspend blockers. ;-)

I'm not tying anybody's hands.

How are people using real-time linux if it's not on mainline? Well, duuh, you apply the patches. If say Fedora was interested on it, they could apply the patches, and see for themselves. People do that all the time, with the mm tree, with Con Koliva's patches, etc. Once people are happy with the results, things get merged. Why should this be any different?

Quoted 7 lines
Quoted 2 lines

Because millions of users are happy -- with Android, including suspend blockers.

I explicitly said somebody besides Android, specifically, somebody with a typical linux ecosystem. You are not addressing the argument at hand, that nobody else wants to tackle the issue this way, thus only making the discussion more difficult.

Can we stop arguing about the pointless?

The facts are that suspend blockers identifies a race within our suspend to ram system that permeates from top to bottom (that's from server to mobile). The problem is that resume events are racy with respect to suspend and vice versa. This manifests itself most annoyingly on my laptop in the "double suspend" case: where I suspend with a pending suspend event, my laptop will resume and then immediately re-suspend (leading me to kick myself and remind myself to check it stayed up before pushing unsuspend and walking away). The other annoying case is that if I accidentally close the lid before presenting, I have to wait until the system is fully down before pressing resume.

In a Data Centre controlling power, if you sent a suspend then a wake on lan, there's a window where the machine will still be down (because the wol got ignored).

There are easy fixes to all the above ... I should wait to verify suspend and resume in my laptop and I have to accept the wait time between the two. In the data centre, you just repeat your power control commands a few times with about 5s between them and so on.

The simple hacky work arounds mean that a user space invasive solution like suspend blockers is a bit of a non starter as a solution to the general case. However, it has shown that we do have a problem and furthermore it's a problem encountered by more than android.

The technical problem with suspend blockers is that they're a solution to a general problem that only works for a specific case. What we're searching for is a general solution that can also be used in the android specific case.

So far, we have three possibilities:

1. Stubs with deprecation - this has been rejected by android, so looks like a non starter.
2. update pm_qos so that the suspend blocks become qos constraints. This may or may not be coupled with a user space suspend manager, but in the latter case it's essentially full suspend blockers (with the additional opportunistic suspend kernel code) but with information systems outside of android can use.
3. Rafael's patch that makes it possible to avoid the races between wakeup and suspend. This requires a user space suspend manager

(There's a whole other load of implementation details like stats and the like, but the above is the concept view).

Unless anyone has something substantive to add to either the problem space or the solution space, the android discussion piece of this thread has degenerated to pure noise.

James

#771 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 23 lines · Felipe Contreras
Quoted 21 lines · Dominik Brodowski
Quoted 20 lines
Quoted 11 lines
Quoted 7 lines

Not Ubuntu, not Fedora, not MeeGo, not anyone with a typical user-space seems to be having this problem. I can argue to you that this problem can be solved in easier ways, but instead I will argue that perhaps we should wait for somebody besides Android to complain about it before providing a "solution". Because after all, what good is a "solution" provided by the kernel, if the user-space is not going to use it, ever.

At this point in the discussion, I am quite prepared to believe that you will avoid using suspend blockers, and that you will further do everything in your power to prevent anyone else from using suspend blockers. ;-)

I'm not tying anybody's hands.

How are people using real-time linux if it's not on mainline? Well, duuh, you apply the patches. If say Fedora was interested on it, they could apply the patches, and see for themselves. People do that all the time, with the mm tree, with Con Koliva's patches, etc. Once people are happy with the results, things get merged. Why should this be any different?

Quoted 7 lines
Quoted 2 lines

Because millions of users are happy -- with Android, including suspend blockers.

I explicitly said somebody besides Android, specifically, somebody with a typical linux ecosystem. You are not addressing the argument at hand, that nobody else wants to tackle the issue this way, thus only making the discussion more difficult.

Can we stop arguing about the pointless?

The facts are that suspend blockers identifies a race within our suspend to ram system that permeates from top to bottom (that's from server to mobile). The problem is that resume events are racy with respect to suspend and vice versa. This manifests itself most annoyingly on my laptop in the "double suspend" case: where I suspend with a pending suspend event, my laptop will resume and then immediately re-suspend (leading me to kick myself and remind myself to check it stayed up before pushing unsuspend and walking away). The other annoying case is that if I accidentally close the lid before presenting, I have to wait until the system is fully down before pressing resume.

In a Data Centre controlling power, if you sent a suspend then a wake on lan, there's a window where the machine will still be down (because the wol got ignored).

There are easy fixes to all the above ... I should wait to verify suspend and resume in my laptop and I have to accept the wait time between the two. In the data centre, you just repeat your power control commands a few times with about 5s between them and so on.

The simple hacky work arounds mean that a user space invasive solution like suspend blockers is a bit of a non starter as a solution to the general case. However, it has shown that we do have a problem and furthermore it's a problem encountered by more than android.

The technical problem with suspend blockers is that they're a solution to a general problem that only works for a specific case. What we're searching for is a general solution that can also be used in the android specific case.

So far, we have three possibilities:

1. Stubs with deprecation - this has been rejected by android, so looks like a non starter.
2. update pm_qos so that the suspend blocks become qos constraints. This may or may not be coupled with a user space suspend manager, but in the latter case it's essentially full suspend blockers (with the additional opportunistic suspend kernel code) but with information systems outside of android can use.
3. Rafael's patch that makes it possible to avoid the races between wakeup and suspend. This requires a user space suspend manager

(There's a whole other load of implementation details like stats and the like, but the above is the concept view).

Unless anyone has something substantive to add to either the problem space or the solution space, the android discussion piece of this thread has degenerated to pure noise.

James

#646 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 10 lines · Felipe Contreras
Quoted 6 lines · Paul E. McKenney
Quoted 1 line · Felipe Contreras

 4) no, we can't say anything about what opportunistic suspend means in practice

Here I disagree.  The Android folks have used it for quite some time. We might not be able to apply their experience directly to other software stacks, but we should nevertheless be able to learn quite a bit from it.

So when it comes to practice you are relying solely on what Android people say.

So when it comes to practice with suspend blockers, only the Android people have any experience, so theirs is the only experience with suspend blockers that there is to rely on. ;-) ;-) ;-)

Quoted 4 lines

If it's true that it's easy to spot the "PM-driving applications", then it shouldn't be hard for a guy from the Android team to assemble a basic typical system (X.org, dbus, etc.) with suspend-blockers in a couple of days.

I am happy to let the Android guys determine the best use for their time.

Thanx, Paul

#647 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras
Quoted 10 lines · Felipe Contreras
Quoted 6 lines · Paul E. McKenney
Quoted 1 line · Felipe Contreras

 4) no, we can't say anything about what opportunistic suspend means in practice

Here I disagree.  The Android folks have used it for quite some time. We might not be able to apply their experience directly to other software stacks, but we should nevertheless be able to learn quite a bit from it.

So when it comes to practice you are relying solely on what Android people say.

So when it comes to practice with suspend blockers, only the Android people have any experience, so theirs is the only experience with suspend blockers that there is to rely on. ;-) ;-) ;-)

Quoted 4 lines

If it's true that it's easy to spot the "PM-driving applications", then it shouldn't be hard for a guy from the Android team to assemble a basic typical system (X.org, dbus, etc.) with suspend-blockers in a couple of days.

I am happy to let the Android guys determine the best use for their time.

Thanx, Paul

#772 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to James Bottomley
Quoted 11 lines · James Bottomley

The facts are that suspend blockers identifies a race within our suspend to ram system that permeates from top to bottom (that's from server to mobile). The problem is that resume events are racy with respect to suspend and vice versa. This manifests itself most annoyingly on my laptop in the "double suspend" case: where I suspend with a pending suspend event, my laptop will resume and then immediately re-suspend (leading me to kick myself and remind myself to check it stayed up before pushing unsuspend and walking away). The other annoying case is that if I accidentally close the lid before presenting, I have to wait until the system is fully down before pressing resume.

This is all true, but it's also only one aspect of the problem. I agree with you that this is the part of the problem which affects Linux at all scales, from Cloud servers in a data center that want to suspend themselves when there's no work to do (and then fail to respond to the WOL packet) to mobile platforms that are suspending much more frequently.

However, it doesn't follow that this is the _only_ problem that the Android folks might be interested in solving. Opportunistic suspend is a different part of the problem space, which is generally believed by the Android developers as being far more efficient than a user-space suspend manager. Rafael has stated his complete unwillingness to deal with this part of the problem. OK, so that probably means that for Android, it will have to be an out-of-tree kernel patch.

The question, then, is whether a solution which addresses the only part of the problem which Rafael is interested in dealing with at this point, is sufficient such that (a) the kernel-level opportunistic suspend can be done as an out-of-tree patch, while simultaneously (b) allowing device drivers for Android devices can utilize Rafael's interfaces to solve the race design bug currently found in our suspend subsystem, while (c) requiring minimal changes to the Android userspace, and (d) providing all of the statistics and debugging functionality required by the Android userspace.

If we can engineer a solution which meets (a), (b), (c), and (d) above, then everyone will be happy.

- Ted

#773 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

In reply to James Bottomley
Quoted 11 lines · James Bottomley

The facts are that suspend blockers identifies a race within our suspend to ram system that permeates from top to bottom (that's from server to mobile). The problem is that resume events are racy with respect to suspend and vice versa. This manifests itself most annoyingly on my laptop in the "double suspend" case: where I suspend with a pending suspend event, my laptop will resume and then immediately re-suspend (leading me to kick myself and remind myself to check it stayed up before pushing unsuspend and walking away). The other annoying case is that if I accidentally close the lid before presenting, I have to wait until the system is fully down before pressing resume.

This is all true, but it's also only one aspect of the problem. I agree with you that this is the part of the problem which affects Linux at all scales, from Cloud servers in a data center that want to suspend themselves when there's no work to do (and then fail to respond to the WOL packet) to mobile platforms that are suspending much more frequently.

However, it doesn't follow that this is the _only_ problem that the Android folks might be interested in solving. Opportunistic suspend is a different part of the problem space, which is generally believed by the Android developers as being far more efficient than a user-space suspend manager. Rafael has stated his complete unwillingness to deal with this part of the problem. OK, so that probably means that for Android, it will have to be an out-of-tree kernel patch.

The question, then, is whether a solution which addresses the only part of the problem which Rafael is interested in dealing with at this point, is sufficient such that (a) the kernel-level opportunistic suspend can be done as an out-of-tree patch, while simultaneously (b) allowing device drivers for Android devices can utilize Rafael's interfaces to solve the race design bug currently found in our suspend subsystem, while (c) requiring minimal changes to the Android userspace, and (d) providing all of the statistics and debugging functionality required by the Android userspace.

If we can engineer a solution which meets (a), (b), (c), and (d) above, then everyone will be happy.

- Ted

#774 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

Quoted 39 lines · Ted Ts'o
Quoted 11 lines · James Bottomley

The facts are that suspend blockers identifies a race within our suspend to ram system that permeates from top to bottom (that's from server to mobile).  The problem is that resume events are racy with respect to suspend and vice versa.  This manifests itself most annoyingly on my laptop in the "double suspend" case: where I suspend with a pending suspend event, my laptop will resume and then immediately re-suspend (leading me to kick myself and remind myself to check it stayed up before pushing unsuspend and walking away).  The other annoying case is that if I accidentally close the lid before presenting, I have to wait until the system is fully down before pressing resume.

This is all true, but it's also only one aspect of the problem.  I agree with you that this is the part of the problem which affects Linux at all scales, from Cloud servers in a data center that want to suspend themselves when there's no work to do (and then fail to respond to the WOL packet) to mobile platforms that are suspending much more frequently.

However, it doesn't follow that this is the _only_ problem that the Android folks might be interested in solving.  Opportunistic suspend is a different part of the problem space, which is generally believed by the Android developers as being far more efficient than a user-space suspend manager.  Rafael has stated his complete unwillingness to deal with this part of the problem.  OK, so that probably means that for Android, it will have to be an out-of-tree kernel patch.

The question, then, is whether a solution which addresses the only part of the problem which Rafael is interested in dealing with at this point, is sufficient such that (a) the kernel-level opportunistic suspend can be done as an out-of-tree patch, while simultaneously (b) allowing device drivers for Android devices can utilize Rafael's interfaces to solve the race design bug currently found in our suspend subsystem, while (c) requiring minimal changes to the Android userspace, and (d) providing all of the statistics and debugging functionality required by the Android userspace.

Quoted 2 lines

If we can engineer a solution which meets (a), (b), (c), and (d) above, then everyone will be happy.

Arve's suspend blockers patch stack actually separates the core functionality (ability for drivers to delay suspend while doing work suspend would interfere with), from the ability to hold suspend blockers from userspace (a separate, smaller patch building on the core functionality).

Brian
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm

#775 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 20 lines · Ted Ts'o
Quoted 11 lines · James Bottomley

The facts are that suspend blockers identifies a race within our suspend to ram system that permeates from top to bottom (that's from server to mobile). The problem is that resume events are racy with respect to suspend and vice versa. This manifests itself most annoyingly on my laptop in the "double suspend" case: where I suspend with a pending suspend event, my laptop will resume and then immediately re-suspend (leading me to kick myself and remind myself to check it stayed up before pushing unsuspend and walking away). The other annoying case is that if I accidentally close the lid before presenting, I have to wait until the system is fully down before pressing resume.

This is all true, but it's also only one aspect of the problem. I agree with you that this is the part of the problem which affects Linux at all scales, from Cloud servers in a data center that want to suspend themselves when there's no work to do (and then fail to respond to the WOL packet) to mobile platforms that are suspending much more frequently.

Quoted 8 lines

However, it doesn't follow that this is the _only_ problem that the Android folks might be interested in solving. Opportunistic suspend is a different part of the problem space, which is generally believed by the Android developers as being far more efficient than a user-space suspend manager. Rafael has stated his complete unwillingness to deal with this part of the problem. OK, so that probably means that for Android, it will have to be an out-of-tree kernel patch.

OK, so I tried desperately to avoid the question of whether opportunistic suspend is a good way of managing power. However, it seems to me that it is in use by several systems (android, olpc, etc). I'll defer the question of whether it's better in user space or kernel space to Rafael's investigations ... but I will point out that the kernel space patch, once the suspend blockers issue is taken care of looks like a single patch to one file, so should be locally containable and should allow upstream to be useful as the driver base again.

Quoted 10 lines

The question, then, is whether a solution which addresses the only part of the problem which Rafael is interested in dealing with at this point, is sufficient such that (a) the kernel-level opportunistic suspend can be done as an out-of-tree patch, while simultaneously (b) allowing device drivers for Android devices can utilize Rafael's interfaces to solve the race design bug currently found in our suspend subsystem, while (c) requiring minimal changes to the Android userspace, and (d) providing all of the statistics and debugging functionality required by the Android userspace.

Quoted 2 lines

If we can engineer a solution which meets (a), (b), (c), and (d) above, then everyone will be happy.

That's my goal.

James

#776 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 20 lines · Ted Ts'o
Quoted 11 lines · James Bottomley

The facts are that suspend blockers identifies a race within our suspend to ram system that permeates from top to bottom (that's from server to mobile). The problem is that resume events are racy with respect to suspend and vice versa. This manifests itself most annoyingly on my laptop in the "double suspend" case: where I suspend with a pending suspend event, my laptop will resume and then immediately re-suspend (leading me to kick myself and remind myself to check it stayed up before pushing unsuspend and walking away). The other annoying case is that if I accidentally close the lid before presenting, I have to wait until the system is fully down before pressing resume.

This is all true, but it's also only one aspect of the problem. I agree with you that this is the part of the problem which affects Linux at all scales, from Cloud servers in a data center that want to suspend themselves when there's no work to do (and then fail to respond to the WOL packet) to mobile platforms that are suspending much more frequently.

Quoted 8 lines

However, it doesn't follow that this is the _only_ problem that the Android folks might be interested in solving. Opportunistic suspend is a different part of the problem space, which is generally believed by the Android developers as being far more efficient than a user-space suspend manager. Rafael has stated his complete unwillingness to deal with this part of the problem. OK, so that probably means that for Android, it will have to be an out-of-tree kernel patch.

OK, so I tried desperately to avoid the question of whether opportunistic suspend is a good way of managing power. However, it seems to me that it is in use by several systems (android, olpc, etc). I'll defer the question of whether it's better in user space or kernel space to Rafael's investigations ... but I will point out that the kernel space patch, once the suspend blockers issue is taken care of looks like a single patch to one file, so should be locally containable and should allow upstream to be useful as the driver base again.

Quoted 10 lines

The question, then, is whether a solution which addresses the only part of the problem which Rafael is interested in dealing with at this point, is sufficient such that (a) the kernel-level opportunistic suspend can be done as an out-of-tree patch, while simultaneously (b) allowing device drivers for Android devices can utilize Rafael's interfaces to solve the race design bug currently found in our suspend subsystem, while (c) requiring minimal changes to the Android userspace, and (d) providing all of the statistics and debugging functionality required by the Android userspace.

Quoted 2 lines

If we can engineer a solution which meets (a), (b), (c), and (d) above, then everyone will be happy.

That's my goal.

James

#697 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Rafael J. Wysocki
Quoted 8 lines · On Fri, 13 Aug 2010 17:07:02 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 4 lines

There is no absolute need to start the suspend process from within the kernel, but it makes the user space code much simpler for what we need.

I'm entirely aware of that. Still, I think user space is the right place to initiate system suspend.

For what it's worth - I completely agree.

Clearly there is no a lot of unanimity on this, and so lots of room to experiment with different approaches. It's best if we leave as much as possible of that experimentation in user-space - just have the kernel do what cannot be done elsewhere.

NeilBrown

#698 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Rafael J. Wysocki
Quoted 8 lines · On Fri, 13 Aug 2010 17:07:02 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 4 lines

There is no absolute need to start the suspend process from within the kernel, but it makes the user space code much simpler for what we need.

I'm entirely aware of that. Still, I think user space is the right place to initiate system suspend.

For what it's worth - I completely agree.

Clearly there is no a lot of unanimity on this, and so lots of room to experiment with different approaches. It's best if we leave as much as possible of that experimentation in user-space - just have the kernel do what cannot be done elsewhere.

NeilBrown

#287 lore raw

Re: Wakeup-events implementation

In reply to Alan Stern

2010/8/13 Alan Stern <[email protected]>:

Quoted 22 lines

Since this area of the discussion has strayed away from the path of Paul McKenney's original summary, I'm starting a new email thread and drastically cutting the CC list.

Quoted 6 lines · Arve Hjønnevåg
Quoted 4 lines

Maybe.  There aren't enough examples coded up yet to be sure.  At this point we could easily make the device argument required instead of optional, and we could add a device argument to pm_relax.

I think that would be a good start. I can create dummy devices for now where I don't already have a device.

Rafael and I spent some time discussing all this during LinuxCon. Combining what he thought with my own ideas led us to decide that the wakeup information should be stored in a separate structure, not in dev_pm_info.  These structures will be allocated dynamically when a device is enabled for remote wakeup (and presumably deallocated if a device is disabled for remote wakeup).  A pointer to the new structure will be stored in dev_pm_info.  We expect that most devices won't need a wakeup structure, because most devices aren't wakeup sources.

Quoted 3 lines

This new structure (as yet unnamed) will be a lot like your suspend_blocker structure, but with some differences.  It won't need a name, since the device already has a name.

A name is still useful if we allocate multiple handles per device (see below for why one handle per device is not enough).

Quoted 2 lines

 It won't have a timer, if
we can get away with leaving one out.

The suspend_blocker structure does not have a timer, it has a timeout. This was intentional, since it avoids unnecessary timers from firing but it also means it takes a lot less space than the stats. We do need the timeout in the structure to support some of our drivers since they mix wake_lock_timeout and wake_unlock.

Quoted 9 lines

 But it will optionally contain
various counters that can be used for statistics reporting and debugging.  The API for exporting these fields to userspace has not yet been decided upon.

The device argument will become mandatory for pm_stay_awake, pm_relax, and pm_wakeup_event, so that the counter fields can be updated properly.

I think this is a step in the right direction, but it is not enough to support mixing timeouts and pm_relax in all the drivers.

Quoted 14 lines
Quoted 9 lines
Quoted 8 lines

In the scheme we're talking about, the suspend-blocking interface for uesrspace would be located entirely in the power manager.  Hence it could maintain all the necessary statistics, without involving the kernel.  During early stages of system startup, before the power manager is running, lower-level services would not be able to block suspend.  This wouldn't matter because at those times the system simply would not ever suspend -- because suspends have to be initiated by the power manager.

Quoted 4 lines

If we do that, a low level process could try to block suspend while the power manager is not running. Then the power manager could start and decide to suspend not knowing that a low level process wanted to block suspend.

Quoted 6 lines

There's a simple solution: Put all this in a _new_, low-level power manager program that can be started very early during boot-up (before any of the other low-level services that need to block suspend).  Then all the other programs would communicate their suspend-blocker requirements to this program instead of to the kernel.

Maintaining an out of mainline driver to export allow user space to block suspend seems like a more appealing solution than adding another process for everyone to depend on. Having a user space interface to block suspend in the mainline kernel would still be valuable, though. Like I mentioned in another message, this would allow some low level services, like the user-space battery monitor some devices have, to not be android specific.

Quoted 17 lines

You expressed concern about the new power manager deadlocking.  This can be avoided by designing the program properly.  It should run in two threads.  Thread 1 will handle IPC, keeping track of userspace suspend-blocker requests, their statistics, and so on.  Thread 2 will manage the PM interface to the kernel, and it will execute the following simple loop:

       for (;;) {
               read /sys/power/wakeup_count    /* blocking read */ if (there are any active userspace suspend blockers) { wait until they are all deactivated } else {
                       if (write to /sys/power/wakeup_count succeeds) write "mem" to /sys/power/state }
       }

Quoted 2 lines

I think this will resolve the problem you were worried about.

I know how to avoid the deadlock. My point was that adding the code in the drivers to support the overlapping wakelock model of handling wakeup events, means that a single threaded power manager that did not deadlock before now could deadlock.

Quoted 18 lines
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

I don't know if they are all kernel-internal but these drivers appear to use timeouts and active cancellation on the same wakelock:
wifi driver, mmc core, alarm driver, evdev (suspend blocker version removes the timeout).

Roughly speaking, what do the timings work out to be?  That is, how long are the timeouts for these wakelocks, how long does it usually take for one of them to be actively cancelled, and what percentage of them end up timing out?

Quoted 7 lines

The evdev timeout is a few seconds, and never timeout unless user space is misbehaving. I don't know how the wifi and mmc wakelocks are used. The alarm driver uses a 1 or 2 second timeout to abort suspend when an alarm is set to close to program an rtc alarm. I think this one is cancelled when the alarm triggers, and the timeout only handles the case where the client cancelled the alarm before it trigger, but I don't remember for sure.

Quoted 5 lines

Evdev turns out to be tricky for a couple of reasons.  One is this business of combining active cancellation with timeouts (we might end up needing a special-purpose timer for this).  Another is the way all input events funnel into a single event queue.

Input events do not funnel to a single event queue in the kernel (at least not with the interface I have used). There are separate queues for each client of every device.

Quoted 21 lines

For example, suppose you want the keyboard to be a wakeup device but not the mouse.  Once events get into the input queue, there's no way to tell where they came from.  Hence mouse motion events would prevent the system from suspending, even though they weren't supposed to.

Quoted 3 lines

You cannot easily mix timeouts, cancellations and nesting. Wakelocks/suspend blockers allow you to mix timeouts and cancellations.

That's true.  And it turns out that we do need to mix cancellations with nesting.  For example, it may well happen that pm_request_resume gets called several times before the pm workqueue thread gets around to resuming the device.  If each of those calls has a corresponding call to pm_stay_awake then we would like to cancel all of them with a single pm_relax after the driver's runtime_resume callback is finished.

On the other hand, the driver's runtime_resume routine might need to carry out some work in a different kernel thread.  It would call pm_stay_awake, and we wouldn't want _this_ call to be cancelled until the other thread has run.

Quoted 7 lines

In the end, the best answer may be to keep a count of pending wakeup events in the new wakeup structure (as well as a global count of the number of devices whose pending count is > 0).  Then pm_stay_awake would increment the count, pm_relax would decrement it, and there could be a variant of pm_stay_awake that would increment the count only if it was currently equal to 0.

If I correctly understand what you are suggesting, that does not work. If two subsystems use the same device an one of them expects the pm_stay_awake call to be nested and the other one does not, then the subsystem that uses the non-nested api is not preventing suspend if the other subsystem was preventing suspend when it called pm_stay_awake_if_not_zero (the non-nested pm_relax variant would cause similar problems). Also, to support all our existing drivers we need multiple handles per device. For each input device we have a wakelock with a timeout per client. We only allow suspend when all the clients have emptied their queue or had their wakelock timeout.

Quoted 6 lines
Quoted 3 lines

The cleanup is a little simpler when you don't nest and there is less chance that a missed edge case prevents suspend forever (we had a few of those bugs in our userspace code that used nested wakelocks).

Bugs in the kernel can be tracked down and fixed.

Yes, bugs can be fixed, but not all bugs are discovered quickly and products ship before some bugs are fixed. For instance, when applying our patch that holds a wakelock when the input queue is not empty to this weeks kernel, I noticed that someone had fixed a bug where a queue overflow could leave the queue empty. If you hit this bug with the wakelock with timeout implementation that we currently use, then it would cause suspend to be blocked for 5 seconds (less if another event occurred or the file descriptor was closed). With the patch that uses a suspend blocker without a timeout, it would block suspend until another event from the same device occurred or user space closes the device. With a nesting api like the current pm_stay_awake/pm_relax, it will prevent suspend forever (unless another driver has the opposite bug).

Do we need the nested api for something? We need a non-nested api to mix timeouts and pm_relax, and unless we need the nested variants, it is easier to just make all the calls non-nesting.

Quoted 9 lines
Quoted 3 lines

If
the above is all you do, then you block suspend forever if someone closes an non-empty input device.

That sounds like a fixable bug.  :-)

Alan Stern

Signature · 1 line
Arve Hjønnevåg
#783 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney

Hi!

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Think in terms of an ARM laptop. What good is opportunistic suspend if it's not going to help when the laptop is being used?

For when the laptop is not being used, presumably.

Or in time between keystrokes for most of the platform (backlight excepted). The Intel MID x86 devices are at the point that suspend/resume time on x86 is being hurt by the kernel rewriting smp alternatives as we go from 2 processors live to 1 and back.

Quoted 5 lines

Given that you are talking about going from 2 processors to 1 and back, I would guess that you are not actually talking about suspend/resume, which is a system-wide thing rather than a CPU-by-CPU thing. I am not sure whether you are using CPU hotplug or invoking SMP alternatives once all but one CPU is idle.

When entering system suspend, we disable non-boot-CPUs to simplify locking. We reenable them when going out of suspend.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#711 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 13 lines · Ted Ts'o
Quoted 9 lines · Felipe Contreras

The question is why are we adding a user-space API that:
1) no user-space beside Android has expresses interest in implementing
2) is dubious whether the benefits are worth the pain for non-Android
user-space
3) will become less and less attractive as dynamic PM gets closer to
the sweet-spot, and then surpass it
4) Android can keep in a separate tree until it's clear in the linux
community that it's useful (if it ever happens)

So, Felipe,

Quoted 8 lines

Do you believe you speak for all of LKML?

Are you willing to tell ZDNet and the Slashdot fanboys that it's OK for Suspend blockers to live in a separate tree, and it's not a case of OMG! Google is forking the kernel?

If you could speak out a passionately on those forums as you have here, that would be great.

Ted, what is going on here? Are you suggesting people disagreeing with Google patches suddenly have to do advocacy for Google?

And yes, for the record Felipe speaks for me pretty well.

Normal path of merging stuff to the kernel is

"Google develops it, then modifies it to address the review comments, then it is merged, then it is deployed".

Unfortunately what Google did here is:

"Google develops it behind the closed door, then deploys it. When asked for changes, Google expects someone else to create system compatible with their existing solution, or else their patches being merged."

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#709 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Felipe Contreras

Hi!

Quoted 13 lines
Quoted 7 lines
Quoted 6 lines

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of?  Seems like a chicken and egg problem.  Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

Quoted 5 lines

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions.  We've merged code one release or more before the new code gets used for example, which is fine IMO.  What we don't want to see is some new drop of code added and abandoned, but you already knew that.

Quoted 3 lines

If Android guys provided a bare minimal Debian system with suspend blockers that people can take a look at and try, I think that would be a good proof of concept. And a bare minimum to get the patches merged.

Yes, that would certainly help.

I guess this is the major point -- as suspend blockers seem very suitable for android, they don't seem suitable for anyone else...

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#699 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Arve Hjønnevåg

Hi!

Quoted 17 lines
Quoted 4 lines

 Arguably, though, this isn't the only possible way to implement a mechanism allowing the system to be suspended automatically when it appears to be inactive.

Quoted 12 lines

Namely, one can use a user space power manager for this purpose and actually the OLPC project has been doing that successfully for some time, which clearly demonstrates that the Android approach to this problem is not the only one possible.  Moreover, the kernel's system suspend (or hibernate for that matter) code has not been designed to be started from within the kernel.  It's been designed to allow a privileged user space process to request the kernel to put the system into a sleep state at any given time regardless of what the other user space processes are doing.  While it can be started from within the kernel, this isn't particularly nice and, in the Android case, starting it from within the kernel requires permission from multiple user space processes (given by not taking suspend blockers these processes are allowed to use).

Quoted 5 lines

Why is starting suspend from within the kernel not nice? Personally I think reentering suspend from within the kernel is nicer than being forced to wake up a user space thread for events that are fully handled within the kernel (for instance the battery monitor on the Nexus One).

For events that are fully handled within the kernel -- like battery monitor on Zaurus/spitz -- doing wakeup all the way to the userspace is not neccessary. But that's implementenation detail with no impact on user/kernel interface, and we are doing that today. (Or were doing that few releases ago; charging is broken on spitz just now).
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#700 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Arve Hjønnevåg

Hi!

Quoted 17 lines
Quoted 4 lines

 Arguably, though, this isn't the only possible way to implement a mechanism allowing the system to be suspended automatically when it appears to be inactive.

Quoted 12 lines

Namely, one can use a user space power manager for this purpose and actually the OLPC project has been doing that successfully for some time, which clearly demonstrates that the Android approach to this problem is not the only one possible.  Moreover, the kernel's system suspend (or hibernate for that matter) code has not been designed to be started from within the kernel.  It's been designed to allow a privileged user space process to request the kernel to put the system into a sleep state at any given time regardless of what the other user space processes are doing.  While it can be started from within the kernel, this isn't particularly nice and, in the Android case, starting it from within the kernel requires permission from multiple user space processes (given by not taking suspend blockers these processes are allowed to use).

Quoted 5 lines

Why is starting suspend from within the kernel not nice? Personally I think reentering suspend from within the kernel is nicer than being forced to wake up a user space thread for events that are fully handled within the kernel (for instance the battery monitor on the Nexus One).

For events that are fully handled within the kernel -- like battery monitor on Zaurus/spitz -- doing wakeup all the way to the userspace is not neccessary. But that's implementenation detail with no impact on user/kernel interface, and we are doing that today. (Or were doing that few releases ago; charging is broken on spitz just now).
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#784 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Pavel Machek
Quoted 12 lines · Pavel Machek

Hi!

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Think in terms of an ARM laptop. What good is opportunistic suspend if it's not going to help when the laptop is being used?

For when the laptop is not being used, presumably.

Or in time between keystrokes for most of the platform (backlight excepted). The Intel MID x86 devices are at the point that suspend/resume time on x86 is being hurt by the kernel rewriting smp alternatives as we go from 2 processors live to 1 and back.

Quoted 8 lines
Quoted 5 lines

Given that you are talking about going from 2 processors to 1 and back, I would guess that you are not actually talking about suspend/resume, which is a system-wide thing rather than a CPU-by-CPU thing. I am not sure whether you are using CPU hotplug or invoking SMP alternatives once all but one CPU is idle.

When entering system suspend, we disable non-boot-CPUs to simplify locking. We reenable them when going out of suspend.

Thank you for the info, Pavel!

So once you are down to one CPU, the last CPU shuts the system off, itself included? Or does the last CPU "run" in a deep idle state throughout suspend? (My guess is the former, and I am also curious whether the cache SRAMs are powered off, etc. But figured I should ask rather than guessing.)

Thanx, Paul

#785 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Pavel Machek
Quoted 12 lines · Pavel Machek

Hi!

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Think in terms of an ARM laptop. What good is opportunistic suspend if it's not going to help when the laptop is being used?

For when the laptop is not being used, presumably.

Or in time between keystrokes for most of the platform (backlight excepted). The Intel MID x86 devices are at the point that suspend/resume time on x86 is being hurt by the kernel rewriting smp alternatives as we go from 2 processors live to 1 and back.

Quoted 8 lines
Quoted 5 lines

Given that you are talking about going from 2 processors to 1 and back, I would guess that you are not actually talking about suspend/resume, which is a system-wide thing rather than a CPU-by-CPU thing. I am not sure whether you are using CPU hotplug or invoking SMP alternatives once all but one CPU is idle.

When entering system suspend, we disable non-boot-CPUs to simplify locking. We reenable them when going out of suspend.

Thank you for the info, Pavel!

So once you are down to one CPU, the last CPU shuts the system off, itself included? Or does the last CPU "run" in a deep idle state throughout suspend? (My guess is the former, and I am also curious whether the cache SRAMs are powered off, etc. But figured I should ask rather than guessing.)

Thanx, Paul

#786 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 6 lines · On Sat, 14 Aug 2010 08:10:48 -0700 "Paul E. McKenney"…

So once you are down to one CPU, the last CPU shuts the system off, itself included? Or does the last CPU "run" in a deep idle state throughout suspend? (My guess is the former, and I am also curious whether the cache SRAMs are powered off, etc. But figured I should ask rather than guessing.)

they tend to go "off".

however I think you're making an assumption that there is a real difference between a deep idle state and "off"....

For modern x86 hardware, that assumption isn't really valid. (other than a very very small sram that stores register content in the idle case)

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#794 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Paul E. McKenney
Quoted 6 lines · On Sat, 14 Aug 2010 08:10:48 -0700 "Paul E. McKenney"…

So once you are down to one CPU, the last CPU shuts the system off, itself included? Or does the last CPU "run" in a deep idle state throughout suspend? (My guess is the former, and I am also curious whether the cache SRAMs are powered off, etc. But figured I should ask rather than guessing.)

they tend to go "off".

however I think you're making an assumption that there is a real difference between a deep idle state and "off"....

For modern x86 hardware, that assumption isn't really valid. (other than a very very small sram that stores register content in the idle case)

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#787 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Arjan van de Ven
Quoted 5 lines · Arjan van de Ven

however I think you're making an assumption
that there is a real difference between a deep idle state and "off"....

For modern x86 hardware, that assumption isn't
really valid.

For ARM processors it's not unrealistic. THey
tend to have idle states that place constraints on
peripherals and clocks which allow peripherals to run independently of CPUs.

I recall for example various processors that allow
USB to continue operating in one or more idle states, if the right clocks are active (and RAM). Similarly with some other peripherals. It may be
desirable to have I/O active while CPUs are idle.

Not all low power states map to x86/ACPI models;
and Linux hasn't accomodated that reality well.

#788 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Arjan van de Ven
Quoted 5 lines · Arjan van de Ven

however I think you're making an assumption
that there is a real difference between a deep idle state and "off"....

For modern x86 hardware, that assumption isn't
really valid.

For ARM processors it's not unrealistic. THey
tend to have idle states that place constraints on
peripherals and clocks which allow peripherals to run independently of CPUs.

I recall for example various processors that allow
USB to continue operating in one or more idle states, if the right clocks are active (and RAM). Similarly with some other peripherals. It may be
desirable to have I/O active while CPUs are idle.

Not all low power states map to x86/ACPI models;
and Linux hasn't accomodated that reality well.

#789 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Arjan van de Ven
Quoted 9 lines · Arjan van de Ven
Quoted 6 lines · On Sat, 14 Aug 2010 08:10:48 -0700 "Paul E. McKenney"…

So once you are down to one CPU, the last CPU shuts the system off, itself included? Or does the last CPU "run" in a deep idle state throughout suspend? (My guess is the former, and I am also curious whether the cache SRAMs are powered off, etc. But figured I should ask rather than guessing.)

Quoted 8 lines

they tend to go "off".

however I think you're making an assumption that there is a real difference between a deep idle state and "off"....

For modern x86 hardware, that assumption isn't really valid. (other than a very very small sram that stores register content in the idle case)

I am and have been taking you at your word that some systems can reach power levels while idle that rival suspended/off. The differences between idle and suspend are instead semantic, have been posted here more than once, and make themselves felt when the non-suspended system is non-idle, even for systems whose deep-idle power approximates that of suspend/off.

Thanx, Paul

#790 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Arjan van de Ven
Quoted 9 lines · Arjan van de Ven
Quoted 6 lines · On Sat, 14 Aug 2010 08:10:48 -0700 "Paul E. McKenney"…

So once you are down to one CPU, the last CPU shuts the system off, itself included? Or does the last CPU "run" in a deep idle state throughout suspend? (My guess is the former, and I am also curious whether the cache SRAMs are powered off, etc. But figured I should ask rather than guessing.)

Quoted 8 lines

they tend to go "off".

however I think you're making an assumption that there is a real difference between a deep idle state and "off"....

For modern x86 hardware, that assumption isn't really valid. (other than a very very small sram that stores register content in the idle case)

I am and have been taking you at your word that some systems can reach power levels while idle that rival suspended/off. The differences between idle and suspend are instead semantic, have been posted here more than once, and make themselves felt when the non-suspended system is non-idle, even for systems whose deep-idle power approximates that of suspend/off.

Thanx, Paul

#712 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Pavel Machek
Quoted 15 lines · Pavel Machek
Quoted 14 lines · Ted Ts'o
Quoted 9 lines · Felipe Contreras

The question is why are we adding a user-space API that:
1) no user-space beside Android has expresses interest in implementing
2) is dubious whether the benefits are worth the pain for non-Android
user-space
3) will become less and less attractive as dynamic PM gets closer to
the sweet-spot, and then surpass it
4) Android can keep in a separate tree until it's clear in the linux
community that it's useful (if it ever happens)

So, Felipe,

Do you believe you speak for all of LKML?

[...]

Quoted 1 line

And yes, for the record Felipe speaks for me pretty well.

Not that I´m as "valuable" as the others quoted above: I have the same impression.

Quoted 11 lines

Normal path of merging stuff to the kernel is

"Google develops it, then modifies it to address the review comments, then it is merged, then it is deployed".

Unfortunately what Google did here is:

"Google develops it behind the closed door, then deploys it. When asked for changes, Google expects someone else to create system compatible with their existing solution, or else their patches being merged."

That basically sums it up as far as I see.

Bernd

Signature · 7 lines
Bernd Petrovitsch                  Email : [email protected]
                     LUGA : http://www.luga.at

_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#713 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Pavel Machek
Quoted 15 lines · Pavel Machek
Quoted 14 lines · Ted Ts'o
Quoted 9 lines · Felipe Contreras

The question is why are we adding a user-space API that:
1) no user-space beside Android has expresses interest in implementing
2) is dubious whether the benefits are worth the pain for non-Android
user-space
3) will become less and less attractive as dynamic PM gets closer to
the sweet-spot, and then surpass it
4) Android can keep in a separate tree until it's clear in the linux
community that it's useful (if it ever happens)

So, Felipe,

Do you believe you speak for all of LKML?

[...]

Quoted 1 line

And yes, for the record Felipe speaks for me pretty well.

Not that I´m as "valuable" as the others quoted above: I have the same impression.

Quoted 11 lines

Normal path of merging stuff to the kernel is

"Google develops it, then modifies it to address the review comments, then it is merged, then it is deployed".

Unfortunately what Google did here is:

"Google develops it behind the closed door, then deploys it. When asked for changes, Google expects someone else to create system compatible with their existing solution, or else their patches being merged."

That basically sums it up as far as I see.

Bernd

Signature · 2 lines
Bernd Petrovitsch                  Email : [email protected]
                     LUGA : http://www.luga.at
#714 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Pavel Machek
Quoted 26 lines · On Sat, 14 Aug 2010 09:50:00 +0200 Pavel Machek <[email protected]> wrote:
Quoted 13 lines · Ted Ts'o
Quoted 9 lines · Felipe Contreras

The question is why are we adding a user-space API that:
1) no user-space beside Android has expresses interest in implementing
2) is dubious whether the benefits are worth the pain for non-Android
user-space
3) will become less and less attractive as dynamic PM gets closer to
the sweet-spot, and then surpass it
4) Android can keep in a separate tree until it's clear in the linux
community that it's useful (if it ever happens)

So, Felipe,

Quoted 8 lines

Do you believe you speak for all of LKML?

Are you willing to tell ZDNet and the Slashdot fanboys that it's OK for Suspend blockers to live in a separate tree, and it's not a case of OMG! Google is forking the kernel?

If you could speak out a passionately on those forums as you have here, that would be great.

Ted, what is going on here? Are you suggesting people disagreeing with Google patches suddenly have to do advocacy for Google?

Quoted 6 lines

And yes, for the record Felipe speaks for me pretty well.

Normal path of merging stuff to the kernel is

"Google develops it, then modifies it to address the review comments, then it is merged, then it is deployed".

Pavel, you should know better than this. You've been working on Linux long enough to know that development doesn't happen this way.

It's far more common (and prudent, business-wise) for companies to develop changes against upstream Linux, ship them, and then try to get them or something like them integrated upstream. This often works fine, but big problems arise when either the company in question doesn't bother to ever push upstream (Linux loses out on support for a given feature or hardware) or ships changes that have very little chance of getting upstream (we end up with a fork).

Quoted 6 lines

Unfortunately what Google did here is:

"Google develops it behind the closed door, then deploys it. When asked for changes, Google expects someone else to create system compatible with their existing solution, or else their patches being merged."

Although it would have been nice for Google to work more directly with upstream on their suspend blockers for Android, I don't think they could have made their product development cycle a slave to the politics of upstream development.

Fortunately in this case the problem doesn't seem to be fatal. We've already established that the userland API portion of suspend blockers could be implemented in userspace with a bit more work, given that the kernel problems with suspend/resume and events are addressed. Hopefully Google is already developing a prototype userspace implementation to make sure it's workable; being able to build stock upstream kernels for my Droid and its Android userspace sure would be nice.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#715 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Pavel Machek
Quoted 26 lines · On Sat, 14 Aug 2010 09:50:00 +0200 Pavel Machek <[email protected]> wrote:
Quoted 13 lines · Ted Ts'o
Quoted 9 lines · Felipe Contreras

The question is why are we adding a user-space API that:
1) no user-space beside Android has expresses interest in implementing
2) is dubious whether the benefits are worth the pain for non-Android
user-space
3) will become less and less attractive as dynamic PM gets closer to
the sweet-spot, and then surpass it
4) Android can keep in a separate tree until it's clear in the linux
community that it's useful (if it ever happens)

So, Felipe,

Quoted 8 lines

Do you believe you speak for all of LKML?

Are you willing to tell ZDNet and the Slashdot fanboys that it's OK for Suspend blockers to live in a separate tree, and it's not a case of OMG! Google is forking the kernel?

If you could speak out a passionately on those forums as you have here, that would be great.

Ted, what is going on here? Are you suggesting people disagreeing with Google patches suddenly have to do advocacy for Google?

Quoted 6 lines

And yes, for the record Felipe speaks for me pretty well.

Normal path of merging stuff to the kernel is

"Google develops it, then modifies it to address the review comments, then it is merged, then it is deployed".

Pavel, you should know better than this. You've been working on Linux long enough to know that development doesn't happen this way.

It's far more common (and prudent, business-wise) for companies to develop changes against upstream Linux, ship them, and then try to get them or something like them integrated upstream. This often works fine, but big problems arise when either the company in question doesn't bother to ever push upstream (Linux loses out on support for a given feature or hardware) or ships changes that have very little chance of getting upstream (we end up with a fork).

Quoted 6 lines

Unfortunately what Google did here is:

"Google develops it behind the closed door, then deploys it. When asked for changes, Google expects someone else to create system compatible with their existing solution, or else their patches being merged."

Although it would have been nice for Google to work more directly with upstream on their suspend blockers for Android, I don't think they could have made their product development cycle a slave to the politics of upstream development.

Fortunately in this case the problem doesn't seem to be fatal. We've already established that the userland API portion of suspend blockers could be implemented in userspace with a bit more work, given that the kernel problems with suspend/resume and events are addressed. Hopefully Google is already developing a prototype userspace implementation to make sure it's workable; being able to build stock upstream kernels for my Droid and its Android userspace sure would be nice.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#791 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Arjan van de Ven
Quoted 8 lines · Arjan van de Ven

they tend to go "off".

however I think you're making an assumption that there is a real difference between a deep idle state and "off"....

For modern x86 hardware, that assumption isn't really valid. (other than a very very small sram that stores register content in the idle case)

Really? I thought the TSC stopped in suspend. Does having a package go into C6 mean that the RAM goes into self-refresh?

Signature · 1 line
Matthew Garrett | [email protected]
#792 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Arjan van de Ven
Quoted 8 lines · Arjan van de Ven

they tend to go "off".

however I think you're making an assumption that there is a real difference between a deep idle state and "off"....

For modern x86 hardware, that assumption isn't really valid. (other than a very very small sram that stores register content in the idle case)

Really? I thought the TSC stopped in suspend. Does having a package go into C6 mean that the RAM goes into self-refresh?

Signature · 1 line
Matthew Garrett | [email protected]
#288 lore raw

Re: Wakeup-events implementation

In reply to Arve Hjønnevåg
Quoted 9 lines · Arve Hjønnevåg
Quoted 9 lines

Rafael and I spent some time discussing all this during LinuxCon. Combining what he thought with my own ideas led us to decide that the wakeup information should be stored in a separate structure, not in dev_pm_info.  These structures will be allocated dynamically when a device is enabled for remote wakeup (and presumably deallocated if a device is disabled for remote wakeup).  A pointer to the new structure will be stored in dev_pm_info.  We expect that most devices won't need a wakeup structure, because most devices aren't wakeup sources.

Quoted 6 lines
Quoted 3 lines

This new structure (as yet unnamed) will be a lot like your suspend_blocker structure, but with some differences.  It won't need a name, since the device already has a name.

A name is still useful if we allocate multiple handles per device (see below for why one handle per device is not enough).

Are the input queues are the only place where this is needed?

And BTW, I'm puzzled with regard to something you wrote earlier:

Quoted 8 lines
Quoted 5 lines

... I can see how relying on devices alone
wouldn't give enough information. There could be two separate programs both reading input events, and you wouldn't know which one was responsible for failing to drain its queue.

We don't know which one now either since we don't give them unique names, but we know that one of them is not reading (and it is usually not the normal input path).

If you don't keep track of the input queues by name, why do you need a separate wakeup structure for each queue?

Quoted 8 lines
Quoted 2 lines

 It won't have a timer, if
we can get away with leaving one out.

The suspend_blocker structure does not have a timer, it has a timeout. This was intentional, since it avoids unnecessary timers from firing but it also means it takes a lot less space than the stats. We do need the timeout in the structure to support some of our drivers since they mix wake_lock_timeout and wake_unlock.

A timeout is okay.

Quoted 6 lines
Quoted 4 lines

The device argument will become mandatory for pm_stay_awake, pm_relax, and pm_wakeup_event, so that the counter fields can be updated properly.

I think this is a step in the right direction, but it is not enough to support mixing timeouts and pm_relax in all the drivers.

We'll figure out the best approach. You mentioned that when the timeouts and pm_relax do get mixed, the timeout value is around 1 or 2 seconds. For these cases, would it be so terrible just to use the timeout alone and forget about pm_relax?

Quoted 7 lines

Maintaining an out of mainline driver to export allow user space to block suspend seems like a more appealing solution than adding another process for everyone to depend on. Having a user space interface to block suspend in the mainline kernel would still be valuable, though. Like I mentioned in another message, this would allow some low level services, like the user-space battery monitor some devices have, to not be android specific.

Adding out-of-mainline drivers is of course always possible. As for your second point, I guess it's a matter of perspective. You see the kernel as always trying to suspend, with userspace needing to do something special to keep it awake. Rafael and I see it as userspace occasionally asking the kernel to suspend, and the kernel delaying or aborting if a wakeup event occurs. This is because we believe that suspends should be initiated by userspace, not by the kernel. From our point of view there doesn't have to be a user interface to block suspends; you only need a way for one part of userspace to tell another to stop requesting a suspend.

This could become non-Android-specific as well, if people decide on some standard way for system management programs to decide when the system should go to sleep.

Quoted 8 lines
Quoted 7 lines

In the end, the best answer may be to keep a count of pending wakeup events in the new wakeup structure (as well as a global count of the number of devices whose pending count is > 0).  Then pm_stay_awake would increment the count, pm_relax would decrement it, and there could be a variant of pm_stay_awake that would increment the count only if it was currently equal to 0.

Quoted 7 lines

If I correctly understand what you are suggesting, that does not work. If two subsystems use the same device an one of them expects the pm_stay_awake call to be nested and the other one does not, then the subsystem that uses the non-nested api is not preventing suspend if the other subsystem was preventing suspend when it called pm_stay_awake_if_not_zero (the non-nested pm_relax variant would cause similar problems).

Do you have any examples where two subsystems use the same device but with differing expectations? In the examples I can think of, the non-nesting call is used only when a wakeup request is received (which happens only when the device is at low power), so the nesting calls can't interfere.

Quoted 4 lines

Also, to support all our existing drivers we need
multiple handles per device. For each input device we have a wakelock with a timeout per client. We only allow suspend when all the clients have emptied their queue or had their wakelock timeout.

We may end up attaching these wakeup structures not just to devices but also to input queues (or other kernel->userspace communication channels).

Quoted 17 lines
Quoted 2 lines

Bugs in the kernel can be tracked down and fixed.

Yes, bugs can be fixed, but not all bugs are discovered quickly and products ship before some bugs are fixed. For instance, when applying our patch that holds a wakelock when the input queue is not empty to this weeks kernel, I noticed that someone had fixed a bug where a queue overflow could leave the queue empty. If you hit this bug with the wakelock with timeout implementation that we currently use, then it would cause suspend to be blocked for 5 seconds (less if another event occurred or the file descriptor was closed). With the patch that uses a suspend blocker without a timeout, it would block suspend until another event from the same device occurred or user space closes the device. With a nesting api like the current pm_stay_awake/pm_relax, it will prevent suspend forever (unless another driver has the opposite bug).

Quoted 3 lines

Do we need the nested api for something? We need a non-nested api to mix timeouts and pm_relax, and unless we need the nested variants, it is easier to just make all the calls non-nesting.

Here's an example where nested pm_stay_awake calls are needed. Suppose a USB root hub is enabled for wakeup (in other words, plugging or unplugging a USB device into the computer should wake the system up). Suppose the root hub is at low power (autosuspended) when a wakeup event occurs. The interrupt handler calls pm_stay_awake and indirectly invokes the USB runtime-resume routine. This routine brings the root hub back to full power, informs the hub driver, and then calls pm_relax.

But the hub driver carries out its main work in a separate kernel thread (i.e., khubd). So the hub_resume routine has to call pm_stay_awake, and then khubd calls pm_relax when it is finished processing the root hub's event. Thus we end up with:

usb_runtime_resume: call pm_stay_awake (1)
call hub_resume
hub_resume: call pm_stay_awake (2)
usb_runtime_resume: call pm_relax (balances 1)
khubd: call pm_relax (balances 2)

As you can see, this won't work right if the pm wakeup calls aren't cumulative. ("Nested" isn't quite the right word.) The system would be allowed to sleep before khubd could process the root hub's wakeup event.

Alan Stern

#777 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to James Bottomley
Quoted 49 lines · James Bottomley
Quoted 20 lines · Ted Ts'o
Quoted 11 lines · James Bottomley

The facts are that suspend blockers identifies a race within our suspend to ram system that permeates from top to bottom (that's from server to mobile). The problem is that resume events are racy with respect to suspend and vice versa. This manifests itself most annoyingly on my laptop in the "double suspend" case: where I suspend with a pending suspend event, my laptop will resume and then immediately re-suspend (leading me to kick myself and remind myself to check it stayed up before pushing unsuspend and walking away). The other annoying case is that if I accidentally close the lid before presenting, I have to wait until the system is fully down before pressing resume.

This is all true, but it's also only one aspect of the problem. I agree with you that this is the part of the problem which affects Linux at all scales, from Cloud servers in a data center that want to suspend themselves when there's no work to do (and then fail to respond to the WOL packet) to mobile platforms that are suspending much more frequently.

Quoted 8 lines

However, it doesn't follow that this is the _only_ problem that the Android folks might be interested in solving. Opportunistic suspend is a different part of the problem space, which is generally believed by the Android developers as being far more efficient than a user-space suspend manager. Rafael has stated his complete unwillingness to deal with this part of the problem. OK, so that probably means that for Android, it will have to be an out-of-tree kernel patch.

OK, so I tried desperately to avoid the question of whether opportunistic suspend is a good way of managing power. However, it seems to me that it is in use by several systems (android, olpc, etc). I'll defer the question of whether it's better in user space or kernel space to Rafael's investigations ... but I will point out that the kernel space patch, once the suspend blockers issue is taken care of looks like a single patch to one file, so should be locally containable and should allow upstream to be useful as the driver base again.

Quoted 10 lines

The question, then, is whether a solution which addresses the only part of the problem which Rafael is interested in dealing with at this point, is sufficient such that (a) the kernel-level opportunistic suspend can be done as an out-of-tree patch, while simultaneously (b) allowing device drivers for Android devices can utilize Rafael's interfaces to solve the race design bug currently found in our suspend subsystem, while (c) requiring minimal changes to the Android userspace, and (d) providing all of the statistics and debugging functionality required by the Android userspace.

Quoted 4 lines
Quoted 2 lines

If we can engineer a solution which meets (a), (b), (c), and (d) above, then everyone will be happy.

That's my goal.

In fact, we (which means basically Alan Stern and me at this point) are working with Arve on this right now.

Thanks,
Rafael

#778 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

In reply to James Bottomley
Quoted 49 lines · James Bottomley
Quoted 20 lines · Ted Ts'o
Quoted 11 lines · James Bottomley

The facts are that suspend blockers identifies a race within our suspend to ram system that permeates from top to bottom (that's from server to mobile). The problem is that resume events are racy with respect to suspend and vice versa. This manifests itself most annoyingly on my laptop in the "double suspend" case: where I suspend with a pending suspend event, my laptop will resume and then immediately re-suspend (leading me to kick myself and remind myself to check it stayed up before pushing unsuspend and walking away). The other annoying case is that if I accidentally close the lid before presenting, I have to wait until the system is fully down before pressing resume.

This is all true, but it's also only one aspect of the problem. I agree with you that this is the part of the problem which affects Linux at all scales, from Cloud servers in a data center that want to suspend themselves when there's no work to do (and then fail to respond to the WOL packet) to mobile platforms that are suspending much more frequently.

Quoted 8 lines

However, it doesn't follow that this is the _only_ problem that the Android folks might be interested in solving. Opportunistic suspend is a different part of the problem space, which is generally believed by the Android developers as being far more efficient than a user-space suspend manager. Rafael has stated his complete unwillingness to deal with this part of the problem. OK, so that probably means that for Android, it will have to be an out-of-tree kernel patch.

OK, so I tried desperately to avoid the question of whether opportunistic suspend is a good way of managing power. However, it seems to me that it is in use by several systems (android, olpc, etc). I'll defer the question of whether it's better in user space or kernel space to Rafael's investigations ... but I will point out that the kernel space patch, once the suspend blockers issue is taken care of looks like a single patch to one file, so should be locally containable and should allow upstream to be useful as the driver base again.

Quoted 10 lines

The question, then, is whether a solution which addresses the only part of the problem which Rafael is interested in dealing with at this point, is sufficient such that (a) the kernel-level opportunistic suspend can be done as an out-of-tree patch, while simultaneously (b) allowing device drivers for Android devices can utilize Rafael's interfaces to solve the race design bug currently found in our suspend subsystem, while (c) requiring minimal changes to the Android userspace, and (d) providing all of the statistics and debugging functionality required by the Android userspace.

Quoted 4 lines
Quoted 2 lines

If we can engineer a solution which meets (a), (b), (c), and (d) above, then everyone will be happy.

That's my goal.

In fact, we (which means basically Alan Stern and me at this point) are working with Arve on this right now.

Thanks,
Rafael

#716 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Jesse Barnes
Quoted 8 lines · Jesse Barnes

Fortunately in this case the problem doesn't seem to be fatal. We've already established that the userland API portion of suspend blockers could be implemented in userspace with a bit more work, given that the kernel problems with suspend/resume and events are addressed. Hopefully Google is already developing a prototype userspace implementation to make sure it's workable; being able to build stock upstream kernels for my Droid and its Android userspace sure would be nice.

You know, you don't have to wait for the Android engineers to do this work. You (or others who want to be able to use stock upstream kernel with Android devices) could just as easily try to do the "bit more work" yourselves --- that is, do the open souce thing and scratch one's own itch.

After all, Rafael is saying he's refusing to accept patches (or implement) in-kernel oppunsitic suspend for upstream unless it's proven to him that a userspace implementation isn't sufficient. It might be just as fair for the Android userspace upstream to refuse to accept (or engineer) userspace changes unless it is proven that the userspace version of opporunistic suspend is just as good as the in-kernel version which is successfully been deployed in millions and millions of shipping units today...

Speaking personally, it's not clear to me how waking up a userspace suspend daemon and waiting for it to get scheduled will result in better power savings than simply handling it in the kernel, but as soon as someone is willing to do the work, we can find out for sure who is right.

- Ted

#717 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Jesse Barnes
Quoted 8 lines · Jesse Barnes

Fortunately in this case the problem doesn't seem to be fatal. We've already established that the userland API portion of suspend blockers could be implemented in userspace with a bit more work, given that the kernel problems with suspend/resume and events are addressed. Hopefully Google is already developing a prototype userspace implementation to make sure it's workable; being able to build stock upstream kernels for my Droid and its Android userspace sure would be nice.

You know, you don't have to wait for the Android engineers to do this work. You (or others who want to be able to use stock upstream kernel with Android devices) could just as easily try to do the "bit more work" yourselves --- that is, do the open souce thing and scratch one's own itch.

After all, Rafael is saying he's refusing to accept patches (or implement) in-kernel oppunsitic suspend for upstream unless it's proven to him that a userspace implementation isn't sufficient. It might be just as fair for the Android userspace upstream to refuse to accept (or engineer) userspace changes unless it is proven that the userspace version of opporunistic suspend is just as good as the in-kernel version which is successfully been deployed in millions and millions of shipping units today...

Speaking personally, it's not clear to me how waking up a userspace suspend daemon and waiting for it to get scheduled will result in better power savings than simply handling it in the kernel, but as soon as someone is willing to do the work, we can find out for sure who is right.

- Ted

#289 lore raw

Re: Wakeup-events implementation

In reply to Alan Stern

2010/8/16 Alan Stern <[email protected]>:

Quoted 11 lines · Arve Hjønnevåg
Quoted 10 lines
Quoted 10 lines

Rafael and I spent some time discussing all this during LinuxCon. Combining what he thought with my own ideas led us to decide that the wakeup information should be stored in a separate structure, not in dev_pm_info.  These structures will be allocated dynamically when a device is enabled for remote wakeup (and presumably deallocated if a device is disabled for remote wakeup).  A pointer to the new structure will be stored in dev_pm_info.  We expect that most devices won't need a wakeup structure, because most devices aren't wakeup sources.

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

This new structure (as yet unnamed) will be a lot like your suspend_blocker structure, but with some differences.  It won't need a name, since the device already has a name.

A name is still useful if we allocate multiple handles per device (see below for why one handle per device is not enough).

Are the input queues are the only place where this is needed?

I don't know if it is the only place that is using more than one wakelock with a timeout per device. There are other drivers that use more than one wakelock, but it is possible they could use a single nested lock instead (with some detail loss in the the stats). I'm not sure every wakelock can be associated with a device though. For instance the mmc core wakelock does not have a corresponding device.

Quoted 7 lines

And BTW, I'm puzzled with regard to something you wrote earlier:

Quoted 5 lines
Quoted 5 lines

... I can see how relying on devices alone
wouldn't give enough information.  There could be two separate programs both reading input events, and you wouldn't know which one was responsible for failing to drain its queue.

Quoted 7 lines
Quoted 3 lines

We don't know which one now either since we don't give them unique names, but we know that one of them is not reading (and it is usually not the normal input path).

If you don't keep track of the input queues by name, why do you need a separate wakeup structure for each queue?

Primarily for the timeouts, but the individual stats are still useful even if they don't name the client.

Quoted 15 lines
Quoted 8 lines
Quoted 2 lines

 It won't have a timer, if
we can get away with leaving one out.

The suspend_blocker structure does not have a timer, it has a timeout. This was intentional, since it avoids unnecessary timers from firing but it also means it takes a lot less space than the stats. We do need the timeout in the structure to support some of our drivers since they mix wake_lock_timeout and wake_unlock.

A timeout is okay.

Quoted 4 lines
Quoted 4 lines

The device argument will become mandatory for pm_stay_awake, pm_relax, and pm_wakeup_event, so that the counter fields can be updated properly.

Quoted 8 lines
Quoted 2 lines

I think this is a step in the right direction, but it is not enough to support mixing timeouts and pm_relax in all the drivers.

We'll figure out the best approach.  You mentioned that when the timeouts and pm_relax do get mixed, the timeout value is around 1 or 2 seconds.  For these cases, would it be so terrible just to use the timeout alone and forget about pm_relax?

The timeout used when mixing timeouts and wake_unlock are generally longer than when only using only timeouts since the timeouts are used to cover edge cases were wake_unlock did not get called. Allowing timeouts and pm_relax to be mixed may allow a gradual path from using timeouts to block suspend only when needed (timeouts only -> timeouts for edge cases -> no timeouts).

We have also had bugs, where sensors generate input events whenever the system is not suspended. The 5 second timeout we have on input events is not short enough to allow the system to suspend at all in this case.

Quoted 8 lines
Quoted 7 lines

Maintaining an out of mainline driver to export allow user space to block suspend seems like a more appealing solution than adding another process for everyone to depend on. Having a user space interface to block suspend in the mainline kernel would still be valuable, though. Like I mentioned in another message, this would allow some low level services, like the user-space battery monitor some devices have, to not be android specific.

Quoted 4 lines

Adding out-of-mainline drivers is of course always possible.  As for your second point, I guess it's a matter of perspective.  You see the kernel as always trying to suspend, with userspace needing to do something special to keep it awake.

I see the kernel as trying to suspend if user space asked it to suspend (until it user space asks the kernel to stop suspending). Wakeup events that don't reach user space should not need user space support to reenter suspend.

Quoted 4 lines

 Rafael and I see it as userspace
occasionally asking the kernel to suspend, and the kernel delaying or aborting if a wakeup event occurs.  This is because we believe that suspends should be initiated by userspace, not by the kernel.

You want each suspend attempt to be initiated by user space. Suspend is initiated from user space in both cases, the difference is that you want the suspend request to be one-shot, which means that the kernel may cancel the user space suspend request, where I want user space to explicitly cancel the request.

Quoted 5 lines

 From our
point of view there doesn't have to be a user interface to block suspends; you only need a way for one part of userspace to tell another to stop requesting a suspend.

The user space interface to block suspend is not all that relevant here. Both suspend interfaces can be used with or without a user space interface to block suspend.

Quoted 20 lines

This could become non-Android-specific as well, if people decide on some standard way for system management programs to decide when the system should go to sleep.

Quoted 8 lines
Quoted 7 lines

In the end, the best answer may be to keep a count of pending wakeup events in the new wakeup structure (as well as a global count of the number of devices whose pending count is > 0).  Then pm_stay_awake would increment the count, pm_relax would decrement it, and there could be a variant of pm_stay_awake that would increment the count only if it was currently equal to 0.

Quoted 7 lines

If I correctly understand what you are suggesting, that does not work. If two subsystems use the same device an one of them expects the pm_stay_awake call to be nested and the other one does not, then the subsystem that uses the non-nested api is not preventing suspend if the other subsystem was preventing suspend when it called pm_stay_awake_if_not_zero (the non-nested pm_relax variant would cause similar problems).

Quoted 6 lines

Do you have any examples where two subsystems use the same device but with differing expectations?  In the examples I can think of, the non-nesting call is used only when a wakeup request is received (which happens only when the device is at low power), so the nesting calls can't interfere.

The wakeup request need to block suspend until the driver has seen the event. If the driver and the wakeup code uses the same handle how can you avoid interference?

Quoted 9 lines
Quoted 4 lines

Also, to support all our existing drivers we need
multiple handles per device. For each input device we have a wakelock with a timeout per client. We only allow suspend when all the clients have emptied their queue or had their wakelock timeout.

We may end up attaching these wakeup structures not just to devices but also to input queues (or other kernel->userspace communication channels).

That is we do now (with wakelocks), but I think we need to pass this handle to the pm_stay_wake... calls, and not the device, for this to work.

Quoted 41 lines
Quoted 17 lines
Quoted 2 lines

Bugs in the kernel can be tracked down and fixed.

Yes, bugs can be fixed, but not all bugs are discovered quickly and products ship before some bugs are fixed. For instance, when applying our patch that holds a wakelock when the input queue is not empty to this weeks kernel, I noticed that someone had fixed a bug where a queue overflow could leave the queue empty. If you hit this bug with the wakelock with timeout implementation that we currently use, then it would cause suspend to be blocked for 5 seconds (less if another event occurred or the file descriptor was closed). With the patch that uses a suspend blocker without a timeout, it would block suspend until another event from the same device occurred or user space closes the device. With a nesting api like the current pm_stay_awake/pm_relax, it will prevent suspend forever (unless another driver has the opposite bug).

Quoted 3 lines

Do we need the nested api for something? We need a non-nested api to mix timeouts and pm_relax, and unless we need the nested variants, it is easier to just make all the calls non-nesting.

Here's an example where nested pm_stay_awake calls are needed. Suppose a USB root hub is enabled for wakeup (in other words, plugging or unplugging a USB device into the computer should wake the system up).  Suppose the root hub is at low power (autosuspended) when a wakeup event occurs.  The interrupt handler calls pm_stay_awake and indirectly invokes the USB runtime-resume routine.  This routine brings the root hub back to full power, informs the hub driver, and then calls pm_relax.

But the hub driver carries out its main work in a separate kernel thread (i.e., khubd).  So the hub_resume routine has to call pm_stay_awake, and then khubd calls pm_relax when it is finished processing the root hub's event.  Thus we end up with:

       usb_runtime_resume:     call pm_stay_awake (1) call hub_resume
               hub_resume:             call pm_stay_awake (2)
       usb_runtime_resume:     call pm_relax (balances 1)
       khubd:                  call pm_relax (balances 2)

Quoted 5 lines

As you can see, this won't work right if the pm wakeup calls aren't cumulative.  ("Nested" isn't quite the right word.)  The system would be allowed to sleep before khubd could process the root hub's wakeup event.

Too me this is an example of where two handles are needed, not where nesting is needed. Yes, you can use a single nested handle here, but the stats will not tell you which driver blocked suspend if there is a problem.

Signature · 1 line
Arve Hjønnevåg
#718 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 10 lines · On Mon, 16 Aug 2010 20:20:32 -0400 Ted Ts'o <[email protected]> wrote:
Quoted 8 lines · Jesse Barnes

Fortunately in this case the problem doesn't seem to be fatal. We've already established that the userland API portion of suspend blockers could be implemented in userspace with a bit more work, given that the kernel problems with suspend/resume and events are addressed. Hopefully Google is already developing a prototype userspace implementation to make sure it's workable; being able to build stock upstream kernels for my Droid and its Android userspace sure would be nice.

Quoted 5 lines

You know, you don't have to wait for the Android engineers to do this work. You (or others who want to be able to use stock upstream kernel with Android devices) could just as easily try to do the "bit more work" yourselves --- that is, do the open souce thing and scratch one's own itch.

Sure, I could. And the Google guys could put together a whole Debian distro with suspend blockers sprinkled throughout various apps. But for my part, I can't justify that kind of work at the moment. Of course I'd be happy if someone could and did do the work, it would be a useful exercise and potentially allow Android to work well on stock kernels.

Quoted 9 lines

After all, Rafael is saying he's refusing to accept patches (or implement) in-kernel oppunsitic suspend for upstream unless it's proven to him that a userspace implementation isn't sufficient. It might be just as fair for the Android userspace upstream to refuse to accept (or engineer) userspace changes unless it is proven that the userspace version of opporunistic suspend is just as good as the in-kernel version which is successfully been deployed in millions and millions of shipping units today...

Quoted 5 lines

Speaking personally, it's not clear to me how waking up a userspace suspend daemon and waiting for it to get scheduled will result in better power savings than simply handling it in the kernel, but as soon as someone is willing to do the work, we can find out for sure who is right.

Yeah it would add some overhead, since suspend blocker calls would use IPC to a userspace daemon, which would also be responsible for (periodically?) waking up to see if the system ought to be suspended... I agree coding it up would be a useful exercise.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#719 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 10 lines · On Mon, 16 Aug 2010 20:20:32 -0400 Ted Ts'o <[email protected]> wrote:
Quoted 8 lines · Jesse Barnes

Fortunately in this case the problem doesn't seem to be fatal. We've already established that the userland API portion of suspend blockers could be implemented in userspace with a bit more work, given that the kernel problems with suspend/resume and events are addressed. Hopefully Google is already developing a prototype userspace implementation to make sure it's workable; being able to build stock upstream kernels for my Droid and its Android userspace sure would be nice.

Quoted 5 lines

You know, you don't have to wait for the Android engineers to do this work. You (or others who want to be able to use stock upstream kernel with Android devices) could just as easily try to do the "bit more work" yourselves --- that is, do the open souce thing and scratch one's own itch.

Sure, I could. And the Google guys could put together a whole Debian distro with suspend blockers sprinkled throughout various apps. But for my part, I can't justify that kind of work at the moment. Of course I'd be happy if someone could and did do the work, it would be a useful exercise and potentially allow Android to work well on stock kernels.

Quoted 9 lines

After all, Rafael is saying he's refusing to accept patches (or implement) in-kernel oppunsitic suspend for upstream unless it's proven to him that a userspace implementation isn't sufficient. It might be just as fair for the Android userspace upstream to refuse to accept (or engineer) userspace changes unless it is proven that the userspace version of opporunistic suspend is just as good as the in-kernel version which is successfully been deployed in millions and millions of shipping units today...

Quoted 5 lines

Speaking personally, it's not clear to me how waking up a userspace suspend daemon and waiting for it to get scheduled will result in better power savings than simply handling it in the kernel, but as soon as someone is willing to do the work, we can find out for sure who is right.

Yeah it would add some overhead, since suspend blocker calls would use IPC to a userspace daemon, which would also be responsible for (periodically?) waking up to see if the system ought to be suspended... I agree coding it up would be a useful exercise.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#720 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 16 lines · On Mon, 16 Aug 2010 20:20:32 -0400 Ted Ts'o <[email protected]> wrote:
Quoted 8 lines · Jesse Barnes

Fortunately in this case the problem doesn't seem to be fatal. We've already established that the userland API portion of suspend blockers could be implemented in userspace with a bit more work, given that the kernel problems with suspend/resume and events are addressed. Hopefully Google is already developing a prototype userspace implementation to make sure it's workable; being able to build stock upstream kernels for my Droid and its Android userspace sure would be nice.

You know, you don't have to wait for the Android engineers to do this work. You (or others who want to be able to use stock upstream kernel with Android devices) could just as easily try to do the "bit more work" yourselves --- that is, do the open souce thing and scratch one's own itch.

Quoted 8 lines

After all, Rafael is saying he's refusing to accept patches (or implement) in-kernel oppunsitic suspend for upstream unless it's proven to him that a userspace implementation isn't sufficient. It might be just as fair for the Android userspace upstream to refuse to accept (or engineer) userspace changes unless it is proven that the userspace version of opporunistic suspend is just as good as the in-kernel version which is successfully been deployed in millions and millions of shipping units today...

Reminds me of the one of the first questions asked in a murder investigation (or so they say on TV)
Cui Bono??

Who benefits? Does Android benefit more by being able to use a standard kernel, or does Linux benefit more by being able to run Android without modification.

Currently it seems that only the lawyers^Wpeople who like arguing on lkml are gaining anything.

Maybe this is the first real fork of Linux - google might be rich enough to persist with it.

Quoted 6 lines

Speaking personally, it's not clear to me how waking up a userspace suspend daemon and waiting for it to get scheduled will result in better power savings than simply handling it in the kernel, but as soon as someone is willing to do the work, we can find out for sure who is right.

I'm surprised at this comment Ted!
Power saving is not the single supreme goal, yet you make it sound like it is.

It should be no surprise to anyone if the most maintainable solution uses a little more power than the most highly optimised solution. I think most of us would still prefer the more maintainable solution. However, if google sees a market opportunity for the minor optimisation of suspend-from-kernel rather than suspend-from-user-space, then it would seem they are welcome to it.

NeilBrown

#721 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Ted Ts'o
Quoted 16 lines · On Mon, 16 Aug 2010 20:20:32 -0400 Ted Ts'o <[email protected]> wrote:
Quoted 8 lines · Jesse Barnes

Fortunately in this case the problem doesn't seem to be fatal. We've already established that the userland API portion of suspend blockers could be implemented in userspace with a bit more work, given that the kernel problems with suspend/resume and events are addressed. Hopefully Google is already developing a prototype userspace implementation to make sure it's workable; being able to build stock upstream kernels for my Droid and its Android userspace sure would be nice.

You know, you don't have to wait for the Android engineers to do this work. You (or others who want to be able to use stock upstream kernel with Android devices) could just as easily try to do the "bit more work" yourselves --- that is, do the open souce thing and scratch one's own itch.

Quoted 8 lines

After all, Rafael is saying he's refusing to accept patches (or implement) in-kernel oppunsitic suspend for upstream unless it's proven to him that a userspace implementation isn't sufficient. It might be just as fair for the Android userspace upstream to refuse to accept (or engineer) userspace changes unless it is proven that the userspace version of opporunistic suspend is just as good as the in-kernel version which is successfully been deployed in millions and millions of shipping units today...

Reminds me of the one of the first questions asked in a murder investigation (or so they say on TV)
Cui Bono??

Who benefits? Does Android benefit more by being able to use a standard kernel, or does Linux benefit more by being able to run Android without modification.

Currently it seems that only the lawyers^Wpeople who like arguing on lkml are gaining anything.

Maybe this is the first real fork of Linux - google might be rich enough to persist with it.

Quoted 6 lines

Speaking personally, it's not clear to me how waking up a userspace suspend daemon and waiting for it to get scheduled will result in better power savings than simply handling it in the kernel, but as soon as someone is willing to do the work, we can find out for sure who is right.

I'm surprised at this comment Ted!
Power saving is not the single supreme goal, yet you make it sound like it is.

It should be no surprise to anyone if the most maintainable solution uses a little more power than the most highly optimised solution. I think most of us would still prefer the more maintainable solution. However, if google sees a market opportunity for the minor optimisation of suspend-from-kernel rather than suspend-from-user-space, then it would seem they are welcome to it.

NeilBrown

#779 lore raw

Re: [linux-pm] Attempted summary of suspend-blockers LKML thread, take three

In reply to Rafael J. Wysocki

Hi,

Quoted 1 line · ext Rafael J. Wysocki

On Saturday, August 14, 2010, James Bottomley wrote:

<snip>

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

The question, then, is whether a solution which addresses the only part of the problem which Rafael is interested in dealing with at this point, is sufficient such that (a) the kernel-level opportunistic suspend can be done as an out-of-tree patch, while simultaneously (b) allowing device drivers for Android devices can utilize Rafael's interfaces to solve the race design bug currently found in our suspend subsystem, while (c) requiring minimal changes to the Android userspace, and (d) providing all of the statistics and debugging functionality required by the Android userspace.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

If we can engineer a solution which meets (a), (b), (c), and (d) above, then everyone will be happy.

That's my goal.

In fact, we (which means basically Alan Stern and me at this point) are working with Arve on this right now.

At least for (d) we - Nokia - would be also interested as well to contribute, see [1].

In general it should help with keeping the solution more generic.

cheers, igor

[1]
https://lists.linux-foundation.org/pipermail/linux-pm/2010-August/028248.html

#703 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Jesse Barnes
Quoted 68 lines · Jesse Barnes
Quoted 23 lines · On Fri, 13 Aug 2010 05:28:21 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 15 lines · Jesse Barnes
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of? Seems like a chicken and egg problem. Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions. We've merged code one release or more before the new code gets used for example, which is fine IMO. What we don't want to see is some new drop of code added and abandoned, but you already knew that.

Quoted 6 lines

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape. Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable. So where's the git pull request already? :)

Quoted 3 lines

In fact my patch going in that direction has been merged already and that code will likely be extended to cover some needs and cases I didn't have in mind when I was preparing it.

Yeah, I like what you've done with dynamic power management, really good stuff (the approach is very similar to the one I used for vblank interrupt management in the drm layer).

Ted's point about providing the user with a way of knowing which apps are blocking things is a good one though, and doesn't seem too hard to add. It might even be possible to do it largely with scripts wrapping fuser and such.

Quoted 17 lines

However, having discussed the whole issue for many times and reconsidered it thoroughly, I think that it's inappropriate to identify the suspend blockers (or wakelocks) framework with the opportunistic suspend feature as proposed in the original submission of the "suspend blockers" patchset. IMO they really are not the same thing and while the suspend blockers framework is used by Android to implement opportunistic suspend, I don't really believe this is the right approach.

We really need something similar to suspend blockers to avoid races between a suspend process and wakeup events, but it isn't necessary to provide user space with an interface allowing it to use these things directly. Such an interface is only necessary in the specific implementation in which the system is suspended as soon as the number of "active" suspend blockers goes down to zero. Arguably, though, this isn't the only possible way to implement a mechanism allowing the system to be suspended automatically when it appears to be inactive.

Quoted 11 lines

Namely, one can use a user space power manager for this purpose and actually the OLPC project has been doing that successfully for some time, which clearly demonstrates that the Android approach to this problem is not the only one possible. Moreover, the kernel's system suspend (or hibernate for that matter) code has not been designed to be started from within the kernel. It's been designed to allow a privileged user space process to request the kernel to put the system into a sleep state at any given time regardless of what the other user space processes are doing. While it can be started from within the kernel, this isn't particularly nice and, in the Android case, starting it from within the kernel requires permission from multiple user space processes (given by not taking suspend blockers these processes are allowed to use).

Quoted 6 lines

Yes, I see your point. But I actually think this is a fairly minor distinction. In one case, a privileged app decides when to suspend the system, in the other case, one or more of several privileged apps decide when a suspend should not be allowed to occur. It's just a matter of where you want to put the code and where you want the complexity.

Well, that used to be my opinion before the whole discussion started, but now I think there's more to it.

First off, we need the "forced" suspend, initiated by writing to /sys/power/state, to work regardless of the "opportunistic" one. Now, the races between wakeup events and suspend process are also a problem for the "forced" suspend mechanism, so the fix should not be specific to "opportunistic" suspend. One could argue that that can be fixed by using wakelocks as proposed by the Android developers, but this is not the case, because there's no way to disinguish wakelocks taken by applications (that we don't want the "forced" suspend to react to) from the wakelocks taken by the kernel (that are strictly related to "real" wakeup events).

Second, system suspend is really an intrusive operation that does violent things to many kernel subsystems (it freezes tasks, it puts the mm subsystem into a degraded mode, it forcibly offlines non-boot CPUs and so on). If that is to be started from the kernel, the kernel thread starting it should really ask all of these subsystems if they are OK with whatever it wants to do and the answer would always be "no" in the majority of cases. The very purpose of that design is to allow a user to suspend the system whenever he wants and not to do that when there's an opportunity to power down things because they appear to be inactive (that may or may not be one of the "whenever the user wants" situations, but really the user should be able to specify the conditions). The powering down of things by the kernel when there's an opportunity should really be done in a more intelligent way (simply becasue the kernel is potentially able to do that more intelligently).

Finally, in the kernel-driven opportunistic suspend scenario (using wakelocks) it is not particularly clear which applications should be given the priviledge to participate in the suspend blocking mechanism. I don't think there are any criteria which can be universally used for selecting these applications and in fact on Android that doesn't work very well either (for example, if you leave Google Maps in the foreground while the screan is off on Nexus One and you happen to move reasonably quickly from one location to another, it will drain the battery for the GPS updates much quickier than you'd expect). For this reason I don't think it is particularly smart to rely on applications when deciding whether or not to start system suspend. Other criteria should also be taken into account in general and I have no idea how to provide the kernel with an interface allowing it to do that. Therefore I don't think the kernel should start system suspend automatically.

Quoted 8 lines

In general, we try to keep such complexity out of the kernel, but not always; there are compelling cases for putting complexity in the kernel to provide uniformity and flexibility (e.g. application state save/restore vs. system-wide checkpoints, the former preserves the "if it can be done outside the kernel, it should be", while the latter provides much greater flexibility and avoids the need to port applications to potentially incompatible or unportable state saves/restore libraries).

I understand that and IMO it should be decided on the case-by-case basis. In this particular case, however, I don't think it's appropriate to use the interface designed with user space in mind for implementing a kernel-based mechanism.

Thanks,
Rafael

#704 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Jesse Barnes
Quoted 68 lines · Jesse Barnes
Quoted 23 lines · On Fri, 13 Aug 2010 05:28:21 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 15 lines · Jesse Barnes
Quoted 6 lines · On Thu, 12 Aug 2010 12:19:34 -0700 Brian Swetland <[email protected]> wrote:

Question though -- has every feature ever added to the kernel been a feature that there's pre-existing usage of? Seems like a chicken and egg problem. Also, some people seem to think there's value in being able to build kernels "out of the box" that work with the Android userspace -- given that there are a few devices out there that have that userspace on 'em.

We generally try to merge new features like this along with code that uses said feature, but there are always exceptions. We've merged code one release or more before the new code gets used for example, which is fine IMO. What we don't want to see is some new drop of code added and abandoned, but you already knew that.

Quoted 6 lines

At any rate, if Felipe is the only one arguing against including suspend blockers in the kernel, you're probably in good shape. Based on my (rather cursory I admit) evaluation of this thread, it seems like reasonable people agree that there's a place for a suspend blocker like API in the kernel, and that dynamic power management is also highly desirable. So where's the git pull request already? :)

Quoted 3 lines

In fact my patch going in that direction has been merged already and that code will likely be extended to cover some needs and cases I didn't have in mind when I was preparing it.

Yeah, I like what you've done with dynamic power management, really good stuff (the approach is very similar to the one I used for vblank interrupt management in the drm layer).

Ted's point about providing the user with a way of knowing which apps are blocking things is a good one though, and doesn't seem too hard to add. It might even be possible to do it largely with scripts wrapping fuser and such.

Quoted 17 lines

However, having discussed the whole issue for many times and reconsidered it thoroughly, I think that it's inappropriate to identify the suspend blockers (or wakelocks) framework with the opportunistic suspend feature as proposed in the original submission of the "suspend blockers" patchset. IMO they really are not the same thing and while the suspend blockers framework is used by Android to implement opportunistic suspend, I don't really believe this is the right approach.

We really need something similar to suspend blockers to avoid races between a suspend process and wakeup events, but it isn't necessary to provide user space with an interface allowing it to use these things directly. Such an interface is only necessary in the specific implementation in which the system is suspended as soon as the number of "active" suspend blockers goes down to zero. Arguably, though, this isn't the only possible way to implement a mechanism allowing the system to be suspended automatically when it appears to be inactive.

Quoted 11 lines

Namely, one can use a user space power manager for this purpose and actually the OLPC project has been doing that successfully for some time, which clearly demonstrates that the Android approach to this problem is not the only one possible. Moreover, the kernel's system suspend (or hibernate for that matter) code has not been designed to be started from within the kernel. It's been designed to allow a privileged user space process to request the kernel to put the system into a sleep state at any given time regardless of what the other user space processes are doing. While it can be started from within the kernel, this isn't particularly nice and, in the Android case, starting it from within the kernel requires permission from multiple user space processes (given by not taking suspend blockers these processes are allowed to use).

Quoted 6 lines

Yes, I see your point. But I actually think this is a fairly minor distinction. In one case, a privileged app decides when to suspend the system, in the other case, one or more of several privileged apps decide when a suspend should not be allowed to occur. It's just a matter of where you want to put the code and where you want the complexity.

Well, that used to be my opinion before the whole discussion started, but now I think there's more to it.

First off, we need the "forced" suspend, initiated by writing to /sys/power/state, to work regardless of the "opportunistic" one. Now, the races between wakeup events and suspend process are also a problem for the "forced" suspend mechanism, so the fix should not be specific to "opportunistic" suspend. One could argue that that can be fixed by using wakelocks as proposed by the Android developers, but this is not the case, because there's no way to disinguish wakelocks taken by applications (that we don't want the "forced" suspend to react to) from the wakelocks taken by the kernel (that are strictly related to "real" wakeup events).

Second, system suspend is really an intrusive operation that does violent things to many kernel subsystems (it freezes tasks, it puts the mm subsystem into a degraded mode, it forcibly offlines non-boot CPUs and so on). If that is to be started from the kernel, the kernel thread starting it should really ask all of these subsystems if they are OK with whatever it wants to do and the answer would always be "no" in the majority of cases. The very purpose of that design is to allow a user to suspend the system whenever he wants and not to do that when there's an opportunity to power down things because they appear to be inactive (that may or may not be one of the "whenever the user wants" situations, but really the user should be able to specify the conditions). The powering down of things by the kernel when there's an opportunity should really be done in a more intelligent way (simply becasue the kernel is potentially able to do that more intelligently).

Finally, in the kernel-driven opportunistic suspend scenario (using wakelocks) it is not particularly clear which applications should be given the priviledge to participate in the suspend blocking mechanism. I don't think there are any criteria which can be universally used for selecting these applications and in fact on Android that doesn't work very well either (for example, if you leave Google Maps in the foreground while the screan is off on Nexus One and you happen to move reasonably quickly from one location to another, it will drain the battery for the GPS updates much quickier than you'd expect). For this reason I don't think it is particularly smart to rely on applications when deciding whether or not to start system suspend. Other criteria should also be taken into account in general and I have no idea how to provide the kernel with an interface allowing it to do that. Therefore I don't think the kernel should start system suspend automatically.

Quoted 8 lines

In general, we try to keep such complexity out of the kernel, but not always; there are compelling cases for putting complexity in the kernel to provide uniformity and flexibility (e.g. application state save/restore vs. system-wide checkpoints, the former preserves the "if it can be done outside the kernel, it should be", while the latter provides much greater flexibility and avoids the need to port applications to potentially incompatible or unportable state saves/restore libraries).

I understand that and IMO it should be decided on the case-by-case basis. In this particular case, however, I don't think it's appropriate to use the interface designed with user space in mind for implementing a kernel-based mechanism.

Thanks,
Rafael

#705 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines

In general, we try to keep such complexity out of the kernel, but not always; there are compelling cases for putting complexity in the kernel to provide uniformity and flexibility (e.g. application state save/restore vs. system-wide checkpoints, the former preserves the "if it can be done outside the kernel, it should be", while the latter provides much greater flexibility and avoids the need to port applications to potentially incompatible or unportable state saves/restore libraries).

Quoted 4 lines

I understand that and IMO it should be decided on the case-by-case basis. In this particular case, however, I don't think it's appropriate to use the interface designed with user space in mind for implementing a kernel-based mechanism.

Putting the "opportunistic suspend" loop into the kernel doesn't save as much as one might think. The loop itself is quite simple, and the task switch it entails is required in any case (since suspend must be carried out within a process context). Putting it in the kernel would save a few user/kernel context switches, not enough to matter IMO. And it wouldn't offer any greater flexibility -- it might even cut down the flexibility.

Alan Stern

#706 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Rafael J. Wysocki
Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines

In general, we try to keep such complexity out of the kernel, but not always; there are compelling cases for putting complexity in the kernel to provide uniformity and flexibility (e.g. application state save/restore vs. system-wide checkpoints, the former preserves the "if it can be done outside the kernel, it should be", while the latter provides much greater flexibility and avoids the need to port applications to potentially incompatible or unportable state saves/restore libraries).

Quoted 4 lines

I understand that and IMO it should be decided on the case-by-case basis. In this particular case, however, I don't think it's appropriate to use the interface designed with user space in mind for implementing a kernel-based mechanism.

Putting the "opportunistic suspend" loop into the kernel doesn't save as much as one might think. The loop itself is quite simple, and the task switch it entails is required in any case (since suspend must be carried out within a process context). Putting it in the kernel would save a few user/kernel context switches, not enough to matter IMO. And it wouldn't offer any greater flexibility -- it might even cut down the flexibility.

Alan Stern

#793 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Arjan van de Ven
Quoted 6 lines · Arjan van de Ven

however I think you're making an assumption that there is a real difference between a deep idle state and "off"....

For modern x86 hardware, that assumption isn't really valid. (other than a very very small sram that stores register content in the idle case)

This is more of CPU statement than a chipset or laptop/device-wide statement, correct?

If "hardware" applies to the entire laptop, how "modern" is "modern"?

- Ted

#722 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Neil Brown
Quoted 3 lines · Neil Brown

Maybe this is the first real fork of Linux - google might be rich enough to persist with it.

Define "real fork"? Both SuSE and Red Hat have carried patches, in some cases for years, forward porting them to newer kernels. Does that make them forks?

SuSE has made changes to e2fsprogs, and carried those patches for years and years, and even added options to command-line programs which SLES's init scripts are dependent on --- and this was done without even consulting me first. Yet you don't see me calling out SLES for "forking" e2fsprogs and how it "got away" with it.

Can we please cut out this whole forking nonsense? I've been told that it's only something Slashdot kiddies and ZDNet media types looking for advertising impressions. Yet you're a kernel programmer, and one who works for a distribution, and you've made this same claim; you should know better.

Quoted 7 lines

I'm surprised at this comment Ted!
Power saving is not the single supreme goal, yet you make it sound like it is.

It should be no surprise to anyone if the most maintainable solution uses a little more power than the most highly optimised solution. I think most of us would still prefer the more maintainable solution.

I think part of the problem here is what's considered "acceptable" to one set of developers may not be considered "acceptable" to another set. As I've said many times before, what makes sense for a cell phone battery and highly power-optimized hardware may not make sense for a devices with 6-cell laptop battery. And I think it's still to be seen whether or not suspend-from-userspace really is as minor as people think it is, and what compromises might have to be made in how app programs are forced to develop their applications, etc.

- Ted

#723 lore raw

Re: Attempted summary of suspend-blockers LKML thread, take three

In reply to Neil Brown
Quoted 3 lines · Neil Brown

Maybe this is the first real fork of Linux - google might be rich enough to persist with it.

Define "real fork"? Both SuSE and Red Hat have carried patches, in some cases for years, forward porting them to newer kernels. Does that make them forks?

SuSE has made changes to e2fsprogs, and carried those patches for years and years, and even added options to command-line programs which SLES's init scripts are dependent on --- and this was done without even consulting me first. Yet you don't see me calling out SLES for "forking" e2fsprogs and how it "got away" with it.

Can we please cut out this whole forking nonsense? I've been told that it's only something Slashdot kiddies and ZDNet media types looking for advertising impressions. Yet you're a kernel programmer, and one who works for a distribution, and you've made this same claim; you should know better.

Quoted 7 lines

I'm surprised at this comment Ted!
Power saving is not the single supreme goal, yet you make it sound like it is.

It should be no surprise to anyone if the most maintainable solution uses a little more power than the most highly optimised solution. I think most of us would still prefer the more maintainable solution.

I think part of the problem here is what's considered "acceptable" to one set of developers may not be considered "acceptable" to another set. As I've said many times before, what makes sense for a cell phone battery and highly power-optimized hardware may not make sense for a devices with 6-cell laptop battery. And I think it's still to be seen whether or not suspend-from-userspace really is as minor as people think it is, and what compromises might have to be made in how app programs are forced to develop their applications, etc.

- Ted