Attempted summary of suspend-blockers LKML thread
Subsystems (4)
Rushing in where angels fear to tread...
I had been quite happily ignoring the suspend-blockers controversy. However, now that I have signed up for the Linaro project that involves embedded battery-powered devices, I find that ignorance is no longer bliss. I have therefore reviewed much of the suspend-blocker/wakelock material, but have not yet seen a clear exposition of the requirements that suspend blockers are supposed to meet. This email is a attempt to present the requirements, based on my interpretation of the LKML discussions.
Please note that I am not proposing a solution that meets these requirements, nor am I attempting to judge the various proposed solutions. In fact, I am not even trying to judge whether the requirements are optimal, or even whether or not they make sense at all. My only goal at the moment is to improve my understanding of what the Android folks' requirements are. That said, I do include example mechanisms as needed to clarify the meaning of the requirements. This should not be interpreted as a preference for any given example mechanism.
But first I am going to look at nomenclature, as it appears to me that at least some of the flamage was due to conflicting definitions. Following that, the requirements, nice-to-haves, apparent non-requirements, an example power-optimized applications, and finally a brief look at other applications.
Donning the asbestos suit, the one with the tungsten pinstripes...
Thanx, Paul
------------------------------------------------------------------------
DEFINITIONS
o "Ill-behaved application" AKA "untrusted application" AKA
"crappy application". The Android guys seem to be thinking in terms of applications that are well-designed and well-implemented in general, but which do not take power consumption or battery life into account. Examples include applications designed for AC-powered PCs. Many other people seemed to instead be thinking in terms of an ill-conceived or useless application, perhaps exemplified by "bouncing cows".
Assuming I have correctly guessed what the Android guys were thinking of, perhaps "power-naive applications" would be a better description, which I will use until someone convinces me otherwise.
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to determine which applications are classified as power aware.
More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
o Oddly enough, "power-optimized applications" were not discussed.
See "POWER-OPTIMIZED APPLICATIONS" below for a brief introduction. The short version is that power-optimized applications are those power-aware applications that have been aggressively tuned to reduce power consumption.
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be obtained.
o It is necessary to be able to use power-naive applications.
Many of these applications were designed for use in PC platforms where power consumption has historically not been of great concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations. The system must be capable of running these power-naive applications without requiring that these applications be modified, and must be capable of reasonable power efficiency even when power-naive applications are available.
o If the display is powered off, there is no need to run any
application whose only effect is to update the display.
Although one could simply block such an application when it next tries to access the display, it appears that it is highly desirable that the application also be prevented from consuming power computing anything that will not be displayed. Furthermore, whatever mechanism is used must operate on power-naive applications that do not use blocking system calls.
o In order to avoid overrunning hardware and/or kernel buffers,
input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.
In particular, if user input that would prevent the system from entering a low-power state is received while the system is transitioning into a low-power state, the system must transition back out of the low-power state so that it can hand the user input off to the corresponding application.
o If a power-aware application receives user input, then that
application must be given the opportunity to process that input.
o A power-aware application must be able to efficiently communicate
its needs to the system, so that such communication can be performed on hot code paths. Communication via open() and close() is considered too slow, but communication via ioctl() is acceptable.
o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.
o Statistics of the power-control actions taken by power-aware
applications must be provided, and must be keyed off of program name.
o Power-aware applications can make use of power-naive infrastructure.
This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.
o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
o If no power-aware or power-optimized application are indicating
a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)
o Transition to low-power state must be efficient. In particular,
methods based on repeated attempts to suspend are considered to be too inefficient to be useful.
o Individual peripherals and CPUs must still use standard
power-conservation measures, for example, transitioning CPUs into low-power states on idle and powering down peripheral devices and hardware accelerators that have not been recently used.
o The API that controls the system power state must be
accessible both from Android's Java replacement, from userland C code, and from kernel C code (both process level and irq code, but not NMI handlers).
o Any initialization of the API that controls the system power
state must be unconditional, so as to be free from failure. (I don't currently understand how this relates, probably due to my current insufficient understanding of the proposed patch set.)
o The API that controls the system power state must operate
correctly on SMP systems of modest size. (My guess is that "modest" means up to four CPUs, maybe up to eight CPUs.)
o Any QoS-based solution must take display and user-input
state into account. In other words, the QoS must be expressed as a function of the display and the user-input states.
o Transitioning to extremely low power states requires saving
and restoring DRAM and/or cache SRAM state, which in itself consumes significant energy. The power savings must therefore be balanced against the energy consumed in the state transitions.
o The current Android userspace API must be supported in order
to support existing device software.
NICE-TO-HAVES
o It would be nice to be able to identify power-naive applications
that never were depended on by power-aware applications. This particular class of power-naive applications could be shut down when the screen blanks even if some power-aware application was preventing the system from powering down. (I am guessing at this one based on the momentary excitement that cgroup freezing raised in the Android folks. Of course, this approach requires a reliable way to identify such applications.)
APPARENT NON-REQUIREMENTS
o Transitioning to low-power states need not be highly scalable,
as evidenced by the global locks. (If you believe that this will in fact be required, please provide a use case. But please understand that I do know something about scalability trends, but also about uses for transistors beyond more cores.)
POWER-OPTIMIZED APPLICATIONS
A typical power-optimized application manually controls the power state of many separately controlled hardware subsystems to minimize power consumption. Such optimization normally requires an understanding of the hardware and of the full system's workload: strangely enough, concurrently running two separately power-optimized applications often does -not- result in a power-optimized system. Such optimization also requires knowledge of what the application will be doing in the future, so that needed hardware subsystems can be proactively powered up just when the application will need them. This is especially important when powering down cache SRAMS or banks of main memory, because such components take significant time (and consume significant energy) when preparing them to be powered off and when restoring their state after powering them on.
Consider an MP3 player as an example. Such a player will periodically read MP3-encoded data from flash memory, decode it (possibly using hardware acceleration), and place the resulting audio data into main memory. Different systems have different ways of getting the data from main memory to the audio output device, but let's assume that the audio output device consumes data at a predictable rate such that the software can use timers to schedule refilling of the device's output buffer. The timer duration will of course need to allow for the time required to power up the CPU and L2 cache. The timer can be allowed to happen too soon, albeit with a battery-lifetime penalty, but cannot be permitted to happen too late, as this will cause "skips" in the playback.
If MP3 playback is the only application running in the system, things are quite easy. We calculate when the audio output device will empty its buffer, allow a few milliseconds to power up the needed hardware, and set a timer accordingly. Because modern audio output devices have buffers that can handle roughly a second's worth of output, it is well worthwhile to spend the few milliseconds required to flush the cache SRAMS in order to put the system into an extremely low power state over the several hundred milliseconds of playback.
Now suppose that this device is also recording audio -- perhaps the device is being used to monitor an area for noise pollution, and the user is also using the device to play music via earphones. The audio input process will be the inverse of the audio output process: the microphone data will fill a data buffer, which must be collected into DRAM, then encoded (perhaps again via MP3) and stored into flash. It would be easy to create an optimal application for audio input, but running this optimal audio input program concurrently with the optimal audio playback program would not necessarily result in a power-optimized combination. This lack of optimality is due to the fact that the input and output programs would each burn power separately powering down and up. In contrast, an optimal solution would align the input and output programs' timers so that a single power-down/power-up event would cover both programs' processing. This would trade off optimal processing of each (for example, by draining the input buffer before it was full) in order to attain global optimality (by sharing power-down/power-up overhead).
There are a number of ways to acheive this:
1. Making the kernel group timers that occur at roughly the same
time, as has been discussed on this list many times. This can work in many cases, but can be problematic in the audio example, due to the presence of hard deadlines.
2. Write the programs to be aware of each other, so that each
adjusts its behavior when the other is present. This seems to be current practice in the battery-powered embedded arena, but is quite complex, sensitive to both hardware configuration and software behavior, and requires that all combinations of programs be anticipated by the designer -- which can be a serious disadvantage given today's app stores.
3. Use new features such as range timers, so that each program
can indicate both its preference and the degree of flexibility that it can tolerate. This also works in some cases, but as far as I know, current proposals do not allow the kernel to take power-consumption penalties into account.
4. Use of hardware facilities that allow DMA to be scheduled across
time. This would allow the CPU to be turned on only for decode/encode operations. I am under the impression that this sort of time-based DMA hardware does exist in the embedded space and that it is actually used for this purpose.
5. Your favorite solution here.
Whatever solution is chosen, the key point to keep in mind is that running power-optimized applications in combination does -not- result in optimal system behavior.
OTHER EXAMPLE APPLICATIONS
GPS application that silently displays position.
There is no point in this application consuming CPU cycles or in powering up the GPS hardware unless the display is active. Such an application could be handled by the Android suspend-blocker proposal. Of course, such an application could also periodically poll the display, shutting itself down if the display is inactive. In this case, it would also need to have some way to be reactivated when the display comes back on.
GPS application that alerts the user when a given location is reached.
This application should presumably run even when the display is powered down due to input timeout. The question of whether or not it should continue running when the device is powered off is an interesting one that would be likely to spark much spirited discussion. Regardless of the answer to this question, the GPS application would hopefully run very intermittently, adjusting the delay interval based on the device's velocity and distance from the location in question.
I don't know enough about GPS hardware to say under what circumstances the GPS hardware itself should be powered off. However, my experience indicates that it takes significant time for the GPS hardware to get a position fix after being powered on, so presumably this decision would also be based on device velocity and distance from the location in question.
Assuming that the application can run only intermittently, suspend blockers would work reasonably well for this use case. If the application needed to run continuously, battery life would be quite short regardless of the approach used.
MP3 playback.
This requires a power-aware (and preferably a power-optimized) application. Because the CPU need only run intermittently, suspend blockers can handle this use case. Presumably switching the device off would halt playback.
Bouncing cows.
This can work with a power-naive application that is shut down whenever the display is powered off or the device is switched off, similar to the GPS application that silently displays position.
Quoted 26 lines · Paul E. McKenney
Rushing in where angels fear to tread...
I had been quite happily ignoring the suspend-blockers controversy. However, now that I have signed up for the Linaro project that involves embedded battery-powered devices, I find that ignorance is no longer bliss. I have therefore reviewed much of the suspend-blocker/wakelock material, but have not yet seen a clear exposition of the requirements that suspend blockers are supposed to meet. This email is a attempt to present the requirements, based on my interpretation of the LKML discussions.
Please note that I am not proposing a solution that meets these requirements, nor am I attempting to judge the various proposed solutions. In fact, I am not even trying to judge whether the requirements are optimal, or even whether or not they make sense at all. My only goal at the moment is to improve my understanding of what the Android folks' requirements are. That said, I do include example mechanisms as needed to clarify the meaning of the requirements. This should not be interpreted as a preference for any given example mechanism.
But first I am going to look at nomenclature, as it appears to me that at least some of the flamage was due to conflicting definitions. Following that, the requirements, nice-to-haves, apparent non-requirements, an example power-optimized applications, and finally a brief look at other applications.
Quoted 3 lines
Donning the asbestos suit, the one with the tungsten pinstripes...
Thanx, Paul
At the risk of sticking my neck out, I think a few of your statements don't fully capture the important ideas.
Quoted 18 lines
------------------------------------------------------------------------
DEFINITIONS
o "Ill-behaved application" AKA "untrusted application" AKA
"crappy application". The Android guys seem to be thinking in terms of applications that are well-designed and well-implemented in general, but which do not take power consumption or battery life into account. Examples include applications designed for AC-powered PCs. Many other people seemed to instead be thinking in terms of an ill-conceived or useless application, perhaps exemplified by "bouncing cows".Assuming I have correctly guessed what the Android guys were thinking of, perhaps "power-naive applications" would be a better description, which I will use until someone convinces me otherwise.
Quoted 8 lines
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
Notice that these definitions allow a program to be both power-naive and power-aware. In addition, "power-awareness" isn't an inherent property of the application itself, since users are allowed to decide which programs may exert control over the system's power state. The same application could be power-aware on one system and non-power-aware on another.
Quoted 5 lines
o Oddly enough, "power-optimized applications" were not discussed.
See "POWER-OPTIMIZED APPLICATIONS" below for a brief introduction. The short version is that power-optimized applications are those power-aware applications that have been aggressively tuned to reduce power consumption.
This would be essentially the same as power-aware && !power_naive, right?
Quoted 4 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be obtained.
External power, not necessarily AC power (a very minor point).
Quoted 10 lines
o It is necessary to be able to use power-naive applications.
Many of these applications were designed for use in PC platforms where power consumption has historically not been of great concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations. The system must be capable of running these power-naive applications without requiring that these applications be modified, and must be capable of reasonable power efficiency even when power-naive applications are available.
Quoted 2 lines
o If the display is powered off, there is no need to run any
application whose only effect is to update the display.
On Android this goes somewhat farther. IIUC, they want hardly anything to run while the display is powered off. (But my understanding could be wrong.)
For computers in general, of course, this statement is correct. The same is true for any output-only device. For example, if the audio speakers are powered off, there is no need to run any application whose only effect is to play sounds through the speakers.
Quoted 7 lines
Although one could simply block such an application when it next tries to access the display, it appears that it is highly desirable that the application also be prevented from consuming power computing anything that will not be displayed. Furthermore, whatever mechanism is used must operate on power-naive applications that do not use blocking system calls.
Quoted 5 lines
o In order to avoid overrunning hardware and/or kernel buffers,
input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.
This goes well beyond overrunning buffers! Events must be delivered in a timely fashion so that the system isn't perceived to be inoperative.
Quoted 9 lines
In particular, if user input that would prevent the system from entering a low-power state is received while the system is transitioning into a low-power state, the system must transition back out of the low-power state so that it can hand the user input off to the corresponding application.
o If a power-aware application receives user input, then that
application must be given the opportunity to process that input.
A better way to put this is: The API must provide a means for power-aware applications receiving user input to keep themselves running until they have been able to process the input.
This is probably also true for power-aware applications having other needs (e.g., non-input-driven computation). In general, power-aware applications must have a mechanism to prevent themselves from being stopped for power-related reasons.
Quoted 9 lines
o A power-aware application must be able to efficiently communicate
its needs to the system, so that such communication can be performed on hot code paths. Communication viaopen()andclose()is considered too slow, but communication viaioctl()is acceptable.o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.
You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
Quoted 10 lines
o Statistics of the power-control actions taken by power-aware
applications must be provided, and must be keyed off of program name.o Power-aware applications can make use of power-naive infrastructure.
This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.
Quoted 6 lines
o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
Quoted 5 lines
o If no power-aware or power-optimized application are indicating
a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)
The controversy was not over the basic point but rather over the detailed meaning of "runnable". A technical matter, related to the implementation of the scheduler.
Quoted 14 lines
o Transition to low-power state must be efficient. In particular,
methods based on repeated attempts to suspend are considered to be too inefficient to be useful.o Individual peripherals and CPUs must still use standard
power-conservation measures, for example, transitioning CPUs into low-power states on idle and powering down peripheral devices and hardware accelerators that have not been recently used.o The API that controls the system power state must be
accessible both from Android's Java replacement, from userland C code, and from kernel C code (both process level and irq code, but not NMI handlers).
Quoted 4 lines
o Any initialization of the API that controls the system power
state must be unconditional, so as to be free from failure. (I don't currently understand how this relates, probably due to my current insufficient understanding of the proposed patch set.)
I suspect this is not a critical requirement, more like a NICE-TO-HAVE.
Quoted 3 lines
o The API that controls the system power state must operate
correctly on SMP systems of modest size. (My guess is that "modest" means up to four CPUs, maybe up to eight CPUs.)
For present-day phones this obviously doesn't matter, but if the API is going to be used on more general systems then it does.
Quoted 5 lines
o Any QoS-based solution must take display and user-input
state into account. In other words, the QoS must be expressed as a function of the display and the user-input states.
Quoted 8 lines
o Transitioning to extremely low power states requires saving
and restoring DRAM and/or cache SRAM state, which in itself consumes significant energy. The power savings must therefore be balanced against the energy consumed in the state transitions.o The current Android userspace API must be supported in order
to support existing device software.
Alan Stern
Quoted 26 lines · Paul E. McKenney
Rushing in where angels fear to tread...
I had been quite happily ignoring the suspend-blockers controversy. However, now that I have signed up for the Linaro project that involves embedded battery-powered devices, I find that ignorance is no longer bliss. I have therefore reviewed much of the suspend-blocker/wakelock material, but have not yet seen a clear exposition of the requirements that suspend blockers are supposed to meet. This email is a attempt to present the requirements, based on my interpretation of the LKML discussions.
Please note that I am not proposing a solution that meets these requirements, nor am I attempting to judge the various proposed solutions. In fact, I am not even trying to judge whether the requirements are optimal, or even whether or not they make sense at all. My only goal at the moment is to improve my understanding of what the Android folks' requirements are. That said, I do include example mechanisms as needed to clarify the meaning of the requirements. This should not be interpreted as a preference for any given example mechanism.
But first I am going to look at nomenclature, as it appears to me that at least some of the flamage was due to conflicting definitions. Following that, the requirements, nice-to-haves, apparent non-requirements, an example power-optimized applications, and finally a brief look at other applications.
Quoted 3 lines
Donning the asbestos suit, the one with the tungsten pinstripes...
Thanx, Paul
At the risk of sticking my neck out, I think a few of your statements don't fully capture the important ideas.
Quoted 18 lines
------------------------------------------------------------------------
DEFINITIONS
o "Ill-behaved application" AKA "untrusted application" AKA
"crappy application". The Android guys seem to be thinking in terms of applications that are well-designed and well-implemented in general, but which do not take power consumption or battery life into account. Examples include applications designed for AC-powered PCs. Many other people seemed to instead be thinking in terms of an ill-conceived or useless application, perhaps exemplified by "bouncing cows".Assuming I have correctly guessed what the Android guys were thinking of, perhaps "power-naive applications" would be a better description, which I will use until someone convinces me otherwise.
Quoted 8 lines
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
Notice that these definitions allow a program to be both power-naive and power-aware. In addition, "power-awareness" isn't an inherent property of the application itself, since users are allowed to decide which programs may exert control over the system's power state. The same application could be power-aware on one system and non-power-aware on another.
Quoted 5 lines
o Oddly enough, "power-optimized applications" were not discussed.
See "POWER-OPTIMIZED APPLICATIONS" below for a brief introduction. The short version is that power-optimized applications are those power-aware applications that have been aggressively tuned to reduce power consumption.
This would be essentially the same as power-aware && !power_naive, right?
Quoted 4 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be obtained.
External power, not necessarily AC power (a very minor point).
Quoted 10 lines
o It is necessary to be able to use power-naive applications.
Many of these applications were designed for use in PC platforms where power consumption has historically not been of great concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations. The system must be capable of running these power-naive applications without requiring that these applications be modified, and must be capable of reasonable power efficiency even when power-naive applications are available.
Quoted 2 lines
o If the display is powered off, there is no need to run any
application whose only effect is to update the display.
On Android this goes somewhat farther. IIUC, they want hardly anything to run while the display is powered off. (But my understanding could be wrong.)
For computers in general, of course, this statement is correct. The same is true for any output-only device. For example, if the audio speakers are powered off, there is no need to run any application whose only effect is to play sounds through the speakers.
Quoted 7 lines
Although one could simply block such an application when it next tries to access the display, it appears that it is highly desirable that the application also be prevented from consuming power computing anything that will not be displayed. Furthermore, whatever mechanism is used must operate on power-naive applications that do not use blocking system calls.
Quoted 5 lines
o In order to avoid overrunning hardware and/or kernel buffers,
input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.
This goes well beyond overrunning buffers! Events must be delivered in a timely fashion so that the system isn't perceived to be inoperative.
Quoted 9 lines
In particular, if user input that would prevent the system from entering a low-power state is received while the system is transitioning into a low-power state, the system must transition back out of the low-power state so that it can hand the user input off to the corresponding application.
o If a power-aware application receives user input, then that
application must be given the opportunity to process that input.
A better way to put this is: The API must provide a means for power-aware applications receiving user input to keep themselves running until they have been able to process the input.
This is probably also true for power-aware applications having other needs (e.g., non-input-driven computation). In general, power-aware applications must have a mechanism to prevent themselves from being stopped for power-related reasons.
Quoted 9 lines
o A power-aware application must be able to efficiently communicate
its needs to the system, so that such communication can be performed on hot code paths. Communication viaopen()andclose()is considered too slow, but communication viaioctl()is acceptable.o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.
You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
Quoted 10 lines
o Statistics of the power-control actions taken by power-aware
applications must be provided, and must be keyed off of program name.o Power-aware applications can make use of power-naive infrastructure.
This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.
Quoted 6 lines
o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
Quoted 5 lines
o If no power-aware or power-optimized application are indicating
a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)
The controversy was not over the basic point but rather over the detailed meaning of "runnable". A technical matter, related to the implementation of the scheduler.
Quoted 14 lines
o Transition to low-power state must be efficient. In particular,
methods based on repeated attempts to suspend are considered to be too inefficient to be useful.o Individual peripherals and CPUs must still use standard
power-conservation measures, for example, transitioning CPUs into low-power states on idle and powering down peripheral devices and hardware accelerators that have not been recently used.o The API that controls the system power state must be
accessible both from Android's Java replacement, from userland C code, and from kernel C code (both process level and irq code, but not NMI handlers).
Quoted 4 lines
o Any initialization of the API that controls the system power
state must be unconditional, so as to be free from failure. (I don't currently understand how this relates, probably due to my current insufficient understanding of the proposed patch set.)
I suspect this is not a critical requirement, more like a NICE-TO-HAVE.
Quoted 3 lines
o The API that controls the system power state must operate
correctly on SMP systems of modest size. (My guess is that "modest" means up to four CPUs, maybe up to eight CPUs.)
For present-day phones this obviously doesn't matter, but if the API is going to be used on more general systems then it does.
Quoted 5 lines
o Any QoS-based solution must take display and user-input
state into account. In other words, the QoS must be expressed as a function of the display and the user-input states.
Quoted 8 lines
o Transitioning to extremely low power states requires saving
and restoring DRAM and/or cache SRAM state, which in itself consumes significant energy. The power savings must therefore be balanced against the energy consumed in the state transitions.o The current Android userspace API must be supported in order
to support existing device software.
Alan Stern
Quoted 28 lines · Alan Stern
Quoted 26 lines · Paul E. McKenney
Rushing in where angels fear to tread...
I had been quite happily ignoring the suspend-blockers controversy. However, now that I have signed up for the Linaro project that involves embedded battery-powered devices, I find that ignorance is no longer bliss. I have therefore reviewed much of the suspend-blocker/wakelock material, but have not yet seen a clear exposition of the requirements that suspend blockers are supposed to meet. This email is a attempt to present the requirements, based on my interpretation of the LKML discussions.
Please note that I am not proposing a solution that meets these requirements, nor am I attempting to judge the various proposed solutions. In fact, I am not even trying to judge whether the requirements are optimal, or even whether or not they make sense at all. My only goal at the moment is to improve my understanding of what the Android folks' requirements are. That said, I do include example mechanisms as needed to clarify the meaning of the requirements. This should not be interpreted as a preference for any given example mechanism.
But first I am going to look at nomenclature, as it appears to me that at least some of the flamage was due to conflicting definitions. Following that, the requirements, nice-to-haves, apparent non-requirements, an example power-optimized applications, and finally a brief look at other applications.
Quoted 6 lines
Quoted 3 lines
Donning the asbestos suit, the one with the tungsten pinstripes...
Thanx, Paul
At the risk of sticking my neck out, I think a few of your statements don't fully capture the important ideas.
Fair enough! ;-)
And thank you for looking this over!!!
Quoted 27 lines
Quoted 18 lines
------------------------------------------------------------------------
DEFINITIONS
o "Ill-behaved application" AKA "untrusted application" AKA
"crappy application". The Android guys seem to be thinking in terms of applications that are well-designed and well-implemented in general, but which do not take power consumption or battery life into account. Examples include applications designed for AC-powered PCs. Many other people seemed to instead be thinking in terms of an ill-conceived or useless application, perhaps exemplified by "bouncing cows".Assuming I have correctly guessed what the Android guys were thinking of, perhaps "power-naive applications" would be a better description, which I will use until someone convinces me otherwise.
Quoted 8 lines
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
Quoted 6 lines
Notice that these definitions allow a program to be both power-naive and power-aware. In addition, "power-awareness" isn't an inherent property of the application itself, since users are allowed to decide which programs may exert control over the system's power state. The same application could be power-aware on one system and non-power-aware on another.
Agreed.
Quoted 8 lines
Quoted 5 lines
o Oddly enough, "power-optimized applications" were not discussed.
See "POWER-OPTIMIZED APPLICATIONS" below for a brief introduction. The short version is that power-optimized applications are those power-aware applications that have been aggressively tuned to reduce power consumption.This would be essentially the same as power-aware && !power_naive, right?
It certainly seems to me that most power-optimized applications would need to be classified as power-aware to work properly. But there could easily be power-aware applications that aren't heavily power-optimized, for example, such an application might make use of the CPU for operations that could be handled by a power-efficient hardware accelerator. Perhaps power-aware is to power-optimized as SMP-safe is to perfectly optimized for SMP scalability and performance.
Though it seems that heavy power-efficiency optimizations might come at the expense of portability in some cases.
Quoted 6 lines
Quoted 4 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be obtained.External power, not necessarily AC power (a very minor point).
A good one, though.
Quoted 10 lines
Quoted 10 lines
o It is necessary to be able to use power-naive applications.
Many of these applications were designed for use in PC platforms where power consumption has historically not been of great concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations. The system must be capable of running these power-naive applications without requiring that these applications be modified, and must be capable of reasonable power efficiency even when power-naive applications are available.
Quoted 6 lines
Quoted 2 lines
o If the display is powered off, there is no need to run any
application whose only effect is to update the display.On Android this goes somewhat farther. IIUC, they want hardly anything to run while the display is powered off. (But my understanding could be wrong.)
I agree that this requirement is but one piece of the Android puzzle.
Quoted 4 lines
For computers in general, of course, this statement is correct. The same is true for any output-only device. For example, if the audio speakers are powered off, there is no need to run any application whose only effect is to play sounds through the speakers.
Good point -- I didn't find any example of this in the email threads, but it does seem plausible.
Quoted 7 lines
Quoted 7 lines
Although one could simply block such an application when it next tries to access the display, it appears that it is highly desirable that the application also be prevented from consuming power computing anything that will not be displayed. Furthermore, whatever mechanism is used must operate on power-naive applications that do not use blocking system calls.
Quoted 8 lines
Quoted 5 lines
o In order to avoid overrunning hardware and/or kernel buffers,
input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.This goes well beyond overrunning buffers! Events must be delivered in a timely fashion so that the system isn't perceived to be inoperative.
Agreed for power-aware applications. For power-naive applications, the last event delivered can be buffered by the application with no response if I understand correctly. If there is a subsequent event for that same application, then the prior event can be processed.
Quoted 6 lines
Quoted 6 lines
In particular, if user input that would prevent the system from entering a low-power state is received while the system is transitioning into a low-power state, the system must transition back out of the low-power state so that it can hand the user input off to the corresponding application.
Quoted 7 lines
Quoted 3 lines
o If a power-aware application receives user input, then that
application must be given the opportunity to process that input.A better way to put this is: The API must provide a means for power-aware applications receiving user input to keep themselves running until they have been able to process the input.
Good point! Would it also make sense to say "events" in general rather than "input" in particular?
Quoted 4 lines
This is probably also true for power-aware applications having other needs (e.g., non-input-driven computation). In general, power-aware applications must have a mechanism to prevent themselves from being stopped for power-related reasons.
I thought I covered this in the next requirement. Did I miss some aspect?
Quoted 6 lines
Quoted 6 lines
o A power-aware application must be able to efficiently communicate
its needs to the system, so that such communication can be performed on hot code paths. Communication viaopen()andclose()is considered too slow, but communication viaioctl()is acceptable.
Quoted 7 lines
Quoted 3 lines
o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
I see your point, but I don't feel comfortable deleting this requirement. My rationale is that the definition needs some enforcement mechanism, and this requirement is calling out the need for such a mechanism.
Quoted 17 lines
Quoted 10 lines
o Statistics of the power-control actions taken by power-aware
applications must be provided, and must be keyed off of program name.o Power-aware applications can make use of power-naive infrastructure.
This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.Quoted 6 lines
o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
Quoted 3 lines
No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
I am not sure we agree on the definition of "power-optimized application". But leaving that aside, I thought that Arve and Brian explicitly stated this as a requirement on power-aware applications -- one of the responsibilities that came with the power to block suspend.
Quoted 9 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating
a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)The controversy was not over the basic point but rather over the detailed meaning of "runnable". A technical matter, related to the implementation of the scheduler.
OK, what would you suggest for the wording of this requirement?
Quoted 14 lines
Quoted 14 lines
o Transition to low-power state must be efficient. In particular,
methods based on repeated attempts to suspend are considered to be too inefficient to be useful.o Individual peripherals and CPUs must still use standard
power-conservation measures, for example, transitioning CPUs into low-power states on idle and powering down peripheral devices and hardware accelerators that have not been recently used.o The API that controls the system power state must be
accessible both from Android's Java replacement, from userland C code, and from kernel C code (both process level and irq code, but not NMI handlers).
Quoted 6 lines
Quoted 4 lines
o Any initialization of the API that controls the system power
state must be unconditional, so as to be free from failure. (I don't currently understand how this relates, probably due to my current insufficient understanding of the proposed patch set.)I suspect this is not a critical requirement, more like a NICE-TO-HAVE.
You could well be correct, though the Android guys stated it pretty strongly. Seems like the usual memory and mass-storage shortages would be hard to handle with an unconditional API, though the usual solution seems to be to make sure that there is enough for normal operation.
Quoted 6 lines
Quoted 3 lines
o The API that controls the system power state must operate
correctly on SMP systems of modest size. (My guess is that "modest" means up to four CPUs, maybe up to eight CPUs.)For present-day phones this obviously doesn't matter, but if the API is going to be used on more general systems then it does.
Indeed, at least if the API is not to be stubbed out for all large systems. Though it might be possible to make a more-scalable implementation of this API, especially if larger systems were more forgiving of time delays in noting any transitions.
Quoted 5 lines
Quoted 5 lines
o Any QoS-based solution must take display and user-input
state into account. In other words, the QoS must be expressed as a function of the display and the user-input states.
Quoted 8 lines
Quoted 8 lines
o Transitioning to extremely low power states requires saving
and restoring DRAM and/or cache SRAM state, which in itself consumes significant energy. The power savings must therefore be balanced against the energy consumed in the state transitions.o The current Android userspace API must be supported in order
to support existing device software.
Thank you again for looking this over!
Thanx, Paul
Quoted 28 lines · Alan Stern
Quoted 26 lines · Paul E. McKenney
Rushing in where angels fear to tread...
I had been quite happily ignoring the suspend-blockers controversy. However, now that I have signed up for the Linaro project that involves embedded battery-powered devices, I find that ignorance is no longer bliss. I have therefore reviewed much of the suspend-blocker/wakelock material, but have not yet seen a clear exposition of the requirements that suspend blockers are supposed to meet. This email is a attempt to present the requirements, based on my interpretation of the LKML discussions.
Please note that I am not proposing a solution that meets these requirements, nor am I attempting to judge the various proposed solutions. In fact, I am not even trying to judge whether the requirements are optimal, or even whether or not they make sense at all. My only goal at the moment is to improve my understanding of what the Android folks' requirements are. That said, I do include example mechanisms as needed to clarify the meaning of the requirements. This should not be interpreted as a preference for any given example mechanism.
But first I am going to look at nomenclature, as it appears to me that at least some of the flamage was due to conflicting definitions. Following that, the requirements, nice-to-haves, apparent non-requirements, an example power-optimized applications, and finally a brief look at other applications.
Quoted 6 lines
Quoted 3 lines
Donning the asbestos suit, the one with the tungsten pinstripes...
Thanx, Paul
At the risk of sticking my neck out, I think a few of your statements don't fully capture the important ideas.
Fair enough! ;-)
And thank you for looking this over!!!
Quoted 27 lines
Quoted 18 lines
------------------------------------------------------------------------
DEFINITIONS
o "Ill-behaved application" AKA "untrusted application" AKA
"crappy application". The Android guys seem to be thinking in terms of applications that are well-designed and well-implemented in general, but which do not take power consumption or battery life into account. Examples include applications designed for AC-powered PCs. Many other people seemed to instead be thinking in terms of an ill-conceived or useless application, perhaps exemplified by "bouncing cows".Assuming I have correctly guessed what the Android guys were thinking of, perhaps "power-naive applications" would be a better description, which I will use until someone convinces me otherwise.
Quoted 8 lines
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
Quoted 6 lines
Notice that these definitions allow a program to be both power-naive and power-aware. In addition, "power-awareness" isn't an inherent property of the application itself, since users are allowed to decide which programs may exert control over the system's power state. The same application could be power-aware on one system and non-power-aware on another.
Agreed.
Quoted 8 lines
Quoted 5 lines
o Oddly enough, "power-optimized applications" were not discussed.
See "POWER-OPTIMIZED APPLICATIONS" below for a brief introduction. The short version is that power-optimized applications are those power-aware applications that have been aggressively tuned to reduce power consumption.This would be essentially the same as power-aware && !power_naive, right?
It certainly seems to me that most power-optimized applications would need to be classified as power-aware to work properly. But there could easily be power-aware applications that aren't heavily power-optimized, for example, such an application might make use of the CPU for operations that could be handled by a power-efficient hardware accelerator. Perhaps power-aware is to power-optimized as SMP-safe is to perfectly optimized for SMP scalability and performance.
Though it seems that heavy power-efficiency optimizations might come at the expense of portability in some cases.
Quoted 6 lines
Quoted 4 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be obtained.External power, not necessarily AC power (a very minor point).
A good one, though.
Quoted 10 lines
Quoted 10 lines
o It is necessary to be able to use power-naive applications.
Many of these applications were designed for use in PC platforms where power consumption has historically not been of great concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations. The system must be capable of running these power-naive applications without requiring that these applications be modified, and must be capable of reasonable power efficiency even when power-naive applications are available.
Quoted 6 lines
Quoted 2 lines
o If the display is powered off, there is no need to run any
application whose only effect is to update the display.On Android this goes somewhat farther. IIUC, they want hardly anything to run while the display is powered off. (But my understanding could be wrong.)
I agree that this requirement is but one piece of the Android puzzle.
Quoted 4 lines
For computers in general, of course, this statement is correct. The same is true for any output-only device. For example, if the audio speakers are powered off, there is no need to run any application whose only effect is to play sounds through the speakers.
Good point -- I didn't find any example of this in the email threads, but it does seem plausible.
Quoted 7 lines
Quoted 7 lines
Although one could simply block such an application when it next tries to access the display, it appears that it is highly desirable that the application also be prevented from consuming power computing anything that will not be displayed. Furthermore, whatever mechanism is used must operate on power-naive applications that do not use blocking system calls.
Quoted 8 lines
Quoted 5 lines
o In order to avoid overrunning hardware and/or kernel buffers,
input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.This goes well beyond overrunning buffers! Events must be delivered in a timely fashion so that the system isn't perceived to be inoperative.
Agreed for power-aware applications. For power-naive applications, the last event delivered can be buffered by the application with no response if I understand correctly. If there is a subsequent event for that same application, then the prior event can be processed.
Quoted 6 lines
Quoted 6 lines
In particular, if user input that would prevent the system from entering a low-power state is received while the system is transitioning into a low-power state, the system must transition back out of the low-power state so that it can hand the user input off to the corresponding application.
Quoted 7 lines
Quoted 3 lines
o If a power-aware application receives user input, then that
application must be given the opportunity to process that input.A better way to put this is: The API must provide a means for power-aware applications receiving user input to keep themselves running until they have been able to process the input.
Good point! Would it also make sense to say "events" in general rather than "input" in particular?
Quoted 4 lines
This is probably also true for power-aware applications having other needs (e.g., non-input-driven computation). In general, power-aware applications must have a mechanism to prevent themselves from being stopped for power-related reasons.
I thought I covered this in the next requirement. Did I miss some aspect?
Quoted 6 lines
Quoted 6 lines
o A power-aware application must be able to efficiently communicate
its needs to the system, so that such communication can be performed on hot code paths. Communication viaopen()andclose()is considered too slow, but communication viaioctl()is acceptable.
Quoted 7 lines
Quoted 3 lines
o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
I see your point, but I don't feel comfortable deleting this requirement. My rationale is that the definition needs some enforcement mechanism, and this requirement is calling out the need for such a mechanism.
Quoted 17 lines
Quoted 10 lines
o Statistics of the power-control actions taken by power-aware
applications must be provided, and must be keyed off of program name.o Power-aware applications can make use of power-naive infrastructure.
This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.Quoted 6 lines
o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
Quoted 3 lines
No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
I am not sure we agree on the definition of "power-optimized application". But leaving that aside, I thought that Arve and Brian explicitly stated this as a requirement on power-aware applications -- one of the responsibilities that came with the power to block suspend.
Quoted 9 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating
a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)The controversy was not over the basic point but rather over the detailed meaning of "runnable". A technical matter, related to the implementation of the scheduler.
OK, what would you suggest for the wording of this requirement?
Quoted 14 lines
Quoted 14 lines
o Transition to low-power state must be efficient. In particular,
methods based on repeated attempts to suspend are considered to be too inefficient to be useful.o Individual peripherals and CPUs must still use standard
power-conservation measures, for example, transitioning CPUs into low-power states on idle and powering down peripheral devices and hardware accelerators that have not been recently used.o The API that controls the system power state must be
accessible both from Android's Java replacement, from userland C code, and from kernel C code (both process level and irq code, but not NMI handlers).
Quoted 6 lines
Quoted 4 lines
o Any initialization of the API that controls the system power
state must be unconditional, so as to be free from failure. (I don't currently understand how this relates, probably due to my current insufficient understanding of the proposed patch set.)I suspect this is not a critical requirement, more like a NICE-TO-HAVE.
You could well be correct, though the Android guys stated it pretty strongly. Seems like the usual memory and mass-storage shortages would be hard to handle with an unconditional API, though the usual solution seems to be to make sure that there is enough for normal operation.
Quoted 6 lines
Quoted 3 lines
o The API that controls the system power state must operate
correctly on SMP systems of modest size. (My guess is that "modest" means up to four CPUs, maybe up to eight CPUs.)For present-day phones this obviously doesn't matter, but if the API is going to be used on more general systems then it does.
Indeed, at least if the API is not to be stubbed out for all large systems. Though it might be possible to make a more-scalable implementation of this API, especially if larger systems were more forgiving of time delays in noting any transitions.
Quoted 5 lines
Quoted 5 lines
o Any QoS-based solution must take display and user-input
state into account. In other words, the QoS must be expressed as a function of the display and the user-input states.
Quoted 8 lines
Quoted 8 lines
o Transitioning to extremely low power states requires saving
and restoring DRAM and/or cache SRAM state, which in itself consumes significant energy. The power savings must therefore be balanced against the energy consumed in the state transitions.o The current Android userspace API must be supported in order
to support existing device software.
Thank you again for looking this over!
Thanx, Paul
Quoted 8 lines · On Sat, 31 Jul 2010 10:58:42 -0700 "Paul E. McKenney"…
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to
determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
I don't like the term "Power aware application". An application is well behaved or it isn't. "aware" has nothing to do with it.
Quoted 6 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be
obtained.
AC power is not relevant in discussions around power: Applications MUST behave well, AC or DC both. Just ask any data center operator on how much they run on DC and if he cares about power consumption. Conversely, most mobile usages (both phone, tablet or netbook) are "DC only"....
Quoted 9 lines
o It is necessary to be able to use power-naive applications.
Many of these applications were designed for use in PC
platforms where power consumption has historically not been of great
concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations.
The system must be capable of running these power-naive applications
without requiring that these applications be modified, and
must be capable of reasonable power efficiency even when power-naive
applications are available.
I don't buy this argument as is.
I do buy that there are many sloppy applications; mostly written quickly for <appstore of the month>. But most if not all of these are written for the device in question (at least that is true for Apple and Android)
Quoted 8 lines · On Sat, 31 Jul 2010 10:58:42 -0700 "Paul E. McKenney"…
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to
determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
I don't like the term "Power aware application". An application is well behaved or it isn't. "aware" has nothing to do with it.
Quoted 6 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be
obtained.
AC power is not relevant in discussions around power: Applications MUST behave well, AC or DC both. Just ask any data center operator on how much they run on DC and if he cares about power consumption. Conversely, most mobile usages (both phone, tablet or netbook) are "DC only"....
Quoted 9 lines
o It is necessary to be able to use power-naive applications.
Many of these applications were designed for use in PC
platforms where power consumption has historically not been of great
concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations.
The system must be capable of running these power-naive applications
without requiring that these applications be modified, and
must be capable of reasonable power efficiency even when power-naive
applications are available.
I don't buy this argument as is.
I do buy that there are many sloppy applications; mostly written quickly for <appstore of the month>. But most if not all of these are written for the device in question (at least that is true for Apple and Android)
Quoted 8 lines · Arjan van de Ven
Quoted 5 lines · On Sat, 31 Jul 2010 10:58:42 -0700 "Paul E. McKenney"…
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to
determine which applications are classified as power aware.
Quoted 6 lines
Quoted 3 lines
More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
I don't like the term "Power aware application". An application is well behaved or it isn't. "aware" has nothing to do with it.
Applications are often complex enough to be aware of some things, naive about others, well behaved in some ways, and ill-behaved in others. This has been the case for some decades now, so it should not come as a surprise.
I am of course open to suggestions for alternatives to the term "power aware application", but most definitely not to obfuscating the difference between power awareness (or whatever name one wishes to call it) and the overall quality of the application, whatever "quality" might mean in a given context.
Quoted 11 lines
Quoted 5 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be
obtained.AC power is not relevant in discussions around power: Applications MUST behave well, AC or DC both. Just ask any data center operator on how much they run on DC and if he cares about power consumption. Conversely, most mobile usages (both phone, tablet or netbook) are "DC only"....
Alan Stern suggested "external power" in place of "AC", which makes sense to me. His suggestion does have the virtue of rendering irrelevant the difference between an AC adapter and a DC adapter for use in automobiles.
And in my experience, people working with mobile devices care -much- more about energy efficiency than do data-center operators.
Quoted 10 lines
Quoted 9 lines
o It is necessary to be able to use power-naive applications.
Many of these applications were designed for use in PC
platforms where power consumption has historically not been of great
concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations.
The system must be capable of running these power-naive applications
without requiring that these applications be modified, and
must be capable of reasonable power efficiency even when power-naive
applications are available.
Quoted 5 lines
I don't buy this argument as is.
I do buy that there are many sloppy applications; mostly written quickly for <appstore of the month>. But most if not all of these are written for the device in question (at least that is true for Apple and Android)
Making an application power-aware or power-naive is a choice, similar to the choice between making an application SMP-aware or single-threaded. This sort of choice is completely orthogonal to ill-behavior, sloppiness, or whatever the pejorative of the day might be.
The choice between power-aware and power-naive will depend on who is available to do the programming and how valuable power-awareness is for the application in question. Given that people who program PC-class applications are much more common than are people who program with energy efficiency in mind, the power-naive choice will be attractive in many cases.
Or do you have some other interpretation of what the Android guys are looking for?
Thanx, Paul
Quoted 8 lines · Arjan van de Ven
Quoted 5 lines · On Sat, 31 Jul 2010 10:58:42 -0700 "Paul E. McKenney"…
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to
determine which applications are classified as power aware.
Quoted 6 lines
Quoted 3 lines
More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
I don't like the term "Power aware application". An application is well behaved or it isn't. "aware" has nothing to do with it.
Applications are often complex enough to be aware of some things, naive about others, well behaved in some ways, and ill-behaved in others. This has been the case for some decades now, so it should not come as a surprise.
I am of course open to suggestions for alternatives to the term "power aware application", but most definitely not to obfuscating the difference between power awareness (or whatever name one wishes to call it) and the overall quality of the application, whatever "quality" might mean in a given context.
Quoted 11 lines
Quoted 5 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be
obtained.AC power is not relevant in discussions around power: Applications MUST behave well, AC or DC both. Just ask any data center operator on how much they run on DC and if he cares about power consumption. Conversely, most mobile usages (both phone, tablet or netbook) are "DC only"....
Alan Stern suggested "external power" in place of "AC", which makes sense to me. His suggestion does have the virtue of rendering irrelevant the difference between an AC adapter and a DC adapter for use in automobiles.
And in my experience, people working with mobile devices care -much- more about energy efficiency than do data-center operators.
Quoted 10 lines
Quoted 9 lines
o It is necessary to be able to use power-naive applications.
Many of these applications were designed for use in PC
platforms where power consumption has historically not been of great
concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations.
The system must be capable of running these power-naive applications
without requiring that these applications be modified, and
must be capable of reasonable power efficiency even when power-naive
applications are available.
Quoted 5 lines
I don't buy this argument as is.
I do buy that there are many sloppy applications; mostly written quickly for <appstore of the month>. But most if not all of these are written for the device in question (at least that is true for Apple and Android)
Making an application power-aware or power-naive is a choice, similar to the choice between making an application SMP-aware or single-threaded. This sort of choice is completely orthogonal to ill-behavior, sloppiness, or whatever the pejorative of the day might be.
The choice between power-aware and power-naive will depend on who is available to do the programming and how valuable power-awareness is for the application in question. Given that people who program PC-class applications are much more common than are people who program with energy efficiency in mind, the power-naive choice will be attractive in many cases.
Or do you have some other interpretation of what the Android guys are looking for?
Thanx, Paul
Quoted 13 lines · On Sat, 31 Jul 2010 22:48:16 -0700 "Paul E. McKenney"…
Quoted 12 lines · Arjan van de Ven
Quoted 8 lines · On Sat, 31 Jul 2010 10:58:42 -0700 "Paul E. McKenney"…
o "Power-aware application" are applications that are
permitted to acquire suspend blockers on Android. Verion 8 of the
suspend-blocker patch seems to use group permissions to
determine which applications are classified as power aware.More generally, power-aware applications seem to be those
that have permission to exert some control over the system's
power state.
Quoted 7 lines
Quoted 2 lines
I don't like the term "Power aware application". An application is well behaved or it isn't. "aware" has nothing to do with it.
Applications are often complex enough to be aware of some things, naive about others, well behaved in some ways, and ill-behaved in others. This has been the case for some decades now, so it should not come as a surprise.
I do not like the term "aware". At all.
It implies "awareness", and implies it does things based on the power circumstances.
It's about *behaving well*. (not polling, not having activity when there is nothing to do etc etc). Not about being aware that power matters.
I can write a very shitty application that polls all the time and otherwise keeps the CPU and system busy, but it'll be aware that power matters.. it just doesn't behave accordingly.
Quoted 7 lines
The choice between power-aware and power-naive will depend on who is available to do the programming and how valuable power-awareness is for the application in question. Given that people who program PC-class applications are much more common than are people who program with energy efficiency in mind, the power-naive choice will be attractive in many cases.
I'm not sure I buy that.
4 years ago.. yes.
Today.. with PowerTOP and co out there for a long time?
I don't believe that anymore. Most of our open source PC apps are actually very well behaving in the power sense.
Yes an occasional bug slips in, and then gets fixed quickly. (speaking as someone who does this sort of work for a Linux distribution... yes bugs happen on a whole distro level, but they're also not all that common, and get fixed quickly)
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
Quoted 13 lines · On Sat, 31 Jul 2010 22:48:16 -0700 "Paul E. McKenney"…
Quoted 12 lines · Arjan van de Ven
Quoted 8 lines · On Sat, 31 Jul 2010 10:58:42 -0700 "Paul E. McKenney"…
o "Power-aware application" are applications that are
permitted to acquire suspend blockers on Android. Verion 8 of the
suspend-blocker patch seems to use group permissions to
determine which applications are classified as power aware.More generally, power-aware applications seem to be those
that have permission to exert some control over the system's
power state.
Quoted 7 lines
Quoted 2 lines
I don't like the term "Power aware application". An application is well behaved or it isn't. "aware" has nothing to do with it.
Applications are often complex enough to be aware of some things, naive about others, well behaved in some ways, and ill-behaved in others. This has been the case for some decades now, so it should not come as a surprise.
I do not like the term "aware". At all.
It implies "awareness", and implies it does things based on the power circumstances.
It's about *behaving well*. (not polling, not having activity when there is nothing to do etc etc). Not about being aware that power matters.
I can write a very shitty application that polls all the time and otherwise keeps the CPU and system busy, but it'll be aware that power matters.. it just doesn't behave accordingly.
Quoted 7 lines
The choice between power-aware and power-naive will depend on who is available to do the programming and how valuable power-awareness is for the application in question. Given that people who program PC-class applications are much more common than are people who program with energy efficiency in mind, the power-naive choice will be attractive in many cases.
I'm not sure I buy that.
4 years ago.. yes.
Today.. with PowerTOP and co out there for a long time?
I don't believe that anymore. Most of our open source PC apps are actually very well behaving in the power sense.
Yes an occasional bug slips in, and then gets fixed quickly. (speaking as someone who does this sort of work for a Linux distribution... yes bugs happen on a whole distro level, but they're also not all that common, and get fixed quickly)
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
Quoted 5 lines · Paul E. McKenney
available to do the programming and how valuable power-awareness is for the application in question. Given that people who program PC-class applications are much more common than are people who program with energy efficiency in mind, the power-naive choice will be attractive in many cases.
I own a Nokia N900. Some applications are ported straight from regular Linux and they're definitely power-naive, as they have little or no optimization for mobile. I agree that this is not "sloppy" or "bad", it's just that mobile (low power) wasn't the intended target of the application when it was written, and this commonly shows.
Just like some people will burn CPU cycles by writing their application in a high-level language because it requires fewer man-hours and that you get thousands of cpu-hours for the cost of a man-hour programming the thing (often by externalising the true cost of power which makes power even less of a problem), not caring much about power is rational behaviour when creating an application for pc.
Just look at flash ads, they consume huge amounts of power and they commonly never stop. I imagine that the power used by PCs around the world displaying web pages with advertising with the monitor in power-save mode (powered down) can be counted in gigawatts. When I need my battery to last on my laptop I make sure I don't have any unneccessary tabs enabled because it seriously affects my battery time. I think laptop users would benefit from more power optimized applications as well, so if the OS could do the same for laptop/desktop use as well (spending less time on programs updating display when the display is off), I think there are real world benefits for every desktop/laptop/mobile user.
If nothing else, it's environmentally friendly.
Signature · 1 line
Mikael Abrahamsson email: [email protected]
Quoted 1 line · Paul E. McKenney
available to do the programming and how valuable power-awareness is for the application in question. Given that people who program PC-class applications are much more common than are people who program with energy efficiency in mind, the power-naive choice will be attractive in many cases.
I own a Nokia N900. Some applications are ported straight from regular Linux and they're definitely power-naive, as they have little or no optimization for mobile. I agree that this is not "sloppy" or "bad", it's just that mobile (low power) wasn't the intended target of the application when it was written, and this commonly shows.
Just like some people will burn CPU cycles by writing their application in a high-level language because it requires fewer man-hours and that you get thousands of cpu-hours for the cost of a man-hour programming the thing (often by externalising the true cost of power which makes power even less of a problem), not caring much about power is rational behaviour when creating an application for pc.
Just look at flash ads, they consume huge amounts of power and they commonly never stop. I imagine that the power used by PCs around the world displaying web pages with advertising with the monitor in power-save mode (powered down) can be counted in gigawatts. When I need my battery to last on my laptop I make sure I don't have any unneccessary tabs enabled because it seriously affects my battery time. I think laptop users would benefit from more power optimized applications as well, so if the OS could do the same for laptop/desktop use as well (spending less time on programs updating display when the display is off), I think there are real world benefits for every desktop/laptop/mobile user.
If nothing else, it's environmentally friendly.
Signature · 1 line
Mikael Abrahamsson email: [email protected]
Quoted 2 lines · Mikael Abrahamsson
it's just that mobile (low power) wasn't the intended target of the application when it was written, and this commonly shows.
I have another aspect I just thought about. I work for a telephony company. We provide Internet connectivity throught various means, DSL, Ethernet to the Home, mobile etc.
For ETTH and DSL, network usage is pretty straight forward, you send packets, they get delivered pretty quickly with low marginal cost per packet. For mobile, this is not quite so simple. Mobile networks are designed for terminal/UE (user equipment) to use low power, so they go down in low power state after a while. Let's take the case of 3G/HSPA:
After a short while (second) of idleness (no packets being sent), the mobile network negotiates away the high speed resources (the one that enables multimegabit/s transfers) and tries to give it to someone else. After approximately 30 seconds, the terminal goes to "idle", meaning it has no network resources at all. Next time it wants to send something (or the network wants to deliver something to it), network resources need to be negotiated again. This can take 1-2 seconds and uses battery power of course. It also consumes resources in the operator network (because mobility control units need to talk to base stations, tunnels need to be re-negotiated etc).
Anyhow, my point is that not only is there a benefit in having multiple applications wake up at the same time for power reasons within the device, there is also a point in having coordination of their network access. If a device is running 3 IM programs at the same time, it'd be beneficial if they were coordinated in their communication with their Internet servers. Same goes for the "check for new email" application. If they all were optimized to only wake up the network connectivity once every 180 seconds instead of doing it when the individual application felt like it, power and other resources would be saved by all involved parties.
Signature · 1 line
Mikael Abrahamsson email: [email protected]
Quoted 1 line · Mikael Abrahamsson
it's just that mobile (low power) wasn't the intended target of the application when it was written, and this commonly shows.
I have another aspect I just thought about. I work for a telephony company. We provide Internet connectivity throught various means, DSL, Ethernet to the Home, mobile etc.
For ETTH and DSL, network usage is pretty straight forward, you send packets, they get delivered pretty quickly with low marginal cost per packet. For mobile, this is not quite so simple. Mobile networks are designed for terminal/UE (user equipment) to use low power, so they go down in low power state after a while. Let's take the case of 3G/HSPA:
After a short while (second) of idleness (no packets being sent), the mobile network negotiates away the high speed resources (the one that enables multimegabit/s transfers) and tries to give it to someone else. After approximately 30 seconds, the terminal goes to "idle", meaning it has no network resources at all. Next time it wants to send something (or the network wants to deliver something to it), network resources need to be negotiated again. This can take 1-2 seconds and uses battery power of course. It also consumes resources in the operator network (because mobility control units need to talk to base stations, tunnels need to be re-negotiated etc).
Anyhow, my point is that not only is there a benefit in having multiple applications wake up at the same time for power reasons within the device, there is also a point in having coordination of their network access. If a device is running 3 IM programs at the same time, it'd be beneficial if they were coordinated in their communication with their Internet servers. Same goes for the "check for new email" application. If they all were optimized to only wake up the network connectivity once every 180 seconds instead of doing it when the individual application felt like it, power and other resources would be saved by all involved parties.
Signature · 1 line
Mikael Abrahamsson email: [email protected]
Quoted 28 lines · Alan Stern
Quoted 26 lines · Paul E. McKenney
Rushing in where angels fear to tread...
I had been quite happily ignoring the suspend-blockers controversy. However, now that I have signed up for the Linaro project that involves embedded battery-powered devices, I find that ignorance is no longer bliss. I have therefore reviewed much of the suspend-blocker/wakelock material, but have not yet seen a clear exposition of the requirements that suspend blockers are supposed to meet. This email is a attempt to present the requirements, based on my interpretation of the LKML discussions.
Please note that I am not proposing a solution that meets these requirements, nor am I attempting to judge the various proposed solutions. In fact, I am not even trying to judge whether the requirements are optimal, or even whether or not they make sense at all. My only goal at the moment is to improve my understanding of what the Android folks' requirements are. That said, I do include example mechanisms as needed to clarify the meaning of the requirements. This should not be interpreted as a preference for any given example mechanism.
But first I am going to look at nomenclature, as it appears to me that at least some of the flamage was due to conflicting definitions. Following that, the requirements, nice-to-haves, apparent non-requirements, an example power-optimized applications, and finally a brief look at other applications.
Quoted 24 lines
Quoted 3 lines
Donning the asbestos suit, the one with the tungsten pinstripes...
Thanx, Paul
At the risk of sticking my neck out, I think a few of your statements don't fully capture the important ideas.
Quoted 17 lines
------------------------------------------------------------------------
DEFINITIONS
o "Ill-behaved application" AKA "untrusted application" AKA
"crappy application". The Android guys seem to be thinking in terms of applications that are well-designed and well-implemented in general, but which do not take power consumption or battery life into account. Examples include applications designed for AC-powered PCs. Many other people seemed to instead be thinking in terms of an ill-conceived or useless application, perhaps exemplified by "bouncing cows".Assuming I have correctly guessed what the Android guys were thinking of, perhaps "power-naive applications" would be a better description, which I will use until someone convinces me otherwise.
I'd slightly prefer these to be called "power-oblvious applications", to reflect the fact that their authors might not take power management into consideration in any form.
Quoted 9 lines
Quoted 8 lines
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
Quoted 6 lines
Notice that these definitions allow a program to be both power-naive and power-aware. In addition, "power-awareness" isn't an inherent property of the application itself, since users are allowed to decide which programs may exert control over the system's power state. The same application could be power-aware on one system and non-power-aware on another.
Also, there is another type of "power-awareness", related to the ability to react to power management events signaled, for example, by pm-utils using dbus protocol (NetworkManager is one such application). However, the applications having that ability don't really participate in making a decision to change the state of the system, while the applications using wakelocks do.
In the wakelocks (or suspend blockers, whatever you prefer to call them) world no single entity is powerful enough to make the system go into a sleep state, but some applications and device drivers collectively can make that happen. The applications using wakelocks not only are aware of system power management, but also are components of a "collective power manager", so perhaps it's better to call them "PM-driving applications" or something like this.
Quoted 8 lines
Quoted 5 lines
o Oddly enough, "power-optimized applications" were not discussed.
See "POWER-OPTIMIZED APPLICATIONS" below for a brief introduction. The short version is that power-optimized applications are those power-aware applications that have been aggressively tuned to reduce power consumption.This would be essentially the same as power-aware && !power_naive, right?
Not really, IMO. !power_naive means "doesn't use wakelocks" in this context, while "power-optimized" would mean something like "not only uses wakelocks, but also tries to reduce energy consumption by as much as possible".
Quoted 17 lines
Quoted 4 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be obtained.External power, not necessarily AC power (a very minor point).
Quoted 10 lines
o It is necessary to be able to use power-naive applications.
Many of these applications were designed for use in PC platforms where power consumption has historically not been of great concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations. The system must be capable of running these power-naive applications without requiring that these applications be modified, and must be capable of reasonable power efficiency even when power-naive applications are available.
Quoted 6 lines
Quoted 2 lines
o If the display is powered off, there is no need to run any
application whose only effect is to update the display.On Android this goes somewhat farther. IIUC, they want hardly anything to run while the display is powered off. (But my understanding could be wrong.)
Not really. Quite a lot of things happen on these systems while the display is off (let alone the periodic battery monitoring on Nexus One :-)). They can send things over the network and do similar stuff in that state.
I think the opposite is true, ie. the display is aggressively turned off whenever it appears not to be used, because it draws a lot of power.
Quoted 4 lines
For computers in general, of course, this statement is correct. The same is true for any output-only device. For example, if the audio speakers are powered off, there is no need to run any application whose only effect is to play sounds through the speakers.
Agreed.
Quoted 7 lines
Quoted 7 lines
Although one could simply block such an application when it next tries to access the display, it appears that it is highly desirable that the application also be prevented from consuming power computing anything that will not be displayed. Furthermore, whatever mechanism is used must operate on power-naive applications that do not use blocking system calls.
Quoted 8 lines
Quoted 5 lines
o In order to avoid overrunning hardware and/or kernel buffers,
input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.This goes well beyond overrunning buffers! Events must be delivered in a timely fashion so that the system isn't perceived to be inoperative.
That's correct, although it doesn't seem to apply to any kind of input events. For example, on Nexus One the touchscreen doesn't generate wakeup events (ie. events that wake the system up from a sleep states), so I'm not sure to what extent they are supposed to block (automatic) suspends.
Quoted 5 lines
Quoted 5 lines
In particular, if user input that would prevent the system from entering a low-power state is received while the system is transitioning into a low-power state, the system must transition back out of the low-power state so that it can hand the user input off to the corresponding application.
Side note. I'd like to avoid confusing device states with system-as-a-whole states, so I always prefer to refer to the system-as-a-whole-low-power states as "system sleep states", while term "low-power state" is reserved for individual devices.
Also in some cases (ACPI mostly) a "system sleep state" is more than a "system low-power state", because you can put the system into a low-power state by putting a number of devices into low-power states, which is not sufficient to put the system into a sleep state (the platform has to be programmed in a special way to carry out that operation). Now, wakelocks are about "system sleep states", not about "system low-power states" in general.
Quoted 4 lines
Quoted 3 lines
o If a power-aware application receives user input, then that
application must be given the opportunity to process that input.
Quoted 8 lines
A better way to put this is: The API must provide a means for power-aware applications receiving user input to keep themselves running until they have been able to process the input.
This is probably also true for power-aware applications having other needs (e.g., non-input-driven computation). In general, power-aware applications must have a mechanism to prevent themselves from being stopped for power-related reasons.
Agreed.
Quoted 6 lines
Quoted 6 lines
o A power-aware application must be able to efficiently communicate
its needs to the system, so that such communication can be performed on hot code paths. Communication viaopen()andclose()is considered too slow, but communication viaioctl()is acceptable.
Quoted 7 lines
Quoted 3 lines
o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
Agreed.
Quoted 17 lines
Quoted 10 lines
o Statistics of the power-control actions taken by power-aware
applications must be provided, and must be keyed off of program name.o Power-aware applications can make use of power-naive infrastructure.
This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.Quoted 6 lines
o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
Quoted 3 lines
No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
Agreed.
Quoted 9 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating
a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)The controversy was not over the basic point but rather over the detailed meaning of "runnable". A technical matter, related to the implementation of the scheduler.
Well, I _think_ it was about the basic point too, since "all execution" means periodic timers in particular and involves shutting down clock sources (except for the RTC).
Arguably, suspending "all execution" is not necessary to achieve a satisfactory level of energy saving, at least on a number of systems.
Thanks,
Rafael
Quoted 28 lines · Alan Stern
Quoted 26 lines · Paul E. McKenney
Rushing in where angels fear to tread...
I had been quite happily ignoring the suspend-blockers controversy. However, now that I have signed up for the Linaro project that involves embedded battery-powered devices, I find that ignorance is no longer bliss. I have therefore reviewed much of the suspend-blocker/wakelock material, but have not yet seen a clear exposition of the requirements that suspend blockers are supposed to meet. This email is a attempt to present the requirements, based on my interpretation of the LKML discussions.
Please note that I am not proposing a solution that meets these requirements, nor am I attempting to judge the various proposed solutions. In fact, I am not even trying to judge whether the requirements are optimal, or even whether or not they make sense at all. My only goal at the moment is to improve my understanding of what the Android folks' requirements are. That said, I do include example mechanisms as needed to clarify the meaning of the requirements. This should not be interpreted as a preference for any given example mechanism.
But first I am going to look at nomenclature, as it appears to me that at least some of the flamage was due to conflicting definitions. Following that, the requirements, nice-to-haves, apparent non-requirements, an example power-optimized applications, and finally a brief look at other applications.
Quoted 24 lines
Quoted 3 lines
Donning the asbestos suit, the one with the tungsten pinstripes...
Thanx, Paul
At the risk of sticking my neck out, I think a few of your statements don't fully capture the important ideas.
Quoted 17 lines
------------------------------------------------------------------------
DEFINITIONS
o "Ill-behaved application" AKA "untrusted application" AKA
"crappy application". The Android guys seem to be thinking in terms of applications that are well-designed and well-implemented in general, but which do not take power consumption or battery life into account. Examples include applications designed for AC-powered PCs. Many other people seemed to instead be thinking in terms of an ill-conceived or useless application, perhaps exemplified by "bouncing cows".Assuming I have correctly guessed what the Android guys were thinking of, perhaps "power-naive applications" would be a better description, which I will use until someone convinces me otherwise.
I'd slightly prefer these to be called "power-oblvious applications", to reflect the fact that their authors might not take power management into consideration in any form.
Quoted 9 lines
Quoted 8 lines
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
Quoted 6 lines
Notice that these definitions allow a program to be both power-naive and power-aware. In addition, "power-awareness" isn't an inherent property of the application itself, since users are allowed to decide which programs may exert control over the system's power state. The same application could be power-aware on one system and non-power-aware on another.
Also, there is another type of "power-awareness", related to the ability to react to power management events signaled, for example, by pm-utils using dbus protocol (NetworkManager is one such application). However, the applications having that ability don't really participate in making a decision to change the state of the system, while the applications using wakelocks do.
In the wakelocks (or suspend blockers, whatever you prefer to call them) world no single entity is powerful enough to make the system go into a sleep state, but some applications and device drivers collectively can make that happen. The applications using wakelocks not only are aware of system power management, but also are components of a "collective power manager", so perhaps it's better to call them "PM-driving applications" or something like this.
Quoted 8 lines
Quoted 5 lines
o Oddly enough, "power-optimized applications" were not discussed.
See "POWER-OPTIMIZED APPLICATIONS" below for a brief introduction. The short version is that power-optimized applications are those power-aware applications that have been aggressively tuned to reduce power consumption.This would be essentially the same as power-aware && !power_naive, right?
Not really, IMO. !power_naive means "doesn't use wakelocks" in this context, while "power-optimized" would mean something like "not only uses wakelocks, but also tries to reduce energy consumption by as much as possible".
Quoted 17 lines
Quoted 4 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be obtained.External power, not necessarily AC power (a very minor point).
Quoted 10 lines
o It is necessary to be able to use power-naive applications.
Many of these applications were designed for use in PC platforms where power consumption has historically not been of great concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations. The system must be capable of running these power-naive applications without requiring that these applications be modified, and must be capable of reasonable power efficiency even when power-naive applications are available.
Quoted 6 lines
Quoted 2 lines
o If the display is powered off, there is no need to run any
application whose only effect is to update the display.On Android this goes somewhat farther. IIUC, they want hardly anything to run while the display is powered off. (But my understanding could be wrong.)
Not really. Quite a lot of things happen on these systems while the display is off (let alone the periodic battery monitoring on Nexus One :-)). They can send things over the network and do similar stuff in that state.
I think the opposite is true, ie. the display is aggressively turned off whenever it appears not to be used, because it draws a lot of power.
Quoted 4 lines
For computers in general, of course, this statement is correct. The same is true for any output-only device. For example, if the audio speakers are powered off, there is no need to run any application whose only effect is to play sounds through the speakers.
Agreed.
Quoted 7 lines
Quoted 7 lines
Although one could simply block such an application when it next tries to access the display, it appears that it is highly desirable that the application also be prevented from consuming power computing anything that will not be displayed. Furthermore, whatever mechanism is used must operate on power-naive applications that do not use blocking system calls.
Quoted 8 lines
Quoted 5 lines
o In order to avoid overrunning hardware and/or kernel buffers,
input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.This goes well beyond overrunning buffers! Events must be delivered in a timely fashion so that the system isn't perceived to be inoperative.
That's correct, although it doesn't seem to apply to any kind of input events. For example, on Nexus One the touchscreen doesn't generate wakeup events (ie. events that wake the system up from a sleep states), so I'm not sure to what extent they are supposed to block (automatic) suspends.
Quoted 5 lines
Quoted 5 lines
In particular, if user input that would prevent the system from entering a low-power state is received while the system is transitioning into a low-power state, the system must transition back out of the low-power state so that it can hand the user input off to the corresponding application.
Side note. I'd like to avoid confusing device states with system-as-a-whole states, so I always prefer to refer to the system-as-a-whole-low-power states as "system sleep states", while term "low-power state" is reserved for individual devices.
Also in some cases (ACPI mostly) a "system sleep state" is more than a "system low-power state", because you can put the system into a low-power state by putting a number of devices into low-power states, which is not sufficient to put the system into a sleep state (the platform has to be programmed in a special way to carry out that operation). Now, wakelocks are about "system sleep states", not about "system low-power states" in general.
Quoted 4 lines
Quoted 3 lines
o If a power-aware application receives user input, then that
application must be given the opportunity to process that input.
Quoted 8 lines
A better way to put this is: The API must provide a means for power-aware applications receiving user input to keep themselves running until they have been able to process the input.
This is probably also true for power-aware applications having other needs (e.g., non-input-driven computation). In general, power-aware applications must have a mechanism to prevent themselves from being stopped for power-related reasons.
Agreed.
Quoted 6 lines
Quoted 6 lines
o A power-aware application must be able to efficiently communicate
its needs to the system, so that such communication can be performed on hot code paths. Communication viaopen()andclose()is considered too slow, but communication viaioctl()is acceptable.
Quoted 7 lines
Quoted 3 lines
o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
Agreed.
Quoted 17 lines
Quoted 10 lines
o Statistics of the power-control actions taken by power-aware
applications must be provided, and must be keyed off of program name.o Power-aware applications can make use of power-naive infrastructure.
This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.Quoted 6 lines
o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
Quoted 3 lines
No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
Agreed.
Quoted 9 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating
a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)The controversy was not over the basic point but rather over the detailed meaning of "runnable". A technical matter, related to the implementation of the scheduler.
Well, I _think_ it was about the basic point too, since "all execution" means periodic timers in particular and involves shutting down clock sources (except for the RTC).
Arguably, suspending "all execution" is not necessary to achieve a satisfactory level of energy saving, at least on a number of systems.
Thanks,
Rafael
Quoted 28 lines · Arjan van de Ven
Quoted 13 lines · On Sat, 31 Jul 2010 22:48:16 -0700 "Paul E. McKenney"…
Quoted 12 lines · Arjan van de Ven
Quoted 8 lines · On Sat, 31 Jul 2010 10:58:42 -0700 "Paul E. McKenney"…
o "Power-aware application" are applications that are
permitted to acquire suspend blockers on Android. Verion 8 of the
suspend-blocker patch seems to use group permissions to
determine which applications are classified as power aware.More generally, power-aware applications seem to be those
that have permission to exert some control over the system's
power state.Quoted 7 lines
Quoted 2 lines
I don't like the term "Power aware application". An application is well behaved or it isn't. "aware" has nothing to do with it.
Applications are often complex enough to be aware of some things, naive about others, well behaved in some ways, and ill-behaved in others. This has been the case for some decades now, so it should not come as a surprise.
I do not like the term "aware". At all.
It implies "awareness", and implies it does things based on the power circumstances.
Quoted 7 lines
It's about *behaving well*. (not polling, not having activity when there is nothing to do etc etc). Not about being aware that power matters.
I can write a very shitty application that polls all the time and otherwise keeps the CPU and system busy, but it'll be aware that power matters.. it just doesn't behave accordingly.
I understand that you would prefer that we group applications into "good" and "bad" categories, but then again, I suspect that most of us understood that before you posted this message. Given your significant and well-appreciated contributions to power efficiency over the past several years, I must confess to be quite disappointed that you failed to do more than to simply restate your preference.
However, your words below are much more to the point, so I will respond to them.
Quoted 7 lines
Quoted 6 lines
The choice between power-aware and power-naive will depend on who is available to do the programming and how valuable power-awareness is for the application in question. Given that people who program PC-class applications are much more common than are people who program with energy efficiency in mind, the power-naive choice will be attractive in many cases.
Quoted 9 lines
I'm not sure I buy that.
4 years ago.. yes.
Today.. with PowerTOP and co out there for a long time?
I don't believe that anymore. Most of our open source PC apps are actually very well behaving in the power sense.
Yes an occasional bug slips in, and then gets fixed quickly. (speaking as someone who does this sort of work for a Linux distribution... yes bugs happen on a whole distro level, but they're also not all that common, and get fixed quickly)
I agree that much progress has been made over the past four years. My laptop's battery life has increased substantially, with roughly half of the increase due to software changes. Taken over all the laptops and PCs out there, this indeed adds up to substantial and valuable savings.
So, yes, you have done quite well.
However, your reliance on application-by-application fixes, while good up to a point, is worrisome longer term. The reason for my concern is that computing history has not been kind to those who fail to vigorously automate. The Android guys have offered up one way of automating power efficiency. There might be better ways, but their approach does at the very least deserve a fair hearing -- and no one who read the recent LKML discussion of their approach could possibly mistake it for anything resembling a fair hearing.
And yes, I do understand and appreciate your contributions in the form of things like timer aggregation, which does automate the otherwise-tricky task of coordinating power usage across unrelated applications, at least in some important cases. But power efficiency will likely require multiple approaches, especially if the Linux stack is to approach the power efficiencies provided by dedicated devices.
Thanx, Paul
Quoted 28 lines · Arjan van de Ven
Quoted 13 lines · On Sat, 31 Jul 2010 22:48:16 -0700 "Paul E. McKenney"…
Quoted 12 lines · Arjan van de Ven
Quoted 8 lines · On Sat, 31 Jul 2010 10:58:42 -0700 "Paul E. McKenney"…
o "Power-aware application" are applications that are
permitted to acquire suspend blockers on Android. Verion 8 of the
suspend-blocker patch seems to use group permissions to
determine which applications are classified as power aware.More generally, power-aware applications seem to be those
that have permission to exert some control over the system's
power state.Quoted 7 lines
Quoted 2 lines
I don't like the term "Power aware application". An application is well behaved or it isn't. "aware" has nothing to do with it.
Applications are often complex enough to be aware of some things, naive about others, well behaved in some ways, and ill-behaved in others. This has been the case for some decades now, so it should not come as a surprise.
I do not like the term "aware". At all.
It implies "awareness", and implies it does things based on the power circumstances.
Quoted 7 lines
It's about *behaving well*. (not polling, not having activity when there is nothing to do etc etc). Not about being aware that power matters.
I can write a very shitty application that polls all the time and otherwise keeps the CPU and system busy, but it'll be aware that power matters.. it just doesn't behave accordingly.
I understand that you would prefer that we group applications into "good" and "bad" categories, but then again, I suspect that most of us understood that before you posted this message. Given your significant and well-appreciated contributions to power efficiency over the past several years, I must confess to be quite disappointed that you failed to do more than to simply restate your preference.
However, your words below are much more to the point, so I will respond to them.
Quoted 7 lines
Quoted 6 lines
The choice between power-aware and power-naive will depend on who is available to do the programming and how valuable power-awareness is for the application in question. Given that people who program PC-class applications are much more common than are people who program with energy efficiency in mind, the power-naive choice will be attractive in many cases.
Quoted 9 lines
I'm not sure I buy that.
4 years ago.. yes.
Today.. with PowerTOP and co out there for a long time?
I don't believe that anymore. Most of our open source PC apps are actually very well behaving in the power sense.
Yes an occasional bug slips in, and then gets fixed quickly. (speaking as someone who does this sort of work for a Linux distribution... yes bugs happen on a whole distro level, but they're also not all that common, and get fixed quickly)
I agree that much progress has been made over the past four years. My laptop's battery life has increased substantially, with roughly half of the increase due to software changes. Taken over all the laptops and PCs out there, this indeed adds up to substantial and valuable savings.
So, yes, you have done quite well.
However, your reliance on application-by-application fixes, while good up to a point, is worrisome longer term. The reason for my concern is that computing history has not been kind to those who fail to vigorously automate. The Android guys have offered up one way of automating power efficiency. There might be better ways, but their approach does at the very least deserve a fair hearing -- and no one who read the recent LKML discussion of their approach could possibly mistake it for anything resembling a fair hearing.
And yes, I do understand and appreciate your contributions in the form of things like timer aggregation, which does automate the otherwise-tricky task of coordinating power usage across unrelated applications, at least in some important cases. But power efficiency will likely require multiple approaches, especially if the Linux stack is to approach the power efficiencies provided by dedicated devices.
Thanx, Paul
Quoted 4 lines · Mikael Abrahamsson
Quoted 2 lines · Mikael Abrahamsson
it's just that mobile (low power) wasn't the intended target of the application when it was written, and this commonly shows.
Good points in both this and your earlier post!!!
Quoted 23 lines
I have another aspect I just thought about. I work for a telephony company. We provide Internet connectivity throught various means, DSL, Ethernet to the Home, mobile etc.
For ETTH and DSL, network usage is pretty straight forward, you send packets, they get delivered pretty quickly with low marginal cost per packet. For mobile, this is not quite so simple. Mobile networks are designed for terminal/UE (user equipment) to use low power, so they go down in low power state after a while. Let's take the case of 3G/HSPA:
After a short while (second) of idleness (no packets being sent), the mobile network negotiates away the high speed resources (the one that enables multimegabit/s transfers) and tries to give it to someone else. After approximately 30 seconds, the terminal goes to "idle", meaning it has no network resources at all. Next time it wants to send something (or the network wants to deliver something to it), network resources need to be negotiated again. This can take 1-2 seconds and uses battery power of course. It also consumes resources in the operator network (because mobility control units need to talk to base stations, tunnels need to be re-negotiated etc).
Quoted 10 lines
Anyhow, my point is that not only is there a benefit in having multiple applications wake up at the same time for power reasons within the device, there is also a point in having coordination of their network access. If a device is running 3 IM programs at the same time, it'd be beneficial if they were coordinated in their communication with their Internet servers. Same goes for the "check for new email" application. If they all were optimized to only wake up the network connectivity once every 180 seconds instead of doing it when the individual application felt like it, power and other resources would be saved by all involved parties.
This is a good point. Within some limits, the timer-aggregation changes that have gone into Linux can handle this, but I am not sure whether or not 180 seconds is within the reasonable boundaries for timer jitter.
Of course, the timers might be synchronized upon wakeup after a sufficiently long suspension, but they would not necessarily stay synchronized without the help of some other mechanism, such as the afore-mentioned timer-aggregation changes.
Thanx, Paul
Quoted 4 lines · Mikael Abrahamsson
Quoted 2 lines · Mikael Abrahamsson
it's just that mobile (low power) wasn't the intended target of the application when it was written, and this commonly shows.
Good points in both this and your earlier post!!!
Quoted 23 lines
I have another aspect I just thought about. I work for a telephony company. We provide Internet connectivity throught various means, DSL, Ethernet to the Home, mobile etc.
For ETTH and DSL, network usage is pretty straight forward, you send packets, they get delivered pretty quickly with low marginal cost per packet. For mobile, this is not quite so simple. Mobile networks are designed for terminal/UE (user equipment) to use low power, so they go down in low power state after a while. Let's take the case of 3G/HSPA:
After a short while (second) of idleness (no packets being sent), the mobile network negotiates away the high speed resources (the one that enables multimegabit/s transfers) and tries to give it to someone else. After approximately 30 seconds, the terminal goes to "idle", meaning it has no network resources at all. Next time it wants to send something (or the network wants to deliver something to it), network resources need to be negotiated again. This can take 1-2 seconds and uses battery power of course. It also consumes resources in the operator network (because mobility control units need to talk to base stations, tunnels need to be re-negotiated etc).
Quoted 10 lines
Anyhow, my point is that not only is there a benefit in having multiple applications wake up at the same time for power reasons within the device, there is also a point in having coordination of their network access. If a device is running 3 IM programs at the same time, it'd be beneficial if they were coordinated in their communication with their Internet servers. Same goes for the "check for new email" application. If they all were optimized to only wake up the network connectivity once every 180 seconds instead of doing it when the individual application felt like it, power and other resources would be saved by all involved parties.
This is a good point. Within some limits, the timer-aggregation changes that have gone into Linux can handle this, but I am not sure whether or not 180 seconds is within the reasonable boundaries for timer jitter.
Of course, the timers might be synchronized upon wakeup after a sufficiently long suspension, but they would not necessarily stay synchronized without the help of some other mechanism, such as the afore-mentioned timer-aggregation changes.
Thanx, Paul
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
Quoted 6 lines
Quoted 6 lines
Notice that these definitions allow a program to be both power-naive and power-aware. In addition, "power-awareness" isn't an inherent property of the application itself, since users are allowed to decide which programs may exert control over the system's power state. The same application could be power-aware on one system and non-power-aware on another.
I should have made a stronger point: "power-aware" is _not_ a good term for these applications. "power-enabled" would be better but still not ideal. Maybe "power-permitted"? The definition is that they are _permitted_ to do something (acquire suspend blockers), not that they actually _do_ something.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be obtained.External power, not necessarily AC power (a very minor point).
A good one, though.
Arjan's point here is well taken. Even systems that always run on external power have motivation for conserving energy (e.g., they may be required by government regulation to do so).
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
o In order to avoid overrunning hardware and/or kernel buffers,
input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.
Quoted 7 lines
Quoted 2 lines
This goes well beyond overrunning buffers! Events must be delivered in a timely fashion so that the system isn't perceived to be inoperative.
Agreed for power-aware applications. For power-naive applications, the last event delivered can be buffered by the application with no response if I understand correctly. If there is a subsequent event for that same application, then the prior event can be processed.
I was agreeing with the requirement but disagreeing with the reason given for it. Even when buffers are large enough that the danger of overrunning them is infinitesimal, delays in input event delivery are still undesirable.
Besides, the Android kernel doesn't vary its behavior based on whether the recipient is power-permitted or power-naive; it _always_ delivers input events in a timely fashion.
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
o If a power-aware application receives user input, then that
application must be given the opportunity to process that input.A better way to put this is: The API must provide a means for power-aware applications receiving user input to keep themselves running until they have been able to process the input.
Good point! Would it also make sense to say "events" in general rather than "input" in particular?
Sure.
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
I see your point, but I don't feel comfortable deleting this requirement. My rationale is that the definition needs some enforcement mechanism, and this requirement is calling out the need for such a mechanism.
Then state it immediately after the definition as an implication of the definition, not as a separate system requirement.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
Quoted 8 lines
Quoted 3 lines
No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
I am not sure we agree on the definition of "power-optimized application". But leaving that aside, I thought that Arve and Brian explicitly stated this as a requirement on power-aware applications -- one of the responsibilities that came with the power to block suspend.
No. There are _no_ requirements on power-permitted (or power-aware if you prefer) applications, other than that the user decides to give it the appropriate permission.
Internally, of course, Android may enforce this rule on their own software. But it has no force in regard to external applications.
Quoted 11 lines
Quoted 9 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating
a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)The controversy was not over the basic point but rather over the detailed meaning of "runnable". A technical matter, related to the implementation of the scheduler.
OK, what would you suggest for the wording of this requirement?
Change the last phrase to "regardless of the state of power-naive applications".
Alan Stern
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
Quoted 6 lines
Quoted 6 lines
Notice that these definitions allow a program to be both power-naive and power-aware. In addition, "power-awareness" isn't an inherent property of the application itself, since users are allowed to decide which programs may exert control over the system's power state. The same application could be power-aware on one system and non-power-aware on another.
I should have made a stronger point: "power-aware" is _not_ a good term for these applications. "power-enabled" would be better but still not ideal. Maybe "power-permitted"? The definition is that they are _permitted_ to do something (acquire suspend blockers), not that they actually _do_ something.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be obtained.External power, not necessarily AC power (a very minor point).
A good one, though.
Arjan's point here is well taken. Even systems that always run on external power have motivation for conserving energy (e.g., they may be required by government regulation to do so).
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
o In order to avoid overrunning hardware and/or kernel buffers,
input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.
Quoted 7 lines
Quoted 2 lines
This goes well beyond overrunning buffers! Events must be delivered in a timely fashion so that the system isn't perceived to be inoperative.
Agreed for power-aware applications. For power-naive applications, the last event delivered can be buffered by the application with no response if I understand correctly. If there is a subsequent event for that same application, then the prior event can be processed.
I was agreeing with the requirement but disagreeing with the reason given for it. Even when buffers are large enough that the danger of overrunning them is infinitesimal, delays in input event delivery are still undesirable.
Besides, the Android kernel doesn't vary its behavior based on whether the recipient is power-permitted or power-naive; it _always_ delivers input events in a timely fashion.
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
o If a power-aware application receives user input, then that
application must be given the opportunity to process that input.A better way to put this is: The API must provide a means for power-aware applications receiving user input to keep themselves running until they have been able to process the input.
Good point! Would it also make sense to say "events" in general rather than "input" in particular?
Sure.
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
I see your point, but I don't feel comfortable deleting this requirement. My rationale is that the definition needs some enforcement mechanism, and this requirement is calling out the need for such a mechanism.
Then state it immediately after the definition as an implication of the definition, not as a separate system requirement.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
Quoted 8 lines
Quoted 3 lines
No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
I am not sure we agree on the definition of "power-optimized application". But leaving that aside, I thought that Arve and Brian explicitly stated this as a requirement on power-aware applications -- one of the responsibilities that came with the power to block suspend.
No. There are _no_ requirements on power-permitted (or power-aware if you prefer) applications, other than that the user decides to give it the appropriate permission.
Internally, of course, Android may enforce this rule on their own software. But it has no force in regard to external applications.
Quoted 11 lines
Quoted 9 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating
a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)The controversy was not over the basic point but rather over the detailed meaning of "runnable". A technical matter, related to the implementation of the scheduler.
OK, what would you suggest for the wording of this requirement?
Change the last phrase to "regardless of the state of power-naive applications".
Alan Stern
Quoted 17 lines · Paul E. McKenney
Quoted 11 lines
Quoted 8 lines
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to
determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
I don't like the term "Power aware application". An application is well behaved or it isn't. "aware" has nothing to do with it.
Applications are often complex enough to be aware of some things, naive about others, well behaved in some ways, and ill-behaved in others. This has been the case for some decades now, so it should not come as a surprise.
Quoted 5 lines
I am of course open to suggestions for alternatives to the term "power aware application", but most definitely not to obfuscating the difference between power awareness (or whatever name one wishes to call it) and the overall quality of the application, whatever "quality" might mean in a given context.
This is a false dichotomy. The two of you have fallen into a logical trap. I forget the word used to describe an argument based on a fundamental misunderstanding, but it applies here.
The term "power-aware" has _nothing_ to do with how well behaved an application is, or its quality (in any sense). Go back and re-read the definition; you'll see what I mean.
Alan Stern
Quoted 17 lines · Paul E. McKenney
Quoted 11 lines
Quoted 8 lines
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to
determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
I don't like the term "Power aware application". An application is well behaved or it isn't. "aware" has nothing to do with it.
Applications are often complex enough to be aware of some things, naive about others, well behaved in some ways, and ill-behaved in others. This has been the case for some decades now, so it should not come as a surprise.
Quoted 5 lines
I am of course open to suggestions for alternatives to the term "power aware application", but most definitely not to obfuscating the difference between power awareness (or whatever name one wishes to call it) and the overall quality of the application, whatever "quality" might mean in a given context.
This is a false dichotomy. The two of you have fallen into a logical trap. I forget the word used to describe an argument based on a fundamental misunderstanding, but it applies here.
The term "power-aware" has _nothing_ to do with how well behaved an application is, or its quality (in any sense). Go back and re-read the definition; you'll see what I mean.
Alan Stern
Quoted 49 lines · Rafael J. Wysocki
Quoted 48 lines · Alan Stern
Quoted 26 lines · Paul E. McKenney
Rushing in where angels fear to tread...
I had been quite happily ignoring the suspend-blockers controversy. However, now that I have signed up for the Linaro project that involves embedded battery-powered devices, I find that ignorance is no longer bliss. I have therefore reviewed much of the suspend-blocker/wakelock material, but have not yet seen a clear exposition of the requirements that suspend blockers are supposed to meet. This email is a attempt to present the requirements, based on my interpretation of the LKML discussions.
Please note that I am not proposing a solution that meets these requirements, nor am I attempting to judge the various proposed solutions. In fact, I am not even trying to judge whether the requirements are optimal, or even whether or not they make sense at all. My only goal at the moment is to improve my understanding of what the Android folks' requirements are. That said, I do include example mechanisms as needed to clarify the meaning of the requirements. This should not be interpreted as a preference for any given example mechanism.
But first I am going to look at nomenclature, as it appears to me that at least some of the flamage was due to conflicting definitions. Following that, the requirements, nice-to-haves, apparent non-requirements, an example power-optimized applications, and finally a brief look at other applications.
Quoted 3 lines
Donning the asbestos suit, the one with the tungsten pinstripes...
Thanx, Paul
At the risk of sticking my neck out, I think a few of your statements don't fully capture the important ideas.
Quoted 13 lines
------------------------------------------------------------------------
DEFINITIONS
o "Ill-behaved application" AKA "untrusted application" AKA
"crappy application". The Android guys seem to be thinking in terms of applications that are well-designed and well-implemented in general, but which do not take power consumption or battery life into account. Examples include applications designed for AC-powered PCs. Many other people seemed to instead be thinking in terms of an ill-conceived or useless application, perhaps exemplified by "bouncing cows".
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Assuming I have correctly guessed what the Android guys were thinking of, perhaps "power-naive applications" would be a better description, which I will use until someone convinces me otherwise.
I'd slightly prefer these to be called "power-oblvious applications", to reflect the fact that their authors might not take power management into consideration in any form.
I am fine with "power-oblivious applications".
Quoted 16 lines
Quoted 9 lines
Quoted 8 lines
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
Quoted 6 lines
Notice that these definitions allow a program to be both power-naive and power-aware. In addition, "power-awareness" isn't an inherent property of the application itself, since users are allowed to decide which programs may exert control over the system's power state. The same application could be power-aware on one system and non-power-aware on another.
Quoted 5 lines
Also, there is another type of "power-awareness", related to the ability to react to power management events signaled, for example, by pm-utils using dbus protocol (NetworkManager is one such application). However, the applications having that ability don't really participate in making a decision to change the state of the system, while the applications using wakelocks do.
Perhaps this group is best named "power-aware applications"?
Quoted 7 lines
In the wakelocks (or suspend blockers, whatever you prefer to call them) world no single entity is powerful enough to make the system go into a sleep state, but some applications and device drivers collectively can make that happen. The applications using wakelocks not only are aware of system power management, but also are components of a "collective power manager", so perhaps it's better to call them "PM-driving applications" or something like this.
Right, any PM-driving application can -prevent- the system from entering a deep sleep state, but no single application can force this -- aside from using the traditional non-opportunistic suspend facility, that is.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
o Oddly enough, "power-optimized applications" were not discussed.
See "POWER-OPTIMIZED APPLICATIONS" below for a brief introduction. The short version is that power-optimized applications are those power-aware applications that have been aggressively tuned to reduce power consumption.
Quoted 6 lines
Quoted 2 lines
This would be essentially the same as power-aware && !power_naive, right?
Not really, IMO. !power_naive means "doesn't use wakelocks" in this context, while "power-optimized" would mean something like "not only uses wakelocks, but also tries to reduce energy consumption by as much as possible".
I agree with this. A power-optimized application is something that goes to lengths to minimize its power consumption, regardless of whether something like wakelocks is in the picture.
Quoted 24 lines
Quoted 17 lines
Quoted 4 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be obtained.External power, not necessarily AC power (a very minor point).
Quoted 10 lines
o It is necessary to be able to use power-naive applications.
Many of these applications were designed for use in PC platforms where power consumption has historically not been of great concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations. The system must be capable of running these power-naive applications without requiring that these applications be modified, and must be capable of reasonable power efficiency even when power-naive applications are available.Quoted 6 lines
Quoted 2 lines
o If the display is powered off, there is no need to run any
application whose only effect is to update the display.On Android this goes somewhat farther. IIUC, they want hardly anything to run while the display is powered off. (But my understanding could be wrong.)
Quoted 6 lines
Not really. Quite a lot of things happen on these systems while the display is off (let alone the periodic battery monitoring on Nexus One :-)). They can send things over the network and do similar stuff in that state.
I think the opposite is true, ie. the display is aggressively turned off whenever it appears not to be used, because it draws a lot of power.
Fair enough. It appears to me that Android won't suspend if the display is on, but I could easily be confused here.
Quoted 20 lines
Quoted 4 lines
For computers in general, of course, this statement is correct. The same is true for any output-only device. For example, if the audio speakers are powered off, there is no need to run any application whose only effect is to play sounds through the speakers.
Agreed.
Quoted 13 lines
Quoted 12 lines
Although one could simply block such an application when it next tries to access the display, it appears that it is highly desirable that the application also be prevented from consuming power computing anything that will not be displayed. Furthermore, whatever mechanism is used must operate on power-naive applications that do not use blocking system calls.
o In order to avoid overrunning hardware and/or kernel buffers,
input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.
Quoted 7 lines
Quoted 2 lines
This goes well beyond overrunning buffers! Events must be delivered in a timely fashion so that the system isn't perceived to be inoperative.
That's correct, although it doesn't seem to apply to any kind of input events. For example, on Nexus One the touchscreen doesn't generate wakeup events (ie. events that wake the system up from a sleep states), so I'm not sure to what extent they are supposed to block (automatic) suspends.
Good point, I forgot that not all events do wakeups. I updated accordingly.
Quoted 11 lines
Quoted 5 lines
Quoted 5 lines
In particular, if user input that would prevent the system from entering a low-power state is received while the system is transitioning into a low-power state, the system must transition back out of the low-power state so that it can hand the user input off to the corresponding application.
Side note. I'd like to avoid confusing device states with system-as-a-whole states, so I always prefer to refer to the system-as-a-whole-low-power states as "system sleep states", while term "low-power state" is reserved for individual devices.
Quoted 7 lines
Also in some cases (ACPI mostly) a "system sleep state" is more than a "system low-power state", because you can put the system into a low-power state by putting a number of devices into low-power states, which is not sufficient to put the system into a sleep state (the platform has to be programmed in a special way to carry out that operation). Now, wakelocks are about "system sleep states", not about "system low-power states" in general.
Good point, noted.
Quoted 25 lines
Quoted 4 lines
Quoted 3 lines
o If a power-aware application receives user input, then that
application must be given the opportunity to process that input.Quoted 8 lines
A better way to put this is: The API must provide a means for power-aware applications receiving user input to keep themselves running until they have been able to process the input.
This is probably also true for power-aware applications having other needs (e.g., non-input-driven computation). In general, power-aware applications must have a mechanism to prevent themselves from being stopped for power-related reasons.
Agreed.
Quoted 10 lines
Quoted 9 lines
o A power-aware application must be able to efficiently communicate
its needs to the system, so that such communication can be performed on hot code paths. Communication viaopen()andclose()is considered too slow, but communication viaioctl()is acceptable.o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.
Quoted 5 lines
Quoted 3 lines
You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
Agreed.
OK, but I still believe that an enforcement mechanism is required.
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
o Statistics of the power-control actions taken by power-aware
applications must be provided, and must be keyed off of program name.o Power-aware applications can make use of power-naive infrastructure.
This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
Quoted 5 lines
Quoted 3 lines
No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
Agreed.
Again, this requirement was explicitly called out by the Android folks.
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating
a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)The controversy was not over the basic point but rather over the detailed meaning of "runnable". A technical matter, related to the implementation of the scheduler.
Quoted 6 lines
Well, I _think_ it was about the basic point too, since "all execution" means periodic timers in particular and involves shutting down clock sources (except for the RTC).
Arguably, suspending "all execution" is not necessary to achieve a satisfactory level of energy saving, at least on a number of systems.
Indeed, some embedded systems are capable of doing quite a lot even when almost everything, including the CPU and cache, is powered down.
Thanx, Paul
Quoted 49 lines · Rafael J. Wysocki
Quoted 48 lines · Alan Stern
Quoted 26 lines · Paul E. McKenney
Rushing in where angels fear to tread...
I had been quite happily ignoring the suspend-blockers controversy. However, now that I have signed up for the Linaro project that involves embedded battery-powered devices, I find that ignorance is no longer bliss. I have therefore reviewed much of the suspend-blocker/wakelock material, but have not yet seen a clear exposition of the requirements that suspend blockers are supposed to meet. This email is a attempt to present the requirements, based on my interpretation of the LKML discussions.
Please note that I am not proposing a solution that meets these requirements, nor am I attempting to judge the various proposed solutions. In fact, I am not even trying to judge whether the requirements are optimal, or even whether or not they make sense at all. My only goal at the moment is to improve my understanding of what the Android folks' requirements are. That said, I do include example mechanisms as needed to clarify the meaning of the requirements. This should not be interpreted as a preference for any given example mechanism.
But first I am going to look at nomenclature, as it appears to me that at least some of the flamage was due to conflicting definitions. Following that, the requirements, nice-to-haves, apparent non-requirements, an example power-optimized applications, and finally a brief look at other applications.
Quoted 3 lines
Donning the asbestos suit, the one with the tungsten pinstripes...
Thanx, Paul
At the risk of sticking my neck out, I think a few of your statements don't fully capture the important ideas.
Quoted 13 lines
------------------------------------------------------------------------
DEFINITIONS
o "Ill-behaved application" AKA "untrusted application" AKA
"crappy application". The Android guys seem to be thinking in terms of applications that are well-designed and well-implemented in general, but which do not take power consumption or battery life into account. Examples include applications designed for AC-powered PCs. Many other people seemed to instead be thinking in terms of an ill-conceived or useless application, perhaps exemplified by "bouncing cows".
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Assuming I have correctly guessed what the Android guys were thinking of, perhaps "power-naive applications" would be a better description, which I will use until someone convinces me otherwise.
I'd slightly prefer these to be called "power-oblvious applications", to reflect the fact that their authors might not take power management into consideration in any form.
I am fine with "power-oblivious applications".
Quoted 16 lines
Quoted 9 lines
Quoted 8 lines
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
Quoted 6 lines
Notice that these definitions allow a program to be both power-naive and power-aware. In addition, "power-awareness" isn't an inherent property of the application itself, since users are allowed to decide which programs may exert control over the system's power state. The same application could be power-aware on one system and non-power-aware on another.
Quoted 5 lines
Also, there is another type of "power-awareness", related to the ability to react to power management events signaled, for example, by pm-utils using dbus protocol (NetworkManager is one such application). However, the applications having that ability don't really participate in making a decision to change the state of the system, while the applications using wakelocks do.
Perhaps this group is best named "power-aware applications"?
Quoted 7 lines
In the wakelocks (or suspend blockers, whatever you prefer to call them) world no single entity is powerful enough to make the system go into a sleep state, but some applications and device drivers collectively can make that happen. The applications using wakelocks not only are aware of system power management, but also are components of a "collective power manager", so perhaps it's better to call them "PM-driving applications" or something like this.
Right, any PM-driving application can -prevent- the system from entering a deep sleep state, but no single application can force this -- aside from using the traditional non-opportunistic suspend facility, that is.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
o Oddly enough, "power-optimized applications" were not discussed.
See "POWER-OPTIMIZED APPLICATIONS" below for a brief introduction. The short version is that power-optimized applications are those power-aware applications that have been aggressively tuned to reduce power consumption.
Quoted 6 lines
Quoted 2 lines
This would be essentially the same as power-aware && !power_naive, right?
Not really, IMO. !power_naive means "doesn't use wakelocks" in this context, while "power-optimized" would mean something like "not only uses wakelocks, but also tries to reduce energy consumption by as much as possible".
I agree with this. A power-optimized application is something that goes to lengths to minimize its power consumption, regardless of whether something like wakelocks is in the picture.
Quoted 24 lines
Quoted 17 lines
Quoted 4 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be obtained.External power, not necessarily AC power (a very minor point).
Quoted 10 lines
o It is necessary to be able to use power-naive applications.
Many of these applications were designed for use in PC platforms where power consumption has historically not been of great concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations. The system must be capable of running these power-naive applications without requiring that these applications be modified, and must be capable of reasonable power efficiency even when power-naive applications are available.Quoted 6 lines
Quoted 2 lines
o If the display is powered off, there is no need to run any
application whose only effect is to update the display.On Android this goes somewhat farther. IIUC, they want hardly anything to run while the display is powered off. (But my understanding could be wrong.)
Quoted 6 lines
Not really. Quite a lot of things happen on these systems while the display is off (let alone the periodic battery monitoring on Nexus One :-)). They can send things over the network and do similar stuff in that state.
I think the opposite is true, ie. the display is aggressively turned off whenever it appears not to be used, because it draws a lot of power.
Fair enough. It appears to me that Android won't suspend if the display is on, but I could easily be confused here.
Quoted 20 lines
Quoted 4 lines
For computers in general, of course, this statement is correct. The same is true for any output-only device. For example, if the audio speakers are powered off, there is no need to run any application whose only effect is to play sounds through the speakers.
Agreed.
Quoted 13 lines
Quoted 12 lines
Although one could simply block such an application when it next tries to access the display, it appears that it is highly desirable that the application also be prevented from consuming power computing anything that will not be displayed. Furthermore, whatever mechanism is used must operate on power-naive applications that do not use blocking system calls.
o In order to avoid overrunning hardware and/or kernel buffers,
input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.
Quoted 7 lines
Quoted 2 lines
This goes well beyond overrunning buffers! Events must be delivered in a timely fashion so that the system isn't perceived to be inoperative.
That's correct, although it doesn't seem to apply to any kind of input events. For example, on Nexus One the touchscreen doesn't generate wakeup events (ie. events that wake the system up from a sleep states), so I'm not sure to what extent they are supposed to block (automatic) suspends.
Good point, I forgot that not all events do wakeups. I updated accordingly.
Quoted 11 lines
Quoted 5 lines
Quoted 5 lines
In particular, if user input that would prevent the system from entering a low-power state is received while the system is transitioning into a low-power state, the system must transition back out of the low-power state so that it can hand the user input off to the corresponding application.
Side note. I'd like to avoid confusing device states with system-as-a-whole states, so I always prefer to refer to the system-as-a-whole-low-power states as "system sleep states", while term "low-power state" is reserved for individual devices.
Quoted 7 lines
Also in some cases (ACPI mostly) a "system sleep state" is more than a "system low-power state", because you can put the system into a low-power state by putting a number of devices into low-power states, which is not sufficient to put the system into a sleep state (the platform has to be programmed in a special way to carry out that operation). Now, wakelocks are about "system sleep states", not about "system low-power states" in general.
Good point, noted.
Quoted 25 lines
Quoted 4 lines
Quoted 3 lines
o If a power-aware application receives user input, then that
application must be given the opportunity to process that input.Quoted 8 lines
A better way to put this is: The API must provide a means for power-aware applications receiving user input to keep themselves running until they have been able to process the input.
This is probably also true for power-aware applications having other needs (e.g., non-input-driven computation). In general, power-aware applications must have a mechanism to prevent themselves from being stopped for power-related reasons.
Agreed.
Quoted 10 lines
Quoted 9 lines
o A power-aware application must be able to efficiently communicate
its needs to the system, so that such communication can be performed on hot code paths. Communication viaopen()andclose()is considered too slow, but communication viaioctl()is acceptable.o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.
Quoted 5 lines
Quoted 3 lines
You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
Agreed.
OK, but I still believe that an enforcement mechanism is required.
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
o Statistics of the power-control actions taken by power-aware
applications must be provided, and must be keyed off of program name.o Power-aware applications can make use of power-naive infrastructure.
This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
Quoted 5 lines
Quoted 3 lines
No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
Agreed.
Again, this requirement was explicitly called out by the Android folks.
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating
a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)The controversy was not over the basic point but rather over the detailed meaning of "runnable". A technical matter, related to the implementation of the scheduler.
Quoted 6 lines
Well, I _think_ it was about the basic point too, since "all execution" means periodic timers in particular and involves shutting down clock sources (except for the RTC).
Arguably, suspending "all execution" is not necessary to achieve a satisfactory level of energy saving, at least on a number of systems.
Indeed, some embedded systems are capable of doing quite a lot even when almost everything, including the CPU and cache, is powered down.
Thanx, Paul
Quoted 16 lines · Alan Stern
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
Quoted 6 lines
Quoted 6 lines
Notice that these definitions allow a program to be both power-naive and power-aware. In addition, "power-awareness" isn't an inherent property of the application itself, since users are allowed to decide which programs may exert control over the system's power state. The same application could be power-aware on one system and non-power-aware on another.
Quoted 5 lines
I should have made a stronger point: "power-aware" is _not_ a good term for these applications. "power-enabled" would be better but still not ideal. Maybe "power-permitted"? The definition is that they are _permitted_ to do something (acquire suspend blockers), not that they actually _do_ something.
How about "PM-driving applications", as Rafael suggested?
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be obtained.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
External power, not necessarily AC power (a very minor point).
A good one, though.
Arjan's point here is well taken. Even systems that always run on external power have motivation for conserving energy (e.g., they may be required by government regulation to do so).
Indeed! However, my observation is that many of the battery-powered embedded folks are much more aggressive in pursuit of energy efficiency than are most of the server/desktop/laptop folks. Both have motivation, but the degree of motivation can differ.
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
o In order to avoid overrunning hardware and/or kernel buffers,
input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.Quoted 7 lines
Quoted 2 lines
This goes well beyond overrunning buffers! Events must be delivered in a timely fashion so that the system isn't perceived to be inoperative.
Agreed for power-aware applications. For power-naive applications, the last event delivered can be buffered by the application with no response if I understand correctly. If there is a subsequent event for that same application, then the prior event can be processed.
Quoted 8 lines
I was agreeing with the requirement but disagreeing with the reason given for it. Even when buffers are large enough that the danger of overrunning them is infinitesimal, delays in input event delivery are still undesirable.
Besides, the Android kernel doesn't vary its behavior based on whether the recipient is power-permitted or power-naive; it _always_ delivers input events in a timely fashion.
True, the difference between the two classes of applications is in whether or not the application is permitted to process the event.
I added "and to minimize response latencies" to the requirement. Does that capture it?
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
o If a power-aware application receives user input, then that
application must be given the opportunity to process that input.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
A better way to put this is: The API must provide a means for power-aware applications receiving user input to keep themselves running until they have been able to process the input.
Good point! Would it also make sense to say "events" in general rather than "input" in particular?
Sure.
K, done.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
Quoted 6 lines
Quoted 3 lines
I see your point, but I don't feel comfortable deleting this requirement. My rationale is that the definition needs some enforcement mechanism, and this requirement is calling out the need for such a mechanism.
Then state it immediately after the definition as an implication of the definition, not as a separate system requirement.
I am OK with that, and have moved it.
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)Quoted 8 lines
Quoted 3 lines
No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
I am not sure we agree on the definition of "power-optimized application". But leaving that aside, I thought that Arve and Brian explicitly stated this as a requirement on power-aware applications -- one of the responsibilities that came with the power to block suspend.
Quoted 6 lines
No. There are _no_ requirements on power-permitted (or power-aware if you prefer) applications, other than that the user decides to give it the appropriate permission.
Internally, of course, Android may enforce this rule on their own software. But it has no force in regard to external applications.
So should this be moved to a new "ANDROID POLICY" section or some such?
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating
a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
The controversy was not over the basic point but rather over the detailed meaning of "runnable". A technical matter, related to the implementation of the scheduler.
OK, what would you suggest for the wording of this requirement?
Change the last phrase to "regardless of the state of power-naive applications".
Done!
Thanx, Paul
Quoted 16 lines · Alan Stern
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to determine which applications are classified as power aware.More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
Quoted 6 lines
Quoted 6 lines
Notice that these definitions allow a program to be both power-naive and power-aware. In addition, "power-awareness" isn't an inherent property of the application itself, since users are allowed to decide which programs may exert control over the system's power state. The same application could be power-aware on one system and non-power-aware on another.
Quoted 5 lines
I should have made a stronger point: "power-aware" is _not_ a good term for these applications. "power-enabled" would be better but still not ideal. Maybe "power-permitted"? The definition is that they are _permitted_ to do something (acquire suspend blockers), not that they actually _do_ something.
How about "PM-driving applications", as Rafael suggested?
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend
battery life and (2) preserve state until AC power can be obtained.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
External power, not necessarily AC power (a very minor point).
A good one, though.
Arjan's point here is well taken. Even systems that always run on external power have motivation for conserving energy (e.g., they may be required by government regulation to do so).
Indeed! However, my observation is that many of the battery-powered embedded folks are much more aggressive in pursuit of energy efficiency than are most of the server/desktop/laptop folks. Both have motivation, but the degree of motivation can differ.
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
o In order to avoid overrunning hardware and/or kernel buffers,
input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.Quoted 7 lines
Quoted 2 lines
This goes well beyond overrunning buffers! Events must be delivered in a timely fashion so that the system isn't perceived to be inoperative.
Agreed for power-aware applications. For power-naive applications, the last event delivered can be buffered by the application with no response if I understand correctly. If there is a subsequent event for that same application, then the prior event can be processed.
Quoted 8 lines
I was agreeing with the requirement but disagreeing with the reason given for it. Even when buffers are large enough that the danger of overrunning them is infinitesimal, delays in input event delivery are still undesirable.
Besides, the Android kernel doesn't vary its behavior based on whether the recipient is power-permitted or power-naive; it _always_ delivers input events in a timely fashion.
True, the difference between the two classes of applications is in whether or not the application is permitted to process the event.
I added "and to minimize response latencies" to the requirement. Does that capture it?
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
o If a power-aware application receives user input, then that
application must be given the opportunity to process that input.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
A better way to put this is: The API must provide a means for power-aware applications receiving user input to keep themselves running until they have been able to process the input.
Good point! Would it also make sense to say "events" in general rather than "input" in particular?
Sure.
K, done.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
Quoted 6 lines
Quoted 3 lines
I see your point, but I don't feel comfortable deleting this requirement. My rationale is that the definition needs some enforcement mechanism, and this requirement is calling out the need for such a mechanism.
Then state it immediately after the definition as an implication of the definition, not as a separate system requirement.
I am OK with that, and have moved it.
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)Quoted 8 lines
Quoted 3 lines
No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
I am not sure we agree on the definition of "power-optimized application". But leaving that aside, I thought that Arve and Brian explicitly stated this as a requirement on power-aware applications -- one of the responsibilities that came with the power to block suspend.
Quoted 6 lines
No. There are _no_ requirements on power-permitted (or power-aware if you prefer) applications, other than that the user decides to give it the appropriate permission.
Internally, of course, Android may enforce this rule on their own software. But it has no force in regard to external applications.
So should this be moved to a new "ANDROID POLICY" section or some such?
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating
a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
The controversy was not over the basic point but rather over the detailed meaning of "runnable". A technical matter, related to the implementation of the scheduler.
OK, what would you suggest for the wording of this requirement?
Change the last phrase to "regardless of the state of power-naive applications".
Done!
Thanx, Paul
Quoted 7 lines · Paul E. McKenney
I understand that you would prefer that we group applications into "good" and "bad" categories, but then again, I suspect that most of us understood that before you posted this message. Given your significant and well-appreciated contributions to power efficiency over the past several years, I must confess to be quite disappointed that you failed to do more than to simply restate your preference.
Paul, I very much agree with what you stated later, with respect to doubting whether the whack-a-mole approach to application fixups is workable. Given how many applications screw up using fsync() correctly, to the extent that XFS, ext4, and btrfs all had to agree on a common hueristics to deal with the fact that application programmers are aggressively ignorant, and outnumber the file system developers, I too doubt the general strategy of relying only on application programmers to do the right thing. That's not to say that we shouldn't give up on trying to influence application programmers --- but relying on that as the only strategy seems to depart from the path of wisdom.
There is however a much bigger point, which is that it's unfortunately black and white to talk about applications being "good" and "bad". In fact, it's a continuing point of concern I have with the whole qos approach to power management. In fact, power is often something that needs to trade off against performance. For example, an application could aggressively prefetch e-mail messages or web pages that a user _might_ view --- or it could aggressively pre-resolve DNS queries, etc, which might make perfect sense when the device is hooked up to AC mains, but which I might not want to do on when I only have 800mWh worth of battery --- however, if I'm using a laptop with 94,000mWh, maybe I'd be happy if the application was a bit more profligate.
So for Arjan to claim that all applications will be held to the same standard, whether they are hooked up to the AC mains, or are limited to 800mWh of battery, or 94,000 mWh worth of power, is vastly oversimplifying the problem. Of *course* if I'm writing an application that will be running in a cloud data center, I'm going to care about power. But I may have different tradeoffs about what might considered acceptible when considering the qualify of user experience I'm delivering to the end-user when I'm connected to AC mains, versus a cell phone battery, versus a 6-cell laptop battery.
This brings me back to a major problem I have with the pm_qos approach to power management. It assumes that applications know best, and that they should be free to tell pm_qos subsystem whether they need 0ms latency for wireless. Right now, I can't even query the pm_qos subsystem to see which application is responsible for keeping the wireless on 100% of the time! And even if I could find out, maybe some power management framework should be allowed to give a override to the application's wishes. OK, maybe the Opera web browser is requesting the very best wireless QOS because it wants to beat Chrome on some silly potato benchmark --- well, it's ***stupid*** to say that my power management should be a one-size-fits all because applications should be always as power efficient as possible whether they are connected to AC mains or I have a 800mWh cell phone battery. Worse yet, it's stupid to say that the application should have the last word. Darn it, *I* own the mobile device, and I (or my proxy, which might be the Android OS, or some power manage daemon) should be able to say, "I don't care what the application claimed it wanted for power QOS --- it's not getting more than 100ms wireless latency, and that's final."
And note that this is something that might even change over time, or depending on circumstances. Maybe normally I might be willing to let the application be profilgate with power, so that web pages render a bit faster than they might otherwise --- but if I'm on an American Airlines flight which has retrofitted its power jacks to use an AC plug, and I only have a DC adaptor, and my laptop batteries are worn out and only have half their endurance as they used to, I might want to use a more stringent pm_qos than I might otherwise normally allow.
- Ted
Quoted 7 lines · Paul E. McKenney
Quoted 5 lines
I should have made a stronger point: "power-aware" is _not_ a good term for these applications. "power-enabled" would be better but still not ideal. Maybe "power-permitted"? The definition is that they are _permitted_ to do something (acquire suspend blockers), not that they actually _do_ something.
How about "PM-driving applications", as Rafael suggested?
Perhaps. But it's a little misleading, since what these applications are permitted to do is to _prevent_ the system from going to low power. So in a real sense they don't drive PM -- they block it. (Indeed, that's what inspired the name "suspend blocker".) Of course, the same objection applies to "power-permitted".
Quoted 9 lines
Quoted 8 lines
I was agreeing with the requirement but disagreeing with the reason given for it. Even when buffers are large enough that the danger of overrunning them is infinitesimal, delays in input event delivery are still undesirable.
Besides, the Android kernel doesn't vary its behavior based on whether the recipient is power-permitted or power-naive; it _always_ delivers input events in a timely fashion.
Quoted 5 lines
True, the difference between the two classes of applications is in whether or not the application is permitted to process the event.
I added "and to minimize response latencies" to the requirement. Does that capture it?
Yes.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
But leaving that aside, I thought that Arve and Brian explicitly stated this as a requirement on power-aware applications -- one of the responsibilities that came with the power to block suspend.
Quoted 8 lines
Quoted 6 lines
No. There are _no_ requirements on power-permitted (or power-aware if you prefer) applications, other than that the user decides to give it the appropriate permission.
Internally, of course, Android may enforce this rule on their own software. But it has no force in regard to external applications.
So should this be moved to a new "ANDROID POLICY" section or some such?
Or DESIRED BEHAVIOR, or some such.
Alan Stern
Quoted 7 lines · Paul E. McKenney
Quoted 5 lines
I should have made a stronger point: "power-aware" is _not_ a good term for these applications. "power-enabled" would be better but still not ideal. Maybe "power-permitted"? The definition is that they are _permitted_ to do something (acquire suspend blockers), not that they actually _do_ something.
How about "PM-driving applications", as Rafael suggested?
Perhaps. But it's a little misleading, since what these applications are permitted to do is to _prevent_ the system from going to low power. So in a real sense they don't drive PM -- they block it. (Indeed, that's what inspired the name "suspend blocker".) Of course, the same objection applies to "power-permitted".
Quoted 9 lines
Quoted 8 lines
I was agreeing with the requirement but disagreeing with the reason given for it. Even when buffers are large enough that the danger of overrunning them is infinitesimal, delays in input event delivery are still undesirable.
Besides, the Android kernel doesn't vary its behavior based on whether the recipient is power-permitted or power-naive; it _always_ delivers input events in a timely fashion.
Quoted 5 lines
True, the difference between the two classes of applications is in whether or not the application is permitted to process the event.
I added "and to minimize response latencies" to the requirement. Does that capture it?
Yes.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
But leaving that aside, I thought that Arve and Brian explicitly stated this as a requirement on power-aware applications -- one of the responsibilities that came with the power to block suspend.
Quoted 8 lines
Quoted 6 lines
No. There are _no_ requirements on power-permitted (or power-aware if you prefer) applications, other than that the user decides to give it the appropriate permission.
Internally, of course, Android may enforce this rule on their own software. But it has no force in regard to external applications.
So should this be moved to a new "ANDROID POLICY" section or some such?
Or DESIRED BEHAVIOR, or some such.
Alan Stern
Quoted 3 lines
Quoted 1 line
Quoted 1 line
I should have made a stronger point:
"power-aware" is _not_ a good
Quoted 1 line
Quoted 1 line
term for these applications.
Strongly disagree. The whole point is that they ARE VERY MUCH AWARE and interact with a power policy to achieve goals.
Like refusing to power down active subsystems, or actively powering down inactive ones. Q.E.D. ... "aware".
Quoted 3 lines
Quoted 1 line
Quoted 1 line
I should have made a stronger point:
"power-aware" is _not_ a good
Quoted 1 line
Quoted 1 line
term for these applications.
Strongly disagree. The whole point is that they ARE VERY MUCH AWARE and interact with a power policy to achieve goals.
Like refusing to power down active subsystems, or actively powering down inactive ones. Q.E.D. ... "aware".
Quoted 7 lines · Paul E. McKenney
I understand that you would prefer that we group applications into "good" and "bad" categories, but then again, I suspect that most of us understood that before you posted this message. Given your significant and well-appreciated contributions to power efficiency over the past several years, I must confess to be quite disappointed that you failed to do more than to simply restate your preference.
Paul, I very much agree with what you stated later, with respect to doubting whether the whack-a-mole approach to application fixups is workable. Given how many applications screw up using fsync() correctly, to the extent that XFS, ext4, and btrfs all had to agree on a common hueristics to deal with the fact that application programmers are aggressively ignorant, and outnumber the file system developers, I too doubt the general strategy of relying only on application programmers to do the right thing. That's not to say that we shouldn't give up on trying to influence application programmers --- but relying on that as the only strategy seems to depart from the path of wisdom.
There is however a much bigger point, which is that it's unfortunately black and white to talk about applications being "good" and "bad". In fact, it's a continuing point of concern I have with the whole qos approach to power management. In fact, power is often something that needs to trade off against performance. For example, an application could aggressively prefetch e-mail messages or web pages that a user _might_ view --- or it could aggressively pre-resolve DNS queries, etc, which might make perfect sense when the device is hooked up to AC mains, but which I might not want to do on when I only have 800mWh worth of battery --- however, if I'm using a laptop with 94,000mWh, maybe I'd be happy if the application was a bit more profligate.
So for Arjan to claim that all applications will be held to the same standard, whether they are hooked up to the AC mains, or are limited to 800mWh of battery, or 94,000 mWh worth of power, is vastly oversimplifying the problem. Of *course* if I'm writing an application that will be running in a cloud data center, I'm going to care about power. But I may have different tradeoffs about what might considered acceptible when considering the qualify of user experience I'm delivering to the end-user when I'm connected to AC mains, versus a cell phone battery, versus a 6-cell laptop battery.
This brings me back to a major problem I have with the pm_qos approach to power management. It assumes that applications know best, and that they should be free to tell pm_qos subsystem whether they need 0ms latency for wireless. Right now, I can't even query the pm_qos subsystem to see which application is responsible for keeping the wireless on 100% of the time! And even if I could find out, maybe some power management framework should be allowed to give a override to the application's wishes. OK, maybe the Opera web browser is requesting the very best wireless QOS because it wants to beat Chrome on some silly potato benchmark --- well, it's ***stupid*** to say that my power management should be a one-size-fits all because applications should be always as power efficient as possible whether they are connected to AC mains or I have a 800mWh cell phone battery. Worse yet, it's stupid to say that the application should have the last word. Darn it, *I* own the mobile device, and I (or my proxy, which might be the Android OS, or some power manage daemon) should be able to say, "I don't care what the application claimed it wanted for power QOS --- it's not getting more than 100ms wireless latency, and that's final."
And note that this is something that might even change over time, or depending on circumstances. Maybe normally I might be willing to let the application be profilgate with power, so that web pages render a bit faster than they might otherwise --- but if I'm on an American Airlines flight which has retrofitted its power jacks to use an AC plug, and I only have a DC adaptor, and my laptop batteries are worn out and only have half their endurance as they used to, I might want to use a more stringent pm_qos than I might otherwise normally allow.
- Ted
Quoted 3 lines · Paul E. McKenney
Quoted 2 lines · Rafael J. Wysocki
Quoted 1 line · Alan Stern
On Sat, 31 Jul 2010, Paul E. McKenney wrote:
...
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
On Android this goes somewhat farther. IIUC, they want hardly anything to run while the display is powered off. (But my understanding could be wrong.)
Not really. Quite a lot of things happen on these systems while the display is off (let alone the periodic battery monitoring on Nexus One :-)). They can send things over the network and do similar stuff in that state.
Quoted 5 lines
Quoted 2 lines
I think the opposite is true, ie. the display is aggressively turned off whenever it appears not to be used, because it draws a lot of power.
Fair enough. It appears to me that Android won't suspend if the display is on, but I could easily be confused here.
That's correct. In fact, Android uses a special mechanism called "early suspend" (or similar) to suspend the display and some other devices before the "real" suspend happens.
...
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines
o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
Agreed.
OK, but I still believe that an enforcement mechanism is required.
The requirement is that power-oblivious applications should not participate in deciding whether or not to put the system into a sleep state which is pretty much by definition.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
o Statistics of the power-control actions taken by power-aware
applications must be provided, and must be keyed off of program name.o Power-aware applications can make use of power-naive infrastructure.
This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
Agreed.
Again, this requirement was explicitly called out by the Android folks.
Rather, there should be a mechanism allowing PM-driving applications to do that, but they are not required to use that mechanism.
Thanks,
Rafael
Quoted 3 lines · Paul E. McKenney
Quoted 2 lines · Rafael J. Wysocki
Quoted 1 line · Alan Stern
On Sat, 31 Jul 2010, Paul E. McKenney wrote:
...
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
On Android this goes somewhat farther. IIUC, they want hardly anything to run while the display is powered off. (But my understanding could be wrong.)
Not really. Quite a lot of things happen on these systems while the display is off (let alone the periodic battery monitoring on Nexus One :-)). They can send things over the network and do similar stuff in that state.
Quoted 5 lines
Quoted 2 lines
I think the opposite is true, ie. the display is aggressively turned off whenever it appears not to be used, because it draws a lot of power.
Fair enough. It appears to me that Android won't suspend if the display is on, but I could easily be confused here.
That's correct. In fact, Android uses a special mechanism called "early suspend" (or similar) to suspend the display and some other devices before the "real" suspend happens.
...
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines
o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
Agreed.
OK, but I still believe that an enforcement mechanism is required.
The requirement is that power-oblivious applications should not participate in deciding whether or not to put the system into a sleep state which is pretty much by definition.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
o Statistics of the power-control actions taken by power-aware
applications must be provided, and must be keyed off of program name.o Power-aware applications can make use of power-naive infrastructure.
This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
Agreed.
Again, this requirement was explicitly called out by the Android folks.
Rather, there should be a mechanism allowing PM-driving applications to do that, but they are not required to use that mechanism.
Thanks,
Rafael
Quoted 17 lines · On Sun, 1 Aug 2010 12:12:28 -0700 "Paul E. McKenney"…
I agree that much progress has been made over the past four years. My laptop's battery life has increased substantially, with roughly half of the increase due to software changes. Taken over all the laptops and PCs out there, this indeed adds up to substantial and valuable savings.
So, yes, you have done quite well.
However, your reliance on application-by-application fixes, while good up to a point, is worrisome longer term. The reason for my concern is that computing history has not been kind to those who fail to vigorously automate. The Android guys have offered up one way of automating power efficiency. There might be better ways, but their approach does at the very least deserve a fair hearing -- and no one who read the recent LKML discussion of their approach could possibly mistake it for anything resembling a fair hearing.
Quoted 8 lines
And yes, I do understand and appreciate your contributions in the form of things like timer aggregation, which does automate the otherwise-tricky task of coordinating power usage across unrelated applications, at least in some important cases. But power efficiency will likely require multiple approaches, especially if the Linux stack is to approach the power efficiencies provided by dedicated devices.
power indeed needs multiple approaches. For example the timer work you mention. What the timer work allows is controlling the behavior of applications that are not well behaved. This is an important way of driving progress, one the android guys sort of swept under the table.
Is the flash plugin (which seems to be the most popular and also worst behaving software in these type of discussions) waking up 100 times per second? <small adjustment by a policy manager> ... now it's only waking up once every 10 seconds, or when something else causes system activity anyway.
That capability is there in Linux today, and has been there for a long time now. It's highly underused unfortunately... at least outside the MeeGo world of Linux distributions.
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
on the suspend blockers for drivers; the linux device runtime PM is effectively doing the same things; it allows drivers to suspend/resume individually (with a very nice API/programming model I should say) based on usage. And it works on a tree level, so that it's relatively easy to do things like "I want to go to <this magic deep idle state>, but only if <this set of devices is suspended already>". This is obviously an important functionality for all low power devices, ARM or x86. Suspend blockers had this functionality as part of what it did (they do more obviously) but I'd wager that the current Linux infrastructure is outright nicer.
It's what I want to be using for the Intel phone silicon (which isn't all that different in power behavior/requirements than ARM based silicon), and I need to thank Qualcomm here for providing some very good patches to the kernel to allow this model to work for this scenario.
As for the aware-versus-good-behaving point; applications can be aware, and yet bad behaving, and can be unaware but good behaving. You don't like me saying this, but the reality is that the behavior matters in the end. *AND WE OBSERVE THIS BEHAVIOR*. It's not hard to move a program/task/whatever from a "behaves well, let run unrestricted" to a "doesn't behave well, needs its behavior adjusted" list and back, just from its behavior. PowerTOP observes such apps. Android has an equivalent thing that observes app behavior. It's not all that hard to detect such things.... and the result is much better than some static "aware" flag one can tag an application with. The "aware" flag indicates that there is a "before" and an "after", and that that's it. Reality isn't so black and white as you stated, but that goes for both sides. Observing *current* behavior is much more powerful. Is the part of the app you use fine, even though some function you don't use behave badly? No problem, you get it categorized with the good guys. Is an app 98% working clean, but you on your phone like using the 2% all the time? it's moved to the "must get its attitude adjusted" list.
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
Quoted 17 lines · On Sun, 1 Aug 2010 12:12:28 -0700 "Paul E. McKenney"…
I agree that much progress has been made over the past four years. My laptop's battery life has increased substantially, with roughly half of the increase due to software changes. Taken over all the laptops and PCs out there, this indeed adds up to substantial and valuable savings.
So, yes, you have done quite well.
However, your reliance on application-by-application fixes, while good up to a point, is worrisome longer term. The reason for my concern is that computing history has not been kind to those who fail to vigorously automate. The Android guys have offered up one way of automating power efficiency. There might be better ways, but their approach does at the very least deserve a fair hearing -- and no one who read the recent LKML discussion of their approach could possibly mistake it for anything resembling a fair hearing.
Quoted 8 lines
And yes, I do understand and appreciate your contributions in the form of things like timer aggregation, which does automate the otherwise-tricky task of coordinating power usage across unrelated applications, at least in some important cases. But power efficiency will likely require multiple approaches, especially if the Linux stack is to approach the power efficiencies provided by dedicated devices.
power indeed needs multiple approaches. For example the timer work you mention. What the timer work allows is controlling the behavior of applications that are not well behaved. This is an important way of driving progress, one the android guys sort of swept under the table.
Is the flash plugin (which seems to be the most popular and also worst behaving software in these type of discussions) waking up 100 times per second? <small adjustment by a policy manager> ... now it's only waking up once every 10 seconds, or when something else causes system activity anyway.
That capability is there in Linux today, and has been there for a long time now. It's highly underused unfortunately... at least outside the MeeGo world of Linux distributions.
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
on the suspend blockers for drivers; the linux device runtime PM is effectively doing the same things; it allows drivers to suspend/resume individually (with a very nice API/programming model I should say) based on usage. And it works on a tree level, so that it's relatively easy to do things like "I want to go to <this magic deep idle state>, but only if <this set of devices is suspended already>". This is obviously an important functionality for all low power devices, ARM or x86. Suspend blockers had this functionality as part of what it did (they do more obviously) but I'd wager that the current Linux infrastructure is outright nicer.
It's what I want to be using for the Intel phone silicon (which isn't all that different in power behavior/requirements than ARM based silicon), and I need to thank Qualcomm here for providing some very good patches to the kernel to allow this model to work for this scenario.
As for the aware-versus-good-behaving point; applications can be aware, and yet bad behaving, and can be unaware but good behaving. You don't like me saying this, but the reality is that the behavior matters in the end. *AND WE OBSERVE THIS BEHAVIOR*. It's not hard to move a program/task/whatever from a "behaves well, let run unrestricted" to a "doesn't behave well, needs its behavior adjusted" list and back, just from its behavior. PowerTOP observes such apps. Android has an equivalent thing that observes app behavior. It's not all that hard to detect such things.... and the result is much better than some static "aware" flag one can tag an application with. The "aware" flag indicates that there is a "before" and an "after", and that that's it. Reality isn't so black and white as you stated, but that goes for both sides. Observing *current* behavior is much more powerful. Is the part of the app you use fine, even though some function you don't use behave badly? No problem, you get it categorized with the good guys. Is an app 98% working clean, but you on your phone like using the 2% all the time? it's moved to the "must get its attitude adjusted" list.
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
Quoted 42 lines · On Sun, 1 Aug 2010 12:27:08 -0700 "Paul E. McKenney"…
Quoted 4 lines · Mikael Abrahamsson
Quoted 2 lines · Mikael Abrahamsson
it's just that mobile (low power) wasn't the intended target of the application when it was written, and this commonly shows.
Good points in both this and your earlier post!!!
Quoted 23 lines
I have another aspect I just thought about. I work for a telephony company. We provide Internet connectivity throught various means, DSL, Ethernet to the Home, mobile etc.
For ETTH and DSL, network usage is pretty straight forward, you send packets, they get delivered pretty quickly with low marginal cost per packet. For mobile, this is not quite so simple. Mobile networks are designed for terminal/UE (user equipment) to use low power, so they go down in low power state after a while. Let's take the case of 3G/HSPA:
After a short while (second) of idleness (no packets being sent), the mobile network negotiates away the high speed resources (the one that enables multimegabit/s transfers) and tries to give it to someone else. After approximately 30 seconds, the terminal goes to "idle", meaning it has no network resources at all. Next time it wants to send something (or the network wants to deliver something to it), network resources need to be negotiated again. This can take 1-2 seconds and uses battery power of course. It also consumes resources in the operator network (because mobility control units need to talk to base stations, tunnels need to be re-negotiated etc).
Quoted 10 lines
Anyhow, my point is that not only is there a benefit in having multiple applications wake up at the same time for power reasons within the device, there is also a point in having coordination of their network access. If a device is running 3 IM programs at the same time, it'd be beneficial if they were coordinated in their communication with their Internet servers. Same goes for the "check for new email" application. If they all were optimized to only wake up the network connectivity once every 180 seconds instead of doing it when the individual application felt like it, power and other resources would be saved by all involved parties.
Quoted 4 lines
This is a good point. Within some limits, the timer-aggregation changes that have gone into Linux can handle this, but I am not sure whether or not 180 seconds is within the reasonable boundaries for timer jitter.
this is why operating systems for mobile devices offer heartbeat services... where apps subscribe to and do background work like checking email at "convenient" times.
I'm not sure if the OS you use on your desktop has one, but MeeGo and Maemo and I'm pretty sure Android and most other mobile Linux OSes have one. It's a higher level activity alignment layer, well above the kernel.
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
Quoted 42 lines · On Sun, 1 Aug 2010 12:27:08 -0700 "Paul E. McKenney"…
Quoted 4 lines · Mikael Abrahamsson
Quoted 2 lines · Mikael Abrahamsson
it's just that mobile (low power) wasn't the intended target of the application when it was written, and this commonly shows.
Good points in both this and your earlier post!!!
Quoted 23 lines
I have another aspect I just thought about. I work for a telephony company. We provide Internet connectivity throught various means, DSL, Ethernet to the Home, mobile etc.
For ETTH and DSL, network usage is pretty straight forward, you send packets, they get delivered pretty quickly with low marginal cost per packet. For mobile, this is not quite so simple. Mobile networks are designed for terminal/UE (user equipment) to use low power, so they go down in low power state after a while. Let's take the case of 3G/HSPA:
After a short while (second) of idleness (no packets being sent), the mobile network negotiates away the high speed resources (the one that enables multimegabit/s transfers) and tries to give it to someone else. After approximately 30 seconds, the terminal goes to "idle", meaning it has no network resources at all. Next time it wants to send something (or the network wants to deliver something to it), network resources need to be negotiated again. This can take 1-2 seconds and uses battery power of course. It also consumes resources in the operator network (because mobility control units need to talk to base stations, tunnels need to be re-negotiated etc).
Quoted 10 lines
Anyhow, my point is that not only is there a benefit in having multiple applications wake up at the same time for power reasons within the device, there is also a point in having coordination of their network access. If a device is running 3 IM programs at the same time, it'd be beneficial if they were coordinated in their communication with their Internet servers. Same goes for the "check for new email" application. If they all were optimized to only wake up the network connectivity once every 180 seconds instead of doing it when the individual application felt like it, power and other resources would be saved by all involved parties.
Quoted 4 lines
This is a good point. Within some limits, the timer-aggregation changes that have gone into Linux can handle this, but I am not sure whether or not 180 seconds is within the reasonable boundaries for timer jitter.
this is why operating systems for mobile devices offer heartbeat services... where apps subscribe to and do background work like checking email at "convenient" times.
I'm not sure if the OS you use on your desktop has one, but MeeGo and Maemo and I'm pretty sure Android and most other mobile Linux OSes have one. It's a higher level activity alignment layer, well above the kernel.
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
On Sun, 1 Aug 2010 16:40:26 -0400
Quoted 3 lines
There is however a much bigger point, which is that it's unfortunately black and white to talk about applications being "good" and "bad".
I'll agree with this.
this is extremely situational.. not only where things run, but also, which part of the application you're talking about. If your application has 3 features (a $0.99 app store app) it's not too burdensome to make all 3 features work well for "power on a phone".
If your app has 5000 features... what do you do when 4500 are behaving well, and the other 500 are somewhat obscure?
Quoted 10 lines
In
fact, it's a continuing point of concern I have with the whole qos approach to power management. In fact, power is often something that needs to trade off against performance. For example, an application could aggressively prefetch e-mail messages or web pages that a user _might_ view --- or it could aggressively pre-resolve DNS queries, etc, which might make perfect sense when the device is hooked up to AC mains, but which I might not want to do on when I only have 800mWh worth of battery --- however, if I'm using a laptop with 94,000mWh, maybe I'd be happy if the application was a bit more profligate.
this is a very tricky area; because prefetching may well be good for power as well.... but "it depends"...
getting DNS ahead of time when you're doing other network stuff anyway? probably a good idea for power, at least when done in moderation. It might save a modem wakeup two seconds down the road.
excessively prefetching DNS all the time? probably not a good idea for power.
Quoted 6 lines
This brings me back to a major problem I have with the
pm_qosapproach to power management. It assumes that applications know best, and that they should be free to tellpm_qossubsystem whether they need 0ms latency for wireless. Right now, I can't even query thepm_qossubsystem to see which application is responsible for keeping the wireless on 100% of the time!
yes if we allowed apps to do this, we absolutely need accountability/diagnostics into it.
Quoted 6 lines
And even if I could find out, maybe
some power management framework should be allowed to give a override to the application's wishes. OK, maybe the Opera web browser is requesting the very best wireless QOS because it wants to beat Chrome on some silly potato benchmark --- well, it's ***stupid*** to say that my power management should be a one-size-fits all because applications
Quoted 8 lines
should be always as power efficient as possible whether they are connected to AC mains or I have a 800mWh cell phone battery. Worse yet, it's stupid to say that the application should have the last word. Darn it, *I* own the mobile device, and I (or my proxy, which might be the Android OS, or some power manage daemon) should be able to say, "I don't care what the application claimed it wanted for power QOS --- it's not getting more than 100ms wireless latency, and that's final."
QOS also should be a request.. and depend on who's asking. If you run as root with realtime privileges, the kernel should probably just give you what you asked for.
If you run as UID 500.... there needs to be either a static rlimit kind of thing, or an intelligent dynamic "clip" to what you ask versus what the system administrator (or his delegate in the form of some policy daemon) wants you to do.
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
On Sun, 1 Aug 2010 16:40:26 -0400
Quoted 3 lines
There is however a much bigger point, which is that it's unfortunately black and white to talk about applications being "good" and "bad".
I'll agree with this.
this is extremely situational.. not only where things run, but also, which part of the application you're talking about. If your application has 3 features (a $0.99 app store app) it's not too burdensome to make all 3 features work well for "power on a phone".
If your app has 5000 features... what do you do when 4500 are behaving well, and the other 500 are somewhat obscure?
Quoted 10 lines
In
fact, it's a continuing point of concern I have with the whole qos approach to power management. In fact, power is often something that needs to trade off against performance. For example, an application could aggressively prefetch e-mail messages or web pages that a user _might_ view --- or it could aggressively pre-resolve DNS queries, etc, which might make perfect sense when the device is hooked up to AC mains, but which I might not want to do on when I only have 800mWh worth of battery --- however, if I'm using a laptop with 94,000mWh, maybe I'd be happy if the application was a bit more profligate.
this is a very tricky area; because prefetching may well be good for power as well.... but "it depends"...
getting DNS ahead of time when you're doing other network stuff anyway? probably a good idea for power, at least when done in moderation. It might save a modem wakeup two seconds down the road.
excessively prefetching DNS all the time? probably not a good idea for power.
Quoted 6 lines
This brings me back to a major problem I have with the
pm_qosapproach to power management. It assumes that applications know best, and that they should be free to tellpm_qossubsystem whether they need 0ms latency for wireless. Right now, I can't even query thepm_qossubsystem to see which application is responsible for keeping the wireless on 100% of the time!
yes if we allowed apps to do this, we absolutely need accountability/diagnostics into it.
Quoted 6 lines
And even if I could find out, maybe
some power management framework should be allowed to give a override to the application's wishes. OK, maybe the Opera web browser is requesting the very best wireless QOS because it wants to beat Chrome on some silly potato benchmark --- well, it's ***stupid*** to say that my power management should be a one-size-fits all because applications
Quoted 8 lines
should be always as power efficient as possible whether they are connected to AC mains or I have a 800mWh cell phone battery. Worse yet, it's stupid to say that the application should have the last word. Darn it, *I* own the mobile device, and I (or my proxy, which might be the Android OS, or some power manage daemon) should be able to say, "I don't care what the application claimed it wanted for power QOS --- it's not getting more than 100ms wireless latency, and that's final."
QOS also should be a request.. and depend on who's asking. If you run as root with realtime privileges, the kernel should probably just give you what you asked for.
If you run as UID 500.... there needs to be either a static rlimit kind of thing, or an intelligent dynamic "clip" to what you ask versus what the system administrator (or his delegate in the form of some policy daemon) wants you to do.
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
Quoted 43 lines · Ted Ts'o
Quoted 7 lines · Paul E. McKenney
I understand that you would prefer that we group applications into "good" and "bad" categories, but then again, I suspect that most of us understood that before you posted this message. Given your significant and well-appreciated contributions to power efficiency over the past several years, I must confess to be quite disappointed that you failed to do more than to simply restate your preference.
Paul, I very much agree with what you stated later, with respect to doubting whether the whack-a-mole approach to application fixups is workable. Given how many applications screw up using
fsync()correctly, to the extent that XFS, ext4, and btrfs all had to agree on a common hueristics to deal with the fact that application programmers are aggressively ignorant, and outnumber the file system developers, I too doubt the general strategy of relying only on application programmers to do the right thing. That's not to say that we shouldn't give up on trying to influence application programmers --- but relying on that as the only strategy seems to depart from the path of wisdom.There is however a much bigger point, which is that it's unfortunately black and white to talk about applications being "good" and "bad". In fact, it's a continuing point of concern I have with the whole qos approach to power management. In fact, power is often something that needs to trade off against performance. For example, an application could aggressively prefetch e-mail messages or web pages that a user _might_ view --- or it could aggressively pre-resolve DNS queries, etc, which might make perfect sense when the device is hooked up to AC mains, but which I might not want to do on when I only have 800mWh worth of battery --- however, if I'm using a laptop with 94,000mWh, maybe I'd be happy if the application was a bit more profligate.
So for Arjan to claim that all applications will be held to the same standard, whether they are hooked up to the AC mains, or are limited to 800mWh of battery, or 94,000 mWh worth of power, is vastly oversimplifying the problem. Of *course* if I'm writing an application that will be running in a cloud data center, I'm going to care about power. But I may have different tradeoffs about what might considered acceptible when considering the qualify of user experience I'm delivering to the end-user when I'm connected to AC mains, versus a cell phone battery, versus a 6-cell laptop battery.
Quoted 8 lines
This brings me back to a major problem I have with the
pm_qosapproach to power management. It assumes that applications know best, and that they should be free to tellpm_qossubsystem whether they need 0ms latency for wireless. Right now, I can't even query thepm_qossubsystem to see which application is responsible for keeping the wireless on 100% of the time! And even if I could find out, maybe some power management framework should be allowed to give a override to the application's wishes.
I agree with that.
Generally speaking, you can divide applications into the ones that will be allowed to influence ths system's behavior with respect to power management and the others that won't be allowed to do it. The latter may be forcibly "frozen" (this way or another) when the "trused" ones collectively decide it's a good idea to enter a deeper "energy saving" state. However, it is not a given that specific applications will always be in the same group. They may be "trusted" on some systems and they may not be "trusted" on some other system, depending on the configuration etc. That even may change over time on the same system.
Thanks,
Rafael
Quoted 12 lines · On Mon, 2 Aug 2010 01:02:24 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
Generally speaking, you can divide applications into the ones that will be allowed to influence ths system's behavior with respect to power management and the others that won't be allowed to do it. The latter may be forcibly "frozen" (this way or another) when the "trused" ones collectively decide it's a good idea to enter a deeper "energy saving" state. However, it is not a given that specific applications will always be in the same group. They may be "trusted" on some systems and they may not be "trusted" on some other system, depending on the configuration etc. That even may change over time on the same system.
it might even be a sliding scale; the voting rights don't have to be "0" and "1", but could also be "0.2" and such....
Quoted 12 lines · On Mon, 2 Aug 2010 01:02:24 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
Generally speaking, you can divide applications into the ones that will be allowed to influence ths system's behavior with respect to power management and the others that won't be allowed to do it. The latter may be forcibly "frozen" (this way or another) when the "trused" ones collectively decide it's a good idea to enter a deeper "energy saving" state. However, it is not a given that specific applications will always be in the same group. They may be "trusted" on some systems and they may not be "trusted" on some other system, depending on the configuration etc. That even may change over time on the same system.
it might even be a sliding scale; the voting rights don't have to be "0" and "1", but could also be "0.2" and such....
Quoted 21 lines · Paul E. McKenney
Quoted 8 lines · Arjan van de Ven
Quoted 5 lines · On Sat, 31 Jul 2010 10:58:42 -0700 "Paul E. McKenney"…
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to
determine which applications are classified as power aware.Quoted 6 lines
Quoted 3 lines
More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
I don't like the term "Power aware application". An application is well behaved or it isn't. "aware" has nothing to do with it.
Applications are often complex enough to be aware of some things, naive about others, well behaved in some ways, and ill-behaved in others. This has been the case for some decades now, so it should not come as a surprise.
Quoted 5 lines
I am of course open to suggestions for alternatives to the term "power aware application", but most definitely not to obfuscating the difference between power awareness (or whatever name one wishes to call it) and the overall quality of the application, whatever "quality" might mean in a given context.
So the reason everyone's having trouble with this definition is that it actually conflates two separate axes of power management.
There are good and bad applications in the power sense ... burns less vs burns more.
And there are user mandated vs user optional processes ... necessary/wanted vs unnecessary/unwanted.
What android actually does is reward well written applications because they "just work" and they don't have to be power aware at all ... they're usually event driven and split into the android provider/consumer model.
Badly written applications that are not suspend block aware get shut down (by system suspend) when the screen turns off, so they're also power/suspend unaware.
Applications that want to present the user with a choice in android are power/suspend aware because the only way they get to present the choice is via suspend blockers.
The "power problem" always devolves to resolving a set of choices around a given set of control axes. The problem is that the set of control axes isn't unique and doesn't have a well agreed upon selection. This makes it hard to make definitive terminology because you have to pick the set of axes (implicitly or explicitly) before defining terms ...
James
Quoted 21 lines · Paul E. McKenney
Quoted 8 lines · Arjan van de Ven
Quoted 5 lines · On Sat, 31 Jul 2010 10:58:42 -0700 "Paul E. McKenney"…
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to
determine which applications are classified as power aware.Quoted 6 lines
Quoted 3 lines
More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
I don't like the term "Power aware application". An application is well behaved or it isn't. "aware" has nothing to do with it.
Applications are often complex enough to be aware of some things, naive about others, well behaved in some ways, and ill-behaved in others. This has been the case for some decades now, so it should not come as a surprise.
Quoted 5 lines
I am of course open to suggestions for alternatives to the term "power aware application", but most definitely not to obfuscating the difference between power awareness (or whatever name one wishes to call it) and the overall quality of the application, whatever "quality" might mean in a given context.
So the reason everyone's having trouble with this definition is that it actually conflates two separate axes of power management.
There are good and bad applications in the power sense ... burns less vs burns more.
And there are user mandated vs user optional processes ... necessary/wanted vs unnecessary/unwanted.
What android actually does is reward well written applications because they "just work" and they don't have to be power aware at all ... they're usually event driven and split into the android provider/consumer model.
Badly written applications that are not suspend block aware get shut down (by system suspend) when the screen turns off, so they're also power/suspend unaware.
Applications that want to present the user with a choice in android are power/suspend aware because the only way they get to present the choice is via suspend blockers.
The "power problem" always devolves to resolving a set of choices around a given set of control axes. The problem is that the set of control axes isn't unique and doesn't have a well agreed upon selection. This makes it hard to make definitive terminology because you have to pick the set of axes (implicitly or explicitly) before defining terms ...
James
Quoted 4 lines
be "trusted" on some systems and they may not be "trusted" on some other
system, depending on the configuration etc.
Yes, let's reserve "trusted" for security contexts.
One might view agressively bad power management as
a security threat, of course: when the machine
becomes unavailable because its battery dies, that
can be viewed as a security attack, since keeping the machine available is the primary security goal.
Distinguish bugs from broken-by-design, too.
- Dave
Quoted 4 lines
be "trusted" on some systems and they may not be "trusted" on some other
system, depending on the configuration etc.
Yes, let's reserve "trusted" for security contexts.
One might view agressively bad power management as
a security threat, of course: when the machine
becomes unavailable because its battery dies, that
can be viewed as a security attack, since keeping the machine available is the primary security goal.
Distinguish bugs from broken-by-design, too.
- Dave
Quoted 4 lines · Ted Ts'o
This brings me back to a major problem I have with the
pm_qosapproach to power management. It assumes that applications know best, and that they should be free to tellpm_qossubsystem whether they need 0ms latency for wireless.
Um, so this behaviour is isomorphic to the suspend block case for the applications. I think everyone agrees that suspend block isn't optimal, but we were prepared to use it as a starting point given the lack of enthusiasm in android for the more innovative approaches that have been proposed.
Quoted 3 lines
Right now, I can't even query the
pm_qos
subsystem to see which application is responsible for keeping the wireless on 100% of the time!
That's hardly a fair criticism: this is easily fixable but the people looking into it have other calls on their time. At least you got some of the basic problems (like init from atomic context and sort efficiency) fixed this time around. If some large organisation actually cared enough to contribute code, we might be moving faster ....
Quoted 6 lines
And even if I could find out, maybe
some power management framework should be allowed to give a override to the application's wishes. OK, maybe the Opera web browser is requesting the very best wireless QOS because it wants to beat Chrome on some silly potato benchmark --- well, it's ***stupid*** to say that my power management should be a one-size-fits all because applications
Quoted 8 lines
should be always as power efficient as possible whether they are connected to AC mains or I have a 800mWh cell phone battery. Worse yet, it's stupid to say that the application should have the last word. Darn it, *I* own the mobile device, and I (or my proxy, which might be the Android OS, or some power manage daemon) should be able to say, "I don't care what the application claimed it wanted for power QOS --- it's not getting more than 100ms wireless latency, and that's final."
That's why you present the user with choices and report on the outcomes. At the end of the day the choice becomes binary: if the mobile optimised browser burns you battery on the power meter, users will either uninstall and move on to the next browser or deny the current browser the ability to block suspend.
Quoted 8 lines
And note that this is something that might even change over time, or depending on circumstances. Maybe normally I might be willing to let the application be profilgate with power, so that web pages render a bit faster than they might otherwise --- but if I'm on an American Airlines flight which has retrofitted its power jacks to use an AC plug, and I only have a DC adaptor, and my laptop batteries are worn out and only have half their endurance as they used to, I might want to use a more stringent
pm_qosthan I might otherwise normally allow.
Right, but this comes back to the axes of control. They have to be presented to the user in a simple but meaningful manner.
James
Quoted 4 lines · Ted Ts'o
This brings me back to a major problem I have with the
pm_qosapproach to power management. It assumes that applications know best, and that they should be free to tellpm_qossubsystem whether they need 0ms latency for wireless.
Um, so this behaviour is isomorphic to the suspend block case for the applications. I think everyone agrees that suspend block isn't optimal, but we were prepared to use it as a starting point given the lack of enthusiasm in android for the more innovative approaches that have been proposed.
Quoted 3 lines
Right now, I can't even query the
pm_qos
subsystem to see which application is responsible for keeping the wireless on 100% of the time!
That's hardly a fair criticism: this is easily fixable but the people looking into it have other calls on their time. At least you got some of the basic problems (like init from atomic context and sort efficiency) fixed this time around. If some large organisation actually cared enough to contribute code, we might be moving faster ....
Quoted 6 lines
And even if I could find out, maybe
some power management framework should be allowed to give a override to the application's wishes. OK, maybe the Opera web browser is requesting the very best wireless QOS because it wants to beat Chrome on some silly potato benchmark --- well, it's ***stupid*** to say that my power management should be a one-size-fits all because applications
Quoted 8 lines
should be always as power efficient as possible whether they are connected to AC mains or I have a 800mWh cell phone battery. Worse yet, it's stupid to say that the application should have the last word. Darn it, *I* own the mobile device, and I (or my proxy, which might be the Android OS, or some power manage daemon) should be able to say, "I don't care what the application claimed it wanted for power QOS --- it's not getting more than 100ms wireless latency, and that's final."
That's why you present the user with choices and report on the outcomes. At the end of the day the choice becomes binary: if the mobile optimised browser burns you battery on the power meter, users will either uninstall and move on to the next browser or deny the current browser the ability to block suspend.
Quoted 8 lines
And note that this is something that might even change over time, or depending on circumstances. Maybe normally I might be willing to let the application be profilgate with power, so that web pages render a bit faster than they might otherwise --- but if I'm on an American Airlines flight which has retrofitted its power jacks to use an AC plug, and I only have a DC adaptor, and my laptop batteries are worn out and only have half their endurance as they used to, I might want to use a more stringent
pm_qosthan I might otherwise normally allow.
Right, but this comes back to the axes of control. They have to be presented to the user in a simple but meaningful manner.
James
Quoted 8 lines · Alan Stern
Quoted 6 lines · Paul E. McKenney
Quoted 5 lines
I should have made a stronger point: "power-aware" is _not_ a good term for these applications. "power-enabled" would be better but still not ideal. Maybe "power-permitted"? The definition is that they are _permitted_ to do something (acquire suspend blockers), not that they actually _do_ something.
Quoted 7 lines
Quoted 1 line
How about "PM-driving applications", as Rafael suggested?
Perhaps. But it's a little misleading, since what these applications are permitted to do is to _prevent_ the system from going to low power. So in a real sense they don't drive PM -- they block it. (Indeed, that's what inspired the name "suspend blocker".) Of course, the same objection applies to "power-permitted".
Good point, but for the moment I would like to keep the number of classes of applications down to a dull roar, and so am proposing one class for applications that either actively control device/system power/sleep or prevent changes in same.
I am of course open to improvements in the "PM-driving applications" name. ;-)
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
I was agreeing with the requirement but disagreeing with the reason given for it. Even when buffers are large enough that the danger of overrunning them is infinitesimal, delays in input event delivery are still undesirable.
Besides, the Android kernel doesn't vary its behavior based on whether the recipient is power-permitted or power-naive; it _always_ delivers input events in a timely fashion.
Quoted 7 lines
Quoted 5 lines
True, the difference between the two classes of applications is in whether or not the application is permitted to process the event.
I added "and to minimize response latencies" to the requirement. Does that capture it?
Yes.
Very good!!!
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
But leaving that aside, I thought that Arve and Brian explicitly stated this as a requirement on power-aware applications -- one of the responsibilities that came with the power to block suspend.
No. There are _no_ requirements on power-permitted (or power-aware if you prefer) applications, other than that the user decides to give it the appropriate permission.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Internally, of course, Android may enforce this rule on their own software. But it has no force in regard to external applications.
So should this be moved to a new "ANDROID POLICY" section or some such?
Or DESIRED BEHAVIOR, or some such.
SUGGESTED USAGE?
Thanx, Paul
Quoted 8 lines · Alan Stern
Quoted 6 lines · Paul E. McKenney
Quoted 5 lines
I should have made a stronger point: "power-aware" is _not_ a good term for these applications. "power-enabled" would be better but still not ideal. Maybe "power-permitted"? The definition is that they are _permitted_ to do something (acquire suspend blockers), not that they actually _do_ something.
Quoted 7 lines
Quoted 1 line
How about "PM-driving applications", as Rafael suggested?
Perhaps. But it's a little misleading, since what these applications are permitted to do is to _prevent_ the system from going to low power. So in a real sense they don't drive PM -- they block it. (Indeed, that's what inspired the name "suspend blocker".) Of course, the same objection applies to "power-permitted".
Good point, but for the moment I would like to keep the number of classes of applications down to a dull roar, and so am proposing one class for applications that either actively control device/system power/sleep or prevent changes in same.
I am of course open to improvements in the "PM-driving applications" name. ;-)
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
I was agreeing with the requirement but disagreeing with the reason given for it. Even when buffers are large enough that the danger of overrunning them is infinitesimal, delays in input event delivery are still undesirable.
Besides, the Android kernel doesn't vary its behavior based on whether the recipient is power-permitted or power-naive; it _always_ delivers input events in a timely fashion.
Quoted 7 lines
Quoted 5 lines
True, the difference between the two classes of applications is in whether or not the application is permitted to process the event.
I added "and to minimize response latencies" to the requirement. Does that capture it?
Yes.
Very good!!!
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
But leaving that aside, I thought that Arve and Brian explicitly stated this as a requirement on power-aware applications -- one of the responsibilities that came with the power to block suspend.
No. There are _no_ requirements on power-permitted (or power-aware if you prefer) applications, other than that the user decides to give it the appropriate permission.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Internally, of course, Android may enforce this rule on their own software. But it has no force in regard to external applications.
So should this be moved to a new "ANDROID POLICY" section or some such?
Or DESIRED BEHAVIOR, or some such.
SUGGESTED USAGE?
Thanx, Paul
Quoted 11 lines · David Brownell
Quoted 3 lines
Quoted 1 line
Quoted 1 line
I should have made a stronger point:
"power-aware" is _not_ a good
Quoted 1 line
Quoted 1 line
term for these applications.
Strongly disagree. The whole point is that they ARE VERY MUCH AWARE and interact with a power policy to achieve goals.
Like refusing to power down active subsystems, or actively powering down inactive ones. Q.E.D. ... "aware".
My initial thoughts was along the same lines as yours, but after thinking about it, the distinction between an application that controls its own behavior ("power-aware application") and an application that controls the system's behavior ("PM-driving application") seemed well worth its weight.
Thanx, Paul
Quoted 11 lines · David Brownell
Quoted 3 lines
Quoted 1 line
Quoted 1 line
I should have made a stronger point:
"power-aware" is _not_ a good
Quoted 1 line
Quoted 1 line
term for these applications.
Strongly disagree. The whole point is that they ARE VERY MUCH AWARE and interact with a power policy to achieve goals.
Like refusing to power down active subsystems, or actively powering down inactive ones. Q.E.D. ... "aware".
My initial thoughts was along the same lines as yours, but after thinking about it, the distinction between an application that controls its own behavior ("power-aware application") and an application that controls the system's behavior ("PM-driving application") seemed well worth its weight.
Thanx, Paul
Quoted 16 lines · Rafael J. Wysocki
Quoted 3 lines · Paul E. McKenney
Quoted 2 lines · Rafael J. Wysocki
Quoted 1 line · Alan Stern
On Sat, 31 Jul 2010, Paul E. McKenney wrote:
...
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
On Android this goes somewhat farther. IIUC, they want hardly anything to run while the display is powered off. (But my understanding could be wrong.)
Not really. Quite a lot of things happen on these systems while the display is off (let alone the periodic battery monitoring on Nexus One :-)). They can send things over the network and do similar stuff in that state.
I think the opposite is true, ie. the display is aggressively turned off whenever it appears not to be used, because it draws a lot of power.
Quoted 6 lines
Quoted 2 lines
Fair enough. It appears to me that Android won't suspend if the display is on, but I could easily be confused here.
That's correct. In fact, Android uses a special mechanism called "early suspend" (or similar) to suspend the display and some other devices before the "real" suspend happens.
Sounds good!
Quoted 9 lines
...
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Agreed.
OK, but I still believe that an enforcement mechanism is required.
The requirement is that power-oblivious applications should not participate in deciding whether or not to put the system into a sleep state which is pretty much by definition.
I moved this into the definitions section -- you and Alan convince me. ;-)
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 10 lines
o Statistics of the power-control actions taken by power-aware
applications must be provided, and must be keyed off of program name.o Power-aware applications can make use of power-naive infrastructure.
This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.Quoted 6 lines
o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Agreed.
Again, this requirement was explicitly called out by the Android folks.
Rather, there should be a mechanism allowing PM-driving applications to do that, but they are not required to use that mechanism.
Fair enough! I moved this into a new section that I am currently calling "SUGGESTED USAGE".
Thanx, Paul
Quoted 16 lines · Rafael J. Wysocki
Quoted 3 lines · Paul E. McKenney
Quoted 2 lines · Rafael J. Wysocki
Quoted 1 line · Alan Stern
On Sat, 31 Jul 2010, Paul E. McKenney wrote:
...
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
On Android this goes somewhat farther. IIUC, they want hardly anything to run while the display is powered off. (But my understanding could be wrong.)
Not really. Quite a lot of things happen on these systems while the display is off (let alone the periodic battery monitoring on Nexus One :-)). They can send things over the network and do similar stuff in that state.
I think the opposite is true, ie. the display is aggressively turned off whenever it appears not to be used, because it draws a lot of power.
Quoted 6 lines
Quoted 2 lines
Fair enough. It appears to me that Android won't suspend if the display is on, but I could easily be confused here.
That's correct. In fact, Android uses a special mechanism called "early suspend" (or similar) to suspend the display and some other devices before the "real" suspend happens.
Sounds good!
Quoted 9 lines
...
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
o Power-naive applications must be prohibited from controlling
the system power state. One acceptable approach is through use of group permissions on a special power-control device.You mean non-power-aware applications, not power-naive applications. But then the statement is redundant; it follows directly from the definition of "power-aware".
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Agreed.
OK, but I still believe that an enforcement mechanism is required.
The requirement is that power-oblivious applications should not participate in deciding whether or not to put the system into a sleep state which is pretty much by definition.
I moved this into the definitions section -- you and Alan convince me. ;-)
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 10 lines
o Statistics of the power-control actions taken by power-aware
applications must be provided, and must be keyed off of program name.o Power-aware applications can make use of power-naive infrastructure.
This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.Quoted 6 lines
o When a power-aware application is preventing the system from
shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)No, this is not a requirement. A power-optimized application would do this, of course, by definition. But a power-aware application doesn't have to.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Agreed.
Again, this requirement was explicitly called out by the Android folks.
Rather, there should be a mechanism allowing PM-driving applications to do that, but they are not required to use that mechanism.
Fair enough! I moved this into a new section that I am currently calling "SUGGESTED USAGE".
Thanx, Paul
Quoted 39 lines · Arjan van de Ven
Quoted 17 lines · On Sun, 1 Aug 2010 12:12:28 -0700 "Paul E. McKenney"…
I agree that much progress has been made over the past four years. My laptop's battery life has increased substantially, with roughly half of the increase due to software changes. Taken over all the laptops and PCs out there, this indeed adds up to substantial and valuable savings.
So, yes, you have done quite well.
However, your reliance on application-by-application fixes, while good up to a point, is worrisome longer term. The reason for my concern is that computing history has not been kind to those who fail to vigorously automate. The Android guys have offered up one way of automating power efficiency. There might be better ways, but their approach does at the very least deserve a fair hearing -- and no one who read the recent LKML discussion of their approach could possibly mistake it for anything resembling a fair hearing.
Quoted 7 lines
And yes, I do understand and appreciate your contributions in the form of things like timer aggregation, which does automate the otherwise-tricky task of coordinating power usage across unrelated applications, at least in some important cases. But power efficiency will likely require multiple approaches, especially if the Linux stack is to approach the power efficiencies provided by dedicated devices.
power indeed needs multiple approaches. For example the timer work you mention. What the timer work allows is controlling the behavior of applications that are not well behaved. This is an important way of driving progress, one the android guys sort of swept under the table.
Is the flash plugin (which seems to be the most popular and also worst behaving software in these type of discussions) waking up 100 times per second? <small adjustment by a policy manager> ... now it's only waking up once every 10 seconds, or when something else causes system activity anyway.
Quoted 3 lines
That capability is there in Linux today, and has been there for a long time now. It's highly underused unfortunately... at least outside the MeeGo world of Linux distributions.
I agree that timer control is important and will continue to be. It doesn't seem to me to be in conflict with the Android guys' approach, in fact, it should help reduce power consumption while the device is active. I might well be missing something, though.
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
Quoted 10 lines
on the suspend blockers for drivers; the linux device runtime PM is effectively doing the same things; it allows drivers to suspend/resume individually (with a very nice API/programming model I should say) based on usage. And it works on a tree level, so that it's relatively easy to do things like "I want to go to <this magic deep idle state>, but only if <this set of devices is suspended already>". This is obviously an important functionality for all low power devices, ARM or x86. Suspend blockers had this functionality as part of what it did (they do more obviously) but I'd wager that the current Linux infrastructure is outright nicer.
This is what Rafael has been working on?
Of course, the Android guys also want to pay attention to which apps are running as well as to the state of devices on the system.
Quoted 5 lines
It's what I want to be using for the Intel phone silicon (which isn't all that different in power behavior/requirements than ARM based silicon), and I need to thank Qualcomm here for providing some very good patches to the kernel to allow this model to work for this scenario.
I must have missed those, and I am not seeing any obvious commits in v2.6.35-rc6. Would you be willing to send a pointer?
Quoted 10 lines
As for the aware-versus-good-behaving point; applications can be aware, and yet bad behaving, and can be unaware but good behaving. You don't like me saying this, but the reality is that the behavior matters in the end. *AND WE OBSERVE THIS BEHAVIOR*. It's not hard to move a program/task/whatever from a "behaves well, let run unrestricted" to a "doesn't behave well, needs its behavior adjusted" list and back, just from its behavior. PowerTOP observes such apps. Android has an equivalent thing that observes app behavior. It's not all that hard to detect such things.... and the result is much better than some static "aware" flag one can tag an application with. The "aware" flag
Quoted 8 lines
indicates that there is a "before" and an "after", and that that's it. Reality isn't so black and white as you stated, but that goes for both sides. Observing *current* behavior is much more powerful. Is the part of the app you use fine, even though some function you don't use behave badly? No problem, you get it categorized with the good guys. Is an app 98% working clean, but you on your phone like using the 2% all the time? it's moved to the "must get its attitude adjusted" list.
If I understand you correctly, a key point of agreement between you and the Android guys is that both the system and the user have some say over how applications are treated by the system in terms of how seriously the system takes a given application's requests.
The Android guys also want the user to have some say about what applications are permitted to have some control over "I want to go to <this magic deep idle state>" requests. Does that seem reasonable to you?
Thanx, Paul
Quoted 39 lines · Arjan van de Ven
Quoted 17 lines · On Sun, 1 Aug 2010 12:12:28 -0700 "Paul E. McKenney"…
I agree that much progress has been made over the past four years. My laptop's battery life has increased substantially, with roughly half of the increase due to software changes. Taken over all the laptops and PCs out there, this indeed adds up to substantial and valuable savings.
So, yes, you have done quite well.
However, your reliance on application-by-application fixes, while good up to a point, is worrisome longer term. The reason for my concern is that computing history has not been kind to those who fail to vigorously automate. The Android guys have offered up one way of automating power efficiency. There might be better ways, but their approach does at the very least deserve a fair hearing -- and no one who read the recent LKML discussion of their approach could possibly mistake it for anything resembling a fair hearing.
Quoted 7 lines
And yes, I do understand and appreciate your contributions in the form of things like timer aggregation, which does automate the otherwise-tricky task of coordinating power usage across unrelated applications, at least in some important cases. But power efficiency will likely require multiple approaches, especially if the Linux stack is to approach the power efficiencies provided by dedicated devices.
power indeed needs multiple approaches. For example the timer work you mention. What the timer work allows is controlling the behavior of applications that are not well behaved. This is an important way of driving progress, one the android guys sort of swept under the table.
Is the flash plugin (which seems to be the most popular and also worst behaving software in these type of discussions) waking up 100 times per second? <small adjustment by a policy manager> ... now it's only waking up once every 10 seconds, or when something else causes system activity anyway.
Quoted 3 lines
That capability is there in Linux today, and has been there for a long time now. It's highly underused unfortunately... at least outside the MeeGo world of Linux distributions.
I agree that timer control is important and will continue to be. It doesn't seem to me to be in conflict with the Android guys' approach, in fact, it should help reduce power consumption while the device is active. I might well be missing something, though.
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
Quoted 10 lines
on the suspend blockers for drivers; the linux device runtime PM is effectively doing the same things; it allows drivers to suspend/resume individually (with a very nice API/programming model I should say) based on usage. And it works on a tree level, so that it's relatively easy to do things like "I want to go to <this magic deep idle state>, but only if <this set of devices is suspended already>". This is obviously an important functionality for all low power devices, ARM or x86. Suspend blockers had this functionality as part of what it did (they do more obviously) but I'd wager that the current Linux infrastructure is outright nicer.
This is what Rafael has been working on?
Of course, the Android guys also want to pay attention to which apps are running as well as to the state of devices on the system.
Quoted 5 lines
It's what I want to be using for the Intel phone silicon (which isn't all that different in power behavior/requirements than ARM based silicon), and I need to thank Qualcomm here for providing some very good patches to the kernel to allow this model to work for this scenario.
I must have missed those, and I am not seeing any obvious commits in v2.6.35-rc6. Would you be willing to send a pointer?
Quoted 10 lines
As for the aware-versus-good-behaving point; applications can be aware, and yet bad behaving, and can be unaware but good behaving. You don't like me saying this, but the reality is that the behavior matters in the end. *AND WE OBSERVE THIS BEHAVIOR*. It's not hard to move a program/task/whatever from a "behaves well, let run unrestricted" to a "doesn't behave well, needs its behavior adjusted" list and back, just from its behavior. PowerTOP observes such apps. Android has an equivalent thing that observes app behavior. It's not all that hard to detect such things.... and the result is much better than some static "aware" flag one can tag an application with. The "aware" flag
Quoted 8 lines
indicates that there is a "before" and an "after", and that that's it. Reality isn't so black and white as you stated, but that goes for both sides. Observing *current* behavior is much more powerful. Is the part of the app you use fine, even though some function you don't use behave badly? No problem, you get it categorized with the good guys. Is an app 98% working clean, but you on your phone like using the 2% all the time? it's moved to the "must get its attitude adjusted" list.
If I understand you correctly, a key point of agreement between you and the Android guys is that both the system and the user have some say over how applications are treated by the system in terms of how seriously the system takes a given application's requests.
The Android guys also want the user to have some say about what applications are permitted to have some control over "I want to go to <this magic deep idle state>" requests. Does that seem reasonable to you?
Thanx, Paul
Quoted 50 lines · James Bottomley
Quoted 21 lines · Paul E. McKenney
Quoted 8 lines · Arjan van de Ven
Quoted 5 lines · On Sat, 31 Jul 2010 10:58:42 -0700 "Paul E. McKenney"…
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to
determine which applications are classified as power aware.Quoted 6 lines
Quoted 3 lines
More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
I don't like the term "Power aware application". An application is well behaved or it isn't. "aware" has nothing to do with it.
Applications are often complex enough to be aware of some things, naive about others, well behaved in some ways, and ill-behaved in others. This has been the case for some decades now, so it should not come as a surprise.
Quoted 5 lines
I am of course open to suggestions for alternatives to the term "power aware application", but most definitely not to obfuscating the difference between power awareness (or whatever name one wishes to call it) and the overall quality of the application, whatever "quality" might mean in a given context.
So the reason everyone's having trouble with this definition is that it actually conflates two separate axes of power management.
There are good and bad applications in the power sense ... burns less vs burns more.
And there are user mandated vs user optional processes ... necessary/wanted vs unnecessary/unwanted.
What android actually does is reward well written applications because they "just work" and they don't have to be power aware at all ... they're usually event driven and split into the android provider/consumer model.
Badly written applications that are not suspend block aware get shut down (by system suspend) when the screen turns off, so they're also power/suspend unaware.
Applications that want to present the user with a choice in android are power/suspend aware because the only way they get to present the choice is via suspend blockers.
Quoted 5 lines
The "power problem" always devolves to resolving a set of choices around a given set of control axes. The problem is that the set of control axes isn't unique and doesn't have a well agreed upon selection. This makes it hard to make definitive terminology because you have to pick the set of axes (implicitly or explicitly) before defining terms ...
That does seem to be about the size of it... :-/
Thanx, Paul
Quoted 50 lines · James Bottomley
Quoted 21 lines · Paul E. McKenney
Quoted 8 lines · Arjan van de Ven
Quoted 5 lines · On Sat, 31 Jul 2010 10:58:42 -0700 "Paul E. McKenney"…
o "Power-aware application" are applications that are permitted
to acquire suspend blockers on Android. Verion 8 of the suspend-blocker patch seems to use group permissions to
determine which applications are classified as power aware.Quoted 6 lines
Quoted 3 lines
More generally, power-aware applications seem to be those that have permission to exert some control over the system's power state.
I don't like the term "Power aware application". An application is well behaved or it isn't. "aware" has nothing to do with it.
Applications are often complex enough to be aware of some things, naive about others, well behaved in some ways, and ill-behaved in others. This has been the case for some decades now, so it should not come as a surprise.
Quoted 5 lines
I am of course open to suggestions for alternatives to the term "power aware application", but most definitely not to obfuscating the difference between power awareness (or whatever name one wishes to call it) and the overall quality of the application, whatever "quality" might mean in a given context.
So the reason everyone's having trouble with this definition is that it actually conflates two separate axes of power management.
There are good and bad applications in the power sense ... burns less vs burns more.
And there are user mandated vs user optional processes ... necessary/wanted vs unnecessary/unwanted.
What android actually does is reward well written applications because they "just work" and they don't have to be power aware at all ... they're usually event driven and split into the android provider/consumer model.
Badly written applications that are not suspend block aware get shut down (by system suspend) when the screen turns off, so they're also power/suspend unaware.
Applications that want to present the user with a choice in android are power/suspend aware because the only way they get to present the choice is via suspend blockers.
Quoted 5 lines
The "power problem" always devolves to resolving a set of choices around a given set of control axes. The problem is that the set of control axes isn't unique and doesn't have a well agreed upon selection. This makes it hard to make definitive terminology because you have to pick the set of axes (implicitly or explicitly) before defining terms ...
That does seem to be about the size of it... :-/
Thanx, Paul
Quoted 9 lines · Ted Ts'o
Quoted 7 lines · Paul E. McKenney
I understand that you would prefer that we group applications into "good" and "bad" categories, but then again, I suspect that most of us understood that before you posted this message. Given your significant and well-appreciated contributions to power efficiency over the past several years, I must confess to be quite disappointed that you failed to do more than to simply restate your preference.
Quoted 11 lines
Paul, I very much agree with what you stated later, with respect to doubting whether the whack-a-mole approach to application fixups is workable. Given how many applications screw up using
fsync()correctly, to the extent that XFS, ext4, and btrfs all had to agree on a common hueristics to deal with the fact that application programmers are aggressively ignorant, and outnumber the file system developers, I too doubt the general strategy of relying only on application programmers to do the right thing. That's not to say that we shouldn't give up on trying to influence application programmers --- but relying on that as the only strategy seems to depart from the path of wisdom.
Unless someone can reliably automate whacking the moles, history is not on the side of the mole-whackers. I won't say that such automation is impossible, but only because of all the "impossible" things in my lifetime that have turned out to be possible.
And I agree that multiple approaches are likely to be needed here.
Quoted 12 lines
There is however a much bigger point, which is that it's unfortunately black and white to talk about applications being "good" and "bad". In fact, it's a continuing point of concern I have with the whole qos approach to power management. In fact, power is often something that needs to trade off against performance. For example, an application could aggressively prefetch e-mail messages or web pages that a user _might_ view --- or it could aggressively pre-resolve DNS queries, etc, which might make perfect sense when the device is hooked up to AC mains, but which I might not want to do on when I only have 800mWh worth of battery --- however, if I'm using a laptop with 94,000mWh, maybe I'd be happy if the application was a bit more profligate.
Quoted 9 lines
So for Arjan to claim that all applications will be held to the same standard, whether they are hooked up to the AC mains, or are limited to 800mWh of battery, or 94,000 mWh worth of power, is vastly oversimplifying the problem. Of *course* if I'm writing an application that will be running in a cloud data center, I'm going to care about power. But I may have different tradeoffs about what might considered acceptible when considering the qualify of user experience I'm delivering to the end-user when I'm connected to AC mains, versus a cell phone battery, versus a 6-cell laptop battery.
And depending on how badly you need the application to run. "Find me the nearest source of AC power!" "Sorry, can't do that because that app is too poorly behaved to run when the battery is nearly exhausted." ;-)
Arjan did suggest taking user preferences into account, but we will see.
Quoted 20 lines
This brings me back to a major problem I have with the
pm_qosapproach to power management. It assumes that applications know best, and that they should be free to tellpm_qossubsystem whether they need 0ms latency for wireless. Right now, I can't even query thepm_qossubsystem to see which application is responsible for keeping the wireless on 100% of the time! And even if I could find out, maybe some power management framework should be allowed to give a override to the application's wishes. OK, maybe the Opera web browser is requesting the very best wireless QOS because it wants to beat Chrome on some silly potato benchmark --- well, it's ***stupid*** to say that my power management should be a one-size-fits all because applications should be always as power efficient as possible whether they are connected to AC mains or I have a 800mWh cell phone battery. Worse yet, it's stupid to say that the application should have the last word. Darn it, *I* own the mobile device, and I (or my proxy, which might be the Android OS, or some power manage daemon) should be able to say, "I don't care what the application claimed it wanted for power QOS --- it's not getting more than 100ms wireless latency, and that's final."
Quoted 8 lines
And note that this is something that might even change over time, or depending on circumstances. Maybe normally I might be willing to let the application be profilgate with power, so that web pages render a bit faster than they might otherwise --- but if I'm on an American Airlines flight which has retrofitted its power jacks to use an AC plug, and I only have a DC adaptor, and my laptop batteries are worn out and only have half their endurance as they used to, I might want to use a more stringent
pm_qosthan I might otherwise normally allow.
Agreed!
Thanx, Paul
Quoted 9 lines · Ted Ts'o
Quoted 7 lines · Paul E. McKenney
I understand that you would prefer that we group applications into "good" and "bad" categories, but then again, I suspect that most of us understood that before you posted this message. Given your significant and well-appreciated contributions to power efficiency over the past several years, I must confess to be quite disappointed that you failed to do more than to simply restate your preference.
Quoted 11 lines
Paul, I very much agree with what you stated later, with respect to doubting whether the whack-a-mole approach to application fixups is workable. Given how many applications screw up using
fsync()correctly, to the extent that XFS, ext4, and btrfs all had to agree on a common hueristics to deal with the fact that application programmers are aggressively ignorant, and outnumber the file system developers, I too doubt the general strategy of relying only on application programmers to do the right thing. That's not to say that we shouldn't give up on trying to influence application programmers --- but relying on that as the only strategy seems to depart from the path of wisdom.
Unless someone can reliably automate whacking the moles, history is not on the side of the mole-whackers. I won't say that such automation is impossible, but only because of all the "impossible" things in my lifetime that have turned out to be possible.
And I agree that multiple approaches are likely to be needed here.
Quoted 12 lines
There is however a much bigger point, which is that it's unfortunately black and white to talk about applications being "good" and "bad". In fact, it's a continuing point of concern I have with the whole qos approach to power management. In fact, power is often something that needs to trade off against performance. For example, an application could aggressively prefetch e-mail messages or web pages that a user _might_ view --- or it could aggressively pre-resolve DNS queries, etc, which might make perfect sense when the device is hooked up to AC mains, but which I might not want to do on when I only have 800mWh worth of battery --- however, if I'm using a laptop with 94,000mWh, maybe I'd be happy if the application was a bit more profligate.
Quoted 9 lines
So for Arjan to claim that all applications will be held to the same standard, whether they are hooked up to the AC mains, or are limited to 800mWh of battery, or 94,000 mWh worth of power, is vastly oversimplifying the problem. Of *course* if I'm writing an application that will be running in a cloud data center, I'm going to care about power. But I may have different tradeoffs about what might considered acceptible when considering the qualify of user experience I'm delivering to the end-user when I'm connected to AC mains, versus a cell phone battery, versus a 6-cell laptop battery.
And depending on how badly you need the application to run. "Find me the nearest source of AC power!" "Sorry, can't do that because that app is too poorly behaved to run when the battery is nearly exhausted." ;-)
Arjan did suggest taking user preferences into account, but we will see.
Quoted 20 lines
This brings me back to a major problem I have with the
pm_qosapproach to power management. It assumes that applications know best, and that they should be free to tellpm_qossubsystem whether they need 0ms latency for wireless. Right now, I can't even query thepm_qossubsystem to see which application is responsible for keeping the wireless on 100% of the time! And even if I could find out, maybe some power management framework should be allowed to give a override to the application's wishes. OK, maybe the Opera web browser is requesting the very best wireless QOS because it wants to beat Chrome on some silly potato benchmark --- well, it's ***stupid*** to say that my power management should be a one-size-fits all because applications should be always as power efficient as possible whether they are connected to AC mains or I have a 800mWh cell phone battery. Worse yet, it's stupid to say that the application should have the last word. Darn it, *I* own the mobile device, and I (or my proxy, which might be the Android OS, or some power manage daemon) should be able to say, "I don't care what the application claimed it wanted for power QOS --- it's not getting more than 100ms wireless latency, and that's final."
Quoted 8 lines
And note that this is something that might even change over time, or depending on circumstances. Maybe normally I might be willing to let the application be profilgate with power, so that web pages render a bit faster than they might otherwise --- but if I'm on an American Airlines flight which has retrofitted its power jacks to use an AC plug, and I only have a DC adaptor, and my laptop batteries are worn out and only have half their endurance as they used to, I might want to use a more stringent
pm_qosthan I might otherwise normally allow.
Agreed!
Thanx, Paul
Quoted 50 lines · Arjan van de Ven
Quoted 42 lines · On Sun, 1 Aug 2010 12:27:08 -0700 "Paul E. McKenney"…
Quoted 4 lines · Mikael Abrahamsson
Quoted 2 lines · Mikael Abrahamsson
it's just that mobile (low power) wasn't the intended target of the application when it was written, and this commonly shows.
Good points in both this and your earlier post!!!
Quoted 23 lines
I have another aspect I just thought about. I work for a telephony company. We provide Internet connectivity throught various means, DSL, Ethernet to the Home, mobile etc.
For ETTH and DSL, network usage is pretty straight forward, you send packets, they get delivered pretty quickly with low marginal cost per packet. For mobile, this is not quite so simple. Mobile networks are designed for terminal/UE (user equipment) to use low power, so they go down in low power state after a while. Let's take the case of 3G/HSPA:
After a short while (second) of idleness (no packets being sent), the mobile network negotiates away the high speed resources (the one that enables multimegabit/s transfers) and tries to give it to someone else. After approximately 30 seconds, the terminal goes to "idle", meaning it has no network resources at all. Next time it wants to send something (or the network wants to deliver something to it), network resources need to be negotiated again. This can take 1-2 seconds and uses battery power of course. It also consumes resources in the operator network (because mobility control units need to talk to base stations, tunnels need to be re-negotiated etc).
Quoted 10 lines
Anyhow, my point is that not only is there a benefit in having multiple applications wake up at the same time for power reasons within the device, there is also a point in having coordination of their network access. If a device is running 3 IM programs at the same time, it'd be beneficial if they were coordinated in their communication with their Internet servers. Same goes for the "check for new email" application. If they all were optimized to only wake up the network connectivity once every 180 seconds instead of doing it when the individual application felt like it, power and other resources would be saved by all involved parties.
Quoted 4 lines
This is a good point. Within some limits, the timer-aggregation changes that have gone into Linux can handle this, but I am not sure whether or not 180 seconds is within the reasonable boundaries for timer jitter.
Quoted 8 lines
this is why operating systems for mobile devices offer heartbeat services... where apps subscribe to and do background work like checking email at "convenient" times.
I'm not sure if the OS you use on your desktop has one, but MeeGo and Maemo and I'm pretty sure Android and most other mobile Linux OSes have one. It's a higher level activity alignment layer, well above the kernel.
Thank you, good to know!
Thanx, Paul
Quoted 50 lines · Arjan van de Ven
Quoted 42 lines · On Sun, 1 Aug 2010 12:27:08 -0700 "Paul E. McKenney"…
Quoted 4 lines · Mikael Abrahamsson
Quoted 2 lines · Mikael Abrahamsson
it's just that mobile (low power) wasn't the intended target of the application when it was written, and this commonly shows.
Good points in both this and your earlier post!!!
Quoted 23 lines
I have another aspect I just thought about. I work for a telephony company. We provide Internet connectivity throught various means, DSL, Ethernet to the Home, mobile etc.
For ETTH and DSL, network usage is pretty straight forward, you send packets, they get delivered pretty quickly with low marginal cost per packet. For mobile, this is not quite so simple. Mobile networks are designed for terminal/UE (user equipment) to use low power, so they go down in low power state after a while. Let's take the case of 3G/HSPA:
After a short while (second) of idleness (no packets being sent), the mobile network negotiates away the high speed resources (the one that enables multimegabit/s transfers) and tries to give it to someone else. After approximately 30 seconds, the terminal goes to "idle", meaning it has no network resources at all. Next time it wants to send something (or the network wants to deliver something to it), network resources need to be negotiated again. This can take 1-2 seconds and uses battery power of course. It also consumes resources in the operator network (because mobility control units need to talk to base stations, tunnels need to be re-negotiated etc).
Quoted 10 lines
Anyhow, my point is that not only is there a benefit in having multiple applications wake up at the same time for power reasons within the device, there is also a point in having coordination of their network access. If a device is running 3 IM programs at the same time, it'd be beneficial if they were coordinated in their communication with their Internet servers. Same goes for the "check for new email" application. If they all were optimized to only wake up the network connectivity once every 180 seconds instead of doing it when the individual application felt like it, power and other resources would be saved by all involved parties.
Quoted 4 lines
This is a good point. Within some limits, the timer-aggregation changes that have gone into Linux can handle this, but I am not sure whether or not 180 seconds is within the reasonable boundaries for timer jitter.
Quoted 8 lines
this is why operating systems for mobile devices offer heartbeat services... where apps subscribe to and do background work like checking email at "convenient" times.
I'm not sure if the OS you use on your desktop has one, but MeeGo and Maemo and I'm pretty sure Android and most other mobile Linux OSes have one. It's a higher level activity alignment layer, well above the kernel.
Thank you, good to know!
Thanx, Paul
Quoted 9 lines · On Sun, 1 Aug 2010 18:10:06 -0700 "Paul E. McKenney"…
If I understand you correctly, a key point of agreement between you and the Android guys is that both the system and the user have some say over how applications are treated by the system in terms of how seriously the system takes a given application's requests.
The Android guys also want the user to have some say about what applications are permitted to have some control over "I want to go to <this magic deep idle state>" requests. Does that seem reasonable to you?
I personally think it's one of those things where... well we can get a LONG way automatically (by just observing things); asking the users is very very often just caving in rather than solving the problem.
Asking the user should only be done for things the user
1) Can give an intelligent answer to
and
2) Are something the user WANTS to be involved in. (rather than 'stupid thing, why don't just do the right thing'.. think the Windows Vista security questions)
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
Quoted 9 lines · On Sun, 1 Aug 2010 18:10:06 -0700 "Paul E. McKenney"…
If I understand you correctly, a key point of agreement between you and the Android guys is that both the system and the user have some say over how applications are treated by the system in terms of how seriously the system takes a given application's requests.
The Android guys also want the user to have some say about what applications are permitted to have some control over "I want to go to <this magic deep idle state>" requests. Does that seem reasonable to you?
I personally think it's one of those things where... well we can get a LONG way automatically (by just observing things); asking the users is very very often just caving in rather than solving the problem.
Asking the user should only be done for things the user
1) Can give an intelligent answer to
and
2) Are something the user WANTS to be involved in. (rather than 'stupid thing, why don't just do the right thing'.. think the Windows Vista security questions)
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
Quoted 9 lines · On Sun, 1 Aug 2010 20:03:04 -0700 "Paul E. McKenney"…
Quoted 4 lines
on application programmers to do the right thing. That's not to say that we shouldn't give up on trying to influence application programmers --- but relying on that as the only strategy seems to depart from the path of wisdom.
Unless someone can reliably automate whacking the moles, history is not on the side of the mole-whackers. I won't say that such automation is impossible, but only because of all the "impossible" things in my lifetime that have turned out to be possible.
we have a few things going for us here though
1) It's easy to programatically detect the problems
1a) so programmers can detect issues before they ship software, unlike the fsync() thing Ted mentions. History is showing this is at least relatively successful in open source, but not with Adobe's proprietary software such as Flash
2) Users can be made aware of what the bad guys are
3) The business models of many of the mobile apps gives programmers a strong incentive to ship well behaving. The moment your first and second review of your app read "this app was identified as reducing battery life a lot"... your revenues will not go beyond the $1.98.. ... assuming these first two guys didn't refund their app.
Since we can detect who the bad guys are, we can also automatically quarantine them for the common cases..... which is good news.
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
Quoted 9 lines · On Sun, 1 Aug 2010 20:03:04 -0700 "Paul E. McKenney"…
Quoted 4 lines
on application programmers to do the right thing. That's not to say that we shouldn't give up on trying to influence application programmers --- but relying on that as the only strategy seems to depart from the path of wisdom.
Unless someone can reliably automate whacking the moles, history is not on the side of the mole-whackers. I won't say that such automation is impossible, but only because of all the "impossible" things in my lifetime that have turned out to be possible.
we have a few things going for us here though
1) It's easy to programatically detect the problems
1a) so programmers can detect issues before they ship software, unlike the fsync() thing Ted mentions. History is showing this is at least relatively successful in open source, but not with Adobe's proprietary software such as Flash
2) Users can be made aware of what the bad guys are
3) The business models of many of the mobile apps gives programmers a strong incentive to ship well behaving. The moment your first and second review of your app read "this app was identified as reducing battery life a lot"... your revenues will not go beyond the $1.98.. ... assuming these first two guys didn't refund their app.
Since we can detect who the bad guys are, we can also automatically quarantine them for the common cases..... which is good news.
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
David Lang
Hi,
Quoted 7 lines · On Sun, 1 Aug 2010 21:05:48 -0700 Arjan van de Ven <[email protected]> wrote:
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
I think that the only thing that really matters (longterm) with suspend is that processes don't get scheduled anymore when the system is suspended.
Cheers,
Flo
Hi,
Quoted 7 lines · On Sun, 1 Aug 2010 21:05:48 -0700 Arjan van de Ven <[email protected]> wrote:
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
I think that the only thing that really matters (longterm) with suspend is that processes don't get scheduled anymore when the system is suspended.
Cheers,
Flo
Quoted 19 lines · On Sun, 1 Aug 2010 22:06:34 -0700 (PDT) [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
Quoted 6 lines
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
David Lang
We then get again to the "runnable tasks" problem that was discussed earlier... the system get's "deadlock-prone" if a subset of tasks is not run.
Interprocess dependencies are not so easy to get right in general.
Cheers,
Flo
Quoted 19 lines · On Sun, 1 Aug 2010 22:06:34 -0700 (PDT) [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
Quoted 6 lines
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
David Lang
We then get again to the "runnable tasks" problem that was discussed earlier... the system get's "deadlock-prone" if a subset of tasks is not run.
Interprocess dependencies are not so easy to get right in general.
Cheers,
Flo
Quoted 27 lines · Florian Mickler
Quoted 24 lines · On Sun, 1 Aug 2010 22:06:34 -0700 (PDT) [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
Quoted 6 lines
Quoted 1 line
David Lang
We then get again to the "runnable tasks" problem that was discussed earlier... the system get's "deadlock-prone" if a subset of tasks is not run.
Interprocess dependencies are not so easy to get right in general.
I'm not suggesting that you don't run the 'untrusted' tasks, just that you don't consider them when deciding if the system can suspend or not. if the system is awake, everything runs, if the system is idle (except for the activity of the 'untrusted' tasks) you suspend normally.
David Lang
Quoted 36 lines · On Sun, 1 Aug 2010 23:06:08 -0700 (PDT) [email protected] wrote:
Quoted 27 lines · Florian Mickler
Quoted 24 lines · On Sun, 1 Aug 2010 22:06:34 -0700 (PDT) [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
Quoted 6 lines
Quoted 1 line
David Lang
We then get again to the "runnable tasks" problem that was discussed earlier... the system get's "deadlock-prone" if a subset of tasks is not run.
Interprocess dependencies are not so easy to get right in general.
Quoted 6 lines
I'm not suggesting that you don't run the 'untrusted' tasks, just that you don't consider them when deciding if the system can suspend or not. if the system is awake, everything runs, if the system is idle (except for the activity of the 'untrusted' tasks) you suspend normally.
David Lang
Ah, yes. Sorry. It's pretty early in the morning over here, I don't seem to have my eyes fully opened yet... A "ignore-these-processes" cgroup could probably work... It would have the advantage of not having to maintain a special purpose API....
Cheers,
Flo
Quoted 36 lines · On Sun, 1 Aug 2010 23:06:08 -0700 (PDT) [email protected] wrote:
Quoted 27 lines · Florian Mickler
Quoted 24 lines · On Sun, 1 Aug 2010 22:06:34 -0700 (PDT) [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
Quoted 6 lines
Quoted 1 line
David Lang
We then get again to the "runnable tasks" problem that was discussed earlier... the system get's "deadlock-prone" if a subset of tasks is not run.
Interprocess dependencies are not so easy to get right in general.
Quoted 6 lines
I'm not suggesting that you don't run the 'untrusted' tasks, just that you don't consider them when deciding if the system can suspend or not. if the system is awake, everything runs, if the system is idle (except for the activity of the 'untrusted' tasks) you suspend normally.
David Lang
Ah, yes. Sorry. It's pretty early in the morning over here, I don't seem to have my eyes fully opened yet... A "ignore-these-processes" cgroup could probably work... It would have the advantage of not having to maintain a special purpose API....
Cheers,
Flo
Quoted 46 lines · On Mon, 2 Aug 2010 08:40:03 +0200 Florian Mickler <[email protected]> wrote:
Quoted 36 lines · On Sun, 1 Aug 2010 23:06:08 -0700 (PDT) [email protected] wrote:
Quoted 27 lines · Florian Mickler
Quoted 24 lines · On Sun, 1 Aug 2010 22:06:34 -0700 (PDT) [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
Quoted 6 lines
Quoted 1 line
David Lang
We then get again to the "runnable tasks" problem that was discussed earlier... the system get's "deadlock-prone" if a subset of tasks is not run.
Interprocess dependencies are not so easy to get right in general.Quoted 6 lines
I'm not suggesting that you don't run the 'untrusted' tasks, just that you don't consider them when deciding if the system can suspend or not. if the system is awake, everything runs, if the system is idle (except for the activity of the 'untrusted' tasks) you suspend normally.
David Lang
Quoted 9 lines
Ah, yes. Sorry. It's pretty early in the morning over here, I don't seem to have my eyes fully opened yet... A "ignore-these-processes" cgroup could probably work... It would have the advantage of not having to maintain a special purpose API....
Cheers,
Flo
Thinking about it.. I don't know much about cgroups, but I think a process can only be in one cgroup at a time. So you'd need to provide
a) a way to race free migrate them to the "suspend block" cgroup (or dropping them out of the "ignore" cgroup)
b) you can't use cgroup for other purposes anymore. I.e. if you want to have 2 groups that each only have half of the memory available, how would you then integrate the cgroup-ignore-for-idle-approach with this?
hmmm..
Cheers,
Flo
Quoted 46 lines · On Mon, 2 Aug 2010 08:40:03 +0200 Florian Mickler <[email protected]> wrote:
Quoted 36 lines · On Sun, 1 Aug 2010 23:06:08 -0700 (PDT) [email protected] wrote:
Quoted 27 lines · Florian Mickler
Quoted 24 lines · On Sun, 1 Aug 2010 22:06:34 -0700 (PDT) [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
Quoted 6 lines
Quoted 1 line
David Lang
We then get again to the "runnable tasks" problem that was discussed earlier... the system get's "deadlock-prone" if a subset of tasks is not run.
Interprocess dependencies are not so easy to get right in general.Quoted 6 lines
I'm not suggesting that you don't run the 'untrusted' tasks, just that you don't consider them when deciding if the system can suspend or not. if the system is awake, everything runs, if the system is idle (except for the activity of the 'untrusted' tasks) you suspend normally.
David Lang
Quoted 9 lines
Ah, yes. Sorry. It's pretty early in the morning over here, I don't seem to have my eyes fully opened yet... A "ignore-these-processes" cgroup could probably work... It would have the advantage of not having to maintain a special purpose API....
Cheers,
Flo
Thinking about it.. I don't know much about cgroups, but I think a process can only be in one cgroup at a time. So you'd need to provide
a) a way to race free migrate them to the "suspend block" cgroup (or dropping them out of the "ignore" cgroup)
b) you can't use cgroup for other purposes anymore. I.e. if you want to have 2 groups that each only have half of the memory available, how would you then integrate the cgroup-ignore-for-idle-approach with this?
hmmm..
Cheers,
Flo
Quoted 59 lines · Florian Mickler
Quoted 46 lines · On Mon, 2 Aug 2010 08:40:03 +0200 Florian Mickler <[email protected]> wrote:
Quoted 36 lines · On Sun, 1 Aug 2010 23:06:08 -0700 (PDT) [email protected] wrote:
Quoted 27 lines · Florian Mickler
Quoted 24 lines · On Sun, 1 Aug 2010 22:06:34 -0700 (PDT) [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
Quoted 6 lines
Quoted 1 line
David Lang
We then get again to the "runnable tasks" problem that was discussed earlier... the system get's "deadlock-prone" if a subset of tasks is not run.
Interprocess dependencies are not so easy to get right in general.Quoted 6 lines
I'm not suggesting that you don't run the 'untrusted' tasks, just that you don't consider them when deciding if the system can suspend or not. if the system is awake, everything runs, if the system is idle (except for the activity of the 'untrusted' tasks) you suspend normally.
David Lang
Quoted 9 lines
Ah, yes. Sorry. It's pretty early in the morning over here, I don't seem to have my eyes fully opened yet... A "ignore-these-processes" cgroup could probably work... It would have the advantage of not having to maintain a special purpose API....
Cheers,
Flo
Quoted 5 lines
Thinking about it.. I don't know much about cgroups, but I think a process can only be in one cgroup at a time. So you'd need to provide
a) a way to race free migrate them to the "suspend block" cgroup (or dropping them out of the "ignore" cgroup)
why does it need to be race free? being in transition is going to be logically the same as being in the other group.
it's not like applications will be moving back and forth between the two groups is it? I expect that this would be a one-time thing at startup.
Quoted 3 lines
b) you can't use cgroup for other purposes anymore. I.e. if you want to have 2 groups that each only have half of the memory available, how would you then integrate the cgroup-ignore-for-idle-approach with this?
two answers to this
1. does this matter? do you really need to combine this 'suspend, even if there are processes trying to run' with other cgroup limitations?
2. who says that this must be limited to one cgroup? a cgroup can have several different flags/limits set on it, so why can't one of them be this 'ignore for suspend' flag?
these seem like simple issues, what I don't know is if it's possible for the process that controlls suspend to follow such a flag without major surgury on it's innards (if it can, this seems like a easy win, but I can imagine internal designs where the software just knows that _something_ is trying to run and would have a very hard time figuring out what)
David Lang
Quoted 59 lines · Florian Mickler
Quoted 46 lines · On Mon, 2 Aug 2010 08:40:03 +0200 Florian Mickler <[email protected]> wrote:
Quoted 36 lines · On Sun, 1 Aug 2010 23:06:08 -0700 (PDT) [email protected] wrote:
Quoted 27 lines · Florian Mickler
Quoted 24 lines · On Sun, 1 Aug 2010 22:06:34 -0700 (PDT) [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
Quoted 6 lines
Quoted 1 line
David Lang
We then get again to the "runnable tasks" problem that was discussed earlier... the system get's "deadlock-prone" if a subset of tasks is not run.
Interprocess dependencies are not so easy to get right in general.Quoted 6 lines
I'm not suggesting that you don't run the 'untrusted' tasks, just that you don't consider them when deciding if the system can suspend or not. if the system is awake, everything runs, if the system is idle (except for the activity of the 'untrusted' tasks) you suspend normally.
David Lang
Quoted 9 lines
Ah, yes. Sorry. It's pretty early in the morning over here, I don't seem to have my eyes fully opened yet... A "ignore-these-processes" cgroup could probably work... It would have the advantage of not having to maintain a special purpose API....
Cheers,
Flo
Quoted 5 lines
Thinking about it.. I don't know much about cgroups, but I think a process can only be in one cgroup at a time. So you'd need to provide
a) a way to race free migrate them to the "suspend block" cgroup (or dropping them out of the "ignore" cgroup)
why does it need to be race free? being in transition is going to be logically the same as being in the other group.
it's not like applications will be moving back and forth between the two groups is it? I expect that this would be a one-time thing at startup.
Quoted 3 lines
b) you can't use cgroup for other purposes anymore. I.e. if you want to have 2 groups that each only have half of the memory available, how would you then integrate the cgroup-ignore-for-idle-approach with this?
two answers to this
1. does this matter? do you really need to combine this 'suspend, even if there are processes trying to run' with other cgroup limitations?
2. who says that this must be limited to one cgroup? a cgroup can have several different flags/limits set on it, so why can't one of them be this 'ignore for suspend' flag?
these seem like simple issues, what I don't know is if it's possible for the process that controlls suspend to follow such a flag without major surgury on it's innards (if it can, this seems like a easy win, but I can imagine internal designs where the software just knows that _something_ is trying to run and would have a very hard time figuring out what)
David Lang
Quoted 64 lines · On Mon, 2 Aug 2010 00:02:04 -0700 (PDT) [email protected] wrote:
Quoted 62 lines · Florian Mickler
Quoted 46 lines · On Mon, 2 Aug 2010 08:40:03 +0200 Florian Mickler <[email protected]> wrote:
Quoted 36 lines · On Sun, 1 Aug 2010 23:06:08 -0700 (PDT) [email protected] wrote:
Quoted 27 lines · Florian Mickler
Quoted 24 lines · On Sun, 1 Aug 2010 22:06:34 -0700 (PDT) [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
Quoted 6 lines
Quoted 1 line
David Lang
We then get again to the "runnable tasks" problem that was discussed earlier... the system get's "deadlock-prone" if a subset of tasks is not run.
Interprocess dependencies are not so easy to get right in general.Quoted 6 lines
I'm not suggesting that you don't run the 'untrusted' tasks, just that you don't consider them when deciding if the system can suspend or not. if the system is awake, everything runs, if the system is idle (except for the activity of the 'untrusted' tasks) you suspend normally.
David Lang
Quoted 9 lines
Ah, yes. Sorry. It's pretty early in the morning over here, I don't seem to have my eyes fully opened yet... A "ignore-these-processes" cgroup could probably work... It would have the advantage of not having to maintain a special purpose API....
Cheers,
FloThinking about it.. I don't know much about cgroups, but I think a process can only be in one cgroup at a time. So you'd need to provide
Quoted 8 lines
Quoted 2 lines
a) a way to race free migrate them to the "suspend block" cgroup (or dropping them out of the "ignore" cgroup)
why does it need to be race free? being in transition is going to be logically the same as being in the other group.
it's not like applications will be moving back and forth between the two groups is it? I expect that this would be a one-time thing at startup.
hmm... i envisioned a mechanism where applications would be able to switch the groups freely depending on what context the device is in. I didn't even thought about a static grouping. But maybe that is possible also and maybe even sufficient...
Anyway... right. This is probably not a show-stopper.
Quoted 13 lines
Quoted 3 lines
b) you can't use cgroup for other purposes anymore. I.e. if you want to have 2 groups that each only have half of the memory available, how would you then integrate the cgroup-ignore-for-idle-approach with this?
two answers to this
1. does this matter? do you really need to combine this 'suspend, even if there are processes trying to run' with other cgroup limitations?
2. who says that this must be limited to one cgroup? a cgroup can have several different flags/limits set on it, so why can't one of them be this 'ignore for suspend' flag?
Quoted 7 lines
these seem like simple issues, what I don't know is if it's possible for the process that controlls suspend to follow such a flag without major surgury on it's innards (if it can, this seems like a easy win, but I can imagine internal designs where the software just knows that _something_ is trying to run and would have a very hard time figuring out what)
David Lang
Well, i fear it becomes some sort of parallel-tree structure... If you want a cgroups-partitioning for one kind of attribute you now need 2 containers for every possible stamping of that attribute... one being flagged with 'ignore-for-suspend-decision' and one without that flag.
Do you see what I'm getting at, or do I need more coffee and it is irelevant to this concept?
Cheers,
Flo
Quoted 64 lines · On Mon, 2 Aug 2010 00:02:04 -0700 (PDT) [email protected] wrote:
Quoted 62 lines · Florian Mickler
Quoted 46 lines · On Mon, 2 Aug 2010 08:40:03 +0200 Florian Mickler <[email protected]> wrote:
Quoted 36 lines · On Sun, 1 Aug 2010 23:06:08 -0700 (PDT) [email protected] wrote:
Quoted 27 lines · Florian Mickler
Quoted 24 lines · On Sun, 1 Aug 2010 22:06:34 -0700 (PDT) [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
Quoted 6 lines
Quoted 1 line
David Lang
We then get again to the "runnable tasks" problem that was discussed earlier... the system get's "deadlock-prone" if a subset of tasks is not run.
Interprocess dependencies are not so easy to get right in general.Quoted 6 lines
I'm not suggesting that you don't run the 'untrusted' tasks, just that you don't consider them when deciding if the system can suspend or not. if the system is awake, everything runs, if the system is idle (except for the activity of the 'untrusted' tasks) you suspend normally.
David Lang
Quoted 9 lines
Ah, yes. Sorry. It's pretty early in the morning over here, I don't seem to have my eyes fully opened yet... A "ignore-these-processes" cgroup could probably work... It would have the advantage of not having to maintain a special purpose API....
Cheers,
FloThinking about it.. I don't know much about cgroups, but I think a process can only be in one cgroup at a time. So you'd need to provide
Quoted 8 lines
Quoted 2 lines
a) a way to race free migrate them to the "suspend block" cgroup (or dropping them out of the "ignore" cgroup)
why does it need to be race free? being in transition is going to be logically the same as being in the other group.
it's not like applications will be moving back and forth between the two groups is it? I expect that this would be a one-time thing at startup.
hmm... i envisioned a mechanism where applications would be able to switch the groups freely depending on what context the device is in. I didn't even thought about a static grouping. But maybe that is possible also and maybe even sufficient...
Anyway... right. This is probably not a show-stopper.
Quoted 13 lines
Quoted 3 lines
b) you can't use cgroup for other purposes anymore. I.e. if you want to have 2 groups that each only have half of the memory available, how would you then integrate the cgroup-ignore-for-idle-approach with this?
two answers to this
1. does this matter? do you really need to combine this 'suspend, even if there are processes trying to run' with other cgroup limitations?
2. who says that this must be limited to one cgroup? a cgroup can have several different flags/limits set on it, so why can't one of them be this 'ignore for suspend' flag?
Quoted 7 lines
these seem like simple issues, what I don't know is if it's possible for the process that controlls suspend to follow such a flag without major surgury on it's innards (if it can, this seems like a easy win, but I can imagine internal designs where the software just knows that _something_ is trying to run and would have a very hard time figuring out what)
David Lang
Well, i fear it becomes some sort of parallel-tree structure... If you want a cgroups-partitioning for one kind of attribute you now need 2 containers for every possible stamping of that attribute... one being flagged with 'ignore-for-suspend-decision' and one without that flag.
Do you see what I'm getting at, or do I need more coffee and it is irelevant to this concept?
Cheers,
Flo
Quoted 73 lines · Florian Mickler
Quoted 62 lines · On Mon, 2 Aug 2010 00:02:04 -0700 (PDT) [email protected] wrote:
Quoted 42 lines · Florian Mickler
Quoted 39 lines · On Mon, 2 Aug 2010 08:40:03 +0200 Florian Mickler <[email protected]> wrote:
Quoted 36 lines · On Sun, 1 Aug 2010 23:06:08 -0700 (PDT) [email protected] wrote:
Quoted 33 lines · Florian Mickler
Quoted 19 lines · On Sun, 1 Aug 2010 22:06:34 -0700 (PDT) [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
Quoted 6 lines
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
David Lang
We then get again to the "runnable tasks" problem that was discussed earlier... the system get's "deadlock-prone" if a subset of tasks is not run.
Interprocess dependencies are not so easy to get right in general.Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
I'm not suggesting that you don't run the 'untrusted' tasks, just that you don't consider them when deciding if the system can suspend or not. if the system is awake, everything runs, if the system is idle (except for the activity of the 'untrusted' tasks) you suspend normally.
b) you can't use cgroup for other purposes anymore. I.e. if you want to have 2 groups that each only have half of the memory available, how would you then integrate the cgroup-ignore-for-idle-approach with this?
two answers to this
1. does this matter? do you really need to combine this 'suspend, even if there are processes trying to run' with other cgroup limitations?
2. who says that this must be limited to one cgroup? a cgroup can have several different flags/limits set on it, so why can't one of them be this 'ignore for suspend' flag?
Quoted 7 lines
these seem like simple issues, what I don't know is if it's possible for the process that controlls suspend to follow such a flag without major surgury on it's innards (if it can, this seems like a easy win, but I can imagine internal designs where the software just knows that _something_ is trying to run and would have a very hard time figuring out what)
David Lang
Quoted 7 lines
Well, i fear it becomes some sort of parallel-tree structure... If you want a cgroups-partitioning for one kind of attribute you now need 2 containers for every possible stamping of that attribute... one being flagged with 'ignore-for-suspend-decision' and one without that flag.
Do you see what I'm getting at, or do I need more coffee and it is irelevant to this concept?
yes, it could mean a doubleing in the number of cgroups that you need on a system. and if there are other features like this you can end up in a geometric explosion in the number of cgroups.
in practice I question if there is likely to be a need for this sort of thing on a system that's complex enough to use cgroups for other purposes.
in particular, in this case the 'ignore for syspend' flag is not going to be set for programs that are trusted to be well behaved. Such programs are unlikely to be placed under other restraints (because they _are_ trusted to be well behaved)
David Lang
Quoted 11 lines · James Bottomley
Quoted 4 lines · Ted Ts'o
This brings me back to a major problem I have with the
pm_qosapproach to power management. It assumes that applications know best, and that they should be free to tellpm_qossubsystem whether they need 0ms latency for wireless.Um, so this behaviour is isomorphic to the suspend block case for the applications. I think everyone agrees that suspend block isn't optimal, but we were prepared to use it as a starting point given the lack of enthusiasm in android for the more innovative approaches that have been proposed.
Um, yes, that was deliberate. For some people I think people have gotten hypersensitive about suspend blockers, to the point that I think sometimes minds get closed automatically to say that suspend blockers or their requirements are evil/not really a requirement, so I decided to use another example other than scheduler control in the hopes of pointing out (a) there is a more general problem, and (b) application knows best is not enough, and (c) Arjan's claim that we don't need to do anything because all applications should be written to be "power optimized" and it shouldn't matter whether they are connected to the AC mains or not is a vast oversimplification.
Quoted 5 lines
That's why you present the user with choices and report on the outcomes. At the end of the day the choice becomes binary: if the mobile optimised browser burns you battery on the power meter, users will either uninstall and move on to the next browser or deny the current browser the ability to block suspend.
Or they may decide to drop the device which has much worse battery lifetime in favor of the hardware that seems to do a much better job of controlling power overall... which is why if the Nokia folks want to claim that suspend blockers are no good, it's probably not going to change what ships with Android, and may be better power management strategy win. :-)
Quoted 2 lines
Right, but this comes back to the axes of control. They have to be presented to the user in a simple but meaningful manner.
In the general case, at least for today, I think it's useful if applications are told, "you are on AC mains", "you are on cell phone battery", "you are on a laptop battery". And from a user's perspective, I suspect if you are wanting something simple but meaningful, it's probably a single linear scale ranging between "performance optimized" and "power optimized", with maybe 1-3 points in between.
Advanced users will want a much finer level of control, though --- I can imagine having a number of different sliders that control the tradeoff between power vs. performance on a number of different
scales: networking, GPS performance, scheduler control, schreen brightness, etc.
Android phones have a very simplified version of this widget, which allows you to toggle GPS on/off, bluetooth on/off, etc. And the GPS toggle is a good example of what I'm talking about. If you disable the GPS, then even if the application wants to use GPS, tough luck; it will have to settle for the less precise cell tower triangulation method. Again, it's the _user_ who gets the final say, not the application --- and that's as it should be.
- Ted
Quoted 11 lines · James Bottomley
Quoted 4 lines · Ted Ts'o
This brings me back to a major problem I have with the
pm_qosapproach to power management. It assumes that applications know best, and that they should be free to tellpm_qossubsystem whether they need 0ms latency for wireless.Um, so this behaviour is isomorphic to the suspend block case for the applications. I think everyone agrees that suspend block isn't optimal, but we were prepared to use it as a starting point given the lack of enthusiasm in android for the more innovative approaches that have been proposed.
Um, yes, that was deliberate. For some people I think people have gotten hypersensitive about suspend blockers, to the point that I think sometimes minds get closed automatically to say that suspend blockers or their requirements are evil/not really a requirement, so I decided to use another example other than scheduler control in the hopes of pointing out (a) there is a more general problem, and (b) application knows best is not enough, and (c) Arjan's claim that we don't need to do anything because all applications should be written to be "power optimized" and it shouldn't matter whether they are connected to the AC mains or not is a vast oversimplification.
Quoted 5 lines
That's why you present the user with choices and report on the outcomes. At the end of the day the choice becomes binary: if the mobile optimised browser burns you battery on the power meter, users will either uninstall and move on to the next browser or deny the current browser the ability to block suspend.
Or they may decide to drop the device which has much worse battery lifetime in favor of the hardware that seems to do a much better job of controlling power overall... which is why if the Nokia folks want to claim that suspend blockers are no good, it's probably not going to change what ships with Android, and may be better power management strategy win. :-)
Quoted 2 lines
Right, but this comes back to the axes of control. They have to be presented to the user in a simple but meaningful manner.
In the general case, at least for today, I think it's useful if applications are told, "you are on AC mains", "you are on cell phone battery", "you are on a laptop battery". And from a user's perspective, I suspect if you are wanting something simple but meaningful, it's probably a single linear scale ranging between "performance optimized" and "power optimized", with maybe 1-3 points in between.
Advanced users will want a much finer level of control, though --- I can imagine having a number of different sliders that control the tradeoff between power vs. performance on a number of different
scales: networking, GPS performance, scheduler control, schreen brightness, etc.
Android phones have a very simplified version of this widget, which allows you to toggle GPS on/off, bluetooth on/off, etc. And the GPS toggle is a good example of what I'm talking about. If you disable the GPS, then even if the application wants to use GPS, tough luck; it will have to settle for the less precise cell tower triangulation method. Again, it's the _user_ who gets the final say, not the application --- and that's as it should be.
- Ted
Quoted 4 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore....
Part of the problem here may also be a naming problem. There are multiple reasons why you might want to block suspend, and it goes far beyond what the CPU can do.
Let's give another example, from the laptop world. If you close the the MacBook, it "suspends". That is, all processes stop, and the CPU enters a sleep state. Sounds just like Linux's suspend-to-ram, right?
Except for the fact that if you insert a USB cable connected to a iPod/iPad/iPhone, the CPU wakes up, and iTunes will do a sync, and then the machine goes back to sleep. And if the Mail application is in the middle of manipulating the IMAP mailbox, it will be allowed to finish what it is doing, and then the system goes to sleep.
So in the case of both the MacBook, where the user has closed the laptop, and in the case of Cell Phone, where the user has pushed the button saying he/she's done working with the application, the _normal_ thing to do force all processes to go to sleep, and then let the CPU go to sleep.
But, you may have applications that are specially privileged so they can ignore the user command to suspend the machine. Maybe it's an iTunes-like situation, where in response to some hardware interrupt, it's allowed to wake up, do its thing, and then go back to sleep, allowing the hardware to go back to sleep. Maybe it's a mail application that wants to wakeup every 15 minutes, suck down any new mail, and then go back to sleep. The suspend blocker is a way to achieve this --- and this has nothing to do with chip technology, but with a specific use case.
- Ted
Quoted 4 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore....
Part of the problem here may also be a naming problem. There are multiple reasons why you might want to block suspend, and it goes far beyond what the CPU can do.
Let's give another example, from the laptop world. If you close the the MacBook, it "suspends". That is, all processes stop, and the CPU enters a sleep state. Sounds just like Linux's suspend-to-ram, right?
Except for the fact that if you insert a USB cable connected to a iPod/iPad/iPhone, the CPU wakes up, and iTunes will do a sync, and then the machine goes back to sleep. And if the Mail application is in the middle of manipulating the IMAP mailbox, it will be allowed to finish what it is doing, and then the system goes to sleep.
So in the case of both the MacBook, where the user has closed the laptop, and in the case of Cell Phone, where the user has pushed the button saying he/she's done working with the application, the _normal_ thing to do force all processes to go to sleep, and then let the CPU go to sleep.
But, you may have applications that are specially privileged so they can ignore the user command to suspend the machine. Maybe it's an iTunes-like situation, where in response to some hardware interrupt, it's allowed to wake up, do its thing, and then go back to sleep, allowing the hardware to go back to sleep. Maybe it's a mail application that wants to wakeup every 15 minutes, suck down any new mail, and then go back to sleep. The suspend blocker is a way to achieve this --- and this has nothing to do with chip technology, but with a specific use case.
- Ted
Quoted 3 lines · Paul E. McKenney
Quoted 2 lines · Arjan van de Ven
On Sun, 1 Aug 2010 12:12:28 -0700
"Paul E. McKenney" <[email protected]> wrote:
...
Quoted 9 lines
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
This isn't more difficult than deciding which applications will be allowed to use wakelocks (in the wakelocks world). It actually seems to be pretty much equivalent to me. :-)
Quoted 11 lines
Quoted 10 lines
on the suspend blockers for drivers; the linux device runtime PM is effectively doing the same things; it allows drivers to suspend/resume individually (with a very nice API/programming model I should say) based on usage. And it works on a tree level, so that it's relatively easy to do things like "I want to go to <this magic deep idle state>, but only if <this set of devices is suspended already>". This is obviously an important functionality for all low power devices, ARM or x86. Suspend blockers had this functionality as part of what it did (they do more obviously) but I'd wager that the current Linux infrastructure is outright nicer.
Quoted 1 line
This is what Rafael has been working on?
If you mean the runtime PM framework, then yes, I've been working on it.
Quoted 2 lines
Of course, the Android guys also want to pay attention to which apps are running as well as to the state of devices on the system.
In fact the runtime PM framework is also important to Android, because it can be used in there, for example, to implement the "early suspend" thing I referred to in one of my previous messages in this thread.
Thanks,
Rafael
Quoted 3 lines · Paul E. McKenney
Quoted 2 lines · Arjan van de Ven
On Sun, 1 Aug 2010 12:12:28 -0700
"Paul E. McKenney" <[email protected]> wrote:
...
Quoted 9 lines
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
This isn't more difficult than deciding which applications will be allowed to use wakelocks (in the wakelocks world). It actually seems to be pretty much equivalent to me. :-)
Quoted 11 lines
Quoted 10 lines
on the suspend blockers for drivers; the linux device runtime PM is effectively doing the same things; it allows drivers to suspend/resume individually (with a very nice API/programming model I should say) based on usage. And it works on a tree level, so that it's relatively easy to do things like "I want to go to <this magic deep idle state>, but only if <this set of devices is suspended already>". This is obviously an important functionality for all low power devices, ARM or x86. Suspend blockers had this functionality as part of what it did (they do more obviously) but I'd wager that the current Linux infrastructure is outright nicer.
Quoted 1 line
This is what Rafael has been working on?
If you mean the runtime PM framework, then yes, I've been working on it.
Quoted 2 lines
Of course, the Android guys also want to pay attention to which apps are running as well as to the state of devices on the system.
In fact the runtime PM framework is also important to Android, because it can be used in there, for example, to implement the "early suspend" thing I referred to in one of my previous messages in this thread.
Thanks,
Rafael
Quoted 26 lines · Arjan van de Ven
Quoted 9 lines · On Sun, 1 Aug 2010 20:03:04 -0700 "Paul E. McKenney"…
Quoted 4 lines
on application programmers to do the right thing. That's not to say that we shouldn't give up on trying to influence application programmers --- but relying on that as the only strategy seems to depart from the path of wisdom.
Unless someone can reliably automate whacking the moles, history is not on the side of the mole-whackers. I won't say that such automation is impossible, but only because of all the "impossible" things in my lifetime that have turned out to be possible.
we have a few things going for us here though
1) It's easy to programatically detect the problems
1a) so programmers can detect issues before they ship software, unlike thefsync()thing Ted mentions. History is showing this is at least relatively successful in open source, but not with Adobe's proprietary software such as Flash
2) Users can be made aware of what the bad guys are
3) The business models of many of the mobile apps gives programmers a strong incentive to ship well behaving. The moment your first and second review of your app read "this app was identified as reducing battery life a lot"... your revenues will not go beyond the $1.98.. ... assuming these first two guys didn't refund their app.
Quoted 2 lines
Since we can detect who the bad guys are, we can also automatically quarantine them for the common cases..... which is good news.
Unless of course the app reducing battery life a lot does something that users like better than the increment in battery life.
Quoted 7 lines
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
Heh! One could make the "might be temporary" argument against any new feature, including the ones that you are proposing. For but one example, I very well remember being told by many people in many communities that SMP was temporary -- Moore's-Law increases in clock frequency would soon mean that even the biggest systems would be uniprocessors.
If by "memory controller" you are referring to the need to save state for cache SRAMs and perhaps also DRAM, then yes, I agree that some of the most difficult low-power-state tradeoffs involve these devices.
Thanx, Paul
Quoted 26 lines · Arjan van de Ven
Quoted 9 lines · On Sun, 1 Aug 2010 20:03:04 -0700 "Paul E. McKenney"…
Quoted 4 lines
on application programmers to do the right thing. That's not to say that we shouldn't give up on trying to influence application programmers --- but relying on that as the only strategy seems to depart from the path of wisdom.
Unless someone can reliably automate whacking the moles, history is not on the side of the mole-whackers. I won't say that such automation is impossible, but only because of all the "impossible" things in my lifetime that have turned out to be possible.
we have a few things going for us here though
1) It's easy to programatically detect the problems
1a) so programmers can detect issues before they ship software, unlike thefsync()thing Ted mentions. History is showing this is at least relatively successful in open source, but not with Adobe's proprietary software such as Flash
2) Users can be made aware of what the bad guys are
3) The business models of many of the mobile apps gives programmers a strong incentive to ship well behaving. The moment your first and second review of your app read "this app was identified as reducing battery life a lot"... your revenues will not go beyond the $1.98.. ... assuming these first two guys didn't refund their app.
Quoted 2 lines
Since we can detect who the bad guys are, we can also automatically quarantine them for the common cases..... which is good news.
Unless of course the app reducing battery life a lot does something that users like better than the increment in battery life.
Quoted 7 lines
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
Heh! One could make the "might be temporary" argument against any new feature, including the ones that you are proposing. For but one example, I very well remember being told by many people in many communities that SMP was temporary -- Moore's-Law increases in clock frequency would soon mean that even the biggest systems would be uniprocessors.
If by "memory controller" you are referring to the need to save state for cache SRAMs and perhaps also DRAM, then yes, I agree that some of the most difficult low-power-state tradeoffs involve these devices.
Thanx, Paul
Quoted 14 lines · Ted Ts'o
Quoted 4 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore....
Part of the problem here may also be a naming problem. There are multiple reasons why you might want to block suspend, and it goes far beyond what the CPU can do.
Let's give another example, from the laptop world. If you close the the MacBook, it "suspends". That is, all processes stop, and the CPU enters a sleep state. Sounds just like Linux's suspend-to-ram, right?
Quoted 5 lines
Except for the fact that if you insert a USB cable connected to a iPod/iPad/iPhone, the CPU wakes up, and iTunes will do a sync, and then the machine goes back to sleep. And if the Mail application is in the middle of manipulating the IMAP mailbox, it will be allowed to finish what it is doing, and then the system goes to sleep.
I _think_ you can implement that with the current kernel's interfaces and an suitable power manager in user space. At least you should be.
The question really boils down to where the "power manager" activity should be located. Should it be in the kernel or in user space? Or is it better to have a "collective power manager", like in the wakelocks case? Moreover, what should the power manager be responsible for and what the kernel's role should be in deciding what "power" state to go into?
Quoted 8 lines
So in the case of both the MacBook, where the user has closed the laptop, and in the case of Cell Phone, where the user has pushed the button saying he/she's done working with the application, the _normal_ thing to do force all processes to go to sleep, and then let the CPU go to sleep.
But, you may have applications that are specially privileged so they can ignore the user command to suspend the machine.
I frankly don't think it's legitimate to overrule the user. If the user tells us "suspend" and specifies a set of devices that can be used for wakeup, we should follow, possibly monitoring the wakeup devices for events.
However, that doesn't apply 100% to the cell phone case, because on cell phones the software is actually owned by the device vendor and/or the network operator and they may want to have a mechanism to overrule the person using the phone. That is a more general issue, though.
Quoted 7 lines
Maybe it's an iTunes-like situation, where in response to some hardware interrupt, it's allowed to wake up, do its thing, and then go back to sleep, allowing the hardware to go back to sleep. Maybe it's a mail application that wants to wakeup every 15 minutes, suck down any new mail, and then go back to sleep. The suspend blocker is a way to achieve this --- and this has nothing to do with chip technology, but with a specific use case.
Assuming that your "power manager activity" will be a collective one, along the Android lines. Still, in principle, you can obtain a functionally equivalent behavior with the help of a power manager in user space.
Thanks,
Rafael
Quoted 19 lines · On Sun, Aug 01, 2010 at 10:06:34PM -0700, [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
Quoted 4 lines
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
Why not flesh this out and compare it to the draft requirements? (I expect to be sending another version by end of day Pacific Time.)
The biggest issue I see right off-hand is that a straightforward implementation of your idea would require moving processes from one cgroup to another when acquiring or releasing a suspend blocker, which from what I understand would be way to heavyweight. On the other hand, if acquiring and releasing a suspend blocker does not move the process from one cgroup to another, then you need something very like the suspend-blocker mechanism to handle those processes that are permitted to acquire suspend blockers, and which are thus not a member of the cgroup in question.
That said, I did see some hint from the Android guys that it -might- be possible to leverage cgroups in the way that you suggest might help save power during times when suspend was blocked but (for example) the screen was turned off. The idea would be to freeze the cgroup whenever the screen blanked, even if suspend was blocked. The biggest issue here is that any process that can hold a suspend blocker must never to an unconditional wait on any process in this cgroup. Seems to me that this should be possible in theory, but the devil would be in the details.
If I am misunderstanding your proposal, please enlighten me!
Thanx, Paul
Quoted 19 lines · On Sun, Aug 01, 2010 at 10:06:34PM -0700, [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
Quoted 4 lines
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
Why not flesh this out and compare it to the draft requirements? (I expect to be sending another version by end of day Pacific Time.)
The biggest issue I see right off-hand is that a straightforward implementation of your idea would require moving processes from one cgroup to another when acquiring or releasing a suspend blocker, which from what I understand would be way to heavyweight. On the other hand, if acquiring and releasing a suspend blocker does not move the process from one cgroup to another, then you need something very like the suspend-blocker mechanism to handle those processes that are permitted to acquire suspend blockers, and which are thus not a member of the cgroup in question.
That said, I did see some hint from the Android guys that it -might- be possible to leverage cgroups in the way that you suggest might help save power during times when suspend was blocked but (for example) the screen was turned off. The idea would be to freeze the cgroup whenever the screen blanked, even if suspend was blocked. The biggest issue here is that any process that can hold a suspend blocker must never to an unconditional wait on any process in this cgroup. Seems to me that this should be possible in theory, but the devil would be in the details.
If I am misunderstanding your proposal, please enlighten me!
Thanx, Paul
Quoted 14 lines · Ted Ts'o
Quoted 4 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore....
Part of the problem here may also be a naming problem. There are multiple reasons why you might want to block suspend, and it goes far beyond what the CPU can do.
Let's give another example, from the laptop world. If you close the the MacBook, it "suspends". That is, all processes stop, and the CPU enters a sleep state. Sounds just like Linux's suspend-to-ram, right?
Quoted 5 lines
Except for the fact that if you insert a USB cable connected to a iPod/iPad/iPhone, the CPU wakes up, and iTunes will do a sync, and then the machine goes back to sleep. And if the Mail application is in the middle of manipulating the IMAP mailbox, it will be allowed to finish what it is doing, and then the system goes to sleep.
I _think_ you can implement that with the current kernel's interfaces and an suitable power manager in user space. At least you should be.
The question really boils down to where the "power manager" activity should be located. Should it be in the kernel or in user space? Or is it better to have a "collective power manager", like in the wakelocks case? Moreover, what should the power manager be responsible for and what the kernel's role should be in deciding what "power" state to go into?
Quoted 8 lines
So in the case of both the MacBook, where the user has closed the laptop, and in the case of Cell Phone, where the user has pushed the button saying he/she's done working with the application, the _normal_ thing to do force all processes to go to sleep, and then let the CPU go to sleep.
But, you may have applications that are specially privileged so they can ignore the user command to suspend the machine.
I frankly don't think it's legitimate to overrule the user. If the user tells us "suspend" and specifies a set of devices that can be used for wakeup, we should follow, possibly monitoring the wakeup devices for events.
However, that doesn't apply 100% to the cell phone case, because on cell phones the software is actually owned by the device vendor and/or the network operator and they may want to have a mechanism to overrule the person using the phone. That is a more general issue, though.
Quoted 7 lines
Maybe it's an iTunes-like situation, where in response to some hardware interrupt, it's allowed to wake up, do its thing, and then go back to sleep, allowing the hardware to go back to sleep. Maybe it's a mail application that wants to wakeup every 15 minutes, suck down any new mail, and then go back to sleep. The suspend blocker is a way to achieve this --- and this has nothing to do with chip technology, but with a specific use case.
Assuming that your "power manager activity" will be a collective one, along the Android lines. Still, in principle, you can obtain a functionally equivalent behavior with the help of a power manager in user space.
Thanks,
Rafael
Quoted 17 lines · Arjan van de Ven
Quoted 9 lines · On Sun, 1 Aug 2010 18:10:06 -0700 "Paul E. McKenney"…
If I understand you correctly, a key point of agreement between you and the Android guys is that both the system and the user have some say over how applications are treated by the system in terms of how seriously the system takes a given application's requests.
The Android guys also want the user to have some say about what applications are permitted to have some control over "I want to go to <this magic deep idle state>" requests. Does that seem reasonable to you?
I personally think it's one of those things where... well we can get a LONG way automatically (by just observing things); asking the users is very very often just caving in rather than solving the problem.
Quoted 6 lines
Asking the user should only be done for things the user
1) Can give an intelligent answer to
and
2) Are something the user WANTS to be involved in. (rather than 'stupid thing, why don't just do the right thing'.. think the Windows Vista security questions)
Combining this with your previous email, I believe that you are saying that it is necessary for the user to be able to exert some control, but that the UI design had better be sufficiently intelligent with sufficiently good defaults that the user almost never actually -needs- to exert such control.
If this is indeed what you are saying, I certainly agree.
Thanx, Paul
Quoted 17 lines · Arjan van de Ven
Quoted 9 lines · On Sun, 1 Aug 2010 18:10:06 -0700 "Paul E. McKenney"…
If I understand you correctly, a key point of agreement between you and the Android guys is that both the system and the user have some say over how applications are treated by the system in terms of how seriously the system takes a given application's requests.
The Android guys also want the user to have some say about what applications are permitted to have some control over "I want to go to <this magic deep idle state>" requests. Does that seem reasonable to you?
I personally think it's one of those things where... well we can get a LONG way automatically (by just observing things); asking the users is very very often just caving in rather than solving the problem.
Quoted 6 lines
Asking the user should only be done for things the user
1) Can give an intelligent answer to
and
2) Are something the user WANTS to be involved in. (rather than 'stupid thing, why don't just do the right thing'.. think the Windows Vista security questions)
Combining this with your previous email, I believe that you are saying that it is necessary for the user to be able to exert some control, but that the UI design had better be sufficiently intelligent with sufficiently good defaults that the user almost never actually -needs- to exert such control.
If this is indeed what you are saying, I certainly agree.
Thanx, Paul
Quoted 17 lines · Ted Ts'o
Quoted 5 lines · James Bottomley
That's why you present the user with choices and report on the outcomes. At the end of the day the choice becomes binary: if the mobile optimised browser burns you battery on the power meter, users will either uninstall and move on to the next browser or deny the current browser the ability to block suspend.
Or they may decide to drop the device which has much worse battery lifetime in favor of the hardware that seems to do a much better job of controlling power overall... which is why if the Nokia folks want to claim that suspend blockers are no good, it's probably not going to change what ships with Android, and may be better power management strategy win. :-)
Quoted 2 lines
Right, but this comes back to the axes of control. They have to be presented to the user in a simple but meaningful manner.
Quoted 7 lines
In the general case, at least for today, I think it's useful if applications are told, "you are on AC mains", "you are on cell phone battery", "you are on a laptop battery". And from a user's perspective, I suspect if you are wanting something simple but meaningful, it's probably a single linear scale ranging between "performance optimized" and "power optimized", with maybe 1-3 points in between.
Actually, I don't necessarily agree with this. In fact, I think it's a dangerous proposition. The reason is that the only class of applications I've seen usefully made power aware are some of the system housekeeping ones (as in don't index my man pages, prelink my binaries etc. when I'm on battery power). Perhaps I could see things that have to poll (like imap without push support on the server) do a "poll when woken else every X minutes", but the potential for annoying the user by doing the wrong thing on power environment change is huge.
Quoted 6 lines
Advanced users will want a much finer level of control, though --- I can imagine having a number of different sliders that control the tradeoff between power vs. performance on a number of different
scales: networking, GPS performance, scheduler control, schreen brightness, etc.
Quoted 7 lines
Android phones have a very simplified version of this widget, which allows you to toggle GPS on/off, bluetooth on/off, etc. And the GPS toggle is a good example of what I'm talking about. If you disable the GPS, then even if the application wants to use GPS, tough luck; it will have to settle for the less precise cell tower triangulation method. Again, it's the _user_ who gets the final say, not the application --- and that's as it should be.
Yes and no; agree about the user not the application but ... I actually find the current five android "power" toggles to be largely useless. If I don't want GPS killing my battery, I don't start GPS using applications, for instance rather than disabling GPS. I think this represents the "axis" problem again ... I like to manage my power in a particular way, and others want to manage it in different ways.
James
Quoted 17 lines · Ted Ts'o
Quoted 5 lines · James Bottomley
That's why you present the user with choices and report on the outcomes. At the end of the day the choice becomes binary: if the mobile optimised browser burns you battery on the power meter, users will either uninstall and move on to the next browser or deny the current browser the ability to block suspend.
Or they may decide to drop the device which has much worse battery lifetime in favor of the hardware that seems to do a much better job of controlling power overall... which is why if the Nokia folks want to claim that suspend blockers are no good, it's probably not going to change what ships with Android, and may be better power management strategy win. :-)
Quoted 2 lines
Right, but this comes back to the axes of control. They have to be presented to the user in a simple but meaningful manner.
Quoted 7 lines
In the general case, at least for today, I think it's useful if applications are told, "you are on AC mains", "you are on cell phone battery", "you are on a laptop battery". And from a user's perspective, I suspect if you are wanting something simple but meaningful, it's probably a single linear scale ranging between "performance optimized" and "power optimized", with maybe 1-3 points in between.
Actually, I don't necessarily agree with this. In fact, I think it's a dangerous proposition. The reason is that the only class of applications I've seen usefully made power aware are some of the system housekeeping ones (as in don't index my man pages, prelink my binaries etc. when I'm on battery power). Perhaps I could see things that have to poll (like imap without push support on the server) do a "poll when woken else every X minutes", but the potential for annoying the user by doing the wrong thing on power environment change is huge.
Quoted 6 lines
Advanced users will want a much finer level of control, though --- I can imagine having a number of different sliders that control the tradeoff between power vs. performance on a number of different
scales: networking, GPS performance, scheduler control, schreen brightness, etc.
Quoted 7 lines
Android phones have a very simplified version of this widget, which allows you to toggle GPS on/off, bluetooth on/off, etc. And the GPS toggle is a good example of what I'm talking about. If you disable the GPS, then even if the application wants to use GPS, tough luck; it will have to settle for the less precise cell tower triangulation method. Again, it's the _user_ who gets the final say, not the application --- and that's as it should be.
Yes and no; agree about the user not the application but ... I actually find the current five android "power" toggles to be largely useless. If I don't want GPS killing my battery, I don't start GPS using applications, for instance rather than disabling GPS. I think this represents the "axis" problem again ... I like to manage my power in a particular way, and others want to manage it in different ways.
James
Quoted 8 lines · James Bottomley
Actually, I don't necessarily agree with this. In fact, I think it's a dangerous proposition. The reason is that the only class of applications I've seen usefully made power aware are some of the system housekeeping ones (as in don't index my man pages, prelink my binaries etc. when I'm on battery power). Perhaps I could see things that have to poll (like imap without push support on the server) do a "poll when woken else every X minutes", but the potential for annoying the user by doing the wrong thing on power environment change is huge.
Sure, but that's why you need to let the user choose. They can decide between, "behave as if you were on AC", and "try to save power as much as possible", and maybe one or two points in between, and let them choose how much performance/battery life they are willing to give up. If they are on a long flight to Europe/Australia with no power, they might choose a very different tradeoff point than if they know they are only going to be in the meeting room for an hour before they can recharge their battery.
The point is you can annoy users by burning power to improve their "user experience" just as much as you can annoy users by trying to sip power as delicately as possible. It's true that many applications don't do a lot in this space, but that's mainly becaue of application laziness. Which is why I really don't buy Arjan's whack-a-mole approach to solving the problem. I *know* I can save tons of power by doing "killall -STOP firefox" when I don't need to use the browser. I've don't the power management when I've been carefully nursing my battery while at a conference. So I have no problem if the system does that automatically for me when I switch to a different virtual console --- in fact, I'd prefer it! Similarly, having tools which forcibly choose different pm_qos settings, even if it's not what the applications want, is things that *can* very much make a difference.
So yes, maybe applications won't do much with that. But that just reinforces the argument that it's the framework or the kernel that needs to do these sorts of things, because the application programers won't.
- Ted
Quoted 8 lines · James Bottomley
Actually, I don't necessarily agree with this. In fact, I think it's a dangerous proposition. The reason is that the only class of applications I've seen usefully made power aware are some of the system housekeeping ones (as in don't index my man pages, prelink my binaries etc. when I'm on battery power). Perhaps I could see things that have to poll (like imap without push support on the server) do a "poll when woken else every X minutes", but the potential for annoying the user by doing the wrong thing on power environment change is huge.
Sure, but that's why you need to let the user choose. They can decide between, "behave as if you were on AC", and "try to save power as much as possible", and maybe one or two points in between, and let them choose how much performance/battery life they are willing to give up. If they are on a long flight to Europe/Australia with no power, they might choose a very different tradeoff point than if they know they are only going to be in the meeting room for an hour before they can recharge their battery.
The point is you can annoy users by burning power to improve their "user experience" just as much as you can annoy users by trying to sip power as delicately as possible. It's true that many applications don't do a lot in this space, but that's mainly becaue of application laziness. Which is why I really don't buy Arjan's whack-a-mole approach to solving the problem. I *know* I can save tons of power by doing "killall -STOP firefox" when I don't need to use the browser. I've don't the power management when I've been carefully nursing my battery while at a conference. So I have no problem if the system does that automatically for me when I switch to a different virtual console --- in fact, I'd prefer it! Similarly, having tools which forcibly choose different pm_qos settings, even if it's not what the applications want, is things that *can* very much make a difference.
So yes, maybe applications won't do much with that. But that just reinforces the argument that it's the framework or the kernel that needs to do these sorts of things, because the application programers won't.
- Ted
Quoted 10 lines · Rafael J. Wysocki
Quoted 3 lines · Paul E. McKenney
Quoted 2 lines · Arjan van de Ven
On Sun, 1 Aug 2010 12:12:28 -0700
"Paul E. McKenney" <[email protected]> wrote:...
Quoted 5 lines
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Quoted 8 lines
Quoted 4 lines
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
This isn't more difficult than deciding which applications will be allowed to use wakelocks (in the wakelocks world). It actually seems to be pretty much equivalent to me. :-)
If I understand correctly, the problem they were concerned about was instead "given that a certain set of apps are permitted to use wakelocks, which of the other apps can safely be frozen when the display blanks itself."
Quoted 13 lines
Quoted 11 lines
Quoted 10 lines
on the suspend blockers for drivers; the linux device runtime PM is effectively doing the same things; it allows drivers to suspend/resume individually (with a very nice API/programming model I should say) based on usage. And it works on a tree level, so that it's relatively easy to do things like "I want to go to <this magic deep idle state>, but only if <this set of devices is suspended already>". This is obviously an important functionality for all low power devices, ARM or x86. Suspend blockers had this functionality as part of what it did (they do more obviously) but I'd wager that the current Linux infrastructure is outright nicer.
Quoted 1 line
This is what Rafael has been working on?
Quoted 8 lines
If you mean the runtime PM framework, then yes, I've been working on it.
Quoted 2 lines
Of course, the Android guys also want to pay attention to which apps are running as well as to the state of devices on the system.
In fact the runtime PM framework is also important to Android, because it can be used in there, for example, to implement the "early suspend" thing I referred to in one of my previous messages in this thread.
Now we just need to convince the Android guys of that. ;-)
Thanx, Paul
Quoted 10 lines · Rafael J. Wysocki
Quoted 3 lines · Paul E. McKenney
Quoted 2 lines · Arjan van de Ven
On Sun, 1 Aug 2010 12:12:28 -0700
"Paul E. McKenney" <[email protected]> wrote:...
Quoted 5 lines
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Quoted 8 lines
Quoted 4 lines
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
This isn't more difficult than deciding which applications will be allowed to use wakelocks (in the wakelocks world). It actually seems to be pretty much equivalent to me. :-)
If I understand correctly, the problem they were concerned about was instead "given that a certain set of apps are permitted to use wakelocks, which of the other apps can safely be frozen when the display blanks itself."
Quoted 13 lines
Quoted 11 lines
Quoted 10 lines
on the suspend blockers for drivers; the linux device runtime PM is effectively doing the same things; it allows drivers to suspend/resume individually (with a very nice API/programming model I should say) based on usage. And it works on a tree level, so that it's relatively easy to do things like "I want to go to <this magic deep idle state>, but only if <this set of devices is suspended already>". This is obviously an important functionality for all low power devices, ARM or x86. Suspend blockers had this functionality as part of what it did (they do more obviously) but I'd wager that the current Linux infrastructure is outright nicer.
Quoted 1 line
This is what Rafael has been working on?
Quoted 8 lines
If you mean the runtime PM framework, then yes, I've been working on it.
Quoted 2 lines
Of course, the Android guys also want to pay attention to which apps are running as well as to the state of devices on the system.
In fact the runtime PM framework is also important to Android, because it can be used in there, for example, to implement the "early suspend" thing I referred to in one of my previous messages in this thread.
Now we just need to convince the Android guys of that. ;-)
Thanx, Paul
Quoted 16 lines · Paul E. McKenney
Quoted 15 lines · Rafael J. Wysocki
Quoted 3 lines · Paul E. McKenney
Quoted 2 lines · Arjan van de Ven
On Sun, 1 Aug 2010 12:12:28 -0700
"Paul E. McKenney" <[email protected]> wrote:...
Quoted 9 lines
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
Quoted 8 lines
Quoted 3 lines
This isn't more difficult than deciding which applications will be allowed to use wakelocks (in the wakelocks world). It actually seems to be pretty much equivalent to me. :-)
If I understand correctly, the problem they were concerned about was instead "given that a certain set of apps are permitted to use wakelocks, which of the other apps can safely be frozen when the display blanks itself."
I _think_ the problem should be reformulated as "which of the other apps can be safely frozen without causing the wakelocks-using ones to have problems" instead (the particular scenario is that one of the wakelocks-using apps may need one of the other apps to process something and therefore the other app cannot be frozen; however, that may be resolved by thawing all of the other apps in such situations IMO).
Quoted 15 lines
Quoted 15 lines
Quoted 11 lines
Quoted 10 lines
on the suspend blockers for drivers; the linux device runtime PM is effectively doing the same things; it allows drivers to suspend/resume individually (with a very nice API/programming model I should say) based on usage. And it works on a tree level, so that it's relatively easy to do things like "I want to go to <this magic deep idle state>, but only if <this set of devices is suspended already>". This is obviously an important functionality for all low power devices, ARM or x86. Suspend blockers had this functionality as part of what it did (they do more obviously) but I'd wager that the current Linux infrastructure is outright nicer.
Quoted 1 line
This is what Rafael has been working on?
If you mean the runtime PM framework, then yes, I've been working on it.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Of course, the Android guys also want to pay attention to which apps are running as well as to the state of devices on the system.
In fact the runtime PM framework is also important to Android, because it can be used in there, for example, to implement the "early suspend" thing I referred to in one of my previous messages in this thread.
Now we just need to convince the Android guys of that. ;-)
I believe there's no need for that, as we were talking about that a few months ago.
Thanks,
Rafael
Quoted 16 lines · Paul E. McKenney
Quoted 15 lines · Rafael J. Wysocki
Quoted 3 lines · Paul E. McKenney
Quoted 2 lines · Arjan van de Ven
On Sun, 1 Aug 2010 12:12:28 -0700
"Paul E. McKenney" <[email protected]> wrote:...
Quoted 9 lines
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
Quoted 8 lines
Quoted 3 lines
This isn't more difficult than deciding which applications will be allowed to use wakelocks (in the wakelocks world). It actually seems to be pretty much equivalent to me. :-)
If I understand correctly, the problem they were concerned about was instead "given that a certain set of apps are permitted to use wakelocks, which of the other apps can safely be frozen when the display blanks itself."
I _think_ the problem should be reformulated as "which of the other apps can be safely frozen without causing the wakelocks-using ones to have problems" instead (the particular scenario is that one of the wakelocks-using apps may need one of the other apps to process something and therefore the other app cannot be frozen; however, that may be resolved by thawing all of the other apps in such situations IMO).
Quoted 15 lines
Quoted 15 lines
Quoted 11 lines
Quoted 10 lines
on the suspend blockers for drivers; the linux device runtime PM is effectively doing the same things; it allows drivers to suspend/resume individually (with a very nice API/programming model I should say) based on usage. And it works on a tree level, so that it's relatively easy to do things like "I want to go to <this magic deep idle state>, but only if <this set of devices is suspended already>". This is obviously an important functionality for all low power devices, ARM or x86. Suspend blockers had this functionality as part of what it did (they do more obviously) but I'd wager that the current Linux infrastructure is outright nicer.
Quoted 1 line
This is what Rafael has been working on?
If you mean the runtime PM framework, then yes, I've been working on it.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Of course, the Android guys also want to pay attention to which apps are running as well as to the state of devices on the system.
In fact the runtime PM framework is also important to Android, because it can be used in there, for example, to implement the "early suspend" thing I referred to in one of my previous messages in this thread.
Now we just need to convince the Android guys of that. ;-)
I believe there's no need for that, as we were talking about that a few months ago.
Thanks,
Rafael
Quoted 26 lines · Rafael J. Wysocki
Quoted 16 lines · Paul E. McKenney
Quoted 15 lines · Rafael J. Wysocki
Quoted 3 lines · Paul E. McKenney
Quoted 2 lines · Arjan van de Ven
On Sun, 1 Aug 2010 12:12:28 -0700
"Paul E. McKenney" <[email protected]> wrote:...
Quoted 9 lines
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
Quoted 8 lines
Quoted 3 lines
This isn't more difficult than deciding which applications will be allowed to use wakelocks (in the wakelocks world). It actually seems to be pretty much equivalent to me. :-)
If I understand correctly, the problem they were concerned about was instead "given that a certain set of apps are permitted to use wakelocks, which of the other apps can safely be frozen when the display blanks itself."
Quoted 6 lines
I _think_ the problem should be reformulated as "which of the other apps can be safely frozen without causing the wakelocks-using ones to have problems" instead (the particular scenario is that one of the wakelocks-using apps may need one of the other apps to process something and therefore the other app cannot be frozen; however, that may be resolved by thawing all of the other apps in such situations IMO).
I agree that your statement is equivalent to mine. From what I can see, the current Android code resolves this by not freezing any app while a wakelock is held.
Just out of curiosity, how are you detecting the situation in order to decide when to thaw the apps in the cgroup?
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 11 lines
Quoted 10 lines
on the suspend blockers for drivers; the linux device runtime PM is effectively doing the same things; it allows drivers to suspend/resume individually (with a very nice API/programming model I should say) based on usage. And it works on a tree level, so that it's relatively easy to do things like "I want to go to <this magic deep idle state>, but only if <this set of devices is suspended already>". This is obviously an important functionality for all low power devices, ARM or x86. Suspend blockers had this functionality as part of what it did (they do more obviously) but I'd wager that the current Linux infrastructure is outright nicer.
Quoted 1 line
This is what Rafael has been working on?
If you mean the runtime PM framework, then yes, I've been working on it.
Quoted 2 lines
Of course, the Android guys also want to pay attention to which apps are running as well as to the state of devices on the system.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
In fact the runtime PM framework is also important to Android, because it can be used in there, for example, to implement the "early suspend" thing I referred to in one of my previous messages in this thread.
Now we just need to convince the Android guys of that. ;-)
I believe there's no need for that, as we were talking about that a few months ago.
Here is hoping...
Thanx, Paul
Quoted 26 lines · Rafael J. Wysocki
Quoted 16 lines · Paul E. McKenney
Quoted 15 lines · Rafael J. Wysocki
Quoted 3 lines · Paul E. McKenney
Quoted 2 lines · Arjan van de Ven
On Sun, 1 Aug 2010 12:12:28 -0700
"Paul E. McKenney" <[email protected]> wrote:...
Quoted 9 lines
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
Quoted 8 lines
Quoted 3 lines
This isn't more difficult than deciding which applications will be allowed to use wakelocks (in the wakelocks world). It actually seems to be pretty much equivalent to me. :-)
If I understand correctly, the problem they were concerned about was instead "given that a certain set of apps are permitted to use wakelocks, which of the other apps can safely be frozen when the display blanks itself."
Quoted 6 lines
I _think_ the problem should be reformulated as "which of the other apps can be safely frozen without causing the wakelocks-using ones to have problems" instead (the particular scenario is that one of the wakelocks-using apps may need one of the other apps to process something and therefore the other app cannot be frozen; however, that may be resolved by thawing all of the other apps in such situations IMO).
I agree that your statement is equivalent to mine. From what I can see, the current Android code resolves this by not freezing any app while a wakelock is held.
Just out of curiosity, how are you detecting the situation in order to decide when to thaw the apps in the cgroup?
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 11 lines
Quoted 10 lines
on the suspend blockers for drivers; the linux device runtime PM is effectively doing the same things; it allows drivers to suspend/resume individually (with a very nice API/programming model I should say) based on usage. And it works on a tree level, so that it's relatively easy to do things like "I want to go to <this magic deep idle state>, but only if <this set of devices is suspended already>". This is obviously an important functionality for all low power devices, ARM or x86. Suspend blockers had this functionality as part of what it did (they do more obviously) but I'd wager that the current Linux infrastructure is outright nicer.
Quoted 1 line
This is what Rafael has been working on?
If you mean the runtime PM framework, then yes, I've been working on it.
Quoted 2 lines
Of course, the Android guys also want to pay attention to which apps are running as well as to the state of devices on the system.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
In fact the runtime PM framework is also important to Android, because it can be used in there, for example, to implement the "early suspend" thing I referred to in one of my previous messages in this thread.
Now we just need to convince the Android guys of that. ;-)
I believe there's no need for that, as we were talking about that a few months ago.
Here is hoping...
Thanx, Paul
Quoted 34 lines · Paul E. McKenney
Quoted 26 lines · Rafael J. Wysocki
Quoted 16 lines · Paul E. McKenney
Quoted 15 lines · Rafael J. Wysocki
Quoted 3 lines · Paul E. McKenney
Quoted 2 lines · Arjan van de Ven
On Sun, 1 Aug 2010 12:12:28 -0700
"Paul E. McKenney" <[email protected]> wrote:...
Quoted 9 lines
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
Quoted 8 lines
Quoted 3 lines
This isn't more difficult than deciding which applications will be allowed to use wakelocks (in the wakelocks world). It actually seems to be pretty much equivalent to me. :-)
If I understand correctly, the problem they were concerned about was instead "given that a certain set of apps are permitted to use wakelocks, which of the other apps can safely be frozen when the display blanks itself."
Quoted 6 lines
I _think_ the problem should be reformulated as "which of the other apps can be safely frozen without causing the wakelocks-using ones to have problems" instead (the particular scenario is that one of the wakelocks-using apps may need one of the other apps to process something and therefore the other app cannot be frozen; however, that may be resolved by thawing all of the other apps in such situations IMO).
Quoted 6 lines
I agree that your statement is equivalent to mine. From what I can see, the current Android code resolves this by not freezing any app while a wakelock is held.
Just out of curiosity, how are you detecting the situation in order to decide when to thaw the apps in the cgroup?
Well, in fact I would only be able to talk about that theoretically, as I'm currently not involved in any project using cgroups for power management. I have considered that, but I haven't tried to implement it.
Thanks,
Rafael
Quoted 47 lines · Paul E. McKenney
Quoted 19 lines · On Sun, Aug 01, 2010 at 10:06:34PM -0700, [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
Quoted 4 lines
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
Why not flesh this out and compare it to the draft requirements? (I expect to be sending another version by end of day Pacific Time.)
The biggest issue I see right off-hand is that a straightforward implementation of your idea would require moving processes from one cgroup to another when acquiring or releasing a suspend blocker, which from what I understand would be way to heavyweight. On the other hand, if acquiring and releasing a suspend blocker does not move the process from one cgroup to another, then you need something very like the suspend-blocker mechanism to handle those processes that are permitted to acquire suspend blockers, and which are thus not a member of the cgroup in question.
That said, I did see some hint from the Android guys that it -might- be possible to leverage cgroups in the way that you suggest might help save power during times when suspend was blocked but (for example) the screen was turned off. The idea would be to freeze the cgroup whenever the screen blanked, even if suspend was blocked. The biggest issue here is that any process that can hold a suspend blocker must never to an unconditional wait on any process in this cgroup. Seems to me that this should be possible in theory, but the devil would be in the details.
Quoted 1 line
If I am misunderstanding your proposal, please enlighten me!
you are close, but I think what I'm proposing is actually simpler (assuming that the scheduler can be configured to generate the appropriate stats)
my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be in cgroup A while all other applications are in cgroup B
when you are deciding if the system shoudl go to sleep because it is idle, ignore the activity of all applications in cgroup B
if cgroup A applications are busy, the system is not idle and should not suspend.
this requires that the applications in cgroup A actually go idle as opposed to simply releaseing the suspend-block lock, but it would mean that there are no application changes required for to move a system from the status "even if it's busy, go ahead ans suspend" to "this application is important, don't suspend if it's got work to do", it would just be classifying the application in one cgroup or the other.
This assumes that an application that you would trust to hold the suspend-block lock is going to be well behaved (if it isn't, how can you trust it to not grab the lock inappropriatly?)
David Lang
Quoted 60 lines · On Mon, Aug 2, 2010 at 5:08 PM, <[email protected]> wrote:
Quoted 48 lines · Paul E. McKenney
Quoted 20 lines · On Sun, Aug 01, 2010 at 10:06:34PM -0700, [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
Quoted 4 lines
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
Why not flesh this out and compare it to the draft requirements? (I expect to be sending another version by end of day Pacific Time.)
The biggest issue I see right off-hand is that a straightforward implementation of your idea would require moving processes from one cgroup to another when acquiring or releasing a suspend blocker, which from what I understand would be way to heavyweight. On the other hand, if acquiring and releasing a suspend blocker does not move the process from one cgroup to another, then you need something very like the suspend-blocker mechanism to handle those processes that are permitted to acquire suspend blockers, and which are thus not a member of the cgroup in question.
That said, I did see some hint from the Android guys that it -might- be possible to leverage cgroups in the way that you suggest might help save power during times when suspend was blocked but (for example) the screen was turned off. The idea would be to freeze the cgroup whenever the screen blanked, even if suspend was blocked. The biggest issue here is that any process that can hold a suspend blocker must never to an unconditional wait on any process in this cgroup. Seems to me that this should be possible in theory, but the devil would be in the details.
Quoted 1 line
If I am misunderstanding your proposal, please enlighten me!
you are close, but I think what I'm proposing is actually simpler (assuming that the scheduler can be configured to generate the appropriate stats)
my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be in cgroup A while all other applications are in cgroup B
Quoted 6 lines
when you are deciding if the system shoudl go to sleep because it is idle, ignore the activity of all applications in cgroup B
if cgroup A applications are busy, the system is not idle and should not suspend.
Triggering suspend from idle has been suggested before. However, idle is not a signal that it is safe to suspend since timers stop in suspend (or the code could temporarily be waiting on a non-wakeup interrupt). If you add suspend blockers or wakelocks to prevent suspend while events you care about are pending, then it does not make a lot of sense to prevent suspend just because the cpu is not idle.
Quoted 13 lines
this requires that the applications in cgroup A actually go idle as opposed to simply releaseing the suspend-block lock, but it would mean that there are no application changes required for to move a system from the status "even if it's busy, go ahead ans suspend" to "this application is important, don't suspend if it's got work to do", it would just be classifying the application in one cgroup or the other.
This assumes that an application that you would trust to hold the suspend-block lock is going to be well behaved (if it isn't, how can you trust it to not grab the lock inappropriatly?)
David Lang
Signature · 1 line
Arve Hjønnevåg
Quoted 60 lines · On Mon, Aug 2, 2010 at 5:08 PM, <[email protected]> wrote:
Quoted 48 lines · Paul E. McKenney
Quoted 20 lines · On Sun, Aug 01, 2010 at 10:06:34PM -0700, [email protected] wrote:
Quoted 7 lines · Arjan van de Ven
I'm a little worried that this whole "I need to block suspend" is temporary. Yes today there is silicon from ARM and Intel where suspend is a heavy operation, yet at the same time it's not all THAT heavy anymore.... at least on the Intel side it's good enough to use pretty much all the time (when the screen is off for now, but that's a memory controller issue more than anything else). I'm pretty sure the ARM guys will not be far behind.
remember that this 'block suspend' is really 'block overriding the fact that there are still runable processes and suspending anyway"
having it labeled as 'suspend blocker' or even 'wakelock' makes it sound as if it blocks any attempt to suspend, and I'm not sure that's what's really intended. Itsounds like the normal syspend process would continue to work, just this 'ignore if these other apps are busy' mode of operation would not work.
Quoted 4 lines
which makes me wonder, would it be possible to tell the normal idle detection mechanism to ignore specific processes when deciding if it should suspend or not? how about only considering processes in one cgroup when deciding to suspend and ignoring all others?
Why not flesh this out and compare it to the draft requirements? (I expect to be sending another version by end of day Pacific Time.)
The biggest issue I see right off-hand is that a straightforward implementation of your idea would require moving processes from one cgroup to another when acquiring or releasing a suspend blocker, which from what I understand would be way to heavyweight. On the other hand, if acquiring and releasing a suspend blocker does not move the process from one cgroup to another, then you need something very like the suspend-blocker mechanism to handle those processes that are permitted to acquire suspend blockers, and which are thus not a member of the cgroup in question.
That said, I did see some hint from the Android guys that it -might- be possible to leverage cgroups in the way that you suggest might help save power during times when suspend was blocked but (for example) the screen was turned off. The idea would be to freeze the cgroup whenever the screen blanked, even if suspend was blocked. The biggest issue here is that any process that can hold a suspend blocker must never to an unconditional wait on any process in this cgroup. Seems to me that this should be possible in theory, but the devil would be in the details.
Quoted 1 line
If I am misunderstanding your proposal, please enlighten me!
you are close, but I think what I'm proposing is actually simpler (assuming that the scheduler can be configured to generate the appropriate stats)
my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be in cgroup A while all other applications are in cgroup B
Quoted 6 lines
when you are deciding if the system shoudl go to sleep because it is idle, ignore the activity of all applications in cgroup B
if cgroup A applications are busy, the system is not idle and should not suspend.
Triggering suspend from idle has been suggested before. However, idle is not a signal that it is safe to suspend since timers stop in suspend (or the code could temporarily be waiting on a non-wakeup interrupt). If you add suspend blockers or wakelocks to prevent suspend while events you care about are pending, then it does not make a lot of sense to prevent suspend just because the cpu is not idle.
Quoted 13 lines
this requires that the applications in cgroup A actually go idle as opposed to simply releaseing the suspend-block lock, but it would mean that there are no application changes required for to move a system from the status "even if it's busy, go ahead ans suspend" to "this application is important, don't suspend if it's got work to do", it would just be classifying the application in one cgroup or the other.
This assumes that an application that you would trust to hold the suspend-block lock is going to be well behaved (if it isn't, how can you trust it to not grab the lock inappropriatly?)
David Lang
Signature · 1 line
Arve Hjønnevåg
On Sat, Jul 31, 2010 at 10:58 AM, Paul E. McKenney <[email protected]> wrote:
...
Quoted 41 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend battery life and (2) preserve state until AC power can be obtained.
o It is necessary to be able to use power-naive applications. Many of these applications were designed for use in PC platforms where power consumption has historically not been of great concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations. The system must be capable of running these power-naive applications without requiring that these applications be modified, and must be capable of reasonable power efficiency even when power-naive applications are available.
o If the display is powered off, there is no need to run any application whose only effect is to update the display.
Although one could simply block such an application when it next tries to access the display, it appears that it is highly desirable that the application also be prevented from consuming power computing anything that will not be displayed. Furthermore, whatever mechanism is used must operate on power-naive applications that do not use blocking system calls.
o In order to avoid overrunning hardware and/or kernel buffers, input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.
In particular, if user input that would prevent the system from entering a low-power state is received while the system is transitioning into a low-power state, the system must transition back out of the low-power state so that it can hand the user input off to the corresponding application.
o If a power-aware application receives user input, then that application must be given the opportunity to process that input.
Quoted 6 lines
o A power-aware application must be able to efficiently communicate its needs to the system, so that such communication can be performed on hot code paths. Communication via
open()andclose()is considered too slow, but communication viaioctl()is acceptable.
The problem with using open and close to prevent an allow suspend is not that it is too slow but that it interferes with collecting stats. The wakelock code has a sysfs interface that allow you to use a open/write/close sequence to block or unblock suspend. There is no limit to the amount of kernel memory that a process can consume with this interface, so the suspend blocker patchset uses a /dev interface with ioctls to block or unblock suspend and it destroys the kernel object when the file descriptor is closed.
Quoted 8 lines
o Power-naive applications must be prohibited from controlling the system power state. One acceptable approach is through use of group permissions on a special power-control device.
o Statistics of the power-control actions taken by power-aware applications must be provided, and must be keyed off of program name.
We don't key the stats off the program name, but having useful statistics is critical too us. The current code in linux-next does not appear to allow this (I'm referring to pm_stay_awake here, etc not pm-qos.)
Quoted 6 lines
o Power-aware applications can make use of power-naive infrastructure. This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.
Quoted 6 lines
o When a power-aware application is preventing the system from shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
wake-lock/suspend-blocker timeouts have nothing to do with the timeout used by applications when waiting for a response from a less trusted application.
Quoted 6 lines
o If no power-aware or power-optimized application are indicating a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)
I would say it should suspend even if power aware applications are runnable. Most applications do not exclusively perform critical work.
Quoted 5 lines
o Transition to low-power state must be efficient. In particular, methods based on repeated attempts to suspend are considered to be too inefficient to be useful.
It must be power-efficient. Repeated attempts to suspend will kill the idle battery life.
Quoted 10 lines
o Individual peripherals and CPUs must still use standard power-conservation measures, for example, transitioning CPUs into low-power states on idle and powering down peripheral devices and hardware accelerators that have not been recently used.
o The API that controls the system power state must be accessible both from Android's Java replacement, from userland C code, and from kernel C code (both process level and irq code, but not NMI handlers).
Quoted 5 lines
o Any initialization of the API that controls the system power state must be unconditional, so as to be free from failure. (I don't currently understand how this relates, probably due to my current insufficient understanding of the proposed patch set.)
Unconditional initialization makes it easier to add suspend blockers to existing kernel code since you don't have to add new failure exit paths. It is not a strong requirement.
Quoted 19 lines
o The API that controls the system power state must operate correctly on SMP systems of modest size. (My guess is that "modest" means up to four CPUs, maybe up to eight CPUs.)
o Any QoS-based solution must take display and user-input state into account. In other words, the QoS must be expressed as a function of the display and the user-input states.
o Transitioning to extremely low power states requires saving and restoring DRAM and/or cache SRAM state, which in itself consumes significant energy. The power savings must therefore be balanced against the energy consumed in the state transitions.
o The current Android userspace API must be supported in order to support existing device software.
Signature · 1 line
Arve Hjønnevåg
On Sat, Jul 31, 2010 at 10:58 AM, Paul E. McKenney <[email protected]> wrote:
...
Quoted 41 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend battery life and (2) preserve state until AC power can be obtained.
o It is necessary to be able to use power-naive applications. Many of these applications were designed for use in PC platforms where power consumption has historically not been of great concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations. The system must be capable of running these power-naive applications without requiring that these applications be modified, and must be capable of reasonable power efficiency even when power-naive applications are available.
o If the display is powered off, there is no need to run any application whose only effect is to update the display.
Although one could simply block such an application when it next tries to access the display, it appears that it is highly desirable that the application also be prevented from consuming power computing anything that will not be displayed. Furthermore, whatever mechanism is used must operate on power-naive applications that do not use blocking system calls.
o In order to avoid overrunning hardware and/or kernel buffers, input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.
In particular, if user input that would prevent the system from entering a low-power state is received while the system is transitioning into a low-power state, the system must transition back out of the low-power state so that it can hand the user input off to the corresponding application.
o If a power-aware application receives user input, then that application must be given the opportunity to process that input.
Quoted 6 lines
o A power-aware application must be able to efficiently communicate its needs to the system, so that such communication can be performed on hot code paths. Communication via
open()andclose()is considered too slow, but communication viaioctl()is acceptable.
The problem with using open and close to prevent an allow suspend is not that it is too slow but that it interferes with collecting stats. The wakelock code has a sysfs interface that allow you to use a open/write/close sequence to block or unblock suspend. There is no limit to the amount of kernel memory that a process can consume with this interface, so the suspend blocker patchset uses a /dev interface with ioctls to block or unblock suspend and it destroys the kernel object when the file descriptor is closed.
Quoted 8 lines
o Power-naive applications must be prohibited from controlling the system power state. One acceptable approach is through use of group permissions on a special power-control device.
o Statistics of the power-control actions taken by power-aware applications must be provided, and must be keyed off of program name.
We don't key the stats off the program name, but having useful statistics is critical too us. The current code in linux-next does not appear to allow this (I'm referring to pm_stay_awake here, etc not pm-qos.)
Quoted 6 lines
o Power-aware applications can make use of power-naive infrastructure. This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.
Quoted 6 lines
o When a power-aware application is preventing the system from shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
wake-lock/suspend-blocker timeouts have nothing to do with the timeout used by applications when waiting for a response from a less trusted application.
Quoted 6 lines
o If no power-aware or power-optimized application are indicating a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)
I would say it should suspend even if power aware applications are runnable. Most applications do not exclusively perform critical work.
Quoted 5 lines
o Transition to low-power state must be efficient. In particular, methods based on repeated attempts to suspend are considered to be too inefficient to be useful.
It must be power-efficient. Repeated attempts to suspend will kill the idle battery life.
Quoted 10 lines
o Individual peripherals and CPUs must still use standard power-conservation measures, for example, transitioning CPUs into low-power states on idle and powering down peripheral devices and hardware accelerators that have not been recently used.
o The API that controls the system power state must be accessible both from Android's Java replacement, from userland C code, and from kernel C code (both process level and irq code, but not NMI handlers).
Quoted 5 lines
o Any initialization of the API that controls the system power state must be unconditional, so as to be free from failure. (I don't currently understand how this relates, probably due to my current insufficient understanding of the proposed patch set.)
Unconditional initialization makes it easier to add suspend blockers to existing kernel code since you don't have to add new failure exit paths. It is not a strong requirement.
Quoted 19 lines
o The API that controls the system power state must operate correctly on SMP systems of modest size. (My guess is that "modest" means up to four CPUs, maybe up to eight CPUs.)
o Any QoS-based solution must take display and user-input state into account. In other words, the QoS must be expressed as a function of the display and the user-input states.
o Transitioning to extremely low power states requires saving and restoring DRAM and/or cache SRAM state, which in itself consumes significant energy. The power savings must therefore be balanced against the energy consumed in the state transitions.
o The current Android userspace API must be supported in order to support existing device software.
Signature · 1 line
Arve Hjønnevåg
Quoted 3 lines · Florian Mickler
Thinking about it.. I don't know much about cgroups, but I think a process can only be in one cgroup at a time.
A thread can only be in one cgroup in each hierarchy at one time. You can mount multiple cgroups hierarchies, with different resource controllers on different hierarchies.
Quoted 4 lines
b) you can't use cgroup for other purposes anymore. I.e. if you want to have 2 groups that each only have half of the memory available, how would you then integrate the cgroup-ignore-for-idle-approach with this?
You could mount the subsystem that provides the "ignore-for-idle" support on one hierarchy, and partition the trusted/untrusted processes that way, and the memory controller subsystem on a different hierarchy, with whatever split you wanted for memory controls.
Paul
Quoted 3 lines · Florian Mickler
Thinking about it.. I don't know much about cgroups, but I think a process can only be in one cgroup at a time.
A thread can only be in one cgroup in each hierarchy at one time. You can mount multiple cgroups hierarchies, with different resource controllers on different hierarchies.
Quoted 4 lines
b) you can't use cgroup for other purposes anymore. I.e. if you want to have 2 groups that each only have half of the memory available, how would you then integrate the cgroup-ignore-for-idle-approach with this?
You could mount the subsystem that provides the "ignore-for-idle" support on one hierarchy, and partition the trusted/untrusted processes that way, and the memory controller subsystem on a different hierarchy, with whatever split you wanted for memory controls.
Paul
Quoted 4 lines · On Mon, Aug 2, 2010 at 2:06 AM, <[email protected]> wrote:
yes, it could mean a doubleing in the number of cgroups that you need on a system. and if there are other features like this you can end up in a geometric explosion in the number of cgroups.
No, it would be additive - you can mount different subsystems on separate hierarchies. So if you had X divisions for memory, Y divisions for CPU and Z divisions for suspend-blocking (where Z=2, probably?) you could mount three separate hierarchies and have X+Y+Z complexity, not X*Y*Z.
(Not that I have a strong opinion on whether cgroups is an appropriate mechanism for solving this problem - just that the problem you forsee shouldn't occur in practice).
Paul
Quoted 4 lines · On Mon, Aug 2, 2010 at 2:06 AM, <[email protected]> wrote:
yes, it could mean a doubleing in the number of cgroups that you need on a system. and if there are other features like this you can end up in a geometric explosion in the number of cgroups.
No, it would be additive - you can mount different subsystems on separate hierarchies. So if you had X divisions for memory, Y divisions for CPU and Z divisions for suspend-blocking (where Z=2, probably?) you could mount three separate hierarchies and have X+Y+Z complexity, not X*Y*Z.
(Not that I have a strong opinion on whether cgroups is an appropriate mechanism for solving this problem - just that the problem you forsee shouldn't occur in practice).
Paul
Quoted 19 lines · Arve Hj?nnev?g
Quoted 11 lines · On Mon, Aug 2, 2010 at 5:08 PM, <[email protected]> wrote:
On Mon, 2 Aug 2010, Paul E. McKenney wrote:
you are close, but I think what I'm proposing is actually simpler (assuming that the scheduler can be configured to generate the appropriate stats)
my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be in cgroup A while all other applications are in cgroup B
Quoted 6 lines
when you are deciding if the system shoudl go to sleep because it is idle, ignore the activity of all applications in cgroup B
if cgroup A applications are busy, the system is not idle and should not suspend.
Quoted 6 lines
Triggering suspend from idle has been suggested before. However, idle is not a signal that it is safe to suspend since timers stop in suspend (or the code could temporarily be waiting on a non-wakeup interrupt). If you add suspend blockers or wakelocks to prevent suspend while events you care about are pending, then it does not make a lot of sense to prevent suspend just because the cpu is not idle.
isn't this a matter of making the suspend decision look at what timers have been set to expire in the near future and/or tweaking how long the system needs to be idle before going to sleep?
to properly do a good job at suspending hyperagressivly you need to look at when you need to wake back up (after all, if you are only going to sleep for 1 second, it makes no sense to try and enter a sleep state that takes .5 seconds to get into and .6 seconds to get out of, you need to pick a lighter power saving mode)
if you really want to have the application be able to say 'I am ready for you to go to sleep NOW and I don't want any chance of waking back up until the system is ready for me to do so' it may be possible to have a special dev file that when a program attempts to read from it the program is considered to have been idle forever (expiring any 'delay since last activity' timers that are running for that process) and when the device wakes back up (or after a little bit of time if the device decides not to go back to sleep), allow the return from the blocking call to allow the app to continue running.
but I am not sure that something like that is needed. I think just checking for timers that are due to expire 'soon' and tweaking how long the system must be 'idle' before it decides to go to sleep should be good enough.
David Lang
Quoted 19 lines · Arve Hj?nnev?g
Quoted 11 lines · On Mon, Aug 2, 2010 at 5:08 PM, <[email protected]> wrote:
On Mon, 2 Aug 2010, Paul E. McKenney wrote:
you are close, but I think what I'm proposing is actually simpler (assuming that the scheduler can be configured to generate the appropriate stats)
my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be in cgroup A while all other applications are in cgroup B
Quoted 6 lines
when you are deciding if the system shoudl go to sleep because it is idle, ignore the activity of all applications in cgroup B
if cgroup A applications are busy, the system is not idle and should not suspend.
Quoted 6 lines
Triggering suspend from idle has been suggested before. However, idle is not a signal that it is safe to suspend since timers stop in suspend (or the code could temporarily be waiting on a non-wakeup interrupt). If you add suspend blockers or wakelocks to prevent suspend while events you care about are pending, then it does not make a lot of sense to prevent suspend just because the cpu is not idle.
isn't this a matter of making the suspend decision look at what timers have been set to expire in the near future and/or tweaking how long the system needs to be idle before going to sleep?
to properly do a good job at suspending hyperagressivly you need to look at when you need to wake back up (after all, if you are only going to sleep for 1 second, it makes no sense to try and enter a sleep state that takes .5 seconds to get into and .6 seconds to get out of, you need to pick a lighter power saving mode)
if you really want to have the application be able to say 'I am ready for you to go to sleep NOW and I don't want any chance of waking back up until the system is ready for me to do so' it may be possible to have a special dev file that when a program attempts to read from it the program is considered to have been idle forever (expiring any 'delay since last activity' timers that are running for that process) and when the device wakes back up (or after a little bit of time if the device decides not to go back to sleep), allow the return from the blocking call to allow the app to continue running.
but I am not sure that something like that is needed. I think just checking for timers that are due to expire 'soon' and tweaking how long the system must be 'idle' before it decides to go to sleep should be good enough.
David Lang
Quoted 1 line · Paul E. McKenney
On Sun, Aug 01, 2010 at 03:47:08PM -0700, Arjan van de Ven wrote:
...
Quoted 10 lines
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
The dependencies is what made this solution uninteresting to us. For instance, we currently use cgroup scheduling to reduce the impact of some background tasks, but we occasionally saw a watchdog restart of the system process were critical services were waiting on a kernel mutex owned by a background task for more than 20 seconds. If we froze a cgroup instead, we would not hit this particular problem since tasks cannot be frozen while executing kernel code the same way they can be preempted, but nothing prevents a task from being frozen while holding a user-space resource.
Signature · 1 line
Arve Hjønnevåg
Quoted 1 line · Paul E. McKenney
On Sun, Aug 01, 2010 at 03:47:08PM -0700, Arjan van de Ven wrote:
...
Quoted 10 lines
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
The dependencies is what made this solution uninteresting to us. For instance, we currently use cgroup scheduling to reduce the impact of some background tasks, but we occasionally saw a watchdog restart of the system process were critical services were waiting on a kernel mutex owned by a background task for more than 20 seconds. If we froze a cgroup instead, we would not hit this particular problem since tasks cannot be frozen while executing kernel code the same way they can be preempted, but nothing prevents a task from being frozen while holding a user-space resource.
Signature · 1 line
Arve Hjønnevåg
2010/8/2 <[email protected]>:
Quoted 32 lines · Arve Hj?nnev?g
Quoted 24 lines · On Mon, Aug 2, 2010 at 5:08 PM, <[email protected]> wrote:
Quoted 14 lines · Paul E. McKenney
you are close, but I think what I'm proposing is actually simpler (assuming
that the scheduler can be configured to generate the appropriate stats)my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be in
cgroup A while all other applications are in cgroup BQuoted 7 lines
when you are deciding if the system shoudl go to sleep because it is idle,
ignore the activity of all applications in cgroup Bif cgroup A applications are busy, the system is not idle and should not suspend.
Quoted 6 lines
Triggering suspend from idle has been suggested before. However, idle is not a signal that it is safe to suspend since timers stop in suspend (or the code could temporarily be waiting on a non-wakeup interrupt). If you add suspend blockers or wakelocks to prevent suspend while events you care about are pending, then it does not make a lot of sense to prevent suspend just because the cpu is not idle.
Quoted 4 lines
isn't this a matter of making the suspend decision look at what timers have been set to expire in the near future and/or tweaking how long the system needs to be idle before going to sleep?
You are describing low power idle modes, not suspend. Most timers stop in suspend, so a timer set 10 seconds from now when entering suspend will go off 10 seconds after resume so it should have no impact on how long you decide to stay in suspend.
Quoted 22 lines
to properly do a good job at suspending hyperagressivly you need to look at when you need to wake back up (after all, if you are only going to sleep for 1 second, it makes no sense to try and enter a sleep state that takes .5 seconds to get into and .6 seconds to get out of, you need to pick a lighter power saving mode)
if you really want to have the application be able to say 'I am ready for you to go to sleep NOW and I don't want any chance of waking back up until the system is ready for me to do so' it may be possible to have a special dev file that when a program attempts to read from it the program is considered to have been idle forever (expiring any 'delay since last activity' timers that are running for that process) and when the device wakes back up (or after a little bit of time if the device decides not to go back to sleep), allow the return from the blocking call to allow the app to continue running.
but I am not sure that something like that is needed. I think just checking for timers that are due to expire 'soon' and tweaking how long the system must be 'idle' before it decides to go to sleep should be good enough.
David Lang
Signature · 1 line
Arve Hjønnevåg
2010/8/2 <[email protected]>:
Quoted 32 lines · Arve Hj?nnev?g
Quoted 24 lines · On Mon, Aug 2, 2010 at 5:08 PM, <[email protected]> wrote:
Quoted 14 lines · Paul E. McKenney
you are close, but I think what I'm proposing is actually simpler (assuming
that the scheduler can be configured to generate the appropriate stats)my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be in
cgroup A while all other applications are in cgroup BQuoted 7 lines
when you are deciding if the system shoudl go to sleep because it is idle,
ignore the activity of all applications in cgroup Bif cgroup A applications are busy, the system is not idle and should not suspend.
Quoted 6 lines
Triggering suspend from idle has been suggested before. However, idle is not a signal that it is safe to suspend since timers stop in suspend (or the code could temporarily be waiting on a non-wakeup interrupt). If you add suspend blockers or wakelocks to prevent suspend while events you care about are pending, then it does not make a lot of sense to prevent suspend just because the cpu is not idle.
Quoted 4 lines
isn't this a matter of making the suspend decision look at what timers have been set to expire in the near future and/or tweaking how long the system needs to be idle before going to sleep?
You are describing low power idle modes, not suspend. Most timers stop in suspend, so a timer set 10 seconds from now when entering suspend will go off 10 seconds after resume so it should have no impact on how long you decide to stay in suspend.
Quoted 22 lines
to properly do a good job at suspending hyperagressivly you need to look at when you need to wake back up (after all, if you are only going to sleep for 1 second, it makes no sense to try and enter a sleep state that takes .5 seconds to get into and .6 seconds to get out of, you need to pick a lighter power saving mode)
if you really want to have the application be able to say 'I am ready for you to go to sleep NOW and I don't want any chance of waking back up until the system is ready for me to do so' it may be possible to have a special dev file that when a program attempts to read from it the program is considered to have been idle forever (expiring any 'delay since last activity' timers that are running for that process) and when the device wakes back up (or after a little bit of time if the device decides not to go back to sleep), allow the return from the blocking call to allow the app to continue running.
but I am not sure that something like that is needed. I think just checking for timers that are due to expire 'soon' and tweaking how long the system must be 'idle' before it decides to go to sleep should be good enough.
David Lang
Signature · 1 line
Arve Hjønnevåg
Quoted 38 lines · Arve Hj?nnev?g
2010/8/2 <[email protected]>:
Quoted 32 lines · Arve Hj?nnev?g
Quoted 24 lines · On Mon, Aug 2, 2010 at 5:08 PM, <[email protected]> wrote:
Quoted 14 lines · Paul E. McKenney
you are close, but I think what I'm proposing is actually simpler (assuming
that the scheduler can be configured to generate the appropriate stats)my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be in
cgroup A while all other applications are in cgroup BQuoted 7 lines
when you are deciding if the system shoudl go to sleep because it is idle,
ignore the activity of all applications in cgroup Bif cgroup A applications are busy, the system is not idle and should not suspend.
Quoted 6 lines
Triggering suspend from idle has been suggested before. However, idle is not a signal that it is safe to suspend since timers stop in suspend (or the code could temporarily be waiting on a non-wakeup interrupt). If you add suspend blockers or wakelocks to prevent suspend while events you care about are pending, then it does not make a lot of sense to prevent suspend just because the cpu is not idle.
Quoted 4 lines
isn't this a matter of making the suspend decision look at what timers have been set to expire in the near future and/or tweaking how long the system needs to be idle before going to sleep?
Quoted 4 lines
You are describing low power idle modes, not suspend. Most timers stop in suspend, so a timer set 10 seconds from now when entering suspend will go off 10 seconds after resume so it should have no impact on how long you decide to stay in suspend.
so what is the fundamental difference between deciding to go into low-power idle modes to wake up back up on a given point in the future and deciding that you are going to be idle for so long that you may as well suspend until there is user input?
David Lang
Quoted 38 lines · Arve Hj?nnev?g
2010/8/2 <[email protected]>:
Quoted 32 lines · Arve Hj?nnev?g
Quoted 24 lines · On Mon, Aug 2, 2010 at 5:08 PM, <[email protected]> wrote:
Quoted 14 lines · Paul E. McKenney
you are close, but I think what I'm proposing is actually simpler (assuming
that the scheduler can be configured to generate the appropriate stats)my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be in
cgroup A while all other applications are in cgroup BQuoted 7 lines
when you are deciding if the system shoudl go to sleep because it is idle,
ignore the activity of all applications in cgroup Bif cgroup A applications are busy, the system is not idle and should not suspend.
Quoted 6 lines
Triggering suspend from idle has been suggested before. However, idle is not a signal that it is safe to suspend since timers stop in suspend (or the code could temporarily be waiting on a non-wakeup interrupt). If you add suspend blockers or wakelocks to prevent suspend while events you care about are pending, then it does not make a lot of sense to prevent suspend just because the cpu is not idle.
Quoted 4 lines
isn't this a matter of making the suspend decision look at what timers have been set to expire in the near future and/or tweaking how long the system needs to be idle before going to sleep?
Quoted 4 lines
You are describing low power idle modes, not suspend. Most timers stop in suspend, so a timer set 10 seconds from now when entering suspend will go off 10 seconds after resume so it should have no impact on how long you decide to stay in suspend.
so what is the fundamental difference between deciding to go into low-power idle modes to wake up back up on a given point in the future and deciding that you are going to be idle for so long that you may as well suspend until there is user input?
David Lang
Hi!
Quoted 14 lines · On Mon, 2 Aug 2010 21:38:12 -0700 Paul Menage <[email protected]> wrote:
Quoted 3 lines · Florian Mickler
Thinking about it.. I don't know much about cgroups, but I think a process can only be in one cgroup at a time.
A thread can only be in one cgroup in each hierarchy at one time. You can mount multiple cgroups hierarchies, with different resource controllers on different hierarchies.
Quoted 4 lines
b) you can't use cgroup for other purposes anymore. I.e. if you want to have 2 groups that each only have half of the memory available, how would you then integrate the cgroup-ignore-for-idle-approach with this?
Quoted 6 lines
You could mount the subsystem that provides the "ignore-for-idle" support on one hierarchy, and partition the trusted/untrusted processes that way, and the memory controller subsystem on a different hierarchy, with whatever split you wanted for memory controls.
Paul
Thank you for the clarification. That renders my original objections more or less void.
I've still got some doubts about the flexibility of this approach (think an open system with arbitrary software components). But with a userspace manager that sorts processes into the groups this may be a possible solution.
But we should probably concentrate first on the requirements now. If we have a set of requirements everyone can agree too, we may be on our way to get a solution.
Cheers,
Flo
Hi!
Quoted 14 lines · On Mon, 2 Aug 2010 21:38:12 -0700 Paul Menage <[email protected]> wrote:
Quoted 3 lines · Florian Mickler
Thinking about it.. I don't know much about cgroups, but I think a process can only be in one cgroup at a time.
A thread can only be in one cgroup in each hierarchy at one time. You can mount multiple cgroups hierarchies, with different resource controllers on different hierarchies.
Quoted 4 lines
b) you can't use cgroup for other purposes anymore. I.e. if you want to have 2 groups that each only have half of the memory available, how would you then integrate the cgroup-ignore-for-idle-approach with this?
Quoted 6 lines
You could mount the subsystem that provides the "ignore-for-idle" support on one hierarchy, and partition the trusted/untrusted processes that way, and the memory controller subsystem on a different hierarchy, with whatever split you wanted for memory controls.
Paul
Thank you for the clarification. That renders my original objections more or less void.
I've still got some doubts about the flexibility of this approach (think an open system with arbitrary software components). But with a userspace manager that sorts processes into the groups this may be a possible solution.
But we should probably concentrate first on the requirements now. If we have a set of requirements everyone can agree too, we may be on our way to get a solution.
Cheers,
Flo
Quoted 12 lines · On Mon, 2 Aug 2010 21:41:17 -0700 Paul Menage <[email protected]> wrote:
Quoted 4 lines · On Mon, Aug 2, 2010 at 2:06 AM, <[email protected]> wrote:
yes, it could mean a doubleing in the number of cgroups that you need on a system. and if there are other features like this you can end up in a geometric explosion in the number of cgroups.
No, it would be additive - you can mount different subsystems on separate hierarchies. So if you had X divisions for memory, Y divisions for CPU and Z divisions for suspend-blocking (where Z=2, probably?) you could mount three separate hierarchies and have X+Y+Z complexity, not X*Y*Z.
Quoted 5 lines
(Not that I have a strong opinion on whether cgroups is an appropriate mechanism for solving this problem - just that the problem you forsee shouldn't occur in practice).
Paul
Ah yes, mea culpa. I've got this wrong.
Cheers,
Flo
Quoted 12 lines · On Mon, 2 Aug 2010 21:41:17 -0700 Paul Menage <[email protected]> wrote:
Quoted 4 lines · On Mon, Aug 2, 2010 at 2:06 AM, <[email protected]> wrote:
yes, it could mean a doubleing in the number of cgroups that you need on a system. and if there are other features like this you can end up in a geometric explosion in the number of cgroups.
No, it would be additive - you can mount different subsystems on separate hierarchies. So if you had X divisions for memory, Y divisions for CPU and Z divisions for suspend-blocking (where Z=2, probably?) you could mount three separate hierarchies and have X+Y+Z complexity, not X*Y*Z.
Quoted 5 lines
(Not that I have a strong opinion on whether cgroups is an appropriate mechanism for solving this problem - just that the problem you forsee shouldn't occur in practice).
Paul
Ah yes, mea culpa. I've got this wrong.
Cheers,
Flo
Hi Arve and Alan,
I have some questions regarding the Android early suspend and ACPI that are as follows:
1) If i see the early suspend features which is for android, it is if the user presses power off
the button and on button for late resumes. The question is if there is mobile platform,
then when user presses power off button, will the early suspend handlers will be called
at that time?
what usecase android early suspend handles?
2) Regarding ACPI which is more bios centric, will the drivers need to implement suspend/resume
as for normal OS use case scenarios?
Regards
Raj
Quoted 38 lines
Date: Mon, 2 Aug 2010 21:56:10 -0700
Subject: Re: Attempted summary of suspend-blockers LKML thread
From: [email protected]
To: [email protected]
CC: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]Quoted 1 line · Paul E. McKenney
On Sun, Aug 01, 2010 at 03:47:08PM -0700, Arjan van de Ven wrote:
...
Quoted 10 lines
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
The dependencies is what made this solution uninteresting to us. For instance, we currently use cgroup scheduling to reduce the impact of some background tasks, but we occasionally saw a watchdog restart of the system process were critical services were waiting on a kernel mutex owned by a background task for more than 20 seconds. If we froze a cgroup instead, we would not hit this particular problem since tasks cannot be frozen while executing kernel code the same way they can be preempted, but nothing prevents a task from being frozen while holding a user-space resource.
Signature · 6 lines
Arve Hjønnevåg -- 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/
Quoted 14 lines · Arve Hjønnevåg
Quoted 1 line · Paul E. McKenney
On Sun, Aug 01, 2010 at 03:47:08PM -0700, Arjan van de Ven wrote:
...
Quoted 9 lines
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
Quoted 9 lines
The dependencies is what made this solution uninteresting to us. For instance, we currently use cgroup scheduling to reduce the impact of some background tasks, but we occasionally saw a watchdog restart of the system process were critical services were waiting on a kernel mutex owned by a background task for more than 20 seconds. If we froze a cgroup instead, we would not hit this particular problem since tasks cannot be frozen while executing kernel code the same way they can be preempted, but nothing prevents a task from being frozen while holding a user-space resource.
Excellent point -- I had completely missed this failure mode!!!
Thanx, Paul
Quoted 14 lines · Arve Hjønnevåg
Quoted 1 line · Paul E. McKenney
On Sun, Aug 01, 2010 at 03:47:08PM -0700, Arjan van de Ven wrote:
...
Quoted 9 lines
Quoted 4 lines
Another one: freezing whole cgroups..... we have that today. it actually works quite well.... of course the hard part is the decision what to put in which cgroup, and at what frequency and duration you let cgroups run.
Indeed, the Android guys seemed to be quite excited by cgroup freezing until they thought about the application-classification problem. Seems like it should be easy for some types of applications, but I do admit that apps can have non-trivial and non-obvious dependencies.
Quoted 9 lines
The dependencies is what made this solution uninteresting to us. For instance, we currently use cgroup scheduling to reduce the impact of some background tasks, but we occasionally saw a watchdog restart of the system process were critical services were waiting on a kernel mutex owned by a background task for more than 20 seconds. If we froze a cgroup instead, we would not hit this particular problem since tasks cannot be frozen while executing kernel code the same way they can be preempted, but nothing prevents a task from being frozen while holding a user-space resource.
Excellent point -- I had completely missed this failure mode!!!
Thanx, Paul
Quoted 3 lines · Arve Hjønnevåg
On Sat, Jul 31, 2010 at 10:58 AM, Paul E. McKenney <[email protected]> wrote:
...
First, thank you very much for your review and feedback!
Quoted 47 lines
Quoted 41 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend battery life and (2) preserve state until AC power can be obtained.
o It is necessary to be able to use power-naive applications. Many of these applications were designed for use in PC platforms where power consumption has historically not been of great concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations. The system must be capable of running these power-naive applications without requiring that these applications be modified, and must be capable of reasonable power efficiency even when power-naive applications are available.
o If the display is powered off, there is no need to run any application whose only effect is to update the display.
Although one could simply block such an application when it next tries to access the display, it appears that it is highly desirable that the application also be prevented from consuming power computing anything that will not be displayed. Furthermore, whatever mechanism is used must operate on power-naive applications that do not use blocking system calls.
o In order to avoid overrunning hardware and/or kernel buffers, input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.
In particular, if user input that would prevent the system from entering a low-power state is received while the system is transitioning into a low-power state, the system must transition back out of the low-power state so that it can hand the user input off to the corresponding application.
o If a power-aware application receives user input, then that application must be given the opportunity to process that input.
Quoted 5 lines
o A power-aware application must be able to efficiently communicate its needs to the system, so that such communication can be performed on hot code paths. Communication via
open()andclose()is considered too slow, but communication viaioctl()is acceptable.
Quoted 8 lines
The problem with using open and close to prevent an allow suspend is not that it is too slow but that it interferes with collecting stats. The wakelock code has a sysfs interface that allow you to use a open/write/close sequence to block or unblock suspend. There is no limit to the amount of kernel memory that a process can consume with this interface, so the suspend blocker patchset uses a /dev interface with ioctls to block or unblock suspend and it destroys the kernel object when the file descriptor is closed.
Ah, I missed this point. What I am doing to adjust is to strike the above requirement, and to add verbiage to the "statistics" requirement about using ioctl() to implement suspend-blocker operations, so that the statistics can be tracked based on the device being open throughout the application's lifetime.
Quoted 4 lines
Quoted 4 lines
o Power-naive applications must be prohibited from controlling the system power state. One acceptable approach is through use of group permissions on a special power-control device.
Quoted 8 lines
Quoted 3 lines
o Statistics of the power-control actions taken by power-aware applications must be provided, and must be keyed off of program name.
We don't key the stats off the program name, but having useful statistics is critical too us. The current code in linux-next does not appear to allow this (I'm referring to
pm_stay_awakehere, etc not pm-qos.)
OK, maybe I was confused earlier. So you do not track statistics via the device being open throughout the application's lifetime?
I am not familiar with pm_stay_awake(), but will take a look at it.
Quoted 13 lines
Quoted 6 lines
o Power-aware applications can make use of power-naive infrastructure. This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.
Quoted 6 lines
o When a power-aware application is preventing the system from shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
Quoted 3 lines
wake-lock/suspend-blocker timeouts have nothing to do with the timeout used by applications when waiting for a response from a less trusted application.
OK, I moved this to a new "SUGGESTED USAGE" section and removed the last (parenthesized) sentence.
Quoted 8 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)
I would say it should suspend even if power aware applications are runnable. Most applications do not exclusively perform critical work.
The point being that a power-aware application does not block suspend -unless- it holds a suspend blocker, correct?
Or am I missing some other subtlety?
Quoted 6 lines
Quoted 3 lines
o Transition to low-power state must be efficient. In particular, methods based on repeated attempts to suspend are considered to be too inefficient to be useful.
It must be power-efficient. Repeated attempts to suspend will kill the idle battery life.
Good point! I changed "Transition to low-power state must be efficient" to instead read "Transition to low-power state must be power-efficient."
Quoted 10 lines
Quoted 10 lines
o Individual peripherals and CPUs must still use standard power-conservation measures, for example, transitioning CPUs into low-power states on idle and powering down peripheral devices and hardware accelerators that have not been recently used.
o The API that controls the system power state must be accessible both from Android's Java replacement, from userland C code, and from kernel C code (both process level and irq code, but not NMI handlers).
Quoted 8 lines
Quoted 4 lines
o Any initialization of the API that controls the system power state must be unconditional, so as to be free from failure. (I don't currently understand how this relates, probably due to my current insufficient understanding of the proposed patch set.)
Unconditional initialization makes it easier to add suspend blockers to existing kernel code since you don't have to add new failure exit paths. It is not a strong requirement.
Ah, that makes more sense! I moved this to a new "NICE-TO-HAVES" section. I also changed the last parenthesized sentence to read "Such unconditional initialization reduces the intrusiveness of the the Android patchset." Does that work?
Quoted 9 lines
Quoted 9 lines
o The API that controls the system power state must operate correctly on SMP systems of modest size. (My guess is that "modest" means up to four CPUs, maybe up to eight CPUs.)
o Any QoS-based solution must take display and user-input state into account. In other words, the QoS must be expressed as a function of the display and the user-input states.
Quoted 8 lines
Quoted 8 lines
o Transitioning to extremely low power states requires saving and restoring DRAM and/or cache SRAM state, which in itself consumes significant energy. The power savings must therefore be balanced against the energy consumed in the state transitions.
o The current Android userspace API must be supported in order to support existing device software.
Thank you again for looking this over and for your comments!!!
Thanx, Paul
Quoted 3 lines · Arve Hjønnevåg
On Sat, Jul 31, 2010 at 10:58 AM, Paul E. McKenney <[email protected]> wrote:
...
First, thank you very much for your review and feedback!
Quoted 47 lines
Quoted 41 lines
REQUIREMENTS
o Reduce the system's power consumption in order to (1) extend battery life and (2) preserve state until AC power can be obtained.
o It is necessary to be able to use power-naive applications. Many of these applications were designed for use in PC platforms where power consumption has historically not been of great concern, due to either (1) the availability of AC power or (2) relatively undemanding laptop battery-lifetime expectations. The system must be capable of running these power-naive applications without requiring that these applications be modified, and must be capable of reasonable power efficiency even when power-naive applications are available.
o If the display is powered off, there is no need to run any application whose only effect is to update the display.
Although one could simply block such an application when it next tries to access the display, it appears that it is highly desirable that the application also be prevented from consuming power computing anything that will not be displayed. Furthermore, whatever mechanism is used must operate on power-naive applications that do not use blocking system calls.
o In order to avoid overrunning hardware and/or kernel buffers, input events must be delivered to the corresponding application in a timely fashion. The application might or might not be required to actually process the events in a timely fashion, depending on the specific application.
In particular, if user input that would prevent the system from entering a low-power state is received while the system is transitioning into a low-power state, the system must transition back out of the low-power state so that it can hand the user input off to the corresponding application.
o If a power-aware application receives user input, then that application must be given the opportunity to process that input.
Quoted 5 lines
o A power-aware application must be able to efficiently communicate its needs to the system, so that such communication can be performed on hot code paths. Communication via
open()andclose()is considered too slow, but communication viaioctl()is acceptable.
Quoted 8 lines
The problem with using open and close to prevent an allow suspend is not that it is too slow but that it interferes with collecting stats. The wakelock code has a sysfs interface that allow you to use a open/write/close sequence to block or unblock suspend. There is no limit to the amount of kernel memory that a process can consume with this interface, so the suspend blocker patchset uses a /dev interface with ioctls to block or unblock suspend and it destroys the kernel object when the file descriptor is closed.
Ah, I missed this point. What I am doing to adjust is to strike the above requirement, and to add verbiage to the "statistics" requirement about using ioctl() to implement suspend-blocker operations, so that the statistics can be tracked based on the device being open throughout the application's lifetime.
Quoted 4 lines
Quoted 4 lines
o Power-naive applications must be prohibited from controlling the system power state. One acceptable approach is through use of group permissions on a special power-control device.
Quoted 8 lines
Quoted 3 lines
o Statistics of the power-control actions taken by power-aware applications must be provided, and must be keyed off of program name.
We don't key the stats off the program name, but having useful statistics is critical too us. The current code in linux-next does not appear to allow this (I'm referring to
pm_stay_awakehere, etc not pm-qos.)
OK, maybe I was confused earlier. So you do not track statistics via the device being open throughout the application's lifetime?
I am not familiar with pm_stay_awake(), but will take a look at it.
Quoted 13 lines
Quoted 6 lines
o Power-aware applications can make use of power-naive infrastructure. This means that a power-aware application must have some way, whether explicit or implicit, to ensure that any power-naive infrastructure is permitted to run when a power-aware application needs it to run.
Quoted 6 lines
o When a power-aware application is preventing the system from shutting down, and is also waiting on a power-naive application, the power-aware application must set a timeout to handle the possibility that the power-naive application might halt or otherwise fail. (Such timeouts are also used to limit the number of kernel modifications required.)
Quoted 3 lines
wake-lock/suspend-blocker timeouts have nothing to do with the timeout used by applications when waiting for a response from a less trusted application.
OK, I moved this to a new "SUGGESTED USAGE" section and removed the last (parenthesized) sentence.
Quoted 8 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)
I would say it should suspend even if power aware applications are runnable. Most applications do not exclusively perform critical work.
The point being that a power-aware application does not block suspend -unless- it holds a suspend blocker, correct?
Or am I missing some other subtlety?
Quoted 6 lines
Quoted 3 lines
o Transition to low-power state must be efficient. In particular, methods based on repeated attempts to suspend are considered to be too inefficient to be useful.
It must be power-efficient. Repeated attempts to suspend will kill the idle battery life.
Good point! I changed "Transition to low-power state must be efficient" to instead read "Transition to low-power state must be power-efficient."
Quoted 10 lines
Quoted 10 lines
o Individual peripherals and CPUs must still use standard power-conservation measures, for example, transitioning CPUs into low-power states on idle and powering down peripheral devices and hardware accelerators that have not been recently used.
o The API that controls the system power state must be accessible both from Android's Java replacement, from userland C code, and from kernel C code (both process level and irq code, but not NMI handlers).
Quoted 8 lines
Quoted 4 lines
o Any initialization of the API that controls the system power state must be unconditional, so as to be free from failure. (I don't currently understand how this relates, probably due to my current insufficient understanding of the proposed patch set.)
Unconditional initialization makes it easier to add suspend blockers to existing kernel code since you don't have to add new failure exit paths. It is not a strong requirement.
Ah, that makes more sense! I moved this to a new "NICE-TO-HAVES" section. I also changed the last parenthesized sentence to read "Such unconditional initialization reduces the intrusiveness of the the Android patchset." Does that work?
Quoted 9 lines
Quoted 9 lines
o The API that controls the system power state must operate correctly on SMP systems of modest size. (My guess is that "modest" means up to four CPUs, maybe up to eight CPUs.)
o Any QoS-based solution must take display and user-input state into account. In other words, the QoS must be expressed as a function of the display and the user-input states.
Quoted 8 lines
Quoted 8 lines
o Transitioning to extremely low power states requires saving and restoring DRAM and/or cache SRAM state, which in itself consumes significant energy. The power savings must therefore be balanced against the energy consumed in the state transitions.
o The current Android userspace API must be supported in order to support existing device software.
Thank you again for looking this over and for your comments!!!
Thanx, Paul
Quoted 9 lines · Arve Hjønnevåg
Quoted 6 lines
o A power-aware application must be able to efficiently communicate
its needs to the system, so that such communication can be performed on hot code paths. Communication viaopen()andclose()is considered too slow, but communication viaioctl()is acceptable.The problem with using open and close to prevent an allow suspend is not that it is too slow but that it interferes with collecting stats.
Please elaborate on this. I expect the pm-qos stats interface will collect stats across user open/close because that's how it currently works. What's the problem?
Quoted 6 lines
The wakelock code has a sysfs interface that allow you to use a open/write/close sequence to block or unblock suspend. There is no limit to the amount of kernel memory that a process can consume with this interface, so the suspend blocker patchset uses a /dev interface with ioctls to block or unblock suspend and it destroys the kernel object when the file descriptor is closed.
This is an implementation detail only. The pm-qos objects are long lived, so their stats would be too. I would guess that explicit stat clearing might be a useful option.
James
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Quoted 9 lines · Arve Hjønnevåg
Quoted 6 lines
o A power-aware application must be able to efficiently communicate
its needs to the system, so that such communication can be performed on hot code paths. Communication viaopen()andclose()is considered too slow, but communication viaioctl()is acceptable.The problem with using open and close to prevent an allow suspend is not that it is too slow but that it interferes with collecting stats.
Please elaborate on this. I expect the pm-qos stats interface will collect stats across user open/close because that's how it currently works. What's the problem?
Quoted 6 lines
The wakelock code has a sysfs interface that allow you to use a open/write/close sequence to block or unblock suspend. There is no limit to the amount of kernel memory that a process can consume with this interface, so the suspend blocker patchset uses a /dev interface with ioctls to block or unblock suspend and it destroys the kernel object when the file descriptor is closed.
This is an implementation detail only. The pm-qos objects are long lived, so their stats would be too. I would guess that explicit stat clearing might be a useful option.
James
2010/8/3 James Bottomley <[email protected]>:
Quoted 8 lines · Arve Hjønnevåg
Quoted 7 lines
Quoted 6 lines
o A power-aware application must be able to efficiently communicate its needs to the system, so that such communication can be performed on hot code paths. Communication via
open()andclose()is considered too slow, but communication viaioctl()is acceptable.
Quoted 7 lines
Quoted 2 lines
The problem with using open and close to prevent an allow suspend is not that it is too slow but that it interferes with collecting stats.
Please elaborate on this. I expect the pm-qos stats interface will collect stats across user open/close because that's how it currently works. What's the problem?
The pm-qos interface creates the request object in open and destroys it in release just like the suspend blocker interface. We need stats for each client which is lost if you free the object every time you unblock suspend.
Or are you talking about user space opening and closing the stats interface (which does not cause any problems)?
Quoted 8 lines
Quoted 6 lines
The wakelock code has a sysfs interface that allow you to use a open/write/close sequence to block or unblock suspend. There is no limit to the amount of kernel memory that a process can consume with this interface, so the suspend blocker patchset uses a /dev interface with ioctls to block or unblock suspend and it destroys the kernel object when the file descriptor is closed.
This is an implementation detail only.
There is no way fix it without changing the user space visible behavior of the API. The kernel does not know when it is safe to free the objects.
Quoted 4 lines
The pm-qos objects are long
lived, so their stats would be too. I would guess that explicit stat clearing might be a useful option.
Which pm-qos objects are you referring to? The struct pm_qos_object that backs each pm-qos class is long lived (I don't know why this is named pm_qos_object), but we need stats in struct pm_qos_request_list.
Signature · 1 line
Arve Hjønnevåg
2010/8/3 James Bottomley <[email protected]>:
Quoted 8 lines · Arve Hjønnevåg
Quoted 7 lines
Quoted 6 lines
o A power-aware application must be able to efficiently communicate its needs to the system, so that such communication can be performed on hot code paths. Communication via
open()andclose()is considered too slow, but communication viaioctl()is acceptable.
Quoted 7 lines
Quoted 2 lines
The problem with using open and close to prevent an allow suspend is not that it is too slow but that it interferes with collecting stats.
Please elaborate on this. I expect the pm-qos stats interface will collect stats across user open/close because that's how it currently works. What's the problem?
The pm-qos interface creates the request object in open and destroys it in release just like the suspend blocker interface. We need stats for each client which is lost if you free the object every time you unblock suspend.
Or are you talking about user space opening and closing the stats interface (which does not cause any problems)?
Quoted 8 lines
Quoted 6 lines
The wakelock code has a sysfs interface that allow you to use a open/write/close sequence to block or unblock suspend. There is no limit to the amount of kernel memory that a process can consume with this interface, so the suspend blocker patchset uses a /dev interface with ioctls to block or unblock suspend and it destroys the kernel object when the file descriptor is closed.
This is an implementation detail only.
There is no way fix it without changing the user space visible behavior of the API. The kernel does not know when it is safe to free the objects.
Quoted 4 lines
The pm-qos objects are long
lived, so their stats would be too. I would guess that explicit stat clearing might be a useful option.
Which pm-qos objects are you referring to? The struct pm_qos_object that backs each pm-qos class is long lived (I don't know why this is named pm_qos_object), but we need stats in struct pm_qos_request_list.
Signature · 1 line
Arve Hjønnevåg
2010/8/3 Paul E. McKenney <[email protected]>:
Quoted 3 lines · Arve Hjønnevåg
Quoted 2 lines
On Sat, Jul 31, 2010 at 10:58 AM, Paul E. McKenney <[email protected]> wrote:
...
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
o Statistics of the power-control actions taken by power-aware applications must be provided, and must be keyed off of program name.
Quoted 8 lines
Quoted 4 lines
We don't key the stats off the program name, but having useful statistics is critical too us. The current code in linux-next does not appear to allow this (I'm referring to
pm_stay_awakehere, etc not pm-qos.)OK, maybe I was confused earlier. So you do not track statistics via the device being open throughout the application's lifetime?
The suspend blocker patchset does track statistics while the device is open, but it it not keyed of the program name. The name is passed from user-space and a single process can have the device open several times. The wakelock interface that we currently use just creates a new object every time it sees a new name and never frees it.
...
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)
I would say it should suspend even if power aware applications are runnable. Most applications do not exclusively perform critical work.
The point being that a power-aware application does not block suspend -unless- it holds a suspend blocker, correct?
Yes.
Quoted 2 lines
Or am I missing some other subtlety?
No.
...
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
o Any initialization of the API that controls the system power state must be unconditional, so as to be free from failure. (I don't currently understand how this relates, probably due to my current insufficient understanding of the proposed patch set.)
Quoted 9 lines
Quoted 3 lines
Unconditional initialization makes it easier to add suspend blockers to existing kernel code since you don't have to add new failure exit paths. It is not a strong requirement.
Ah, that makes more sense! I moved this to a new "NICE-TO-HAVES" section. I also changed the last parenthesized sentence to read "Such unconditional initialization reduces the intrusiveness of the the Android patchset." Does that work?
Sure.
Signature · 1 line
Arve Hjønnevåg
2010/8/3 Paul E. McKenney <[email protected]>:
Quoted 3 lines · Arve Hjønnevåg
Quoted 2 lines
On Sat, Jul 31, 2010 at 10:58 AM, Paul E. McKenney <[email protected]> wrote:
...
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
o Statistics of the power-control actions taken by power-aware applications must be provided, and must be keyed off of program name.
Quoted 8 lines
Quoted 4 lines
We don't key the stats off the program name, but having useful statistics is critical too us. The current code in linux-next does not appear to allow this (I'm referring to
pm_stay_awakehere, etc not pm-qos.)OK, maybe I was confused earlier. So you do not track statistics via the device being open throughout the application's lifetime?
The suspend blocker patchset does track statistics while the device is open, but it it not keyed of the program name. The name is passed from user-space and a single process can have the device open several times. The wakelock interface that we currently use just creates a new object every time it sees a new name and never frees it.
...
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)
I would say it should suspend even if power aware applications are runnable. Most applications do not exclusively perform critical work.
The point being that a power-aware application does not block suspend -unless- it holds a suspend blocker, correct?
Yes.
Quoted 2 lines
Or am I missing some other subtlety?
No.
...
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
o Any initialization of the API that controls the system power state must be unconditional, so as to be free from failure. (I don't currently understand how this relates, probably due to my current insufficient understanding of the proposed patch set.)
Quoted 9 lines
Quoted 3 lines
Unconditional initialization makes it easier to add suspend blockers to existing kernel code since you don't have to add new failure exit paths. It is not a strong requirement.
Ah, that makes more sense! I moved this to a new "NICE-TO-HAVES" section. I also changed the last parenthesized sentence to read "Such unconditional initialization reduces the intrusiveness of the the Android patchset." Does that work?
Sure.
Signature · 1 line
Arve Hjønnevåg
2010/8/2 <[email protected]>:
Quoted 49 lines · Arve Hj?nnev?g
Quoted 43 lines
2010/8/2 <[email protected]>:
Quoted 35 lines · Arve Hj?nnev?g
Quoted 26 lines · On Mon, Aug 2, 2010 at 5:08 PM, <[email protected]> wrote:
Quoted 15 lines · Paul E. McKenney
you are close, but I think what I'm proposing is actually simpler (assuming
that the scheduler can be configured to generate the appropriate stats)my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be
in
cgroup A while all other applications are in cgroup BQuoted 8 lines
when you are deciding if the system shoudl go to sleep because it is idle,
ignore the activity of all applications in cgroup Bif cgroup A applications are busy, the system is not idle and should not
suspend.Quoted 6 lines
Triggering suspend from idle has been suggested before. However, idle is not a signal that it is safe to suspend since timers stop in suspend (or the code could temporarily be waiting on a non-wakeup interrupt). If you add suspend blockers or wakelocks to prevent suspend while events you care about are pending, then it does not make a lot of sense to prevent suspend just because the cpu is not idle.
Quoted 5 lines
isn't this a matter of making the suspend decision look at what timers have
been set to expire in the near future and/or tweaking how long the system needs to be idle before going to sleep?Quoted 4 lines
You are describing low power idle modes, not suspend. Most timers stop in suspend, so a timer set 10 seconds from now when entering suspend will go off 10 seconds after resume so it should have no impact on how long you decide to stay in suspend.
Quoted 5 lines
so what is the fundamental difference between deciding to go into low-power idle modes to wake up back up on a given point in the future and deciding that you are going to be idle for so long that you may as well suspend until there is user input?
Low power idle modes are supposed to be transparent. Suspend stops the monotonic clock, ignores ready threads and switches over to a separate set of wakeup events/interrupts. We don't suspend until there is user input, we suspend until there is a wakeup event (user-input, incoming network data/phone-calls, alarms etc..).
Signature · 1 line
Arve Hjønnevåg
2010/8/2 <[email protected]>:
Quoted 49 lines · Arve Hj?nnev?g
Quoted 43 lines
2010/8/2 <[email protected]>:
Quoted 35 lines · Arve Hj?nnev?g
Quoted 26 lines · On Mon, Aug 2, 2010 at 5:08 PM, <[email protected]> wrote:
Quoted 15 lines · Paul E. McKenney
you are close, but I think what I'm proposing is actually simpler (assuming
that the scheduler can be configured to generate the appropriate stats)my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be
in
cgroup A while all other applications are in cgroup BQuoted 8 lines
when you are deciding if the system shoudl go to sleep because it is idle,
ignore the activity of all applications in cgroup Bif cgroup A applications are busy, the system is not idle and should not
suspend.Quoted 6 lines
Triggering suspend from idle has been suggested before. However, idle is not a signal that it is safe to suspend since timers stop in suspend (or the code could temporarily be waiting on a non-wakeup interrupt). If you add suspend blockers or wakelocks to prevent suspend while events you care about are pending, then it does not make a lot of sense to prevent suspend just because the cpu is not idle.
Quoted 5 lines
isn't this a matter of making the suspend decision look at what timers have
been set to expire in the near future and/or tweaking how long the system needs to be idle before going to sleep?Quoted 4 lines
You are describing low power idle modes, not suspend. Most timers stop in suspend, so a timer set 10 seconds from now when entering suspend will go off 10 seconds after resume so it should have no impact on how long you decide to stay in suspend.
Quoted 5 lines
so what is the fundamental difference between deciding to go into low-power idle modes to wake up back up on a given point in the future and deciding that you are going to be idle for so long that you may as well suspend until there is user input?
Low power idle modes are supposed to be transparent. Suspend stops the monotonic clock, ignores ready threads and switches over to a separate set of wakeup events/interrupts. We don't suspend until there is user input, we suspend until there is a wakeup event (user-input, incoming network data/phone-calls, alarms etc..).
Signature · 1 line
Arve Hjønnevåg
Quoted 6 lines · Raj Kumar
Hi Arve and Alan,
I have some questions regarding the Android early suspend and ACPI that are as follows:
Quoted 9 lines
1) If i see the early suspend features which is for android, it is if the user presses power off
the button and on button for late resumes. The question is if there is mobile platform,
then when user presses power off button, will the early suspend handlers will be called
at that time?
what usecase android early suspend handles?
Early suspend is called on android when user-space turns the screen off. It provides a central switch for user-space to turn off devices that are not needed when the screen is off. The goal is to use runtime-pm for this instead so the drivers don't have to be android specific.
Quoted 8 lines
2) Regarding ACPI which is more bios centric, will the drivers need to implement suspend/resume
as for normal OS use case scenarios?Regards
Raj
Signature · 1 line
Arve Hjønnevåg
Quoted 56 lines · Arve Hj?nnev?g
2010/8/2 <[email protected]>:
Quoted 49 lines · Arve Hj?nnev?g
Quoted 43 lines
2010/8/2 <[email protected]>:
Quoted 35 lines · Arve Hj?nnev?g
Quoted 26 lines · On Mon, Aug 2, 2010 at 5:08 PM, <[email protected]> wrote:
Quoted 15 lines · Paul E. McKenney
you are close, but I think what I'm proposing is actually simpler (assuming
that the scheduler can be configured to generate the appropriate stats)my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be
in
cgroup A while all other applications are in cgroup BQuoted 8 lines
when you are deciding if the system shoudl go to sleep because it is idle,
ignore the activity of all applications in cgroup Bif cgroup A applications are busy, the system is not idle and should not
suspend.Quoted 6 lines
Triggering suspend from idle has been suggested before. However, idle is not a signal that it is safe to suspend since timers stop in suspend (or the code could temporarily be waiting on a non-wakeup interrupt). If you add suspend blockers or wakelocks to prevent suspend while events you care about are pending, then it does not make a lot of sense to prevent suspend just because the cpu is not idle.
Quoted 5 lines
isn't this a matter of making the suspend decision look at what timers have
been set to expire in the near future and/or tweaking how long the system needs to be idle before going to sleep?Quoted 4 lines
You are describing low power idle modes, not suspend. Most timers stop in suspend, so a timer set 10 seconds from now when entering suspend will go off 10 seconds after resume so it should have no impact on how long you decide to stay in suspend.
Quoted 5 lines
so what is the fundamental difference between deciding to go into low-power idle modes to wake up back up on a given point in the future and deciding that you are going to be idle for so long that you may as well suspend until there is user input?
Quoted 5 lines
Low power idle modes are supposed to be transparent. Suspend stops the monotonic clock, ignores ready threads and switches over to a separate set of wakeup events/interrupts. We don't suspend until there is user input, we suspend until there is a wakeup event (user-input, incoming network data/phone-calls, alarms etc..).
s/user input/wakeup event/ and my question still stands.
low power modes are not transparent to the user in all cases (if the screen backlight dimms/shuts off a user reading something will notice, if the system switches to a lower clock speed it can impact user response time, etc) The system is making it's best guess as to how to best srve the user by sacraficing some capibilities to save power now so that the power can be available later.
as I see it, suspending until a wakeup event (button press, incoming call, alarm, etc) is just another datapoint along the same path.
If the system could not wake itself up to respond to user input, phone call, alarm, etc and needed the power button pressed to wake up (or shut down to the point where the battery could be removed and reinstalled a long time later), I would see things moving into a different category, but as long as the system has the ability to wake itself up later (and is still consuming power) I see the suspend as being in the same category as the other low-power modes (it's just more expensive to go in and out of)
why should the suspend be put into a different category from the other low-power states?
David Lang
Quoted 56 lines · Arve Hj?nnev?g
2010/8/2 <[email protected]>:
Quoted 49 lines · Arve Hj?nnev?g
Quoted 43 lines
2010/8/2 <[email protected]>:
Quoted 35 lines · Arve Hj?nnev?g
Quoted 26 lines · On Mon, Aug 2, 2010 at 5:08 PM, <[email protected]> wrote:
Quoted 15 lines · Paul E. McKenney
you are close, but I think what I'm proposing is actually simpler (assuming
that the scheduler can be configured to generate the appropriate stats)my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be
in
cgroup A while all other applications are in cgroup BQuoted 8 lines
when you are deciding if the system shoudl go to sleep because it is idle,
ignore the activity of all applications in cgroup Bif cgroup A applications are busy, the system is not idle and should not
suspend.Quoted 6 lines
Triggering suspend from idle has been suggested before. However, idle is not a signal that it is safe to suspend since timers stop in suspend (or the code could temporarily be waiting on a non-wakeup interrupt). If you add suspend blockers or wakelocks to prevent suspend while events you care about are pending, then it does not make a lot of sense to prevent suspend just because the cpu is not idle.
Quoted 5 lines
isn't this a matter of making the suspend decision look at what timers have
been set to expire in the near future and/or tweaking how long the system needs to be idle before going to sleep?Quoted 4 lines
You are describing low power idle modes, not suspend. Most timers stop in suspend, so a timer set 10 seconds from now when entering suspend will go off 10 seconds after resume so it should have no impact on how long you decide to stay in suspend.
Quoted 5 lines
so what is the fundamental difference between deciding to go into low-power idle modes to wake up back up on a given point in the future and deciding that you are going to be idle for so long that you may as well suspend until there is user input?
Quoted 5 lines
Low power idle modes are supposed to be transparent. Suspend stops the monotonic clock, ignores ready threads and switches over to a separate set of wakeup events/interrupts. We don't suspend until there is user input, we suspend until there is a wakeup event (user-input, incoming network data/phone-calls, alarms etc..).
s/user input/wakeup event/ and my question still stands.
low power modes are not transparent to the user in all cases (if the screen backlight dimms/shuts off a user reading something will notice, if the system switches to a lower clock speed it can impact user response time, etc) The system is making it's best guess as to how to best srve the user by sacraficing some capibilities to save power now so that the power can be available later.
as I see it, suspending until a wakeup event (button press, incoming call, alarm, etc) is just another datapoint along the same path.
If the system could not wake itself up to respond to user input, phone call, alarm, etc and needed the power button pressed to wake up (or shut down to the point where the battery could be removed and reinstalled a long time later), I would see things moving into a different category, but as long as the system has the ability to wake itself up later (and is still consuming power) I see the suspend as being in the same category as the other low-power modes (it's just more expensive to go in and out of)
why should the suspend be put into a different category from the other low-power states?
David Lang
Quoted 86 lines · On Tue, Aug 03, 2010 at 04:19:25PM -0700, [email protected] wrote:
Quoted 56 lines · Arve Hj?nnev?g
2010/8/2 <[email protected]>:
Quoted 49 lines · Arve Hj?nnev?g
Quoted 43 lines
2010/8/2 <[email protected]>:
Quoted 35 lines · Arve Hj?nnev?g
Quoted 26 lines · On Mon, Aug 2, 2010 at 5:08 PM, <[email protected]> wrote:
Quoted 15 lines · Paul E. McKenney
you are close, but I think what I'm proposing is actually simpler (assuming
that the scheduler can be configured to generate the appropriate stats)my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be
in
cgroup A while all other applications are in cgroup BQuoted 8 lines
when you are deciding if the system shoudl go to sleep because it is idle,
ignore the activity of all applications in cgroup Bif cgroup A applications are busy, the system is not idle and should not
suspend.Quoted 6 lines
Triggering suspend from idle has been suggested before. However, idle is not a signal that it is safe to suspend since timers stop in suspend (or the code could temporarily be waiting on a non-wakeup interrupt). If you add suspend blockers or wakelocks to prevent suspend while events you care about are pending, then it does not make a lot of sense to prevent suspend just because the cpu is not idle.
Quoted 5 lines
isn't this a matter of making the suspend decision look at what timers have
been set to expire in the near future and/or tweaking how long the system needs to be idle before going to sleep?Quoted 4 lines
You are describing low power idle modes, not suspend. Most timers stop in suspend, so a timer set 10 seconds from now when entering suspend will go off 10 seconds after resume so it should have no impact on how long you decide to stay in suspend.
Quoted 5 lines
so what is the fundamental difference between deciding to go into low-power idle modes to wake up back up on a given point in the future and deciding that you are going to be idle for so long that you may as well suspend until there is user input?
Quoted 5 lines
Low power idle modes are supposed to be transparent. Suspend stops the monotonic clock, ignores ready threads and switches over to a separate set of wakeup events/interrupts. We don't suspend until there is user input, we suspend until there is a wakeup event (user-input, incoming network data/phone-calls, alarms etc..).
s/user input/wakeup event/ and my question still stands.
low power modes are not transparent to the user in all cases (if the screen backlight dimms/shuts off a user reading something will notice, if the system switches to a lower clock speed it can impact user response time, etc) The system is making it's best guess as to how to best srve the user by sacraficing some capibilities to save power now so that the power can be available later.
as I see it, suspending until a wakeup event (button press, incoming call, alarm, etc) is just another datapoint along the same path.
If the system could not wake itself up to respond to user input, phone call, alarm, etc and needed the power button pressed to wake up (or shut down to the point where the battery could be removed and reinstalled a long time later), I would see things moving into a different category, but as long as the system has the ability to wake itself up later (and is still consuming power) I see the suspend as being in the same category as the other low-power modes (it's just more expensive to go in and out of)
Quoted 2 lines
why should the suspend be put into a different category from the other low-power states?
OK, I'll bite...
Quoted 1 line
From an Android perspective, the differences are as follows:
1. Deep idle states are entered only if there are no runnable tasks.
In contrast, opportunistic suspend can happen even when there are tasks that are ready, willing, and able to run.
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 a deep idle state. For example, I believe that it was stated that one of the Android-based smartphones ignores touchscreen input while suspended, but pays attention to it while in deep idle states.
3. The system comes out of a deep idle state when a timer
expires. In contrast, timers cannot expire while the system is suspended. (This one is debatable: some people argue that timers are subject to jitter, and the suspend case for timers is the same as that for deep idle states, but with unbounded timer jitter. Others disagree. The resulting discussions have produced much heat, but little light. Such is life.)
There may well be others.
Whether these distinctions are a good thing or a bad thing is one of the topics of this discussion. But the distinctions themselves are certainly very real, from what I can see.
Or am I missing your point?
Thanx, Paul
Quoted 86 lines · On Tue, Aug 03, 2010 at 04:19:25PM -0700, [email protected] wrote:
Quoted 56 lines · Arve Hj?nnev?g
2010/8/2 <[email protected]>:
Quoted 49 lines · Arve Hj?nnev?g
Quoted 43 lines
2010/8/2 <[email protected]>:
Quoted 35 lines · Arve Hj?nnev?g
Quoted 26 lines · On Mon, Aug 2, 2010 at 5:08 PM, <[email protected]> wrote:
Quoted 15 lines · Paul E. McKenney
you are close, but I think what I'm proposing is actually simpler (assuming
that the scheduler can be configured to generate the appropriate stats)my thought was not to move applications between cgroups as they aquire/release the suspend-block lock, bur rather to say that any application that you would trust to get the suspend-block lock should be
in
cgroup A while all other applications are in cgroup BQuoted 8 lines
when you are deciding if the system shoudl go to sleep because it is idle,
ignore the activity of all applications in cgroup Bif cgroup A applications are busy, the system is not idle and should not
suspend.Quoted 6 lines
Triggering suspend from idle has been suggested before. However, idle is not a signal that it is safe to suspend since timers stop in suspend (or the code could temporarily be waiting on a non-wakeup interrupt). If you add suspend blockers or wakelocks to prevent suspend while events you care about are pending, then it does not make a lot of sense to prevent suspend just because the cpu is not idle.
Quoted 5 lines
isn't this a matter of making the suspend decision look at what timers have
been set to expire in the near future and/or tweaking how long the system needs to be idle before going to sleep?Quoted 4 lines
You are describing low power idle modes, not suspend. Most timers stop in suspend, so a timer set 10 seconds from now when entering suspend will go off 10 seconds after resume so it should have no impact on how long you decide to stay in suspend.
Quoted 5 lines
so what is the fundamental difference between deciding to go into low-power idle modes to wake up back up on a given point in the future and deciding that you are going to be idle for so long that you may as well suspend until there is user input?
Quoted 5 lines
Low power idle modes are supposed to be transparent. Suspend stops the monotonic clock, ignores ready threads and switches over to a separate set of wakeup events/interrupts. We don't suspend until there is user input, we suspend until there is a wakeup event (user-input, incoming network data/phone-calls, alarms etc..).
s/user input/wakeup event/ and my question still stands.
low power modes are not transparent to the user in all cases (if the screen backlight dimms/shuts off a user reading something will notice, if the system switches to a lower clock speed it can impact user response time, etc) The system is making it's best guess as to how to best srve the user by sacraficing some capibilities to save power now so that the power can be available later.
as I see it, suspending until a wakeup event (button press, incoming call, alarm, etc) is just another datapoint along the same path.
If the system could not wake itself up to respond to user input, phone call, alarm, etc and needed the power button pressed to wake up (or shut down to the point where the battery could be removed and reinstalled a long time later), I would see things moving into a different category, but as long as the system has the ability to wake itself up later (and is still consuming power) I see the suspend as being in the same category as the other low-power modes (it's just more expensive to go in and out of)
Quoted 2 lines
why should the suspend be put into a different category from the other low-power states?
OK, I'll bite...
Quoted 1 line
From an Android perspective, the differences are as follows:
1. Deep idle states are entered only if there are no runnable tasks.
In contrast, opportunistic suspend can happen even when there are tasks that are ready, willing, and able to run.
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 a deep idle state. For example, I believe that it was stated that one of the Android-based smartphones ignores touchscreen input while suspended, but pays attention to it while in deep idle states.
3. The system comes out of a deep idle state when a timer
expires. In contrast, timers cannot expire while the system is suspended. (This one is debatable: some people argue that timers are subject to jitter, and the suspend case for timers is the same as that for deep idle states, but with unbounded timer jitter. Others disagree. The resulting discussions have produced much heat, but little light. Such is life.)
There may well be others.
Whether these distinctions are a good thing or a bad thing is one of the topics of this discussion. But the distinctions themselves are certainly very real, from what I can see.
Or am I missing your point?
Thanx, Paul
Quoted 39 lines · Paul E. McKenney
Quoted 38 lines · On Tue, Aug 03, 2010 at 04:19:25PM -0700, [email protected] wrote:
Quoted 8 lines · Arve Hj?nnev?g
2010/8/2 <[email protected]>:
Quoted 6 lines
so what is the fundamental difference between deciding to go into low-power idle modes to wake up back up on a given point in the future and deciding that you are going to be idle for so long that you may as well suspend until there is user input?
Quoted 5 lines
Low power idle modes are supposed to be transparent. Suspend stops the monotonic clock, ignores ready threads and switches over to a separate set of wakeup events/interrupts. We don't suspend until there is user input, we suspend until there is a wakeup event (user-input, incoming network data/phone-calls, alarms etc..).
s/user input/wakeup event/ and my question still stands.
low power modes are not transparent to the user in all cases (if the screen backlight dimms/shuts off a user reading something will notice, if the system switches to a lower clock speed it can impact user response time, etc) The system is making it's best guess as to how to best srve the user by sacraficing some capibilities to save power now so that the power can be available later.
as I see it, suspending until a wakeup event (button press, incoming call, alarm, etc) is just another datapoint along the same path.
If the system could not wake itself up to respond to user input, phone call, alarm, etc and needed the power button pressed to wake up (or shut down to the point where the battery could be removed and reinstalled a long time later), I would see things moving into a different category, but as long as the system has the ability to wake itself up later (and is still consuming power) I see the suspend as being in the same category as the other low-power modes (it's just more expensive to go in and out of)
Quoted 4 lines
Quoted 2 lines
why should the suspend be put into a different category from the other low-power states?
OK, I'll bite...
thanks, this is not intended to be a trap.
Quoted 5 lines
From an Android perspective, the differences are as follows:
1. Deep idle states are entered only if there are no runnable tasks.
In contrast, opportunistic suspend can happen even when there are tasks that are ready, willing, and able to run.
Ok, this is a complication to what I'm proposing (and seems a little odd, but I can see how it can work), but not neccessarily a major problem. it depends on exactly how the decision is made to go into low power states and/or suspend. If this is done by an application that is able to look at either all activity or ignore one cgroup of processes at different times in it's calculations than this would work.
Quoted 5 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 a deep idle state. For example, I believe that it was stated that one of the Android-based smartphones ignores touchscreen input while suspended, but pays attention to it while in deep idle states.
I see this as simply being a matter of what devices are still enabled at the different power savings levels. At one level the touchscreen is still powered, while at another level it isn't, and at yet another level you have to hit the power soft-button. This isn't fundamentally different from powering off a USB peripheral that the system decides is idle (and then not seeing input from it until something else wakes the system)
Quoted 8 lines
3. The system comes out of a deep idle state when a timer
expires. In contrast, timers cannot expire while the system is suspended. (This one is debatable: some people argue that timers are subject to jitter, and the suspend case for timers is the same as that for deep idle states, but with unbounded timer jitter. Others disagree. The resulting discussions have produced much heat, but little light. Such is life.)
if you have the ability to wake for an alarm, you have the ability to wake for a timer (if from no other method than to set the alarm to when the timer tick would go off)
Quoted 7 lines
There may well be others.
Whether these distinctions are a good thing or a bad thing is one of the topics of this discussion. But the distinctions themselves are certainly very real, from what I can see.
Or am I missing your point?
these big distinction that I see as significant seem to be in the decision of when to go into the different states, and the difference between the states themselves seem to be less significant (and either very close to, or within the variation that already exists for power saving modes)
If I'm right bout this, then it would seem to simplify the concept and change it from some really foreign android-only thing into a special case variation of existing core concepts.
you have many different power saving modes, the daemon (or kernel code) that is determining which mode to go into would need different logic (including, but not limited to the ability to be able to ignore one or more cgroups of processes). different power saving modes have different trade-offs, and some of them power down different peripherals (which is always a platform specific, if not system specific set of trade-offs)
This all depends on the ability for the code that decides to switch power modes (including to trigger suspend) to be able to see things in sufficient detail to be able to do different things depending on the class of programs. I don't know enough about this code to know if this is the case or not, I really wish that someone familiar with the power saving code could either confirm that this is possible, or state that it's not possible (or at least, not without major surgery)
David Lang
Quoted 14 lines · Arve Hjønnevåg
2010/8/3 Paul E. McKenney <[email protected]>:
Quoted 3 lines · Arve Hjønnevåg
Quoted 2 lines
On Sat, Jul 31, 2010 at 10:58 AM, Paul E. McKenney <[email protected]> wrote:
...
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
o Statistics of the power-control actions taken by power-aware applications must be provided, and must be keyed off of program name.
We don't key the stats off the program name, but having useful statistics is critical too us. The current code in linux-next does not appear to allow this (I'm referring to
pm_stay_awakehere, etc not pm-qos.)
Quoted 8 lines
Quoted 2 lines
OK, maybe I was confused earlier. So you do not track statistics via the device being open throughout the application's lifetime?
The suspend blocker patchset does track statistics while the device is open, but it it not keyed of the program name. The name is passed from user-space and a single process can have the device open several times. The wakelock interface that we currently use just creates a new object every time it sees a new name and never frees it.
Ah, good to know!
Thanx, Paul
Quoted 42 lines
...
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)
I would say it should suspend even if power aware applications are runnable. Most applications do not exclusively perform critical work.
The point being that a power-aware application does not block suspend -unless- it holds a suspend blocker, correct?
Yes.
Quoted 2 lines
Or am I missing some other subtlety?
No.
...
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
o Any initialization of the API that controls the system power state must be unconditional, so as to be free from failure. (I don't currently understand how this relates, probably due to my current insufficient understanding of the proposed patch set.)
Quoted 9 lines
Quoted 3 lines
Unconditional initialization makes it easier to add suspend blockers to existing kernel code since you don't have to add new failure exit paths. It is not a strong requirement.
Ah, that makes more sense! I moved this to a new "NICE-TO-HAVES" section. I also changed the last parenthesized sentence to read "Such unconditional initialization reduces the intrusiveness of the the Android patchset." Does that work?
Sure.
Signature · 1 line
Arve Hjønnevåg
Quoted 14 lines · Arve Hjønnevåg
2010/8/3 Paul E. McKenney <[email protected]>:
Quoted 3 lines · Arve Hjønnevåg
Quoted 2 lines
On Sat, Jul 31, 2010 at 10:58 AM, Paul E. McKenney <[email protected]> wrote:
...
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
o Statistics of the power-control actions taken by power-aware applications must be provided, and must be keyed off of program name.
We don't key the stats off the program name, but having useful statistics is critical too us. The current code in linux-next does not appear to allow this (I'm referring to
pm_stay_awakehere, etc not pm-qos.)
Quoted 8 lines
Quoted 2 lines
OK, maybe I was confused earlier. So you do not track statistics via the device being open throughout the application's lifetime?
The suspend blocker patchset does track statistics while the device is open, but it it not keyed of the program name. The name is passed from user-space and a single process can have the device open several times. The wakelock interface that we currently use just creates a new object every time it sees a new name and never frees it.
Ah, good to know!
Thanx, Paul
Quoted 42 lines
...
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
o If no power-aware or power-optimized application are indicating a need for the system to remain operating, the system is permitted (even encouraged!) to suspend all execution, even if power-naive applications are runnable. (This requirement did appear to be somewhat controversial.)
I would say it should suspend even if power aware applications are runnable. Most applications do not exclusively perform critical work.
The point being that a power-aware application does not block suspend -unless- it holds a suspend blocker, correct?
Yes.
Quoted 2 lines
Or am I missing some other subtlety?
No.
...
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
o Any initialization of the API that controls the system power state must be unconditional, so as to be free from failure. (I don't currently understand how this relates, probably due to my current insufficient understanding of the proposed patch set.)
Quoted 9 lines
Quoted 3 lines
Unconditional initialization makes it easier to add suspend blockers to existing kernel code since you don't have to add new failure exit paths. It is not a strong requirement.
Ah, that makes more sense! I moved this to a new "NICE-TO-HAVES" section. I also changed the last parenthesized sentence to read "Such unconditional initialization reduces the intrusiveness of the the Android patchset." Does that work?
Sure.
Signature · 1 line
Arve Hjønnevåg
Quoted 13 lines · On Mon, 2 Aug 2010 21:56:10 -0700 Arve Hjønnevåg <[email protected]> wrote:
Quoted 2 lines
non-obvious dependencies.
The dependencies is what made this solution uninteresting to us. For instance, we currently use cgroup scheduling to reduce the impact of some background tasks, but we occasionally saw a watchdog restart of the system process were critical services were waiting on a kernel mutex owned by a background task for more than 20 seconds. If we froze a cgroup instead, we would not hit this particular problem since tasks cannot be frozen while executing kernel code the same way they can be preempted, but nothing prevents a task from being frozen while holding a user-space resource.
one of the solutions we're looking at to solve this is to unfreeze the cgroup on a regular basis (say, every 15 to 30 seconds) briefly to avoid this kind of deadlock...
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
Quoted 13 lines · On Mon, 2 Aug 2010 21:56:10 -0700 Arve Hjønnevåg <[email protected]> wrote:
Quoted 2 lines
non-obvious dependencies.
The dependencies is what made this solution uninteresting to us. For instance, we currently use cgroup scheduling to reduce the impact of some background tasks, but we occasionally saw a watchdog restart of the system process were critical services were waiting on a kernel mutex owned by a background task for more than 20 seconds. If we froze a cgroup instead, we would not hit this particular problem since tasks cannot be frozen while executing kernel code the same way they can be preempted, but nothing prevents a task from being frozen while holding a user-space resource.
one of the solutions we're looking at to solve this is to unfreeze the cgroup on a regular basis (say, every 15 to 30 seconds) briefly to avoid this kind of deadlock...
Signature · 7 lines
Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org _______________________________________________ linux-pm mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Quoted 71 lines · On Tue, Aug 3, 2010 at 5:51 PM, <[email protected]> wrote:
Quoted 43 lines · Paul E. McKenney
Quoted 42 lines · On Tue, Aug 03, 2010 at 04:19:25PM -0700, [email protected] wrote:
Quoted 11 lines · Arve Hj?nnev?g
2010/8/2 <[email protected]>:
Quoted 9 lines
so what is the fundamental difference between deciding to go into low-power
idle modes to wake up back up on a given point in the future and deciding
that you are going to be idle for so long that you may as well suspend until
there is user input?Quoted 5 lines
Low power idle modes are supposed to be transparent. Suspend stops the monotonic clock, ignores ready threads and switches over to a separate set of wakeup events/interrupts. We don't suspend until there is user input, we suspend until there is a wakeup event (user-input, incoming network data/phone-calls, alarms etc..).
s/user input/wakeup event/ and my question still stands.
low power modes are not transparent to the user in all cases (if the screen backlight dimms/shuts off a user reading something will notice, if the system switches to a lower clock speed it can impact user response time, etc) The system is making it's best guess as to how to best srve the user by sacraficing some capibilities to save power now so that the power can be available later.
as I see it, suspending until a wakeup event (button press, incoming call, alarm, etc) is just another datapoint along the same path.
If the system could not wake itself up to respond to user input, phone call, alarm, etc and needed the power button pressed to wake up (or shut down to the point where the battery could be removed and reinstalled a long time later), I would see things moving into a different category, but as long as the system has the ability to wake itself up later (and is still consuming power) I see the suspend as being in the same category as the other low-power modes (it's just more expensive to go in and out of)
Quoted 4 lines
Quoted 2 lines
why should the suspend be put into a different category from the other low-power states?
OK, I'll bite...
thanks, this is not intended to be a trap.
Quoted 5 lines
From an Android perspective, the differences are as follows:
1. Deep idle states are entered only if there are no runnable tasks. In contrast, opportunistic suspend can happen even when there are tasks that are ready, willing, and able to run.
Ok, this is a complication to what I'm proposing (and seems a little odd, but I can see how it can work), but not neccessarily a major problem. it depends on exactly how the decision is made to go into low power states and/or suspend. If this is done by an application that is able to look at either all activity or ignore one cgroup of processes at different times in it's calculations than this would work.
Quoted 5 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 a deep idle state. For example, I believe that it was stated that one of the Android-based smartphones ignores touchscreen input while suspended, but pays attention to it while in deep idle states.
Quoted 6 lines
I see this as simply being a matter of what devices are still enabled at the different power savings levels. At one level the touchscreen is still powered, while at another level it isn't, and at yet another level you have to hit the power soft-button. This isn't fundamentally different from powering off a USB peripheral that the system decides is idle (and then not seeing input from it until something else wakes the system)
The touchscreen on android devices is powered down long before we suspend, so that is not a good example. There is still a significant difference between suspend and idle though. In idle all interrupts work, in suspend only interrupts that the driver has called enable_irq_wake on will work (on platforms that support it).
Quoted 10 lines
Quoted 9 lines
3. The system comes out of a deep idle state when a timer expires. In contrast, timers cannot expire while the system is suspended. (This one is debatable: some people argue that timers are subject to jitter, and the suspend case for timers is the same as that for deep idle states, but with unbounded timer jitter. Others disagree. The resulting discussions have produced much heat, but little light. Such is life.)
Quoted 4 lines
if you have the ability to wake for an alarm, you have the ability to wake for a timer (if from no other method than to set the alarm to when the timer tick would go off)
If you just program the alarm you will wake up see that the monotonic clock has not advanced and set the alarm another n seconds into the future. Or are proposing that suspend should be changed to keep the monotonic clock running? If you are, why? We can enter the same hardware states from idle, and modifying suspend to wake up more often would increase the average power consumption in suspend, not improve it for idle. In other words, if suspend wakes up as often as idle, why use suspend?
Quoted 8 lines
Quoted 7 lines
There may well be others.
Whether these distinctions are a good thing or a bad thing is one of the topics of this discussion. But the distinctions themselves are certainly very real, from what I can see.
Or am I missing your point?
Quoted 8 lines
these big distinction that I see as significant seem to be in the decision of when to go into the different states, and the difference between the states themselves seem to be less significant (and either very close to, or within the variation that already exists for power saving modes)
If I'm right bout this, then it would seem to simplify the concept and change it from some really foreign android-only thing into a special case variation of existing core concepts.
Suspend is not an android only concept. The android extensions just allow us to aggressively use suspend without loosing (or delaying) wakeup events. On the hardware that we shipped we can enter the same power mode from idle as we do in suspend, but we still use suspend primarily because it stops the monotonic clock and all the timers that use it. Changing suspend to behave more like an idle mode, which seems to be what you are suggesting, would not buy us anything.
Quoted 8 lines
you have many different power saving modes, the daemon (or kernel code) that is determining which mode to go into would need different logic (including, but not limited to the ability to be able to ignore one or more cgroups of processes). different power saving modes have different trade-offs, and some of them power down different peripherals (which is always a platform specific, if not system specific set of trade-offs)
The hardware specific idle hook can (and does) decide to go into any power state from idle that does not disrupt any active devices.
Quoted 8 lines
This all depends on the ability for the code that decides to switch power modes (including to trigger suspend) to be able to see things in sufficient detail to be able to do different things depending on the class of programs. I don't know enough about this code to know if this is the case or not, I really wish that someone familiar with the power saving code could either confirm that this is possible, or state that it's not possible (or at least, not without major surgery)
Signature · 1 line
Arve Hjønnevåg
Quoted 71 lines · On Tue, Aug 3, 2010 at 5:51 PM, <[email protected]> wrote:
Quoted 43 lines · Paul E. McKenney
Quoted 42 lines · On Tue, Aug 03, 2010 at 04:19:25PM -0700, [email protected] wrote:
Quoted 11 lines · Arve Hj?nnev?g
2010/8/2 <[email protected]>:
Quoted 9 lines
so what is the fundamental difference between deciding to go into low-power
idle modes to wake up back up on a given point in the future and deciding
that you are going to be idle for so long that you may as well suspend until
there is user input?Quoted 5 lines
Low power idle modes are supposed to be transparent. Suspend stops the monotonic clock, ignores ready threads and switches over to a separate set of wakeup events/interrupts. We don't suspend until there is user input, we suspend until there is a wakeup event (user-input, incoming network data/phone-calls, alarms etc..).
s/user input/wakeup event/ and my question still stands.
low power modes are not transparent to the user in all cases (if the screen backlight dimms/shuts off a user reading something will notice, if the system switches to a lower clock speed it can impact user response time, etc) The system is making it's best guess as to how to best srve the user by sacraficing some capibilities to save power now so that the power can be available later.
as I see it, suspending until a wakeup event (button press, incoming call, alarm, etc) is just another datapoint along the same path.
If the system could not wake itself up to respond to user input, phone call, alarm, etc and needed the power button pressed to wake up (or shut down to the point where the battery could be removed and reinstalled a long time later), I would see things moving into a different category, but as long as the system has the ability to wake itself up later (and is still consuming power) I see the suspend as being in the same category as the other low-power modes (it's just more expensive to go in and out of)
Quoted 4 lines
Quoted 2 lines
why should the suspend be put into a different category from the other low-power states?
OK, I'll bite...
thanks, this is not intended to be a trap.
Quoted 5 lines
From an Android perspective, the differences are as follows:
1. Deep idle states are entered only if there are no runnable tasks. In contrast, opportunistic suspend can happen even when there are tasks that are ready, willing, and able to run.
Ok, this is a complication to what I'm proposing (and seems a little odd, but I can see how it can work), but not neccessarily a major problem. it depends on exactly how the decision is made to go into low power states and/or suspend. If this is done by an application that is able to look at either all activity or ignore one cgroup of processes at different times in it's calculations than this would work.
Quoted 5 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 a deep idle state. For example, I believe that it was stated that one of the Android-based smartphones ignores touchscreen input while suspended, but pays attention to it while in deep idle states.
Quoted 6 lines
I see this as simply being a matter of what devices are still enabled at the different power savings levels. At one level the touchscreen is still powered, while at another level it isn't, and at yet another level you have to hit the power soft-button. This isn't fundamentally different from powering off a USB peripheral that the system decides is idle (and then not seeing input from it until something else wakes the system)
The touchscreen on android devices is powered down long before we suspend, so that is not a good example. There is still a significant difference between suspend and idle though. In idle all interrupts work, in suspend only interrupts that the driver has called enable_irq_wake on will work (on platforms that support it).
Quoted 10 lines
Quoted 9 lines
3. The system comes out of a deep idle state when a timer expires. In contrast, timers cannot expire while the system is suspended. (This one is debatable: some people argue that timers are subject to jitter, and the suspend case for timers is the same as that for deep idle states, but with unbounded timer jitter. Others disagree. The resulting discussions have produced much heat, but little light. Such is life.)
Quoted 4 lines
if you have the ability to wake for an alarm, you have the ability to wake for a timer (if from no other method than to set the alarm to when the timer tick would go off)
If you just program the alarm you will wake up see that the monotonic clock has not advanced and set the alarm another n seconds into the future. Or are proposing that suspend should be changed to keep the monotonic clock running? If you are, why? We can enter the same hardware states from idle, and modifying suspend to wake up more often would increase the average power consumption in suspend, not improve it for idle. In other words, if suspend wakes up as often as idle, why use suspend?
Quoted 8 lines
Quoted 7 lines
There may well be others.
Whether these distinctions are a good thing or a bad thing is one of the topics of this discussion. But the distinctions themselves are certainly very real, from what I can see.
Or am I missing your point?
Quoted 8 lines
these big distinction that I see as significant seem to be in the decision of when to go into the different states, and the difference between the states themselves seem to be less significant (and either very close to, or within the variation that already exists for power saving modes)
If I'm right bout this, then it would seem to simplify the concept and change it from some really foreign android-only thing into a special case variation of existing core concepts.
Suspend is not an android only concept. The android extensions just allow us to aggressively use suspend without loosing (or delaying) wakeup events. On the hardware that we shipped we can enter the same power mode from idle as we do in suspend, but we still use suspend primarily because it stops the monotonic clock and all the timers that use it. Changing suspend to behave more like an idle mode, which seems to be what you are suggesting, would not buy us anything.
Quoted 8 lines
you have many different power saving modes, the daemon (or kernel code) that is determining which mode to go into would need different logic (including, but not limited to the ability to be able to ignore one or more cgroups of processes). different power saving modes have different trade-offs, and some of them power down different peripherals (which is always a platform specific, if not system specific set of trade-offs)
The hardware specific idle hook can (and does) decide to go into any power state from idle that does not disrupt any active devices.
Quoted 8 lines
This all depends on the ability for the code that decides to switch power modes (including to trigger suspend) to be able to see things in sufficient detail to be able to do different things depending on the class of programs. I don't know enough about this code to know if this is the case or not, I really wish that someone familiar with the power saving code could either confirm that this is possible, or state that it's not possible (or at least, not without major surgery)
Signature · 1 line
Arve Hjønnevåg
Quoted 8 lines · On Tue, 3 Aug 2010 17:10:15 -0700 "Paul E. McKenney"…
OK, I'll bite...
Quoted 1 line
From an Android perspective, the differences are as follows:
1. Deep idle states are entered only if there are no runnable
tasks. In contrast, opportunistic suspend can happen even when there
are tasks that are ready, willing, and able to run.
for "system suspend", this is an absolutely valid statement. for "use suspend as idle state", it's not so clearly valid. (but this is sort of a separate problem, basically the "when do we freeze the tasks that we don't like for power reasons" problem, which in first order is independent on what kind of idle power state you pick, and discussed extensively elsewhere in this thread)
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 a deep
idle state. For example, I believe that it was stated that
one of the Android-based smartphones ignores touchscreen input while
suspended, but pays attention to it while in deep idle states.
I would argue that this is both a hardware specific issue, but also a policy issue. From the user point of view, screen off with idle and screen off with suspend aren't all that different (if my phone would decide to idle rather than suspend because some app blocks suspend... I wouldn't expect a difference in behavior when I touch the screen). "Screen off -> don't honor touch after a bit" is almost an independent, but very real, policy problem (and a forced one in suspend, I'll grant you that). I could even argue that the policy decision "we don't care about the touch screen input" is a pre-condition for entering suspend (or in android speak, caring for touch screen input/having the touch screen path active would be a suspend blocker)
Quoted 9 lines
3. The system comes out of a deep idle state when a timer
expires. In contrast, timers cannot expire while the system is suspended. (This one is debatable: some people argue that timers are subject to jitter, and the suspend case for timers is the same as that for deep idle states, but with unbounded timer jitter. Others disagree. The resulting discussions have produced much heat, but little light. Such is life.)
I'll debate it even harder in that it's platform specific whether timers can get the system out of suspend or not. Clearly on the Android platform in question that's not the case, but for some of the Intel phone silicon for example, timers CAN be wake sources to get you out of suspend just fine. It just depend on which exact hw you talk about. Generally, even if the fast timers aren't wake up sources, there'll be some sort of alarm thing that you can pre-wake.. but yes you are right in saying that's rather lame.
Either way, it's not a general property of suspend, but a property of suspend on the specific platform in question.
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
Quoted 8 lines · On Tue, 3 Aug 2010 17:10:15 -0700 "Paul E. McKenney"…
OK, I'll bite...
Quoted 1 line
From an Android perspective, the differences are as follows:
1. Deep idle states are entered only if there are no runnable
tasks. In contrast, opportunistic suspend can happen even when there
are tasks that are ready, willing, and able to run.
for "system suspend", this is an absolutely valid statement. for "use suspend as idle state", it's not so clearly valid. (but this is sort of a separate problem, basically the "when do we freeze the tasks that we don't like for power reasons" problem, which in first order is independent on what kind of idle power state you pick, and discussed extensively elsewhere in this thread)
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 a deep
idle state. For example, I believe that it was stated that
one of the Android-based smartphones ignores touchscreen input while
suspended, but pays attention to it while in deep idle states.
I would argue that this is both a hardware specific issue, but also a policy issue. From the user point of view, screen off with idle and screen off with suspend aren't all that different (if my phone would decide to idle rather than suspend because some app blocks suspend... I wouldn't expect a difference in behavior when I touch the screen). "Screen off -> don't honor touch after a bit" is almost an independent, but very real, policy problem (and a forced one in suspend, I'll grant you that). I could even argue that the policy decision "we don't care about the touch screen input" is a pre-condition for entering suspend (or in android speak, caring for touch screen input/having the touch screen path active would be a suspend blocker)
Quoted 9 lines
3. The system comes out of a deep idle state when a timer
expires. In contrast, timers cannot expire while the system is suspended. (This one is debatable: some people argue that timers are subject to jitter, and the suspend case for timers is the same as that for deep idle states, but with unbounded timer jitter. Others disagree. The resulting discussions have produced much heat, but little light. Such is life.)
I'll debate it even harder in that it's platform specific whether timers can get the system out of suspend or not. Clearly on the Android platform in question that's not the case, but for some of the Intel phone silicon for example, timers CAN be wake sources to get you out of suspend just fine. It just depend on which exact hw you talk about. Generally, even if the fast timers aren't wake up sources, there'll be some sort of alarm thing that you can pre-wake.. but yes you are right in saying that's rather lame.
Either way, it's not a general property of suspend, but a property of suspend on the specific platform in question.
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
Quoted 17 lines · Arve Hjønnevåg
2010/8/3 James Bottomley <[email protected]>:
Quoted 8 lines · Arve Hjønnevåg
Quoted 7 lines
Quoted 6 lines
o A power-aware application must be able to efficiently communicate
its needs to the system, so that such communication can be performed on hot code paths. Communication viaopen()andclose()is considered too slow, but communication viaioctl()is acceptable.Quoted 7 lines
Quoted 2 lines
The problem with using open and close to prevent an allow suspend is not that it is too slow but that it interferes with collecting stats.
Please elaborate on this. I expect the pm-qos stats interface will collect stats across user open/close because that's how it currently works. What's the problem?
Quoted 4 lines
The pm-qos interface creates the request object in open and destroys it in release just like the suspend blocker interface. We need stats for each client which is lost if you free the object every time you unblock suspend.
? right at the moment it doesn't do stats. I don't see why adding a per pid or per name stat count on the long lived object won't work here.
Quoted 2 lines
Or are you talking about user space opening and closing the stats interface (which does not cause any problems)?
There is no stat interface yet; it's for us to define.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
The wakelock code has a sysfs interface that allow you to use a open/write/close sequence to block or unblock suspend. There is no limit to the amount of kernel memory that a process can consume with this interface, so the suspend blocker patchset uses a /dev interface with ioctls to block or unblock suspend and it destroys the kernel object when the file descriptor is closed.
Quoted 5 lines
Quoted 1 line
This is an implementation detail only.
There is no way fix it without changing the user space visible behavior of the API. The kernel does not know when it is safe to free the objects.
They're freed on destruction of the long lived kernel object or on user space clear request. Surely that's definitive enough?
Quoted 8 lines
Quoted 4 lines
The pm-qos objects are long
lived, so their stats would be too. I would guess that explicit stat clearing might be a useful option.Which pm-qos objects are you referring to? The struct
pm_qos_objectthat backs each pm-qos class is long lived (I don't know why this is namedpm_qos_object), but we need stats in structpm_qos_request_list.
Actually, why not two separate lists? one for the request and one for the stats?
OK, so I'm tired and I've had a long flight to get to where I am, so I may be a bit jaded, but this isn't fucking rocket science the question is how do we implement what you want on what we have ... there looks to be multiple useful solutions ... we just have to pick one and agree on it (that's standard open source).
James
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm