Attempted summary of suspend-blockers LKML thread
Subsystems (4)
Re: Wakeup-events implementation
In reply to Alan SternQuoted 28 lines · Alan Stern
Quoted 4 lines · Arve Hjønnevåg
We don't uncover all bugs during testing before we ship. For instance the bug could be triggered by a 3db party app, and there is value in making the system as robust as possible to both driver and user space bugs.
By that argument, all in-kernel wakelocks should always have a timeout.
What happens if somebody puts down their phone and then puts something on top of it, in such a way that one of the keypad buttons is depressed? If the keypad driver's wakelock doesn't have a timeout then the battery would drain quickly.
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
Wakeup events that don't reach user space should not need user space support to reenter suspend.
That's debatable. For example, consider a Wake-On-LAN magic packet. It generally doesn't go anywhere -- it gets dropped once the system is awake.
Yes. I think every event that would wake up a sleeping system should result in unfreezing user space.
In fact they do -- there's almost no way to avoid it. However, unfreezing userspace is different from sending a wakeup event to userspace.
Quoted 7 lines
The question is whether the kernel should automatically try to re-suspend following a wakeup for which no information was sent to userspace (e.g., WOL). The alternative, of course, is that the kernel does not try to re-suspend until a power-manager program tells it to. To me this seems more flexible and general (the PM program can always start a new suspend, whereas there's no way to prevent an automatic in-kernel re-suspend).
I agree.
Quoted 43 lines
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Let's say the interrupt handlers responsible for invoking
pm_request_resumeuse non-nesting calls. This may happen several times, depending on the wakeup and interrupt delivery mechanism, but the end result is that the counter is incremented only once. When thepm_runtime_resumecall ends,pm_relaxdoes a single decrement.Quoted 7 lines
Quoted 7 lines
Meanwhile, the driver uses nesting calls. It can increment the counter as much as it wants, and it has to perform an equal number of decrements. The key point is that
pm_request_resumenever gets called while the driver has any outstandingpm_stay_awakerequests. Hence the non-nesting calls never got "lost", since the first one is always made while the counter is 0.Quoted 5 lines
It sounds as if you are saying that the two drivers don't interfere because one of them always gets there first. In your example if another interrupt occurs before the second driver still has released all its references on the counter, the interrupt will (incorrectly) not increment the count.
That's right -- one of them always gets there first. You're also right to suspect that this is an unusual situation. It arises with USB root hubs because a root hub is the only child of its parent controller device, and the only reason a controller would generate a wakeup request is because the root hub needs to wake up.
This means that a root-hub wakeup can be signalled in two different ways:
If the controller is in low-power then the controller sends its wakeup request. The controller's driver sets the controller back to full power, sees that the root hub has needs attention, and calls
pm_request_resumefor the root hub.If the controller isn't in low-power then the root hub simply generates an IRQ. The interrupt handler calls
pm_request_resumefor the root hub.Depending on how the timing works out, both can occur: The controller gets set to full power and then the IRQ line is signalled before the PM workqueue gets around to resuming the root hub. I have seen this happen while testing my computer.
Quoted 5 lines
With a little care, I could avoid calling
pm_stay_awaketwice. The code already sets a bitflag before queuing the resume request, and I could usetest_and_set_bitinstead. If I did then the non-nesting calls wouldn't be needed at all. And that was the only case I could think of where the two types of calls might need to be mixed.
That means one corner case less to worry about, good. :-)
Quoted 10 lines
Quoted 9 lines
Quoted 7 lines
I actually like the idea of having two levels of calls, ie.
pm_stay_awake(dev)calling something like__pm_stay_awake(handle), where the handle is read from structdev_pm_info. And analogously forpm_relax().Then, the object associated with the handle might be created when the device is enabled to wake up and destroyed when it's disabled to do that.
When multiple drivers use the same device, who creates and destroys the handle?
Quoted 7 lines
The primary driver (i.e., the one bound to the device) would use the device's handle. Other drivers would create and use their own separate wakeup structures.
But if all the calls are of the "nesting" sort then there's not really any need for multiple structures, other than to help identify which driver is misbehaving when a problem occurs.
Still, IMO we can do that if it would help to narrow the gap between the Android kernel and the mainline.
Quoted 33 lines
Quoted 3 lines
Typically a driver puts a wakelock in the state that it already allocates for each device, so you have a handle for each device/driver combo that needs to block suspend.
You didn't answer my question about which devices have more than one associated wakelock in Android. Those would be the only cases where the device/driver combo matters.
Also, why does Android's MMC core have its own wakelock instead of using a per-device wakelock?
Quoted 11 lines
Quoted 8 lines
Quoted 2 lines
Allocating these wakeup structures for all possible wakeup sources would be a big waste.
Indeed.
Quoted 3 lines
On the other hand, a driver generally doesn't
know until a suspend starts whether or not its devices should be enabled for wakeup.Why? How is the driver notified on suspend that it needs to be enabled for wakeup.
The driver's (or bus subsystem's) suspend routine calls
device_may_wakeup(dev)to see whether it should enable dev's wakeup mechanism. The value returned bydevice_may_wakeupcan change at almost any time, since it is set by userspace.Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
That makes things difficult, especially if you
contemplate having multiple structures for each device. Have you really sat down and thought about what wakelocks would be needed on a general system such as a desktop or laptop machine?
Quoted 6 lines
Quoted 3 lines
No, I don't know what wakelocks are needed on a general system, but you need code to turn the wakeup events on and off events anyway, so I assume allocating a handle for the wakeup event is possible.
Yes. However system suspend is generally not a good time to go around allocating new structures; memory tends to be tight then.
Well, that's what I wanted to do originally in pm_stay_awake(), but you convinced me it was avoidable. :-)
Quoted 2 lines
I suppose it might be acceptable to do this during the "prepare" phase of system suspend.
I generally think it would make sense to allocate a structure, call it struct wakeup_source for now, for each device or whatever part of the system that we want to treat as a wakeup source and put all of the statistics in there.
For devices it would be pretty straightforward, the structure is allocated as soon as the device is enabled to wakeup and freed when it is disabled. In the other cases it would have to depend on the usage scenario, I guess.
Rafael
Re: Wakeup-events implementation
2010/8/18 Rafael J. Wysocki <[email protected]>:
Quoted 10 lines · Alan Stern
Quoted 9 lines · Arve Hjønnevåg
Quoted 5 lines
We don't uncover all bugs during testing before we ship. For instance the bug could be triggered by a 3db party app, and there is value in making the system as robust as possible to both driver and user space bugs.
By that argument, all in-kernel wakelocks should always have a timeout.
I don't think that is the only conclusion.
Quoted 4 lines
Quoted 4 lines
What happens if somebody puts down their phone and then puts something on top of it, in such a way that one of the keypad buttons is depressed? If the keypad driver's wakelock doesn't have a timeout then the battery would drain quickly.
This is a real problem that might be worth solving, but just adding a wakelock timeout does not solve it since the keyboard driver would either renew the timeout after every scan, or it would leave the keyboard in a state where you could not use it to wake up the device anymore.
Quoted 23 lines
Quoted 15 lines
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
Wakeup events that don't reach user space should not need user space support to reenter suspend.
That's debatable. For example, consider a Wake-On-LAN magic packet. It generally doesn't go anywhere -- it gets dropped once the system is awake.
Yes. I think every event that would wake up a sleeping system should result in unfreezing user space.
In fact they do -- there's almost no way to avoid it. However, unfreezing userspace is different from sending a wakeup event to userspace.
Quoted 7 lines
The question is whether the kernel should automatically try to re-suspend following a wakeup for which no information was sent to userspace (e.g., WOL). The alternative, of course, is that the kernel does not try to re-suspend until a power-manager program tells it to. To me this seems more flexible and general (the PM program can always start a new suspend, whereas there's no way to prevent an automatic in-kernel re-suspend).
Quoted 2 lines
I agree.
Having user space initiate every suspend operation is more flexible out of the box, but you can get the same flexibility with the other approach by adding an interface to report all wakeup events and failed suspend attempts. However, I have not seen a use case for this flexibility other than as a partial workaround for wakeup events that user space needs to know about but are not reported to user space any other way (it is only a partial workaround since it still has the same race condition we are fixing for other wakeup events).
Quoted 65 lines
Quoted 43 lines
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Let's say the interrupt handlers responsible for invoking
pm_request_resumeuse non-nesting calls. This may happen several times, depending on the wakeup and interrupt delivery mechanism, but the end result is that the counter is incremented only once. When thepm_runtime_resumecall ends,pm_relaxdoes a single decrement.Quoted 7 lines
Quoted 7 lines
Meanwhile, the driver uses nesting calls. It can increment the counter as much as it wants, and it has to perform an equal number of decrements. The key point is that
pm_request_resumenever gets called while the driver has any outstandingpm_stay_awakerequests. Hence the non-nesting calls never got "lost", since the first one is always made while the counter is 0.Quoted 5 lines
It sounds as if you are saying that the two drivers don't interfere because one of them always gets there first. In your example if another interrupt occurs before the second driver still has released all its references on the counter, the interrupt will (incorrectly) not increment the count.
That's right -- one of them always gets there first. You're also right to suspect that this is an unusual situation. It arises with USB root hubs because a root hub is the only child of its parent controller device, and the only reason a controller would generate a wakeup request is because the root hub needs to wake up.
This means that a root-hub wakeup can be signalled in two different ways:
If the controller is in low-power then the controller sends its wakeup request. The controller's driver sets the controller back to full power, sees that the root hub has needs attention, and calls
pm_request_resumefor the root hub.If the controller isn't in low-power then the root hub simply generates an IRQ. The interrupt handler calls
pm_request_resumefor the root hub.Depending on how the timing works out, both can occur: The controller gets set to full power and then the IRQ line is signalled before the PM workqueue gets around to resuming the root hub. I have seen this happen while testing my computer.
Quoted 5 lines
With a little care, I could avoid calling
pm_stay_awaketwice. The code already sets a bitflag before queuing the resume request, and I could usetest_and_set_bitinstead. If I did then the non-nesting calls wouldn't be needed at all. And that was the only case I could think of where the two types of calls might need to be mixed.That means one corner case less to worry about, good. :-)
Quoted 14 lines
Quoted 9 lines
Quoted 7 lines
I actually like the idea of having two levels of calls, ie.
pm_stay_awake(dev)calling something like__pm_stay_awake(handle), where the handle is read from structdev_pm_info. And analogously forpm_relax().Then, the object associated with the handle might be created when the device is enabled to wake up and destroyed when it's disabled to do that.
When multiple drivers use the same device, who creates and destroys the handle?
The primary driver (i.e., the one bound to the device) would use the device's handle. Other drivers would create and use their own separate wakeup structures.
Quoted 7 lines
Quoted 3 lines
But if all the calls are of the "nesting" sort then there's not really any need for multiple structures, other than to help identify which driver is misbehaving when a problem occurs.
Still, IMO we can do that if it would help to narrow the gap between the Android kernel and the mainline.
Some android drivers currently need the calls to be not nested so that they can mix timeouts and pm_relax. With only nesting apis we cannot get the same functionality.
Other drivers rely on the non nesting property of the existing wakelock api but do not use timeouts. I expect these drivers can be converted have the same behavior with a nested api, but there could be difficult edge cases.
Non-android driver may need a nested api so they can use a handle that they did not allocate. It is not clear to me if this is really needed. If it is not needed we can make all the calls non nested and require that the driver allocates a handle (or more commonly put the handle in the private data it already allocates). If we do need to keep the nested behavior, we a way to select which variant to use. We can have separate calls that nest and require drivers that use the non-nested variant have their own handle, or we could set a flag when creating a handle that makes calls on that handle not nest.
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Typically a driver puts a wakelock in the state that it already allocates for each device, so you have a handle for each device/driver combo that needs to block suspend.
You didn't answer my question about which devices have more than one associated wakelock in Android. Those would be the only cases where the device/driver combo matters.
Wakelocks are not associated with devices at all right now, so I don't have a list for you. However, the input queues need more than one wakelock per device if they use timeouts. In this case there is only one driver though, but the driver allocates a separate queue for each client that opens a device. Our keypad/gpio-keys driver may also end up using multiple wakelocks. Many phones use different keys types in the same logical keyboard, so you could end up with one wakelock for the matrix scan and another one for debouncing keys connected directly to a gpio. The driver could be changed to share a nested handle, but I prefer to keep them separate.
Quoted 3 lines
Quoted 3 lines
Also, why does Android's MMC core have its own wakelock instead of using a per-device wakelock?
There is a global work queue.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
Allocating these wakeup structures for all possible wakeup sources would be a big waste.
Indeed.
Quoted 3 lines
On the other hand, a driver generally doesn't
know until a suspend starts whether or not its devices should be enabled for wakeup.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Why? How is the driver notified on suspend that it needs to be enabled for wakeup.
The driver's (or bus subsystem's) suspend routine calls
device_may_wakeup(dev)to see whether it should enable dev's wakeup mechanism. The value returned bydevice_may_wakeupcan change at almost any time, since it is set by userspace.
It would be better to allocate the structure when user space changes the setting. If you wait until suspend before blocking suspend you may have passed the event on already.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
That makes things difficult, especially if you
contemplate having multiple structures for each device. Have you really sat down and thought about what wakelocks would be needed on a general system such as a desktop or laptop machine?
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
No, I don't know what wakelocks are needed on a general system, but you need code to turn the wakeup events on and off events anyway, so I assume allocating a handle for the wakeup event is possible.
Yes. However system suspend is generally not a good time to go around allocating new structures; memory tends to be tight then.
I mean the code that lets user space turn wakeup events on and off, not the driver transferring a wakeup source from an interrupt to a wakeup controller.
Quoted 16 lines
Well, that's what I wanted to do originally in
pm_stay_awake(), but you convinced me it was avoidable. :-)Quoted 2 lines
I suppose it might be acceptable to do this during the "prepare" phase of system suspend.
I generally think it would make sense to allocate a structure, call it struct
wakeup_sourcefor now, for each device or whatever part of the system that we want to treat as a wakeup source and put all of the statistics in there.For devices it would be pretty straightforward, the structure is allocated as soon as the device is enabled to wakeup and freed when it is disabled. In the other cases it would have to depend on the usage scenario, I guess.
Rafael
Signature · 1 line
Arve Hjønnevåg
Re: Wakeup-events implementation
Quoted 9 lines · Arve Hjønnevåg
Quoted 2 lines
Quoted 2 lines
By that argument, all in-kernel wakelocks should always have a timeout.
I don't think that is the only conclusion.
Quoted 4 lines
Quoted 4 lines
What happens if somebody puts down their phone and then puts something on top of it, in such a way that one of the keypad buttons is depressed? If the keypad driver's wakelock doesn't have a timeout then the battery would drain quickly.
Quoted 5 lines
This is a real problem that might be worth solving, but just adding a wakelock timeout does not solve it since the keyboard driver would either renew the timeout after every scan, or it would leave the keyboard in a state where you could not use it to wake up the device anymore.
Okay. Nevertheless, you maintain debugging info in case a driver bug causes a wakelock not to be released. If the wakelocks all had timeouts then a bug of that sort wouldn't be able to affect battery life very much. So why not add the timeouts?
Or conversely, if you think the likelihood of such bugs is too low to worry about, then why have the debugging info?
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
The question is whether the kernel should automatically try to re-suspend following a wakeup for which no information was sent to userspace (e.g., WOL). The alternative, of course, is that the kernel does not try to re-suspend until a power-manager program tells it to. To me this seems more flexible and general (the PM program can always start a new suspend, whereas there's no way to prevent an automatic in-kernel re-suspend).
I agree.
Quoted 8 lines
Having user space initiate every suspend operation is more flexible out of the box, but you can get the same flexibility with the other approach by adding an interface to report all wakeup events and failed suspend attempts. However, I have not seen a use case for this flexibility other than as a partial workaround for wakeup events that user space needs to know about but are not reported to user space any other way (it is only a partial workaround since it still has the same race condition we are fixing for other wakeup events).
In any case, this is something that could easily be changed with a small Android-specific kernel patch. At the moment it doesn't seem to be a major issue.
Quoted 23 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
When multiple drivers use the same device, who creates and destroys the handle?
The primary driver (i.e., the one bound to the device) would use the device's handle. Other drivers would create and use their own separate wakeup structures.
Quoted 7 lines
Quoted 3 lines
But if all the calls are of the "nesting" sort then there's not really any need for multiple structures, other than to help identify which driver is misbehaving when a problem occurs.
Still, IMO we can do that if it would help to narrow the gap between the Android kernel and the mainline.
Some android drivers currently need the calls to be not nested so that they can mix timeouts and
pm_relax. With only nesting apis we cannot get the same functionality.Other drivers rely on the non nesting property of the existing wakelock api but do not use timeouts. I expect these drivers can be converted have the same behavior with a nested api, but there could be difficult edge cases.
Quoted 9 lines
Non-android driver may need a nested api so they can use a handle that they did not allocate. It is not clear to me if this is really needed. If it is not needed we can make all the calls non nested and require that the driver allocates a handle (or more commonly put the handle in the private data it already allocates). If we do need to keep the nested behavior, we a way to select which variant to use. We can have separate calls that nest and require drivers that use the non-nested variant have their own handle, or we could set a flag when creating a handle that makes calls on that handle not nest.
I agree, there are several possible designs. It's hard to tell which will be best without more experience.
How much degradation do you think you would observe if in-kernel wakelocks _always_ used timeouts alone and _never_ were cancelled?
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
You didn't answer my question about which devices have more than one associated wakelock in Android. Those would be the only cases where the device/driver combo matters.
Quoted 10 lines
Wakelocks are not associated with devices at all right now, so I don't have a list for you. However, the input queues need more than one wakelock per device if they use timeouts. In this case there is only one driver though, but the driver allocates a separate queue for each client that opens a device. Our keypad/gpio-keys driver may also end up using multiple wakelocks. Many phones use different keys types in the same logical keyboard, so you could end up with one wakelock for the matrix scan and another one for debouncing keys connected directly to a gpio. The driver could be changed to share a nested handle, but I prefer to keep them separate.
Okay. In addition, we've already seen that devices for which you haven't yet implemented any wakelocks may end up needing more than one.
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Also, why does Android's MMC core have its own wakelock instead of using a per-device wakelock?
There is a global work queue.
So you want to be able to cancel the wakelock whenever the queue is empty, right? And not have to keep track of whether each MMC device has any work items in the queue.
In theory this is insufficient -- it doesn't handle the case where one MMC device is enabled for wakeup and another isn't. I assume you don't really care about this (especially since Android phones aren't likely to have more than one MMC device capable of generating wakeup events).
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
The driver's (or bus subsystem's) suspend routine calls
device_may_wakeup(dev)to see whether it should enable dev's wakeup mechanism. The value returned bydevice_may_wakeupcan change at almost any time, since it is set by userspace.It would be better to allocate the structure when user space changes the setting. If you wait until suspend before blocking suspend you may have passed the event on already.
That will work for the structure directly associated with the device. Additional structures allocated by the drivers have to be handled differently, because the drivers aren't notified when the wakeup-enable setting is changed.
Alan Stern
Re: Wakeup-events implementation
2010/8/19 Alan Stern <[email protected]>:
Quoted 17 lines · Arve Hjønnevåg
Quoted 10 lines
Quoted 3 lines
Quoted 3 lines
By that argument, all in-kernel wakelocks should always have a timeout.
I don't think that is the only conclusion.
Quoted 4 lines
Quoted 4 lines
What happens if somebody puts down their phone and then puts something on top of it, in such a way that one of the keypad buttons is depressed? If the keypad driver's wakelock doesn't have a timeout then the battery would drain quickly.
Quoted 5 lines
This is a real problem that might be worth solving, but just adding a wakelock timeout does not solve it since the keyboard driver would either renew the timeout after every scan, or it would leave the keyboard in a state where you could not use it to wake up the device anymore.
Quoted 5 lines
Okay. Nevertheless, you maintain debugging info in case a driver bug causes a wakelock not to be released. If the wakelocks all had timeouts then a bug of that sort wouldn't be able to affect battery life very much. So why not add the timeouts?
Because we can't. I just described how the keypad driver would break we just add a timeout to its wakelock. Other drivers, like the usb gadget driver may need to block suspend for an extended time period.
Quoted 3 lines
Or conversely, if you think the likelihood of such bugs is too low to worry about, then why have the debugging info?
That statement assumes all the bugs can be fixed by adding timeouts, which I don't think is true. Also, you don't need to have bugs for the stats to be useful. The gps could for instance prevent suspend for a long time because the user ran a gps tracking app.
Quoted 20 lines
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
The question is whether the kernel should automatically try to re-suspend following a wakeup for which no information was sent to userspace (e.g., WOL). The alternative, of course, is that the kernel does not try to re-suspend until a power-manager program tells it to. To me this seems more flexible and general (the PM program can always start a new suspend, whereas there's no way to prevent an automatic in-kernel re-suspend).
I agree.
Quoted 8 lines
Having user space initiate every suspend operation is more flexible out of the box, but you can get the same flexibility with the other approach by adding an interface to report all wakeup events and failed suspend attempts. However, I have not seen a use case for this flexibility other than as a partial workaround for wakeup events that user space needs to know about but are not reported to user space any other way (it is only a partial workaround since it still has the same race condition we are fixing for other wakeup events).
Quoted 4 lines
In any case, this is something that could easily be changed with a small Android-specific kernel patch. At the moment it doesn't seem to be a major issue.
Yes, that seems to be a likely outcome.
Quoted 33 lines
Quoted 23 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
When multiple drivers use the same device, who creates and destroys the handle?
The primary driver (i.e., the one bound to the device) would use the device's handle. Other drivers would create and use their own separate wakeup structures.
Quoted 7 lines
Quoted 3 lines
But if all the calls are of the "nesting" sort then there's not really any need for multiple structures, other than to help identify which driver is misbehaving when a problem occurs.
Still, IMO we can do that if it would help to narrow the gap between the Android kernel and the mainline.
Some android drivers currently need the calls to be not nested so that they can mix timeouts and
pm_relax. With only nesting apis we cannot get the same functionality.Other drivers rely on the non nesting property of the existing wakelock api but do not use timeouts. I expect these drivers can be converted have the same behavior with a nested api, but there could be difficult edge cases.
Quoted 9 lines
Non-android driver may need a nested api so they can use a handle that they did not allocate. It is not clear to me if this is really needed. If it is not needed we can make all the calls non nested and require that the driver allocates a handle (or more commonly put the handle in the private data it already allocates). If we do need to keep the nested behavior, we a way to select which variant to use. We can have separate calls that nest and require drivers that use the non-nested variant have their own handle, or we could set a flag when creating a handle that makes calls on that handle not nest.
Quoted 6 lines
I agree, there are several possible designs. It's hard to tell which will be best without more experience.
How much degradation do you think you would observe if in-kernel wakelocks _always_ used timeouts alone and _never_ were cancelled?
I don't think that is an option. We have kernel wakelocks that need to be held while the device is in a specific state.
Quoted 23 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
You didn't answer my question about which devices have more than one associated wakelock in Android. Those would be the only cases where the device/driver combo matters.
Quoted 10 lines
Wakelocks are not associated with devices at all right now, so I don't have a list for you. However, the input queues need more than one wakelock per device if they use timeouts. In this case there is only one driver though, but the driver allocates a separate queue for each client that opens a device. Our keypad/gpio-keys driver may also end up using multiple wakelocks. Many phones use different keys types in the same logical keyboard, so you could end up with one wakelock for the matrix scan and another one for debouncing keys connected directly to a gpio. The driver could be changed to share a nested handle, but I prefer to keep them separate.
Okay. In addition, we've already seen that devices for which you haven't yet implemented any wakelocks may end up needing more than one.
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Also, why does Android's MMC core have its own wakelock instead of using a per-device wakelock?
Quoted 6 lines
Quoted 1 line
There is a global work queue.
So you want to be able to cancel the wakelock whenever the queue is empty, right? And not have to keep track of whether each MMC device has any work items in the queue.
I have not reviewed that code, so I don't know the details of how it works or even if it is correct, but I see that it uses both timeouts and wake_unlock calls on the same wakelock.
Quoted 5 lines
In theory this is insufficient -- it doesn't handle the case where one MMC device is enabled for wakeup and another isn't. I assume you don't really care about this (especially since Android phones aren't likely to have more than one MMC device capable of generating wakeup events).
I'm not sure what you mean by insufficient here. If it not optimal if you also have work that does not need to prevent suspend, but it should still work correctly.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
The driver's (or bus subsystem's) suspend routine calls
device_may_wakeup(dev)to see whether it should enable dev's wakeup mechanism. The value returned bydevice_may_wakeupcan change at almost any time, since it is set by userspace.
Quoted 9 lines
Quoted 3 lines
It would be better to allocate the structure when user space changes the setting. If you wait until suspend before blocking suspend you may have passed the event on already.
That will work for the structure directly associated with the device. Additional structures allocated by the drivers have to be handled differently, because the drivers aren't notified when the wakeup-enable setting is changed.
I'm not convinced that is it sufficient to detect that a device is wakeup-enabled on suspend. However it is not a problem I have tried to solve since we have only used static wakeup sources.
Signature · 1 line
Arve Hjønnevåg
Re: Wakeup-events implementation
Quoted 9 lines · Arve Hjønnevåg
Quoted 5 lines
Okay. Nevertheless, you maintain debugging info in case a driver bug causes a wakelock not to be released. If the wakelocks all had timeouts then a bug of that sort wouldn't be able to affect battery life very much. So why not add the timeouts?
Because we can't. I just described how the keypad driver would break we just add a timeout to its wakelock. Other drivers, like the usb gadget driver may need to block suspend for an extended time period.
Some wakelocks can't use timeouts because they may have to be held for extended periods. But the others could have timeouts.
Quoted 6 lines
Quoted 3 lines
How much degradation do you think you would observe if in-kernel wakelocks _always_ used timeouts alone and _never_ were cancelled?
I don't think that is an option. We have kernel wakelocks that need to be held while the device is in a specific state.
Yes, but what about all the others? What I'm getting at is whether it's feasible for each wakelock to be exclusively used either with timeouts or cancellations, but never both.
Quoted 9 lines
Quoted 5 lines
In theory this is insufficient -- it doesn't handle the case where one MMC device is enabled for wakeup and another isn't. I assume you don't really care about this (especially since Android phones aren't likely to have more than one MMC device capable of generating wakeup events).
I'm not sure what you mean by insufficient here. If it not optimal if you also have work that does not need to prevent suspend, but it should still work correctly.
Yeah, that's what I meant. You would end up blocking suspends unnecessarily. It's okay if it doesn't happen very often.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
It would be better to allocate the structure when user space changes the setting. If you wait until suspend before blocking suspend you may have passed the event on already.
Quoted 8 lines
Quoted 5 lines
That will work for the structure directly associated with the device. Additional structures allocated by the drivers have to be handled differently, because the drivers aren't notified when the wakeup-enable setting is changed.
I'm not convinced that is it sufficient to detect that a device is wakeup-enabled on suspend.
It isn't.
Quoted 2 lines
However it is not a problem I have tried to
solve since we have only used static wakeup sources.
Well, we may need to solve it eventually. One possible solution is to imitate what you're doing with MMC: Use a single per-driver wakelock instead of separate wakelocks for each driver/device combination. I don't know if that would work for all the cases, though.
Alan Stern
RFC PATCH 1/1 PM / Wakeup: Introduce wakeup source objects and event statistics (was: Re: Wakeup-events implementation)
Hi,
Below is a patch that adds some statistics to the previously merged pm_wakeup_event()/pm_stay_awake()/pm_relax() code. It also makes it possible to use wakeup sources that are not directly associated with devices.
It adds functions for manipulating wakeup source objects and reworks the device wakeup enabling/disabling to use the new functions. The list of wakeup sources is only used for updating the "hit count" statistics for now (this is the number of times the wakeup source was active when the PM core checked), but I'm planning to add a /proc file listing all wakeup sources, including the ones that are not attached to device objects.
It appears to work with the PCI wakeup code added previously, but that's only one case. I'm also not sure if it builds withoug CONFIG_PM_SLEEP. [BTW, I'm not sure it atomic_inc() and atomic_dec() imply a memory barrier in general. That seems to be the case on x86, but I don't know about other architectures.]
Please have a look and let me know what you think.
Thanks,
Rafael
--- drivers/base/power/main.c | 3 drivers/base/power/power.h | 1 drivers/base/power/runtime.c | 2 drivers/base/power/sysfs.c | 121 +++++++++ drivers/base/power/wakeup.c | 532 ++++++++++++++++++++++++++++++++++++------- include/linux/pm.h | 16 - include/linux/pm_wakeup.h | 114 +++++++-- include/linux/suspend.h | 4 kernel/power/main.c | 8 9 files changed, 673 insertions(+), 128 deletions(-)
include/linux/pm_wakeup.h +89 -25
@@ -2,6 +2,7 @@* pm_wakeup.h - Power management wakeup interface * * Copyright (C) 2008 Alan Stern +* Copyright (C) 2010 Rafael J. Wysocki, Novell Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -27,18 +28,27 @@#include <linux/types.h> -#ifdef CONFIG_PM +struct wakeup_source { +char *name; +struct list_head entry; +spinlock_t lock; +struct timer_list timer; +unsigned long timer_expires; +ktime_t total_time; +ktime_t max_time; +ktime_t last_time; +unsigned long event_count; +unsigned long active_count; +unsigned long relax_count; +unsigned long hit_count; +unsigned int active:1 ; +}; -/* Changes to device_may_wakeup take effect on the next pm state change. -* -* By default, most devices should leave wakeup disabled. The exceptions -* are devices that everyone expects to be wakeup sources: keyboards, -* power buttons, possibly network interfaces, etc. +#ifdef CONFIG_PM_SLEEP + +/* +* Changes to device_may_wakeup take effect on the next pm state change. */ -static inline void device_init_wakeup (struct device *dev,bool val) -{ - dev->power.can_wakeup = dev->power.should_wakeup = val; -}static inline void device_set_wakeup_capable (struct device *dev,bool capable) {
@@ -50,23 +60,32 @@ static inline bool device_can_wakeup(strreturn dev->power.can_wakeup; } -static inline void device_set_wakeup_enable (struct device *dev,bool enable) -{ - dev->power.should_wakeup = enable; -} +static inline bool device_may_wakeup (struct device *dev) { -return dev->power.can_wakeup && dev->power.should_wakeup; +return dev->power.can_wakeup && !!dev->power.wakeup; } -#else /* !CONFIG_PM */ +/* drivers/base/power/wakeup.c */ +extern struct wakeup_source *wakeup_source_create (const char *name); +extern void wakeup_source_destroy (struct wakeup_source *ws); +extern void wakeup_source_register (struct wakeup_source *ws); +extern void wakeup_source_unregister (struct wakeup_source *ws); +extern struct wakeup_source *wakeup_source_add (const char *name); +extern void wakeup_source_remove (struct wakeup_source *ws); +extern int device_wakeup_enable (struct device *dev); +extern int device_wakeup_disable (struct device *dev); +extern int device_init_wakeup (struct device *dev,bool val); +extern int device_set_wakeup_enable (struct device *dev,bool enable); +extern void __pm_stay_awake (struct wakeup_source *ws); +extern void pm_stay_awake (struct device *dev); +extern void __pm_relax (struct wakeup_source *ws); +extern void pm_relax (struct device *dev); +extern void __pm_wakeup_event (struct wakeup_source *ws,unsigned int msec); +extern void pm_wakeup_event (struct device *dev,unsigned int msec); -/* For some reason the following routines work even without CONFIG_PM */ -static inline void device_init_wakeup (struct device *dev,bool val) -{ - dev->power.can_wakeup = val; -} +#else /* !CONFIG_PM_SLEEP */ static inline void device_set_wakeup_capable (struct device *dev,bool capable) {
@@ -78,15 +97,60 @@ static inline bool device_can_wakeup(strreturn dev->power.can_wakeup; } -static inline void device_set_wakeup_enable (struct device *dev,bool enable) +static inline bool device_may_wakeup (struct device *dev) { +return false; } -static inline bool device_may_wakeup (struct device *dev) +static inline struct wakeup_source *wakeup_source_create (char *name) { -return false; +return NULL ; +} + +static inline void wakeup_source_destroy (struct wakeup_source *ws) {} + +static inline void wakeup_source_register (struct wakeup_source *ws) {} + +static inline void wakeup_source_unregister (struct wakeup_source *ws) {} + +static inline struct wakeup_source *wakeup_source_add (char *name) +{ +return NULL ; } -#endif /* !CONFIG_PM */ +static inline void wakeup_source_remove (struct wakeup_source *ws) {} + +static inline int device_wakeup_enable (struct device *dev) +{ +return -EINVAL ; +} + +static inline int device_wakeup_disable (struct device *dev) {} + +static inline int device_init_wakeup (struct device *dev,bool val) +{ + dev->power.can_wakeup = val; +return val ? -EINVAL :0 ; +} + + +static inline int device_set_wakeup_enable (struct device *dev,bool enable) +{ +return -EINVAL ; +} + +static inline void __pm_stay_awake (struct wakeup_source *ws) {} + +static inline void pm_stay_awake (struct device *dev) {} + +static inline void __pm_relax (struct wakeup_source *ws) {} + +static inline void pm_relax (struct device *dev) {} + +static inline void __pm_wakeup_event (struct wakeup_source *ws,unsigned int msec) {} + +static inline void pm_wakeup_event (struct device *dev,unsigned int msec) {} + +#endif /* !CONFIG_PM_SLEEP */ #endif /* _LINUX_PM_WAKEUP_H */
include/linux/pm.h +4 -12
@@ -448,23 +448,24 @@ enum rpm_request { RPM_REQ_RESUME, }; +struct wakeup_source ; +struct dev_pm_info {pm_message_t power_state;unsigned int can_wakeup:1 ; -unsigned int should_wakeup:1 ;unsigned async_suspend:1 ;enum dpm_state status;/* Owned by the PM core */ +spinlock_t lock;#ifdef CONFIG_PM_SLEEP struct list_head entry;struct completion completion; -unsigned long wakeup_count; +struct wakeup_source *wakeup;#endif #ifdef CONFIG_PM_RUNTIME struct timer_list suspend_timer;unsigned long timer_expires;struct work_struct work;wait_queue_head_t wait_queue; -spinlock_t lock;atomic_t usage_count;atomic_t child_count;unsigned int disable_depth:3 ;
@@ -559,11 +560,6 @@ extern void __suspend_report_result(cons } while (0) extern void device_pm_wait_for_dev(struct device *sub, struct device *dev); - -/* drivers/base/power/wakeup.c */ -extern void pm_wakeup_event (struct device *dev,unsigned int msec); -extern void pm_stay_awake (struct device *dev); -extern void pm_relax (void );#else /* !CONFIG_PM_SLEEP */ #define device_pm_lock () do {} while (0)
@@ -577,10 +573,6 @@ static inline int dpm_suspend_start(pm_m#define suspend_report_result (fn, ret) do {} while (0)static inline void device_pm_wait_for_dev (struct device *a,struct device *b) {} - -static inline void pm_wakeup_event (struct device *dev,unsigned int msec) {} -static inline void pm_stay_awake (struct device *dev) {} -static inline void pm_relax (void ) {}#endif /* !CONFIG_PM_SLEEP */ /* How to reorder dpm_list after device_move() */
drivers/base/power/wakeup.c +452 -80
645 lines not on this page · raw message
drivers/base/power/main.c +2 -1
@@ -60,7 +60,8 @@ void device_pm_init(struct device *dev) dev->power.status =DPM_ON ;init_completion (&dev->power.completion);complete_all (&dev->power.completion); - dev->power.wakeup_count =0 ; + dev->power.wakeup =NULL ; +spin_lock_init (&dev->power.lock);pm_runtime_init (dev); }
drivers/base/power/power.h +1 -0
@@ -34,6 +34,7 @@ extern void device_pm_move_last(struct dstatic inline void device_pm_init (struct device *dev) { +spin_lock_init (&dev->power.lock);pm_runtime_init (dev); }
drivers/base/power/runtime.c +0 -2
@@ -1099,8 +1099,6 @@ EXPORT_SYMBOL_GPL(pm_runtime_allow);*/ void pm_runtime_init (struct device *dev) { -spin_lock_init (&dev->power.lock); - dev->power.runtime_status =RPM_SUSPENDED ; dev->power.idle_notification = false;
include/linux/suspend.h +2 -2
@@ -302,8 +302,8 @@ extern int unregister_pm_notifier(structextern bool events_check_enabled;extern bool pm_check_wakeup_events (void ); -extern bool pm_get_wakeup_count (unsigned long *count); -extern bool pm_save_wakeup_count (unsigned long count); +extern bool pm_get_wakeup_count (unsigned int *count); +extern bool pm_save_wakeup_count (unsigned int count);#else /* !CONFIG_PM_SLEEP */ static inline int register_pm_notifier (struct notifier_block *nb)
kernel/power/main.c +4 -4
@@ -237,18 +237,18 @@ static ssize_t wakeup_count_show(structstruct kobj_attribute *attr, char *buf) { - unsigned long val; + unsigned int val; -return pm_get_wakeup_count (&val) ?sprintf (buf,"%lu\n" , val) : -EINTR ; +return pm_get_wakeup_count (&val) ?sprintf (buf,"%u\n" , val) : -EINTR ; }static ssize_t wakeup_count_store (struct kobject *kobj,struct kobj_attribute *attr,const char *buf,size_t n) { -unsigned long val; +unsigned int val; -if (sscanf (buf,"%lu" , &val) ==1 ) { +if (sscanf (buf,"%u" , &val) ==1 ) {if (pm_save_wakeup_count (val))return n; }
drivers/base/power/sysfs.c +119 -2
136 lines not on this page · raw message
RFC PATCH 1/1 PM / Wakeup: Introduce wakeup source objects and event statistics (was: Re: Wakeup-events implementation)
In reply to Alan SternHi,
Below is a patch that adds some statistics to the previously merged pm_wakeup_event()/pm_stay_awake()/pm_relax() code. It also makes it possible to use wakeup sources that are not directly associated with devices.
It adds functions for manipulating wakeup source objects and reworks the device wakeup enabling/disabling to use the new functions. The list of wakeup sources is only used for updating the "hit count" statistics for now (this is the number of times the wakeup source was active when the PM core checked), but I'm planning to add a /proc file listing all wakeup sources, including the ones that are not attached to device objects.
It appears to work with the PCI wakeup code added previously, but that's only one case. I'm also not sure if it builds withoug CONFIG_PM_SLEEP. [BTW, I'm not sure it atomic_inc() and atomic_dec() imply a memory barrier in general. That seems to be the case on x86, but I don't know about other architectures.]
Please have a look and let me know what you think.
Thanks,
Rafael
--- drivers/base/power/main.c | 3 drivers/base/power/power.h | 1 drivers/base/power/runtime.c | 2 drivers/base/power/sysfs.c | 121 +++++++++ drivers/base/power/wakeup.c | 532 ++++++++++++++++++++++++++++++++++++------- include/linux/pm.h | 16 - include/linux/pm_wakeup.h | 114 +++++++-- include/linux/suspend.h | 4 kernel/power/main.c | 8 9 files changed, 673 insertions(+), 128 deletions(-)
include/linux/pm_wakeup.h +89 -25
@@ -2,6 +2,7 @@* pm_wakeup.h - Power management wakeup interface * * Copyright (C) 2008 Alan Stern +* Copyright (C) 2010 Rafael J. Wysocki, Novell Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -27,18 +28,27 @@#include <linux/types.h> -#ifdef CONFIG_PM +struct wakeup_source { +char *name; +struct list_head entry; +spinlock_t lock; +struct timer_list timer; +unsigned long timer_expires; +ktime_t total_time; +ktime_t max_time; +ktime_t last_time; +unsigned long event_count; +unsigned long active_count; +unsigned long relax_count; +unsigned long hit_count; +unsigned int active:1 ; +}; -/* Changes to device_may_wakeup take effect on the next pm state change. -* -* By default, most devices should leave wakeup disabled. The exceptions -* are devices that everyone expects to be wakeup sources: keyboards, -* power buttons, possibly network interfaces, etc. +#ifdef CONFIG_PM_SLEEP + +/* +* Changes to device_may_wakeup take effect on the next pm state change. */ -static inline void device_init_wakeup (struct device *dev,bool val) -{ - dev->power.can_wakeup = dev->power.should_wakeup = val; -}static inline void device_set_wakeup_capable (struct device *dev,bool capable) {
@@ -50,23 +60,32 @@ static inline bool device_can_wakeup(strreturn dev->power.can_wakeup; } -static inline void device_set_wakeup_enable (struct device *dev,bool enable) -{ - dev->power.should_wakeup = enable; -} +static inline bool device_may_wakeup (struct device *dev) { -return dev->power.can_wakeup && dev->power.should_wakeup; +return dev->power.can_wakeup && !!dev->power.wakeup; } -#else /* !CONFIG_PM */ +/* drivers/base/power/wakeup.c */ +extern struct wakeup_source *wakeup_source_create (const char *name); +extern void wakeup_source_destroy (struct wakeup_source *ws); +extern void wakeup_source_register (struct wakeup_source *ws); +extern void wakeup_source_unregister (struct wakeup_source *ws); +extern struct wakeup_source *wakeup_source_add (const char *name); +extern void wakeup_source_remove (struct wakeup_source *ws); +extern int device_wakeup_enable (struct device *dev); +extern int device_wakeup_disable (struct device *dev); +extern int device_init_wakeup (struct device *dev,bool val); +extern int device_set_wakeup_enable (struct device *dev,bool enable); +extern void __pm_stay_awake (struct wakeup_source *ws); +extern void pm_stay_awake (struct device *dev); +extern void __pm_relax (struct wakeup_source *ws); +extern void pm_relax (struct device *dev); +extern void __pm_wakeup_event (struct wakeup_source *ws,unsigned int msec); +extern void pm_wakeup_event (struct device *dev,unsigned int msec); -/* For some reason the following routines work even without CONFIG_PM */ -static inline void device_init_wakeup (struct device *dev,bool val) -{ - dev->power.can_wakeup = val; -} +#else /* !CONFIG_PM_SLEEP */ static inline void device_set_wakeup_capable (struct device *dev,bool capable) {
@@ -78,15 +97,60 @@ static inline bool device_can_wakeup(strreturn dev->power.can_wakeup; } -static inline void device_set_wakeup_enable (struct device *dev,bool enable) +static inline bool device_may_wakeup (struct device *dev) { +return false; } -static inline bool device_may_wakeup (struct device *dev) +static inline struct wakeup_source *wakeup_source_create (char *name) { -return false; +return NULL ; +} + +static inline void wakeup_source_destroy (struct wakeup_source *ws) {} + +static inline void wakeup_source_register (struct wakeup_source *ws) {} + +static inline void wakeup_source_unregister (struct wakeup_source *ws) {} + +static inline struct wakeup_source *wakeup_source_add (char *name) +{ +return NULL ; } -#endif /* !CONFIG_PM */ +static inline void wakeup_source_remove (struct wakeup_source *ws) {} + +static inline int device_wakeup_enable (struct device *dev) +{ +return -EINVAL ; +} + +static inline int device_wakeup_disable (struct device *dev) {} + +static inline int device_init_wakeup (struct device *dev,bool val) +{ + dev->power.can_wakeup = val; +return val ? -EINVAL :0 ; +} + + +static inline int device_set_wakeup_enable (struct device *dev,bool enable) +{ +return -EINVAL ; +} + +static inline void __pm_stay_awake (struct wakeup_source *ws) {} + +static inline void pm_stay_awake (struct device *dev) {} + +static inline void __pm_relax (struct wakeup_source *ws) {} + +static inline void pm_relax (struct device *dev) {} + +static inline void __pm_wakeup_event (struct wakeup_source *ws,unsigned int msec) {} + +static inline void pm_wakeup_event (struct device *dev,unsigned int msec) {} + +#endif /* !CONFIG_PM_SLEEP */ #endif /* _LINUX_PM_WAKEUP_H */
include/linux/pm.h +4 -12
@@ -448,23 +448,24 @@ enum rpm_request { RPM_REQ_RESUME, }; +struct wakeup_source ; +struct dev_pm_info {pm_message_t power_state;unsigned int can_wakeup:1 ; -unsigned int should_wakeup:1 ;unsigned async_suspend:1 ;enum dpm_state status;/* Owned by the PM core */ +spinlock_t lock;#ifdef CONFIG_PM_SLEEP struct list_head entry;struct completion completion; -unsigned long wakeup_count; +struct wakeup_source *wakeup;#endif #ifdef CONFIG_PM_RUNTIME struct timer_list suspend_timer;unsigned long timer_expires;struct work_struct work;wait_queue_head_t wait_queue; -spinlock_t lock;atomic_t usage_count;atomic_t child_count;unsigned int disable_depth:3 ;
@@ -559,11 +560,6 @@ extern void __suspend_report_result(cons } while (0) extern void device_pm_wait_for_dev(struct device *sub, struct device *dev); - -/* drivers/base/power/wakeup.c */ -extern void pm_wakeup_event (struct device *dev,unsigned int msec); -extern void pm_stay_awake (struct device *dev); -extern void pm_relax (void );#else /* !CONFIG_PM_SLEEP */ #define device_pm_lock () do {} while (0)
@@ -577,10 +573,6 @@ static inline int dpm_suspend_start(pm_m#define suspend_report_result (fn, ret) do {} while (0)static inline void device_pm_wait_for_dev (struct device *a,struct device *b) {} - -static inline void pm_wakeup_event (struct device *dev,unsigned int msec) {} -static inline void pm_stay_awake (struct device *dev) {} -static inline void pm_relax (void ) {}#endif /* !CONFIG_PM_SLEEP */ /* How to reorder dpm_list after device_move() */
drivers/base/power/wakeup.c +452 -80
645 lines not on this page · raw message
drivers/base/power/main.c +2 -1
@@ -60,7 +60,8 @@ void device_pm_init(struct device *dev) dev->power.status =DPM_ON ;init_completion (&dev->power.completion);complete_all (&dev->power.completion); - dev->power.wakeup_count =0 ; + dev->power.wakeup =NULL ; +spin_lock_init (&dev->power.lock);pm_runtime_init (dev); }
drivers/base/power/power.h +1 -0
@@ -34,6 +34,7 @@ extern void device_pm_move_last(struct dstatic inline void device_pm_init (struct device *dev) { +spin_lock_init (&dev->power.lock);pm_runtime_init (dev); }
drivers/base/power/runtime.c +0 -2
@@ -1099,8 +1099,6 @@ EXPORT_SYMBOL_GPL(pm_runtime_allow);*/ void pm_runtime_init (struct device *dev) { -spin_lock_init (&dev->power.lock); - dev->power.runtime_status =RPM_SUSPENDED ; dev->power.idle_notification = false;
include/linux/suspend.h +2 -2
@@ -302,8 +302,8 @@ extern int unregister_pm_notifier(structextern bool events_check_enabled;extern bool pm_check_wakeup_events (void ); -extern bool pm_get_wakeup_count (unsigned long *count); -extern bool pm_save_wakeup_count (unsigned long count); +extern bool pm_get_wakeup_count (unsigned int *count); +extern bool pm_save_wakeup_count (unsigned int count);#else /* !CONFIG_PM_SLEEP */ static inline int register_pm_notifier (struct notifier_block *nb)
kernel/power/main.c +4 -4
@@ -237,18 +237,18 @@ static ssize_t wakeup_count_show(structstruct kobj_attribute *attr, char *buf) { - unsigned long val; + unsigned int val; -return pm_get_wakeup_count (&val) ?sprintf (buf,"%lu\n" , val) : -EINTR ; +return pm_get_wakeup_count (&val) ?sprintf (buf,"%u\n" , val) : -EINTR ; }static ssize_t wakeup_count_store (struct kobject *kobj,struct kobj_attribute *attr,const char *buf,size_t n) { -unsigned long val; +unsigned int val; -if (sscanf (buf,"%lu" , &val) ==1 ) { +if (sscanf (buf,"%u" , &val) ==1 ) {if (pm_save_wakeup_count (val))return n; }
drivers/base/power/sysfs.c +119 -2
136 lines not on this page · raw message
Re: [RFC][PATCH] PM / Wakeup: Introduce wakeup source objects and event statistics (was: Re: Wakeup-events implementation)
Quoted 5 lines · Rafael J. Wysocki
Hi,
Below is a patch that adds some statistics to the previously merged pm_wakeup_event()/pm_stay_awake()/pm_relax() code. It also makes it possible to use wakeup sources that are not directly associated with devices.
I noted only a few things during a quick read-through. See below.
Quoted 6 lines
It adds functions for manipulating wakeup source objects and reworks the device wakeup enabling/disabling to use the new functions. The list of wakeup sources is only used for updating the "hit count" statistics for now (this is the number of times the wakeup source was active when the PM core checked), but I'm planning to add a /proc file listing all wakeup sources, including the ones that are not attached to device objects.
It must be obvious that this is starting to look more and more like the suspend_blockers patch. What that means or will lead to, I don't know...
Quoted 4 lines
It appears to work with the PCI wakeup code added previously, but that's only one case. I'm also not sure if it builds withoug
CONFIG_PM_SLEEP. [BTW, I'm not sure itatomic_inc()andatomic_dec()imply a memory barrier in general. That seems to be the case on x86, but I don't know about other architectures.]
They do not imply memory barriers. See the section on atomic operations in Documentation/memory-barriers.txt.
Quoted 7 lines
drivers/base/power/wakeup.c +7
-0+/** +* wakeup_source_create - Create a struct wakeup_source object. +* @name: Name of the new wakeup source. +*/ +struct wakeup_source *wakeup_source_create (const char *name) +{ +struct wakeup_source *ws;
drivers/base/power/wakeup.c line 54
Quoted 10 lines
drivers/base/power/wakeup.c +10
-0+ + ws =kzalloc (sizeof (*ws),GFP_KERNEL ); +if (!ws) +return NULL ; + +if (name) { +int len =strlen (name); +char *s =kzalloc (len +1 ,GFP_KERNEL ); +if (s) { +strncpy (s, name, len);
Would it be better to use kmalloc instead of kzalloc, call memcpy instead of strncpy, and write the terminating NUL character manually?
Quoted 8 lines
drivers/base/power/wakeup.c +8
-0+ ws->name = s; + } + } + +return ws; +} +EXPORT_SYMBOL_GPL (wakeup_source_create); +
drivers/base/power/wakeup.c line 72
Quoted 10 lines
drivers/base/power/wakeup.c +10
-0+/** +* wakeup_source_destroy - Destroy a struct wakeup_source object. +* @ws: Wakeup source to destroy. +*/ +void wakeup_source_destroy (struct wakeup_source *ws) +{ +if (!ws) +return ; + +spin_lock_irq (&ws->lock);
Since you use the spinlock here, it needs to be initialized in wakeup_source_create rather than wakeup_source_register.
drivers/base/power/wakeup.c line 83
Quoted 11 lines
drivers/base/power/wakeup.c +11
-0+while (ws->active) { +spin_unlock_irq (&ws->lock); + +schedule_timeout_interruptible (msecs_to_jiffies (TIMEOUT )); + +spin_lock_irq (&ws->lock); + } +spin_unlock_irq (&ws->lock); + +if (ws->name) +kfree (ws->name);
No need for the "if".
Quoted 23 lines
drivers/base/power/wakeup.c +23
-0+kfree (ws); +} +EXPORT_SYMBOL_GPL (wakeup_source_destroy); + +/** +* wakeup_source_register - Add given object to the list of wakeup sources. +* @ws: Wakeup source object to register. +*/ +void wakeup_source_register (struct wakeup_source *ws) +{ +if (WARN_ON (!ws)) +return ; + +spin_lock_init (&ws->lock); +setup_timer (&ws->timer, pm_wakeup_timer_fn, (unsigned long )ws); + ws->active = false; + +spin_lock_irq (&events_lock); +list_add_rcu (&ws->entry, &wakeup_sources); +spin_unlock_irq (&events_lock); +synchronize_rcu (); +} +EXPORT_SYMBOL_GPL (wakeup_source_register);
...
Quoted 5 lines
drivers/base/power/wakeup.c +5
-0+/** +* wakeup_source_add - Create and register a wakeup source object. +* @name: Name of the wakeup source to create. +*/ +struct wakeup_source *wakeup_source_add (const char *name)
drivers/base/power/wakeup.c line 138
Quoted 10 lines
drivers/base/power/wakeup.c +10
-0+{ +struct wakeup_source *ws; + + ws =wakeup_source_create (name); +if (ws) +wakeup_source_register (ws); + +return ws; +} +EXPORT_SYMBOL_GPL (wakeup_source_add);
Your use of names is backward. Normally the *_register routine does *_init followed by *_add.
I haven't looked through the rest in enough detail yet to make any meaningful comments.
Alan Stern
Re: [RFC][PATCH] PM / Wakeup: Introduce wakeup source objects and event statistics (was: Re: Wakeup-events implementation)
In reply to Rafael J. WysockiQuoted 5 lines · Rafael J. Wysocki
Hi,
Below is a patch that adds some statistics to the previously merged pm_wakeup_event()/pm_stay_awake()/pm_relax() code. It also makes it possible to use wakeup sources that are not directly associated with devices.
I noted only a few things during a quick read-through. See below.
Quoted 6 lines
It adds functions for manipulating wakeup source objects and reworks the device wakeup enabling/disabling to use the new functions. The list of wakeup sources is only used for updating the "hit count" statistics for now (this is the number of times the wakeup source was active when the PM core checked), but I'm planning to add a /proc file listing all wakeup sources, including the ones that are not attached to device objects.
It must be obvious that this is starting to look more and more like the suspend_blockers patch. What that means or will lead to, I don't know...
Quoted 4 lines
It appears to work with the PCI wakeup code added previously, but that's only one case. I'm also not sure if it builds withoug
CONFIG_PM_SLEEP. [BTW, I'm not sure itatomic_inc()andatomic_dec()imply a memory barrier in general. That seems to be the case on x86, but I don't know about other architectures.]
They do not imply memory barriers. See the section on atomic operations in Documentation/memory-barriers.txt.
Quoted 7 lines
drivers/base/power/wakeup.c +7
-0+/** +* wakeup_source_create - Create a struct wakeup_source object. +* @name: Name of the new wakeup source. +*/ +struct wakeup_source *wakeup_source_create (const char *name) +{ +struct wakeup_source *ws;
drivers/base/power/wakeup.c line 54
Quoted 10 lines
drivers/base/power/wakeup.c +10
-0+ + ws =kzalloc (sizeof (*ws),GFP_KERNEL ); +if (!ws) +return NULL ; + +if (name) { +int len =strlen (name); +char *s =kzalloc (len +1 ,GFP_KERNEL ); +if (s) { +strncpy (s, name, len);
Would it be better to use kmalloc instead of kzalloc, call memcpy instead of strncpy, and write the terminating NUL character manually?
Quoted 8 lines
drivers/base/power/wakeup.c +8
-0+ ws->name = s; + } + } + +return ws; +} +EXPORT_SYMBOL_GPL (wakeup_source_create); +
drivers/base/power/wakeup.c line 72
Quoted 10 lines
drivers/base/power/wakeup.c +10
-0+/** +* wakeup_source_destroy - Destroy a struct wakeup_source object. +* @ws: Wakeup source to destroy. +*/ +void wakeup_source_destroy (struct wakeup_source *ws) +{ +if (!ws) +return ; + +spin_lock_irq (&ws->lock);
Since you use the spinlock here, it needs to be initialized in wakeup_source_create rather than wakeup_source_register.
drivers/base/power/wakeup.c line 83
Quoted 11 lines
drivers/base/power/wakeup.c +11
-0+while (ws->active) { +spin_unlock_irq (&ws->lock); + +schedule_timeout_interruptible (msecs_to_jiffies (TIMEOUT )); + +spin_lock_irq (&ws->lock); + } +spin_unlock_irq (&ws->lock); + +if (ws->name) +kfree (ws->name);
No need for the "if".
Quoted 23 lines
drivers/base/power/wakeup.c +23
-0+kfree (ws); +} +EXPORT_SYMBOL_GPL (wakeup_source_destroy); + +/** +* wakeup_source_register - Add given object to the list of wakeup sources. +* @ws: Wakeup source object to register. +*/ +void wakeup_source_register (struct wakeup_source *ws) +{ +if (WARN_ON (!ws)) +return ; + +spin_lock_init (&ws->lock); +setup_timer (&ws->timer, pm_wakeup_timer_fn, (unsigned long )ws); + ws->active = false; + +spin_lock_irq (&events_lock); +list_add_rcu (&ws->entry, &wakeup_sources); +spin_unlock_irq (&events_lock); +synchronize_rcu (); +} +EXPORT_SYMBOL_GPL (wakeup_source_register);
...
Quoted 5 lines
drivers/base/power/wakeup.c +5
-0+/** +* wakeup_source_add - Create and register a wakeup source object. +* @name: Name of the wakeup source to create. +*/ +struct wakeup_source *wakeup_source_add (const char *name)
drivers/base/power/wakeup.c line 138
Quoted 10 lines
drivers/base/power/wakeup.c +10
-0+{ +struct wakeup_source *ws; + + ws =wakeup_source_create (name); +if (ws) +wakeup_source_register (ws); + +return ws; +} +EXPORT_SYMBOL_GPL (wakeup_source_add);
Your use of names is backward. Normally the *_register routine does *_init followed by *_add.
I haven't looked through the rest in enough detail yet to make any meaningful comments.
Alan Stern
Re: [RFC][PATCH] PM / Wakeup: Introduce wakeup source objects and event statistics (was: Re: Wakeup-events implementation)
Quoted 9 lines · Alan Stern
Quoted 5 lines · Rafael J. Wysocki
Hi,
Below is a patch that adds some statistics to the previously merged pm_wakeup_event()/pm_stay_awake()/pm_relax() code. It also makes it possible to use wakeup sources that are not directly associated with devices.
I noted only a few things during a quick read-through.
Great. :-)
Quoted 9 lines
See below.
Quoted 6 lines
It adds functions for manipulating wakeup source objects and reworks the device wakeup enabling/disabling to use the new functions. The list of wakeup sources is only used for updating the "hit count" statistics for now (this is the number of times the wakeup source was active when the PM core checked), but I'm planning to add a /proc file listing all wakeup sources, including the ones that are not attached to device objects.
Quoted 3 lines
It must be obvious that this is starting to look more and more like the
suspend_blockerspatch. What that means or will lead to, I don't know...
This actually is intentional, because I want to make it easier for the Android people to move their stuff towards the mainline, if they want to.
Quoted 7 lines
Quoted 4 lines
It appears to work with the PCI wakeup code added previously, but that's only one case. I'm also not sure if it builds withoug
CONFIG_PM_SLEEP. [BTW, I'm not sure itatomic_inc()andatomic_dec()imply a memory barrier in general. That seems to be the case on x86, but I don't know about other architectures.]They do not imply memory barriers. See the section on atomic operations in
Documentation/memory-barriers.txt.
Ah. Thanks for the pointer.
Quoted 12 lines
Quoted 12 lines
drivers/base/power/wakeup.c +12
-0+/** +* wakeup_source_create - Create a struct wakeup_source object. +* @name: Name of the new wakeup source. +*/ +struct wakeup_source *wakeup_source_create (const char *name) +{ +struct wakeup_source *ws; + + ws =kzalloc (sizeof (*ws),GFP_KERNEL ); +if (!ws) +return NULL ; +
Quoted 8 lines
drivers/base/power/wakeup.c line 54
Quoted 5 lines
drivers/base/power/wakeup.c +5
-0+if (name) { +int len =strlen (name); +char *s =kzalloc (len +1 ,GFP_KERNEL ); +if (s) { +strncpy (s, name, len);Would it be better to use kmalloc instead of kzalloc, call memcpy instead of strncpy, and write the terminating NUL character manually?
Yeah, thanks.
Quoted 13 lines
Quoted 13 lines
drivers/base/power/wakeup.c +13
-0+ ws->name = s; + } + } + +return ws; +} +EXPORT_SYMBOL_GPL (wakeup_source_create); + +/** +* wakeup_source_destroy - Destroy a struct wakeup_source object. +* @ws: Wakeup source to destroy. +*/ +void wakeup_source_destroy (struct wakeup_source *ws)
Quoted 8 lines
drivers/base/power/wakeup.c line 72
Quoted 5 lines
drivers/base/power/wakeup.c +5
-0+{ +if (!ws) +return ; + +spin_lock_irq (&ws->lock);Since you use the spinlock here, it needs to be initialized in
wakeup_source_createrather thanwakeup_source_register.
Yes, thanks.
Quoted 5 lines
Quoted 5 lines
drivers/base/power/wakeup.c +5
-0+while (ws->active) { +spin_unlock_irq (&ws->lock); + +schedule_timeout_interruptible (msecs_to_jiffies (TIMEOUT )); +
Quoted 8 lines
drivers/base/power/wakeup.c line 83
Quoted 6 lines
drivers/base/power/wakeup.c +6
-0+spin_lock_irq (&ws->lock); + } +spin_unlock_irq (&ws->lock); + +if (ws->name) +kfree (ws->name);No need for the "if".
OK
Quoted 36 lines
Quoted 23 lines
drivers/base/power/wakeup.c +23
-0+kfree (ws); +} +EXPORT_SYMBOL_GPL (wakeup_source_destroy); + +/** +* wakeup_source_register - Add given object to the list of wakeup sources. +* @ws: Wakeup source object to register. +*/ +void wakeup_source_register (struct wakeup_source *ws) +{ +if (WARN_ON (!ws)) +return ; + +spin_lock_init (&ws->lock); +setup_timer (&ws->timer, pm_wakeup_timer_fn, (unsigned long )ws); + ws->active = false; + +spin_lock_irq (&events_lock); +list_add_rcu (&ws->entry, &wakeup_sources); +spin_unlock_irq (&events_lock); +synchronize_rcu (); +} +EXPORT_SYMBOL_GPL (wakeup_source_register);...
Quoted 10 lines
drivers/base/power/wakeup.c +10
-0+/** +* wakeup_source_add - Create and register a wakeup source object. +* @name: Name of the wakeup source to create. +*/ +struct wakeup_source *wakeup_source_add (const char *name) +{ +struct wakeup_source *ws; + + ws =wakeup_source_create (name); +if (ws)
Quoted 8 lines
drivers/base/power/wakeup.c line 138
Quoted 5 lines
drivers/base/power/wakeup.c +5
-0+wakeup_source_register (ws); + +return ws; +} +EXPORT_SYMBOL_GPL (wakeup_source_add);Your use of names is backward. Normally the
*_registerroutine does*_initfollowed by*_add.
Hmm, I haven't noticed that. Thanks for the heads up. :-)
Quoted 2 lines
I haven't looked through the rest in enough detail yet to make any meaningful comments.
Sure. Thanks a lot for your comments so far!
Rafael
Re: [RFC][PATCH] PM / Wakeup: Introduce wakeup source objects and event statistics (was: Re: Wakeup-events implementation)
In reply to Rafael J. WysockiQuoted 9 lines · Rafael J. Wysocki
drivers/base/power/wakeup.c +9
-0+struct wakeup_source *wakeup_source_create (const char *name) +{ +struct wakeup_source *ws; + + ws =kzalloc (sizeof (*ws),GFP_KERNEL ); +if (!ws) +return NULL ; + +if (name) {
drivers/base/power/wakeup.c line 60
Quoted 10 lines
drivers/base/power/wakeup.c +10
-0+int len =strlen (name); +char *s =kzalloc (len +1 ,GFP_KERNEL ); +if (s) { +strncpy (s, name, len); + ws->name = s; + } + } + +return ws; +}
Forget what I wrote earlier; it was stupid. Just use kstrdup.
Alan Stern
Re: [RFC][PATCH] PM / Wakeup: Introduce wakeup source objects and event statistics (was: Re: Wakeup-events implementation)
In reply to Rafael J. WysockiQuoted 9 lines · Rafael J. Wysocki
drivers/base/power/wakeup.c +9
-0+struct wakeup_source *wakeup_source_create (const char *name) +{ +struct wakeup_source *ws; + + ws =kzalloc (sizeof (*ws),GFP_KERNEL ); +if (!ws) +return NULL ; + +if (name) {
drivers/base/power/wakeup.c line 60
Quoted 10 lines
drivers/base/power/wakeup.c +10
-0+int len =strlen (name); +char *s =kzalloc (len +1 ,GFP_KERNEL ); +if (s) { +strncpy (s, name, len); + ws->name = s; + } + } + +return ws; +}
Forget what I wrote earlier; it was stupid. Just use kstrdup.
Alan Stern
Re: [RFC][PATCH] PM / Wakeup: Introduce wakeup source objects and event statistics (was: Re: Wakeup-events implementation)
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Alan Stern
Quoted 13 lines · Rafael J. Wysocki
drivers/base/power/wakeup.c +13
-0+struct wakeup_source *wakeup_source_create (const char *name) +{ +struct wakeup_source *ws; + + ws =kzalloc (sizeof (*ws),GFP_KERNEL ); +if (!ws) +return NULL ; + +if (name) { +int len =strlen (name); +char *s =kzalloc (len +1 ,GFP_KERNEL ); +if (s) { +strncpy (s, name, len);
Quoted 8 lines
Quoted 8 lines
drivers/base/power/wakeup.c line 60
Quoted 6 lines
drivers/base/power/wakeup.c +6
-0+ ws->name = s; + } + } + +return ws; +}Forget what I wrote earlier; it was stupid. Just use kstrdup.
Right, I didn't know it existed. :-)
Thanks,
Rafael
Re: [RFC][PATCH] PM / Wakeup: Introduce wakeup source objects and event statistics (was: Re: Wakeup-events implementation)
In reply to Alan SternQuoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Alan Stern
Quoted 13 lines · Rafael J. Wysocki
drivers/base/power/wakeup.c +13
-0+struct wakeup_source *wakeup_source_create (const char *name) +{ +struct wakeup_source *ws; + + ws =kzalloc (sizeof (*ws),GFP_KERNEL ); +if (!ws) +return NULL ; + +if (name) { +int len =strlen (name); +char *s =kzalloc (len +1 ,GFP_KERNEL ); +if (s) { +strncpy (s, name, len);
Quoted 8 lines
Quoted 8 lines
drivers/base/power/wakeup.c line 60
Quoted 6 lines
drivers/base/power/wakeup.c +6
-0+ ws->name = s; + } + } + +return ws; +}Forget what I wrote earlier; it was stupid. Just use kstrdup.
Right, I didn't know it existed. :-)
Thanks,
Rafael
PM / Wakeup: Introduce wakeup source objects and event statistics (v2)
Quoted 26 lines · Rafael J. Wysocki
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Alan Stern
Quoted 13 lines · Rafael J. Wysocki
(quoted diff) +13
-0+struct wakeup_source *wakeup_source_create(const char *name) +{ + struct wakeup_source *ws; + + ws = kzalloc(sizeof(*ws), GFP_KERNEL); + if (!ws) + return NULL; + + if (name) { + int len = strlen(name); + char *s = kzalloc(len + 1, GFP_KERNEL); + if (s) { + strncpy(s, name, len);Quoted 8 lines
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ ws->name = s; + } + } + + return ws; +}Forget what I wrote earlier; it was stupid. Just use kstrdup.
Quoted 1 line
Right, I didn't know it existed. :-)
Below is a new version of the patch with your comments addressed (hopefully) and a few unrelated fixes, and some documentation.
Thanks,
Rafael
---
From: Rafael J. Wysocki <[email protected]>
Subject: PM / Wakeup: Introduce wakeup source objects and event statistics (v2)
Introduce struct wakeup_source for representing system wakeup sources within the kernel and for collecting statistics related to them. Make the recently introduced helper functions pm_wakeup_event(), pm_stay_awake() and pm_relax() use struct wakeup_source objects internally, so that wakeup statistics associated with wakeup devices can be collected and reported in a consistent way (the definition of pm_relax() is changed, which is harmless, because this function is not called directly by anyone yet). Introduce new wakeup-related sysfs device attributes in /sys/devices/.../power for reporting the device wakeup statistics.
Change the global wakeup events counters event_count and events_in_progress into atomic variables, so that it is not necessary to acquire a global spinlock in pm_wakeup_event(), pm_stay_awake() and pm_relax(), which should allow us to avoid lock contention in these functions on SMP systems with many wakeup devices.
--- Documentation/ABI/testing/sysfs-devices-power | 70 +++ drivers/base/power/main.c | 4 drivers/base/power/power.h | 1 drivers/base/power/runtime.c | 2 drivers/base/power/sysfs.c | 121 +++++ drivers/base/power/wakeup.c | 534 ++++++++++++++++++++++---- include/linux/pm.h | 16 include/linux/pm_wakeup.h | 126 ++++-- include/linux/suspend.h | 4 kernel/power/main.c | 8 10 files changed, 757 insertions(+), 129 deletions(-)
include/linux/pm_wakeup.h +101 -25
@@ -2,6 +2,7 @@* pm_wakeup.h - Power management wakeup interface * * Copyright (C) 2008 Alan Stern +* Copyright (C) 2010 Rafael J. Wysocki, Novell Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -27,18 +28,39 @@#include <linux/types.h> -#ifdef CONFIG_PM - -/* Changes to device_may_wakeup take effect on the next pm state change. +/** +* struct wakeup_source - Representation of wakeup sources * -* By default, most devices should leave wakeup disabled. The exceptions -* are devices that everyone expects to be wakeup sources: keyboards, -* power buttons, possibly network interfaces, etc. +* @total_time: Total time this wakeup source has been active. +* @max_time: Maximum time this wakeup source has been continuously active. +* @last_time: Monotonic clock when the wakeup source's was activated last time. +* @event_count: Number of signaled wakeup events. +* @active_count: Number of times the wakeup sorce was activated. +* @relax_count: Number of times the wakeup sorce was deactivated. +* @hit_count: Number of times the wakeup sorce might abort system suspend. +* @active: Status of the wakeup source. +*/ +struct wakeup_source { +char *name; +struct list_head entry; +spinlock_t lock; +struct timer_list timer; +unsigned long timer_expires; +ktime_t total_time; +ktime_t max_time; +ktime_t last_time; +unsigned long event_count; +unsigned long active_count; +unsigned long relax_count; +unsigned long hit_count; +unsigned int active:1 ; +}; + +#ifdef CONFIG_PM_SLEEP + +/* +* Changes to device_may_wakeup take effect on the next pm state change. */ -static inline void device_init_wakeup (struct device *dev,bool val) -{ - dev->power.can_wakeup = dev->power.should_wakeup = val; -}static inline void device_set_wakeup_capable (struct device *dev,bool capable) {
@@ -50,23 +72,32 @@ static inline bool device_can_wakeup(strreturn dev->power.can_wakeup; } -static inline void device_set_wakeup_enable (struct device *dev,bool enable) -{ - dev->power.should_wakeup = enable; -} +static inline bool device_may_wakeup (struct device *dev) { -return dev->power.can_wakeup && dev->power.should_wakeup; +return dev->power.can_wakeup && !!dev->power.wakeup; } -#else /* !CONFIG_PM */ +/* drivers/base/power/wakeup.c */ +extern struct wakeup_source *wakeup_source_create (const char *name); +extern void wakeup_source_destroy (struct wakeup_source *ws); +extern void wakeup_source_add (struct wakeup_source *ws); +extern void wakeup_source_remove (struct wakeup_source *ws); +extern struct wakeup_source *wakeup_source_register (const char *name); +extern void wakeup_source_unregister (struct wakeup_source *ws); +extern int device_wakeup_enable (struct device *dev); +extern int device_wakeup_disable (struct device *dev); +extern int device_init_wakeup (struct device *dev,bool val); +extern int device_set_wakeup_enable (struct device *dev,bool enable); +extern void __pm_stay_awake (struct wakeup_source *ws); +extern void pm_stay_awake (struct device *dev); +extern void __pm_relax (struct wakeup_source *ws); +extern void pm_relax (struct device *dev); +extern void __pm_wakeup_event (struct wakeup_source *ws,unsigned int msec); +extern void pm_wakeup_event (struct device *dev,unsigned int msec); -/* For some reason the following routines work even without CONFIG_PM */ -static inline void device_init_wakeup (struct device *dev,bool val) -{ - dev->power.can_wakeup = val; -} +#else /* !CONFIG_PM_SLEEP */ static inline void device_set_wakeup_capable (struct device *dev,bool capable) {
@@ -78,15 +109,60 @@ static inline bool device_can_wakeup(strreturn dev->power.can_wakeup; } -static inline void device_set_wakeup_enable (struct device *dev,bool enable) +static inline bool device_may_wakeup (struct device *dev) { +return false; } -static inline bool device_may_wakeup (struct device *dev) +static inline struct wakeup_source *wakeup_source_create (const char *name) { -return false; +return NULL ; } -#endif /* !CONFIG_PM */ +static inline void wakeup_source_destroy (struct wakeup_source *ws) {} + +static inline void wakeup_source_add (struct wakeup_source *ws) {} + +static inline void wakeup_source_remove (struct wakeup_source *ws) {} + +static inline struct wakeup_source *wakeup_source_register (const char *name) +{ +return NULL ; +} + +static inline void wakeup_source_unregister (struct wakeup_source *ws) {} + +static inline int device_wakeup_enable (struct device *dev) +{ +return -EINVAL ; +} + +static inline int device_wakeup_disable (struct device *dev) {} + +static inline int device_init_wakeup (struct device *dev,bool val) +{ + dev->power.can_wakeup = val; +return val ? -EINVAL :0 ; +} + + +static inline int device_set_wakeup_enable (struct device *dev,bool enable) +{ +return -EINVAL ; +} + +static inline void __pm_stay_awake (struct wakeup_source *ws) {} + +static inline void pm_stay_awake (struct device *dev) {} + +static inline void __pm_relax (struct wakeup_source *ws) {} + +static inline void pm_relax (struct device *dev) {} + +static inline void __pm_wakeup_event (struct wakeup_source *ws,unsigned int msec) {} + +static inline void pm_wakeup_event (struct device *dev,unsigned int msec) {} + +#endif /* !CONFIG_PM_SLEEP */ #endif /* _LINUX_PM_WAKEUP_H */
include/linux/pm.h +4 -12
@@ -448,23 +448,24 @@ enum rpm_request { RPM_REQ_RESUME, }; +struct wakeup_source ; +struct dev_pm_info {pm_message_t power_state;unsigned int can_wakeup:1 ; -unsigned int should_wakeup:1 ;unsigned async_suspend:1 ;enum dpm_state status;/* Owned by the PM core */ +spinlock_t lock;#ifdef CONFIG_PM_SLEEP struct list_head entry;struct completion completion; -unsigned long wakeup_count; +struct wakeup_source *wakeup;#endif #ifdef CONFIG_PM_RUNTIME struct timer_list suspend_timer;unsigned long timer_expires;struct work_struct work;wait_queue_head_t wait_queue; -spinlock_t lock;atomic_t usage_count;atomic_t child_count;unsigned int disable_depth:3 ;
@@ -559,11 +560,6 @@ extern void __suspend_report_result(cons } while (0) extern void device_pm_wait_for_dev(struct device *sub, struct device *dev); - -/* drivers/base/power/wakeup.c */ -extern void pm_wakeup_event (struct device *dev,unsigned int msec); -extern void pm_stay_awake (struct device *dev); -extern void pm_relax (void );#else /* !CONFIG_PM_SLEEP */ #define device_pm_lock () do {} while (0)
@@ -577,10 +573,6 @@ static inline int dpm_suspend_start(pm_m#define suspend_report_result (fn, ret) do {} while (0)static inline void device_pm_wait_for_dev (struct device *a,struct device *b) {} - -static inline void pm_wakeup_event (struct device *dev,unsigned int msec) {} -static inline void pm_stay_awake (struct device *dev) {} -static inline void pm_relax (void ) {}#endif /* !CONFIG_PM_SLEEP */ /* How to reorder dpm_list after device_move() */
drivers/base/power/wakeup.c +453 -81
646 lines not on this page · raw message
drivers/base/power/main.c +3 -1
@@ -60,7 +60,8 @@ void device_pm_init(struct device *dev) dev->power.status =DPM_ON ;init_completion (&dev->power.completion);complete_all (&dev->power.completion); - dev->power.wakeup_count =0 ; + dev->power.wakeup =NULL ; +spin_lock_init (&dev->power.lock);pm_runtime_init (dev); }
@@ -120,6 +121,7 @@ void device_pm_remove(struct device *devmutex_lock (&dpm_list_mtx);list_del_init (&dev->power.entry);mutex_unlock (&dpm_list_mtx); +device_wakeup_disable (dev);pm_runtime_remove (dev); }
drivers/base/power/power.h +1 -0
@@ -34,6 +34,7 @@ extern void device_pm_move_last(struct dstatic inline void device_pm_init (struct device *dev) { +spin_lock_init (&dev->power.lock);pm_runtime_init (dev); }
drivers/base/power/runtime.c +0 -2
@@ -1099,8 +1099,6 @@ EXPORT_SYMBOL_GPL(pm_runtime_allow);*/ void pm_runtime_init (struct device *dev) { -spin_lock_init (&dev->power.lock); - dev->power.runtime_status =RPM_SUSPENDED ; dev->power.idle_notification = false;
include/linux/suspend.h +2 -2
@@ -302,8 +302,8 @@ extern int unregister_pm_notifier(structextern bool events_check_enabled;extern bool pm_check_wakeup_events (void ); -extern bool pm_get_wakeup_count (unsigned long *count); -extern bool pm_save_wakeup_count (unsigned long count); +extern bool pm_get_wakeup_count (unsigned int *count); +extern bool pm_save_wakeup_count (unsigned int count);#else /* !CONFIG_PM_SLEEP */ static inline int register_pm_notifier (struct notifier_block *nb)
kernel/power/main.c +4 -4
@@ -237,18 +237,18 @@ static ssize_t wakeup_count_show(structstruct kobj_attribute *attr, char *buf) { - unsigned long val; + unsigned int val; -return pm_get_wakeup_count (&val) ?sprintf (buf,"%lu\n" , val) : -EINTR ; +return pm_get_wakeup_count (&val) ?sprintf (buf,"%u\n" , val) : -EINTR ; }static ssize_t wakeup_count_store (struct kobject *kobj,struct kobj_attribute *attr,const char *buf,size_t n) { -unsigned long val; +unsigned int val; -if (sscanf (buf,"%lu" , &val) ==1 ) { +if (sscanf (buf,"%u" , &val) ==1 ) {if (pm_save_wakeup_count (val))return n; }
drivers/base/power/sysfs.c +119 -2
136 lines not on this page · raw message
Documentation/ABI/testing/sysfs-devices-power +70 -0
73 lines not on this page · raw message
PM / Wakeup: Introduce wakeup source objects and event statistics (v2)
In reply to Rafael J. WysockiQuoted 26 lines · Rafael J. Wysocki
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Alan Stern
Quoted 13 lines · Rafael J. Wysocki
(quoted diff) +13
-0+struct wakeup_source *wakeup_source_create(const char *name) +{ + struct wakeup_source *ws; + + ws = kzalloc(sizeof(*ws), GFP_KERNEL); + if (!ws) + return NULL; + + if (name) { + int len = strlen(name); + char *s = kzalloc(len + 1, GFP_KERNEL); + if (s) { + strncpy(s, name, len);Quoted 8 lines
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ ws->name = s; + } + } + + return ws; +}Forget what I wrote earlier; it was stupid. Just use kstrdup.
Quoted 1 line
Right, I didn't know it existed. :-)
Below is a new version of the patch with your comments addressed (hopefully) and a few unrelated fixes, and some documentation.
Thanks,
Rafael
---
From: Rafael J. Wysocki <[email protected]>
Subject: PM / Wakeup: Introduce wakeup source objects and event statistics (v2)
Introduce struct wakeup_source for representing system wakeup sources within the kernel and for collecting statistics related to them. Make the recently introduced helper functions pm_wakeup_event(), pm_stay_awake() and pm_relax() use struct wakeup_source objects internally, so that wakeup statistics associated with wakeup devices can be collected and reported in a consistent way (the definition of pm_relax() is changed, which is harmless, because this function is not called directly by anyone yet). Introduce new wakeup-related sysfs device attributes in /sys/devices/.../power for reporting the device wakeup statistics.
Change the global wakeup events counters event_count and events_in_progress into atomic variables, so that it is not necessary to acquire a global spinlock in pm_wakeup_event(), pm_stay_awake() and pm_relax(), which should allow us to avoid lock contention in these functions on SMP systems with many wakeup devices.
--- Documentation/ABI/testing/sysfs-devices-power | 70 +++ drivers/base/power/main.c | 4 drivers/base/power/power.h | 1 drivers/base/power/runtime.c | 2 drivers/base/power/sysfs.c | 121 +++++ drivers/base/power/wakeup.c | 534 ++++++++++++++++++++++---- include/linux/pm.h | 16 include/linux/pm_wakeup.h | 126 ++++-- include/linux/suspend.h | 4 kernel/power/main.c | 8 10 files changed, 757 insertions(+), 129 deletions(-)
include/linux/pm_wakeup.h +101 -25
@@ -2,6 +2,7 @@* pm_wakeup.h - Power management wakeup interface * * Copyright (C) 2008 Alan Stern +* Copyright (C) 2010 Rafael J. Wysocki, Novell Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -27,18 +28,39 @@#include <linux/types.h> -#ifdef CONFIG_PM - -/* Changes to device_may_wakeup take effect on the next pm state change. +/** +* struct wakeup_source - Representation of wakeup sources * -* By default, most devices should leave wakeup disabled. The exceptions -* are devices that everyone expects to be wakeup sources: keyboards, -* power buttons, possibly network interfaces, etc. +* @total_time: Total time this wakeup source has been active. +* @max_time: Maximum time this wakeup source has been continuously active. +* @last_time: Monotonic clock when the wakeup source's was activated last time. +* @event_count: Number of signaled wakeup events. +* @active_count: Number of times the wakeup sorce was activated. +* @relax_count: Number of times the wakeup sorce was deactivated. +* @hit_count: Number of times the wakeup sorce might abort system suspend. +* @active: Status of the wakeup source. +*/ +struct wakeup_source { +char *name; +struct list_head entry; +spinlock_t lock; +struct timer_list timer; +unsigned long timer_expires; +ktime_t total_time; +ktime_t max_time; +ktime_t last_time; +unsigned long event_count; +unsigned long active_count; +unsigned long relax_count; +unsigned long hit_count; +unsigned int active:1 ; +}; + +#ifdef CONFIG_PM_SLEEP + +/* +* Changes to device_may_wakeup take effect on the next pm state change. */ -static inline void device_init_wakeup (struct device *dev,bool val) -{ - dev->power.can_wakeup = dev->power.should_wakeup = val; -}static inline void device_set_wakeup_capable (struct device *dev,bool capable) {
@@ -50,23 +72,32 @@ static inline bool device_can_wakeup(strreturn dev->power.can_wakeup; } -static inline void device_set_wakeup_enable (struct device *dev,bool enable) -{ - dev->power.should_wakeup = enable; -} +static inline bool device_may_wakeup (struct device *dev) { -return dev->power.can_wakeup && dev->power.should_wakeup; +return dev->power.can_wakeup && !!dev->power.wakeup; } -#else /* !CONFIG_PM */ +/* drivers/base/power/wakeup.c */ +extern struct wakeup_source *wakeup_source_create (const char *name); +extern void wakeup_source_destroy (struct wakeup_source *ws); +extern void wakeup_source_add (struct wakeup_source *ws); +extern void wakeup_source_remove (struct wakeup_source *ws); +extern struct wakeup_source *wakeup_source_register (const char *name); +extern void wakeup_source_unregister (struct wakeup_source *ws); +extern int device_wakeup_enable (struct device *dev); +extern int device_wakeup_disable (struct device *dev); +extern int device_init_wakeup (struct device *dev,bool val); +extern int device_set_wakeup_enable (struct device *dev,bool enable); +extern void __pm_stay_awake (struct wakeup_source *ws); +extern void pm_stay_awake (struct device *dev); +extern void __pm_relax (struct wakeup_source *ws); +extern void pm_relax (struct device *dev); +extern void __pm_wakeup_event (struct wakeup_source *ws,unsigned int msec); +extern void pm_wakeup_event (struct device *dev,unsigned int msec); -/* For some reason the following routines work even without CONFIG_PM */ -static inline void device_init_wakeup (struct device *dev,bool val) -{ - dev->power.can_wakeup = val; -} +#else /* !CONFIG_PM_SLEEP */ static inline void device_set_wakeup_capable (struct device *dev,bool capable) {
@@ -78,15 +109,60 @@ static inline bool device_can_wakeup(strreturn dev->power.can_wakeup; } -static inline void device_set_wakeup_enable (struct device *dev,bool enable) +static inline bool device_may_wakeup (struct device *dev) { +return false; } -static inline bool device_may_wakeup (struct device *dev) +static inline struct wakeup_source *wakeup_source_create (const char *name) { -return false; +return NULL ; } -#endif /* !CONFIG_PM */ +static inline void wakeup_source_destroy (struct wakeup_source *ws) {} + +static inline void wakeup_source_add (struct wakeup_source *ws) {} + +static inline void wakeup_source_remove (struct wakeup_source *ws) {} + +static inline struct wakeup_source *wakeup_source_register (const char *name) +{ +return NULL ; +} + +static inline void wakeup_source_unregister (struct wakeup_source *ws) {} + +static inline int device_wakeup_enable (struct device *dev) +{ +return -EINVAL ; +} + +static inline int device_wakeup_disable (struct device *dev) {} + +static inline int device_init_wakeup (struct device *dev,bool val) +{ + dev->power.can_wakeup = val; +return val ? -EINVAL :0 ; +} + + +static inline int device_set_wakeup_enable (struct device *dev,bool enable) +{ +return -EINVAL ; +} + +static inline void __pm_stay_awake (struct wakeup_source *ws) {} + +static inline void pm_stay_awake (struct device *dev) {} + +static inline void __pm_relax (struct wakeup_source *ws) {} + +static inline void pm_relax (struct device *dev) {} + +static inline void __pm_wakeup_event (struct wakeup_source *ws,unsigned int msec) {} + +static inline void pm_wakeup_event (struct device *dev,unsigned int msec) {} + +#endif /* !CONFIG_PM_SLEEP */ #endif /* _LINUX_PM_WAKEUP_H */
include/linux/pm.h +4 -12
@@ -448,23 +448,24 @@ enum rpm_request { RPM_REQ_RESUME, }; +struct wakeup_source ; +struct dev_pm_info {pm_message_t power_state;unsigned int can_wakeup:1 ; -unsigned int should_wakeup:1 ;unsigned async_suspend:1 ;enum dpm_state status;/* Owned by the PM core */ +spinlock_t lock;#ifdef CONFIG_PM_SLEEP struct list_head entry;struct completion completion; -unsigned long wakeup_count; +struct wakeup_source *wakeup;#endif #ifdef CONFIG_PM_RUNTIME struct timer_list suspend_timer;unsigned long timer_expires;struct work_struct work;wait_queue_head_t wait_queue; -spinlock_t lock;atomic_t usage_count;atomic_t child_count;unsigned int disable_depth:3 ;
@@ -559,11 +560,6 @@ extern void __suspend_report_result(cons } while (0) extern void device_pm_wait_for_dev(struct device *sub, struct device *dev); - -/* drivers/base/power/wakeup.c */ -extern void pm_wakeup_event (struct device *dev,unsigned int msec); -extern void pm_stay_awake (struct device *dev); -extern void pm_relax (void );#else /* !CONFIG_PM_SLEEP */ #define device_pm_lock () do {} while (0)
@@ -577,10 +573,6 @@ static inline int dpm_suspend_start(pm_m#define suspend_report_result (fn, ret) do {} while (0)static inline void device_pm_wait_for_dev (struct device *a,struct device *b) {} - -static inline void pm_wakeup_event (struct device *dev,unsigned int msec) {} -static inline void pm_stay_awake (struct device *dev) {} -static inline void pm_relax (void ) {}#endif /* !CONFIG_PM_SLEEP */ /* How to reorder dpm_list after device_move() */
drivers/base/power/wakeup.c +453 -81
646 lines not on this page · raw message
drivers/base/power/main.c +3 -1
@@ -60,7 +60,8 @@ void device_pm_init(struct device *dev) dev->power.status =DPM_ON ;init_completion (&dev->power.completion);complete_all (&dev->power.completion); - dev->power.wakeup_count =0 ; + dev->power.wakeup =NULL ; +spin_lock_init (&dev->power.lock);pm_runtime_init (dev); }
@@ -120,6 +121,7 @@ void device_pm_remove(struct device *devmutex_lock (&dpm_list_mtx);list_del_init (&dev->power.entry);mutex_unlock (&dpm_list_mtx); +device_wakeup_disable (dev);pm_runtime_remove (dev); }
drivers/base/power/power.h +1 -0
@@ -34,6 +34,7 @@ extern void device_pm_move_last(struct dstatic inline void device_pm_init (struct device *dev) { +spin_lock_init (&dev->power.lock);pm_runtime_init (dev); }
drivers/base/power/runtime.c +0 -2
@@ -1099,8 +1099,6 @@ EXPORT_SYMBOL_GPL(pm_runtime_allow);*/ void pm_runtime_init (struct device *dev) { -spin_lock_init (&dev->power.lock); - dev->power.runtime_status =RPM_SUSPENDED ; dev->power.idle_notification = false;
include/linux/suspend.h +2 -2
@@ -302,8 +302,8 @@ extern int unregister_pm_notifier(structextern bool events_check_enabled;extern bool pm_check_wakeup_events (void ); -extern bool pm_get_wakeup_count (unsigned long *count); -extern bool pm_save_wakeup_count (unsigned long count); +extern bool pm_get_wakeup_count (unsigned int *count); +extern bool pm_save_wakeup_count (unsigned int count);#else /* !CONFIG_PM_SLEEP */ static inline int register_pm_notifier (struct notifier_block *nb)
kernel/power/main.c +4 -4
@@ -237,18 +237,18 @@ static ssize_t wakeup_count_show(structstruct kobj_attribute *attr, char *buf) { - unsigned long val; + unsigned int val; -return pm_get_wakeup_count (&val) ?sprintf (buf,"%lu\n" , val) : -EINTR ; +return pm_get_wakeup_count (&val) ?sprintf (buf,"%u\n" , val) : -EINTR ; }static ssize_t wakeup_count_store (struct kobject *kobj,struct kobj_attribute *attr,const char *buf,size_t n) { -unsigned long val; +unsigned int val; -if (sscanf (buf,"%lu" , &val) ==1 ) { +if (sscanf (buf,"%u" , &val) ==1 ) {if (pm_save_wakeup_count (val))return n; }
drivers/base/power/sysfs.c +119 -2
136 lines not on this page · raw message
Documentation/ABI/testing/sysfs-devices-power +70 -0
73 lines not on this page · raw message
Re: PM / Wakeup: Introduce wakeup source objects and event statistics (v2)
Quoted 14 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Subject: PM / Wakeup: Introduce wakeup source objects and event statistics (v2)Introduce struct
wakeup_sourcefor representing system wakeup sources within the kernel and for collecting statistics related to them. Make the recently introduced helper functionspm_wakeup_event(),pm_stay_awake()andpm_relax()use structwakeup_sourceobjects internally, so that wakeup statistics associated with wakeup devices can be collected and reported in a consistent way (the definition ofpm_relax()is changed, which is harmless, because this function is not called directly by anyone yet). Introduce new wakeup-related sysfs device attributes in/sys/devices/.../powerfor reporting the device wakeup statistics.
Quoted 7 lines
Change the global wakeup events counters
event_countandevents_in_progressinto atomic variables, so that it is not necessary to acquire a global spinlock inpm_wakeup_event(),pm_stay_awake()andpm_relax(), which should allow us to avoid lock contention in these functions on SMP systems with many wakeup devices.Signed-off-by Rafael J. Wysocki <[email protected]>
Hi Rafael,
This looks like a really useful feature. Was doing some experiments with this on OMAP, and found a minor cut-and-paste bug in the Documentation file:
[...]
Documentation/ABI/testing/sysfs-devices-power Description: · line 140
Quoted 11 lines
Documentation/ABI/testing/sysfs-devices-power +11
-0+What: /sys/devices/.../power/wakeup_max_time_ms +Date: September 2010 +Contact: Rafael J. Wysocki <[email protected]> +Description: + The /sys/devices/.../wakeup_max_time_ms attribute contains + the maximum time of processing a single wakeup event associated + with the device, in milliseconds. This attribute is read-only. + If the device is not enabled to wake up the system from sleep + states, this attribute is empty. + +What: /sys/devices/.../power/wakeup_max_time_ms
^^^
s/max/last/ for this one.
Documentation/ABI/testing/sysfs-devices-power Description: · line 149
Quoted 9 lines
Documentation/ABI/testing/sysfs-devices-power +9
-0+Date: September 2010 +Contact: Rafael J. Wysocki <[email protected]> +Description: + The /sys/devices/.../wakeup_last_time_ms attribute contains + the value of the monotonic clock corresponding to the time of + signaling the last wakeup event associated with the device, in + milliseconds. This attribute is read-only. If the device is + not enabled to wake up the system from sleep states, this + attribute is empty.
Kevin
Re: PM / Wakeup: Introduce wakeup source objects and event statistics (v2)
In reply to Rafael J. WysockiQuoted 14 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Subject: PM / Wakeup: Introduce wakeup source objects and event statistics (v2)Introduce struct
wakeup_sourcefor representing system wakeup sources within the kernel and for collecting statistics related to them. Make the recently introduced helper functionspm_wakeup_event(),pm_stay_awake()andpm_relax()use structwakeup_sourceobjects internally, so that wakeup statistics associated with wakeup devices can be collected and reported in a consistent way (the definition ofpm_relax()is changed, which is harmless, because this function is not called directly by anyone yet). Introduce new wakeup-related sysfs device attributes in/sys/devices/.../powerfor reporting the device wakeup statistics.
Quoted 7 lines
Change the global wakeup events counters
event_countandevents_in_progressinto atomic variables, so that it is not necessary to acquire a global spinlock inpm_wakeup_event(),pm_stay_awake()andpm_relax(), which should allow us to avoid lock contention in these functions on SMP systems with many wakeup devices.Signed-off-by Rafael J. Wysocki <[email protected]>
Hi Rafael,
This looks like a really useful feature. Was doing some experiments with this on OMAP, and found a minor cut-and-paste bug in the Documentation file:
[...]
Documentation/ABI/testing/sysfs-devices-power Description: · line 140
Quoted 11 lines
Documentation/ABI/testing/sysfs-devices-power +11
-0+What: /sys/devices/.../power/wakeup_max_time_ms +Date: September 2010 +Contact: Rafael J. Wysocki <[email protected]> +Description: + The /sys/devices/.../wakeup_max_time_ms attribute contains + the maximum time of processing a single wakeup event associated + with the device, in milliseconds. This attribute is read-only. + If the device is not enabled to wake up the system from sleep + states, this attribute is empty. + +What: /sys/devices/.../power/wakeup_max_time_ms
^^^
s/max/last/ for this one.
Documentation/ABI/testing/sysfs-devices-power Description: · line 149
Quoted 9 lines
Documentation/ABI/testing/sysfs-devices-power +9
-0+Date: September 2010 +Contact: Rafael J. Wysocki <[email protected]> +Description: + The /sys/devices/.../wakeup_last_time_ms attribute contains + the value of the monotonic clock corresponding to the time of + signaling the last wakeup event associated with the device, in + milliseconds. This attribute is read-only. If the device is + not enabled to wake up the system from sleep states, this + attribute is empty.
Kevin
Re: PM / Wakeup: Introduce wakeup source objects and event statistics (v2)
Quoted 22 lines · Kevin Hilman
Quoted 20 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Subject: PM / Wakeup: Introduce wakeup source objects and event statistics (v2)Introduce struct
wakeup_sourcefor representing system wakeup sources within the kernel and for collecting statistics related to them. Make the recently introduced helper functionspm_wakeup_event(),pm_stay_awake()andpm_relax()use structwakeup_sourceobjects internally, so that wakeup statistics associated with wakeup devices can be collected and reported in a consistent way (the definition ofpm_relax()is changed, which is harmless, because this function is not called directly by anyone yet). Introduce new wakeup-related sysfs device attributes in/sys/devices/.../powerfor reporting the device wakeup statistics.Change the global wakeup events counters
event_countandevents_in_progressinto atomic variables, so that it is not necessary to acquire a global spinlock inpm_wakeup_event(),pm_stay_awake()andpm_relax(), which should allow us to avoid lock contention in these functions on SMP systems with many wakeup devices.
Quoted 5 lines
Quoted 1 line
Signed-off-by Rafael J. Wysocki <[email protected]>Hi Rafael,
This looks like a really useful feature.
Great!
Quoted 17 lines
Was doing some experiments with this on OMAP, and found a minor cut-and-paste bug in the Documentation file:
[...]
Documentation/ABI/testing/sysfs-devices-power Description: · line 140
Quoted 11 lines
Documentation/ABI/testing/sysfs-devices-power +11
-0+What: /sys/devices/.../power/wakeup_max_time_ms +Date: September 2010 +Contact: Rafael J. Wysocki <[email protected]> +Description: + The /sys/devices/.../wakeup_max_time_ms attribute contains + the maximum time of processing a single wakeup event associated + with the device, in milliseconds. This attribute is read-only. + If the device is not enabled to wake up the system from sleep + states, this attribute is empty. + +What: /sys/devices/.../power/wakeup_max_time_ms^^^
Quoted 1 line
s/max/last/ for this one.
Ah, thanks a lot.
Quoted 9 lines
Documentation/ABI/testing/sysfs-devices-power Description: · line 149
Quoted 9 lines
Documentation/ABI/testing/sysfs-devices-power +9
-0+Date: September 2010 +Contact: Rafael J. Wysocki <[email protected]> +Description: + The /sys/devices/.../wakeup_last_time_ms attribute contains + the value of the monotonic clock corresponding to the time of + signaling the last wakeup event associated with the device, in + milliseconds. This attribute is read-only. If the device is + not enabled to wake up the system from sleep states, this + attribute is empty.
Rafael
Re: PM / Wakeup: Introduce wakeup source objects and event statistics (v2)
In reply to Kevin HilmanQuoted 22 lines · Kevin Hilman
Quoted 20 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Subject: PM / Wakeup: Introduce wakeup source objects and event statistics (v2)Introduce struct
wakeup_sourcefor representing system wakeup sources within the kernel and for collecting statistics related to them. Make the recently introduced helper functionspm_wakeup_event(),pm_stay_awake()andpm_relax()use structwakeup_sourceobjects internally, so that wakeup statistics associated with wakeup devices can be collected and reported in a consistent way (the definition ofpm_relax()is changed, which is harmless, because this function is not called directly by anyone yet). Introduce new wakeup-related sysfs device attributes in/sys/devices/.../powerfor reporting the device wakeup statistics.Change the global wakeup events counters
event_countandevents_in_progressinto atomic variables, so that it is not necessary to acquire a global spinlock inpm_wakeup_event(),pm_stay_awake()andpm_relax(), which should allow us to avoid lock contention in these functions on SMP systems with many wakeup devices.
Quoted 5 lines
Quoted 1 line
Signed-off-by Rafael J. Wysocki <[email protected]>Hi Rafael,
This looks like a really useful feature.
Great!
Quoted 17 lines
Was doing some experiments with this on OMAP, and found a minor cut-and-paste bug in the Documentation file:
[...]
Documentation/ABI/testing/sysfs-devices-power Description: · line 140
Quoted 11 lines
Documentation/ABI/testing/sysfs-devices-power +11
-0+What: /sys/devices/.../power/wakeup_max_time_ms +Date: September 2010 +Contact: Rafael J. Wysocki <[email protected]> +Description: + The /sys/devices/.../wakeup_max_time_ms attribute contains + the maximum time of processing a single wakeup event associated + with the device, in milliseconds. This attribute is read-only. + If the device is not enabled to wake up the system from sleep + states, this attribute is empty. + +What: /sys/devices/.../power/wakeup_max_time_ms^^^
Quoted 1 line
s/max/last/ for this one.
Ah, thanks a lot.
Quoted 9 lines
Documentation/ABI/testing/sysfs-devices-power Description: · line 149
Quoted 9 lines
Documentation/ABI/testing/sysfs-devices-power +9
-0+Date: September 2010 +Contact: Rafael J. Wysocki <[email protected]> +Description: + The /sys/devices/.../wakeup_last_time_ms attribute contains + the value of the monotonic clock corresponding to the time of + signaling the last wakeup event associated with the device, in + milliseconds. This attribute is read-only. If the device is + not enabled to wake up the system from sleep states, this + attribute is empty.
Rafael
Re: PM / Wakeup: Introduce wakeup source objects and event statistics (v2)
Quoted 19 lines · Rafael J. Wysocki
Quoted 17 lines
Was doing some experiments with this on OMAP, and found a minor cut-and-paste bug in the Documentation file:
[...]
Documentation/ABI/testing/sysfs-devices-power Description: · line 140
Quoted 11 lines
Documentation/ABI/testing/sysfs-devices-power +11
-0+What: /sys/devices/.../power/wakeup_max_time_ms +Date: September 2010 +Contact: Rafael J. Wysocki <[email protected]> +Description: + The /sys/devices/.../wakeup_max_time_ms attribute contains + the maximum time of processing a single wakeup event associated + with the device, in milliseconds. This attribute is read-only. + If the device is not enabled to wake up the system from sleep + states, this attribute is empty. + +What: /sys/devices/.../power/wakeup_max_time_ms^^^Quoted 1 line
s/max/last/ for this one.
Quoted 1 line
Ah, thanks a lot.
There was another copy & paste errors in that file, a "wakeup_active_count" that should be "wakeup_hit_count".
Alan Stern
Re: PM / Wakeup: Introduce wakeup source objects and event statistics (v2)
In reply to Rafael J. WysockiQuoted 19 lines · Rafael J. Wysocki
Quoted 17 lines
Was doing some experiments with this on OMAP, and found a minor cut-and-paste bug in the Documentation file:
[...]
Documentation/ABI/testing/sysfs-devices-power Description: · line 140
Quoted 11 lines
Documentation/ABI/testing/sysfs-devices-power +11
-0+What: /sys/devices/.../power/wakeup_max_time_ms +Date: September 2010 +Contact: Rafael J. Wysocki <[email protected]> +Description: + The /sys/devices/.../wakeup_max_time_ms attribute contains + the maximum time of processing a single wakeup event associated + with the device, in milliseconds. This attribute is read-only. + If the device is not enabled to wake up the system from sleep + states, this attribute is empty. + +What: /sys/devices/.../power/wakeup_max_time_ms^^^Quoted 1 line
s/max/last/ for this one.
Quoted 1 line
Ah, thanks a lot.
There was another copy & paste errors in that file, a "wakeup_active_count" that should be "wakeup_hit_count".
Alan Stern
Re: PM / Wakeup: Introduce wakeup source objects and event statistics (v2)
Quoted 21 lines · Alan Stern
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines
Was doing some experiments with this on OMAP, and found a minor cut-and-paste bug in the Documentation file:
[...]
Documentation/ABI/testing/sysfs-devices-power Description: · line 140
Quoted 11 lines
Documentation/ABI/testing/sysfs-devices-power +11
-0+What: /sys/devices/.../power/wakeup_max_time_ms +Date: September 2010 +Contact: Rafael J. Wysocki <[email protected]> +Description: + The /sys/devices/.../wakeup_max_time_ms attribute contains + the maximum time of processing a single wakeup event associated + with the device, in milliseconds. This attribute is read-only. + If the device is not enabled to wake up the system from sleep + states, this attribute is empty. + +What: /sys/devices/.../power/wakeup_max_time_ms^^^s/max/last/ for this one.
Quoted 4 lines
Quoted 1 line
Ah, thanks a lot.
There was another copy & paste errors in that file, a "
wakeup_active_count" that should be "wakeup_hit_count".
Indeed, fixed now.
Thanks,
Rafael
Re: PM / Wakeup: Introduce wakeup source objects and event statistics (v2)
In reply to Alan SternQuoted 21 lines · Alan Stern
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines
Was doing some experiments with this on OMAP, and found a minor cut-and-paste bug in the Documentation file:
[...]
Documentation/ABI/testing/sysfs-devices-power Description: · line 140
Quoted 11 lines
Documentation/ABI/testing/sysfs-devices-power +11
-0+What: /sys/devices/.../power/wakeup_max_time_ms +Date: September 2010 +Contact: Rafael J. Wysocki <[email protected]> +Description: + The /sys/devices/.../wakeup_max_time_ms attribute contains + the maximum time of processing a single wakeup event associated + with the device, in milliseconds. This attribute is read-only. + If the device is not enabled to wake up the system from sleep + states, this attribute is empty. + +What: /sys/devices/.../power/wakeup_max_time_ms^^^s/max/last/ for this one.
Quoted 4 lines
Quoted 1 line
Ah, thanks a lot.
There was another copy & paste errors in that file, a "
wakeup_active_count" that should be "wakeup_hit_count".
Indeed, fixed now.
Thanks,
Rafael
Re: Wakeup-events implementation
In reply to Alan SternQuoted 10 lines · On Tue, 17 Aug 2010 11:53:53 -0400 (EDT) Alan Stern…
Also, I frankly have to wonder why you demand such a large amount of detailed debugging about the kernel's wakeup/wakelock subsystem (as opposed to userspace wakelocks). Yes, it's clear that if something goes wrong then you will drain your phone's battery in a few hours rather than a few days. But what if something goes wrong with the VM subsystem, or the RF subsystem, or the keypad driver? The device would crash immediately or at best become almost totally unusable. These are much worse scenarios than losing some battery life -- have you added comparable quantities of debugging to those other parts of the kernel?
Quoted 4 lines
In addition, you retain all these debugging facilities in your production builds, not just in the debug kernels. Doesn't this seem excessive?
There is a theory about risk analysis and follow-up costs... i don't have anything concrete at hand but the main idea is that if you develop for example some monitoring for a production line of a pharmaceutical product, you have to take into consideration all possible failure-modes, the associated risk (likelihood * impact)
and the likelihood of detecting these failures before shipping.
A failure mode that is fatal (->high risk), and is not detectable before shipping is bad and a sign that you probably shouldn't produce at all.
A failure mode that is fatal (->high risk) but is detectable in all cases before shipping is not such a big problem.
With battery powered devices, you have failure-modes (run-time not optimal) that is not easily detectable before shipping. This is the worst kind of failure-mode because you don't know if it will happen or not.
The risk of this failure mode (non-optimal runtime) is bad also, because for mobile devices the runtime is critical and the fact that we talk about millions of devices will turn this up with a non-negligible probability.
So I totally understand that the android people want all the debugging they can get to make non-optimal runtime as visible as a broken vm or a not functioning keypad. After all, runtime is critical for mobile devices.
Cheers,
Flo
Quoted 15 lines · Arve Hjønnevåg
2010/8/7 Rafael J. Wysocki <[email protected]>:
Quoted 14 lines · Arve Hjønnevåg
Quoted 12 lines
2010/8/6 Alan Stern <[email protected]>:
Quoted 9 lines · Arve Hjønnevåg
Quoted 5 lines
count, tells you how many times the wakelock was activated. If a wakelock prevented suspend for a long time a large count tells you it handled a lot of events while a small count tells you it took a long time to process the events, or the wakelock was not released properly.
As noted, we already have this.
Almost. We have it when a device is passed in.
Quoted 7 lines
Quoted 2 lines
Sure. And what are the other cases (details, please)?
The suspend blockers I added I my suspend blocker patchset were not directly associated with a device. The evdev changes could be modified to share a device, but it would give less detail since a separate queue is created for each client that opens the device.
OK, that's a good argument.
Quoted 8 lines
The suspend blocking work api would have to change so the caller to passes a device in, which I think would make that api less flexible. Mostly the problem is that we need separate stats for wakelocks created by a single driver. For instance we will still need a user-space interface to block suspend on android devices (lower level services than the power manager need to block suspend), with the stats in the device struct we have to create a new device for every wakelock user space creates in the kernel.
Well, what about managing these stats in user space?
Quoted 3 lines
There is also the issue of reading the stats. It is a lot easier to read a single stats file, than looping though every device on the system (when most of the devices never block suspend).
It seems you can have a list of the "interesting" ones.
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
expire_count, tells you how many times the timeout expired. For the input event wakelock in the android kernel (which has a timeout) an expire count that matches the count tells you that someone opened an input device but is not reading from it (this has happened several times).This is a little tricky. Rafael's model currently does not allow wakeup events started by
pm_wakeup_event()to be cancelled any way other than by having their timer expire. This essentially means that for some devices,expire_countwill always be the same as count and for others it will always be 0. To change this would require adding an extra timer struct, which could be done (in fact, an earlier version of the code included it). It would be nice if we could avoid the need.Does Android use any kernel-internal wakelocks both with a timer and with active cancellation?
Quoted 8 lines
Quoted 4 lines
I don't know if they are all kernel-internal but these drivers appear to use timeouts and active cancellation on the same wakelock:
wifi driver, mmc core, alarm driver, evdev (suspend blocker version removes the timeout).You previously said you didn't need timeouted wakelocks in the kernel, so I guess that was incorrect.
Quoted 6 lines
I don't know what you are reffering to. We have always stated that we need timeouts in the kernel to pass events through other kernel layers that do not use wakelocks (that list is much longer than the list above which mixes timeouts and unlock on the same wakelock). The only feature we do not use is the timeout feature in the user space interface to kernel wakelocks.
Now that's more clear, thanks.
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 8 lines
Quoted 4 lines
wake_count, tells you that this is the first wakelock that was acquired in the resume path. This is currently less useful than I would like on the Nexus One since it is usually "SMD_RPCCALL" which does not tell me a lot.This could be done easily enough, but if it's not very useful then there's no point.
It is useful there is no other way to tell what triggered a wakeup, but it would probably be better to just track wakeup interrupts/events elsewhere.
Quoted 9 lines
Quoted 3 lines
active_since, tells you how long a a still active wakelock has been active. If someone activated a wakelock and never released it, it will be obvious here.Easily added. But you didn't mention any field saying whether the wakelock is currently active. That could be added too (although it would be racy -- but for detecting unreleased wakelocks you wouldn't care).
These are the reported stats, not the fields in the stats structure. The wakelock code has an active flag. If we want to keep the
pm_stay_wakenesting (which I would argue against), we would need an active count. It would also require a handle, which is a change Rafael said would not fly.Quoted 5 lines
Quoted 2 lines
total_time, total time the wake lock has been active. This one should be obvious.Also easily added.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Only with a handle passed to all the calls.
Well, I'm kind of tired of this "my solution is the only acceptable one" mindset. IMHO, it's totally counter productive.
How do you propose to track how long a driver has blocked suspend when you have an unblock call that takes no arguments.
You can extend pm_relax() to take a dev argument and measure the time between pm_stay_awake() and pm_relax() called for the same device.
Quoted 49 lines
Quoted 49 lines
Quoted 48 lines
Quoted 5 lines
Quoted 1 line
sleep_time, total time the wake lock has been active when the screen was off.Not applicable to general systems. Is there anything like it that _would_ apply in general?
The screen off is how it is used on android, the stats is keyed of what user space wrote to
/sys/power/state. If "on" was written the sleep time is not updated.Quoted 11 lines
Quoted 4 lines
max_time, longest time the wakelock was active uninterrupted. This used less often, but the battery on a device was draining fast, but the problem went away before looking at the stats this will show if a wakelock was active for a long time.Again, easily added. The only drawback is that all these additions will bloat the size of struct device. Of course, that's why you used separately-allocated structures for your wakelocks. Maybe we can change to do the same; it seems likely that the majority of device structures won't ever be used for wakeup events.
Since many wakelocks are not associated with s struct device we need a separate object for this anyway.
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
and I would prefer that the kernel interfaces would encourage drivers to block suspend until user space has consumed the event, which works for the android user space, instead of just long enough to work with a hypothetical user space power manager.
Rafael doesn't _discourage_ drivers from doing this. However you have to keep in mind that many kernel developers are accustomed to working on systems (mostly PCs) with a different range of hardware devices from embedded systems like your phones. With PCI
devices(*), for example, there's no clear point where a wakeup event gets handed off to userspace.Quoted 2 lines
On the other hand, there's no reason the input layer shouldn't use
pm_stay_awakeandpm_relax. It simply hasn't been implemented yet....
The merged user space interface makes this unclear to me. When I first used suspend on android I had a power manager process that opened all the input devices and reset a screen off timeout every time there was an input event. If the input layer uses
pm_stay_awaketo block suspend when the queue is not empty, this will deadlock with the current interface since reading the wake count will block forever if an input event occurred right after the power manager decides to suspend.
Quoted 4 lines
Quoted 2 lines
No, in that case suspend will be aborted, IIUC.
How? Your
pm_get_wakeup_countfunction loops untilevents_in_progressbecomes 0.
So, to deadlock with it you'd have to call pm_stay_awake() and wait for it to complete. However, right now there are no means by which user space can call pm_stay_awake(), so this can't happen.
Of course, if you add pm_stay_awake() to an ioctl() code path, you should make sure that whoever uses that ioctl() won't be waiting for the power manager to read from /sys/power/wakeup_count. I guess your point is that this isn't possible to achieve?
Thanks,
Rafael
2010/8/8 Rafael J. Wysocki <[email protected]>:
Quoted 1 line · Arve Hjønnevåg
...
Quoted 11 lines
Quoted 8 lines
The suspend blocking work api would have to change so the caller to passes a device in, which I think would make that api less flexible. Mostly the problem is that we need separate stats for wakelocks created by a single driver. For instance we will still need a user-space interface to block suspend on android devices (lower level services than the power manager need to block suspend), with the stats in the device struct we have to create a new device for every wakelock user space creates in the kernel.
Well, what about managing these stats in user space?
The java wakelocks have stats in user space, but the lower level services that use the kernel api do not show up there.
Quoted 6 lines
Quoted 3 lines
There is also the issue of reading the stats. It is a lot easier to read a single stats file, than looping though every device on the system (when most of the devices never block suspend).
It seems you can have a list of the "interesting" ones.
I'm not sure what you mean. If you mean add a procfs or debugfs api that lists the stats for devices that have used the api, then yes that should work. If I have a devices where the battery drained too quickly, I run cat /proc/wakelocks which has all the reasons why it was not suspended.
...
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
total_time, total time the wake lock has been active. This one should be obvious.Also easily added.
Only with a handle passed to all the calls.
Well, I'm kind of tired of this "my solution is the only acceptable one" mindset. IMHO, it's totally counter productive.
Quoted 6 lines
Quoted 2 lines
How do you propose to track how long a driver has blocked suspend when you have an unblock call that takes no arguments.
You can extend
pm_relax()to take a dev argument and measure the time betweenpm_stay_awake()andpm_relax()called for the same device.
As long as it is not optional.
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 48 lines
Quoted 5 lines
Quoted 1 line
sleep_time, total time the wake lock has been active when the screen was off.Not applicable to general systems. Is there anything like it that _would_ apply in general?
The screen off is how it is used on android, the stats is keyed of what user space wrote to
/sys/power/state. If "on" was written the sleep time is not updated.Quoted 11 lines
Quoted 4 lines
max_time, longest time the wakelock was active uninterrupted. This used less often, but the battery on a device was draining fast, but the problem went away before looking at the stats this will show if a wakelock was active for a long time.Again, easily added. The only drawback is that all these additions will bloat the size of struct device. Of course, that's why you used separately-allocated structures for your wakelocks. Maybe we can change to do the same; it seems likely that the majority of device structures won't ever be used for wakeup events.
Since many wakelocks are not associated with s struct device we need a separate object for this anyway.
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
and I would prefer that the kernel interfaces would encourage drivers to block suspend until user space has consumed the event, which works for the android user space, instead of just long enough to work with a hypothetical user space power manager.
Rafael doesn't _discourage_ drivers from doing this. However you have to keep in mind that many kernel developers are accustomed to working on systems (mostly PCs) with a different range of hardware devices from embedded systems like your phones. With PCI
devices(*), for example, there's no clear point where a wakeup event gets handed off to userspace.Quoted 2 lines
On the other hand, there's no reason the input layer shouldn't use
pm_stay_awakeandpm_relax. It simply hasn't been implemented yet....
The merged user space interface makes this unclear to me. When I first used suspend on android I had a power manager process that opened all the input devices and reset a screen off timeout every time there was an input event. If the input layer uses
pm_stay_awaketo block suspend when the queue is not empty, this will deadlock with the current interface since reading the wake count will block forever if an input event occurred right after the power manager decides to suspend.
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
No, in that case suspend will be aborted, IIUC.
How? Your
pm_get_wakeup_countfunction loops untilevents_in_progressbecomes 0.So, to deadlock with it you'd have to call
pm_stay_awake()and wait for it to complete. However, right now there are no means by which user space can callpm_stay_awake(), so this can't happen.
No that is not how it deadlocks. The input driver calls pm_stay_awake which blocks the thread that reads from /sys/power/wakeup_count. If that threads needs to run before the user-space reads from the input device (either because it is the same thread, or because it provides a user-space wakelock api) you have a deadlock.
Quoted 5 lines
Of course, if you add
pm_stay_awake()to anioctl()code path, you should make sure that whoever uses thatioctl()won't be waiting for the power manager to read from/sys/power/wakeup_count. I guess your point is that this isn't possible to achieve?
My main point is that blocking suspend while the input event queue is not empty changes what else is safe for the user-space process reading /sys/power/wakeup_count.
Signature · 1 line
Arve Hjønnevåg
2010/8/8 Rafael J. Wysocki <[email protected]>:
Quoted 1 line · Arve Hjønnevåg
...
Quoted 11 lines
Quoted 8 lines
The suspend blocking work api would have to change so the caller to passes a device in, which I think would make that api less flexible. Mostly the problem is that we need separate stats for wakelocks created by a single driver. For instance we will still need a user-space interface to block suspend on android devices (lower level services than the power manager need to block suspend), with the stats in the device struct we have to create a new device for every wakelock user space creates in the kernel.
Well, what about managing these stats in user space?
The java wakelocks have stats in user space, but the lower level services that use the kernel api do not show up there.
Quoted 6 lines
Quoted 3 lines
There is also the issue of reading the stats. It is a lot easier to read a single stats file, than looping though every device on the system (when most of the devices never block suspend).
It seems you can have a list of the "interesting" ones.
I'm not sure what you mean. If you mean add a procfs or debugfs api that lists the stats for devices that have used the api, then yes that should work. If I have a devices where the battery drained too quickly, I run cat /proc/wakelocks which has all the reasons why it was not suspended.
...
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
total_time, total time the wake lock has been active. This one should be obvious.Also easily added.
Only with a handle passed to all the calls.
Well, I'm kind of tired of this "my solution is the only acceptable one" mindset. IMHO, it's totally counter productive.
Quoted 6 lines
Quoted 2 lines
How do you propose to track how long a driver has blocked suspend when you have an unblock call that takes no arguments.
You can extend
pm_relax()to take a dev argument and measure the time betweenpm_stay_awake()andpm_relax()called for the same device.
As long as it is not optional.
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 48 lines
Quoted 5 lines
Quoted 1 line
sleep_time, total time the wake lock has been active when the screen was off.Not applicable to general systems. Is there anything like it that _would_ apply in general?
The screen off is how it is used on android, the stats is keyed of what user space wrote to
/sys/power/state. If "on" was written the sleep time is not updated.Quoted 11 lines
Quoted 4 lines
max_time, longest time the wakelock was active uninterrupted. This used less often, but the battery on a device was draining fast, but the problem went away before looking at the stats this will show if a wakelock was active for a long time.Again, easily added. The only drawback is that all these additions will bloat the size of struct device. Of course, that's why you used separately-allocated structures for your wakelocks. Maybe we can change to do the same; it seems likely that the majority of device structures won't ever be used for wakeup events.
Since many wakelocks are not associated with s struct device we need a separate object for this anyway.
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
and I would prefer that the kernel interfaces would encourage drivers to block suspend until user space has consumed the event, which works for the android user space, instead of just long enough to work with a hypothetical user space power manager.
Rafael doesn't _discourage_ drivers from doing this. However you have to keep in mind that many kernel developers are accustomed to working on systems (mostly PCs) with a different range of hardware devices from embedded systems like your phones. With PCI
devices(*), for example, there's no clear point where a wakeup event gets handed off to userspace.Quoted 2 lines
On the other hand, there's no reason the input layer shouldn't use
pm_stay_awakeandpm_relax. It simply hasn't been implemented yet....
The merged user space interface makes this unclear to me. When I first used suspend on android I had a power manager process that opened all the input devices and reset a screen off timeout every time there was an input event. If the input layer uses
pm_stay_awaketo block suspend when the queue is not empty, this will deadlock with the current interface since reading the wake count will block forever if an input event occurred right after the power manager decides to suspend.
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
No, in that case suspend will be aborted, IIUC.
How? Your
pm_get_wakeup_countfunction loops untilevents_in_progressbecomes 0.So, to deadlock with it you'd have to call
pm_stay_awake()and wait for it to complete. However, right now there are no means by which user space can callpm_stay_awake(), so this can't happen.
No that is not how it deadlocks. The input driver calls pm_stay_awake which blocks the thread that reads from /sys/power/wakeup_count. If that threads needs to run before the user-space reads from the input device (either because it is the same thread, or because it provides a user-space wakelock api) you have a deadlock.
Quoted 5 lines
Of course, if you add
pm_stay_awake()to anioctl()code path, you should make sure that whoever uses thatioctl()won't be waiting for the power manager to read from/sys/power/wakeup_count. I guess your point is that this isn't possible to achieve?
My main point is that blocking suspend while the input event queue is not empty changes what else is safe for the user-space process reading /sys/power/wakeup_count.
Signature · 1 line
Arve Hjønnevåg
Quoted 1 line · Arve Hjønnevåg
On Wed, Aug 4, 2010 at 1:56 PM, Matthew Garrett <[email protected]> wrote:
[ . . . ]
Quoted 10 lines
Quoted 2 lines
having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
That is "this"? The merged code? If so, no it does not satisfy our requirements. The in kernel api, while offering similar functionality to the wakelock interface, does not use any handles which makes it impossible to get reasonable stats (You don't know which
pm_stay_awakerequestpm_relaxis reverting). The proposed in user-space interface of calling into every process that receives wakeup events before every suspend call is also not compatible with existing apps.
I should have asked this earlier... What exactly are the apps' compatibility constraints? Source-level APIs? Byte-code class-library invocations? C/C++ dynamic linking? C/C++ static linking (in other words, syscall)?
Thanx, Paul
Quoted 1 line · Arve Hjønnevåg
On Wed, Aug 4, 2010 at 1:56 PM, Matthew Garrett <[email protected]> wrote:
[ . . . ]
Quoted 10 lines
Quoted 2 lines
having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
That is "this"? The merged code? If so, no it does not satisfy our requirements. The in kernel api, while offering similar functionality to the wakelock interface, does not use any handles which makes it impossible to get reasonable stats (You don't know which
pm_stay_awakerequestpm_relaxis reverting). The proposed in user-space interface of calling into every process that receives wakeup events before every suspend call is also not compatible with existing apps.
I should have asked this earlier... What exactly are the apps' compatibility constraints? Source-level APIs? Byte-code class-library invocations? C/C++ dynamic linking? C/C++ static linking (in other words, syscall)?
Thanx, Paul
2010/8/4 Paul E. McKenney <[email protected]>:
Quoted 16 lines · Arve Hjønnevåg
Quoted 1 line · Matthew Garrett
[ . . . ]
Quoted 10 lines
Quoted 2 lines
having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
That is "this"? The merged code? If so, no it does not satisfy our requirements. The in kernel api, while offering similar functionality to the wakelock interface, does not use any handles which makes it impossible to get reasonable stats (You don't know which
pm_stay_awakerequestpm_relaxis reverting). The proposed in user-space interface of calling into every process that receives wakeup events before every suspend call is also not compatible with existing apps.
Quoted 4 lines
I should have asked this earlier... What exactly are the apps' compatibility constraints? Source-level APIs? Byte-code class-library invocations? C/C++ dynamic linking? C/C++ static linking (in other words, syscall)?
For Java/Dalvik apps, the wakelock API is pertty high level -- it talks to a service via RPC (Binder) that actually interacts with the kernel. Changing the basic kernel<->userspace interface (within reason) is not unthinkable. For example, Arve's suspend_blocker patch provides a device interface rather than the proc interface the older wakelock patches use. We'd have to make some userspace changes to support that but they're pretty low level and minor.
In the current model, only a few processes need to specifically interact with the kernel (the power management service in the system_server, possibly the media_server and the radio interface glue). A model where every process needs to have a bunch of instrumentation is not very desirable from our point of view. We definitely do need reasonable statistics in order to enable debugging and to enable reporting to endusers (through the Battery Usage UI) what's keeping the device awake.
Brian
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
2010/8/4 Paul E. McKenney <[email protected]>:
Quoted 16 lines · Arve Hjønnevåg
Quoted 1 line · Matthew Garrett
[ . . . ]
Quoted 10 lines
Quoted 2 lines
having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
That is "this"? The merged code? If so, no it does not satisfy our requirements. The in kernel api, while offering similar functionality to the wakelock interface, does not use any handles which makes it impossible to get reasonable stats (You don't know which
pm_stay_awakerequestpm_relaxis reverting). The proposed in user-space interface of calling into every process that receives wakeup events before every suspend call is also not compatible with existing apps.
Quoted 4 lines
I should have asked this earlier... What exactly are the apps' compatibility constraints? Source-level APIs? Byte-code class-library invocations? C/C++ dynamic linking? C/C++ static linking (in other words, syscall)?
For Java/Dalvik apps, the wakelock API is pertty high level -- it talks to a service via RPC (Binder) that actually interacts with the kernel. Changing the basic kernel<->userspace interface (within reason) is not unthinkable. For example, Arve's suspend_blocker patch provides a device interface rather than the proc interface the older wakelock patches use. We'd have to make some userspace changes to support that but they're pretty low level and minor.
In the current model, only a few processes need to specifically interact with the kernel (the power management service in the system_server, possibly the media_server and the radio interface glue). A model where every process needs to have a bunch of instrumentation is not very desirable from our point of view. We definitely do need reasonable statistics in order to enable debugging and to enable reporting to endusers (through the Battery Usage UI) what's keeping the device awake.
Brian
Quoted 30 lines · Brian Swetland
2010/8/4 Paul E. McKenney <[email protected]>:
Quoted 16 lines · Arve Hjønnevåg
Quoted 1 line · Matthew Garrett
[ . . . ]
Quoted 10 lines
Quoted 2 lines
having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
That is "this"? The merged code? If so, no it does not satisfy our requirements. The in kernel api, while offering similar functionality to the wakelock interface, does not use any handles which makes it impossible to get reasonable stats (You don't know which
pm_stay_awakerequestpm_relaxis reverting). The proposed in user-space interface of calling into every process that receives wakeup events before every suspend call is also not compatible with existing apps.Quoted 4 lines
I should have asked this earlier... What exactly are the apps' compatibility constraints? Source-level APIs? Byte-code class-library invocations? C/C++ dynamic linking? C/C++ static linking (in other words, syscall)?
For Java/Dalvik apps, the wakelock API is pertty high level -- it talks to a service via RPC (Binder) that actually interacts with the kernel. Changing the basic kernel<->userspace interface (within reason) is not unthinkable. For example, Arve's
suspend_blockerpatch provides a device interface rather than the proc interface the older wakelock patches use. We'd have to make some userspace changes to support that but they're pretty low level and minor.
Quoted 8 lines
In the current model, only a few processes need to specifically interact with the kernel (the power management service in the
system_server, possibly themedia_serverand the radio interface glue). A model where every process needs to have a bunch of instrumentation is not very desirable from our point of view. We definitely do need reasonable statistics in order to enable debugging and to enable reporting to endusers (through the Battery Usage UI) what's keeping the device awake.
Thank you for the info!
Thanx, Paul
Quoted 30 lines · Brian Swetland
2010/8/4 Paul E. McKenney <[email protected]>:
Quoted 16 lines · Arve Hjønnevåg
Quoted 1 line · Matthew Garrett
[ . . . ]
Quoted 10 lines
Quoted 2 lines
having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
That is "this"? The merged code? If so, no it does not satisfy our requirements. The in kernel api, while offering similar functionality to the wakelock interface, does not use any handles which makes it impossible to get reasonable stats (You don't know which
pm_stay_awakerequestpm_relaxis reverting). The proposed in user-space interface of calling into every process that receives wakeup events before every suspend call is also not compatible with existing apps.Quoted 4 lines
I should have asked this earlier... What exactly are the apps' compatibility constraints? Source-level APIs? Byte-code class-library invocations? C/C++ dynamic linking? C/C++ static linking (in other words, syscall)?
For Java/Dalvik apps, the wakelock API is pertty high level -- it talks to a service via RPC (Binder) that actually interacts with the kernel. Changing the basic kernel<->userspace interface (within reason) is not unthinkable. For example, Arve's
suspend_blockerpatch provides a device interface rather than the proc interface the older wakelock patches use. We'd have to make some userspace changes to support that but they're pretty low level and minor.
Quoted 8 lines
In the current model, only a few processes need to specifically interact with the kernel (the power management service in the
system_server, possibly themedia_serverand the radio interface glue). A model where every process needs to have a bunch of instrumentation is not very desirable from our point of view. We definitely do need reasonable statistics in order to enable debugging and to enable reporting to endusers (through the Battery Usage UI) what's keeping the device awake.
Thank you for the info!
Thanx, Paul
Quoted 18 lines · Matthew Garrett
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Matthew Garrett
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressWhat stops the system going to sleep between (2) and (3)? cgroups don't, because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.
Quoted 8 lines
Quoted 2 lines
I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to avoid the race (ifpm_wakeup_event()is called at 2)).Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
the proposal that I nade was not to use cgroups to freeze some processes and not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just a way of easily grouping processes (and their children) into different groups.
David Lang
Quoted 18 lines · Matthew Garrett
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Matthew Garrett
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressWhat stops the system going to sleep between (2) and (3)? cgroups don't, because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.
Quoted 8 lines
Quoted 2 lines
I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to avoid the race (ifpm_wakeup_event()is called at 2)).Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
the proposal that I nade was not to use cgroups to freeze some processes and not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just a way of easily grouping processes (and their children) into different groups.
David Lang
Quoted 32 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 24 lines · Matthew Garrett
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Matthew Garrett
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 7 lines
Quoted 3 lines
What stops the system going to sleep between (2) and (3)? cgroups don't, because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.
I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 6 lines
the proposal that I nade was not to use cgroups to freeze some processes and not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just a way of easily grouping processes (and their children) into different groups.
That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
Signature · 1 line
Arve Hjønnevåg
Quoted 32 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 24 lines · Matthew Garrett
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Matthew Garrett
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 7 lines
Quoted 3 lines
What stops the system going to sleep between (2) and (3)? cgroups don't, because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.
I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 6 lines
the proposal that I nade was not to use cgroups to freeze some processes and not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just a way of easily grouping processes (and their children) into different groups.
That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
Signature · 1 line
Arve Hjønnevåg
Quoted 40 lines · Arve Hj?nnev?g
Quoted 32 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 24 lines · Matthew Garrett
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Matthew Garrett
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 7 lines
Quoted 3 lines
What stops the system going to sleep between (2) and (3)? cgroups don't, because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.
I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 6 lines
the proposal that I nade was not to use cgroups to freeze some processes and not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just a way of easily grouping processes (and their children) into different groups.
Quoted 5 lines
That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
and if you don't have a wakelock the same thing will happen. If you expect the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
David Lang
Quoted 40 lines · Arve Hj?nnev?g
Quoted 32 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 24 lines · Matthew Garrett
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Matthew Garrett
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 7 lines
Quoted 3 lines
What stops the system going to sleep between (2) and (3)? cgroups don't, because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.
I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 6 lines
the proposal that I nade was not to use cgroups to freeze some processes and not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just a way of easily grouping processes (and their children) into different groups.
Quoted 5 lines
That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
and if you don't have a wakelock the same thing will happen. If you expect the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
David Lang
Quoted 47 lines · On Wed, Aug 04, 2010 at 03:56:42PM -0700, [email protected] wrote:
Quoted 39 lines · Arve Hj?nnev?g
Quoted 32 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 24 lines · Matthew Garrett
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Matthew Garrett
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 7 lines
Quoted 3 lines
What stops the system going to sleep between (2) and (3)? cgroups don't, because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.
I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 5 lines
the proposal that I nade was not to use cgroups to freeze some processes and not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just a way of easily grouping processes (and their children) into different groups.
Quoted 5 lines
That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
Quoted 6 lines
and if you don't have a wakelock the same thing will happen. If you expect the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
The difference between the Android scheme and your proposal is that the Android scheme freezes -all- the processes, not just a subset of them. Therefore, in the Android scheme, the case of one process attempting to acquire a resource held by a frozen process. In contrast, any scheme that attempts to freeze only a subset of the processes must somehow either avoid or properly handle the situation where a frozen process is holding a resource that a running process is trying to acquire.
Thanx, Paul
Quoted 47 lines · On Wed, Aug 04, 2010 at 03:56:42PM -0700, [email protected] wrote:
Quoted 39 lines · Arve Hj?nnev?g
Quoted 32 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 24 lines · Matthew Garrett
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Matthew Garrett
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 7 lines
Quoted 3 lines
What stops the system going to sleep between (2) and (3)? cgroups don't, because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.
I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 5 lines
the proposal that I nade was not to use cgroups to freeze some processes and not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just a way of easily grouping processes (and their children) into different groups.
Quoted 5 lines
That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
Quoted 6 lines
and if you don't have a wakelock the same thing will happen. If you expect the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
The difference between the Android scheme and your proposal is that the Android scheme freezes -all- the processes, not just a subset of them. Therefore, in the Android scheme, the case of one process attempting to acquire a resource held by a frozen process. In contrast, any scheme that attempts to freeze only a subset of the processes must somehow either avoid or properly handle the situation where a frozen process is holding a resource that a running process is trying to acquire.
Thanx, Paul
One suggestion: Get an Android Phone, test your ideas on it, then comment.
One suggestion: Get an Android Phone, test your ideas on it, then comment.
Quoted 1 line · Anca Emanuel
One suggestion: Get an Android Phone, test your ideas on it, then comment.
I actually have played with an Android phone. ;-)
Thanx, Paul
Quoted 1 line · Anca Emanuel
One suggestion: Get an Android Phone, test your ideas on it, then comment.
I actually have played with an Android phone. ;-)
Thanx, Paul
Quoted 55 lines · Paul E. McKenney
Quoted 47 lines · On Wed, Aug 04, 2010 at 03:56:42PM -0700, [email protected] wrote:
Quoted 39 lines · Arve Hj?nnev?g
Quoted 32 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 24 lines · Matthew Garrett
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Matthew Garrett
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 7 lines
Quoted 3 lines
What stops the system going to sleep between (2) and (3)? cgroups don't, because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.
I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 5 lines
the proposal that I nade was not to use cgroups to freeze some processes and not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just a way of easily grouping processes (and their children) into different groups.
Quoted 5 lines
That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
Quoted 6 lines
and if you don't have a wakelock the same thing will happen. If you expect the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
Quoted 7 lines
The difference between the Android scheme and your proposal is that the Android scheme freezes -all- the processes, not just a subset of them. Therefore, in the Android scheme, the case of one process attempting to acquire a resource held by a frozen process. In contrast, any scheme that attempts to freeze only a subset of the processes must somehow either avoid or properly handle the situation where a frozen process is holding a resource that a running process is trying to acquire.
My proposal would never freeze a subset of processes.
what my proposal:
only consider the activity of a subset of processes when deciding if we should suspend or not. If the decision is to suspend, freeze everything.
you (and many other people) are confusing what I've proposed (use cgroups to indicate what processes to care about and what ones to not care about when deciding to suspend/go to idle) with the prior cgroup proposal (use cgroups to freeze a subset of tasks while leaving others runnable)
David Lang
Quoted 55 lines · Paul E. McKenney
Quoted 47 lines · On Wed, Aug 04, 2010 at 03:56:42PM -0700, [email protected] wrote:
Quoted 39 lines · Arve Hj?nnev?g
Quoted 32 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 24 lines · Matthew Garrett
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Matthew Garrett
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 7 lines
Quoted 3 lines
What stops the system going to sleep between (2) and (3)? cgroups don't, because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.
I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 5 lines
the proposal that I nade was not to use cgroups to freeze some processes and not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just a way of easily grouping processes (and their children) into different groups.
Quoted 5 lines
That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
Quoted 6 lines
and if you don't have a wakelock the same thing will happen. If you expect the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
Quoted 7 lines
The difference between the Android scheme and your proposal is that the Android scheme freezes -all- the processes, not just a subset of them. Therefore, in the Android scheme, the case of one process attempting to acquire a resource held by a frozen process. In contrast, any scheme that attempts to freeze only a subset of the processes must somehow either avoid or properly handle the situation where a frozen process is holding a resource that a running process is trying to acquire.
My proposal would never freeze a subset of processes.
what my proposal:
only consider the activity of a subset of processes when deciding if we should suspend or not. If the decision is to suspend, freeze everything.
you (and many other people) are confusing what I've proposed (use cgroups to indicate what processes to care about and what ones to not care about when deciding to suspend/go to idle) with the prior cgroup proposal (use cgroups to freeze a subset of tasks while leaving others runnable)
David Lang
Quoted 65 lines · On Thursday, August 05, 2010, [email protected] wrote:
Quoted 55 lines · Paul E. McKenney
Quoted 47 lines · On Wed, Aug 04, 2010 at 03:56:42PM -0700, [email protected] wrote:
Quoted 39 lines · Arve Hj?nnev?g
Quoted 32 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 24 lines · Matthew Garrett
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Matthew Garrett
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 7 lines
Quoted 3 lines
What stops the system going to sleep between (2) and (3)? cgroups don't, because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.
I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 5 lines
the proposal that I nade was not to use cgroups to freeze some processes and not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just a way of easily grouping processes (and their children) into different groups.
Quoted 5 lines
That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
Quoted 6 lines
and if you don't have a wakelock the same thing will happen. If you expect the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
Quoted 7 lines
The difference between the Android scheme and your proposal is that the Android scheme freezes -all- the processes, not just a subset of them. Therefore, in the Android scheme, the case of one process attempting to acquire a resource held by a frozen process. In contrast, any scheme that attempts to freeze only a subset of the processes must somehow either avoid or properly handle the situation where a frozen process is holding a resource that a running process is trying to acquire.
Quoted 6 lines
My proposal would never freeze a subset of processes.
what my proposal:
only consider the activity of a subset of processes when deciding if we should suspend or not. If the decision is to suspend, freeze everything.
That alone doesn't allow you to handle the race Matthew was referring to (ie. wakeup event happening right after you've decided to suspend).
A mechanism of making a decision alone is not sufficient, you also need a mechanism to avoid races between wakeup events and suspend process.
Thanks,
Rafael
Quoted 65 lines · On Thursday, August 05, 2010, [email protected] wrote:
Quoted 55 lines · Paul E. McKenney
Quoted 47 lines · On Wed, Aug 04, 2010 at 03:56:42PM -0700, [email protected] wrote:
Quoted 39 lines · Arve Hj?nnev?g
Quoted 32 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 24 lines · Matthew Garrett
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Matthew Garrett
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 7 lines
Quoted 3 lines
What stops the system going to sleep between (2) and (3)? cgroups don't, because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.
I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 5 lines
the proposal that I nade was not to use cgroups to freeze some processes and not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just a way of easily grouping processes (and their children) into different groups.
Quoted 5 lines
That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
Quoted 6 lines
and if you don't have a wakelock the same thing will happen. If you expect the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
Quoted 7 lines
The difference between the Android scheme and your proposal is that the Android scheme freezes -all- the processes, not just a subset of them. Therefore, in the Android scheme, the case of one process attempting to acquire a resource held by a frozen process. In contrast, any scheme that attempts to freeze only a subset of the processes must somehow either avoid or properly handle the situation where a frozen process is holding a resource that a running process is trying to acquire.
Quoted 6 lines
My proposal would never freeze a subset of processes.
what my proposal:
only consider the activity of a subset of processes when deciding if we should suspend or not. If the decision is to suspend, freeze everything.
That alone doesn't allow you to handle the race Matthew was referring to (ie. wakeup event happening right after you've decided to suspend).
A mechanism of making a decision alone is not sufficient, you also need a mechanism to avoid races between wakeup events and suspend process.
Thanks,
Rafael
Quoted 6 lines · Rafael J. Wysocki
Quoted 5 lines · On Thursday, August 05, 2010, [email protected] wrote:
My proposal would never freeze a subset of processes.
what my proposal:
Quoted 9 lines
Quoted 2 lines
only consider the activity of a subset of processes when deciding if we should suspend or not. If the decision is to suspend, freeze everything.
That alone doesn't allow you to handle the race Matthew was referring to (ie. wakeup event happening right after you've decided to suspend).
A mechanism of making a decision alone is not sufficient, you also need a mechanism to avoid races between wakeup events and suspend process.
I thought you just posted that there was a new feature that would be able to abort the suspend and so that race was closed.
David Lang
Quoted 6 lines · Rafael J. Wysocki
Quoted 5 lines · On Thursday, August 05, 2010, [email protected] wrote:
My proposal would never freeze a subset of processes.
what my proposal:
Quoted 9 lines
Quoted 2 lines
only consider the activity of a subset of processes when deciding if we should suspend or not. If the decision is to suspend, freeze everything.
That alone doesn't allow you to handle the race Matthew was referring to (ie. wakeup event happening right after you've decided to suspend).
A mechanism of making a decision alone is not sufficient, you also need a mechanism to avoid races between wakeup events and suspend process.
I thought you just posted that there was a new feature that would be able to abort the suspend and so that race was closed.
David Lang
Quoted 14 lines · On Thursday, August 05, 2010, [email protected] wrote:
Quoted 12 lines · Rafael J. Wysocki
Quoted 7 lines · On Thursday, August 05, 2010, [email protected] wrote:
My proposal would never freeze a subset of processes.
what my proposal:
only consider the activity of a subset of processes when deciding if we should suspend or not. If the decision is to suspend, freeze everything.
That alone doesn't allow you to handle the race Matthew was referring to (ie. wakeup event happening right after you've decided to suspend).
Quoted 6 lines
Quoted 3 lines
A mechanism of making a decision alone is not sufficient, you also need a mechanism to avoid races between wakeup events and suspend process.
I thought you just posted that there was a new feature that would be able to abort the suspend and so that race was closed.
Yes, you can use that for this purpose, but then you'd need a user space power manager who would decide whether or not to suspend. Then, however, the problem boils down to setting up appropriate communication between the power manager and the other applications in user space (ie. the kernel doesn't need to be involved in that at all).
Thanks,
Rafael
Quoted 14 lines · On Thursday, August 05, 2010, [email protected] wrote:
Quoted 12 lines · Rafael J. Wysocki
Quoted 7 lines · On Thursday, August 05, 2010, [email protected] wrote:
My proposal would never freeze a subset of processes.
what my proposal:
only consider the activity of a subset of processes when deciding if we should suspend or not. If the decision is to suspend, freeze everything.
That alone doesn't allow you to handle the race Matthew was referring to (ie. wakeup event happening right after you've decided to suspend).
Quoted 6 lines
Quoted 3 lines
A mechanism of making a decision alone is not sufficient, you also need a mechanism to avoid races between wakeup events and suspend process.
I thought you just posted that there was a new feature that would be able to abort the suspend and so that race was closed.
Yes, you can use that for this purpose, but then you'd need a user space power manager who would decide whether or not to suspend. Then, however, the problem boils down to setting up appropriate communication between the power manager and the other applications in user space (ie. the kernel doesn't need to be involved in that at all).
Thanks,
Rafael
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines · On Thursday, August 05, 2010, [email protected] wrote:
Quoted 15 lines · Rafael J. Wysocki
Quoted 7 lines · On Thursday, August 05, 2010, [email protected] wrote:
My proposal would never freeze a subset of processes.
what my proposal:
only consider the activity of a subset of processes when deciding if we should suspend or not. If the decision is to suspend, freeze everything.
That alone doesn't allow you to handle the race Matthew was referring to (ie. wakeup event happening right after you've decided to suspend).
A mechanism of making a decision alone is not sufficient, you also need a mechanism to avoid races between wakeup events and suspend process.
Quoted 8 lines
Quoted 2 lines
I thought you just posted that there was a new feature that would be able to abort the suspend and so that race was closed.
Yes, you can use that for this purpose, but then you'd need a user space power manager who would decide whether or not to suspend. Then, however, the problem boils down to setting up appropriate communication between the power manager and the other applications in user space (ie. the kernel doesn't need to be involved in that at all).
This race sounds like it's generic across all platforms and not an Android specific problem. Android is just more sensitive to it as they do a suspend more frequently.
one thought on this, as a generic solution to the problem would it be possible for the suspend controller (whatever it is) to do the following
1. decide to suspend
2. setup monitors for the wake events
3. double check if it still wants to suspend
this way you don't pay the overhead of the wake monitors while you are running normally, but if one hits while you are suspending you wake up again as quickly as you can (which could involve aborting the suspend and backing out, or going fully into suspend and waking up immediatly, depending on which is better/easier at the time you get the wakeup)
David Lang
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines · On Thursday, August 05, 2010, [email protected] wrote:
Quoted 15 lines · Rafael J. Wysocki
Quoted 7 lines · On Thursday, August 05, 2010, [email protected] wrote:
My proposal would never freeze a subset of processes.
what my proposal:
only consider the activity of a subset of processes when deciding if we should suspend or not. If the decision is to suspend, freeze everything.
That alone doesn't allow you to handle the race Matthew was referring to (ie. wakeup event happening right after you've decided to suspend).
A mechanism of making a decision alone is not sufficient, you also need a mechanism to avoid races between wakeup events and suspend process.
Quoted 8 lines
Quoted 2 lines
I thought you just posted that there was a new feature that would be able to abort the suspend and so that race was closed.
Yes, you can use that for this purpose, but then you'd need a user space power manager who would decide whether or not to suspend. Then, however, the problem boils down to setting up appropriate communication between the power manager and the other applications in user space (ie. the kernel doesn't need to be involved in that at all).
This race sounds like it's generic across all platforms and not an Android specific problem. Android is just more sensitive to it as they do a suspend more frequently.
one thought on this, as a generic solution to the problem would it be possible for the suspend controller (whatever it is) to do the following
1. decide to suspend
2. setup monitors for the wake events
3. double check if it still wants to suspend
this way you don't pay the overhead of the wake monitors while you are running normally, but if one hits while you are suspending you wake up again as quickly as you can (which could involve aborting the suspend and backing out, or going fully into suspend and waking up immediatly, depending on which is better/easier at the time you get the wakeup)
David Lang
Quoted 7 lines · On Wed, Aug 04, 2010 at 04:19:20PM -0700, [email protected] wrote:
only consider the activity of a subset of processes when deciding if we should suspend or not. If the decision is to suspend, freeze everything.
you (and many other people) are confusing what I've proposed (use cgroups to indicate what processes to care about and what ones to not care about when deciding to suspend/go to idle) with the prior cgroup proposal (use cgroups to freeze a subset of tasks while leaving others runnable)
The decision on whether or not to go to sleep isn't the difficult bit of this problem space.
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 7 lines · On Wed, Aug 04, 2010 at 04:19:20PM -0700, [email protected] wrote:
only consider the activity of a subset of processes when deciding if we should suspend or not. If the decision is to suspend, freeze everything.
you (and many other people) are confusing what I've proposed (use cgroups to indicate what processes to care about and what ones to not care about when deciding to suspend/go to idle) with the prior cgroup proposal (use cgroups to freeze a subset of tasks while leaving others runnable)
The decision on whether or not to go to sleep isn't the difficult bit of this problem space.
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 5 lines · Matthew Garrett
Quoted 3 lines · On Wed, Aug 04, 2010 at 04:19:20PM -0700, [email protected] wrote:
only consider the activity of a subset of processes when deciding if we should suspend or not. If the decision is to suspend, freeze everything.
Quoted 7 lines
Quoted 4 lines
you (and many other people) are confusing what I've proposed (use cgroups to indicate what processes to care about and what ones to not care about when deciding to suspend/go to idle) with the prior cgroup proposal (use cgroups to freeze a subset of tasks while leaving others runnable)
The decision on whether or not to go to sleep isn't the difficult bit of this problem space.
but isn't that all that wakelocks do? affect the decision on whether or not to go to sleep.
David Lang
Quoted 5 lines · Matthew Garrett
Quoted 3 lines · On Wed, Aug 04, 2010 at 04:19:20PM -0700, [email protected] wrote:
only consider the activity of a subset of processes when deciding if we should suspend or not. If the decision is to suspend, freeze everything.
Quoted 7 lines
Quoted 4 lines
you (and many other people) are confusing what I've proposed (use cgroups to indicate what processes to care about and what ones to not care about when deciding to suspend/go to idle) with the prior cgroup proposal (use cgroups to freeze a subset of tasks while leaving others runnable)
The decision on whether or not to go to sleep isn't the difficult bit of this problem space.
but isn't that all that wakelocks do? affect the decision on whether or not to go to sleep.
David Lang
Quoted 6 lines · On Thu, Aug 05, 2010 at 07:07:06AM -0700, [email protected] wrote:
Quoted 2 lines · Matthew Garrett
The decision on whether or not to go to sleep isn't the difficult bit of this problem space.
but isn't that all that wakelocks do? affect the decision on whether or not to go to sleep.
You could think of them that way, but it's not the useful aspect of them
- that much could be implemented entirely in userspace. Wakelocks provide a mechanism for userspace to ensure that it's handled all received events before a system suspend takes place.
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 6 lines · On Thu, Aug 05, 2010 at 07:07:06AM -0700, [email protected] wrote:
Quoted 2 lines · Matthew Garrett
The decision on whether or not to go to sleep isn't the difficult bit of this problem space.
but isn't that all that wakelocks do? affect the decision on whether or not to go to sleep.
You could think of them that way, but it's not the useful aspect of them
- that much could be implemented entirely in userspace. Wakelocks provide a mechanism for userspace to ensure that it's handled all received events before a system suspend takes place.
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 5 lines · Matthew Garrett
Quoted 4 lines · On Thu, Aug 05, 2010 at 07:07:06AM -0700, [email protected] wrote:
Quoted 2 lines · Matthew Garrett
The decision on whether or not to go to sleep isn't the difficult bit of this problem space.
Quoted 7 lines
Quoted 2 lines
but isn't that all that wakelocks do? affect the decision on whether or not to go to sleep.
You could think of them that way, but it's not the useful aspect of them
- that much could be implemented entirely in userspace. Wakelocks provide a mechanism for userspace to ensure that it's handled all received events before a system suspend takes place.
For userspace or the kernel -- some events may not require userspace intervention, but do require the kernel to stay awake long enough to finish chewing on them. Say perhaps a wifi irq comes in, the wifi driver/stack needs to process some beacon packets or whatnot.
Brian
Quoted 5 lines · Matthew Garrett
Quoted 4 lines · On Thu, Aug 05, 2010 at 07:07:06AM -0700, [email protected] wrote:
Quoted 2 lines · Matthew Garrett
The decision on whether or not to go to sleep isn't the difficult bit of this problem space.
Quoted 7 lines
Quoted 2 lines
but isn't that all that wakelocks do? affect the decision on whether or not to go to sleep.
You could think of them that way, but it's not the useful aspect of them
- that much could be implemented entirely in userspace. Wakelocks provide a mechanism for userspace to ensure that it's handled all received events before a system suspend takes place.
For userspace or the kernel -- some events may not require userspace intervention, but do require the kernel to stay awake long enough to finish chewing on them. Say perhaps a wifi irq comes in, the wifi driver/stack needs to process some beacon packets or whatnot.
Brian
Quoted 63 lines · On Wed, 4 Aug 2010 16:10:03 -0700 "Paul E. McKenney"…
Quoted 47 lines · On Wed, Aug 04, 2010 at 03:56:42PM -0700, [email protected] wrote:
Quoted 39 lines · Arve Hj?nnev?g
Quoted 32 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 24 lines · Matthew Garrett
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Matthew Garrett
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 7 lines
Quoted 3 lines
What stops the system going to sleep between (2) and (3)? cgroups don't, because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.
I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 5 lines
the proposal that I nade was not to use cgroups to freeze some processes and not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just a way of easily grouping processes (and their children) into different groups.
Quoted 5 lines
That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
Quoted 6 lines
and if you don't have a wakelock the same thing will happen. If you expect the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
The difference between the Android scheme and your proposal is that the Android scheme freezes -all- the processes, not just a subset of them. Therefore, in the Android scheme, the case of one process attempting to acquire a resource held by a frozen process. In contrast, any scheme that attempts to freeze only a subset of the processes must somehow either avoid or properly handle the situation where a frozen process is holding a resource that a running process is trying to acquire.
Quoted 1 line
Thanx, Paul
No no. In the David-Lang-CGroup-Scheme[1](tm?) suspend-from-idle is used. For idle decision a certain subset of tasks is ignored.
Where suspend is prevented by the trusted
process in android-world taking a wakelock, here it would just prevent the system from going idle by arming timers.
This would be pretty equivalent to the suspend-blocker scheme and not introduce new userspace api. But the downside is, as Arve pointed out, that now one can not get full-idle-power-leverage while suspend is blocked.
[1] http://permalink.gmane.org/gmane.linux.kernel/1018452 and following
Cheers,
Flo
Quoted 63 lines · On Wed, 4 Aug 2010 16:10:03 -0700 "Paul E. McKenney"…
Quoted 47 lines · On Wed, Aug 04, 2010 at 03:56:42PM -0700, [email protected] wrote:
Quoted 39 lines · Arve Hj?nnev?g
Quoted 32 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 24 lines · Matthew Garrett
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Matthew Garrett
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 7 lines
Quoted 3 lines
What stops the system going to sleep between (2) and (3)? cgroups don't, because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.
I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 5 lines
the proposal that I nade was not to use cgroups to freeze some processes and not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just a way of easily grouping processes (and their children) into different groups.
Quoted 5 lines
That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
Quoted 6 lines
and if you don't have a wakelock the same thing will happen. If you expect the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
The difference between the Android scheme and your proposal is that the Android scheme freezes -all- the processes, not just a subset of them. Therefore, in the Android scheme, the case of one process attempting to acquire a resource held by a frozen process. In contrast, any scheme that attempts to freeze only a subset of the processes must somehow either avoid or properly handle the situation where a frozen process is holding a resource that a running process is trying to acquire.
Quoted 1 line
Thanx, Paul
No no. In the David-Lang-CGroup-Scheme[1](tm?) suspend-from-idle is used. For idle decision a certain subset of tasks is ignored.
Where suspend is prevented by the trusted
process in android-world taking a wakelock, here it would just prevent the system from going idle by arming timers.
This would be pretty equivalent to the suspend-blocker scheme and not introduce new userspace api. But the downside is, as Arve pointed out, that now one can not get full-idle-power-leverage while suspend is blocked.
[1] http://permalink.gmane.org/gmane.linux.kernel/1018452 and following
Cheers,
Flo
Quoted 16 lines · On Thu, 5 Aug 2010 07:33:59 +0200 Florian Mickler <[email protected]> wrote:
On Wed, 4 Aug 2010 16:10:03 -0700
"Paul E. McKenney" <[email protected]> wrote:No no. In the David-Lang-CGroup-Scheme[1](tm?) suspend-from-idle is used. For idle decision a certain subset of tasks is ignored.
Where suspend is prevented by the trusted
process in android-world taking a wakelock, here it would just prevent the system from going idle by arming timers.This would be pretty equivalent to the suspend-blocker scheme and not introduce new userspace api. But the downside is, as Arve pointed out, that now one can not get full-idle-power-leverage while suspend is blocked.
Quoted 7 lines
[1] http://permalink.gmane.org/gmane.linux.kernel/1018452 and following
Cheers,
Flo
There are a few downsides that got mentioned already in reponse.. I got a little lagged behind.
There are upsides to this approach like not
having a special purpose userspace api, conceptually integrating suspend into the idle mechanism ..
Short summary of the cons that got mentioned:
- applications need to resort to polling to keep the system
out of idle (-> system will never be fully idle)
- the race between deciding to suspend and becoming active again is not handled
- no special statistics available
- the timers of the ignored applications will behave unexpected (as the monotonic clock is not stopped)... while applications have already to cope with network-loss, other side effects of suspend without monotonic clock stopped are to be expected...
Cheers,
Flo
Quoted 16 lines · On Thu, 5 Aug 2010 07:33:59 +0200 Florian Mickler <[email protected]> wrote:
On Wed, 4 Aug 2010 16:10:03 -0700
"Paul E. McKenney" <[email protected]> wrote:No no. In the David-Lang-CGroup-Scheme[1](tm?) suspend-from-idle is used. For idle decision a certain subset of tasks is ignored.
Where suspend is prevented by the trusted
process in android-world taking a wakelock, here it would just prevent the system from going idle by arming timers.This would be pretty equivalent to the suspend-blocker scheme and not introduce new userspace api. But the downside is, as Arve pointed out, that now one can not get full-idle-power-leverage while suspend is blocked.
Quoted 7 lines
[1] http://permalink.gmane.org/gmane.linux.kernel/1018452 and following
Cheers,
Flo
There are a few downsides that got mentioned already in reponse.. I got a little lagged behind.
There are upsides to this approach like not
having a special purpose userspace api, conceptually integrating suspend into the idle mechanism ..
Short summary of the cons that got mentioned:
- applications need to resort to polling to keep the system
out of idle (-> system will never be fully idle)
- the race between deciding to suspend and becoming active again is not handled
- no special statistics available
- the timers of the ignored applications will behave unexpected (as the monotonic clock is not stopped)... while applications have already to cope with network-loss, other side effects of suspend without monotonic clock stopped are to be expected...
Cheers,
Flo
Quoted 27 lines · Florian Mickler
Quoted 16 lines · On Thu, 5 Aug 2010 07:33:59 +0200 Florian Mickler <[email protected]> wrote:
On Wed, 4 Aug 2010 16:10:03 -0700
"Paul E. McKenney" <[email protected]> wrote:No no. In the David-Lang-CGroup-Scheme[1](tm?) suspend-from-idle is used. For idle decision a certain subset of tasks is ignored.
Where suspend is prevented by the trusted
process in android-world taking a wakelock, here it would just prevent the system from going idle by arming timers.This would be pretty equivalent to the suspend-blocker scheme and not introduce new userspace api. But the downside is, as Arve pointed out, that now one can not get full-idle-power-leverage while suspend is blocked.
Quoted 7 lines
[1] http://permalink.gmane.org/gmane.linux.kernel/1018452 and following
Cheers,
Flo
Quoted 6 lines
There are a few downsides that got mentioned already in reponse.. I got a little lagged behind.
There are upsides to this approach like not
having a special purpose userspace api, conceptually integrating suspend into the idle mechanism ..
first off, a good summary of that I've been saying, thanks.
Quoted 4 lines
Short summary of the cons that got mentioned:
- applications need to resort to polling to keep the system
out of idle (-> system will never be fully idle)
true, although the power difference between a system that is completelyidle (but with a wavelock held) and a system where one application is polling every 10 seconds or so is _really_ low.
Quoted 2 lines
- the race between deciding to suspend and becoming active again is not handled
this one I will admit to not fully understanding, it sounds like there are opptions here, but I don't understand them or their trade-offs
Quoted 1 line
- no special statistics available
or no special statistics needed. Powertop is already avaible to analyse a system and report what processes are keeping it awake. Why would this not be enough?
Quoted 4 lines
- the timers of the ignored applications will behave unexpected (as the monotonic clock is not stopped)... while applications have already to cope with network-loss, other side effects of suspend without monotonic clock stopped are to be expected...
I'm not sure this is true. there's nothing stopping the suspend (when it finally does happen) from stopping the monotonic clock. The core of my proposal is tweaking how we decide to suspend. Other than the possibility that we decide to suspend between timers (and set an alarm to wake up when a timer would go off) I'm not suggesting that the suspend itself change once it's finally triggered.
David Lang
Quoted 27 lines · Florian Mickler
Quoted 16 lines · On Thu, 5 Aug 2010 07:33:59 +0200 Florian Mickler <[email protected]> wrote:
On Wed, 4 Aug 2010 16:10:03 -0700
"Paul E. McKenney" <[email protected]> wrote:No no. In the David-Lang-CGroup-Scheme[1](tm?) suspend-from-idle is used. For idle decision a certain subset of tasks is ignored.
Where suspend is prevented by the trusted
process in android-world taking a wakelock, here it would just prevent the system from going idle by arming timers.This would be pretty equivalent to the suspend-blocker scheme and not introduce new userspace api. But the downside is, as Arve pointed out, that now one can not get full-idle-power-leverage while suspend is blocked.
Quoted 7 lines
[1] http://permalink.gmane.org/gmane.linux.kernel/1018452 and following
Cheers,
Flo
Quoted 6 lines
There are a few downsides that got mentioned already in reponse.. I got a little lagged behind.
There are upsides to this approach like not
having a special purpose userspace api, conceptually integrating suspend into the idle mechanism ..
first off, a good summary of that I've been saying, thanks.
Quoted 4 lines
Short summary of the cons that got mentioned:
- applications need to resort to polling to keep the system
out of idle (-> system will never be fully idle)
true, although the power difference between a system that is completelyidle (but with a wavelock held) and a system where one application is polling every 10 seconds or so is _really_ low.
Quoted 2 lines
- the race between deciding to suspend and becoming active again is not handled
this one I will admit to not fully understanding, it sounds like there are opptions here, but I don't understand them or their trade-offs
Quoted 1 line
- no special statistics available
or no special statistics needed. Powertop is already avaible to analyse a system and report what processes are keeping it awake. Why would this not be enough?
Quoted 4 lines
- the timers of the ignored applications will behave unexpected (as the monotonic clock is not stopped)... while applications have already to cope with network-loss, other side effects of suspend without monotonic clock stopped are to be expected...
I'm not sure this is true. there's nothing stopping the suspend (when it finally does happen) from stopping the monotonic clock. The core of my proposal is tweaking how we decide to suspend. Other than the possibility that we decide to suspend between timers (and set an alarm to wake up when a timer would go off) I'm not suggesting that the suspend itself change once it's finally triggered.
David Lang
2010/8/4 <[email protected]>:
Quoted 46 lines · Arve Hj?nnev?g
Quoted 45 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 42 lines · Matthew Garrett
Quoted 26 lines · Rafael J. Wysocki
Quoted 15 lines · Matthew Garrett
Quoted 13 lines
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 8 lines
Quoted 4 lines
What stops the system going to sleep between (2) and (3)? cgroups don't,
because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
the proposal that I nade was not to use cgroups to freeze some processes and
not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just
a way of easily grouping processes (and their children) into different groups.
Quoted 7 lines
Quoted 5 lines
That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
and if you don't have a wakelock the same thing will happen. If you expect
Not the same thing. If you don't hold a wakelock the entire system will suspend and when it wakes up it continues where it left off. Timeout still have time left before they expire.
Quoted 2 lines
the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going
I don't think polling is an acceptable solution to this problem. You user space code know needs to know what "idle" timeout you have selected so it can choose a faster poll rate. When is it safe to stop polling?
Quoted 3 lines
to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
We suspend as soon as no wakelocks are held. There is no delay.
Signature · 1 line
Arve Hjønnevåg
2010/8/4 <[email protected]>:
Quoted 46 lines · Arve Hj?nnev?g
Quoted 45 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 42 lines · Matthew Garrett
Quoted 26 lines · Rafael J. Wysocki
Quoted 15 lines · Matthew Garrett
Quoted 13 lines
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 8 lines
Quoted 4 lines
What stops the system going to sleep between (2) and (3)? cgroups don't,
because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
the proposal that I nade was not to use cgroups to freeze some processes and
not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just
a way of easily grouping processes (and their children) into different groups.
Quoted 7 lines
Quoted 5 lines
That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
and if you don't have a wakelock the same thing will happen. If you expect
Not the same thing. If you don't hold a wakelock the entire system will suspend and when it wakes up it continues where it left off. Timeout still have time left before they expire.
Quoted 2 lines
the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going
I don't think polling is an acceptable solution to this problem. You user space code know needs to know what "idle" timeout you have selected so it can choose a faster poll rate. When is it safe to stop polling?
Quoted 3 lines
to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
We suspend as soon as no wakelocks are held. There is no delay.
Signature · 1 line
Arve Hjønnevåg
Quoted 53 lines · Arve Hj?nnev?g
2010/8/4 <[email protected]>:
Quoted 52 lines · Arve Hj?nnev?g
Quoted 50 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 34 lines · Matthew Garrett
Quoted 26 lines · Rafael J. Wysocki
Quoted 15 lines · Matthew Garrett
Quoted 13 lines
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 8 lines
Quoted 4 lines
What stops the system going to sleep between (2) and (3)? cgroups don't,
because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 8 lines
the proposal that I nade was not to use cgroups to freeze some processes and
not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just
a way of easily grouping processes (and their children) into different groups.That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
Quoted 5 lines
Quoted 1 line
and if you don't have a wakelock the same thing will happen. If you expect
Not the same thing. If you don't hold a wakelock the entire system will suspend and when it wakes up it continues where it left off. Timeout still have time left before they expire.
in what I'm proposing, if the 'privilaged/trusted" processes are idle long enough the entire system will suspend, and when it wakes up everything will continue to process normally
Quoted 7 lines
Quoted 2 lines
the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going
I don't think polling is an acceptable solution to this problem. You user space code know needs to know what "idle" timeout you have selected so it can choose a faster poll rate. When is it safe to stop polling?
I think the timeouts are of such an order of magnatude that the polling can be infrequent enough to not be a significant amount of load, but be faster than any timeout
Quoted 5 lines
Quoted 3 lines
to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
We suspend as soon as no wakelocks are held. There is no delay.
So, if I have a bookreader app that is not allowed to get the wakelock, and nothing else is running, the system will suspend immediatly after I click a button to go to the next page? it will not stay awake to give me a chance to read the page at all?
how can any application run without wakelock privilages?
David Lang
Quoted 53 lines · Arve Hj?nnev?g
2010/8/4 <[email protected]>:
Quoted 52 lines · Arve Hj?nnev?g
Quoted 50 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 34 lines · Matthew Garrett
Quoted 26 lines · Rafael J. Wysocki
Quoted 15 lines · Matthew Garrett
Quoted 13 lines
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 8 lines
Quoted 4 lines
What stops the system going to sleep between (2) and (3)? cgroups don't,
because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 8 lines
the proposal that I nade was not to use cgroups to freeze some processes and
not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just
a way of easily grouping processes (and their children) into different groups.That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
Quoted 5 lines
Quoted 1 line
and if you don't have a wakelock the same thing will happen. If you expect
Not the same thing. If you don't hold a wakelock the entire system will suspend and when it wakes up it continues where it left off. Timeout still have time left before they expire.
in what I'm proposing, if the 'privilaged/trusted" processes are idle long enough the entire system will suspend, and when it wakes up everything will continue to process normally
Quoted 7 lines
Quoted 2 lines
the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going
I don't think polling is an acceptable solution to this problem. You user space code know needs to know what "idle" timeout you have selected so it can choose a faster poll rate. When is it safe to stop polling?
I think the timeouts are of such an order of magnatude that the polling can be infrequent enough to not be a significant amount of load, but be faster than any timeout
Quoted 5 lines
Quoted 3 lines
to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
We suspend as soon as no wakelocks are held. There is no delay.
So, if I have a bookreader app that is not allowed to get the wakelock, and nothing else is running, the system will suspend immediatly after I click a button to go to the next page? it will not stay awake to give me a chance to read the page at all?
how can any application run without wakelock privilages?
David Lang
Quoted 81 lines · On Wed, Aug 04, 2010 at 04:23:43PM -0700, [email protected] wrote:
Quoted 53 lines · Arve Hj?nnev?g
2010/8/4 <[email protected]>:
Quoted 52 lines · Arve Hj?nnev?g
Quoted 50 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 34 lines · Matthew Garrett
Quoted 26 lines · Rafael J. Wysocki
Quoted 15 lines · Matthew Garrett
Quoted 13 lines
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 8 lines
Quoted 4 lines
What stops the system going to sleep between (2) and (3)? cgroups don't,
because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 8 lines
the proposal that I nade was not to use cgroups to freeze some processes and
not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just
a way of easily grouping processes (and their children) into different groups.That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
Quoted 5 lines
Quoted 1 line
and if you don't have a wakelock the same thing will happen. If you expect
Not the same thing. If you don't hold a wakelock the entire system will suspend and when it wakes up it continues where it left off. Timeout still have time left before they expire.
in what I'm proposing, if the 'privilaged/trusted" processes are idle long enough the entire system will suspend, and when it wakes up everything will continue to process normally
Quoted 7 lines
Quoted 2 lines
the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going
I don't think polling is an acceptable solution to this problem. You user space code know needs to know what "idle" timeout you have selected so it can choose a faster poll rate. When is it safe to stop polling?
I think the timeouts are of such an order of magnatude that the polling can be infrequent enough to not be a significant amount of load, but be faster than any timeout
Quoted 4 lines
Quoted 3 lines
to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
Quoted 8 lines
Quoted 1 line
We suspend as soon as no wakelocks are held. There is no delay.
So, if I have a bookreader app that is not allowed to get the wakelock, and nothing else is running, the system will suspend immediatly after I click a button to go to the next page? it will not stay awake to give me a chance to read the page at all?
how can any application run without wakelock privilages?
Isn't a wakelock held as long as the display is lit, so that the system would continue running as long as the page was visible?
Thanx, Paul
Quoted 81 lines · On Wed, Aug 04, 2010 at 04:23:43PM -0700, [email protected] wrote:
Quoted 53 lines · Arve Hj?nnev?g
2010/8/4 <[email protected]>:
Quoted 52 lines · Arve Hj?nnev?g
Quoted 50 lines · On Wed, Aug 4, 2010 at 3:31 PM, <[email protected]> wrote:
Quoted 34 lines · Matthew Garrett
Quoted 26 lines · Rafael J. Wysocki
Quoted 15 lines · Matthew Garrett
Quoted 13 lines
No! And that's precisely the issue. Android's existing behaviour could be entirely implemented in the form of binary that manually triggers suspend when (a) the screen is off and (b) no userspace applications have indicated that the system shouldn't sleep, except for the wakeup event race. Imagine the following:
1) The policy timeout is about to expire. No applications are holding wakelocks. The system will suspend providing nothing takes a wakelock.
2) A network packet arrives indicating an incoming SIP call
3) The VOIP application takes a wakelock and prevents the phone from suspending while the call is in progressQuoted 8 lines
Quoted 4 lines
What stops the system going to sleep between (2) and (3)? cgroups don't,
because the voip app is an otherwise untrusted application that you've just told the scheduler to ignore.I _think_ you can use the just-merged
/sys/power/wakeup_countmechanism to
avoid the race (ifpm_wakeup_event()is called at 2)).Quoted 5 lines
Yes, I think that solves the problem. The only question then is whether it's preferable to use cgroups or suspend fully, which is pretty much up to the implementation. In other words, is there a reason we're still having this conversation? :) It'd be good to have some feedback from Google as to whether this satisfies their functional requirements.
Quoted 8 lines
the proposal that I nade was not to use cgroups to freeze some processes and
not others, but to use cgroups to decide to ignore some processes when deciding if the system is idle, stop everything or nothing. cgroups are just
a way of easily grouping processes (and their children) into different groups.That does not avoid the dependency problem. A process may be waiting on a resource that a process you ignore owns. I you ignore the process that owns the resource and enter idle when it is ready to run (or waiting on a timer), you are still effectively blocking the other process.
Quoted 5 lines
Quoted 1 line
and if you don't have a wakelock the same thing will happen. If you expect
Not the same thing. If you don't hold a wakelock the entire system will suspend and when it wakes up it continues where it left off. Timeout still have time left before they expire.
in what I'm proposing, if the 'privilaged/trusted" processes are idle long enough the entire system will suspend, and when it wakes up everything will continue to process normally
Quoted 7 lines
Quoted 2 lines
the process to take a while you can set a timeout to wake up every 30 seconds or so and wait again, this would be enough to prevent you from going
I don't think polling is an acceptable solution to this problem. You user space code know needs to know what "idle" timeout you have selected so it can choose a faster poll rate. When is it safe to stop polling?
I think the timeouts are of such an order of magnatude that the polling can be infrequent enough to not be a significant amount of load, but be faster than any timeout
Quoted 4 lines
Quoted 3 lines
to sleep (or am I misunderstanding how long before you go into suspend without a wakelock set, see my other e-mail for the full question)
Quoted 8 lines
Quoted 1 line
We suspend as soon as no wakelocks are held. There is no delay.
So, if I have a bookreader app that is not allowed to get the wakelock, and nothing else is running, the system will suspend immediatly after I click a button to go to the next page? it will not stay awake to give me a chance to read the page at all?
how can any application run without wakelock privilages?
Isn't a wakelock held as long as the display is lit, so that the system would continue running as long as the page was visible?
Thanx, Paul
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · On Wed, Aug 04, 2010 at 04:23:43PM -0700, [email protected] wrote:
Quoted 2 lines · Arve Hj?nnev?g
We suspend as soon as no wakelocks are held. There is no delay.
So, if I have a bookreader app that is not allowed to get the wakelock, and nothing else is running, the system will suspend immediatly after I click a button to go to the next page? it will not stay awake to give me a chance to read the page at all?
Quoted 4 lines
Quoted 1 line
how can any application run without wakelock privilages?
Isn't a wakelock held as long as the display is lit, so that the system would continue running as long as the page was visible?
what holds this wakelock, and what sort of timeout does it have? (and why could that same timeout be used in other ways instead)
how many apps really need to keep running after the screen blanks? there are a few (audio output apps, including music player and Navigation directions), but I don't have see a problem with them being marked as the 'trusted' apps to pay attention instead.
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
David Lang
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · On Wed, Aug 04, 2010 at 04:23:43PM -0700, [email protected] wrote:
Quoted 2 lines · Arve Hj?nnev?g
We suspend as soon as no wakelocks are held. There is no delay.
So, if I have a bookreader app that is not allowed to get the wakelock, and nothing else is running, the system will suspend immediatly after I click a button to go to the next page? it will not stay awake to give me a chance to read the page at all?
Quoted 4 lines
Quoted 1 line
how can any application run without wakelock privilages?
Isn't a wakelock held as long as the display is lit, so that the system would continue running as long as the page was visible?
what holds this wakelock, and what sort of timeout does it have? (and why could that same timeout be used in other ways instead)
how many apps really need to keep running after the screen blanks? there are a few (audio output apps, including music player and Navigation directions), but I don't have see a problem with them being marked as the 'trusted' apps to pay attention instead.
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
David Lang
Quoted 13 lines · On Wed, Aug 04, 2010 at 04:49:22PM -0700, [email protected] wrote:
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · On Wed, Aug 04, 2010 at 04:23:43PM -0700, [email protected] wrote:
Quoted 2 lines · Arve Hj?nnev?g
We suspend as soon as no wakelocks are held. There is no delay.
So, if I have a bookreader app that is not allowed to get the wakelock, and nothing else is running, the system will suspend immediatly after I click a button to go to the next page? it will not stay awake to give me a chance to read the page at all?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
how can any application run without wakelock privilages?
Isn't a wakelock held as long as the display is lit, so that the system would continue running as long as the page was visible?
what holds this wakelock, and what sort of timeout does it have? (and why could that same timeout be used in other ways instead)
I defer to the Android guys on what exactly holds the display's wakelock. The timeout is the display-blank timeout.
Quoted 4 lines
how many apps really need to keep running after the screen blanks? there are a few (audio output apps, including music player and Navigation directions), but I don't have see a problem with them being marked as the 'trusted' apps to pay attention instead.
Downloading is another.
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
Thanx, Paul
Quoted 13 lines · On Wed, Aug 04, 2010 at 04:49:22PM -0700, [email protected] wrote:
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · On Wed, Aug 04, 2010 at 04:23:43PM -0700, [email protected] wrote:
Quoted 2 lines · Arve Hj?nnev?g
We suspend as soon as no wakelocks are held. There is no delay.
So, if I have a bookreader app that is not allowed to get the wakelock, and nothing else is running, the system will suspend immediatly after I click a button to go to the next page? it will not stay awake to give me a chance to read the page at all?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
how can any application run without wakelock privilages?
Isn't a wakelock held as long as the display is lit, so that the system would continue running as long as the page was visible?
what holds this wakelock, and what sort of timeout does it have? (and why could that same timeout be used in other ways instead)
I defer to the Android guys on what exactly holds the display's wakelock. The timeout is the display-blank timeout.
Quoted 4 lines
how many apps really need to keep running after the screen blanks? there are a few (audio output apps, including music player and Navigation directions), but I don't have see a problem with them being marked as the 'trusted' apps to pay attention instead.
Downloading is another.
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
Thanx, Paul
Quoted 25 lines · Paul E. McKenney
Quoted 13 lines · On Wed, Aug 04, 2010 at 04:49:22PM -0700, [email protected] wrote:
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · On Wed, Aug 04, 2010 at 04:23:43PM -0700, [email protected] wrote:
Quoted 2 lines · Arve Hj?nnev?g
We suspend as soon as no wakelocks are held. There is no delay.
So, if I have a bookreader app that is not allowed to get the wakelock, and nothing else is running, the system will suspend immediatly after I click a button to go to the next page? it will not stay awake to give me a chance to read the page at all?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
how can any application run without wakelock privilages?
Isn't a wakelock held as long as the display is lit, so that the system would continue running as long as the page was visible?
what holds this wakelock, and what sort of timeout does it have? (and why could that same timeout be used in other ways instead)
I defer to the Android guys on what exactly holds the display's wakelock. The timeout is the display-blank timeout.
Quoted 6 lines
Quoted 4 lines
how many apps really need to keep running after the screen blanks? there are a few (audio output apps, including music player and Navigation directions), but I don't have see a problem with them being marked as the 'trusted' apps to pay attention instead.
Downloading is another.
this is definantly an interesting case, do you want an active network connection to keep the machine awake? if so do you want it for all network connections, or only for some...
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
Quoted 8 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
David Lang
Quoted 25 lines · Paul E. McKenney
Quoted 13 lines · On Wed, Aug 04, 2010 at 04:49:22PM -0700, [email protected] wrote:
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · On Wed, Aug 04, 2010 at 04:23:43PM -0700, [email protected] wrote:
Quoted 2 lines · Arve Hj?nnev?g
We suspend as soon as no wakelocks are held. There is no delay.
So, if I have a bookreader app that is not allowed to get the wakelock, and nothing else is running, the system will suspend immediatly after I click a button to go to the next page? it will not stay awake to give me a chance to read the page at all?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
how can any application run without wakelock privilages?
Isn't a wakelock held as long as the display is lit, so that the system would continue running as long as the page was visible?
what holds this wakelock, and what sort of timeout does it have? (and why could that same timeout be used in other ways instead)
I defer to the Android guys on what exactly holds the display's wakelock. The timeout is the display-blank timeout.
Quoted 6 lines
Quoted 4 lines
how many apps really need to keep running after the screen blanks? there are a few (audio output apps, including music player and Navigation directions), but I don't have see a problem with them being marked as the 'trusted' apps to pay attention instead.
Downloading is another.
this is definantly an interesting case, do you want an active network connection to keep the machine awake? if so do you want it for all network connections, or only for some...
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
Quoted 8 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
David Lang
Quoted 32 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
Quoted 30 lines · Paul E. McKenney
Quoted 13 lines · On Wed, Aug 04, 2010 at 04:49:22PM -0700, [email protected] wrote:
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · On Wed, Aug 04, 2010 at 04:23:43PM -0700, [email protected] wrote:
Quoted 2 lines · Arve Hj?nnev?g
We suspend as soon as no wakelocks are held. There is no delay.
So, if I have a bookreader app that is not allowed to get the wakelock, and nothing else is running, the system will suspend immediatly after I click a button to go to the next page? it will not stay awake to give me a chance to read the page at all?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
how can any application run without wakelock privilages?
Isn't a wakelock held as long as the display is lit, so that the system would continue running as long as the page was visible?
what holds this wakelock, and what sort of timeout does it have? (and why could that same timeout be used in other ways instead)
I defer to the Android guys on what exactly holds the display's wakelock. The timeout is the display-blank timeout.
Quoted 4 lines
how many apps really need to keep running after the screen blanks? there are a few (audio output apps, including music player and Navigation directions), but I don't have see a problem with them being marked as the 'trusted' apps to pay attention instead.
Quoted 5 lines
Quoted 1 line
Downloading is another.
this is definantly an interesting case, do you want an active network connection to keep the machine awake? if so do you want it for all network connections, or only for some...
The Android approach is that everything is permitted to run when the device is not suspended. So that would be all network connections.
Quoted 7 lines
Quoted 7 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Quoted 7 lines
Quoted 1 line
Or am I misunderstanding what you are proposing?
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when
it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
Quoted 8 lines
Quoted 4 lines
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
Thanx, Paul
Quoted 32 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
Quoted 30 lines · Paul E. McKenney
Quoted 13 lines · On Wed, Aug 04, 2010 at 04:49:22PM -0700, [email protected] wrote:
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · On Wed, Aug 04, 2010 at 04:23:43PM -0700, [email protected] wrote:
Quoted 2 lines · Arve Hj?nnev?g
We suspend as soon as no wakelocks are held. There is no delay.
So, if I have a bookreader app that is not allowed to get the wakelock, and nothing else is running, the system will suspend immediatly after I click a button to go to the next page? it will not stay awake to give me a chance to read the page at all?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
how can any application run without wakelock privilages?
Isn't a wakelock held as long as the display is lit, so that the system would continue running as long as the page was visible?
what holds this wakelock, and what sort of timeout does it have? (and why could that same timeout be used in other ways instead)
I defer to the Android guys on what exactly holds the display's wakelock. The timeout is the display-blank timeout.
Quoted 4 lines
how many apps really need to keep running after the screen blanks? there are a few (audio output apps, including music player and Navigation directions), but I don't have see a problem with them being marked as the 'trusted' apps to pay attention instead.
Quoted 5 lines
Quoted 1 line
Downloading is another.
this is definantly an interesting case, do you want an active network connection to keep the machine awake? if so do you want it for all network connections, or only for some...
The Android approach is that everything is permitted to run when the device is not suspended. So that would be all network connections.
Quoted 7 lines
Quoted 7 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Quoted 7 lines
Quoted 1 line
Or am I misunderstanding what you are proposing?
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when
it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
Quoted 8 lines
Quoted 4 lines
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
Thanx, Paul
Quoted 33 lines · Paul E. McKenney
Quoted 32 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
Quoted 30 lines · Paul E. McKenney
Quoted 13 lines · On Wed, Aug 04, 2010 at 04:49:22PM -0700, [email protected] wrote:
Quoted 11 lines · Paul E. McKenney
Quoted 10 lines · On Wed, Aug 04, 2010 at 04:23:43PM -0700, [email protected] wrote:
Quoted 2 lines · Arve Hj?nnev?g
We suspend as soon as no wakelocks are held. There is no delay.
So, if I have a bookreader app that is not allowed to get the wakelock, and nothing else is running, the system will suspend immediatly after I click a button to go to the next page? it will not stay awake to give me a chance to read the page at all?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
how can any application run without wakelock privilages?
Isn't a wakelock held as long as the display is lit, so that the system would continue running as long as the page was visible?
what holds this wakelock, and what sort of timeout does it have? (and why could that same timeout be used in other ways instead)
I defer to the Android guys on what exactly holds the display's wakelock. The timeout is the display-blank timeout.
Quoted 4 lines
how many apps really need to keep running after the screen blanks? there are a few (audio output apps, including music player and Navigation directions), but I don't have see a problem with them being marked as the 'trusted' apps to pay attention instead.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Downloading is another.
this is definantly an interesting case, do you want an active network connection to keep the machine awake? if so do you want it for all network connections, or only for some...
The Android approach is that everything is permitted to run when the device is not suspended. So that would be all network connections.
I wasn't suggesting freezing some network connections while letting others run, I was thinking in terms of 'if the system patcher daemon is downloading, don't go to sleep, but if it's dancing cows (or mail client to an IMAP server) go ahead and sleep, even if there is some data passing over the connection.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
Quoted 6 lines
Quoted 3 lines
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
correct, but the number of such apps indicates the scope of the problem.
Quoted 1 line
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the system_server, possibly the media_server and the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.
Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
David Lang
Quoted 3 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 2 lines · Paul E. McKenney
Quoted 1 line · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 8 lines
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Ah, I was assuming -much- shorter "do full suspend" timeouts.
My (possibly incorrect) assumption is based on the complaint that led to my implementing RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
correct, but the number of such apps indicates the scope of the problem.
The number of such apps certainly indicates the amount of effort required to modify them, if required. Is that what you are getting at?
Quoted 11 lines
Quoted 2 lines
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the
system_server, possibly themedia_serverand the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.
Quoted 6 lines
Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
Hmmm... Isn't it the "trusted" (AKA PM-driving) apps that interact with the power daemon via suspend blockers, rather than the other way around?
Quoted 2 lines
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
Powertop is indeed an extremely valuable tool, but I am not certain that it really provides the information that the Android guys need. If I understand Arve's and Brian's posts, here is the scenario that they are trying to detect:
o Some PM-driving application has a bug in which it fails to
release a wakelock, thus blocking suspend indefinitely.
o This PM-driving application, otherwise being a good citizen,
blocks.
o There are numerous power-oblivious apps running, consuming
significant CPU.
What the Android developers need to know is that the trusted application is wrongly holding a wakelock. Won't powertop instead tell them about all the power-oblivious apps?
Thanx, Paul
Quoted 3 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 2 lines · Paul E. McKenney
Quoted 1 line · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 8 lines
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Ah, I was assuming -much- shorter "do full suspend" timeouts.
My (possibly incorrect) assumption is based on the complaint that led to my implementing RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
correct, but the number of such apps indicates the scope of the problem.
The number of such apps certainly indicates the amount of effort required to modify them, if required. Is that what you are getting at?
Quoted 11 lines
Quoted 2 lines
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the
system_server, possibly themedia_serverand the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.
Quoted 6 lines
Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
Hmmm... Isn't it the "trusted" (AKA PM-driving) apps that interact with the power daemon via suspend blockers, rather than the other way around?
Quoted 2 lines
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
Powertop is indeed an extremely valuable tool, but I am not certain that it really provides the information that the Android guys need. If I understand Arve's and Brian's posts, here is the scenario that they are trying to detect:
o Some PM-driving application has a bug in which it fails to
release a wakelock, thus blocking suspend indefinitely.
o This PM-driving application, otherwise being a good citizen,
blocks.
o There are numerous power-oblivious apps running, consuming
significant CPU.
What the Android developers need to know is that the trusted application is wrongly holding a wakelock. Won't powertop instead tell them about all the power-oblivious apps?
Thanx, Paul
Quoted 44 lines · Paul E. McKenney
Quoted 3 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 2 lines · Paul E. McKenney
Quoted 1 line · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 8 lines
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Ah, I was assuming -much- shorter "do full suspend" timeouts.
My (possibly incorrect) assumption is based on the complaint that led to my implementing
RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.
Quoted 2 lines
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
if the system was looking at all applications I would agree that the timeout should be much shorter.
I have a couple devices that are able to have the display usable, even if the CPU is asleep (the OLPC and the Kindle, two different display technologies). With these devices I would like to see the suspend happen so fast that it can suspend between keystrokes.
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
correct, but the number of such apps indicates the scope of the problem.
The number of such apps certainly indicates the amount of effort required to modify them, if required. Is that what you are getting at?
yes.
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the
system_server, possibly themedia_serverand the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
Quoted 6 lines
Quoted 3 lines
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
Hmmm... Isn't it the "trusted" (AKA PM-driving) apps that interact with the power daemon via suspend blockers, rather than the other way around?
I was looking at it from a kernel point of view, "trusted" (AKA PM-driving) apps are ones that have permission to grab the wakelock. Any app/daemon that is so trusted can communicate with anything else in userspace as part of making it's decision on whento take the wakelock, but those other applications would not qualify as "trusted" in my eyes.
Quoted 14 lines
Quoted 2 lines
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
Powertop is indeed an extremely valuable tool, but I am not certain that it really provides the information that the Android guys need. If I understand Arve's and Brian's posts, here is the scenario that they are trying to detect:
o Some PM-driving application has a bug in which it fails to
release a wakelock, thus blocking suspend indefinitely.o This PM-driving application, otherwise being a good citizen,
blocks.
Quoted 6 lines
o There are numerous power-oblivious apps running, consuming
significant CPU.What the Android developers need to know is that the trusted application is wrongly holding a wakelock. Won't powertop instead tell them about all the power-oblivious apps?
in my proposal (without a wakelock), powertop would tell you what applications are running and setting timers. If we can modify the kernel/suspend decision code to only look at processes in one cgroup when deciding if the system should go to sleep, a similar modification to poewrtop should let you only show stats on the "trusted" applications.
If you have a userspace power management daemon that accepts requests from untrusted programs and does something to keep the system from sleeping (either taking a wakelock or setting a 'short' timer), it needs to keep the records of this itself because otherwise all the kernel will see (with either powertop or wakelock reporting) is that the power management daemon is what kept the system from sleeping.
David Lang
Quoted 44 lines · Paul E. McKenney
Quoted 3 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 2 lines · Paul E. McKenney
Quoted 1 line · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 8 lines
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Ah, I was assuming -much- shorter "do full suspend" timeouts.
My (possibly incorrect) assumption is based on the complaint that led to my implementing
RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.
Quoted 2 lines
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
if the system was looking at all applications I would agree that the timeout should be much shorter.
I have a couple devices that are able to have the display usable, even if the CPU is asleep (the OLPC and the Kindle, two different display technologies). With these devices I would like to see the suspend happen so fast that it can suspend between keystrokes.
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
correct, but the number of such apps indicates the scope of the problem.
The number of such apps certainly indicates the amount of effort required to modify them, if required. Is that what you are getting at?
yes.
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the
system_server, possibly themedia_serverand the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
Quoted 6 lines
Quoted 3 lines
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
Hmmm... Isn't it the "trusted" (AKA PM-driving) apps that interact with the power daemon via suspend blockers, rather than the other way around?
I was looking at it from a kernel point of view, "trusted" (AKA PM-driving) apps are ones that have permission to grab the wakelock. Any app/daemon that is so trusted can communicate with anything else in userspace as part of making it's decision on whento take the wakelock, but those other applications would not qualify as "trusted" in my eyes.
Quoted 14 lines
Quoted 2 lines
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
Powertop is indeed an extremely valuable tool, but I am not certain that it really provides the information that the Android guys need. If I understand Arve's and Brian's posts, here is the scenario that they are trying to detect:
o Some PM-driving application has a bug in which it fails to
release a wakelock, thus blocking suspend indefinitely.o This PM-driving application, otherwise being a good citizen,
blocks.
Quoted 6 lines
o There are numerous power-oblivious apps running, consuming
significant CPU.What the Android developers need to know is that the trusted application is wrongly holding a wakelock. Won't powertop instead tell them about all the power-oblivious apps?
in my proposal (without a wakelock), powertop would tell you what applications are running and setting timers. If we can modify the kernel/suspend decision code to only look at processes in one cgroup when deciding if the system should go to sleep, a similar modification to poewrtop should let you only show stats on the "trusted" applications.
If you have a userspace power management daemon that accepts requests from untrusted programs and does something to keep the system from sleeping (either taking a wakelock or setting a 'short' timer), it needs to keep the records of this itself because otherwise all the kernel will see (with either powertop or wakelock reporting) is that the power management daemon is what kept the system from sleeping.
David Lang
Quoted 67 lines · On Thu, Aug 05, 2010 at 08:46:54AM -0700, [email protected] wrote:
Quoted 44 lines · Paul E. McKenney
Quoted 3 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 2 lines · Paul E. McKenney
Quoted 1 line · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 8 lines
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Ah, I was assuming -much- shorter "do full suspend" timeouts.
My (possibly incorrect) assumption is based on the complaint that led to my implementing
RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.Quoted 2 lines
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
if the system was looking at all applications I would agree that the timeout should be much shorter.
I have a couple devices that are able to have the display usable, even if the CPU is asleep (the OLPC and the Kindle, two different display technologies). With these devices I would like to see the suspend happen so fast that it can suspend between keystrokes.
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 8 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
From what I can see, the decision between these two approaches comes down
to their energy efficiencies, and thus their battery lifetimes. Are you in a position to benchmark these two approaches against each other?
Quoted 44 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
correct, but the number of such apps indicates the scope of the problem.
The number of such apps certainly indicates the amount of effort required to modify them, if required. Is that what you are getting at?
yes.
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the
system_server, possibly themedia_serverand the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
Quoted 6 lines
Quoted 3 lines
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
Hmmm... Isn't it the "trusted" (AKA PM-driving) apps that interact with the power daemon via suspend blockers, rather than the other way around?
Quoted 6 lines
I was looking at it from a kernel point of view, "trusted" (AKA PM-driving) apps are ones that have permission to grab the wakelock. Any app/daemon that is so trusted can communicate with anything else in userspace as part of making it's decision on whento take the wakelock, but those other applications would not qualify as "trusted" in my eyes.
So you are saying that PM-driving apps can check up on power-oblivious apps as part of their decision process. Sounds reasonable to me, though such checking increases the dependencies among apps, which might increase complexity.
Quoted 21 lines
Quoted 14 lines
Quoted 2 lines
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
Powertop is indeed an extremely valuable tool, but I am not certain that it really provides the information that the Android guys need. If I understand Arve's and Brian's posts, here is the scenario that they are trying to detect:
o Some PM-driving application has a bug in which it fails to
release a wakelock, thus blocking suspend indefinitely.o This PM-driving application, otherwise being a good citizen,
blocks.Quoted 6 lines
o There are numerous power-oblivious apps running, consuming
significant CPU.What the Android developers need to know is that the trusted application is wrongly holding a wakelock. Won't powertop instead tell them about all the power-oblivious apps?
Quoted 6 lines
in my proposal (without a wakelock), powertop would tell you what applications are running and setting timers. If we can modify the kernel/suspend decision code to only look at processes in one cgroup when deciding if the system should go to sleep, a similar modification to poewrtop should let you only show stats on the "trusted" applications.
Mark Brown suggests adding suspend-blocker information to powertop, which might well be a very good way to handle this. This sounds plausible to me, but then again, I have never chased down wakelock bugs on Android systems.
A key point is that it is not enough to focus on PM-driving apps, you instead need to focus on only those PM-driving apps that currently hold a suspend blocker.
Quoted 7 lines
If you have a userspace power management daemon that accepts requests from untrusted programs and does something to keep the system from sleeping (either taking a wakelock or setting a 'short' timer), it needs to keep the records of this itself because otherwise all the kernel will see (with either powertop or wakelock reporting) is that the power management daemon is what kept the system from sleeping.
According to Brian Swetland, Android does in fact have such a power-management daemon. I would guess that this daemon tracks which apps it is holding suspend blockers on behalf of. This approach might well make it harder to bring powertop to bear, as powertop would need to communicate with Android's power-management daemon. But perhaps something could be arranged.
Thanx, Paul
Quoted 67 lines · On Thu, Aug 05, 2010 at 08:46:54AM -0700, [email protected] wrote:
Quoted 44 lines · Paul E. McKenney
Quoted 3 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 2 lines · Paul E. McKenney
Quoted 1 line · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 8 lines
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Ah, I was assuming -much- shorter "do full suspend" timeouts.
My (possibly incorrect) assumption is based on the complaint that led to my implementing
RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.Quoted 2 lines
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
if the system was looking at all applications I would agree that the timeout should be much shorter.
I have a couple devices that are able to have the display usable, even if the CPU is asleep (the OLPC and the Kindle, two different display technologies). With these devices I would like to see the suspend happen so fast that it can suspend between keystrokes.
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 8 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
From what I can see, the decision between these two approaches comes down
to their energy efficiencies, and thus their battery lifetimes. Are you in a position to benchmark these two approaches against each other?
Quoted 44 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
correct, but the number of such apps indicates the scope of the problem.
The number of such apps certainly indicates the amount of effort required to modify them, if required. Is that what you are getting at?
yes.
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the
system_server, possibly themedia_serverand the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
Quoted 6 lines
Quoted 3 lines
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
Hmmm... Isn't it the "trusted" (AKA PM-driving) apps that interact with the power daemon via suspend blockers, rather than the other way around?
Quoted 6 lines
I was looking at it from a kernel point of view, "trusted" (AKA PM-driving) apps are ones that have permission to grab the wakelock. Any app/daemon that is so trusted can communicate with anything else in userspace as part of making it's decision on whento take the wakelock, but those other applications would not qualify as "trusted" in my eyes.
So you are saying that PM-driving apps can check up on power-oblivious apps as part of their decision process. Sounds reasonable to me, though such checking increases the dependencies among apps, which might increase complexity.
Quoted 21 lines
Quoted 14 lines
Quoted 2 lines
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
Powertop is indeed an extremely valuable tool, but I am not certain that it really provides the information that the Android guys need. If I understand Arve's and Brian's posts, here is the scenario that they are trying to detect:
o Some PM-driving application has a bug in which it fails to
release a wakelock, thus blocking suspend indefinitely.o This PM-driving application, otherwise being a good citizen,
blocks.Quoted 6 lines
o There are numerous power-oblivious apps running, consuming
significant CPU.What the Android developers need to know is that the trusted application is wrongly holding a wakelock. Won't powertop instead tell them about all the power-oblivious apps?
Quoted 6 lines
in my proposal (without a wakelock), powertop would tell you what applications are running and setting timers. If we can modify the kernel/suspend decision code to only look at processes in one cgroup when deciding if the system should go to sleep, a similar modification to poewrtop should let you only show stats on the "trusted" applications.
Mark Brown suggests adding suspend-blocker information to powertop, which might well be a very good way to handle this. This sounds plausible to me, but then again, I have never chased down wakelock bugs on Android systems.
A key point is that it is not enough to focus on PM-driving apps, you instead need to focus on only those PM-driving apps that currently hold a suspend blocker.
Quoted 7 lines
If you have a userspace power management daemon that accepts requests from untrusted programs and does something to keep the system from sleeping (either taking a wakelock or setting a 'short' timer), it needs to keep the records of this itself because otherwise all the kernel will see (with either powertop or wakelock reporting) is that the power management daemon is what kept the system from sleeping.
According to Brian Swetland, Android does in fact have such a power-management daemon. I would guess that this daemon tracks which apps it is holding suspend blockers on behalf of. This approach might well make it harder to bring powertop to bear, as powertop would need to communicate with Android's power-management daemon. But perhaps something could be arranged.
Thanx, Paul
Quoted 77 lines · Paul E. McKenney
Subject: Re: Attempted summary of suspend-blockers LKML thread
Quoted 67 lines · On Thu, Aug 05, 2010 at 08:46:54AM -0700, [email protected] wrote:
Quoted 44 lines · Paul E. McKenney
Quoted 3 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 2 lines · Paul E. McKenney
Quoted 1 line · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 8 lines
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Ah, I was assuming -much- shorter "do full suspend" timeouts.
My (possibly incorrect) assumption is based on the complaint that led to my implementing
RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.Quoted 2 lines
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
if the system was looking at all applications I would agree that the timeout should be much shorter.
I have a couple devices that are able to have the display usable, even if the CPU is asleep (the OLPC and the Kindle, two different display technologies). With these devices I would like to see the suspend happen so fast that it can suspend between keystrokes.
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 6 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
Quoted 3 lines
From what I can see, the decision between these two approaches comes down to their energy efficiencies, and thus their battery lifetimes. Are you in a position to benchmark these two approaches against each other?
no, I'm not in a position to benchmark them against each other.
I am claiming that (in this area) the two are equivalent (or at lease very close to equivalent given the approximate magnatude of the timeouts that are involved)
1. a daemon controls the screen, monitors input and holds a wakelock until a configurable timeout after input, after which the system sleeps
2. a daemon monitors input, it wakes up every few seconds (to 10s of seconds) when there is no input for a configurable timeout the daemon sleep without waking up periodically. when the daemon sleeps for longer than a configurable period the system is considered idle and goes to sleep.
in both cases the system will be awake as long as there is input within the initial timeout period.
the second case could eata smidge power as there can be an additional lag before the system sleeps (the second timeout), that depends on exactly how the input is detected.
Quoted 28 lines
Quoted 21 lines
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the
system_server, possibly themedia_serverand the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
Quoted 6 lines
Quoted 3 lines
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
Hmmm... Isn't it the "trusted" (AKA PM-driving) apps that interact with the power daemon via suspend blockers, rather than the other way around?
Quoted 6 lines
I was looking at it from a kernel point of view, "trusted" (AKA PM-driving) apps are ones that have permission to grab the wakelock. Any app/daemon that is so trusted can communicate with anything else in userspace as part of making it's decision on whento take the wakelock, but those other applications would not qualify as "trusted" in my eyes.
Quoted 4 lines
So you are saying that PM-driving apps can check up on power-oblivious apps as part of their decision process. Sounds reasonable to me, though such checking increases the dependencies among apps, which might increase complexity.
more to the point, I'm saying that that's how it works currently with wavelocks. the unprivilaged processes can ask the privilaged process to hold a wavelock for them.
Quoted 28 lines
Quoted 21 lines
Quoted 14 lines
Quoted 2 lines
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
Powertop is indeed an extremely valuable tool, but I am not certain that it really provides the information that the Android guys need. If I understand Arve's and Brian's posts, here is the scenario that they are trying to detect:
o Some PM-driving application has a bug in which it fails to
release a wakelock, thus blocking suspend indefinitely.o This PM-driving application, otherwise being a good citizen,
blocks.Quoted 6 lines
o There are numerous power-oblivious apps running, consuming
significant CPU.What the Android developers need to know is that the trusted application is wrongly holding a wakelock. Won't powertop instead tell them about all the power-oblivious apps?
Quoted 6 lines
in my proposal (without a wakelock), powertop would tell you what applications are running and setting timers. If we can modify the kernel/suspend decision code to only look at processes in one cgroup when deciding if the system should go to sleep, a similar modification to poewrtop should let you only show stats on the "trusted" applications.
Quoted 8 lines
Mark Brown suggests adding suspend-blocker information to powertop, which might well be a very good way to handle this. This sounds plausible to me, but then again, I have never chased down wakelock bugs on Android systems.
A key point is that it is not enough to focus on PM-driving apps, you instead need to focus on only those PM-driving apps that currently hold a suspend blocker.
if you have wavelocks, then you just need info on the use of wavelocks
with my proposal staying awake is based on process activity, which is exactly what powertop is monitoring now, it just needs to be able to filter out the activity of the untrusted apps.
Quoted 8 lines
Quoted 7 lines
If you have a userspace power management daemon that accepts requests from untrusted programs and does something to keep the system from sleeping (either taking a wakelock or setting a 'short' timer), it needs to keep the records of this itself because otherwise all the kernel will see (with either powertop or wakelock reporting) is that the power management daemon is what kept the system from sleeping.
Quoted 6 lines
According to Brian Swetland, Android does in fact have such a power-management daemon. I would guess that this daemon tracks which apps it is holding suspend blockers on behalf of. This approach might well make it harder to bring powertop to bear, as powertop would need to communicate with Android's power-management daemon. But perhaps something could be arranged.
My expectation is that instead of modifying apps to talk to the power management daemon, the apps would be classified as 'trusted' or 'untrusted' more appropriatly.
if user input is activity that keeps the system alive, then only applications that will run for extended period with no user input need to be trusted.
David Lang
Quoted 77 lines · Paul E. McKenney
Subject: Re: Attempted summary of suspend-blockers LKML thread
Quoted 67 lines · On Thu, Aug 05, 2010 at 08:46:54AM -0700, [email protected] wrote:
Quoted 44 lines · Paul E. McKenney
Quoted 3 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 2 lines · Paul E. McKenney
Quoted 1 line · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 8 lines
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Ah, I was assuming -much- shorter "do full suspend" timeouts.
My (possibly incorrect) assumption is based on the complaint that led to my implementing
RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.Quoted 2 lines
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
if the system was looking at all applications I would agree that the timeout should be much shorter.
I have a couple devices that are able to have the display usable, even if the CPU is asleep (the OLPC and the Kindle, two different display technologies). With these devices I would like to see the suspend happen so fast that it can suspend between keystrokes.
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 6 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
Quoted 3 lines
From what I can see, the decision between these two approaches comes down to their energy efficiencies, and thus their battery lifetimes. Are you in a position to benchmark these two approaches against each other?
no, I'm not in a position to benchmark them against each other.
I am claiming that (in this area) the two are equivalent (or at lease very close to equivalent given the approximate magnatude of the timeouts that are involved)
1. a daemon controls the screen, monitors input and holds a wakelock until a configurable timeout after input, after which the system sleeps
2. a daemon monitors input, it wakes up every few seconds (to 10s of seconds) when there is no input for a configurable timeout the daemon sleep without waking up periodically. when the daemon sleeps for longer than a configurable period the system is considered idle and goes to sleep.
in both cases the system will be awake as long as there is input within the initial timeout period.
the second case could eata smidge power as there can be an additional lag before the system sleeps (the second timeout), that depends on exactly how the input is detected.
Quoted 28 lines
Quoted 21 lines
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the
system_server, possibly themedia_serverand the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
Quoted 6 lines
Quoted 3 lines
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
Hmmm... Isn't it the "trusted" (AKA PM-driving) apps that interact with the power daemon via suspend blockers, rather than the other way around?
Quoted 6 lines
I was looking at it from a kernel point of view, "trusted" (AKA PM-driving) apps are ones that have permission to grab the wakelock. Any app/daemon that is so trusted can communicate with anything else in userspace as part of making it's decision on whento take the wakelock, but those other applications would not qualify as "trusted" in my eyes.
Quoted 4 lines
So you are saying that PM-driving apps can check up on power-oblivious apps as part of their decision process. Sounds reasonable to me, though such checking increases the dependencies among apps, which might increase complexity.
more to the point, I'm saying that that's how it works currently with wavelocks. the unprivilaged processes can ask the privilaged process to hold a wavelock for them.
Quoted 28 lines
Quoted 21 lines
Quoted 14 lines
Quoted 2 lines
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
Powertop is indeed an extremely valuable tool, but I am not certain that it really provides the information that the Android guys need. If I understand Arve's and Brian's posts, here is the scenario that they are trying to detect:
o Some PM-driving application has a bug in which it fails to
release a wakelock, thus blocking suspend indefinitely.o This PM-driving application, otherwise being a good citizen,
blocks.Quoted 6 lines
o There are numerous power-oblivious apps running, consuming
significant CPU.What the Android developers need to know is that the trusted application is wrongly holding a wakelock. Won't powertop instead tell them about all the power-oblivious apps?
Quoted 6 lines
in my proposal (without a wakelock), powertop would tell you what applications are running and setting timers. If we can modify the kernel/suspend decision code to only look at processes in one cgroup when deciding if the system should go to sleep, a similar modification to poewrtop should let you only show stats on the "trusted" applications.
Quoted 8 lines
Mark Brown suggests adding suspend-blocker information to powertop, which might well be a very good way to handle this. This sounds plausible to me, but then again, I have never chased down wakelock bugs on Android systems.
A key point is that it is not enough to focus on PM-driving apps, you instead need to focus on only those PM-driving apps that currently hold a suspend blocker.
if you have wavelocks, then you just need info on the use of wavelocks
with my proposal staying awake is based on process activity, which is exactly what powertop is monitoring now, it just needs to be able to filter out the activity of the untrusted apps.
Quoted 8 lines
Quoted 7 lines
If you have a userspace power management daemon that accepts requests from untrusted programs and does something to keep the system from sleeping (either taking a wakelock or setting a 'short' timer), it needs to keep the records of this itself because otherwise all the kernel will see (with either powertop or wakelock reporting) is that the power management daemon is what kept the system from sleeping.
Quoted 6 lines
According to Brian Swetland, Android does in fact have such a power-management daemon. I would guess that this daemon tracks which apps it is holding suspend blockers on behalf of. This approach might well make it harder to bring powertop to bear, as powertop would need to communicate with Android's power-management daemon. But perhaps something could be arranged.
My expectation is that instead of modifying apps to talk to the power management daemon, the apps would be classified as 'trusted' or 'untrusted' more appropriatly.
if user input is activity that keeps the system alive, then only applications that will run for extended period with no user input need to be trusted.
David Lang
Quoted 70 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 47 lines · Paul E. McKenney
Quoted 6 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 4 lines · Paul E. McKenney
Quoted 2 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 8 lines
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Ah, I was assuming -much- shorter "do full suspend" timeouts.
My (possibly incorrect) assumption is based on the complaint that led to my implementing
RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.Quoted 2 lines
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
if the system was looking at all applications I would agree that the timeout should be much shorter.
I have a couple devices that are able to have the display usable, even if the CPU is asleep (the OLPC and the Kindle, two different display technologies). With these devices I would like to see the suspend happen so fast that it can suspend between keystrokes.
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
Quoted 92 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 9 lines
Quoted 4 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
correct, but the number of such apps indicates the scope of the problem.
The number of such apps certainly indicates the amount of effort required to modify them, if required. Is that what you are getting at?
yes.
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the
system_server, possibly themedia_serverand the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
Quoted 6 lines
Quoted 3 lines
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
Hmmm... Isn't it the "trusted" (AKA PM-driving) apps that interact with the power daemon via suspend blockers, rather than the other way around?
I was looking at it from a kernel point of view, "trusted" (AKA PM-driving) apps are ones that have permission to grab the wakelock. Any app/daemon that is so trusted can communicate with anything else in userspace as part of making it's decision on whento take the wakelock, but those other applications would not qualify as "trusted" in my eyes.
Quoted 14 lines
Quoted 2 lines
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
Powertop is indeed an extremely valuable tool, but I am not certain that it really provides the information that the Android guys need. If I understand Arve's and Brian's posts, here is the scenario that they are trying to detect:
o Some PM-driving application has a bug in which it fails to release a wakelock, thus blocking suspend indefinitely.
o This PM-driving application, otherwise being a good citizen, blocks.
Quoted 6 lines
o There are numerous power-oblivious apps running, consuming significant CPU.
What the Android developers need to know is that the trusted application is wrongly holding a wakelock. Won't powertop instead tell them about all the power-oblivious apps?
in my proposal (without a wakelock), powertop would tell you what applications are running and setting timers. If we can modify the kernel/suspend decision code to only look at processes in one cgroup when deciding if the system should go to sleep, a similar modification to poewrtop should let you only show stats on the "trusted" applications.
If you have a userspace power management daemon that accepts requests from untrusted programs and does something to keep the system from sleeping (either taking a wakelock or setting a 'short' timer), it needs to keep the records of this itself because otherwise all the kernel will see (with either powertop or wakelock reporting) is that the power management daemon is what kept the system from sleeping.
David Lang
--
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 70 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 47 lines · Paul E. McKenney
Quoted 6 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 4 lines · Paul E. McKenney
Quoted 2 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 8 lines
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Ah, I was assuming -much- shorter "do full suspend" timeouts.
My (possibly incorrect) assumption is based on the complaint that led to my implementing
RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.Quoted 2 lines
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
if the system was looking at all applications I would agree that the timeout should be much shorter.
I have a couple devices that are able to have the display usable, even if the CPU is asleep (the OLPC and the Kindle, two different display technologies). With these devices I would like to see the suspend happen so fast that it can suspend between keystrokes.
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
Quoted 92 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 9 lines
Quoted 4 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
correct, but the number of such apps indicates the scope of the problem.
The number of such apps certainly indicates the amount of effort required to modify them, if required. Is that what you are getting at?
yes.
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the
system_server, possibly themedia_serverand the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
Quoted 6 lines
Quoted 3 lines
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
Hmmm... Isn't it the "trusted" (AKA PM-driving) apps that interact with the power daemon via suspend blockers, rather than the other way around?
I was looking at it from a kernel point of view, "trusted" (AKA PM-driving) apps are ones that have permission to grab the wakelock. Any app/daemon that is so trusted can communicate with anything else in userspace as part of making it's decision on whento take the wakelock, but those other applications would not qualify as "trusted" in my eyes.
Quoted 14 lines
Quoted 2 lines
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
Powertop is indeed an extremely valuable tool, but I am not certain that it really provides the information that the Android guys need. If I understand Arve's and Brian's posts, here is the scenario that they are trying to detect:
o Some PM-driving application has a bug in which it fails to release a wakelock, thus blocking suspend indefinitely.
o This PM-driving application, otherwise being a good citizen, blocks.
Quoted 6 lines
o There are numerous power-oblivious apps running, consuming significant CPU.
What the Android developers need to know is that the trusted application is wrongly holding a wakelock. Won't powertop instead tell them about all the power-oblivious apps?
in my proposal (without a wakelock), powertop would tell you what applications are running and setting timers. If we can modify the kernel/suspend decision code to only look at processes in one cgroup when deciding if the system should go to sleep, a similar modification to poewrtop should let you only show stats on the "trusted" applications.
If you have a userspace power management daemon that accepts requests from untrusted programs and does something to keep the system from sleeping (either taking a wakelock or setting a 'short' timer), it needs to keep the records of this itself because otherwise all the kernel will see (with either powertop or wakelock reporting) is that the power management daemon is what kept the system from sleeping.
David Lang
--
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 6 lines · kevin granade
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
The display being on should not prevent suspend unless the particular platform is incapable of suspending while the display is on.
Quoted 12 lines
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
Yeah, we much prefer the wakelock model where the moment the resource (system-needing-to-not-be-suspended) is released we return to the lowest power state, rather than waiting for a timer to expire (and/or burning cycles polling for "can we suspend yet?" when we're definitely not ready to suspend).
Brian
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Quoted 6 lines · kevin granade
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
The display being on should not prevent suspend unless the particular platform is incapable of suspending while the display is on.
Quoted 12 lines
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
Yeah, we much prefer the wakelock model where the moment the resource (system-needing-to-not-be-suspended) is released we return to the lowest power state, rather than waiting for a timer to expire (and/or burning cycles polling for "can we suspend yet?" when we're definitely not ready to suspend).
Brian
Quoted 10 lines · Brian Swetland
Quoted 6 lines · kevin granade
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
The display being on should not prevent suspend unless the particular platform is incapable of suspending while the display is on.
if that is the case, I'll go back to my question about the untrusted reader app.
what is it that will prevent the system from going to sleep while I am reading the page?
Quoted 19 lines
Quoted 12 lines
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
Quoted 5 lines
Yeah, we much prefer the wakelock model where the moment the resource (system-needing-to-not-be-suspended) is released we return to the lowest power state, rather than waiting for a timer to expire (and/or burning cycles polling for "can we suspend yet?" when we're definitely not ready to suspend).
at the micro level it is definantly better for power, but at the macro level I don't think it needs to make much difference in the overall battery life of the device. To borrow a phrase, I think you may be into premature optimization of power :-)
David Lang
Quoted 10 lines · Brian Swetland
Quoted 6 lines · kevin granade
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
The display being on should not prevent suspend unless the particular platform is incapable of suspending while the display is on.
if that is the case, I'll go back to my question about the untrusted reader app.
what is it that will prevent the system from going to sleep while I am reading the page?
Quoted 19 lines
Quoted 12 lines
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
Quoted 5 lines
Yeah, we much prefer the wakelock model where the moment the resource (system-needing-to-not-be-suspended) is released we return to the lowest power state, rather than waiting for a timer to expire (and/or burning cycles polling for "can we suspend yet?" when we're definitely not ready to suspend).
at the micro level it is definantly better for power, but at the macro level I don't think it needs to make much difference in the overall battery life of the device. To borrow a phrase, I think you may be into premature optimization of power :-)
David Lang
Quoted 41 lines · kevin granade
Quoted 22 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 10 lines · Paul E. McKenney
Quoted 6 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 4 lines · Paul E. McKenney
Quoted 2 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
Quoted 6 lines
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
when you suspend the audio will shut off, so it's sleep ->wake -> sleep, not suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
it really depnds on the frequency of the wakeups.
if you get a network packet once every 5 min and need to wake to process it, staying awake for 20 seconds after finishing procesing is FAR more significant than if you get a network packet once every hour. It's not just the factor of 20 that simple math would indicate because the time in suspend eats power as well.
I don't know real numbers, so these are made up for this example
if suspend (with the cell live to receive packets) is 10ma average current and full power is 500ma average current
packets every 5 min with .1 sec wake time will eat ~13maH per hour
packets every 5 min with 10 second wake time will eat ~37maH per hour
packets every hour with .1 sec wake time will eat ~10maH per hour
packets every hour with 10 sec wake time will eat ~11maH per hour
so if you have frequent wakeups, staying awake 100 times as long will cut your battery life to 1/3 what it was before.
if your wakeups are rare, it's about a 10% hit to stay awake 100 times as long.
there is a lot of room for tuning the timeouts here.
David Lang
Quoted 41 lines · kevin granade
Quoted 22 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 10 lines · Paul E. McKenney
Quoted 6 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 4 lines · Paul E. McKenney
Quoted 2 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
Quoted 6 lines
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
when you suspend the audio will shut off, so it's sleep ->wake -> sleep, not suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
it really depnds on the frequency of the wakeups.
if you get a network packet once every 5 min and need to wake to process it, staying awake for 20 seconds after finishing procesing is FAR more significant than if you get a network packet once every hour. It's not just the factor of 20 that simple math would indicate because the time in suspend eats power as well.
I don't know real numbers, so these are made up for this example
if suspend (with the cell live to receive packets) is 10ma average current and full power is 500ma average current
packets every 5 min with .1 sec wake time will eat ~13maH per hour
packets every 5 min with 10 second wake time will eat ~37maH per hour
packets every hour with .1 sec wake time will eat ~10maH per hour
packets every hour with 10 sec wake time will eat ~11maH per hour
so if you have frequent wakeups, staying awake 100 times as long will cut your battery life to 1/3 what it was before.
if your wakeups are rare, it's about a 10% hit to stay awake 100 times as long.
there is a lot of room for tuning the timeouts here.
David Lang
Quoted 81 lines · On Thu, Aug 05, 2010 at 01:26:18PM -0700, [email protected] wrote:
Quoted 41 lines · kevin granade
Quoted 22 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 10 lines · Paul E. McKenney
Quoted 6 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 4 lines · Paul E. McKenney
Quoted 2 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
Quoted 6 lines
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
when you suspend the audio will shut off, so it's sleep ->wake -> sleep, not suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
it really depnds on the frequency of the wakeups.
if you get a network packet once every 5 min and need to wake to process it, staying awake for 20 seconds after finishing procesing is FAR more significant than if you get a network packet once every hour. It's not just the factor of 20 that simple math would indicate because the time in suspend eats power as well.
I don't know real numbers, so these are made up for this example
if suspend (with the cell live to receive packets) is 10ma average current and full power is 500ma average current
packets every 5 min with .1 sec wake time will eat ~13maH per hour
packets every 5 min with 10 second wake time will eat ~37maH per hour
packets every hour with .1 sec wake time will eat ~10maH per hour
packets every hour with 10 sec wake time will eat ~11maH per hour
Quoted 7 lines
so if you have frequent wakeups, staying awake 100 times as long will cut your battery life to 1/3 what it was before.
if your wakeups are rare, it's about a 10% hit to stay awake 100 times as long.
there is a lot of room for tuning the timeouts here.
Especially given different scenarios, for example, audio playback when the device is in airplane mode. ;-)
Thanx, Paul
Quoted 81 lines · On Thu, Aug 05, 2010 at 01:26:18PM -0700, [email protected] wrote:
Quoted 41 lines · kevin granade
Quoted 22 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 10 lines · Paul E. McKenney
Quoted 6 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 4 lines · Paul E. McKenney
Quoted 2 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
Quoted 6 lines
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
when you suspend the audio will shut off, so it's sleep ->wake -> sleep, not suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
it really depnds on the frequency of the wakeups.
if you get a network packet once every 5 min and need to wake to process it, staying awake for 20 seconds after finishing procesing is FAR more significant than if you get a network packet once every hour. It's not just the factor of 20 that simple math would indicate because the time in suspend eats power as well.
I don't know real numbers, so these are made up for this example
if suspend (with the cell live to receive packets) is 10ma average current and full power is 500ma average current
packets every 5 min with .1 sec wake time will eat ~13maH per hour
packets every 5 min with 10 second wake time will eat ~37maH per hour
packets every hour with .1 sec wake time will eat ~10maH per hour
packets every hour with 10 sec wake time will eat ~11maH per hour
Quoted 7 lines
so if you have frequent wakeups, staying awake 100 times as long will cut your battery life to 1/3 what it was before.
if your wakeups are rare, it's about a 10% hit to stay awake 100 times as long.
there is a lot of room for tuning the timeouts here.
Especially given different scenarios, for example, audio playback when the device is in airplane mode. ;-)
Thanx, Paul
Quoted 85 lines · Paul E. McKenney
Quoted 84 lines · On Thu, Aug 05, 2010 at 01:26:18PM -0700, [email protected] wrote:
Quoted 41 lines · kevin granade
Quoted 22 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 10 lines · Paul E. McKenney
Quoted 6 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 4 lines · Paul E. McKenney
Quoted 2 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
Quoted 6 lines
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
when you suspend the audio will shut off, so it's sleep ->wake -> sleep, not suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
it really depnds on the frequency of the wakeups.
if you get a network packet once every 5 min and need to wake to process it, staying awake for 20 seconds after finishing procesing is FAR more significant than if you get a network packet once every hour. It's not just the factor of 20 that simple math would indicate because the time in suspend eats power as well.
I don't know real numbers, so these are made up for this example
if suspend (with the cell live to receive packets) is 10ma average current and full power is 500ma average current
packets every 5 min with .1 sec wake time will eat ~13maH per hour
packets every 5 min with 10 second wake time will eat ~37maH per hour
packets every hour with .1 sec wake time will eat ~10maH per hour
packets every hour with 10 sec wake time will eat ~11maH per hour
so if you have frequent wakeups, staying awake 100 times as long will cut your battery life to 1/3 what it was before.
Quoted 7 lines
Quoted 4 lines
if your wakeups are rare, it's about a 10% hit to stay awake 100 times as long.
there is a lot of room for tuning the timeouts here.
Especially given different scenarios, for example, audio playback when the device is in airplane mode. ;-)
hmm, I've been thinking and talking in terms of two classes of cgroups, trusted and untrusted. I wonder if it would be possible to set timeouts for each cgroup instead)
the system would go to sleep IFF all cgroups have been idle longer than the idle time (with -1 idle time being 'ignore this cgroup')
if this could be done you could set longer times for things designed for user-interaction than you do for other purposes.
you could set media to 0 idle time (so that as soon as it finishes processing the system can sleep until the next timer)
to do this, the code making the decision would have to be able to find out the following fairly cheaply.
1. for this cgroup, what was the last time something ran
2. for this cgroup, what is the next timer set
it would be nice to get network traffic/connection stats.
so two questions.
first, what else would you need to get accumulated for the cgroup
second, is there a fairly easy way to have these stats available?
for the 'last time it ran' stat, this seems like you could have a per-cpu variable per cgroup that's fairly cheap to update, but you would need to take a global lock to read accuratly (the lock may be expensive enough that it's worth trying to read the variables from the other cpu without a lock, just to see if it's remotely possible to sleep/suspend)
with timers, is it possible to have multiple timer wheels (one per cgroup)?
David Lang
Quoted 85 lines · Paul E. McKenney
Quoted 84 lines · On Thu, Aug 05, 2010 at 01:26:18PM -0700, [email protected] wrote:
Quoted 41 lines · kevin granade
Quoted 22 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 10 lines · Paul E. McKenney
Quoted 6 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 4 lines · Paul E. McKenney
Quoted 2 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
Quoted 6 lines
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
when you suspend the audio will shut off, so it's sleep ->wake -> sleep, not suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
it really depnds on the frequency of the wakeups.
if you get a network packet once every 5 min and need to wake to process it, staying awake for 20 seconds after finishing procesing is FAR more significant than if you get a network packet once every hour. It's not just the factor of 20 that simple math would indicate because the time in suspend eats power as well.
I don't know real numbers, so these are made up for this example
if suspend (with the cell live to receive packets) is 10ma average current and full power is 500ma average current
packets every 5 min with .1 sec wake time will eat ~13maH per hour
packets every 5 min with 10 second wake time will eat ~37maH per hour
packets every hour with .1 sec wake time will eat ~10maH per hour
packets every hour with 10 sec wake time will eat ~11maH per hour
so if you have frequent wakeups, staying awake 100 times as long will cut your battery life to 1/3 what it was before.
Quoted 7 lines
Quoted 4 lines
if your wakeups are rare, it's about a 10% hit to stay awake 100 times as long.
there is a lot of room for tuning the timeouts here.
Especially given different scenarios, for example, audio playback when the device is in airplane mode. ;-)
hmm, I've been thinking and talking in terms of two classes of cgroups, trusted and untrusted. I wonder if it would be possible to set timeouts for each cgroup instead)
the system would go to sleep IFF all cgroups have been idle longer than the idle time (with -1 idle time being 'ignore this cgroup')
if this could be done you could set longer times for things designed for user-interaction than you do for other purposes.
you could set media to 0 idle time (so that as soon as it finishes processing the system can sleep until the next timer)
to do this, the code making the decision would have to be able to find out the following fairly cheaply.
1. for this cgroup, what was the last time something ran
2. for this cgroup, what is the next timer set
it would be nice to get network traffic/connection stats.
so two questions.
first, what else would you need to get accumulated for the cgroup
second, is there a fairly easy way to have these stats available?
for the 'last time it ran' stat, this seems like you could have a per-cpu variable per cgroup that's fairly cheap to update, but you would need to take a global lock to read accuratly (the lock may be expensive enough that it's worth trying to read the variables from the other cpu without a lock, just to see if it's remotely possible to sleep/suspend)
with timers, is it possible to have multiple timer wheels (one per cgroup)?
David Lang
Quoted 130 lines · On Fri, Aug 06, 2010 at 01:29:57AM -0700, [email protected] wrote:
Quoted 85 lines · Paul E. McKenney
Quoted 84 lines · On Thu, Aug 05, 2010 at 01:26:18PM -0700, [email protected] wrote:
Quoted 41 lines · kevin granade
Quoted 22 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 10 lines · Paul E. McKenney
Quoted 6 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 4 lines · Paul E. McKenney
Quoted 2 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
Quoted 6 lines
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
when you suspend the audio will shut off, so it's sleep ->wake -> sleep, not suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
it really depnds on the frequency of the wakeups.
if you get a network packet once every 5 min and need to wake to process it, staying awake for 20 seconds after finishing procesing is FAR more significant than if you get a network packet once every hour. It's not just the factor of 20 that simple math would indicate because the time in suspend eats power as well.
I don't know real numbers, so these are made up for this example
if suspend (with the cell live to receive packets) is 10ma average current and full power is 500ma average current
packets every 5 min with .1 sec wake time will eat ~13maH per hour
packets every 5 min with 10 second wake time will eat ~37maH per hour
packets every hour with .1 sec wake time will eat ~10maH per hour
packets every hour with 10 sec wake time will eat ~11maH per hour
so if you have frequent wakeups, staying awake 100 times as long will cut your battery life to 1/3 what it was before.
Quoted 7 lines
Quoted 4 lines
if your wakeups are rare, it's about a 10% hit to stay awake 100 times as long.
there is a lot of room for tuning the timeouts here.
Especially given different scenarios, for example, audio playback when the device is in airplane mode. ;-)
hmm, I've been thinking and talking in terms of two classes of cgroups, trusted and untrusted. I wonder if it would be possible to set timeouts for each cgroup instead)
the system would go to sleep IFF all cgroups have been idle longer than the idle time (with -1 idle time being 'ignore this cgroup')
if this could be done you could set longer times for things designed for user-interaction than you do for other purposes.
you could set media to 0 idle time (so that as soon as it finishes processing the system can sleep until the next timer)
to do this, the code making the decision would have to be able to find out the following fairly cheaply.
1. for this cgroup, what was the last time something ran
2. for this cgroup, what is the next timer set
it would be nice to get network traffic/connection stats.
so two questions.
first, what else would you need to get accumulated for the cgroup
second, is there a fairly easy way to have these stats available?
for the 'last time it ran' stat, this seems like you could have a per-cpu variable per cgroup that's fairly cheap to update, but you would need to take a global lock to read accuratly (the lock may be expensive enough that it's worth trying to read the variables from the other cpu without a lock, just to see if it's remotely possible to sleep/suspend)
Quoted 2 lines
with timers, is it possible to have multiple timer wheels (one per cgroup)?
I apologize in advance for what I am about to write, but...
If you continue in this vein, you are likely to make suspend blockers look very simple and natural. ;-)
Thanx, Paul
Quoted 130 lines · On Fri, Aug 06, 2010 at 01:29:57AM -0700, [email protected] wrote:
Quoted 85 lines · Paul E. McKenney
Quoted 84 lines · On Thu, Aug 05, 2010 at 01:26:18PM -0700, [email protected] wrote:
Quoted 41 lines · kevin granade
Quoted 22 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 10 lines · Paul E. McKenney
Quoted 6 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 4 lines · Paul E. McKenney
Quoted 2 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
Quoted 6 lines
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
when you suspend the audio will shut off, so it's sleep ->wake -> sleep, not suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
it really depnds on the frequency of the wakeups.
if you get a network packet once every 5 min and need to wake to process it, staying awake for 20 seconds after finishing procesing is FAR more significant than if you get a network packet once every hour. It's not just the factor of 20 that simple math would indicate because the time in suspend eats power as well.
I don't know real numbers, so these are made up for this example
if suspend (with the cell live to receive packets) is 10ma average current and full power is 500ma average current
packets every 5 min with .1 sec wake time will eat ~13maH per hour
packets every 5 min with 10 second wake time will eat ~37maH per hour
packets every hour with .1 sec wake time will eat ~10maH per hour
packets every hour with 10 sec wake time will eat ~11maH per hour
so if you have frequent wakeups, staying awake 100 times as long will cut your battery life to 1/3 what it was before.
Quoted 7 lines
Quoted 4 lines
if your wakeups are rare, it's about a 10% hit to stay awake 100 times as long.
there is a lot of room for tuning the timeouts here.
Especially given different scenarios, for example, audio playback when the device is in airplane mode. ;-)
hmm, I've been thinking and talking in terms of two classes of cgroups, trusted and untrusted. I wonder if it would be possible to set timeouts for each cgroup instead)
the system would go to sleep IFF all cgroups have been idle longer than the idle time (with -1 idle time being 'ignore this cgroup')
if this could be done you could set longer times for things designed for user-interaction than you do for other purposes.
you could set media to 0 idle time (so that as soon as it finishes processing the system can sleep until the next timer)
to do this, the code making the decision would have to be able to find out the following fairly cheaply.
1. for this cgroup, what was the last time something ran
2. for this cgroup, what is the next timer set
it would be nice to get network traffic/connection stats.
so two questions.
first, what else would you need to get accumulated for the cgroup
second, is there a fairly easy way to have these stats available?
for the 'last time it ran' stat, this seems like you could have a per-cpu variable per cgroup that's fairly cheap to update, but you would need to take a global lock to read accuratly (the lock may be expensive enough that it's worth trying to read the variables from the other cpu without a lock, just to see if it's remotely possible to sleep/suspend)
Quoted 2 lines
with timers, is it possible to have multiple timer wheels (one per cgroup)?
I apologize in advance for what I am about to write, but...
If you continue in this vein, you are likely to make suspend blockers look very simple and natural. ;-)
Thanx, Paul
Quoted 35 lines · Paul E. McKenney
Quoted 34 lines · On Fri, Aug 06, 2010 at 01:29:57AM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney
Quoted 7 lines · On Thu, Aug 05, 2010 at 01:26:18PM -0700, [email protected] wrote:
Quoted 5 lines · kevin granade
Quoted 4 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 2 lines · Paul E. McKenney
Quoted 1 line · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines · Paul E. McKenney
Quoted 4 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
Quoted 2 lines · Paul E. McKenney
[ . . . ]
it would be nice to get network traffic/connection stats.
so two questions.
first, what else would you need to get accumulated for the cgroup
second, is there a fairly easy way to have these stats available?
for the 'last time it ran' stat, this seems like you could have a per-cpu variable per cgroup that's fairly cheap to update, but you would need to take a global lock to read accuratly (the lock may be expensive enough that it's worth trying to read the variables from the other cpu without a lock, just to see if it's remotely possible to sleep/suspend)
Quoted 7 lines
Quoted 2 lines
with timers, is it possible to have multiple timer wheels (one per cgroup)?
I apologize in advance for what I am about to write, but...
If you continue in this vein, you are likely to make suspend blockers look very simple and natural. ;-)
if that's the case then they should be implemented :-)
on the other hand, this may be something that's desirable for idle-low-power as well.
David Lang
Quoted 35 lines · Paul E. McKenney
Quoted 34 lines · On Fri, Aug 06, 2010 at 01:29:57AM -0700, [email protected] wrote:
Quoted 8 lines · Paul E. McKenney
Quoted 7 lines · On Thu, Aug 05, 2010 at 01:26:18PM -0700, [email protected] wrote:
Quoted 5 lines · kevin granade
Quoted 4 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 2 lines · Paul E. McKenney
Quoted 1 line · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines · Paul E. McKenney
Quoted 4 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
Quoted 2 lines · Paul E. McKenney
[ . . . ]
it would be nice to get network traffic/connection stats.
so two questions.
first, what else would you need to get accumulated for the cgroup
second, is there a fairly easy way to have these stats available?
for the 'last time it ran' stat, this seems like you could have a per-cpu variable per cgroup that's fairly cheap to update, but you would need to take a global lock to read accuratly (the lock may be expensive enough that it's worth trying to read the variables from the other cpu without a lock, just to see if it's remotely possible to sleep/suspend)
Quoted 7 lines
Quoted 2 lines
with timers, is it possible to have multiple timer wheels (one per cgroup)?
I apologize in advance for what I am about to write, but...
If you continue in this vein, you are likely to make suspend blockers look very simple and natural. ;-)
if that's the case then they should be implemented :-)
on the other hand, this may be something that's desirable for idle-low-power as well.
David Lang
Quoted 96 lines · kevin granade
Quoted 70 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 47 lines · Paul E. McKenney
Quoted 6 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 4 lines · Paul E. McKenney
Quoted 2 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 8 lines
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Ah, I was assuming -much- shorter "do full suspend" timeouts.
My (possibly incorrect) assumption is based on the complaint that led to my implementing
RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.Quoted 2 lines
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
if the system was looking at all applications I would agree that the timeout should be much shorter.
I have a couple devices that are able to have the display usable, even if the CPU is asleep (the OLPC and the Kindle, two different display technologies). With these devices I would like to see the suspend happen so fast that it can suspend between keystrokes.
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
It would be good to get some sort of range for the "timeout". In the audio-output case, my understanding that the spacing between bursts of audio-processing activity is measured in some hundreds of milliseconds, in which case one would want the delays until suspend to be on the millisecond scale. But does Android really suspend between bursts of audio processing while playing music? Very cool if so! ;-)
Thanx, Paul
Quoted 91 lines
Quoted 91 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
correct, but the number of such apps indicates the scope of the problem.
The number of such apps certainly indicates the amount of effort required to modify them, if required. Is that what you are getting at?
yes.
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the
system_server, possibly themedia_serverand the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
Quoted 6 lines
Quoted 3 lines
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
Hmmm... Isn't it the "trusted" (AKA PM-driving) apps that interact with the power daemon via suspend blockers, rather than the other way around?
I was looking at it from a kernel point of view, "trusted" (AKA PM-driving) apps are ones that have permission to grab the wakelock. Any app/daemon that is so trusted can communicate with anything else in userspace as part of making it's decision on whento take the wakelock, but those other applications would not qualify as "trusted" in my eyes.
Quoted 14 lines
Quoted 2 lines
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
Powertop is indeed an extremely valuable tool, but I am not certain that it really provides the information that the Android guys need. If I understand Arve's and Brian's posts, here is the scenario that they are trying to detect:
o Some PM-driving application has a bug in which it fails to release a wakelock, thus blocking suspend indefinitely.
o This PM-driving application, otherwise being a good citizen, blocks.
Quoted 6 lines
o There are numerous power-oblivious apps running, consuming significant CPU.
What the Android developers need to know is that the trusted application is wrongly holding a wakelock. Won't powertop instead tell them about all the power-oblivious apps?
in my proposal (without a wakelock), powertop would tell you what applications are running and setting timers. If we can modify the kernel/suspend decision code to only look at processes in one cgroup when deciding if the system should go to sleep, a similar modification to poewrtop should let you only show stats on the "trusted" applications.
If you have a userspace power management daemon that accepts requests from untrusted programs and does something to keep the system from sleeping (either taking a wakelock or setting a 'short' timer), it needs to keep the records of this itself because otherwise all the kernel will see (with either powertop or wakelock reporting) is that the power management daemon is what kept the system from sleeping.
David Lang
--
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 96 lines · kevin granade
Quoted 70 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 47 lines · Paul E. McKenney
Quoted 6 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 4 lines · Paul E. McKenney
Quoted 2 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 8 lines
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Ah, I was assuming -much- shorter "do full suspend" timeouts.
My (possibly incorrect) assumption is based on the complaint that led to my implementing
RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.Quoted 2 lines
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
if the system was looking at all applications I would agree that the timeout should be much shorter.
I have a couple devices that are able to have the display usable, even if the CPU is asleep (the OLPC and the Kindle, two different display technologies). With these devices I would like to see the suspend happen so fast that it can suspend between keystrokes.
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
It would be good to get some sort of range for the "timeout". In the audio-output case, my understanding that the spacing between bursts of audio-processing activity is measured in some hundreds of milliseconds, in which case one would want the delays until suspend to be on the millisecond scale. But does Android really suspend between bursts of audio processing while playing music? Very cool if so! ;-)
Thanx, Paul
Quoted 91 lines
Quoted 91 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
correct, but the number of such apps indicates the scope of the problem.
The number of such apps certainly indicates the amount of effort required to modify them, if required. Is that what you are getting at?
yes.
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the
system_server, possibly themedia_serverand the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
Quoted 6 lines
Quoted 3 lines
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
Hmmm... Isn't it the "trusted" (AKA PM-driving) apps that interact with the power daemon via suspend blockers, rather than the other way around?
I was looking at it from a kernel point of view, "trusted" (AKA PM-driving) apps are ones that have permission to grab the wakelock. Any app/daemon that is so trusted can communicate with anything else in userspace as part of making it's decision on whento take the wakelock, but those other applications would not qualify as "trusted" in my eyes.
Quoted 14 lines
Quoted 2 lines
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
Powertop is indeed an extremely valuable tool, but I am not certain that it really provides the information that the Android guys need. If I understand Arve's and Brian's posts, here is the scenario that they are trying to detect:
o Some PM-driving application has a bug in which it fails to release a wakelock, thus blocking suspend indefinitely.
o This PM-driving application, otherwise being a good citizen, blocks.
Quoted 6 lines
o There are numerous power-oblivious apps running, consuming significant CPU.
What the Android developers need to know is that the trusted application is wrongly holding a wakelock. Won't powertop instead tell them about all the power-oblivious apps?
in my proposal (without a wakelock), powertop would tell you what applications are running and setting timers. If we can modify the kernel/suspend decision code to only look at processes in one cgroup when deciding if the system should go to sleep, a similar modification to poewrtop should let you only show stats on the "trusted" applications.
If you have a userspace power management daemon that accepts requests from untrusted programs and does something to keep the system from sleeping (either taking a wakelock or setting a 'short' timer), it needs to keep the records of this itself because otherwise all the kernel will see (with either powertop or wakelock reporting) is that the power management daemon is what kept the system from sleeping.
David Lang
--
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 104 lines · Paul E. McKenney
Quoted 96 lines · kevin granade
Quoted 70 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 47 lines · Paul E. McKenney
Quoted 6 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 4 lines · Paul E. McKenney
Quoted 2 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 8 lines
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Ah, I was assuming -much- shorter "do full suspend" timeouts.
My (possibly incorrect) assumption is based on the complaint that led to my implementing
RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.Quoted 2 lines
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
if the system was looking at all applications I would agree that the timeout should be much shorter.
I have a couple devices that are able to have the display usable, even if the CPU is asleep (the OLPC and the Kindle, two different display technologies). With these devices I would like to see the suspend happen so fast that it can suspend between keystrokes.
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
Quoted 6 lines
It would be good to get some sort of range for the "timeout". In the audio-output case, my understanding that the spacing between bursts of audio-processing activity is measured in some hundreds of milliseconds, in which case one would want the delays until suspend to be on the millisecond scale. But does Android really suspend between bursts of audio processing while playing music? Very cool if so! ;-)
Oops, yea that's actually a really bad example, that's probably something that would be handled by low-power states. I think the incoming text message example is a good one though. There seemed to be a focus on user-interaction scale time scales, and I wanted to point out that there are also very short duration time scales to consider as well.
*back to lurking*
Kevin
Quoted 95 lines
Thanx, Paul
Quoted 91 lines
Quoted 91 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
correct, but the number of such apps indicates the scope of the problem.
The number of such apps certainly indicates the amount of effort required to modify them, if required. Is that what you are getting at?
yes.
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the
system_server, possibly themedia_serverand the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
Quoted 6 lines
Quoted 3 lines
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
Hmmm... Isn't it the "trusted" (AKA PM-driving) apps that interact with the power daemon via suspend blockers, rather than the other way around?
I was looking at it from a kernel point of view, "trusted" (AKA PM-driving) apps are ones that have permission to grab the wakelock. Any app/daemon that is so trusted can communicate with anything else in userspace as part of making it's decision on whento take the wakelock, but those other applications would not qualify as "trusted" in my eyes.
Quoted 14 lines
Quoted 2 lines
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
Powertop is indeed an extremely valuable tool, but I am not certain that it really provides the information that the Android guys need. If I understand Arve's and Brian's posts, here is the scenario that they are trying to detect:
o Some PM-driving application has a bug in which it fails to release a wakelock, thus blocking suspend indefinitely.
o This PM-driving application, otherwise being a good citizen, blocks.
Quoted 6 lines
o There are numerous power-oblivious apps running, consuming significant CPU.
What the Android developers need to know is that the trusted application is wrongly holding a wakelock. Won't powertop instead tell them about all the power-oblivious apps?
in my proposal (without a wakelock), powertop would tell you what applications are running and setting timers. If we can modify the kernel/suspend decision code to only look at processes in one cgroup when deciding if the system should go to sleep, a similar modification to poewrtop should let you only show stats on the "trusted" applications.
If you have a userspace power management daemon that accepts requests from untrusted programs and does something to keep the system from sleeping (either taking a wakelock or setting a 'short' timer), it needs to keep the records of this itself because otherwise all the kernel will see (with either powertop or wakelock reporting) is that the power management daemon is what kept the system from sleeping.
David Lang
--
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 104 lines · Paul E. McKenney
Quoted 96 lines · kevin granade
Quoted 70 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 47 lines · Paul E. McKenney
Quoted 6 lines · On Wed, Aug 04, 2010 at 10:18:40PM -0700, [email protected] wrote:
Quoted 4 lines · Paul E. McKenney
Quoted 2 lines · On Wed, Aug 04, 2010 at 05:25:53PM -0700, [email protected] wrote:
On Wed, 4 Aug 2010, Paul E. McKenney wrote:
[ . . . ]
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
The music player is an interesting example. It would be idle most of the time, given that audio output doesn't consume very much CPU. So you would not want to suspend the system just because there were no runnable processes. In contrast, allowing the music player to hold a wake lock lets the system know that it would not be appropriate to suspend.
Or am I misunderstanding what you are proposing?
Quoted 7 lines
Quoted 3 lines
the system would need to be idle for 'long enough' (configurable) before deciding to suspend, so as long as 'long enough' is longer than the music player is idle this would not be a problem.
From a user standpoint, having the music player tell the system when it is OK to suspend (e.g., when the user has paused playback) seems a lot nicer than having configurable timeouts that need tweaking.
Quoted 8 lines
every system that I have seen has a configurable "sleep if it's idle for this long" knob. On the iphone (work issue, I didn't want it) that I am currently using it can be configured from 1 min to 5 min.
this is the sort of timeout I am talking about.
with something in the multi-minute range for the 'do a full suspend' doing a wakeup every few 10s of seconds is perfectly safe.
Ah, I was assuming -much- shorter "do full suspend" timeouts.
My (possibly incorrect) assumption is based on the complaint that led to my implementing
RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.Quoted 2 lines
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
if the system was looking at all applications I would agree that the timeout should be much shorter.
I have a couple devices that are able to have the display usable, even if the CPU is asleep (the OLPC and the Kindle, two different display technologies). With these devices I would like to see the suspend happen so fast that it can suspend between keystrokes.
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
Quoted 6 lines
It would be good to get some sort of range for the "timeout". In the audio-output case, my understanding that the spacing between bursts of audio-processing activity is measured in some hundreds of milliseconds, in which case one would want the delays until suspend to be on the millisecond scale. But does Android really suspend between bursts of audio processing while playing music? Very cool if so! ;-)
Oops, yea that's actually a really bad example, that's probably something that would be handled by low-power states. I think the incoming text message example is a good one though. There seemed to be a focus on user-interaction scale time scales, and I wanted to point out that there are also very short duration time scales to consider as well.
*back to lurking*
Kevin
Quoted 95 lines
Thanx, Paul
Quoted 91 lines
Quoted 91 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
Quoted 3 lines
if the backlight being on holds the wakelock, it would seem that almost every other use of the wakelock could (and probably should) be replaced by something that tickles the display to stay on longer.
The problem with this approach is that the display consumes quite a bit of power, so you don't want to leave it on unnecessarily. So if the system is doing something (for example, playing music) that does not require the display, you really want the display to be off.
what percentage (and types) of apps are really useful with the display off. I think that there are relativly few apps that you really want to keep running if the display is off.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The length of time those apps are running is the governing factor for battery life, and not the number of such apps, right?
correct, but the number of such apps indicates the scope of the problem.
The number of such apps certainly indicates the amount of effort required to modify them, if required. Is that what you are getting at?
yes.
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
From another e-mail tonight it sounds like almost everything already talks
to a userspace daemon, so if "(the power management service in the
system_server, possibly themedia_serverand the radio interface glue)" (plus possibly some kernel activity) are the only things looked at when considering if it's safe to sleep or not, all of these can (or already do) do 'something' every few seconds, making this problem sound significantly smaller than it sounded like before.Android could even keep it's user-space API between the system power daemon and the rest of userspace the same if they want to.
Quoted 6 lines
Quoted 3 lines
over time, additional apps could be considered 'trusted' (or flagged that way by the user) and not have to interact with the power daemon to keep things alive.
Hmmm... Isn't it the "trusted" (AKA PM-driving) apps that interact with the power daemon via suspend blockers, rather than the other way around?
I was looking at it from a kernel point of view, "trusted" (AKA PM-driving) apps are ones that have permission to grab the wakelock. Any app/daemon that is so trusted can communicate with anything else in userspace as part of making it's decision on whento take the wakelock, but those other applications would not qualify as "trusted" in my eyes.
Quoted 14 lines
Quoted 2 lines
as for intramentation, the key tool to use to see why a system isn't going to sleep would be powertop, just like on other linux systems.
Powertop is indeed an extremely valuable tool, but I am not certain that it really provides the information that the Android guys need. If I understand Arve's and Brian's posts, here is the scenario that they are trying to detect:
o Some PM-driving application has a bug in which it fails to release a wakelock, thus blocking suspend indefinitely.
o This PM-driving application, otherwise being a good citizen, blocks.
Quoted 6 lines
o There are numerous power-oblivious apps running, consuming significant CPU.
What the Android developers need to know is that the trusted application is wrongly holding a wakelock. Won't powertop instead tell them about all the power-oblivious apps?
in my proposal (without a wakelock), powertop would tell you what applications are running and setting timers. If we can modify the kernel/suspend decision code to only look at processes in one cgroup when deciding if the system should go to sleep, a similar modification to poewrtop should let you only show stats on the "trusted" applications.
If you have a userspace power management daemon that accepts requests from untrusted programs and does something to keep the system from sleeping (either taking a wakelock or setting a 'short' timer), it needs to keep the records of this itself because otherwise all the kernel will see (with either powertop or wakelock reporting) is that the power management daemon is what kept the system from sleeping.
David Lang
--
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 79 lines · kevin granade
Quoted 70 lines · Paul E. McKenney
Quoted 62 lines · kevin granade
Quoted 36 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 13 lines · Paul E. McKenney
[ . . . ]
My (possibly incorrect) assumption is based on the complaint that led to my implementing
RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.Quoted 2 lines
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
if the system was looking at all applications I would agree that the timeout should be much shorter.
I have a couple devices that are able to have the display usable, even if the CPU is asleep (the OLPC and the Kindle, two different display technologies). With these devices I would like to see the suspend happen so fast that it can suspend between keystrokes.
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
Quoted 6 lines
It would be good to get some sort of range for the "timeout". In the audio-output case, my understanding that the spacing between bursts of audio-processing activity is measured in some hundreds of milliseconds, in which case one would want the delays until suspend to be on the millisecond scale. But does Android really suspend between bursts of audio processing while playing music? Very cool if so! ;-)
Quoted 6 lines
Oops, yea that's actually a really bad example, that's probably something that would be handled by low-power states. I think the incoming text message example is a good one though. There seemed to be a focus on user-interaction scale time scales, and I wanted to point out that there are also very short duration time scales to consider as well.
good point, but I do think the short time scales are less common than people think.
I'd love to get good examples of them
on my iphone when a text message arrives the phone displays an alert for user-interaction times (it even lights the display to show who the message is from, and optionally a preview of the message)
so what would wake a phone up from suspend where the phone should go back to sleep in under a second?
David Lang
Quoted 79 lines · kevin granade
Quoted 70 lines · Paul E. McKenney
Quoted 62 lines · kevin granade
Quoted 36 lines · On Thu, Aug 5, 2010 at 10:46 AM, <[email protected]> wrote:
Quoted 13 lines · Paul E. McKenney
[ . . . ]
My (possibly incorrect) assumption is based on the complaint that led to my implementing
RCU_FAST_NO_HZ. A (non-Android) embedded person was quite annoyed (to put it mildly) at the earlier version of RCU because it prevented the system from entering the power-saving dyntick-idle mode, not for minutes, or even for seconds, but for a handful of -milliseconds-. This was my first hint that "energy efficiency" means something completely different in embedded systems than it does in the servers that I am used to.Quoted 2 lines
But I must defer to the Android guys on this -- who knows, perhaps multi-minute delays to enter full-suspend mode are OK for them.
if the system was looking at all applications I would agree that the timeout should be much shorter.
I have a couple devices that are able to have the display usable, even if the CPU is asleep (the OLPC and the Kindle, two different display technologies). With these devices I would like to see the suspend happen so fast that it can suspend between keystrokes.
however, in the case of Android I think the timeouts have to end up being _much_ longer. Otherwise you have the problem of loading an untrusted book reader app on the device and the device suspends while you are reading the page.
currently Android works around this by having a wakelock held whenever the display is on. This seems backwards to me, the display should be on because the system is not suspended, not the system is prevented from suspending because the display is on.
Quoted 5 lines
Rather than having the display be on causing a wavelock to be held (with the code that is controls the display having a timeout for how long it leaves the display on), I would invert this and have the timeout be based on system activity, and when it decides the system is not active, turn off the display (along with other things as it suspends)
IIRC, this was a major point of their (Android's) power management policy. User input of any kind would reset the "display active" timeout, which is the primary thing keeping random untrusted user-facing programs from being suspended while in use. They seemed to consider this to be a special case in their policy, but from the kernel's point of view it is just another suspend blocker being held.
I'm not sure this is the best use case to look at though, because since it is user-facing, the timeout durations are on a different scale than the ones they are really worried about. I think another category of use case that they are worried about is:
(in suspend) -> wakeup due to network -> process network activity -> suspend
or an example that has been mentioned previously:
(in suspend) -> wakeup due to alarm for audio processing -> process batch of audio -> suspend
Quoted 6 lines
In both of these cases, the display may never power on (phone might beep to indicate txt message or email, audio just keeps playing), so the magnitude of the "timeout" for suspending again should be very small. Specifically, they don't want there to be a timeout at all, so as little time as possible time is spent out of suspend in addition to the time required to handle the event that caused wakeup.
Quoted 6 lines
It would be good to get some sort of range for the "timeout". In the audio-output case, my understanding that the spacing between bursts of audio-processing activity is measured in some hundreds of milliseconds, in which case one would want the delays until suspend to be on the millisecond scale. But does Android really suspend between bursts of audio processing while playing music? Very cool if so! ;-)
Quoted 6 lines
Oops, yea that's actually a really bad example, that's probably something that would be handled by low-power states. I think the incoming text message example is a good one though. There seemed to be a focus on user-interaction scale time scales, and I wanted to point out that there are also very short duration time scales to consider as well.
good point, but I do think the short time scales are less common than people think.
I'd love to get good examples of them
on my iphone when a text message arrives the phone displays an alert for user-interaction times (it even lights the display to show who the message is from, and optionally a preview of the message)
so what would wake a phone up from suspend where the phone should go back to sleep in under a second?
David Lang
Quoted 10 lines · On Thu, Aug 5, 2010 at 3:09 PM, <[email protected]> wrote:
Quoted 6 lines
Oops, yea that's actually a really bad example, that's probably something that would be handled by low-power states. I think the incoming text message example is a good one though. There seemed to be a focus on user-interaction scale time scales, and I wanted to point out that there are also very short duration time scales to consider as well.
good point, but I do think the short time scales are less common than people think.
Quoted 8 lines
I'd love to get good examples of them
on my iphone when a text message arrives the phone displays an alert for user-interaction times (it even lights the display to show who the message is from, and optionally a preview of the message)
so what would wake a phone up from suspend where the phone should go back to sleep in under a second?
Here are some real-world examples from shipped android devices:
- battery gauging happens every 10 minutes, need to wake long enough to chatter with the 1w interface and make sure the battery is not exploding
- always on mail/im/calendar/etc sync often has network events that happen every 5-10 minutes which cause devices to briefly wake up and return to sleep
- gps tracker app might wake every couple minutes or every n gps events to log location
- low power audio subsystems can wake you up every 1-4 seconds (pcm) or 1-4 minutes (mp3) to fetch more data
Brian
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Quoted 10 lines · On Thu, Aug 5, 2010 at 3:09 PM, <[email protected]> wrote:
Quoted 6 lines
Oops, yea that's actually a really bad example, that's probably something that would be handled by low-power states. I think the incoming text message example is a good one though. There seemed to be a focus on user-interaction scale time scales, and I wanted to point out that there are also very short duration time scales to consider as well.
good point, but I do think the short time scales are less common than people think.
Quoted 8 lines
I'd love to get good examples of them
on my iphone when a text message arrives the phone displays an alert for user-interaction times (it even lights the display to show who the message is from, and optionally a preview of the message)
so what would wake a phone up from suspend where the phone should go back to sleep in under a second?
Here are some real-world examples from shipped android devices:
- battery gauging happens every 10 minutes, need to wake long enough to chatter with the 1w interface and make sure the battery is not exploding
- always on mail/im/calendar/etc sync often has network events that happen every 5-10 minutes which cause devices to briefly wake up and return to sleep
- gps tracker app might wake every couple minutes or every n gps events to log location
- low power audio subsystems can wake you up every 1-4 seconds (pcm) or 1-4 minutes (mp3) to fetch more data
Brian
Quoted 20 lines · Brian Swetland
Quoted 10 lines · On Thu, Aug 5, 2010 at 3:09 PM, <[email protected]> wrote:
Quoted 6 lines
Oops, yea that's actually a really bad example, that's probably something that would be handled by low-power states. I think the incoming text message example is a good one though. There seemed to be a focus on user-interaction scale time scales, and I wanted to point out that there are also very short duration time scales to consider as well.
good point, but I do think the short time scales are less common than people think.
Quoted 8 lines
I'd love to get good examples of them
on my iphone when a text message arrives the phone displays an alert for user-interaction times (it even lights the display to show who the message is from, and optionally a preview of the message)
so what would wake a phone up from suspend where the phone should go back to sleep in under a second?
Quoted 11 lines
Here are some real-world examples from shipped android devices:
- battery gauging happens every 10 minutes, need to wake long enough to chatter with the 1w interface and make sure the battery is not exploding
- always on mail/im/calendar/etc sync often has network events that happen every 5-10 minutes which cause devices to briefly wake up and return to sleep
- gps tracker app might wake every couple minutes or every n gps events to log location
- low power audio subsystems can wake you up every 1-4 seconds (pcm) or 1-4 minutes (mp3) to fetch more data
Interesting!
So for an mp3 playback, does an Android suspend between data fetches?
Thanx, Paul
Quoted 20 lines · Brian Swetland
Quoted 10 lines · On Thu, Aug 5, 2010 at 3:09 PM, <[email protected]> wrote:
Quoted 6 lines
Oops, yea that's actually a really bad example, that's probably something that would be handled by low-power states. I think the incoming text message example is a good one though. There seemed to be a focus on user-interaction scale time scales, and I wanted to point out that there are also very short duration time scales to consider as well.
good point, but I do think the short time scales are less common than people think.
Quoted 8 lines
I'd love to get good examples of them
on my iphone when a text message arrives the phone displays an alert for user-interaction times (it even lights the display to show who the message is from, and optionally a preview of the message)
so what would wake a phone up from suspend where the phone should go back to sleep in under a second?
Quoted 11 lines
Here are some real-world examples from shipped android devices:
- battery gauging happens every 10 minutes, need to wake long enough to chatter with the 1w interface and make sure the battery is not exploding
- always on mail/im/calendar/etc sync often has network events that happen every 5-10 minutes which cause devices to briefly wake up and return to sleep
- gps tracker app might wake every couple minutes or every n gps events to log location
- low power audio subsystems can wake you up every 1-4 seconds (pcm) or 1-4 minutes (mp3) to fetch more data
Interesting!
So for an mp3 playback, does an Android suspend between data fetches?
Thanx, Paul
Quoted 15 lines · Paul E. McKenney
Quoted 14 lines
Quoted 2 lines
so what would wake a phone up from suspend where the phone should go back to sleep in under a second?
Here are some real-world examples from shipped android devices:
- battery gauging happens every 10 minutes, need to wake long enough to chatter with the 1w interface and make sure the battery is not exploding
- always on mail/im/calendar/etc sync often has network events that happen every 5-10 minutes which cause devices to briefly wake up and return to sleep
- gps tracker app might wake every couple minutes or every n gps events to log location
- low power audio subsystems can wake you up every 1-4 seconds (pcm) or 1-4 minutes (mp3) to fetch more data
Quoted 3 lines
Interesting!
So for an mp3 playback, does an Android suspend between data fetches?
It can if the latency is long enough (which is why I point out low power audio which is usually high latency). For low latency (system sounds, etc) 10-25ms between buffers it's not practical to fully suspend but we will go to the lowest power state in idle if possible.
Brian
Quoted 15 lines · Paul E. McKenney
Quoted 14 lines
Quoted 2 lines
so what would wake a phone up from suspend where the phone should go back to sleep in under a second?
Here are some real-world examples from shipped android devices:
- battery gauging happens every 10 minutes, need to wake long enough to chatter with the 1w interface and make sure the battery is not exploding
- always on mail/im/calendar/etc sync often has network events that happen every 5-10 minutes which cause devices to briefly wake up and return to sleep
- gps tracker app might wake every couple minutes or every n gps events to log location
- low power audio subsystems can wake you up every 1-4 seconds (pcm) or 1-4 minutes (mp3) to fetch more data
Quoted 3 lines
Interesting!
So for an mp3 playback, does an Android suspend between data fetches?
It can if the latency is long enough (which is why I point out low power audio which is usually high latency). For low latency (system sounds, etc) 10-25ms between buffers it's not practical to fully suspend but we will go to the lowest power state in idle if possible.
Brian
Quoted 17 lines · Brian Swetland
Quoted 15 lines · Paul E. McKenney
Quoted 14 lines
Quoted 2 lines
so what would wake a phone up from suspend where the phone should go back to sleep in under a second?
Here are some real-world examples from shipped android devices:
- battery gauging happens every 10 minutes, need to wake long enough to chatter with the 1w interface and make sure the battery is not exploding
- always on mail/im/calendar/etc sync often has network events that happen every 5-10 minutes which cause devices to briefly wake up and return to sleep
- gps tracker app might wake every couple minutes or every n gps events to log location
- low power audio subsystems can wake you up every 1-4 seconds (pcm) or 1-4 minutes (mp3) to fetch more data
Quoted 8 lines
Quoted 3 lines
Interesting!
So for an mp3 playback, does an Android suspend between data fetches?
It can if the latency is long enough (which is why I point out low power audio which is usually high latency). For low latency (system sounds, etc) 10-25ms between buffers it's not practical to fully suspend but we will go to the lowest power state in idle if possible.
the playback is able to continue even with all the clocks stopped? that surprises me. I would hav expected it to be able to sleep while playing audio, but not do a full suspend.
David Lang
Quoted 17 lines · Brian Swetland
Quoted 15 lines · Paul E. McKenney
Quoted 14 lines
Quoted 2 lines
so what would wake a phone up from suspend where the phone should go back to sleep in under a second?
Here are some real-world examples from shipped android devices:
- battery gauging happens every 10 minutes, need to wake long enough to chatter with the 1w interface and make sure the battery is not exploding
- always on mail/im/calendar/etc sync often has network events that happen every 5-10 minutes which cause devices to briefly wake up and return to sleep
- gps tracker app might wake every couple minutes or every n gps events to log location
- low power audio subsystems can wake you up every 1-4 seconds (pcm) or 1-4 minutes (mp3) to fetch more data
Quoted 8 lines
Quoted 3 lines
Interesting!
So for an mp3 playback, does an Android suspend between data fetches?
It can if the latency is long enough (which is why I point out low power audio which is usually high latency). For low latency (system sounds, etc) 10-25ms between buffers it's not practical to fully suspend but we will go to the lowest power state in idle if possible.
the playback is able to continue even with all the clocks stopped? that surprises me. I would hav expected it to be able to sleep while playing audio, but not do a full suspend.
David Lang
Quoted 11 lines · On Thu, Aug 5, 2010 at 5:16 PM, <[email protected]> wrote:
Quoted 7 lines
Quoted 2 lines
So for an mp3 playback, does an Android suspend between data fetches?
It can if the latency is long enough (which is why I point out low power audio which is usually high latency). For low latency (system sounds, etc) 10-25ms between buffers it's not practical to fully suspend but we will go to the lowest power state in idle if possible.
the playback is able to continue even with all the clocks stopped? that surprises me. I would hav expected it to be able to sleep while playing audio, but not do a full suspend.
Obviously not all clocks are stopped (the DSP and codec are powered and clocked, for example), but yeah we can clock gate and power gate the cpu and most other peripherals while audio is playing on a number of ARM SoC designs available today (and the past few years).
Brian
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Quoted 11 lines · On Thu, Aug 5, 2010 at 5:16 PM, <[email protected]> wrote:
Quoted 7 lines
Quoted 2 lines
So for an mp3 playback, does an Android suspend between data fetches?
It can if the latency is long enough (which is why I point out low power audio which is usually high latency). For low latency (system sounds, etc) 10-25ms between buffers it's not practical to fully suspend but we will go to the lowest power state in idle if possible.
the playback is able to continue even with all the clocks stopped? that surprises me. I would hav expected it to be able to sleep while playing audio, but not do a full suspend.
Obviously not all clocks are stopped (the DSP and codec are powered and clocked, for example), but yeah we can clock gate and power gate the cpu and most other peripherals while audio is playing on a number of ARM SoC designs available today (and the past few years).
Brian
Quoted 9 lines · Brian Swetland
Quoted 8 lines · On Thu, Aug 5, 2010 at 5:16 PM, <[email protected]> wrote:
Quoted 7 lines
Quoted 2 lines
So for an mp3 playback, does an Android suspend between data fetches?
It can if the latency is long enough (which is why I point out low power audio which is usually high latency). For low latency (system sounds, etc) 10-25ms between buffers it's not practical to fully suspend but we will go to the lowest power state in idle if possible.
Quoted 8 lines
Quoted 3 lines
the playback is able to continue even with all the clocks stopped? that surprises me. I would hav expected it to be able to sleep while playing audio, but not do a full suspend.
Obviously not all clocks are stopped (the DSP and codec are powered and clocked, for example), but yeah we can clock gate and power gate the cpu and most other peripherals while audio is playing on a number of ARM SoC designs available today (and the past few years).
does this then mean that you have multiple variations of suspend?
for example, one where the audio stuff is left powered, and one where it isn't?
David Lang
Quoted 19 lines · On Thu, Aug 5, 2010 at 6:01 PM, <[email protected]> wrote:
Quoted 9 lines · Brian Swetland
Quoted 8 lines · On Thu, Aug 5, 2010 at 5:16 PM, <[email protected]> wrote:
Quoted 7 lines
Quoted 2 lines
So for an mp3 playback, does an Android suspend between data fetches?
It can if the latency is long enough (which is why I point out low power audio which is usually high latency). For low latency (system sounds, etc) 10-25ms between buffers it's not practical to fully suspend but we will go to the lowest power state in idle if possible.
Quoted 8 lines
Quoted 3 lines
the playback is able to continue even with all the clocks stopped? that surprises me. I would hav expected it to be able to sleep while playing audio, but not do a full suspend.
Obviously not all clocks are stopped (the DSP and codec are powered and clocked, for example), but yeah we can clock gate and power gate the cpu and most other peripherals while audio is playing on a number of ARM SoC designs available today (and the past few years).
Quoted 4 lines
does this then mean that you have multiple variations of suspend?
for example, one where the audio stuff is left powered, and one where it isn't?
While the cpu (and the bulk of the system) is suspended, it's not uncommon for some peripherals to continue to operate -- for example a cellular radio, gps, low power audio playback, etc. Details will vary depending on the SoC and board design. It's not so much a different suspend mode (the system is still suspended), just a matter of whether a peripheral can operate independently (and if it is lower power for it to do so).
Brian
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Quoted 19 lines · On Thu, Aug 5, 2010 at 6:01 PM, <[email protected]> wrote:
Quoted 9 lines · Brian Swetland
Quoted 8 lines · On Thu, Aug 5, 2010 at 5:16 PM, <[email protected]> wrote:
Quoted 7 lines
Quoted 2 lines
So for an mp3 playback, does an Android suspend between data fetches?
It can if the latency is long enough (which is why I point out low power audio which is usually high latency). For low latency (system sounds, etc) 10-25ms between buffers it's not practical to fully suspend but we will go to the lowest power state in idle if possible.
Quoted 8 lines
Quoted 3 lines
the playback is able to continue even with all the clocks stopped? that surprises me. I would hav expected it to be able to sleep while playing audio, but not do a full suspend.
Obviously not all clocks are stopped (the DSP and codec are powered and clocked, for example), but yeah we can clock gate and power gate the cpu and most other peripherals while audio is playing on a number of ARM SoC designs available today (and the past few years).
Quoted 4 lines
does this then mean that you have multiple variations of suspend?
for example, one where the audio stuff is left powered, and one where it isn't?
While the cpu (and the bulk of the system) is suspended, it's not uncommon for some peripherals to continue to operate -- for example a cellular radio, gps, low power audio playback, etc. Details will vary depending on the SoC and board design. It's not so much a different suspend mode (the system is still suspended), just a matter of whether a peripheral can operate independently (and if it is lower power for it to do so).
Brian
Quoted 25 lines · Brian Swetland
Quoted 19 lines · On Thu, Aug 5, 2010 at 6:01 PM, <[email protected]> wrote:
Quoted 9 lines · Brian Swetland
Quoted 8 lines · On Thu, Aug 5, 2010 at 5:16 PM, <[email protected]> wrote:
Quoted 7 lines
Quoted 2 lines
So for an mp3 playback, does an Android suspend between data fetches?
It can if the latency is long enough (which is why I point out low power audio which is usually high latency). For low latency (system sounds, etc) 10-25ms between buffers it's not practical to fully suspend but we will go to the lowest power state in idle if possible.
Quoted 8 lines
Quoted 3 lines
the playback is able to continue even with all the clocks stopped? that surprises me. I would hav expected it to be able to sleep while playing audio, but not do a full suspend.
Obviously not all clocks are stopped (the DSP and codec are powered and clocked, for example), but yeah we can clock gate and power gate the cpu and most other peripherals while audio is playing on a number of ARM SoC designs available today (and the past few years).
Quoted 4 lines
does this then mean that you have multiple variations of suspend?
for example, one where the audio stuff is left powered, and one where it isn't?
Quoted 7 lines
While the cpu (and the bulk of the system) is suspended, it's not uncommon for some peripherals to continue to operate -- for example a cellular radio, gps, low power audio playback, etc. Details will vary depending on the SoC and board design. It's not so much a different suspend mode (the system is still suspended), just a matter of whether a peripheral can operate independently (and if it is lower power for it to do so).
this helps, but isn't quite what I was trying to ask.
on a given piece of hardware, does suspend always leave the same peripherals on, or do you sometimes power more things down than other times when suspending?
David Lang
Quoted 3 lines · On Fri, Aug 06, 2010 at 01:07:47AM -0700, [email protected] wrote:
on a given piece of hardware, does suspend always leave the same peripherals on, or do you sometimes power more things down than other times when suspending?
Different bits of hardware get powered down depending on current system state. In the audio case (which is so far as I know the only case for this sort of stuff that currently does anything in mainline) we'll keep alive any active paths (that is, paths carrying live audio) between endpoints in the audio subsystem which have been explicitly marked as staying alive during suspend. Other audio paths will be powered down when the system suspends. During normal run time only paths that are active will be powered up.
Quoted 3 lines · On Fri, Aug 06, 2010 at 01:07:47AM -0700, [email protected] wrote:
on a given piece of hardware, does suspend always leave the same peripherals on, or do you sometimes power more things down than other times when suspending?
Different bits of hardware get powered down depending on current system state. In the audio case (which is so far as I know the only case for this sort of stuff that currently does anything in mainline) we'll keep alive any active paths (that is, paths carrying live audio) between endpoints in the audio subsystem which have been explicitly marked as staying alive during suspend. Other audio paths will be powered down when the system suspends. During normal run time only paths that are active will be powered up.
Quoted 11 lines · On Thu, Aug 05, 2010 at 06:01:24PM -0700, [email protected] wrote:
Quoted 4 lines · Brian Swetland
Obviously not all clocks are stopped (the DSP and codec are powered and clocked, for example), but yeah we can clock gate and power gate the cpu and most other peripherals while audio is playing on a number of ARM SoC designs available today (and the past few years).
does this then mean that you have multiple variations of suspend?
for example, one where the audio stuff is left powered, and one where it isn't?
This was the core of the issue I was raising in the last thread about this (the one following the rename to suspend blockers). Essentially what happens in a mainline context is that some subsystems can with varying degress of optionality ignore some or all of the instruction to suspend and keep bits of the system alive during suspend.
Those that stay alive will either have per subsystem handling or will be outside the direct control of the kernel entirely (the modem is a good example of the latter case in many systems - in terms of the software it's essentially a parallel computer that's sitting in the system rather than a perhiperal of the AP).
Quoted 11 lines · On Thu, Aug 05, 2010 at 06:01:24PM -0700, [email protected] wrote:
Quoted 4 lines · Brian Swetland
Obviously not all clocks are stopped (the DSP and codec are powered and clocked, for example), but yeah we can clock gate and power gate the cpu and most other peripherals while audio is playing on a number of ARM SoC designs available today (and the past few years).
does this then mean that you have multiple variations of suspend?
for example, one where the audio stuff is left powered, and one where it isn't?
This was the core of the issue I was raising in the last thread about this (the one following the rename to suspend blockers). Essentially what happens in a mainline context is that some subsystems can with varying degress of optionality ignore some or all of the instruction to suspend and keep bits of the system alive during suspend.
Those that stay alive will either have per subsystem handling or will be outside the direct control of the kernel entirely (the modem is a good example of the latter case in many systems - in terms of the software it's essentially a parallel computer that's sitting in the system rather than a perhiperal of the AP).
Quoted 19 lines · Mark Brown
Quoted 11 lines · On Thu, Aug 05, 2010 at 06:01:24PM -0700, [email protected] wrote:
Quoted 4 lines · Brian Swetland
Obviously not all clocks are stopped (the DSP and codec are powered and clocked, for example), but yeah we can clock gate and power gate the cpu and most other peripherals while audio is playing on a number of ARM SoC designs available today (and the past few years).
does this then mean that you have multiple variations of suspend?
for example, one where the audio stuff is left powered, and one where it isn't?
This was the core of the issue I was raising in the last thread about this (the one following the rename to suspend blockers). Essentially what happens in a mainline context is that some subsystems can with varying degress of optionality ignore some or all of the instruction to suspend and keep bits of the system alive during suspend.
Quoted 5 lines
Those that stay alive will either have per subsystem handling or will be outside the direct control of the kernel entirely (the modem is a good example of the latter case in many systems - in terms of the software it's essentially a parallel computer that's sitting in the system rather than a perhiperal of the AP).
This underscores a basic difference between servers and these embedded devices. When you suspend a server, it is doing nothing, because servers rely very heavily on the CPUs. In contrast, many embedded devices can perform useful work even when the CPUs are completely powered down.
Thanx, Paul
Quoted 19 lines · Mark Brown
Quoted 11 lines · On Thu, Aug 05, 2010 at 06:01:24PM -0700, [email protected] wrote:
Quoted 4 lines · Brian Swetland
Obviously not all clocks are stopped (the DSP and codec are powered and clocked, for example), but yeah we can clock gate and power gate the cpu and most other peripherals while audio is playing on a number of ARM SoC designs available today (and the past few years).
does this then mean that you have multiple variations of suspend?
for example, one where the audio stuff is left powered, and one where it isn't?
This was the core of the issue I was raising in the last thread about this (the one following the rename to suspend blockers). Essentially what happens in a mainline context is that some subsystems can with varying degress of optionality ignore some or all of the instruction to suspend and keep bits of the system alive during suspend.
Quoted 5 lines
Those that stay alive will either have per subsystem handling or will be outside the direct control of the kernel entirely (the modem is a good example of the latter case in many systems - in terms of the software it's essentially a parallel computer that's sitting in the system rather than a perhiperal of the AP).
This underscores a basic difference between servers and these embedded devices. When you suspend a server, it is doing nothing, because servers rely very heavily on the CPUs. In contrast, many embedded devices can perform useful work even when the CPUs are completely powered down.
Thanx, Paul
Quoted 11 lines · Paul E. McKenney
Quoted 4 lines · Mark Brown
this (the one following the rename to suspend blockers). Essentially what happens in a mainline context is that some subsystems can with varying degress of optionality ignore some or all of the instruction to suspend and keep bits of the system alive during suspend.
This underscores a basic difference between servers and these embedded devices. When you suspend a server, it is doing nothing, because servers rely very heavily on the CPUs. In contrast, many embedded devices can perform useful work even when the CPUs are completely powered down.
Well, not really from the Linux point of view. It's not massively different to something like keeping an ethernet controller sufficiently alive to allow it to provide wake on LAN functionality while the system is suspended in terms of what Linux has to do, and quite a few servers have lights out management systems which aren't a million miles away from the modem on a phone in terms of their relationship with the host computer.
Quoted 11 lines · Paul E. McKenney
Quoted 4 lines · Mark Brown
this (the one following the rename to suspend blockers). Essentially what happens in a mainline context is that some subsystems can with varying degress of optionality ignore some or all of the instruction to suspend and keep bits of the system alive during suspend.
This underscores a basic difference between servers and these embedded devices. When you suspend a server, it is doing nothing, because servers rely very heavily on the CPUs. In contrast, many embedded devices can perform useful work even when the CPUs are completely powered down.
Well, not really from the Linux point of view. It's not massively different to something like keeping an ethernet controller sufficiently alive to allow it to provide wake on LAN functionality while the system is suspended in terms of what Linux has to do, and quite a few servers have lights out management systems which aren't a million miles away from the modem on a phone in terms of their relationship with the host computer.
Quoted 13 lines · Mark Brown
Quoted 11 lines · Paul E. McKenney
Quoted 4 lines · Mark Brown
this (the one following the rename to suspend blockers). Essentially what happens in a mainline context is that some subsystems can with varying degress of optionality ignore some or all of the instruction to suspend and keep bits of the system alive during suspend.
This underscores a basic difference between servers and these embedded devices. When you suspend a server, it is doing nothing, because servers rely very heavily on the CPUs. In contrast, many embedded devices can perform useful work even when the CPUs are completely powered down.
Quoted 7 lines
Well, not really from the Linux point of view. It's not massively different to something like keeping an ethernet controller sufficiently alive to allow it to provide wake on LAN functionality while the system is suspended in terms of what Linux has to do, and quite a few servers have lights out management systems which aren't a million miles away from the modem on a phone in terms of their relationship with the host computer.
The wake-on-LAN and the lights-out management systems are indeed interesting examples, and actually pretty good ones. The reason I excluded them is that they don't do any application processing -- their only purpose is the care and feeding of the system itself. In contrast, the embedded processors are able to do significant applications processing (e.g., play back music) while any CPUs are completely shut down and most of the memory is powered down as well.
Thanx, Paul
Quoted 13 lines · Mark Brown
Quoted 11 lines · Paul E. McKenney
Quoted 4 lines · Mark Brown
this (the one following the rename to suspend blockers). Essentially what happens in a mainline context is that some subsystems can with varying degress of optionality ignore some or all of the instruction to suspend and keep bits of the system alive during suspend.
This underscores a basic difference between servers and these embedded devices. When you suspend a server, it is doing nothing, because servers rely very heavily on the CPUs. In contrast, many embedded devices can perform useful work even when the CPUs are completely powered down.
Quoted 7 lines
Well, not really from the Linux point of view. It's not massively different to something like keeping an ethernet controller sufficiently alive to allow it to provide wake on LAN functionality while the system is suspended in terms of what Linux has to do, and quite a few servers have lights out management systems which aren't a million miles away from the modem on a phone in terms of their relationship with the host computer.
The wake-on-LAN and the lights-out management systems are indeed interesting examples, and actually pretty good ones. The reason I excluded them is that they don't do any application processing -- their only purpose is the care and feeding of the system itself. In contrast, the embedded processors are able to do significant applications processing (e.g., play back music) while any CPUs are completely shut down and most of the memory is powered down as well.
Thanx, Paul
Quoted 22 lines · Paul E. McKenney
Quoted 13 lines · Mark Brown
Quoted 11 lines · Paul E. McKenney
Quoted 4 lines · Mark Brown
this (the one following the rename to suspend blockers). Essentially what happens in a mainline context is that some subsystems can with varying degress of optionality ignore some or all of the instruction to suspend and keep bits of the system alive during suspend.
This underscores a basic difference between servers and these embedded devices. When you suspend a server, it is doing nothing, because servers rely very heavily on the CPUs. In contrast, many embedded devices can perform useful work even when the CPUs are completely powered down.
Quoted 7 lines
Well, not really from the Linux point of view. It's not massively different to something like keeping an ethernet controller sufficiently alive to allow it to provide wake on LAN functionality while the system is suspended in terms of what Linux has to do, and quite a few servers have lights out management systems which aren't a million miles away from the modem on a phone in terms of their relationship with the host computer.
Quoted 7 lines
The wake-on-LAN and the lights-out management systems are indeed interesting examples, and actually pretty good ones. The reason I excluded them is that they don't do any application processing -- their only purpose is the care and feeding of the system itself. In contrast, the embedded processors are able to do significant applications processing (e.g., play back music) while any CPUs are completely shut down and most of the memory is powered down as well.
one other significant issue is that on the PC, things like wake-on-LAN, lights out management cards, etc require nothing from the main system other than power. If they do something, they are sending the signal to the chipset, which then wakes the system up. they don't interact with the main processor/memory/etc at all.
So as I see it, we need to do one of two things.
1. change the suspend definition to allow for some things to not be suspended
or
2. change the sleep/low-power mode definition to have a more standardized way of turning things off, and extend it to allow clocks to be turned off as well (today we have things able to be turned off, drive spin-down for example, but per comments in this thread it's all one-off methods)
to me #2 seems the better thing to do from a design/concept point of view
David Lang
Quoted 22 lines · Paul E. McKenney
Quoted 13 lines · Mark Brown
Quoted 11 lines · Paul E. McKenney
Quoted 4 lines · Mark Brown
this (the one following the rename to suspend blockers). Essentially what happens in a mainline context is that some subsystems can with varying degress of optionality ignore some or all of the instruction to suspend and keep bits of the system alive during suspend.
This underscores a basic difference between servers and these embedded devices. When you suspend a server, it is doing nothing, because servers rely very heavily on the CPUs. In contrast, many embedded devices can perform useful work even when the CPUs are completely powered down.
Quoted 7 lines
Well, not really from the Linux point of view. It's not massively different to something like keeping an ethernet controller sufficiently alive to allow it to provide wake on LAN functionality while the system is suspended in terms of what Linux has to do, and quite a few servers have lights out management systems which aren't a million miles away from the modem on a phone in terms of their relationship with the host computer.
Quoted 7 lines
The wake-on-LAN and the lights-out management systems are indeed interesting examples, and actually pretty good ones. The reason I excluded them is that they don't do any application processing -- their only purpose is the care and feeding of the system itself. In contrast, the embedded processors are able to do significant applications processing (e.g., play back music) while any CPUs are completely shut down and most of the memory is powered down as well.
one other significant issue is that on the PC, things like wake-on-LAN, lights out management cards, etc require nothing from the main system other than power. If they do something, they are sending the signal to the chipset, which then wakes the system up. they don't interact with the main processor/memory/etc at all.
So as I see it, we need to do one of two things.
1. change the suspend definition to allow for some things to not be suspended
or
2. change the sleep/low-power mode definition to have a more standardized way of turning things off, and extend it to allow clocks to be turned off as well (today we have things able to be turned off, drive spin-down for example, but per comments in this thread it's all one-off methods)
to me #2 seems the better thing to do from a design/concept point of view
David Lang
Quoted 1 line · On Fri, Aug 06, 2010 at 04:35:59PM -0700, [email protected] wrote:
On Fri, 6 Aug 2010, Paul E. McKenney wrote:
Guys, please try to cut unneeded text from the quotes - it makes it much easier to find the new text.
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
Well, not really from the Linux point of view. It's not massively different to something like keeping an ethernet controller sufficiently alive to allow it to provide wake on LAN functionality while the system
The wake-on-LAN and the lights-out management systems are indeed interesting examples, and actually pretty good ones. The reason I excluded them is that they don't do any application processing -- their only purpose is the care and feeding of the system itself. In contrast, the embedded processors are able to do significant applications processing (e.g., play back music) while any CPUs are completely shut down and most of the memory is powered down as well.
This isn't a particularly meaningful distinction, things like the LoM systems on servers are generally at least as capable as things like the DSPs doing tasks like offloaded MP3 decode and often provide useful services in themselves (like system monitoring). It's really just semantics to treat them differently to something like a cellular modem - at a high level they're both just independant processors ticking away without the application processor.
Quoted 5 lines
one other significant issue is that on the PC, things like wake-on-LAN, lights out management cards, etc require nothing from the main system other than power. If they do something, they are sending the signal to the chipset, which then wakes the system up. they don't interact with the main processor/memory/etc at all.
I don't see that it makes much difference what gets kept alive - at the end of the day the point is that we're making a decision to keep bits of the system alive over suspend.
Quoted 4 lines
So as I see it, we need to do one of two things.
1. change the suspend definition to allow for some things to not be suspended
This is essentially what's already happening.
Quoted 4 lines
2. change the sleep/low-power mode definition to have a more standardized way of turning things off, and extend it to allow clocks to be turned off as well (today we have things able to be turned off, drive spin-down for example, but per comments in this thread it's all one-off methods)
Currently things like clock trees are frequently managed orthogonaly to the system power state to at least some extent anyway - for example, perfectly normal wake events like button presses will often require clocks for things like debouncing.
Quoted 1 line · On Fri, Aug 06, 2010 at 04:35:59PM -0700, [email protected] wrote:
On Fri, 6 Aug 2010, Paul E. McKenney wrote:
Guys, please try to cut unneeded text from the quotes - it makes it much easier to find the new text.
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
Well, not really from the Linux point of view. It's not massively different to something like keeping an ethernet controller sufficiently alive to allow it to provide wake on LAN functionality while the system
The wake-on-LAN and the lights-out management systems are indeed interesting examples, and actually pretty good ones. The reason I excluded them is that they don't do any application processing -- their only purpose is the care and feeding of the system itself. In contrast, the embedded processors are able to do significant applications processing (e.g., play back music) while any CPUs are completely shut down and most of the memory is powered down as well.
This isn't a particularly meaningful distinction, things like the LoM systems on servers are generally at least as capable as things like the DSPs doing tasks like offloaded MP3 decode and often provide useful services in themselves (like system monitoring). It's really just semantics to treat them differently to something like a cellular modem - at a high level they're both just independant processors ticking away without the application processor.
Quoted 5 lines
one other significant issue is that on the PC, things like wake-on-LAN, lights out management cards, etc require nothing from the main system other than power. If they do something, they are sending the signal to the chipset, which then wakes the system up. they don't interact with the main processor/memory/etc at all.
I don't see that it makes much difference what gets kept alive - at the end of the day the point is that we're making a decision to keep bits of the system alive over suspend.
Quoted 4 lines
So as I see it, we need to do one of two things.
1. change the suspend definition to allow for some things to not be suspended
This is essentially what's already happening.
Quoted 4 lines
2. change the sleep/low-power mode definition to have a more standardized way of turning things off, and extend it to allow clocks to be turned off as well (today we have things able to be turned off, drive spin-down for example, but per comments in this thread it's all one-off methods)
Currently things like clock trees are frequently managed orthogonaly to the system power state to at least some extent anyway - for example, perfectly normal wake events like button presses will often require clocks for things like debouncing.
Quoted 18 lines · Mark Brown
Quoted 1 line · On Fri, Aug 06, 2010 at 04:35:59PM -0700, [email protected] wrote:
On Fri, 6 Aug 2010, Paul E. McKenney wrote:
Guys, please try to cut unneeded text from the quotes - it makes it much easier to find the new text.
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
Well, not really from the Linux point of view. It's not massively different to something like keeping an ethernet controller sufficiently alive to allow it to provide wake on LAN functionality while the system
The wake-on-LAN and the lights-out management systems are indeed interesting examples, and actually pretty good ones. The reason I excluded them is that they don't do any application processing -- their only purpose is the care and feeding of the system itself. In contrast, the embedded processors are able to do significant applications processing (e.g., play back music) while any CPUs are completely shut down and most of the memory is powered down as well.
Quoted 7 lines
This isn't a particularly meaningful distinction, things like the LoM systems on servers are generally at least as capable as things like the DSPs doing tasks like offloaded MP3 decode and often provide useful services in themselves (like system monitoring). It's really just semantics to treat them differently to something like a cellular modem - at a high level they're both just independant processors ticking away without the application processor.
I agree that a smartphone's cellular modem can be argued to be very similar to wake-on-LAN. The smartphone applications that seem to me to be very different from wake-on-LAN are things like audio playback, where the system is providing service to the user during the time that it is suspended.
Quoted 9 lines
Quoted 5 lines
one other significant issue is that on the PC, things like wake-on-LAN, lights out management cards, etc require nothing from the main system other than power. If they do something, they are sending the signal to the chipset, which then wakes the system up. they don't interact with the main processor/memory/etc at all.
I don't see that it makes much difference what gets kept alive - at the end of the day the point is that we're making a decision to keep bits of the system alive over suspend.
The distinction is whether or not the system is perceived to be actively doing something useful while it is suspended. Yes, this is subjective, but the distinction is still important.
Quoted 6 lines
Quoted 4 lines
So as I see it, we need to do one of two things.
1. change the suspend definition to allow for some things to not be suspended
This is essentially what's already happening.
The time-of-day clock is certainly a case in point here. ;-)
Thanx, Paul
Quoted 9 lines
Quoted 4 lines
2. change the sleep/low-power mode definition to have a more standardized way of turning things off, and extend it to allow clocks to be turned off as well (today we have things able to be turned off, drive spin-down for example, but per comments in this thread it's all one-off methods)
Currently things like clock trees are frequently managed orthogonaly to the system power state to at least some extent anyway - for example, perfectly normal wake events like button presses will often require clocks for things like debouncing.
Quoted 18 lines · Mark Brown
Quoted 1 line · On Fri, Aug 06, 2010 at 04:35:59PM -0700, [email protected] wrote:
On Fri, 6 Aug 2010, Paul E. McKenney wrote:
Guys, please try to cut unneeded text from the quotes - it makes it much easier to find the new text.
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
Well, not really from the Linux point of view. It's not massively different to something like keeping an ethernet controller sufficiently alive to allow it to provide wake on LAN functionality while the system
The wake-on-LAN and the lights-out management systems are indeed interesting examples, and actually pretty good ones. The reason I excluded them is that they don't do any application processing -- their only purpose is the care and feeding of the system itself. In contrast, the embedded processors are able to do significant applications processing (e.g., play back music) while any CPUs are completely shut down and most of the memory is powered down as well.
Quoted 7 lines
This isn't a particularly meaningful distinction, things like the LoM systems on servers are generally at least as capable as things like the DSPs doing tasks like offloaded MP3 decode and often provide useful services in themselves (like system monitoring). It's really just semantics to treat them differently to something like a cellular modem - at a high level they're both just independant processors ticking away without the application processor.
I agree that a smartphone's cellular modem can be argued to be very similar to wake-on-LAN. The smartphone applications that seem to me to be very different from wake-on-LAN are things like audio playback, where the system is providing service to the user during the time that it is suspended.
Quoted 9 lines
Quoted 5 lines
one other significant issue is that on the PC, things like wake-on-LAN, lights out management cards, etc require nothing from the main system other than power. If they do something, they are sending the signal to the chipset, which then wakes the system up. they don't interact with the main processor/memory/etc at all.
I don't see that it makes much difference what gets kept alive - at the end of the day the point is that we're making a decision to keep bits of the system alive over suspend.
The distinction is whether or not the system is perceived to be actively doing something useful while it is suspended. Yes, this is subjective, but the distinction is still important.
Quoted 6 lines
Quoted 4 lines
So as I see it, we need to do one of two things.
1. change the suspend definition to allow for some things to not be suspended
This is essentially what's already happening.
The time-of-day clock is certainly a case in point here. ;-)
Thanx, Paul
Quoted 9 lines
Quoted 4 lines
2. change the sleep/low-power mode definition to have a more standardized way of turning things off, and extend it to allow clocks to be turned off as well (today we have things able to be turned off, drive spin-down for example, but per comments in this thread it's all one-off methods)
Currently things like clock trees are frequently managed orthogonaly to the system power state to at least some extent anyway - for example, perfectly normal wake events like button presses will often require clocks for things like debouncing.
Quoted 7 lines · Paul E. McKenney
Quoted 4 lines · Mark Brown
services in themselves (like system monitoring). It's really just semantics to treat them differently to something like a cellular modem - at a high level they're both just independant processors ticking away without the application processor.
Quoted 5 lines
I agree that a smartphone's cellular modem can be argued to be very similar to wake-on-LAN. The smartphone applications that seem to me to be very different from wake-on-LAN are things like audio playback, where the system is providing service to the user during the time that it is suspended.
The cellular modem case includes not just hanging off the network but also being on a call - the voice path for a phone call doesn't need the CPU to do anything. It's probably best to view a phone as a bunch of interconnected systems that happen to sit in the same box, and there's various design decisions that can be taken about which systems own the shared components.
Quoted 7 lines · Paul E. McKenney
Quoted 4 lines · Mark Brown
services in themselves (like system monitoring). It's really just semantics to treat them differently to something like a cellular modem - at a high level they're both just independant processors ticking away without the application processor.
Quoted 5 lines
I agree that a smartphone's cellular modem can be argued to be very similar to wake-on-LAN. The smartphone applications that seem to me to be very different from wake-on-LAN are things like audio playback, where the system is providing service to the user during the time that it is suspended.
The cellular modem case includes not just hanging off the network but also being on a call - the voice path for a phone call doesn't need the CPU to do anything. It's probably best to view a phone as a bunch of interconnected systems that happen to sit in the same box, and there's various design decisions that can be taken about which systems own the shared components.
Quoted 14 lines · Mark Brown
Quoted 7 lines · Paul E. McKenney
Quoted 4 lines · Mark Brown
services in themselves (like system monitoring). It's really just semantics to treat them differently to something like a cellular modem - at a high level they're both just independant processors ticking away without the application processor.
Quoted 5 lines
I agree that a smartphone's cellular modem can be argued to be very similar to wake-on-LAN. The smartphone applications that seem to me to be very different from wake-on-LAN are things like audio playback, where the system is providing service to the user during the time that it is suspended.
Quoted 6 lines
The cellular modem case includes not just hanging off the network but also being on a call - the voice path for a phone call doesn't need the CPU to do anything. It's probably best to view a phone as a bunch of interconnected systems that happen to sit in the same box, and there's various design decisions that can be taken about which systems own the shared components.
OK, apologies, I thought you were talking about the wait-for-a-call case. If there actually is a call ongoing, then the user perceives the system as doing something, so this is similar to audio playback and quite different from wake-on-LAN or system monitoring.
Thanx, Paul
Quoted 14 lines · Mark Brown
Quoted 7 lines · Paul E. McKenney
Quoted 4 lines · Mark Brown
services in themselves (like system monitoring). It's really just semantics to treat them differently to something like a cellular modem - at a high level they're both just independant processors ticking away without the application processor.
Quoted 5 lines
I agree that a smartphone's cellular modem can be argued to be very similar to wake-on-LAN. The smartphone applications that seem to me to be very different from wake-on-LAN are things like audio playback, where the system is providing service to the user during the time that it is suspended.
Quoted 6 lines
The cellular modem case includes not just hanging off the network but also being on a call - the voice path for a phone call doesn't need the CPU to do anything. It's probably best to view a phone as a bunch of interconnected systems that happen to sit in the same box, and there's various design decisions that can be taken about which systems own the shared components.
OK, apologies, I thought you were talking about the wait-for-a-call case. If there actually is a call ongoing, then the user perceives the system as doing something, so this is similar to audio playback and quite different from wake-on-LAN or system monitoring.
Thanx, Paul
Quoted 15 lines · Mark Brown
Quoted 6 lines · On Fri, Aug 06, 2010 at 04:35:59PM -0700, [email protected] wrote:
On Fri, 6 Aug 2010, Paul E. McKenney wrote:
So as I see it, we need to do one of two things.
1. change the suspend definition to allow for some things to not be suspended
This is essentially what's already happening.
Quoted 4 lines
2. change the sleep/low-power mode definition to have a more standardized way of turning things off, and extend it to allow clocks to be turned off as well (today we have things able to be turned off, drive spin-down for example, but per comments in this thread it's all one-off methods)
Quoted 4 lines
Currently things like clock trees are frequently managed orthogonaly to the system power state to at least some extent anyway - for example, perfectly normal wake events like button presses will often require clocks for things like debouncing.
I recognise that #1 is essentially what Android is already doing.
I'm asking the question, "Is this what Linux should be doing?
Personally, I think that suspend should be treated much more like a low-power state and much less like hibernation than it currently is (I believe that Linus has also voiced this opinion). And I think that the situation with Android suspending while audio is playing between busts of CPU activity is a perfect example.
for the moment, forget the problem of other apps that may be running, and consider a system that's just running a media player.
the media player needs bursts of CPU to decode the media so that the output device can access it (via DMA or something like that)
the media player needs bursts of I/O to read the encoded program source from storage.
What we want to have happen in an ideal world is
when the storage isn't needed (between reads) the storage should shutdown to as low a power state as possible.
when the CPU isn't needed (between decoding bursts) the CPU and as much of the system as possible (potentially including some banks of RAM) should shutdown to as low a power state as possible.
today there are two ways of this happening, via the idle approach (on everything except Android), or via suspend (on Android)
Given that many platforms cannot go to into suspend while still playing audio, the idle approach is not going to be able to be eliminated (and in fact will be the most common approach to be used/deugged in terms of the types of platforms), it seems to me that there may be a significant amount of value in seeing if there is a way to change Android to use this approach as well instead of having two different systems competing to do the same job.
David Lang