Suspend block api (version 8)
Subsystems (6)
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Peter ZijlstraQuoted 12 lines · Peter Zijlstra
Quoted 10 lines · James Bottomley
Quoted 2 lines
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
It's a fairly large piece of code to try to rewrite in C, so I don't think that's feasible on a reasonable timescale. Android does have the concept of special sockets that can be used to communicate from less to more privileged processes (it has a very segmented runtime model), so these might be usable ... they have a drawback that they're essentially named pipes, so no multiplexing, but one per suspend influencing C process shouldn't be a huge burden.
Quoted 6 lines
It wouldn't need to convert the whole Frameworks layer into C, just enough to manage the suspend state.
Anyway, I think there's been enough arguments against even the concept of opportunistic/auto-suspend, and I for one will object with a NAK if Rafael send this to Linus.
It was submitted already. I tried to followup with NAK, but can't currently see it in the archive.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH 1/8] PM: Opportunistic suspend support.
Quoted 16 lines · Pavel Machek
Quoted 15 lines · Peter Zijlstra
Quoted 10 lines · James Bottomley
Quoted 2 lines
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
It's a fairly large piece of code to try to rewrite in C, so I don't think that's feasible on a reasonable timescale. Android does have the concept of special sockets that can be used to communicate from less to more privileged processes (it has a very segmented runtime model), so these might be usable ... they have a drawback that they're essentially named pipes, so no multiplexing, but one per suspend influencing C process shouldn't be a huge burden.
It wouldn't need to convert the whole Frameworks layer into C, just enough to manage the suspend state.
Quoted 6 lines
Quoted 3 lines
Anyway, I think there's been enough arguments against even the concept of opportunistic/auto-suspend, and I for one will object with a NAK if Rafael send this to Linus.
It was submitted already. I tried to followup with NAK, but can't currently see it in the archive.
It was apparently hidden on some funky list. Hiding pull requests is bad enough, but hiding pull requests for contended features is just plain wrong.
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Pavel MachekQuoted 16 lines · Pavel Machek
Quoted 15 lines · Peter Zijlstra
Quoted 10 lines · James Bottomley
Quoted 2 lines
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
It's a fairly large piece of code to try to rewrite in C, so I don't think that's feasible on a reasonable timescale. Android does have the concept of special sockets that can be used to communicate from less to more privileged processes (it has a very segmented runtime model), so these might be usable ... they have a drawback that they're essentially named pipes, so no multiplexing, but one per suspend influencing C process shouldn't be a huge burden.
It wouldn't need to convert the whole Frameworks layer into C, just enough to manage the suspend state.
Quoted 6 lines
Quoted 3 lines
Anyway, I think there's been enough arguments against even the concept of opportunistic/auto-suspend, and I for one will object with a NAK if Rafael send this to Linus.
It was submitted already. I tried to followup with NAK, but can't currently see it in the archive.
It was apparently hidden on some funky list. Hiding pull requests is bad enough, but hiding pull requests for contended features is just plain wrong.
Re: [PATCH 1/8] PM: Opportunistic suspend support.
Quoted 17 lines · Peter Zijlstra
Quoted 16 lines · Pavel Machek
Quoted 15 lines · Peter Zijlstra
Quoted 10 lines · James Bottomley
Quoted 2 lines
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
It's a fairly large piece of code to try to rewrite in C, so I don't think that's feasible on a reasonable timescale. Android does have the concept of special sockets that can be used to communicate from less to more privileged processes (it has a very segmented runtime model), so these might be usable ... they have a drawback that they're essentially named pipes, so no multiplexing, but one per suspend influencing C process shouldn't be a huge burden.
It wouldn't need to convert the whole Frameworks layer into C, just enough to manage the suspend state.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Anyway, I think there's been enough arguments against even the concept of opportunistic/auto-suspend, and I for one will object with a NAK if Rafael send this to Linus.
It was submitted already. I tried to followup with NAK, but can't currently see it in the archive.
You mean this one:
https://lists.linux-foundation.org/pipermail/linux-pm/2010-May/025689.html
?
Quoted 1 line
It was apparently hidden on some funky list.
Sending a PM pull request to the PM list doesn't really strike me as the height of obfuscation. Plus almost everyone who objected was on the cc list.
Quoted 2 lines
Hiding pull requests is bad enough, but hiding pull requests for
contended features is just plain wrong.
I don't think it's a conspiracy ... just standard operating procedure for this subsystem. I do think cc'ing lkml is good practise (having been yelled at for not doing that in the past) but it's certainly not universal practise.
James
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Peter ZijlstraQuoted 17 lines · Peter Zijlstra
Quoted 16 lines · Pavel Machek
Quoted 15 lines · Peter Zijlstra
Quoted 10 lines · James Bottomley
Quoted 2 lines
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
It's a fairly large piece of code to try to rewrite in C, so I don't think that's feasible on a reasonable timescale. Android does have the concept of special sockets that can be used to communicate from less to more privileged processes (it has a very segmented runtime model), so these might be usable ... they have a drawback that they're essentially named pipes, so no multiplexing, but one per suspend influencing C process shouldn't be a huge burden.
It wouldn't need to convert the whole Frameworks layer into C, just enough to manage the suspend state.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Anyway, I think there's been enough arguments against even the concept of opportunistic/auto-suspend, and I for one will object with a NAK if Rafael send this to Linus.
It was submitted already. I tried to followup with NAK, but can't currently see it in the archive.
You mean this one:
https://lists.linux-foundation.org/pipermail/linux-pm/2010-May/025689.html
?
Quoted 1 line
It was apparently hidden on some funky list.
Sending a PM pull request to the PM list doesn't really strike me as the height of obfuscation. Plus almost everyone who objected was on the cc list.
Quoted 2 lines
Hiding pull requests is bad enough, but hiding pull requests for
contended features is just plain wrong.
I don't think it's a conspiracy ... just standard operating procedure for this subsystem. I do think cc'ing lkml is good practise (having been yelled at for not doing that in the past) but it's certainly not universal practise.
James
Re: [PATCH 1/8] PM: Opportunistic suspend support.
Quoted 37 lines · James Bottomley
Quoted 17 lines · Peter Zijlstra
Quoted 16 lines · Pavel Machek
Quoted 15 lines · Peter Zijlstra
Quoted 10 lines · James Bottomley
Quoted 2 lines
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
It's a fairly large piece of code to try to rewrite in C, so I don't think that's feasible on a reasonable timescale. Android does have the concept of special sockets that can be used to communicate from less to more privileged processes (it has a very segmented runtime model), so these might be usable ... they have a drawback that they're essentially named pipes, so no multiplexing, but one per suspend influencing C process shouldn't be a huge burden.
It wouldn't need to convert the whole Frameworks layer into C, just enough to manage the suspend state.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Anyway, I think there's been enough arguments against even the concept of opportunistic/auto-suspend, and I for one will object with a NAK if Rafael send this to Linus.
It was submitted already. I tried to followup with NAK, but can't currently see it in the archive.
You mean this one:
https://lists.linux-foundation.org/pipermail/linux-pm/2010-May/025689.html
?
Quoted 1 line
It was apparently hidden on some funky list.
Sending a PM pull request to the PM list doesn't really strike me as the height of obfuscation. Plus almost everyone who objected was on the cc list.
Quoted 7 lines
Quoted 2 lines
Hiding pull requests is bad enough, but hiding pull requests for
contended features is just plain wrong.I don't think it's a conspiracy ... just standard operating procedure for this subsystem. I do think cc'ing lkml is good practise (having been yelled at for not doing that in the past) but it's certainly not universal practise.
At least it would be good style for a topic which is
1) contended like this one
2) pushing an intrusive feature last minute which has been merged into the pm tree barely two days ago.
Darn, _we_ have to deal with that forever as it sets a crappy user space ABI in stone.
Thanks,
tglx
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to James BottomleyQuoted 37 lines · James Bottomley
Quoted 17 lines · Peter Zijlstra
Quoted 16 lines · Pavel Machek
Quoted 15 lines · Peter Zijlstra
Quoted 10 lines · James Bottomley
Quoted 2 lines
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
It's a fairly large piece of code to try to rewrite in C, so I don't think that's feasible on a reasonable timescale. Android does have the concept of special sockets that can be used to communicate from less to more privileged processes (it has a very segmented runtime model), so these might be usable ... they have a drawback that they're essentially named pipes, so no multiplexing, but one per suspend influencing C process shouldn't be a huge burden.
It wouldn't need to convert the whole Frameworks layer into C, just enough to manage the suspend state.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Anyway, I think there's been enough arguments against even the concept of opportunistic/auto-suspend, and I for one will object with a NAK if Rafael send this to Linus.
It was submitted already. I tried to followup with NAK, but can't currently see it in the archive.
You mean this one:
https://lists.linux-foundation.org/pipermail/linux-pm/2010-May/025689.html
?
Quoted 1 line
It was apparently hidden on some funky list.
Sending a PM pull request to the PM list doesn't really strike me as the height of obfuscation. Plus almost everyone who objected was on the cc list.
Quoted 7 lines
Quoted 2 lines
Hiding pull requests is bad enough, but hiding pull requests for
contended features is just plain wrong.I don't think it's a conspiracy ... just standard operating procedure for this subsystem. I do think cc'ing lkml is good practise (having been yelled at for not doing that in the past) but it's certainly not universal practise.
At least it would be good style for a topic which is
1) contended like this one
2) pushing an intrusive feature last minute which has been merged into the pm tree barely two days ago.
Darn, _we_ have to deal with that forever as it sets a crappy user space ABI in stone.
Thanks,
tglx
Re: [PATCH 1/8] PM: Opportunistic suspend support.
Quoted 46 lines · Thomas Gleixner
Quoted 37 lines · James Bottomley
Quoted 17 lines · Peter Zijlstra
Quoted 16 lines · Pavel Machek
Quoted 15 lines · Peter Zijlstra
Quoted 10 lines · James Bottomley
Quoted 2 lines
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
It's a fairly large piece of code to try to rewrite in C, so I don't think that's feasible on a reasonable timescale. Android does have the concept of special sockets that can be used to communicate from less to more privileged processes (it has a very segmented runtime model), so these might be usable ... they have a drawback that they're essentially named pipes, so no multiplexing, but one per suspend influencing C process shouldn't be a huge burden.
It wouldn't need to convert the whole Frameworks layer into C, just enough to manage the suspend state.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Anyway, I think there's been enough arguments against even the concept of opportunistic/auto-suspend, and I for one will object with a NAK if Rafael send this to Linus.
It was submitted already. I tried to followup with NAK, but can't currently see it in the archive.
You mean this one:
https://lists.linux-foundation.org/pipermail/linux-pm/2010-May/025689.html
?
Quoted 1 line
It was apparently hidden on some funky list.
Sending a PM pull request to the PM list doesn't really strike me as the height of obfuscation. Plus almost everyone who objected was on the cc list.
Quoted 7 lines
Quoted 2 lines
Hiding pull requests is bad enough, but hiding pull requests for
contended features is just plain wrong.I don't think it's a conspiracy ... just standard operating procedure for this subsystem. I do think cc'ing lkml is good practise (having been yelled at for not doing that in the past) but it's certainly not universal practise.
Quoted 6 lines
At least it would be good style for a topic which is
1) contended like this one
2) pushing an intrusive feature last minute which has been merged into the pm tree barely two days ago.
Don't disagree ... I was just explaining how it could happen while not being a conspiracy.
Quoted 2 lines
Darn, _we_ have to deal with that forever as it sets a crappy user space ABI in stone.
I really don't see how it is ... the ABI comes with a switch that allows it to be disabled, so only platforms wishing to use it have to support it. Even on those platforms that do support it, we can translate most of it into pm QoS stuff and if one day someone solves the rogue app problem, we can migrate over.
James
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Thomas GleixnerQuoted 46 lines · Thomas Gleixner
Quoted 37 lines · James Bottomley
Quoted 17 lines · Peter Zijlstra
Quoted 16 lines · Pavel Machek
Quoted 15 lines · Peter Zijlstra
Quoted 10 lines · James Bottomley
Quoted 2 lines
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
It's a fairly large piece of code to try to rewrite in C, so I don't think that's feasible on a reasonable timescale. Android does have the concept of special sockets that can be used to communicate from less to more privileged processes (it has a very segmented runtime model), so these might be usable ... they have a drawback that they're essentially named pipes, so no multiplexing, but one per suspend influencing C process shouldn't be a huge burden.
It wouldn't need to convert the whole Frameworks layer into C, just enough to manage the suspend state.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Anyway, I think there's been enough arguments against even the concept of opportunistic/auto-suspend, and I for one will object with a NAK if Rafael send this to Linus.
It was submitted already. I tried to followup with NAK, but can't currently see it in the archive.
You mean this one:
https://lists.linux-foundation.org/pipermail/linux-pm/2010-May/025689.html
?
Quoted 1 line
It was apparently hidden on some funky list.
Sending a PM pull request to the PM list doesn't really strike me as the height of obfuscation. Plus almost everyone who objected was on the cc list.
Quoted 7 lines
Quoted 2 lines
Hiding pull requests is bad enough, but hiding pull requests for
contended features is just plain wrong.I don't think it's a conspiracy ... just standard operating procedure for this subsystem. I do think cc'ing lkml is good practise (having been yelled at for not doing that in the past) but it's certainly not universal practise.
Quoted 6 lines
At least it would be good style for a topic which is
1) contended like this one
2) pushing an intrusive feature last minute which has been merged into the pm tree barely two days ago.
Don't disagree ... I was just explaining how it could happen while not being a conspiracy.
Quoted 2 lines
Darn, _we_ have to deal with that forever as it sets a crappy user space ABI in stone.
I really don't see how it is ... the ABI comes with a switch that allows it to be disabled, so only platforms wishing to use it have to support it. Even on those platforms that do support it, we can translate most of it into pm QoS stuff and if one day someone solves the rogue app problem, we can migrate over.
James
Re: [PATCH 1/8] PM: Opportunistic suspend support.
Quoted 9 lines · James Bottomley
Quoted 2 lines · Thomas Gleixner
Darn, _we_ have to deal with that forever as it sets a crappy user space ABI in stone.
I really don't see how it is ... the ABI comes with a switch that allows it to be disabled, so only platforms wishing to use it have to support it. Even on those platforms that do support it, we can translate most of it into pm QoS stuff and if one day someone solves the rogue app problem, we can migrate over.
And yet, the OSS drivers are *still* in-tree, even though similar arguments apply to an OSS->ALSA migration. And there's a bunch of other stuff in Documentation/feature-removal-schedule.txt in a similar situation.
Remember - programming is like sex. One poorly planned release and you're stuck maintaining it for years. :)
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to James BottomleyQuoted 9 lines · James Bottomley
Quoted 2 lines · Thomas Gleixner
Darn, _we_ have to deal with that forever as it sets a crappy user space ABI in stone.
I really don't see how it is ... the ABI comes with a switch that allows it to be disabled, so only platforms wishing to use it have to support it. Even on those platforms that do support it, we can translate most of it into pm QoS stuff and if one day someone solves the rogue app problem, we can migrate over.
And yet, the OSS drivers are *still* in-tree, even though similar arguments apply to an OSS->ALSA migration. And there's a bunch of other stuff in Documentation/feature-removal-schedule.txt in a similar situation.
Remember - programming is like sex. One poorly planned release and you're stuck maintaining it for years. :)
Re: [PATCH 1/8] PM: Opportunistic suspend support.
Quoted 11 lines · On Wed, 2010-05-26 at 14:50 -0400, [email protected] wrote:
Quoted 9 lines · James Bottomley
Quoted 2 lines · Thomas Gleixner
Darn, _we_ have to deal with that forever as it sets a crappy user space ABI in stone.
I really don't see how it is ... the ABI comes with a switch that allows it to be disabled, so only platforms wishing to use it have to support it. Even on those platforms that do support it, we can translate most of it into pm QoS stuff and if one day someone solves the rogue app problem, we can migrate over.
Quoted 3 lines
And yet, the OSS drivers are *still* in-tree, even though similar arguments apply to an
OSS->ALSAmigration. And there's a bunch of other stuff inDocumentation/feature-removal-schedule.txtin a similar situation.
On the other hand APM, which is what all laptops used to use to suspend is gone from the x86 kernel today ... replaced by ACPI or other platform mechanisms, so it is at least possible.
James
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to [email protected]Quoted 11 lines · On Wed, 2010-05-26 at 14:50 -0400, [email protected] wrote:
Quoted 9 lines · James Bottomley
Quoted 2 lines · Thomas Gleixner
Darn, _we_ have to deal with that forever as it sets a crappy user space ABI in stone.
I really don't see how it is ... the ABI comes with a switch that allows it to be disabled, so only platforms wishing to use it have to support it. Even on those platforms that do support it, we can translate most of it into pm QoS stuff and if one day someone solves the rogue app problem, we can migrate over.
Quoted 3 lines
And yet, the OSS drivers are *still* in-tree, even though similar arguments apply to an
OSS->ALSAmigration. And there's a bunch of other stuff inDocumentation/feature-removal-schedule.txtin a similar situation.
On the other hand APM, which is what all laptops used to use to suspend is gone from the x86 kernel today ... replaced by ACPI or other platform mechanisms, so it is at least possible.
James
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to James BottomleyQuoted 1 line · James Bottomley
On Wed, 2010-05-26 at 19:51 +0200, Thomas Gleixner wrote:
[...]
Quoted 6 lines
Quoted 2 lines
Darn, _we_ have to deal with that forever as it sets a crappy user space ABI in stone.
I really don't see how it is ... the ABI comes with a switch that allows it to be disabled, so only platforms wishing to use it have to support it. Even on those platforms that do support it, we can translate most
You completely missed the point: The crappy user interface - and interferences with pother subsystems - must be maintained for ages - and that is independent if one uses it or not. Even worse if it's not widely used.
Quoted 2 lines
of it into pm QoS stuff and if one day someone solves the rogue app problem, we can migrate over.
If it's so important for Android and no one else, Android can carry it out of tree.
Bernd
Signature · 2 lines
Bernd Petrovitsch Email : [email protected] LUGA : http://www.luga.at
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to James BottomleyQuoted 1 line · James Bottomley
On Wed, 2010-05-26 at 19:51 +0200, Thomas Gleixner wrote:
[...]
Quoted 6 lines
Quoted 2 lines
Darn, _we_ have to deal with that forever as it sets a crappy user space ABI in stone.
I really don't see how it is ... the ABI comes with a switch that allows it to be disabled, so only platforms wishing to use it have to support it. Even on those platforms that do support it, we can translate most
You completely missed the point: The crappy user interface - and interferences with pother subsystems - must be maintained for ages - and that is independent if one uses it or not. Even worse if it's not widely used.
Quoted 2 lines
of it into pm QoS stuff and if one day someone solves the rogue app problem, we can migrate over.
If it's so important for Android and no one else, Android can carry it out of tree.
Bernd
Signature · 2 lines
Bernd Petrovitsch Email : [email protected] LUGA : http://www.luga.at
Re: [PATCH 1/8] PM: Opportunistic suspend support.
Quoted 6 lines · Bernd Petrovitsch
Quoted 1 line · James Bottomley
On Wed, 2010-05-26 at 19:51 +0200, Thomas Gleixner wrote:
[...]
Quoted 3 lines
Quoted 2 lines
Darn, _we_ have to deal with that forever as it sets a crappy user space ABI in stone.
Quoted 8 lines
Quoted 3 lines
I really don't see how it is ... the ABI comes with a switch that allows it to be disabled, so only platforms wishing to use it have to support it. Even on those platforms that do support it, we can translate most
You completely missed the point: The crappy user interface - and interferences with pother subsystems - must be maintained for ages - and that is independent if one uses it or not. Even worse if it's not widely used.
When (or if) the time comes that suspend is no longer useful, this api becomes a NOP.
Quoted 7 lines
Quoted 3 lines
of it into pm QoS stuff and if one day someone solves the rogue app problem, we can migrate over.
If it's so important for Android and no one else, Android can carry it out of tree.
This is not only important for Android. If you use suspend on a current Linux system you run the risk of loosing wakeup events. If you have wakeup events that you cannot afford to lose your only option is to never suspend. On some hardware (e.g. x86) the cost of not suspending is always huge, on other hardware (many ARM SOCs) the cost is only huge if your apps behave poorly.
Signature · 1 line
Arve Hjønnevåg
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Bernd PetrovitschQuoted 6 lines · Bernd Petrovitsch
Quoted 1 line · James Bottomley
On Wed, 2010-05-26 at 19:51 +0200, Thomas Gleixner wrote:
[...]
Quoted 3 lines
Quoted 2 lines
Darn, _we_ have to deal with that forever as it sets a crappy user space ABI in stone.
Quoted 8 lines
Quoted 3 lines
I really don't see how it is ... the ABI comes with a switch that allows it to be disabled, so only platforms wishing to use it have to support it. Even on those platforms that do support it, we can translate most
You completely missed the point: The crappy user interface - and interferences with pother subsystems - must be maintained for ages - and that is independent if one uses it or not. Even worse if it's not widely used.
When (or if) the time comes that suspend is no longer useful, this api becomes a NOP.
Quoted 7 lines
Quoted 3 lines
of it into pm QoS stuff and if one day someone solves the rogue app problem, we can migrate over.
If it's so important for Android and no one else, Android can carry it out of tree.
This is not only important for Android. If you use suspend on a current Linux system you run the risk of loosing wakeup events. If you have wakeup events that you cannot afford to lose your only option is to never suspend. On some hardware (e.g. x86) the cost of not suspending is always huge, on other hardware (many ARM SOCs) the cost is only huge if your apps behave poorly.
Signature · 1 line
Arve Hjønnevåg
Just fix the bug - Re: [PATCH 1/8] PM: Opportunistic suspend support.
Quoted 8 lines · On Thu, 27 May 2010 02:07:21 -0700 Arve Hjønnevåg <[email protected]> wrote:
Quoted 7 lines
Quoted 3 lines
of it into pm QoS stuff and if one day someone solves the rogue app problem, we can migrate over.
If it's so important for Android and no one else, Android can carry it out of tree.
Quoted 7 lines
This is not only important for Android. If you use suspend on a current Linux system you run the risk of loosing wakeup events. If you have wakeup events that you cannot afford to lose your only option is to never suspend. On some hardware (e.g. x86) the cost of not suspending is always huge, on other hardware (many ARM SOCs) the cost is only huge if your apps behave poorly.
So here is my suggestion.
Rather than trying to push a feature that is clearly meeting lots of resistance, the Android devs should state the problem as a bug that needs fixing. As you have.
Upstream is a lot more receptive of fixing bugs than adding features.
In this case the bug is that you cannot suspend without the risk of losing wakeup events. This is a real bug that for your use case is a serious bug. I've toyed with several ways of fixing this but the one that seems most promising is to note that in the kernel the suspend process is two-stage with a 'prepare' followed by a 'suspend'. Userspace cannot make that distinction and so ends up with a race.
Maybe userspace should be able to say "prepare to suspend" with the meaning that after a successful return, any event which would cause a wakeup sets a flag so that the final suspend returns immediately (without actually going to the lower power state).
Then your opportunistic suspend could be entirely in userspace where you wouldn't have to fight with the kernel crowd :-)
The suspend-daemon would:
Wait for all user-space suspend blocks to be dropped.
Tell the kernel to "prepare to suspend".
Tell all userspace programs which have registered for the message that they
should prepare to suspend. They have the opportunity at this point to take out a new suspend block if they notice an event that has just arrived
Wait for all those programs to acknowledge
If there are no new suspend blocks, tell the kernel to suspend else tell the kernel to abort the suspend.
This (I think) allows race-free opportunistic suspend in user-space where you can do all the accounting you need.
I don't fully understand your requirements for accounting of devices drivers rejecting or blocking a suspend, so I cannot say precisely how that would fit in. Maybe you just need to know - whenever the 'suspend request' completes - what the wakeup events were. It shouldn't be too hard to export that to user-space via sysfs.
I won't propose an exact enhancement to the user-space interface for requesting a suspend, but I suspect it should expose each of
suspend_prepare
suspend_devices_and_enter
suspend_finish
(or close analogues there-of) to user-space. It is tempting to map those to "open-for-write", "write", "close", but I'm not sure that suspend_prepare would be appropriate if the app was about to write "disk" - it is a pity that both suspend and hibernate use the same sysfs file.
So just fix the bug, and everyone will be happy :-)
Thanks,
NeilBrown
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Re: Just fix the bug - Re: [PATCH 1/8] PM: Opportunistic suspend support.
2010/5/27 Neil Brown <[email protected]>:
Quoted 50 lines
Quoted 8 lines · On Thu, 27 May 2010 02:07:21 -0700 Arve Hjønnevåg <[email protected]> wrote:
Quoted 7 lines
Quoted 3 lines
of it into pm QoS stuff and if one day someone solves the rogue app problem, we can migrate over.
If it's so important for Android and no one else, Android can carry it out of tree.
Quoted 7 lines
This is not only important for Android. If you use suspend on a current Linux system you run the risk of loosing wakeup events. If you have wakeup events that you cannot afford to lose your only option is to never suspend. On some hardware (e.g. x86) the cost of not suspending is always huge, on other hardware (many ARM SOCs) the cost is only huge if your apps behave poorly.
So here is my suggestion.
Rather than trying to push a feature that is clearly meeting lots of resistance, the Android devs should state the problem as a bug that needs fixing. As you have.
Upstream is a lot more receptive of fixing bugs than adding features.In this case the bug is that you cannot suspend without the risk of losing wakeup events. This is a real bug that for your use case is a serious bug. I've toyed with several ways of fixing this but the one that seems most promising is to note that in the kernel the suspend process is two-stage with a 'prepare' followed by a 'suspend'. Userspace cannot make that distinction and so ends up with a race.
Maybe userspace should be able to say "prepare to suspend" with the meaning that after a successful return, any event which would cause a wakeup sets a flag so that the final suspend returns immediately (without actually going to the lower power state).
Then your opportunistic suspend could be entirely in userspace where you wouldn't have to fight with the kernel crowd :-)
The suspend-daemon would:
Wait for all user-space suspend blocks to be dropped.
Tell the kernel to "prepare to suspend".
Tell all userspace programs which have registered for the message that they should prepare to suspend. They have the opportunity at this point to take out a new suspend block if they notice an event that has just arrived
Wait for all those programs to acknowledge
If there are no new suspend blocks, tell the kernel to suspend else tell the kernel to abort the suspend.
Quoted 3 lines
This (I think) allows race-free opportunistic suspend in user-space where you can do all the accounting you need.
Perhaps, but it forces all user space programs that get events from the kernel to also receive messages from the suspend-daemon, check for other events again, then respond to the suspend-daemon. The current suspend blocker interface is easier to use. I don't see how your suggestion avoids races for events that pass trough several kernel layers though. If a wakeup event happened before the "prepare to suspend" call but has not yet been passed to user-space, the user-space program that needs this event will not know that it needs to block suspend when it gets the prepare-to-suspend message.
Quoted 16 lines
I don't fully understand your requirements for accounting of devices drivers rejecting or blocking a suspend, so I cannot say precisely how that would fit in. Maybe you just need to know - whenever the 'suspend request' completes - what the wakeup events were. It shouldn't be too hard to export that to user-space via sysfs.
I won't propose an exact enhancement to the user-space interface for requesting a suspend, but I suspect it should expose each of
suspend_prepare
suspend_devices_and_enter
suspend_finish
(or close analogues there-of) to user-space. It is tempting to map those to "open-for-write", "write", "close", but I'm not sure thatsuspend_preparewould be appropriate if the app was about to write "disk" - it is a pity that both suspend and hibernate use the same sysfs file.
Quoted 2 lines
So just fix the bug, and everyone will be happy :-)
I already have, but everyone do not appear to be happy.
Signature · 1 line
Arve Hjønnevåg
Re: Just fix the bug - Re: [PATCH 1/8] PM: Opportunistic suspend support.
Quoted 51 lines · On Thu, 27 May 2010 21:57:02 -0700 Arve Hjønnevåg <[email protected]> wrote:
2010/5/27 Neil Brown <[email protected]>:
Quoted 50 lines
Quoted 8 lines · On Thu, 27 May 2010 02:07:21 -0700 Arve Hjønnevåg <[email protected]> wrote:
Quoted 7 lines
Quoted 3 lines
of it into pm QoS stuff and if one day someone solves the rogue app problem, we can migrate over.
If it's so important for Android and no one else, Android can carry it out of tree.
Quoted 7 lines
This is not only important for Android. If you use suspend on a current Linux system you run the risk of loosing wakeup events. If you have wakeup events that you cannot afford to lose your only option is to never suspend. On some hardware (e.g. x86) the cost of not suspending is always huge, on other hardware (many ARM SOCs) the cost is only huge if your apps behave poorly.
So here is my suggestion.
Rather than trying to push a feature that is clearly meeting lots of resistance, the Android devs should state the problem as a bug that needs fixing. As you have.
Upstream is a lot more receptive of fixing bugs than adding features.In this case the bug is that you cannot suspend without the risk of losing wakeup events. This is a real bug that for your use case is a serious bug. I've toyed with several ways of fixing this but the one that seems most promising is to note that in the kernel the suspend process is two-stage with a 'prepare' followed by a 'suspend'. Userspace cannot make that distinction and so ends up with a race.
Maybe userspace should be able to say "prepare to suspend" with the meaning that after a successful return, any event which would cause a wakeup sets a flag so that the final suspend returns immediately (without actually going to the lower power state).
Then your opportunistic suspend could be entirely in userspace where you wouldn't have to fight with the kernel crowd :-)
The suspend-daemon would:
Wait for all user-space suspend blocks to be dropped.
Tell the kernel to "prepare to suspend".
Tell all userspace programs which have registered for the message that they should prepare to suspend. They have the opportunity at this point to take out a new suspend block if they notice an event that has just arrived
Wait for all those programs to acknowledge
If there are no new suspend blocks, tell the kernel to suspend else tell the kernel to abort the suspend.
Quoted 8 lines
Quoted 3 lines
This (I think) allows race-free opportunistic suspend in user-space where you can do all the accounting you need.
Perhaps, but it forces all user space programs that get events from the kernel to also receive messages from the suspend-daemon, check for other events again, then respond to the suspend-daemon. The current suspend blocker interface is easier to use.
Maybe so. There are quite possibly better ways to fix the bug. There are a variety of different tradeoffs possible and I suspect we could have fun arguing about those. My main point though is that if we focus on a bug that needs to be fixed, we should be able to keep the conversation more focussed. Currently it seems to be branching all over the place which doesn't seem very helpful.
Quoted 6 lines
I don't see how your
suggestion avoids races for events that pass trough several kernel layers though. If a wakeup event happened before the "prepare to suspend" call but has not yet been passed to user-space, the user-space program that needs this event will not know that it needs to block suspend when it gets the prepare-to-suspend message.
Each layer must understand that the event is a wake-up event, and the "prepare to suspend call" to each layer should drive all pending events through to the next layer. If the layers (drivers) are prepared in the "right" order, this will force the event all the way to user-space. If they are called in exactly the "Wrong" order, this will require multiple prepare/suspend/instant-resume cycles to get the event through, but I suspect that this would very rarely result in truly pathological behaviour.
I'm guessing your current code (sorry, I haven't looked at all) already tracks events up through multiple layers so they can interact with a pending opporunistic-suspend request. I suspect that aspect of the code isn't particularly controversial.
Keep that, and use it precisely to implement a race-free "suspend" request from user-space.
Quoted 17 lines
Quoted 17 lines
I don't fully understand your requirements for accounting of devices drivers rejecting or blocking a suspend, so I cannot say precisely how that would fit in. Maybe you just need to know - whenever the 'suspend request' completes - what the wakeup events were. It shouldn't be too hard to export that to user-space via sysfs.
I won't propose an exact enhancement to the user-space interface for requesting a suspend, but I suspect it should expose each of
suspend_prepare
suspend_devices_and_enter
suspend_finish
(or close analogues there-of) to user-space. It is tempting to map those to "open-for-write", "write", "close", but I'm not sure thatsuspend_preparewould be appropriate if the app was about to write "disk" - it is a pity that both suspend and hibernate use the same sysfs file.
Quoted 5 lines
Quoted 2 lines
So just fix the bug, and everyone will be happy :-)
I already have, but everyone do not appear to be happy.
I don't think you have. You have proposed a significant new feature: a suspend-as-soon-as-you-can request which *user*space*can*block*. People don't like that because it seems like a poor second cousin to something that would be really useful (user-space setting more general latency requirements).
I am suggesting that you stick with the feature we have, which is that user-space can request a suspend and the kernel/hardware can cause a subsequent (possibly immediate) resume in response to a wake-up event. Argue that the current definition of "wake-up event" is too weak and does not allow the feature to be used safely. Present an implementation (I suspect you have most of it already) where a wake-up event is tracked all the way from the hardware to user-space and is still a 'wake-up event' until userspace actually consumes it.
Then user-space simply has to:
poll for event to be ready
request suspend-block in user-space
consume event
handle event
release suspend-block
loop
No change to API. No new concepts. Simply a bug and a direct fix.
You probably want the "suspend" request to block until there are no pending events (and then immediately fail if there were) so that there is no risk of the suspend-daemon spinning asking of a suspend which appears to resume immediately (until some other process sees an event and blocks suspend.
NeilBrown
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Re: Just fix the bug - Re: [PATCH 1/8] PM: Opportunistic suspend support.
2010/5/27 Neil Brown <[email protected]>:
Quoted 112 lines
Quoted 51 lines · On Thu, 27 May 2010 21:57:02 -0700 Arve Hjønnevåg <[email protected]> wrote:
2010/5/27 Neil Brown <[email protected]>:
Quoted 50 lines
Quoted 8 lines · On Thu, 27 May 2010 02:07:21 -0700 Arve Hjønnevåg <[email protected]> wrote:
Quoted 7 lines
Quoted 3 lines
of it into pm QoS stuff and if one day someone solves the rogue app problem, we can migrate over.
If it's so important for Android and no one else, Android can carry it out of tree.
Quoted 7 lines
This is not only important for Android. If you use suspend on a current Linux system you run the risk of loosing wakeup events. If you have wakeup events that you cannot afford to lose your only option is to never suspend. On some hardware (e.g. x86) the cost of not suspending is always huge, on other hardware (many ARM SOCs) the cost is only huge if your apps behave poorly.
So here is my suggestion.
Rather than trying to push a feature that is clearly meeting lots of resistance, the Android devs should state the problem as a bug that needs fixing. As you have.
Upstream is a lot more receptive of fixing bugs than adding features.In this case the bug is that you cannot suspend without the risk of losing wakeup events. This is a real bug that for your use case is a serious bug. I've toyed with several ways of fixing this but the one that seems most promising is to note that in the kernel the suspend process is two-stage with a 'prepare' followed by a 'suspend'. Userspace cannot make that distinction and so ends up with a race.
Maybe userspace should be able to say "prepare to suspend" with the meaning that after a successful return, any event which would cause a wakeup sets a flag so that the final suspend returns immediately (without actually going to the lower power state).
Then your opportunistic suspend could be entirely in userspace where you wouldn't have to fight with the kernel crowd :-)
The suspend-daemon would:
Wait for all user-space suspend blocks to be dropped.
Tell the kernel to "prepare to suspend".
Tell all userspace programs which have registered for the message that they should prepare to suspend. They have the opportunity at this point to take out a new suspend block if they notice an event that has just arrived
Wait for all those programs to acknowledge
If there are no new suspend blocks, tell the kernel to suspend else tell the kernel to abort the suspend.Quoted 8 lines
Quoted 3 lines
This (I think) allows race-free opportunistic suspend in user-space where you can do all the accounting you need.
Perhaps, but it forces all user space programs that get events from the kernel to also receive messages from the suspend-daemon, check for other events again, then respond to the suspend-daemon. The current suspend blocker interface is easier to use.
Maybe so. There are quite possibly better ways to fix the bug. There are a variety of different tradeoffs possible and I suspect we could have fun arguing about those. My main point though is that if we focus on a bug that needs to be fixed, we should be able to keep the conversation more focussed. Currently it seems to be branching all over the place which doesn't seem very helpful.
Quoted 6 lines
I don't see how your suggestion avoids races for events that pass trough several kernel layers though. If a wakeup event happened before the "prepare to suspend" call but has not yet been passed to user-space, the user-space program that needs this event will not know that it needs to block suspend when it gets the prepare-to-suspend message.
Each layer must understand that the event is a wake-up event, and the "prepare to suspend call" to each layer should drive all pending events through to the next layer. If the layers (drivers) are prepared in the "right" order, this will force the event all the way to user-space. If they are called in exactly the "Wrong" order, this will require multiple prepare/suspend/instant-resume cycles to get the event through, but I suspect that this would very rarely result in truly pathological behaviour.
I'm guessing your current code (sorry, I haven't looked at all) already tracks events up through multiple layers so they can interact with a pending opporunistic-suspend request. I suspect that aspect of the code isn't particularly controversial.
Keep that, and use it precisely to implement a race-free "suspend" request from user-space.Quoted 20 lines
Quoted 19 lines
I don't fully understand your requirements for accounting of devices drivers rejecting or blocking a suspend, so I cannot say precisely how that would fit in. Maybe you just need to know - whenever the 'suspend request' completes - what the wakeup events were. It shouldn't be too hard to export that to user-space via sysfs.
I won't propose an exact enhancement to the user-space interface for requesting a suspend, but I suspect it should expose each of
suspend_prepare
suspend_devices_and_enter
suspend_finish
(or close analogues there-of) to user-space. It is tempting to map those to "open-for-write", "write", "close", but I'm not sure thatsuspend_preparewould be appropriate if the app was about to write "disk" - it is a pity that both suspend and hibernate use the same sysfs file.So just fix the bug, and everyone will be happy :-)
Quoted 9 lines
Quoted 2 lines
I already have, but everyone do not appear to be happy.
I don't think you have. You have proposed a significant new feature: a suspend-as-soon-as-you-can request which *user*space*can*block*. People don't like that because it seems like a poor second cousin to something that would be really useful (user-space setting more general latency requirements).
The ability to block the suspend request is necessary to avoid races with wakeup events.
Quoted 3 lines
I am suggesting that you stick with the feature we have, which is that user-space can request a suspend and the kernel/hardware can cause a subsequent (possibly immediate) resume in response to a wake-up event.
Since not all wakeup events propagate to user-space it is very useful to allow the kernel to reenter suspend when there are no active suspend blockers remaining.
Quoted 6 lines
Argue that the current definition of "wake-up event" is too weak and does not allow the feature to be used safely. Present an implementation (I suspect you have most of it already) where a wake-up event is tracked all the way from the hardware to user-space and is still a 'wake-up event' until userspace actually consumes it.
Quoted 7 lines
Then user-space simply has to:
poll for event to be ready
request suspend-block in user-space
consume event
handle event
release suspend-block
loop
This you copy this from the example in the documentation file added by this patch? This is exactly what we do for input events, but for this to work the kernel also has to block suspend while an event is ready but not consumed.
Quoted 3 lines
No change to API. No new concepts. Simply a bug and a direct fix.
I don't know how you got to that conclusion.
Quoted 7 lines
You probably want the "suspend" request to block until there are no pending events (and then immediately fail if there were) so that there is no risk of the suspend-daemon spinning asking of a suspend which appears to resume immediately (until some other process sees an event and blocks suspend.
NeilBrown
Signature · 1 line
Arve Hjønnevåg
Re: Just fix the bug - Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Arve HjønnevågHi!
Quoted 16 lines
Quoted 16 lines
I don't fully understand your requirements for accounting of devices drivers rejecting or blocking a suspend, so I cannot say precisely how that would fit in. Maybe you just need to know - whenever the 'suspend request' completes - what the wakeup events were. It shouldn't be too hard to export that to user-space via sysfs.
I won't propose an exact enhancement to the user-space interface for requesting a suspend, but I suspect it should expose each of
suspend_prepare
suspend_devices_and_enter
suspend_finish
(or close analogues there-of) to user-space. It is tempting to map those to "open-for-write", "write", "close", but I'm not sure thatsuspend_preparewould be appropriate if the app was about to write "disk" - it is a pity that both suspend and hibernate use the same sysfs file.
Quoted 4 lines
Quoted 2 lines
So just fix the bug, and everyone will be happy :-)
I already have, but everyone do not appear to be happy.
Half of the code you submitted was infrastructure for debugging userspace. Sorry, that does not count as a bugfix.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: Just fix the bug - Re: [PATCH 1/8] PM: Opportunistic suspend support.
Quoted 18 lines · On Fri, 28 May 2010 15:35:16 +0200 Pavel Machek <[email protected]> wrote:
Hi!
Quoted 16 lines
Quoted 16 lines
I don't fully understand your requirements for accounting of devices drivers rejecting or blocking a suspend, so I cannot say precisely how that would fit in. Maybe you just need to know - whenever the 'suspend request' completes - what the wakeup events were. It shouldn't be too hard to export that to user-space via sysfs.
I won't propose an exact enhancement to the user-space interface for requesting a suspend, but I suspect it should expose each of
suspend_prepare
suspend_devices_and_enter
suspend_finish
(or close analogues there-of) to user-space. It is tempting to map those to "open-for-write", "write", "close", but I'm not sure thatsuspend_preparewould be appropriate if the app was about to write "disk" - it is a pity that both suspend and hibernate use the same sysfs file.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
So just fix the bug, and everyone will be happy :-)
I already have, but everyone do not appear to be happy.
Half of the code you submitted was infrastructure for debugging userspace. Sorry, that does not count as a bugfix.
That is not the issue here.
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Thomas GleixnerQuoted 41 lines · Thomas Gleixner
Quoted 40 lines · James Bottomley
Quoted 17 lines · Peter Zijlstra
Quoted 16 lines · Pavel Machek
Quoted 15 lines · Peter Zijlstra
Quoted 10 lines · James Bottomley
Quoted 2 lines
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
It's a fairly large piece of code to try to rewrite in C, so I don't think that's feasible on a reasonable timescale. Android does have the concept of special sockets that can be used to communicate from less to more privileged processes (it has a very segmented runtime model), so these might be usable ... they have a drawback that they're essentially named pipes, so no multiplexing, but one per suspend influencing C process shouldn't be a huge burden.
It wouldn't need to convert the whole Frameworks layer into C, just enough to manage the suspend state.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Anyway, I think there's been enough arguments against even the concept of opportunistic/auto-suspend, and I for one will object with a NAK if Rafael send this to Linus.
It was submitted already. I tried to followup with NAK, but can't currently see it in the archive.
You mean this one:
https://lists.linux-foundation.org/pipermail/linux-pm/2010-May/025689.html
?
Quoted 1 line
It was apparently hidden on some funky list.
Sending a PM pull request to the PM list doesn't really strike me as the height of obfuscation. Plus almost everyone who objected was on the cc list.
Quoted 2 lines
Hiding pull requests is bad enough, but hiding pull requests for
contended features is just plain wrong.
Quoted 6 lines
Quoted 4 lines
I don't think it's a conspiracy ... just standard operating procedure for this subsystem. I do think cc'ing lkml is good practise (having been yelled at for not doing that in the past) but it's certainly not universal practise.
At least it would be good style for a topic which is
As I said in another message, I intended to send the pull request to the LKML, but for some reason that didn't work. Perhaps that was my fault, so sorry for that, but I think the CC list contained people who had objections, so they easily could respond (adding the CC to the LKML).
Quoted 4 lines
1) contended like this one
2) pushing an intrusive feature last minute which has been merged into the pm tree barely two days ago.
It had been discussed for a month before without any serious progress, though, so I simply had to do something to make things go. :-)
Quoted 2 lines
Darn, _we_ have to deal with that forever as it sets a crappy user space ABI in stone.
Well, I don't think it's _that_ bad, although it isn't nice either.
The whole reason why it's there is because the Google people want to collect suspend blocker usage statistics, so that they can easily check how often applications block suspending. If we dropped the statistics part, the interface might be substantially simplified.
Thanks,
Rafael
Quoted 6 lines
Thanks,
tglx
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Thomas GleixnerQuoted 41 lines · Thomas Gleixner
Quoted 40 lines · James Bottomley
Quoted 17 lines · Peter Zijlstra
Quoted 16 lines · Pavel Machek
Quoted 15 lines · Peter Zijlstra
Quoted 10 lines · James Bottomley
Quoted 2 lines
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
It's a fairly large piece of code to try to rewrite in C, so I don't think that's feasible on a reasonable timescale. Android does have the concept of special sockets that can be used to communicate from less to more privileged processes (it has a very segmented runtime model), so these might be usable ... they have a drawback that they're essentially named pipes, so no multiplexing, but one per suspend influencing C process shouldn't be a huge burden.
It wouldn't need to convert the whole Frameworks layer into C, just enough to manage the suspend state.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Anyway, I think there's been enough arguments against even the concept of opportunistic/auto-suspend, and I for one will object with a NAK if Rafael send this to Linus.
It was submitted already. I tried to followup with NAK, but can't currently see it in the archive.
You mean this one:
https://lists.linux-foundation.org/pipermail/linux-pm/2010-May/025689.html
?
Quoted 1 line
It was apparently hidden on some funky list.
Sending a PM pull request to the PM list doesn't really strike me as the height of obfuscation. Plus almost everyone who objected was on the cc list.
Quoted 2 lines
Hiding pull requests is bad enough, but hiding pull requests for
contended features is just plain wrong.
Quoted 6 lines
Quoted 4 lines
I don't think it's a conspiracy ... just standard operating procedure for this subsystem. I do think cc'ing lkml is good practise (having been yelled at for not doing that in the past) but it's certainly not universal practise.
At least it would be good style for a topic which is
As I said in another message, I intended to send the pull request to the LKML, but for some reason that didn't work. Perhaps that was my fault, so sorry for that, but I think the CC list contained people who had objections, so they easily could respond (adding the CC to the LKML).
Quoted 4 lines
1) contended like this one
2) pushing an intrusive feature last minute which has been merged into the pm tree barely two days ago.
It had been discussed for a month before without any serious progress, though, so I simply had to do something to make things go. :-)
Quoted 2 lines
Darn, _we_ have to deal with that forever as it sets a crappy user space ABI in stone.
Well, I don't think it's _that_ bad, although it isn't nice either.
The whole reason why it's there is because the Google people want to collect suspend blocker usage statistics, so that they can easily check how often applications block suspending. If we dropped the statistics part, the interface might be substantially simplified.
Thanks,
Rafael
Quoted 6 lines
Thanks,
tglx
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Peter ZijlstraQuoted 21 lines · Peter Zijlstra
Quoted 20 lines · Pavel Machek
Quoted 18 lines · Peter Zijlstra
Quoted 10 lines · James Bottomley
Quoted 2 lines
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
It's a fairly large piece of code to try to rewrite in C, so I don't think that's feasible on a reasonable timescale. Android does have the concept of special sockets that can be used to communicate from less to more privileged processes (it has a very segmented runtime model), so these might be usable ... they have a drawback that they're essentially named pipes, so no multiplexing, but one per suspend influencing C process shouldn't be a huge burden.
It wouldn't need to convert the whole Frameworks layer into C, just enough to manage the suspend state.
Anyway, I think there's been enough arguments against even the concept of opportunistic/auto-suspend, and I for one will object with a NAK if Rafael send this to Linus.
Quoted 6 lines
Quoted 2 lines
It was submitted already. I tried to followup with NAK, but can't currently see it in the archive.
It was apparently hidden on some funky list. Hiding pull requests is bad enough, but hiding pull requests for contended features is just plain wrong.
It was not intentionally hidden. I think my mailer did that wrong because the CC list was too long or something like this. I surely intended to send it to the LKML, so sorry for the inconvenience.
Rafael
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Peter ZijlstraQuoted 21 lines · Peter Zijlstra
Quoted 20 lines · Pavel Machek
Quoted 18 lines · Peter Zijlstra
Quoted 10 lines · James Bottomley
Quoted 2 lines
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
It's a fairly large piece of code to try to rewrite in C, so I don't think that's feasible on a reasonable timescale. Android does have the concept of special sockets that can be used to communicate from less to more privileged processes (it has a very segmented runtime model), so these might be usable ... they have a drawback that they're essentially named pipes, so no multiplexing, but one per suspend influencing C process shouldn't be a huge burden.
It wouldn't need to convert the whole Frameworks layer into C, just enough to manage the suspend state.
Anyway, I think there's been enough arguments against even the concept of opportunistic/auto-suspend, and I for one will object with a NAK if Rafael send this to Linus.
Quoted 6 lines
Quoted 2 lines
It was submitted already. I tried to followup with NAK, but can't currently see it in the archive.
It was apparently hidden on some funky list. Hiding pull requests is bad enough, but hiding pull requests for contended features is just plain wrong.
It was not intentionally hidden. I think my mailer did that wrong because the CC list was too long or something like this. I surely intended to send it to the LKML, so sorry for the inconvenience.
Rafael
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to James BottomleyHi James,
Quoted 2 lines · Pekka Enberg
Quoted 2 lines
Yup, I don't quite get Arve's argument either. C code can interact with Java code (and vice versa) just fine in userspace.
Quoted 9 lines · James Bottomley
This is an incorrect statement. It's possible for java to call C via the JNI, even though there are quite a few gotchas that mean not just *any* C code can do it (been there, tripped over some of them, although they were all ultimately ironed out). It's very difficult for C to call directly into Java without being specially coded because it involves creating and managing a JVM (so in general, arbitrary C code can't do this). The usual way we do C -> Java is process to process via some intermediary like RPC or Corba or SOAP (or even JSON) ... which gets very messy for a mobile device.
Incorrect statement how exactly? A JVM can do mmap(), for example, just fine through FileChannel.map() so there's no need for heavy-weight RPC. Furthermore, the whole discussion is moot anyway as Android runs Dalvik which can be hacked to support whatever communication mechanism is the best choice here.
So can we drop the whole "we need to do it in kernel because Java is hard" nonsense and concentrate on real issues?
Pekka
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to James BottomleyHi James,
Quoted 2 lines · Pekka Enberg
Quoted 2 lines
Yup, I don't quite get Arve's argument either. C code can interact with Java code (and vice versa) just fine in userspace.
Quoted 9 lines · James Bottomley
This is an incorrect statement. It's possible for java to call C via the JNI, even though there are quite a few gotchas that mean not just *any* C code can do it (been there, tripped over some of them, although they were all ultimately ironed out). It's very difficult for C to call directly into Java without being specially coded because it involves creating and managing a JVM (so in general, arbitrary C code can't do this). The usual way we do C -> Java is process to process via some intermediary like RPC or Corba or SOAP (or even JSON) ... which gets very messy for a mobile device.
Incorrect statement how exactly? A JVM can do mmap(), for example, just fine through FileChannel.map() so there's no need for heavy-weight RPC. Furthermore, the whole discussion is moot anyway as Android runs Dalvik which can be hacked to support whatever communication mechanism is the best choice here.
So can we drop the whole "we need to do it in kernel because Java is hard" nonsense and concentrate on real issues?
Pekka
Re: [PATCH 1/8] PM: Opportunistic suspend support.
Quoted 18 lines · Pekka Enberg
Hi James,
Quoted 2 lines · Pekka Enberg
Quoted 2 lines
Yup, I don't quite get Arve's argument either. C code can interact with Java code (and vice versa) just fine in userspace.
Quoted 9 lines · James Bottomley
This is an incorrect statement. It's possible for java to call C via the JNI, even though there are quite a few gotchas that mean not just *any* C code can do it (been there, tripped over some of them, although they were all ultimately ironed out). It's very difficult for C to call directly into Java without being specially coded because it involves creating and managing a JVM (so in general, arbitrary C code can't do this). The usual way we do C -> Java is process to process via some intermediary like RPC or Corba or SOAP (or even JSON) ... which gets very messy for a mobile device.
Quoted 3 lines
Incorrect statement how exactly? A JVM can do
mmap(), for example, just fine throughFileChannel.map()so there's no need for heavy-weight RPC.
Incorrect in that an arbitrary C application can't link to a java API. mmap and some other messaging (like signals) is just another form of IPC ... the list I gave wasn't exhaustive.
Quoted 6 lines
Furthermore, the whole discussion is moot anyway as
Android runs Dalvik which can be hacked to support whatever communication mechanism is the best choice here.So can we drop the whole "we need to do it in kernel because Java is hard" nonsense and concentrate on real issues?
I've lost you. This argument seems to hinge on whether or not you believe that suspend in any form is a solution to the rogue app problem ... whether it's implemented in Java or C is an ancillary issue.
James
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Pekka EnbergQuoted 18 lines · Pekka Enberg
Hi James,
Quoted 2 lines · Pekka Enberg
Quoted 2 lines
Yup, I don't quite get Arve's argument either. C code can interact with Java code (and vice versa) just fine in userspace.
Quoted 9 lines · James Bottomley
This is an incorrect statement. It's possible for java to call C via the JNI, even though there are quite a few gotchas that mean not just *any* C code can do it (been there, tripped over some of them, although they were all ultimately ironed out). It's very difficult for C to call directly into Java without being specially coded because it involves creating and managing a JVM (so in general, arbitrary C code can't do this). The usual way we do C -> Java is process to process via some intermediary like RPC or Corba or SOAP (or even JSON) ... which gets very messy for a mobile device.
Quoted 3 lines
Incorrect statement how exactly? A JVM can do
mmap(), for example, just fine throughFileChannel.map()so there's no need for heavy-weight RPC.
Incorrect in that an arbitrary C application can't link to a java API. mmap and some other messaging (like signals) is just another form of IPC ... the list I gave wasn't exhaustive.
Quoted 6 lines
Furthermore, the whole discussion is moot anyway as
Android runs Dalvik which can be hacked to support whatever communication mechanism is the best choice here.So can we drop the whole "we need to do it in kernel because Java is hard" nonsense and concentrate on real issues?
I've lost you. This argument seems to hinge on whether or not you believe that suspend in any form is a solution to the rogue app problem ... whether it's implemented in Java or C is an ancillary issue.
James
Re: [PATCH 1/8] PM: Opportunistic suspend support.
Quoted 16 lines · James Bottomley
Quoted 16 lines · Pekka Enberg
Quoted 2 lines
Quoted 2 lines
Yup, I don't quite get Arve's argument either. C code can interact with Java code (and vice versa) just fine in userspace.
Quoted 9 lines · James Bottomley
This is an incorrect statement. It's possible for java to call C via the JNI, even though there are quite a few gotchas that mean not just *any* C code can do it (been there, tripped over some of them, although they were all ultimately ironed out). It's very difficult for C to call directly into Java without being specially coded because it involves creating and managing a JVM (so in general, arbitrary C code can't do this). The usual way we do C -> Java is process to process via some intermediary like RPC or Corba or SOAP (or even JSON) ... which gets very messy for a mobile device.
Quoted 5 lines
Quoted 3 lines
Incorrect statement how exactly? A JVM can do
mmap(), for example, just fine throughFileChannel.map()so there's no need for heavy-weight RPC.Incorrect in that an arbitrary C application can't link to a java API.
Dunno what you mean by "arbitrary" C application but yes, I do agree that using JNI is somewhat cumbersome. Not sure if that's relevant, though, as it can all be hidden in the framework APIs.
Quoted 2 lines
mmap and some other messaging (like signals) is just another form of IPC ... the list I gave wasn't exhaustive.
The protocols you mentioned are meant for RPC (as in remote) and messaging, not for IPC which I'm assume is needed for the suspend manager process Peter is talking about.
Quoted 10 lines
Quoted 6 lines
Furthermore, the whole discussion is moot anyway as Android runs Dalvik which can be hacked to support whatever communication mechanism is the best choice here.
So can we drop the whole "we need to do it in kernel because Java is hard" nonsense and concentrate on real issues?
I've lost you. This argument seems to hinge on whether or not you believe that suspend in any form is a solution to the rogue app problem ... whether it's implemented in Java or C is an ancillary issue.
I'm responding to the original argument from Arve that C programs can't use the existing suspend manager because it's written in Java.
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to James BottomleyQuoted 16 lines · James Bottomley
Quoted 16 lines · Pekka Enberg
Quoted 2 lines
Quoted 2 lines
Yup, I don't quite get Arve's argument either. C code can interact with Java code (and vice versa) just fine in userspace.
Quoted 9 lines · James Bottomley
This is an incorrect statement. It's possible for java to call C via the JNI, even though there are quite a few gotchas that mean not just *any* C code can do it (been there, tripped over some of them, although they were all ultimately ironed out). It's very difficult for C to call directly into Java without being specially coded because it involves creating and managing a JVM (so in general, arbitrary C code can't do this). The usual way we do C -> Java is process to process via some intermediary like RPC or Corba or SOAP (or even JSON) ... which gets very messy for a mobile device.
Quoted 5 lines
Quoted 3 lines
Incorrect statement how exactly? A JVM can do
mmap(), for example, just fine throughFileChannel.map()so there's no need for heavy-weight RPC.Incorrect in that an arbitrary C application can't link to a java API.
Dunno what you mean by "arbitrary" C application but yes, I do agree that using JNI is somewhat cumbersome. Not sure if that's relevant, though, as it can all be hidden in the framework APIs.
Quoted 2 lines
mmap and some other messaging (like signals) is just another form of IPC ... the list I gave wasn't exhaustive.
The protocols you mentioned are meant for RPC (as in remote) and messaging, not for IPC which I'm assume is needed for the suspend manager process Peter is talking about.
Quoted 10 lines
Quoted 6 lines
Furthermore, the whole discussion is moot anyway as Android runs Dalvik which can be hacked to support whatever communication mechanism is the best choice here.
So can we drop the whole "we need to do it in kernel because Java is hard" nonsense and concentrate on real issues?
I've lost you. This argument seems to hinge on whether or not you believe that suspend in any form is a solution to the rogue app problem ... whether it's implemented in Java or C is an ancillary issue.
I'm responding to the original argument from Arve that C programs can't use the existing suspend manager because it's written in Java.
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Peter Zijlstra2010/5/26 Peter Zijlstra <[email protected]>:
Quoted 5 lines · Arve Hjønnevåg
Quoted 4 lines
Quoted 3 lines
With a single suspend manager process that manages the suspend state you can achieve the same goal.
Quoted 8 lines
Quoted 5 lines
Yes we don't need the /dev interface, but it is useful. Without it any program that needs to block suspend has to make a blocking ipc call into the suspend manager process. Android already does this for java code, but system processes written in C block suspend directly with the kernel since they cannot use the java APIs.
So provide a C interface to it as well?
We could, but the result would be that any program that needs to block suspend has to be android specific.
Quoted 6 lines
Surely you can have the java thing have a unix socket or something a C app can talk to. That shouldn't be hard at all.
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
Signature · 1 line
Arve Hjønnevåg
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Peter Zijlstra2010/5/26 Peter Zijlstra <[email protected]>:
Quoted 5 lines · Arve Hjønnevåg
Quoted 4 lines
Quoted 3 lines
With a single suspend manager process that manages the suspend state you can achieve the same goal.
Quoted 8 lines
Quoted 5 lines
Yes we don't need the /dev interface, but it is useful. Without it any program that needs to block suspend has to make a blocking ipc call into the suspend manager process. Android already does this for java code, but system processes written in C block suspend directly with the kernel since they cannot use the java APIs.
So provide a C interface to it as well?
We could, but the result would be that any program that needs to block suspend has to be android specific.
Quoted 6 lines
Surely you can have the java thing have a unix socket or something a C app can talk to. That shouldn't be hard at all.
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
Signature · 1 line
Arve Hjønnevåg
Re: [PATCH 1/8] PM: Opportunistic suspend support.
2010/5/26 Arve Hjønnevåg <[email protected]>:
Quoted 4 lines
Quoted 1 line
So provide a C interface to it as well?
We could, but the result would be that any program that needs to block suspend has to be android specific.
Why? You could put the userspace daemon to tools/suspend-manager, for example?
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Arve Hjønnevåg2010/5/26 Arve Hjønnevåg <[email protected]>:
Quoted 4 lines
Quoted 1 line
So provide a C interface to it as well?
We could, but the result would be that any program that needs to block suspend has to be android specific.
Why? You could put the userspace daemon to tools/suspend-manager, for example?
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Arve Hjønnevåg2010/5/26 Arve Hjønnevåg <[email protected]>:
Quoted 12 lines
2010/5/26 Peter Zijlstra <[email protected]>:
Quoted 11 lines · Arve Hjønnevåg
Quoted 9 lines
Quoted 3 lines
With a single suspend manager process that manages the suspend state you can achieve the same goal.
Yes we don't need the /dev interface, but it is useful. Without it any program that needs to block suspend has to make a blocking ipc call into the suspend manager process. Android already does this for java code, but system processes written in C block suspend directly with the kernel since they cannot use the java APIs.
Quoted 5 lines
Quoted 2 lines
So provide a C interface to it as well?
We could, but the result would be that any program that needs to block suspend has to be android specific.
Just a suspicion, but... The things you're saying don't make sense to me other than if you're fighting with GPL in userspace here.
~Vitaly
Re: [linux-pm] [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Arve Hjønnevåg2010/5/26 Arve Hjønnevåg <[email protected]>:
Quoted 12 lines
2010/5/26 Peter Zijlstra <[email protected]>:
Quoted 11 lines · Arve Hjønnevåg
Quoted 9 lines
Quoted 3 lines
With a single suspend manager process that manages the suspend state you can achieve the same goal.
Yes we don't need the /dev interface, but it is useful. Without it any program that needs to block suspend has to make a blocking ipc call into the suspend manager process. Android already does this for java code, but system processes written in C block suspend directly with the kernel since they cannot use the java APIs.
Quoted 5 lines
Quoted 2 lines
So provide a C interface to it as well?
We could, but the result would be that any program that needs to block suspend has to be android specific.
Just a suspicion, but... The things you're saying don't make sense to me other than if you're fighting with GPL in userspace here.
~Vitaly
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Peter Zijlstra2010/5/26 Peter Zijlstra <[email protected]>:
Quoted 11 lines · Arve Hjønnevåg
Quoted 9 lines
Quoted 3 lines
With a single suspend manager process that manages the suspend state you can achieve the same goal.
Yes we don't need the /dev interface, but it is useful. Without it any program that needs to block suspend has to make a blocking ipc call into the suspend manager process. Android already does this for java code, but system processes written in C block suspend directly with the kernel since they cannot use the java APIs.
Quoted 7 lines
So provide a C interface to it as well?
Surely you can have the java thing have a unix socket or something a C app can talk to. That shouldn't be hard at all.
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
Android already has D-Bus:
http://android.git.kernel.org/?p=platform/external/dbus.git;a=summary
Which has Java bindings:
http://dbus.freedesktop.org/doc/dbus-java/
D-Bus can be from C to send messages to the Java daemon. So why not use that if this seems to be a problem. It even brings serialized typing and all that funny stuff.
Yours,
Linus Walleij
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Peter ZijlstraQuoted 11 lines · On Wed, 26 May 2010 12:21:02 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 9 lines · Arve Hjønnevåg
Quoted 3 lines
With a single suspend manager process that manages the suspend state you can achieve the same goal.
Yes we don't need the /dev interface, but it is useful. Without it any program that needs to block suspend has to make a blocking ipc call into the suspend manager process. Android already does this for java code, but system processes written in C block suspend directly with the kernel since they cannot use the java APIs.
Quoted 7 lines
So provide a C interface to it as well?
Surely you can have the java thing have a unix socket or something a C app can talk to. That shouldn't be hard at all.
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
I fail to understand the modern fascination with complex IPC mechanisms.
If you have a userspace process that initiates suspends, and you want other user-space processes to be able to block that suspend, then I would suggest the use of a lock-file. /var/run/suspend/blocked maybe.
To block suspend, you open the file and get a read lock.
To initiate a suspend you take a write-lock (blocking if necessary), then ask the kernel to suspend.
To restrict access to particular users you use permissions - either group based or ACLs (or both).
This is all easy to do from C or python or perl or presumably even java.. (I use this mechanism on my Freerunner and even have shell scripts that happily prevent suspend).
NeilBrown
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Peter ZijlstraQuoted 11 lines · On Wed, 26 May 2010 12:21:02 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 9 lines · Arve Hjønnevåg
Quoted 3 lines
With a single suspend manager process that manages the suspend state you can achieve the same goal.
Yes we don't need the /dev interface, but it is useful. Without it any program that needs to block suspend has to make a blocking ipc call into the suspend manager process. Android already does this for java code, but system processes written in C block suspend directly with the kernel since they cannot use the java APIs.
Quoted 7 lines
So provide a C interface to it as well?
Surely you can have the java thing have a unix socket or something a C app can talk to. That shouldn't be hard at all.
Or make the suspend manager a C proglet and provide a JNI interface, or whatever.
I fail to understand the modern fascination with complex IPC mechanisms.
If you have a userspace process that initiates suspends, and you want other user-space processes to be able to block that suspend, then I would suggest the use of a lock-file. /var/run/suspend/blocked maybe.
To block suspend, you open the file and get a read lock.
To initiate a suspend you take a write-lock (blocking if necessary), then ask the kernel to suspend.
To restrict access to particular users you use permissions - either group based or ACLs (or both).
This is all easy to do from C or python or perl or presumably even java.. (I use this mechanism on my Freerunner and even have shell scripts that happily prevent suspend).
NeilBrown
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Rafael J. WysockiQuoted 6 lines · Rafael J. Wysocki
No, I don't really think it's going to be a small change. The problem is that for the Android people changing user space is very hard, so I don't think this realy is an option, given that they would have to implement it themselves, test it, validate it on multiple different hardware platforms etc. and _then_ resubmit the feature without any guarantee that it will be merged.
So your position is basically that we're going to merge this stuff because google doesn't want to expend effort into investigating a potential saner solution?
So why don't we simply merge all the crap people throw at us and be done with it.
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Rafael J. WysockiQuoted 6 lines · Rafael J. Wysocki
No, I don't really think it's going to be a small change. The problem is that for the Android people changing user space is very hard, so I don't think this realy is an option, given that they would have to implement it themselves, test it, validate it on multiple different hardware platforms etc. and _then_ resubmit the feature without any guarantee that it will be merged.
So your position is basically that we're going to merge this stuff because google doesn't want to expend effort into investigating a potential saner solution?
So why don't we simply merge all the crap people throw at us and be done with it.
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Alan SternQuoted 48 lines · Alan Stern
Quoted 1 line · Rafael J. Wysocki
So, basically, you'd prefer to move the entire complexity to user space.
No, just the complexity of the userspace suspend blockers. That was one of the parts of the interface that people objected to, after all.
Quoted 1 line
I'm not sure if that's a big win
It's not a _big_ win, but it is an improvement IMO.
Quoted 3 lines
and I'm not sure anyone is actually going to
implement it (and some drivers would still have to be modified to participate in this framework).Of course drivers have to be modified. The kernel-layer suspend blockers aren't affected by this proposal, so they still have to be implemented.
Quoted 3 lines
So again, we have a hunch that the goal may be achieved
in a different way, but at this point we'd rather need a _working_ _solution_ (in the form of code one can build and actually use).It's not very different from what has been submitted, and I think there's little doubt that it could be built and used fairly easily. All we're talking about is removing the userspace suspend-blocker API and the opportunistic workqueue, replacing them with an "opportunistic" entry in
/sys/power/state, and setting up a userspace power manager process.Quoted 3 lines
I don't think it's realistic to expect the Android people to go and redesign their stuff along the lines you've described, because they have a working implementation (in the kernel) that they are satisfied with.
The redesign would be pretty small. The kernel changes relative to what they have submitted are minimal, mostly just removing a few of their additions. Furthermore, we've been told that Android _already_ funnels all its userspace suspend-blocker work through a single process. All that would be needed would be to make that process initiate an opportunistic suspend whenever no userspace suspend blockers were active.
Quoted 6 lines
Now, we can reject their patches, but that's not going to cause any progress to happen, realistically. Quite on the contrary, Android will continue to use wakelocks and Android driver writers will continue to ignore the mainline and the gap between the two kernel lines will only get wider and wider over time.
Quoted 8 lines
Quoted 2 lines
And what really is the drawback if we merge the patches? Quite frankly, I don't see any.
You don't seem to appreciate how small a change Dmitry has proposed. Almost all of the suspend-blocker work would remain as in the submitted patches. The only difference is that the userspace API and opportunistic-suspend implementation would be simplified, by moving some of the work out of the kernel.
No, I don't really think it's going to be a small change. The problem is that for the Android people changing user space is very hard, so I don't think this realy is an option, given that they would have to implement it themselves, test it, validate it on multiple different hardware platforms etc. and _then_ resubmit the feature without any guarantee that it will be merged.
So, my opinion is that we only have a choice to either take the feature as is now, or reject it altogether and live with the consequeces in each case. And quite frankly I don't feel like I'm in position to make that decision.
Thanks,
Rafael
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Rafael J. WysockiQuoted 60 lines · Rafael J. Wysocki
Quoted 59 lines · Dmitry Torokhov
Quoted 57 lines · Rafael J. Wysocki
Quoted 43 lines · Dmitry Torokhov
Quoted 32 lines · Alan Stern
Quoted 10 lines · Dmitry Torokhov
Quoted 9 lines
Quoted 2 lines
I don't see a big difference between 2 and 3. You can use suspend blockers to handle either.
You can, but they aren't necessary. If 2 were the only reason for suspend blockers, I would say they shouldn't be merged.
Whereas 3, on the other hand, can _not_ be handled by any existing mechanism. 3 is perhaps the most important reason for using suspend blockers.
Quoted 5 lines
I do not see why 3 has to be implemented using suspend blockers either. If you are concerned that event gets stuck somewhere in the stack make sure that devices in the stack do not suspend while their queue is not empty. This way if you try opportunistic suspend it will keep failing until you drained all important queues.
Here's the scenario:
The system is awake, and the user presses a key. The keyboard driver processes the keystroke and puts it in an input queue. A user process reads it from the event queue, thereby emptying the queue.
At that moment, the system decides to go into opportunistic suspend. Since the input queue is empty, there's nothing to stop it. As the first step, userspace is frozen -- before the process has a chance to do anything with the keystroke it just read. As a result, the system stays asleep until something else wakes it up, even though the keystroke was important and should have prevented it from sleeping.
Suspend blockers protect against this scenario. Here's how:
Quoted 9 lines
The user process doesn't read the input queue directly; instead it does a select or poll. When it sees there is data in the queue, it first acquires a suspend blocker and then reads the data.
Now the system _can't_ go into opportunistic suspend, because a suspend blocker is active. The user process can do whatever it wants with the keystroke. When it is finished, it releases the suspend blocker and loops back to the select/poll call.
Quoted 6 lines
What you describe can be done in userspace though, via a "suspend manager" process. Tasks reading input events will post "busy" events to stop the manager process from sending system into suspend. But this can be confined to Android userspace, leaving the kernel as is (well, kernel needs to be modified to not go into suspend with full queues, but that is using existing kernel APIs).
For that to work, you'd have to make the user space suspend manager prevent key-reading processes from emptying the queue before it orders the kernel to put the system to sleep. Otherwise it still is possible that the queue will be emptied right at the moment it writes to
/sys/power/stateand the scenario described by Alan is going to happen.
Quoted 6 lines
Quoted 4 lines
You do exactly the same as what Alan done, but in userspace - poll, post "busy" event to suspend manager, read, process, retract "busy". Basically you still have the suspend blocker, but it is confined to your userspace.
OK, now the question is why this is actually better.
A couple things come to mind...
1. Fixes problems for *all* kernel users, not just Android.
The kernel changes (refuse to suspend) would be done in a way that would fix problems in the traditional suspend path as well as the opportunistic suspend path, thus benefiting everyone.
2. Keep policy out of the kernel
A userspace suspend manager could implement _policy_ decisions in a platform specific way, rather than having policy hard-coded into the kernel.
Keeping the policy/governor in userspace would also allow various governor techniques to be experimented with (polling/timeout intervals, etc.) without having to patch the kernel.
Kevin
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Rafael J. WysockiQuoted 60 lines · Rafael J. Wysocki
Quoted 59 lines · Dmitry Torokhov
Quoted 57 lines · Rafael J. Wysocki
Quoted 43 lines · Dmitry Torokhov
Quoted 32 lines · Alan Stern
Quoted 10 lines · Dmitry Torokhov
Quoted 9 lines
Quoted 2 lines
I don't see a big difference between 2 and 3. You can use suspend blockers to handle either.
You can, but they aren't necessary. If 2 were the only reason for suspend blockers, I would say they shouldn't be merged.
Whereas 3, on the other hand, can _not_ be handled by any existing mechanism. 3 is perhaps the most important reason for using suspend blockers.
Quoted 5 lines
I do not see why 3 has to be implemented using suspend blockers either. If you are concerned that event gets stuck somewhere in the stack make sure that devices in the stack do not suspend while their queue is not empty. This way if you try opportunistic suspend it will keep failing until you drained all important queues.
Here's the scenario:
The system is awake, and the user presses a key. The keyboard driver processes the keystroke and puts it in an input queue. A user process reads it from the event queue, thereby emptying the queue.
At that moment, the system decides to go into opportunistic suspend. Since the input queue is empty, there's nothing to stop it. As the first step, userspace is frozen -- before the process has a chance to do anything with the keystroke it just read. As a result, the system stays asleep until something else wakes it up, even though the keystroke was important and should have prevented it from sleeping.
Suspend blockers protect against this scenario. Here's how:
Quoted 9 lines
The user process doesn't read the input queue directly; instead it does a select or poll. When it sees there is data in the queue, it first acquires a suspend blocker and then reads the data.
Now the system _can't_ go into opportunistic suspend, because a suspend blocker is active. The user process can do whatever it wants with the keystroke. When it is finished, it releases the suspend blocker and loops back to the select/poll call.
Quoted 6 lines
What you describe can be done in userspace though, via a "suspend manager" process. Tasks reading input events will post "busy" events to stop the manager process from sending system into suspend. But this can be confined to Android userspace, leaving the kernel as is (well, kernel needs to be modified to not go into suspend with full queues, but that is using existing kernel APIs).
For that to work, you'd have to make the user space suspend manager prevent key-reading processes from emptying the queue before it orders the kernel to put the system to sleep. Otherwise it still is possible that the queue will be emptied right at the moment it writes to
/sys/power/stateand the scenario described by Alan is going to happen.
Quoted 6 lines
Quoted 4 lines
You do exactly the same as what Alan done, but in userspace - poll, post "busy" event to suspend manager, read, process, retract "busy". Basically you still have the suspend blocker, but it is confined to your userspace.
OK, now the question is why this is actually better.
A couple things come to mind...
1. Fixes problems for *all* kernel users, not just Android.
The kernel changes (refuse to suspend) would be done in a way that would fix problems in the traditional suspend path as well as the opportunistic suspend path, thus benefiting everyone.
2. Keep policy out of the kernel
A userspace suspend manager could implement _policy_ decisions in a platform specific way, rather than having policy hard-coded into the kernel.
Keeping the policy/governor in userspace would also allow various governor techniques to be experimented with (polling/timeout intervals, etc.) without having to patch the kernel.
Kevin
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Rafael J. WysockiQuoted 9 lines · Rafael J. Wysocki
Now, we can reject their patches, but that's not going to cause any progress to happen, realistically. Quite on the contrary, Android will continue to use wakelocks and Android driver writers will continue to ignore the mainline and the gap between the two kernel lines will only get wider and wider over time.
And what really is the drawback if we merge the patches? Quite frankly, I don't see any.
A funny userspace API of questionable use (esp. with the advent of better hardware and better runtime PM support) which we will have to support forever seems like a big enough downside.
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Rafael J. WysockiQuoted 9 lines · Rafael J. Wysocki
Now, we can reject their patches, but that's not going to cause any progress to happen, realistically. Quite on the contrary, Android will continue to use wakelocks and Android driver writers will continue to ignore the mainline and the gap between the two kernel lines will only get wider and wider over time.
And what really is the drawback if we merge the patches? Quite frankly, I don't see any.
A funny userspace API of questionable use (esp. with the advent of better hardware and better runtime PM support) which we will have to support forever seems like a big enough downside.
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Dmitry TorokhovQuoted 59 lines · Dmitry Torokhov
Quoted 51 lines · Rafael J. Wysocki
Quoted 43 lines · Dmitry Torokhov
Quoted 32 lines · Alan Stern
Quoted 10 lines · Dmitry Torokhov
Quoted 9 lines
Quoted 2 lines
I don't see a big difference between 2 and 3. You can use suspend blockers to handle either.
You can, but they aren't necessary. If 2 were the only reason for suspend blockers, I would say they shouldn't be merged.
Whereas 3, on the other hand, can _not_ be handled by any existing mechanism. 3 is perhaps the most important reason for using suspend blockers.
Quoted 5 lines
I do not see why 3 has to be implemented using suspend blockers either. If you are concerned that event gets stuck somewhere in the stack make sure that devices in the stack do not suspend while their queue is not empty. This way if you try opportunistic suspend it will keep failing until you drained all important queues.
Here's the scenario:
The system is awake, and the user presses a key. The keyboard driver processes the keystroke and puts it in an input queue. A user process reads it from the event queue, thereby emptying the queue.
At that moment, the system decides to go into opportunistic suspend. Since the input queue is empty, there's nothing to stop it. As the first step, userspace is frozen -- before the process has a chance to do anything with the keystroke it just read. As a result, the system stays asleep until something else wakes it up, even though the keystroke was important and should have prevented it from sleeping.
Suspend blockers protect against this scenario. Here's how:
Quoted 9 lines
The user process doesn't read the input queue directly; instead it does a select or poll. When it sees there is data in the queue, it first acquires a suspend blocker and then reads the data.
Now the system _can't_ go into opportunistic suspend, because a suspend blocker is active. The user process can do whatever it wants with the keystroke. When it is finished, it releases the suspend blocker and loops back to the select/poll call.
Quoted 6 lines
What you describe can be done in userspace though, via a "suspend manager" process. Tasks reading input events will post "busy" events to stop the manager process from sending system into suspend. But this can be confined to Android userspace, leaving the kernel as is (well, kernel needs to be modified to not go into suspend with full queues, but that is using existing kernel APIs).
Quoted 6 lines
For that to work, you'd have to make the user space suspend manager prevent key-reading processes from emptying the queue before it orders the kernel to put the system to sleep. Otherwise it still is possible that the queue will be emptied right at the moment it writes to
/sys/power/stateand the scenario described by Alan is going to happen.
Quoted 4 lines
You do exactly the same as what Alan done, but in userspace - poll, post "busy" event to suspend manager, read, process, retract "busy". Basically you still have the suspend blocker, but it is confined to your userspace.
OK, now the question is why this is actually better.
Quoted 6 lines
Quoted 3 lines
Moreover, I don't think it's limited to the input subsystem, because the wakeup events may originate from the network or some other sources and all of them would require similar handling.
Yes, all devices (real or virtual), not only input ones, holding the queues have to refuse suspending for this to work.
So, basically, you'd prefer to move the entire complexity to user space. I'm not sure if that's a big win and I'm not sure anyone is actually going to implement it (and some drivers would still have to be modified to participate in this framework). So again, we have a hunch that the goal may be achieved in a different way, but at this point we'd rather need a _working_ _solution_ (in the form of code one can build and actually use).
I don't think it's realistic to expect the Android people to go and redesign their stuff along the lines you've described, because they have a working implementation (in the kernel) that they are satisfied with.
Now, we can reject their patches, but that's not going to cause any progress to happen, realistically. Quite on the contrary, Android will continue to use wakelocks and Android driver writers will continue to ignore the mainline and the gap between the two kernel lines will only get wider and wider over time.
And what really is the drawback if we merge the patches? Quite frankly, I don't see any.
Rafael
Re: [PATCH 1/8] PM: Opportunistic suspend support.
In reply to Dmitry TorokhovQuoted 43 lines · Dmitry Torokhov
Quoted 32 lines · Alan Stern
Quoted 10 lines · Dmitry Torokhov
Quoted 9 lines
Quoted 2 lines
I don't see a big difference between 2 and 3. You can use suspend blockers to handle either.
You can, but they aren't necessary. If 2 were the only reason for suspend blockers, I would say they shouldn't be merged.
Whereas 3, on the other hand, can _not_ be handled by any existing mechanism. 3 is perhaps the most important reason for using suspend blockers.
Quoted 5 lines
I do not see why 3 has to be implemented using suspend blockers either. If you are concerned that event gets stuck somewhere in the stack make sure that devices in the stack do not suspend while their queue is not empty. This way if you try opportunistic suspend it will keep failing until you drained all important queues.
Here's the scenario:
The system is awake, and the user presses a key. The keyboard driver processes the keystroke and puts it in an input queue. A user process reads it from the event queue, thereby emptying the queue.
At that moment, the system decides to go into opportunistic suspend. Since the input queue is empty, there's nothing to stop it. As the first step, userspace is frozen -- before the process has a chance to do anything with the keystroke it just read. As a result, the system stays asleep until something else wakes it up, even though the keystroke was important and should have prevented it from sleeping.
Suspend blockers protect against this scenario. Here's how:
Quoted 9 lines
The user process doesn't read the input queue directly; instead it does a select or poll. When it sees there is data in the queue, it first acquires a suspend blocker and then reads the data.
Now the system _can't_ go into opportunistic suspend, because a suspend blocker is active. The user process can do whatever it wants with the keystroke. When it is finished, it releases the suspend blocker and loops back to the select/poll call.
Quoted 6 lines
What you describe can be done in userspace though, via a "suspend manager" process. Tasks reading input events will post "busy" events to stop the manager process from sending system into suspend. But this can be confined to Android userspace, leaving the kernel as is (well, kernel needs to be modified to not go into suspend with full queues, but that is using existing kernel APIs).
For that to work, you'd have to make the user space suspend manager prevent key-reading processes from emptying the queue before it orders the kernel to put the system to sleep. Otherwise it still is possible that the queue will be emptied right at the moment it writes to /sys/power/state and the scenario described by Alan is going to happen.
Moreover, I don't think it's limited to the input subsystem, because the wakeup events may originate from the network or some other sources and all of them would require similar handling.
The problem here is that user space can't do anything to stop the freezing of tasks without suspend blockers (or something more-or-less equivalent).
Now, you can argue that in theory we can avoid that if tasks are not frozen, but quite frankly that's not a very realistic way to go.
Rafael
Quoted 4 lines · Arve Hjønnevåg
This patch series adds a suspend-block api that provides the same functionality as the android wakelock api. This version adds a delay before suspending again if no suspend blockers were used during the last suspend attempt.
Patches [1-6/8] applied to suspend-2.6/linux-next
Thanks,
Rafael
Quoted 7 lines · ext Rafael J. Wysocki
Quoted 4 lines · Arve Hjønnevåg
This patch series adds a suspend-block api that provides the same functionality as the android wakelock api. This version adds a delay before suspending again if no suspend blockers were used during the last suspend attempt.
Patches [1-6/8] applied to suspend-2.6/linux-next
funny thing is that even without sorting out the concerns plenty of developers had on the other thread, this series is still taken. What's the point in dicussing/reviewing the patches then ?
Signature · 3 lines
balbi DefectiveByDesign.org
Quoted 7 lines · Felipe Balbi
Quoted 6 lines · ext Rafael J. Wysocki
Quoted 4 lines · Arve Hjønnevåg
This patch series adds a suspend-block api that provides the same functionality as the android wakelock api. This version adds a delay before suspending again if no suspend blockers were used during the last suspend attempt.
Quoted 5 lines
Quoted 1 line
Patches [1-6/8] applied to suspend-2.6/linux-next
funny thing is that even without sorting out the concerns plenty of developers had on the other thread, this series is still taken. What's the point in dicussing/reviewing the patches then ?
I don't think the concerns you're referring to can be solved out. Some people just don't like the whole idea and I don't think there's any way we can improve the patches to make them happy. The only "solution" they would be satisfied with would simply be rejecting the feature altogether, although there are no practically viable alternatives known to me.
OTOH I do think there are quite a few reasons to take the patchset, so I'm going to push it to Linus as I told in one of my replies to Kevin. If Linus decides not to pull it, so be it.
Thanks,
Rafael
Quoted 14 lines · Rafael J. Wysocki
Quoted 7 lines · Felipe Balbi
Quoted 6 lines · ext Rafael J. Wysocki
Quoted 4 lines · Arve Hjønnevåg
This patch series adds a suspend-block api that provides the same functionality as the android wakelock api. This version adds a delay before suspending again if no suspend blockers were used during the last suspend attempt.
Quoted 5 lines
Quoted 1 line
Patches [1-6/8] applied to suspend-2.6/linux-next
funny thing is that even without sorting out the concerns plenty of developers had on the other thread, this series is still taken. What's the point in dicussing/reviewing the patches then ?
Quoted 6 lines
I don't think the concerns you're referring to can be solved out. Some people just don't like the whole idea and I don't think there's any way we can improve the patches to make them happy. The only "solution" they would be satisfied with would simply be rejecting the feature altogether, although there are no practically viable alternatives known to me.
I'm not sure who the "some people" you're referring to are, but I'll assume I'm included in that group.
I don't think this is a fair characterization of the objections, nor do I think "rejecting the feature altogether" is the only satisfactory answer. Speaking for myself, I find the idea of being able to suspend while idle a valid objective, and certainly see the usefulness of it for embedded systems. I'm also an owner and user of an Android phone, so I am certainly not out just to make life difficult for Android.
The primary objection is not the end goal, but rather the implementation. In particular, the problematic redefintion of what it means to be idle, or "not doing work that's immediately useful to the user" to use the phrase from the changelog (where "useful" is still not defined.)
This (re)definition completely bypasses all current idle infrastructure based on timers, scheduler, etc. and makes "usefulness" defined in terms of who holds suspend blockers. This of course will lead to a scattering of suspend blockers into any drivers/subsystems considered "useful", which by looking through current Android kernels is many of them.
Kevin
Quoted 33 lines · Kevin Hilman
Quoted 14 lines · Rafael J. Wysocki
Quoted 7 lines · Felipe Balbi
Quoted 6 lines · ext Rafael J. Wysocki
Quoted 4 lines · Arve Hjønnevåg
This patch series adds a suspend-block api that provides the same functionality as the android wakelock api. This version adds a delay before suspending again if no suspend blockers were used during the last suspend attempt.
Quoted 5 lines
Quoted 1 line
Patches [1-6/8] applied to suspend-2.6/linux-next
funny thing is that even without sorting out the concerns plenty of developers had on the other thread, this series is still taken. What's the point in dicussing/reviewing the patches then ?
Quoted 6 lines
I don't think the concerns you're referring to can be solved out. Some people just don't like the whole idea and I don't think there's any way we can improve the patches to make them happy. The only "solution" they would be satisfied with would simply be rejecting the feature altogether, although there are no practically viable alternatives known to me.
I'm not sure who the "some people" you're referring to are, but I'll assume I'm included in that group.
I don't think this is a fair characterization of the objections, nor do I think "rejecting the feature altogether" is the only satisfactory answer. Speaking for myself, I find the idea of being able to suspend while idle a valid objective, and certainly see the usefulness of it for embedded systems. I'm also an owner and user of an Android phone, so I am certainly not out just to make life difficult for Android.
Quoted 5 lines
The primary objection is not the end goal, but rather the implementation. In particular, the problematic redefintion of what it means to be idle, or "not doing work that's immediately useful to the user" to use the phrase from the changelog (where "useful" is still not defined.)
So, in fact, you don't like the _idea_, because the _idea_ is to use suspend blockers instead of trying to define what "idle" means.
I don't think it's generally possible to define "idle" to match every possible criteria one can imagine, so you're request to do that simply cannot be satisfied.
Quoted 3 lines
This (re)definition completely bypasses all current idle infrastructure based on timers, scheduler, etc. and makes "usefulness" defined in terms of who holds suspend blockers.
That's because the point is not to suspend when the system is "idle", because that would mean "suspend transparently from the applications' point of view", which is what the Android people _don't_ _want_ _to_ _do_, because in that case their battery life would go to the toilet. The idea is to suspend even when the system is not techincally "idle" and you don't like _that_.
Quoted 3 lines
This of course will lead to a scattering of suspend blockers into any
drivers/subsystemsconsidered "useful", which by looking through current Android kernels is many of them.
That depends on the maintainers of these subsystems, who still have the power to reject requested changes.
As I said before, I don't think there's a way to resolve this so that everyone is happy and in my opinion there are reasons to merge the feature.
Also I don't think we can make any progress discussing it. We've already discussed it for a month or so without any real progress and I don't see how that's going to change now.
Thanks,
Rafael
Quoted 6 lines · Rafael J. Wysocki
Quoted 3 lines
This of course will lead to a scattering of suspend blockers into any
drivers/subsystemsconsidered "useful", which by looking through current Android kernels is many of them.That depends on the maintainers of these subsystems, who still have the power to reject requested changes.
So as a scheduler maintainer I'm going to merge a patch that does a suspend_blocker when the runqueue's aren't empty... how about that?
Quoted 11 lines · Peter Zijlstra
Quoted 6 lines · Rafael J. Wysocki
Quoted 3 lines
This of course will lead to a scattering of suspend blockers into any
drivers/subsystemsconsidered "useful", which by looking through current Android kernels is many of them.That depends on the maintainers of these subsystems, who still have the power to reject requested changes.
So as a scheduler maintainer I'm going to merge a patch that does a
suspend_blockerwhen the runqueue's aren't empty... how about that?
I don't know if you are serious, since the all the runqueues are never empty while suspending, this would disable opportunistic suspend altogether.
Signature · 1 line
Arve Hjønnevåg
Quoted 11 lines · Peter Zijlstra
Quoted 6 lines · Rafael J. Wysocki
Quoted 3 lines
This of course will lead to a scattering of suspend blockers into any
drivers/subsystemsconsidered "useful", which by looking through current Android kernels is many of them.That depends on the maintainers of these subsystems, who still have the power to reject requested changes.
So as a scheduler maintainer I'm going to merge a patch that does a
suspend_blockerwhen the runqueue's aren't empty... how about that?
I don't know if you are serious, since the all the runqueues are never empty while suspending, this would disable opportunistic suspend altogether.
Signature · 5 lines
Arve Hjønnevåg -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Arve Hjønnevåg
Quoted 8 lines · Peter Zijlstra
Quoted 6 lines · Rafael J. Wysocki
Quoted 3 lines
This of course will lead to a scattering of suspend blockers into any
drivers/subsystemsconsidered "useful", which by looking through current Android kernels is many of them.That depends on the maintainers of these subsystems, who still have the power to reject requested changes.
Quoted 7 lines
Quoted 3 lines
So as a scheduler maintainer I'm going to merge a patch that does a
suspend_blockerwhen the runqueue's aren't empty... how about that?I don't know if you are serious, since the all the runqueues are never empty while suspending, this would disable opportunistic suspend altogether.
So why again was this such a great scheme? Go fix your userspace to not not run when not needed.
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Quoted 9 lines · Arve Hjønnevåg
Quoted 8 lines · Peter Zijlstra
Quoted 6 lines · Rafael J. Wysocki
Quoted 3 lines
This of course will lead to a scattering of suspend blockers into any
drivers/subsystemsconsidered "useful", which by looking through current Android kernels is many of them.That depends on the maintainers of these subsystems, who still have the power to reject requested changes.
Quoted 7 lines
Quoted 3 lines
So as a scheduler maintainer I'm going to merge a patch that does a
suspend_blockerwhen the runqueue's aren't empty... how about that?I don't know if you are serious, since the all the runqueues are never empty while suspending, this would disable opportunistic suspend altogether.
So why again was this such a great scheme? Go fix your userspace to not not run when not needed.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 14 lines · Peter Zijlstra
Quoted 13 lines · Arve Hjønnevåg
Quoted 11 lines · Peter Zijlstra
Quoted 6 lines · Rafael J. Wysocki
Quoted 3 lines
This of course will lead to a scattering of suspend blockers into any
drivers/subsystemsconsidered "useful", which by looking through current Android kernels is many of them.That depends on the maintainers of these subsystems, who still have the power to reject requested changes.
So as a scheduler maintainer I'm going to merge a patch that does a
suspend_blockerwhen the runqueue's aren't empty... how about that?
Quoted 6 lines
Quoted 3 lines
I don't know if you are serious, since the all the runqueues are never empty while suspending, this would disable opportunistic suspend altogether.
So why again was this such a great scheme? Go fix your userspace to not not run when not needed.
Thanks for your constructive feedback.
Brian
Quoted 14 lines · Peter Zijlstra
Quoted 13 lines · Arve Hjønnevåg
Quoted 11 lines · Peter Zijlstra
Quoted 6 lines · Rafael J. Wysocki
Quoted 3 lines
This of course will lead to a scattering of suspend blockers into any
drivers/subsystemsconsidered "useful", which by looking through current Android kernels is many of them.That depends on the maintainers of these subsystems, who still have the power to reject requested changes.
So as a scheduler maintainer I'm going to merge a patch that does a
suspend_blockerwhen the runqueue's aren't empty... how about that?
Quoted 6 lines
Quoted 3 lines
I don't know if you are serious, since the all the runqueues are never empty while suspending, this would disable opportunistic suspend altogether.
So why again was this such a great scheme? Go fix your userspace to not not run when not needed.
Thanks for your constructive feedback.
Brian
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Quoted 14 lines · On Wed, 26 May 2010 11:45:06 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 13 lines · Arve Hjønnevåg
Quoted 11 lines · Peter Zijlstra
Quoted 6 lines · Rafael J. Wysocki
Quoted 3 lines
This of course will lead to a scattering of suspend blockers into any
drivers/subsystemsconsidered "useful", which by looking through current Android kernels is many of them.That depends on the maintainers of these subsystems, who still have the power to reject requested changes.
So as a scheduler maintainer I'm going to merge a patch that does a
suspend_blockerwhen the runqueue's aren't empty... how about that?
Quoted 6 lines
Quoted 3 lines
I don't know if you are serious, since the all the runqueues are never empty while suspending, this would disable opportunistic suspend altogether.
So why again was this such a great scheme? Go fix your userspace to not not run when not needed.
Hi Peter!
This was already mentioned in one of these threads.
The summary is: The device this kernel is running on dosn't want to (or can) rely on userspace to save power. This is because it is an open system, without an app-store or the like. Everyone can run what he wants.
So anything relying on (all) userspace solves a different problem.
Cheers,
Flo
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 14 lines · On Wed, 26 May 2010 11:45:06 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 13 lines · Arve Hjønnevåg
Quoted 11 lines · Peter Zijlstra
Quoted 6 lines · Rafael J. Wysocki
Quoted 3 lines
This of course will lead to a scattering of suspend blockers into any
drivers/subsystemsconsidered "useful", which by looking through current Android kernels is many of them.That depends on the maintainers of these subsystems, who still have the power to reject requested changes.
So as a scheduler maintainer I'm going to merge a patch that does a
suspend_blockerwhen the runqueue's aren't empty... how about that?
Quoted 6 lines
Quoted 3 lines
I don't know if you are serious, since the all the runqueues are never empty while suspending, this would disable opportunistic suspend altogether.
So why again was this such a great scheme? Go fix your userspace to not not run when not needed.
Hi Peter!
This was already mentioned in one of these threads.
The summary is: The device this kernel is running on dosn't want to (or can) rely on userspace to save power. This is because it is an open system, without an app-store or the like. Everyone can run what he wants.
So anything relying on (all) userspace solves a different problem.
Cheers,
Flo
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Florian Mickler
The summary is: The device this kernel is running on dosn't want to (or can) rely on userspace to save power. This is because it is an open system, without an app-store or the like. Everyone can run what he wants.
So anything relying on (all) userspace solves a different problem.
So what stops an application from grabbing a suspend blocker?
Quoted 9 lines · On Wed, 26 May 2010 12:08:04 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 6 lines · Florian Mickler
The summary is: The device this kernel is running on dosn't want to (or can) rely on userspace to save power. This is because it is an open system, without an app-store or the like. Everyone can run what he wants.
So anything relying on (all) userspace solves a different problem.
So what stops an application from grabbing a suspend blocker?
Well, I don't own any android devices, but If I read this all correctly, an app can request the permission to grab an suspend blocker at installation time. ("This application is requesting permission to keep the device from sleeping, thus possibly reducing your battery time. Are you shure you want to continue? [Yes,No]")
every app grabbing a suspend blocker is showing
up in a "these programs stop suspend" kind of battery-app and are thus well accounted for. _And the user knows who to blame_.
Maybe this is implemented via fs-permissions? Anyway, I'm shure, that the access control uses a well established method. :)
Cheers,
Flo
Quoted 9 lines · On Wed, 26 May 2010 12:08:04 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 6 lines · Florian Mickler
The summary is: The device this kernel is running on dosn't want to (or can) rely on userspace to save power. This is because it is an open system, without an app-store or the like. Everyone can run what he wants.
So anything relying on (all) userspace solves a different problem.
So what stops an application from grabbing a suspend blocker?
Well, I don't own any android devices, but If I read this all correctly, an app can request the permission to grab an suspend blocker at installation time. ("This application is requesting permission to keep the device from sleeping, thus possibly reducing your battery time. Are you shure you want to continue? [Yes,No]")
every app grabbing a suspend blocker is showing
up in a "these programs stop suspend" kind of battery-app and are thus well accounted for. _And the user knows who to blame_.
Maybe this is implemented via fs-permissions? Anyway, I'm shure, that the access control uses a well established method. :)
Cheers,
Flo
Quoted 6 lines · Florian Mickler
The summary is: The device this kernel is running on dosn't want to (or can) rely on userspace to save power. This is because it is an open system, without an app-store or the like. Everyone can run what he wants.
So anything relying on (all) userspace solves a different problem.
So what stops an application from grabbing a suspend blocker?
Quoted 11 lines · Florian Mickler
Quoted 2 lines
So why again was this such a great scheme? Go fix your userspace to not not run when not needed.
Hi Peter!
This was already mentioned in one of these threads.
The summary is: The device this kernel is running on dosn't want to (or can) rely on userspace to save power. This is because it is an open system, without an app-store or the like. Everyone can run what he wants.
I don't see this as a valid point. Everyone can run a different kernel where nothing will just work. Are you aiming protection against that as well?
~Vitaly
Quoted 14 lines · On Wed, 26 May 2010 13:18:51 +0200 Vitaly Wool <[email protected]> wrote:
Quoted 11 lines · Florian Mickler
Quoted 2 lines
So why again was this such a great scheme? Go fix your userspace to not not run when not needed.
Hi Peter!
This was already mentioned in one of these threads.
The summary is: The device this kernel is running on dosn't want to (or can) rely on userspace to save power. This is because it is an open system, without an app-store or the like. Everyone can run what he wants.
Quoted 5 lines
I don't see this as a valid point. Everyone can run a different kernel where nothing will just work. Are you aiming protection against that as well?
~Vitaly
This is not "protection". This is functioning properly in a real world scenario. Why would the user change the kernel, if the device would be buggy after that? (Except maybe he is a geek)
Cheers,
Flo
Quoted 3 lines · Florian Mickler
This is not "protection". This is functioning properly in a real world scenario. Why would the user change the kernel, if the device would be buggy after that? (Except maybe he is a geek)
Hmm... Why would the user continue to use the program if it slows down his device and sucks the battery as a vampire (Except maybe he's a moron)? ;)
~Vitaly
Quoted 3 lines · Florian Mickler
This is not "protection". This is functioning properly in a real world scenario. Why would the user change the kernel, if the device would be buggy after that? (Except maybe he is a geek)
Hmm... Why would the user continue to use the program if it slows down his device and sucks the battery as a vampire (Except maybe he's a moron)? ;)
~Vitaly
Quoted 11 lines · On Wed, 26 May 2010 14:01:49 +0200 Vitaly Wool <[email protected]> wrote:
Quoted 3 lines · Florian Mickler
This is not "protection". This is functioning properly in a real world scenario. Why would the user change the kernel, if the device would be buggy after that? (Except maybe he is a geek)
Hmm... Why would the user continue to use the program if it slows down his device and sucks the battery as a vampire (Except maybe he's a moron)? ;)
~Vitaly
Because he is using a robust kernel that provides suspend blockers and is preventing the vampire from sucking power?
Most users don't even grasp the simple concept of different "programs". They just have a device and click here and there and are happy.
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
Cheers,
Flo
Quoted 11 lines · On Wed, 26 May 2010 14:01:49 +0200 Vitaly Wool <[email protected]> wrote:
Quoted 3 lines · Florian Mickler
This is not "protection". This is functioning properly in a real world scenario. Why would the user change the kernel, if the device would be buggy after that? (Except maybe he is a geek)
Hmm... Why would the user continue to use the program if it slows down his device and sucks the battery as a vampire (Except maybe he's a moron)? ;)
~Vitaly
Because he is using a robust kernel that provides suspend blockers and is preventing the vampire from sucking power?
Most users don't even grasp the simple concept of different "programs". They just have a device and click here and there and are happy.
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
Cheers,
Flo
hi,
Quoted 3 lines · ext Florian Mickler
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
What I find ridiculous is the assumption that kernel should provide good power management even for badly written applications. They should work, of course, but there's no assumption that the kernel should cope with those applications and provide good battery usage on those cases.
You can install and run anything on the device, and they will work as they should (they will be scheduled and will be processed) but you can't expect the kernel to prevent that application from waking up the CPU every 10 ms simply because someone didn't think straight while writting the app.
Signature · 3 lines
balbi DefectiveByDesign.org
hi,
Quoted 3 lines · ext Florian Mickler
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
What I find ridiculous is the assumption that kernel should provide good power management even for badly written applications. They should work, of course, but there's no assumption that the kernel should cope with those applications and provide good battery usage on those cases.
You can install and run anything on the device, and they will work as they should (they will be scheduled and will be processed) but you can't expect the kernel to prevent that application from waking up the CPU every 10 ms simply because someone didn't think straight while writting the app.
Signature · 3 lines
balbi DefectiveByDesign.org
Quoted 12 lines · On Wed, 26 May 2010 15:29:32 +0300 Felipe Balbi <[email protected]> wrote:
hi,
Quoted 3 lines · ext Florian Mickler
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
What I find ridiculous is the assumption that kernel should provide good power management even for badly written applications. They should work, of course, but there's no assumption that the kernel should cope with those applications and provide good battery usage on those cases.
Quoted 6 lines
You can install and run anything on the device, and they will work as they should (they will be scheduled and will be processed) but you can't expect the kernel to prevent that application from waking up the CPU every 10 ms simply because someone didn't think straight while writting the app.
But then someone at the user side has to know what he is doing.
I fear, if you target mass market without central distribution channels, you can not assume that much.
Cheers,
Flo
Quoted 12 lines · On Wed, 26 May 2010 15:29:32 +0300 Felipe Balbi <[email protected]> wrote:
hi,
Quoted 3 lines · ext Florian Mickler
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
What I find ridiculous is the assumption that kernel should provide good power management even for badly written applications. They should work, of course, but there's no assumption that the kernel should cope with those applications and provide good battery usage on those cases.
Quoted 6 lines
You can install and run anything on the device, and they will work as they should (they will be scheduled and will be processed) but you can't expect the kernel to prevent that application from waking up the CPU every 10 ms simply because someone didn't think straight while writting the app.
But then someone at the user side has to know what he is doing.
I fear, if you target mass market without central distribution channels, you can not assume that much.
Cheers,
Flo
Hi,
Quoted 4 lines · ext Florian Mickler
But then someone at the user side has to know what he is doing.
I fear, if you target mass market without central distribution channels, you can not assume that much.
and that's enough to push hacks into the kernel ? I don't think so. Do it like apple and prevent multi-tasking for any non-apple applications :-p
Signature · 3 lines
balbi DefectiveByDesign.org
Hi,
Quoted 4 lines · ext Florian Mickler
But then someone at the user side has to know what he is doing.
I fear, if you target mass market without central distribution channels, you can not assume that much.
and that's enough to push hacks into the kernel ? I don't think so. Do it like apple and prevent multi-tasking for any non-apple applications :-p
Signature · 3 lines
balbi DefectiveByDesign.org
Quoted 12 lines · On Wed, 26 May 2010 15:35:32 +0300 Felipe Balbi <[email protected]> wrote:
Hi,
Quoted 4 lines · ext Florian Mickler
But then someone at the user side has to know what he is doing.
I fear, if you target mass market without central distribution channels, you can not assume that much.
and that's enough to push hacks into the kernel ? I don't think so. Do it like apple and prevent multi-tasking for any non-apple applications :-p
:)
It really comes down to a policy decision by the distribution maker. And I don't think kernel upstream should be the one to force one way or the other. So merging this patch set will allow android to continue their work _on mainline_ while everybody else can continue as before.
All points about the impact on the kernel have already been raised. So you should be happy there.
Nonetheless, I really think the kernel needs to allow for the android way of power saving. It misses out on a big feature and a big user-base if not.
Also I expect there to be synergies between android development and mainline kernel development _only_ if android development can use mainline kernel.
And as for the quality of the "hack": I think you find this ugly, just because you don't like the concept of degrading user space guaranties on timers and stuff.
But look at it this way: Suspend blockers are a way for the kernel to make user space programs accountable for using the resource "power". If a user space program needs the "traditional" guaranties for functioning properly, it needs to take a suspend blocker. But _THEN_ it better be well behaved. This is a kind of contract between userspace and kernelspace.
On the other hand, if I don't need these traditional guaranties on timers and stuff, I don't have to know device specific things about power consumption. I can just use whatever facilities the programming language provides without needing to worry about low level details.
This is a _big_ plus for attracting 3rd party programs. (And of course the thing you don't like).
Cheers,
Flo
Quoted 3 lines · Florian Mickler
It really comes down to a policy decision by the distribution maker. And I don't think kernel upstream should be the one to force one way or the other.
That's exactly what we always do. If we were not to do so, the kernel would be a bloated incoherent piece of crap.
Quoted 6 lines
So merging this patch set will allow android to continue
their work_onmainline_while everybody else can continue as before.Nonetheless, I really think the kernel needs to allow for the android way of power saving. It misses out on a big feature and a big user-base if not.
I really think we should not do so. Let them help in fixing the real issue instead of creating a new class of userspace that is more important than another.
Quoted 2 lines
But look at it this way: Suspend blockers are a way for the kernel to make user space programs accountable for using the resource "power".
How is userspace without suspend blockers not accountable? We can easily account runtime and in fact have several ways to do so.
Quoted 3 lines · Florian Mickler
It really comes down to a policy decision by the distribution maker. And I don't think kernel upstream should be the one to force one way or the other.
That's exactly what we always do. If we were not to do so, the kernel would be a bloated incoherent piece of crap.
Quoted 6 lines
So merging this patch set will allow android to continue
their work_onmainline_while everybody else can continue as before.Nonetheless, I really think the kernel needs to allow for the android way of power saving. It misses out on a big feature and a big user-base if not.
I really think we should not do so. Let them help in fixing the real issue instead of creating a new class of userspace that is more important than another.
Quoted 2 lines
But look at it this way: Suspend blockers are a way for the kernel to make user space programs accountable for using the resource "power".
How is userspace without suspend blockers not accountable? We can easily account runtime and in fact have several ways to do so.
Quoted 3 lines
Nonetheless, I really think the kernel needs to allow for the android way of power saving. It misses out on a big feature and a big user-base if not.
That seems to me to be conflating models of behaviour and implementations.
Quoted 2 lines
This is a _big_ plus for attracting 3rd party programs. (And of course the thing you don't like).
You would do better to concentrate on technical issues that the assignment of malicious intent to other parties.
Alan
Quoted 7 lines · On Wed, 26 May 2010 14:19:42 +0100 Alan Cox <[email protected]> wrote:
Quoted 2 lines
This is a _big_ plus for attracting 3rd party programs. (And of course the thing you don't like).
You would do better to concentrate on technical issues that the assignment of malicious intent to other parties.
Alan
This was nothing the kind of! He explicitly said this:
Quoted 4 lines · On Wed, 26 May 2010 15:29:32 +0300 Felipe Balbi <[email protected]> wrote:
What I find ridiculous is the assumption that kernel should provide good power management even for badly written applications. They should work, of course, but there's no assumption that the kernel should cope with those applications and provide good battery usage on those cases.
And I responded that if the kernel would do this, then that would be a "_big_ plus for attracting 3d party programs".
I had no intent in attacking anyone or putting word's in someones mouth. Sorry if this was unclearly written.
Cheers,
Flo
Quoted 7 lines · On Wed, 26 May 2010 14:19:42 +0100 Alan Cox <[email protected]> wrote:
Quoted 2 lines
This is a _big_ plus for attracting 3rd party programs. (And of course the thing you don't like).
You would do better to concentrate on technical issues that the assignment of malicious intent to other parties.
Alan
This was nothing the kind of! He explicitly said this:
Quoted 4 lines · On Wed, 26 May 2010 15:29:32 +0300 Felipe Balbi <[email protected]> wrote:
What I find ridiculous is the assumption that kernel should provide good power management even for badly written applications. They should work, of course, but there's no assumption that the kernel should cope with those applications and provide good battery usage on those cases.
And I responded that if the kernel would do this, then that would be a "_big_ plus for attracting 3d party programs".
I had no intent in attacking anyone or putting word's in someones mouth. Sorry if this was unclearly written.
Cheers,
Flo
Quoted 3 lines
Nonetheless, I really think the kernel needs to allow for the android way of power saving. It misses out on a big feature and a big user-base if not.
That seems to me to be conflating models of behaviour and implementations.
Quoted 2 lines
This is a _big_ plus for attracting 3rd party programs. (And of course the thing you don't like).
You would do better to concentrate on technical issues that the assignment of malicious intent to other parties.
Alan
Quoted 11 lines · Florian Mickler
It really comes down to a policy decision by the distribution maker. And I don't think kernel upstream should be the one to force one way or the other. So merging this patch set will allow android to continue their work
_onmainline_while everybody else can continue as before.All points about the impact on the kernel have already been raised. So you should be happy there.
Nonetheless, I really think the kernel needs to allow for the android way of power saving. It misses out on a big feature and a big user-base if not.
Let's get rid of hypothetical uses in the future: suspend blockers is _only_ used by Android user-space. Nobody else has expressed any intention of using them.
Quoted 3 lines
Also I expect there to be synergies between android development and mainline kernel development _only_ if android development can use mainline kernel.
That's like saying "there can only be synergies between linux real time and mainline _only_ if RT development can use mainline".
I can give you my experience at Nokia... can you use mainline on any of the Maemo devices? No. You have to patch the kernel heavily, to be able to kind-of run the official user-space, or you have to use a different user-space.
Does that prevent synergies? No. As Brian Swetland and Daniel Walker already expressed before; you can run mainline kernel with debian on Android phones.
It would be nice to run Android user-space, or parts of it on mainline kernels, but if it's not possible, that's a deficiency on Android's design; Maemo/Moblin/Meego are good players in the linux ecosystem so you can re-use parts of the system on typical desktops (in fact many are coming from there), and there are community distributions re-using those parts and running just fine on mainline kernels.
Sure, it would be easier for Android developers if all their crap was in the mainline, but even then there are no guarantees of anything. Just like any other linux phone, you'll probably need to add patches for 3D drivers, DSP, or other hardware acceleration, missing board-specfic patches, and bunch of hacks.
So if you have to add all those patches anyway, what's the problem of having to add the suspend block patches?
Why do some Android developers think they can be the exception and have patches merged in the core of linux _only_ for their specific user-space, and their specific drivers?
If you separate suspend blockers from Android, and judge them on their technical merit, I don't see a single person saying this is a good idea, we'll switch all our user-space to use them.
Signature · 1 line
Felipe Contreras
Quoted 11 lines · Florian Mickler
It really comes down to a policy decision by the distribution maker. And I don't think kernel upstream should be the one to force one way or the other. So merging this patch set will allow android to continue their work
_onmainline_while everybody else can continue as before.All points about the impact on the kernel have already been raised. So you should be happy there.
Nonetheless, I really think the kernel needs to allow for the android way of power saving. It misses out on a big feature and a big user-base if not.
Let's get rid of hypothetical uses in the future: suspend blockers is _only_ used by Android user-space. Nobody else has expressed any intention of using them.
Quoted 3 lines
Also I expect there to be synergies between android development and mainline kernel development _only_ if android development can use mainline kernel.
That's like saying "there can only be synergies between linux real time and mainline _only_ if RT development can use mainline".
I can give you my experience at Nokia... can you use mainline on any of the Maemo devices? No. You have to patch the kernel heavily, to be able to kind-of run the official user-space, or you have to use a different user-space.
Does that prevent synergies? No. As Brian Swetland and Daniel Walker already expressed before; you can run mainline kernel with debian on Android phones.
It would be nice to run Android user-space, or parts of it on mainline kernels, but if it's not possible, that's a deficiency on Android's design; Maemo/Moblin/Meego are good players in the linux ecosystem so you can re-use parts of the system on typical desktops (in fact many are coming from there), and there are community distributions re-using those parts and running just fine on mainline kernels.
Sure, it would be easier for Android developers if all their crap was in the mainline, but even then there are no guarantees of anything. Just like any other linux phone, you'll probably need to add patches for 3D drivers, DSP, or other hardware acceleration, missing board-specfic patches, and bunch of hacks.
So if you have to add all those patches anyway, what's the problem of having to add the suspend block patches?
Why do some Android developers think they can be the exception and have patches merged in the core of linux _only_ for their specific user-space, and their specific drivers?
If you separate suspend blockers from Android, and judge them on their technical merit, I don't see a single person saying this is a good idea, we'll switch all our user-space to use them.
Signature · 1 line
Felipe Contreras
Quoted 22 lines · Florian Mickler
Quoted 12 lines · On Wed, 26 May 2010 15:29:32 +0300 Felipe Balbi <[email protected]> wrote:
hi,
Quoted 3 lines · ext Florian Mickler
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
What I find ridiculous is the assumption that kernel should provide good power management even for badly written applications. They should work, of course, but there's no assumption that the kernel should cope with those applications and provide good battery usage on those cases.
Quoted 6 lines
You can install and run anything on the device, and they will work as they should (they will be scheduled and will be processed) but you can't expect the kernel to prevent that application from waking up the CPU every 10 ms simply because someone didn't think straight while writting the app.
Quoted 4 lines
But then someone at the user side has to know what he is doing.
I fear, if you target mass market without central distribution channels, you can not assume that much.
Provide the developers and users with tools.
Notify the users that their phone is using power at an unadvised rate due to proglet $foo.
Also, if you can integrate into the development environment and provide developers instant feedback on suckage of their app they can react and fix before letting users run into the issue.
Quoted 28 lines · On Wed, 26 May 2010 14:41:29 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 22 lines · Florian Mickler
Quoted 12 lines · On Wed, 26 May 2010 15:29:32 +0300 Felipe Balbi <[email protected]> wrote:
hi,
Quoted 3 lines · ext Florian Mickler
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
What I find ridiculous is the assumption that kernel should provide good power management even for badly written applications. They should work, of course, but there's no assumption that the kernel should cope with those applications and provide good battery usage on those cases.
Quoted 6 lines
You can install and run anything on the device, and they will work as they should (they will be scheduled and will be processed) but you can't expect the kernel to prevent that application from waking up the CPU every 10 ms simply because someone didn't think straight while writting the app.
Quoted 4 lines
But then someone at the user side has to know what he is doing.
I fear, if you target mass market without central distribution channels, you can not assume that much.
Quoted 9 lines
Provide the developers and users with tools.
Notify the users that their phone is using power at an unadvised rate due to proglet $foo.
Also, if you can integrate into the development environment and provide developers instant feedback on suckage of their app they can react and fix before letting users run into the issue.
Yeah. And I personally agree with you there. But this is a policy decision that should not prevent android from doing it differently. The kernel can not win if it does not try to integrate any use of it. After all, we are a free comunity and if someone wants to use it their way, why not allow for it? (As long as it does not directly impact other uses)
The best solution wins, but not by decision of some kernel development gatekeepers, but because it is superior. There are no clear markings of the better solution. Time will tell.
Cheers,
Flo
Quoted 1 line · Florian Mickler
The kernel can not win if it does not try to integrate any use of it.
If we'd integrate every patch that came to lkml, you'd run away screaming.
We most certainly do not want to integrate _any_ use.
Quoted 1 line · Florian Mickler
The kernel can not win if it does not try to integrate any use of it.
If we'd integrate every patch that came to lkml, you'd run away screaming.
We most certainly do not want to integrate _any_ use.
Quoted 7 lines · On Wed, 26 May 2010 15:07:27 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 1 line · Florian Mickler
The kernel can not win if it does not try to integrate any use of it.
If we'd integrate every patch that came to lkml, you'd run away screaming.
We most certainly do not want to integrate _any_ use.
We most certainly do want to integrate any use that is not harmful to others.
I don't buy the argument that this is harmful.
Cheers,
Flo
Quoted 7 lines · On Wed, 26 May 2010 15:07:27 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 1 line · Florian Mickler
The kernel can not win if it does not try to integrate any use of it.
If we'd integrate every patch that came to lkml, you'd run away screaming.
We most certainly do not want to integrate _any_ use.
We most certainly do want to integrate any use that is not harmful to others.
I don't buy the argument that this is harmful.
Cheers,
Flo
Quoted 28 lines · On Wed, 26 May 2010 14:41:29 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 22 lines · Florian Mickler
Quoted 12 lines · On Wed, 26 May 2010 15:29:32 +0300 Felipe Balbi <[email protected]> wrote:
hi,
Quoted 3 lines · ext Florian Mickler
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
What I find ridiculous is the assumption that kernel should provide good power management even for badly written applications. They should work, of course, but there's no assumption that the kernel should cope with those applications and provide good battery usage on those cases.
Quoted 6 lines
You can install and run anything on the device, and they will work as they should (they will be scheduled and will be processed) but you can't expect the kernel to prevent that application from waking up the CPU every 10 ms simply because someone didn't think straight while writting the app.
Quoted 4 lines
But then someone at the user side has to know what he is doing.
I fear, if you target mass market without central distribution channels, you can not assume that much.
Quoted 9 lines
Provide the developers and users with tools.
Notify the users that their phone is using power at an unadvised rate due to proglet $foo.
Also, if you can integrate into the development environment and provide developers instant feedback on suckage of their app they can react and fix before letting users run into the issue.
Yeah. And I personally agree with you there. But this is a policy decision that should not prevent android from doing it differently. The kernel can not win if it does not try to integrate any use of it. After all, we are a free comunity and if someone wants to use it their way, why not allow for it? (As long as it does not directly impact other uses)
The best solution wins, but not by decision of some kernel development gatekeepers, but because it is superior. There are no clear markings of the better solution. Time will tell.
Cheers,
Flo
Quoted 22 lines · Florian Mickler
Quoted 12 lines · On Wed, 26 May 2010 15:29:32 +0300 Felipe Balbi <[email protected]> wrote:
hi,
Quoted 3 lines · ext Florian Mickler
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
What I find ridiculous is the assumption that kernel should provide good power management even for badly written applications. They should work, of course, but there's no assumption that the kernel should cope with those applications and provide good battery usage on those cases.
Quoted 6 lines
You can install and run anything on the device, and they will work as they should (they will be scheduled and will be processed) but you can't expect the kernel to prevent that application from waking up the CPU every 10 ms simply because someone didn't think straight while writting the app.
Quoted 4 lines
But then someone at the user side has to know what he is doing.
I fear, if you target mass market without central distribution channels, you can not assume that much.
Provide the developers and users with tools.
Notify the users that their phone is using power at an unadvised rate due to proglet $foo.
Also, if you can integrate into the development environment and provide developers instant feedback on suckage of their app they can react and fix before letting users run into the issue.
Quoted 7 lines · Florian Mickler
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
You almost always need to "hack" the mainline software for a production system. So do it here as well. Make sure the hack is well isolated and local. You can even submit it to the mainline, better as a configuration option, _unless_ it is a *framework* that provokes writing code in an ugly and unsafe way.
~Vitaly
Quoted 7 lines · Florian Mickler
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
You almost always need to "hack" the mainline software for a production system. So do it here as well. Make sure the hack is well isolated and local. You can even submit it to the mainline, better as a configuration option, _unless_ it is a *framework* that provokes writing code in an ugly and unsafe way.
~Vitaly
Quoted 10 lines · On Wed, 26 May 2010 14:55:31 +0200 Vitaly Wool <[email protected]> wrote:
Quoted 7 lines · Florian Mickler
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
Quoted 7 lines
You almost always need to "hack" the mainline software for a production system. So do it here as well. Make sure the hack is well isolated and local. You can even submit it to the mainline, better as a configuration option, _unless_ it is a *framework* that provokes writing code in an ugly and unsafe way.
~Vitaly
I don't think that the in-kernel suspend block is a bad idea.
You could probably use the suspend-blockers unconditionally in the suspend framework to indicate if a suspend is possible or not. Regardless of opportunistic suspend or not. This way, you don't have to try-and-fail on a suspend request and thus making suspending potentially more robust or allowing for a "suspend as soon as possible" semantic (which is probably a good idea, if you have to grab your laptop in a hurry to get away).
Cheers,
Flo
Quoted 10 lines · On Wed, 26 May 2010 14:55:31 +0200 Vitaly Wool <[email protected]> wrote:
Quoted 7 lines · Florian Mickler
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
Quoted 7 lines
You almost always need to "hack" the mainline software for a production system. So do it here as well. Make sure the hack is well isolated and local. You can even submit it to the mainline, better as a configuration option, _unless_ it is a *framework* that provokes writing code in an ugly and unsafe way.
~Vitaly
I don't think that the in-kernel suspend block is a bad idea.
You could probably use the suspend-blockers unconditionally in the suspend framework to indicate if a suspend is possible or not. Regardless of opportunistic suspend or not. This way, you don't have to try-and-fail on a suspend request and thus making suspending potentially more robust or allowing for a "suspend as soon as possible" semantic (which is probably a good idea, if you have to grab your laptop in a hurry to get away).
Cheers,
Flo
Quoted 4 lines · Florian Mickler
I don't think that the in-kernel suspend block is a bad idea.
You could probably use the suspend-blockers unconditionally in the suspend framework to indicate if a suspend is possible or not.
That's not how it works. Drivers aren't supposed to abort unconditional suspend -- not without a really good reason (for example, the device received a wakeup event before it was fully suspended). In short, suspends should be considered to be _always_ possible.
Quoted 5 lines
Regardless of opportunistic suspend or not. This way, you don't have to try-and-fail on a suspend request and thus making suspending potentially more robust or allowing for a "suspend as soon as possible" semantic (which is probably a good idea, if you have to grab your laptop in a hurry to get away).
That's different. Suspend blockers could block (not abort!) regular suspends, just as they do opportunistic suspends.
But why should they? I mean, if userspace wants to initiate a suspend that is capable of being blocked by a kernel suspend blocker, then all it has to do is initiate an opportunistic suspend instead of a normal suspend.
Alan Stern
Quoted 4 lines · Florian Mickler
I don't think that the in-kernel suspend block is a bad idea.
You could probably use the suspend-blockers unconditionally in the suspend framework to indicate if a suspend is possible or not.
That's not how it works. Drivers aren't supposed to abort unconditional suspend -- not without a really good reason (for example, the device received a wakeup event before it was fully suspended). In short, suspends should be considered to be _always_ possible.
Quoted 5 lines
Regardless of opportunistic suspend or not. This way, you don't have to try-and-fail on a suspend request and thus making suspending potentially more robust or allowing for a "suspend as soon as possible" semantic (which is probably a good idea, if you have to grab your laptop in a hurry to get away).
That's different. Suspend blockers could block (not abort!) regular suspends, just as they do opportunistic suspends.
But why should they? I mean, if userspace wants to initiate a suspend that is capable of being blocked by a kernel suspend blocker, then all it has to do is initiate an opportunistic suspend instead of a normal suspend.
Alan Stern
Quoted 21 lines · On Wed, 26 May 2010 10:38:50 -0400 (EDT) Alan Stern…
Quoted 4 lines · Florian Mickler
I don't think that the in-kernel suspend block is a bad idea.
You could probably use the suspend-blockers unconditionally in the suspend framework to indicate if a suspend is possible or not.
That's not how it works. Drivers aren't supposed to abort unconditional suspend -- not without a really good reason (for example, the device received a wakeup event before it was fully suspended). In short, suspends should be considered to be _always_ possible.
Quoted 5 lines
Regardless of opportunistic suspend or not. This way, you don't have to try-and-fail on a suspend request and thus making suspending potentially more robust or allowing for a "suspend as soon as possible" semantic (which is probably a good idea, if you have to grab your laptop in a hurry to get away).
That's different. Suspend blockers could block (not abort!) regular suspends, just as they do opportunistic suspends.
Quoted 6 lines
But why should they? I mean, if userspace wants to initiate a suspend that is capable of being blocked by a kernel suspend blocker, then all it has to do is initiate an opportunistic suspend instead of a normal suspend.
Alan Stern
Let me elaborate what i mean:
The assumption beeing that specifying pm constraints in the drivers is a good thing which we will be doing anyway in the long run. (See Alan Cox's summary of current mainline problems[1].)
I don't wanna go into specifing any constraint API here, but it could probably be either a blocker flag (the here presented suspend-blocker, which Alan doesnt like?)
or maybe a few integer-typed constraints defined by the pm-core. (needed scheduler-latency/needed io-latency?)
As an intermediate step, it would probably be possible to specify the "I cant be suspended" constraint (aka blocker) for all drivers not explicitly stating anything other.
Converting a driver to using any constraint-API would require analysing what makes a driver refuse suspending in the old suspend handler and then specify any "no suspend" (or whatever) constraint before those conditions arise and clearing of the constraints when it is no longer critical. (Much work.)
A future switch from something like a flag (blocker) to a full integer-typed requirement would probably be a simple search and replace or even possible by extending the blocker-api.
If that is done, the prototype of the driver callback
int suspend();
could probably be changed to
void suspend();
and it be expected to always _successfully_ suspend.
The hard part is finding the places where special guarantees are needed. But android did show that this is possible.
Cheers,
Flo
Quoted 21 lines · On Wed, 26 May 2010 10:38:50 -0400 (EDT) Alan Stern…
Quoted 4 lines · Florian Mickler
I don't think that the in-kernel suspend block is a bad idea.
You could probably use the suspend-blockers unconditionally in the suspend framework to indicate if a suspend is possible or not.
That's not how it works. Drivers aren't supposed to abort unconditional suspend -- not without a really good reason (for example, the device received a wakeup event before it was fully suspended). In short, suspends should be considered to be _always_ possible.
Quoted 5 lines
Regardless of opportunistic suspend or not. This way, you don't have to try-and-fail on a suspend request and thus making suspending potentially more robust or allowing for a "suspend as soon as possible" semantic (which is probably a good idea, if you have to grab your laptop in a hurry to get away).
That's different. Suspend blockers could block (not abort!) regular suspends, just as they do opportunistic suspends.
Quoted 6 lines
But why should they? I mean, if userspace wants to initiate a suspend that is capable of being blocked by a kernel suspend blocker, then all it has to do is initiate an opportunistic suspend instead of a normal suspend.
Alan Stern
Let me elaborate what i mean:
The assumption beeing that specifying pm constraints in the drivers is a good thing which we will be doing anyway in the long run. (See Alan Cox's summary of current mainline problems[1].)
I don't wanna go into specifing any constraint API here, but it could probably be either a blocker flag (the here presented suspend-blocker, which Alan doesnt like?)
or maybe a few integer-typed constraints defined by the pm-core. (needed scheduler-latency/needed io-latency?)
As an intermediate step, it would probably be possible to specify the "I cant be suspended" constraint (aka blocker) for all drivers not explicitly stating anything other.
Converting a driver to using any constraint-API would require analysing what makes a driver refuse suspending in the old suspend handler and then specify any "no suspend" (or whatever) constraint before those conditions arise and clearing of the constraints when it is no longer critical. (Much work.)
A future switch from something like a flag (blocker) to a full integer-typed requirement would probably be a simple search and replace or even possible by extending the blocker-api.
If that is done, the prototype of the driver callback
int suspend();
could probably be changed to
void suspend();
and it be expected to always _successfully_ suspend.
The hard part is finding the places where special guarantees are needed. But android did show that this is possible.
Cheers,
Flo
Quoted 6 lines · ext Florian Mickler
Converting a driver to using any constraint-API would require analysing
what makes a driver refuse suspending in the old suspend handler and
then specify any "no suspend" (or whatever) constraint before those
conditions arise and clearing of the constraints when it is no longer critical. (Much work.)
That's not really true.
Nothing prevents using from the beginning a sane approach where drivers are required to specify constraints.
The way it has been done for the N900 was to let driver developers specify _very_ conservative constraints, during the conversion phase.
Then each driver has been optimized.
If you have as requirement for driver developers that their driver must be working properly when compiled as module, it is possible to test the system with a minimalistic kernel which enters the lowest power state as soon as possible, plus only those modules that are being optimized.
This allows also to identify parasitic drivers, which fail to apply the proper constraint and instead rely on some other driver to keep the system alive.
igor
Quoted 6 lines · ext Florian Mickler
Converting a driver to using any constraint-API would require analysing
what makes a driver refuse suspending in the old suspend handler and
then specify any "no suspend" (or whatever) constraint before those
conditions arise and clearing of the constraints when it is no longer critical. (Much work.)
That's not really true.
Nothing prevents using from the beginning a sane approach where drivers are required to specify constraints.
The way it has been done for the N900 was to let driver developers specify _very_ conservative constraints, during the conversion phase.
Then each driver has been optimized.
If you have as requirement for driver developers that their driver must be working properly when compiled as module, it is possible to test the system with a minimalistic kernel which enters the lowest power state as soon as possible, plus only those modules that are being optimized.
This allows also to identify parasitic drivers, which fail to apply the proper constraint and instead rely on some other driver to keep the system alive.
igor
Quoted 7 lines · ext Florian Mickler
Converting a driver to using any constraint-API would require analysing what makes a driver refuse suspending in the old suspend handler and then specify any "no suspend" (or whatever) constraint before those conditions arise and clearing of the constraints when it is no longer critical. (Much work.)
That's not really true.
Nothing prevents using from the beginning a sane approach where drivers are required to specify constraints.
The way it has been done for the N900 was to let driver developers specify _very_ conservative constraints, during the conversion phase.
Then each driver has been optimized.
If you have as requirement for driver developers that their driver must be working properly when compiled as module, it is possible to test the system with a minimalistic kernel which enters the lowest power state as soon as possible, plus only those modules that are being optimized.
This allows also to identify parasitic drivers, which fail to apply the proper constraint and instead rely on some other driver to keep the system alive.
igor
Quoted 7 lines · ext Florian Mickler
Converting a driver to using any constraint-API would require analysing what makes a driver refuse suspending in the old suspend handler and then specify any "no suspend" (or whatever) constraint before those conditions arise and clearing of the constraints when it is no longer critical. (Much work.)
That's not really true.
Nothing prevents using from the beginning a sane approach where drivers are required to specify constraints.
The way it has been done for the N900 was to let driver developers specify _very_ conservative constraints, during the conversion phase.
Then each driver has been optimized.
If you have as requirement for driver developers that their driver must be working properly when compiled as module, it is possible to test the system with a minimalistic kernel which enters the lowest power state as soon as possible, plus only those modules that are being optimized.
This allows also to identify parasitic drivers, which fail to apply the proper constraint and instead rely on some other driver to keep the system alive.
igor
Quoted 7 lines
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
The problem you have is that this is policy. If I have the device wired to a big screen and I want cows bouncing on it I'll be most upset if instead it suspends. What you are essentially arguing for is for the kernel to disobey the userspace. It's as ridiculous (albeit usually less damaging) as a file system saying "Ooh thats a rude file name, the app can't have meant it, I'll put your document soemwhere else"
The whole API feels wrong to me. It's breaking rule #1 of technology "You cannot solve a social problem with technology". In this case you have a social/economic problem which is crap code. You solve it with an economics solution - creative incentives not to produce crap code like boxes that keep popping up saying "App XYZ is using all your battery" and red-amber-green powermeter scores in app stores.
That said if you want technical mitigation I think it makes more sense if you look at it from a different starting point. The starting point being this: We have idling logic in the kernel and improving this helps everyone. What is needed to improve the existing logic ?
- You don't know which processes should be ignored for the purpose of suspend (except for kernel threads) and there is no way to set this
- You don't know whether a move from a deep idle to a 'suspend' (which is just a really deep idle in truth anyway) might break wakeups requirements because a device has wake dependencies due to hardware design (eg a port that has no electronics to kick the box out of suspend into running). This is a problem we have already. [1]
That maps onto two existing ideas
Sandboxing/Resource Limits: handling apps that can't be trusted. So the phone runs the appstore code via something like
setpidle(getpid(), something); exec()
where 'something' is a value with meaning to both user space and to the existing idling logic in the kernel that basically says to what extent it is permitted to block idling/suspend. That also seems to tie into some of the realtime + idle problems. This I think deals with Kevin Hillman's thoughts on dealing with untrustworthy app code more cleanly and avoids the need for userspace hackery like the blocker API.
And an entirely in kernel API where device drivers can indicate that in their current situation they require that the power level doesn't drop below some limit unless user requested. This is really important because the platform vendor of the phone/pda/tablet whatever effectively owns the kernel - so it's *their* problem, *their* control, *their* hardware and they can make it work as best for the device. Best of all it means its all free software stuff so if the vendor screws up you can still fix your phone.
Implementation-wise it probably ties into setpidle, its simply that a task has a pair of idle values, a dynamic one and a base one, the dynamic one being the base one but updatable temporarily by drivers.
Alan
--
[1] Note I disagree with Kevin here on static/dynamic power management. There are IMHO two types of PM but they are 'user invoked' and 'automatic'. "Static" simply means it's not been made fast enough yet but its just a policy divide dependant on the users 'acceptable' resume time (which for hard RT may just as well rule out some more usual power states)
Alan,
Quoted 15 lines · Alan Cox
Quoted 7 lines
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
The problem you have is that this is policy. If I have the device wired to a big screen and I want cows bouncing on it I'll be most upset if instead it suspends. What you are essentially arguing for is for the kernel to disobey the userspace. It's as ridiculous (albeit usually less damaging) as a file system saying "Ooh thats a rude file name, the app can't have meant it, I'll put your document soemwhere else"
Quoted 6 lines
The whole API feels wrong to me. It's breaking rule #1 of technology "You cannot solve a social problem with technology". In this case you have a social/economic problem which is crap code. You solve it with an economics solution - creative incentives not to produce crap code like boxes that keep popping up saying "App XYZ is using all your battery" and red-amber-green powermeter scores in app stores.
I completely agree.
We have already proven that the social pressure on crappy applications works. When NOHZ was merged into the kernel we got no effect at all because a big percentage of user space applications just used timers at will and without any thoughts, also it unveiled busy polling and other horrible coding constructs. So what happened ? Arjan created powertop which lets the user analyse the worst offenders in his system. As a result the offending apps got fixed rapidly simply because no maintainer wanted to be on top of the powertop sh*tlist.
In the mobile app space it's basically the same problem. Users can influence the app writers simply by voting and setting up public lists of apps which are crappy or excellent. All it needs is a nice powertop tool for the phone which allows the users to identify the crap on their phones. That provides much more incentive - especially for commercial players - to fix their crappy code.
Adding that sys_try_to_fix_crappy_userspace_code() API to the kernel is just counter productive as it signals to the app provider: Go ahead, keep on coding crap!
That's not a solution, that's just capitulation.
It's absurd that some folks believe that giving up the most efficient tool to apply pressure to crappy app providers is a good idea.
Thanks,
tglx
Alan,
Quoted 15 lines · Alan Cox
Quoted 7 lines
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
The problem you have is that this is policy. If I have the device wired to a big screen and I want cows bouncing on it I'll be most upset if instead it suspends. What you are essentially arguing for is for the kernel to disobey the userspace. It's as ridiculous (albeit usually less damaging) as a file system saying "Ooh thats a rude file name, the app can't have meant it, I'll put your document soemwhere else"
Quoted 6 lines
The whole API feels wrong to me. It's breaking rule #1 of technology "You cannot solve a social problem with technology". In this case you have a social/economic problem which is crap code. You solve it with an economics solution - creative incentives not to produce crap code like boxes that keep popping up saying "App XYZ is using all your battery" and red-amber-green powermeter scores in app stores.
I completely agree.
We have already proven that the social pressure on crappy applications works. When NOHZ was merged into the kernel we got no effect at all because a big percentage of user space applications just used timers at will and without any thoughts, also it unveiled busy polling and other horrible coding constructs. So what happened ? Arjan created powertop which lets the user analyse the worst offenders in his system. As a result the offending apps got fixed rapidly simply because no maintainer wanted to be on top of the powertop sh*tlist.
In the mobile app space it's basically the same problem. Users can influence the app writers simply by voting and setting up public lists of apps which are crappy or excellent. All it needs is a nice powertop tool for the phone which allows the users to identify the crap on their phones. That provides much more incentive - especially for commercial players - to fix their crappy code.
Adding that sys_try_to_fix_crappy_userspace_code() API to the kernel is just counter productive as it signals to the app provider: Go ahead, keep on coding crap!
That's not a solution, that's just capitulation.
It's absurd that some folks believe that giving up the most efficient tool to apply pressure to crappy app providers is a good idea.
Thanks,
tglx
Hi,
Quoted 40 lines · Thomas Gleixner
Quoted 15 lines
Quoted 7 lines
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
The problem you have is that this is policy. If I have the device wired to a big screen and I want cows bouncing on it I'll be most upset if instead it suspends. What you are essentially arguing for is for the kernel to disobey the userspace. It's as ridiculous (albeit usually less damaging) as a file system saying "Ooh thats a rude file name, the app can't have meant it, I'll put your document soemwhere else"
Quoted 6 lines
The whole API feels wrong to me. It's breaking rule #1 of technology "You cannot solve a social problem with technology". In this case you have a social/economic problem which is crap code. You solve it with an economics solution - creative incentives not to produce crap code like boxes that keep popping up saying "App XYZ is using all your battery" and red-amber-green powermeter scores in app stores.
I completely agree.
We have already proven that the social pressure on crappy applications works. When NOHZ was merged into the kernel we got no effect at all because a big percentage of user space applications just used timers at will and without any thoughts, also it unveiled busy polling and other horrible coding constructs. So what happened ? Arjan created powertop which lets the user analyse the worst offenders in his system. As a result the offending apps got fixed rapidly simply because no maintainer wanted to be on top of the powertop sh*tlist.
In the mobile app space it's basically the same problem. Users can influence the app writers simply by voting and setting up public lists of apps which are crappy or excellent. All it needs is a nice powertop tool for the phone which allows the users to identify the crap on their phones. That provides much more incentive - especially for commercial players - to fix their crappy code.
Quoted 8 lines
Adding that
sys_try_to_fix_crappy_userspace_code()API to the kernel is just counter productive as it signals to the app provider: Go ahead, keep on coding crap!That's not a solution, that's just capitulation.
It's absurd that some folks believe that giving up the most efficient tool to apply pressure to crappy app providers is a good idea.
I couldn't agree more with both of you. I also have stated that a powertop application with a fancy UI would do the job. Also building some sort of power estimations on the SDK would allow the developer the have fast feedback about potential power consumption caused by his app on the device.
On top of that, the app stores can use the same power estimation "technology" to rate apps automatically and even reject apps that are waaaay too badly written.
I also feel that kernel shouldn't have to deal, fix, hide bad behavior from apps.
Signature · 1 line
balbi
Hi,
Quoted 40 lines · Thomas Gleixner
Quoted 15 lines
Quoted 7 lines
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
The problem you have is that this is policy. If I have the device wired to a big screen and I want cows bouncing on it I'll be most upset if instead it suspends. What you are essentially arguing for is for the kernel to disobey the userspace. It's as ridiculous (albeit usually less damaging) as a file system saying "Ooh thats a rude file name, the app can't have meant it, I'll put your document soemwhere else"
Quoted 6 lines
The whole API feels wrong to me. It's breaking rule #1 of technology "You cannot solve a social problem with technology". In this case you have a social/economic problem which is crap code. You solve it with an economics solution - creative incentives not to produce crap code like boxes that keep popping up saying "App XYZ is using all your battery" and red-amber-green powermeter scores in app stores.
I completely agree.
We have already proven that the social pressure on crappy applications works. When NOHZ was merged into the kernel we got no effect at all because a big percentage of user space applications just used timers at will and without any thoughts, also it unveiled busy polling and other horrible coding constructs. So what happened ? Arjan created powertop which lets the user analyse the worst offenders in his system. As a result the offending apps got fixed rapidly simply because no maintainer wanted to be on top of the powertop sh*tlist.
In the mobile app space it's basically the same problem. Users can influence the app writers simply by voting and setting up public lists of apps which are crappy or excellent. All it needs is a nice powertop tool for the phone which allows the users to identify the crap on their phones. That provides much more incentive - especially for commercial players - to fix their crappy code.
Quoted 8 lines
Adding that
sys_try_to_fix_crappy_userspace_code()API to the kernel is just counter productive as it signals to the app provider: Go ahead, keep on coding crap!That's not a solution, that's just capitulation.
It's absurd that some folks believe that giving up the most efficient tool to apply pressure to crappy app providers is a good idea.
I couldn't agree more with both of you. I also have stated that a powertop application with a fancy UI would do the job. Also building some sort of power estimations on the SDK would allow the developer the have fast feedback about potential power consumption caused by his app on the device.
On top of that, the app stores can use the same power estimation "technology" to rate apps automatically and even reject apps that are waaaay too badly written.
I also feel that kernel shouldn't have to deal, fix, hide bad behavior from apps.
Signature · 1 line
balbi
Quoted 15 lines · On Wed, 26 May 2010 14:16:12 +0100 Alan Cox <[email protected]> wrote:
Quoted 7 lines
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
The problem you have is that this is policy. If I have the device wired to a big screen and I want cows bouncing on it I'll be most upset if instead it suspends. What you are essentially arguing for is for the kernel to disobey the userspace. It's as ridiculous (albeit usually less damaging) as a file system saying "Ooh thats a rude file name, the app can't have meant it, I'll put your document soemwhere else"
Quoted 6 lines
The whole API feels wrong to me. It's breaking rule #1 of technology "You cannot solve a social problem with technology". In this case you have a social/economic problem which is crap code. You solve it with an economics solution - creative incentives not to produce crap code like boxes that keep popping up saying "App XYZ is using all your battery" and red-amber-green powermeter scores in app stores.
I'm not saying that your argument is not valid. But why don't you look at suspend blockers as a contract between userspace and kernelspace? An Opt-In to the current guarantees the kernel provides in the non-suspend case.
<<If you want to use the rare resource "power" you have to take a suspend blocker. By this you assert that you are a well written application. If you are not well written, you will get the worst of our red-amber-green powermeter scores we have.>>
On the other hand, applications can say, they don't need that much power and userspace guaranties and not take a suspend blocker.
This is an option which they currently don't have.
I don't think opportunistic suspend is a policy decision by the kernel. it is something new. Something which currently only the android userspace implements / supports. If you don't want to suspend while looking at the bouncing-cow, you have to take a suspend blocker and make yourself a user-visible power-eater, or don't do
echo "opportunistic" > /sys/power/policy
in the first place.
This "optionally being badly written, who cares?" is a new feature the kernel can provide to applications.
That said, your proposed alternative implementation scheme looks like another possible approach.
Quoted 38 lines
That said if you want technical mitigation I think it makes more sense if you look at it from a different starting point. The starting point being this: We have idling logic in the kernel and improving this helps everyone. What is needed to improve the existing logic ?
- You don't know which processes should be ignored for the purpose of suspend (except for kernel threads) and there is no way to set this
- You don't know whether a move from a deep idle to a 'suspend' (which is just a really deep idle in truth anyway) might break wakeups requirements because a device has wake dependencies due to hardware design (eg a port that has no electronics to kick the box out of suspend into running). This is a problem we have already. [1]
That maps onto two existing ideas
Sandboxing/Resource Limits: handling apps that can't be trusted. So the phone runs the appstore code via something like
setpidle(getpid(), something); exec()where 'something' is a value with meaning to both user space and to the existing idling logic in the kernel that basically says to what extent it is permitted to block idling/suspend. That also seems to tie into some of the realtime + idle problems. This I think deals with Kevin Hillman's thoughts on dealing with untrustworthy app code more cleanly and avoids the need for userspace hackery like the blocker API.
And an entirely in kernel API where device drivers can indicate that in their current situation they require that the power level doesn't drop below some limit unless user requested. This is really important because the platform vendor of the phone/pda/tablet whatever effectively owns the kernel - so it's *their* problem, *their* control, *their* hardware and they can make it work as best for the device. Best of all it means its all free software stuff so if the vendor screws up you can still fix your phone.
Quoted 5 lines
Implementation-wise it probably ties into setpidle, its simply that a task has a pair of idle values, a dynamic one and a base one, the dynamic one being the base one but updatable temporarily by drivers.
Alan
How does this address the loss of wakeup events while using suspend? (For example the 2 issues formulated by Alan Stern in [1])
cheers,
Flo
[1]http://lkml.org/lkml/2010/5/21/458
p.s.:
dmk@schatten /usr/src/linux $ grep -r "setpidle" . dmk@schatten /usr/src/linux $
Quoted 6 lines · Florian Mickler
Quoted 3 lines
Implementation-wise it probably ties into setpidle, its simply that a task has a pair of idle values, a dynamic one and a base one, the dynamic one being the base one but updatable temporarily by drivers.
How does this address the loss of wakeup events while using suspend? (For example the 2 issues formulated by Alan Stern in [1])
By not suspending obviously.
Quoted 6 lines · Florian Mickler
Quoted 3 lines
Implementation-wise it probably ties into setpidle, its simply that a task has a pair of idle values, a dynamic one and a base one, the dynamic one being the base one but updatable temporarily by drivers.
How does this address the loss of wakeup events while using suspend? (For example the 2 issues formulated by Alan Stern in [1])
By not suspending obviously.
Quoted 4 lines · Florian Mickler
I'm not saying that your argument is not valid. But why don't you look at suspend blockers as a contract between userspace and kernelspace? An Opt-In to the current guarantees the kernel provides in the non-suspend case.
That's backwards.
Quoted 4 lines · Florian Mickler
I'm not saying that your argument is not valid. But why don't you look at suspend blockers as a contract between userspace and kernelspace? An Opt-In to the current guarantees the kernel provides in the non-suspend case.
That's backwards.
Quoted 7 lines · On Wed, 26 May 2010 17:15:47 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Florian Mickler
I'm not saying that your argument is not valid. But why don't you look at suspend blockers as a contract between userspace and kernelspace? An Opt-In to the current guarantees the kernel provides in the non-suspend case.
That's backwards.
I think that's the point of it.
Quoted 4 lines · Florian Mickler
Quoted 1 line · On Wed, 26 May 2010 17:15:47 +0200 Peter Zijlstra <[email protected]> wrote:
On Wed, 2010-05-26 at 17:11 +0200, Florian Mickler wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
I'm not saying that your argument is not valid. But why don't you look at suspend blockers as a contract between userspace and kernelspace? An Opt-In to the current guarantees the kernel provides in the non-suspend case.
That's backwards.
I think that's the point of it.
Apparently, and you're not accepting that we're telling you we think its a singularly bad idea. Alan seems to have the skill to clearly explain why, I suggest you re-read his emails again.
Quoted 10 lines · On Wed, 26 May 2010 17:45:00 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 9 lines · Florian Mickler
Quoted 6 lines · On Wed, 26 May 2010 17:15:47 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Florian Mickler
I'm not saying that your argument is not valid. But why don't you look at suspend blockers as a contract between userspace and kernelspace? An Opt-In to the current guarantees the kernel provides in the non-suspend case.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
That's backwards.
I think that's the point of it.
Apparently, and you're not accepting that we're telling you we think its a singularly bad idea. Alan seems to have the skill to clearly explain why, I suggest you re-read his emails again.
I'm sorry if I offend you. I indeed read Alan's emails. It's just they have more content than yours. So it takes longer.
Cheers,
Flo
Quoted 21 lines · On Wed, 26 May 2010 17:47:35 +0200 Florian Mickler <[email protected]> wrote:
Quoted 10 lines · On Wed, 26 May 2010 17:45:00 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 9 lines · Florian Mickler
Quoted 6 lines · On Wed, 26 May 2010 17:15:47 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Florian Mickler
I'm not saying that your argument is not valid. But why don't you look at suspend blockers as a contract between userspace and kernelspace? An Opt-In to the current guarantees the kernel provides in the non-suspend case.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
That's backwards.
I think that's the point of it.
Apparently, and you're not accepting that we're telling you we think its a singularly bad idea. Alan seems to have the skill to clearly explain why, I suggest you re-read his emails again.
Quoted 5 lines
I'm sorry if I offend you. I indeed read Alan's emails. It's just they have more content than yours. So it takes longer.
Cheers,
Flo
p.s.: also they encourage me to think more before answering.
Quoted 21 lines · On Wed, 26 May 2010 17:47:35 +0200 Florian Mickler <[email protected]> wrote:
Quoted 10 lines · On Wed, 26 May 2010 17:45:00 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 9 lines · Florian Mickler
Quoted 6 lines · On Wed, 26 May 2010 17:15:47 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Florian Mickler
I'm not saying that your argument is not valid. But why don't you look at suspend blockers as a contract between userspace and kernelspace? An Opt-In to the current guarantees the kernel provides in the non-suspend case.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
That's backwards.
I think that's the point of it.
Apparently, and you're not accepting that we're telling you we think its a singularly bad idea. Alan seems to have the skill to clearly explain why, I suggest you re-read his emails again.
Quoted 5 lines
I'm sorry if I offend you. I indeed read Alan's emails. It's just they have more content than yours. So it takes longer.
Cheers,
Flo
p.s.: also they encourage me to think more before answering.
Quoted 10 lines · On Wed, 26 May 2010 17:45:00 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 9 lines · Florian Mickler
Quoted 6 lines · On Wed, 26 May 2010 17:15:47 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Florian Mickler
I'm not saying that your argument is not valid. But why don't you look at suspend blockers as a contract between userspace and kernelspace? An Opt-In to the current guarantees the kernel provides in the non-suspend case.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
That's backwards.
I think that's the point of it.
Apparently, and you're not accepting that we're telling you we think its a singularly bad idea. Alan seems to have the skill to clearly explain why, I suggest you re-read his emails again.
I'm sorry if I offend you. I indeed read Alan's emails. It's just they have more content than yours. So it takes longer.
Cheers,
Flo
Quoted 4 lines · Florian Mickler
Quoted 1 line · On Wed, 26 May 2010 17:15:47 +0200 Peter Zijlstra <[email protected]> wrote:
On Wed, 2010-05-26 at 17:11 +0200, Florian Mickler wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
I'm not saying that your argument is not valid. But why don't you look at suspend blockers as a contract between userspace and kernelspace? An Opt-In to the current guarantees the kernel provides in the non-suspend case.
That's backwards.
I think that's the point of it.
Apparently, and you're not accepting that we're telling you we think its a singularly bad idea. Alan seems to have the skill to clearly explain why, I suggest you re-read his emails again.
Quoted 7 lines · On Wed, 26 May 2010 17:15:47 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Florian Mickler
I'm not saying that your argument is not valid. But why don't you look at suspend blockers as a contract between userspace and kernelspace? An Opt-In to the current guarantees the kernel provides in the non-suspend case.
That's backwards.
I think that's the point of it.
Quoted 6 lines · Florian Mickler
If you don't want to suspend while
looking at the bouncing-cow, you have to take a suspend blocker and make yourself a user-visible power-eater, or don't doecho "opportunistic" >
/sys/power/policy
How about we don't merge that junk and don't give you the opportunity to do silly things like that? :-)
Quoted 6 lines · Florian Mickler
If you don't want to suspend while
looking at the bouncing-cow, you have to take a suspend blocker and make yourself a user-visible power-eater, or don't doecho "opportunistic" >
/sys/power/policy
How about we don't merge that junk and don't give you the opportunity to do silly things like that? :-)
Quoted 4 lines
I'm not saying that your argument is not valid. But why don't you look at suspend blockers as a contract between userspace and kernelspace? An Opt-In to the current guarantees the kernel provides in the non-suspend case.
It is a contract - but not the right one. You are removing autonomy from the kernel when only the kernel can measure the full picture and when the kernel is actually supposed to be responsible for resource management.
Quoted 2 lines
On the other hand, applications can say, they don't need that much power and userspace guaranties and not take a suspend blocker.
Even the the model is wrong.
Quoted 2 lines
I don't think opportunistic suspend is a policy decision by the kernel. it is something new. Something which currently only the android
Disagree. It's an arbitary and misleading divide that happens to reflect a specific vendors current phones. Worse yet it may not reflect their own future products. It assumes for example that their is some power level that is 'suspend' that is singular, application understood and can be effectively user space managed. Big assumptions and not ones that seem to be sensible.
It also breaks another rule - when the hardware changes your application blocker policies will be wrong. Do you want multiple hand optimised copies of each app ? Take a look at what happened to CPU designs where the assumption was you'd recompile the app for each CPU version to get any useful performance.
If you are instead expressing it as "must be able to respond in time X" and "must be able to wake up from an event on an active device" then your interface is generic and hardware independant.
If "bouncing cows" says 'need to wake up every 0.3 seconds" you want the kernel to decide how best to do that. It will vary by hardware. On todays desktop PC thats probably a low power state limit. On some current embedded hardware it might be a special deep sleep mode. On one or two devices it might be 'suspend'. It might also be that the properties have been set to 2 seconds already so it gets told it can't have 0.3.
The app cannot be allowed to know platform specific stuff or your portability comes apart and you end up with a disaster area where each app only comes on a subset of devices. Express the requirement right and you get a simple clean interface that continues to work.
Express it wrong and you get a mess.
Quoted 3 lines
userspace implements / supports. If you don't want to suspend while looking at the bouncing-cow, you have to take a suspend blocker and make yourself a user-visible power-eater, or don't do
Thats a very big hammer and it doesn't express what I actually want, which is to allow the cows to run as efficiently as possible.
Quoted 4 lines
echo "opportunistic" >
/sys/power/policyin the first place.
But you can do this properly by having a per process idle requirement, and that can encompass things like hard real time as well (or even gaming). The suspend blockers break all the global policy, don't solve real time and don't allow for sensible expansion models. They don't solve our existing wakeup versus device problems either.
Quoted 2 lines
How does this address the loss of wakeup events while using suspend? (For example the 2 issues formulated by Alan Stern in [1])
In this environment the problem cannot occur in the first place unless there are kernel code bugs, if there are then they are in GPL code and can be fixed. But you are mixing up interfaces and implementations which I find is usually a bad idea. Doing the right thing badly gives you an interface to an implementation you can later fix. Doing the wrong thing well leaves you stuck down a hole.
Quoted 2 lines
p.s.:
dmk@schatten/usr/src/linux$ grep -r "setpidle" .
Yes I know - no point having a new function which has an in use name is there ? It's trivial to add per process idling or wakeup requirements.
Alan
Quoted 4 lines
I'm not saying that your argument is not valid. But why don't you look at suspend blockers as a contract between userspace and kernelspace? An Opt-In to the current guarantees the kernel provides in the non-suspend case.
It is a contract - but not the right one. You are removing autonomy from the kernel when only the kernel can measure the full picture and when the kernel is actually supposed to be responsible for resource management.
Quoted 2 lines
On the other hand, applications can say, they don't need that much power and userspace guaranties and not take a suspend blocker.
Even the the model is wrong.
Quoted 2 lines
I don't think opportunistic suspend is a policy decision by the kernel. it is something new. Something which currently only the android
Disagree. It's an arbitary and misleading divide that happens to reflect a specific vendors current phones. Worse yet it may not reflect their own future products. It assumes for example that their is some power level that is 'suspend' that is singular, application understood and can be effectively user space managed. Big assumptions and not ones that seem to be sensible.
It also breaks another rule - when the hardware changes your application blocker policies will be wrong. Do you want multiple hand optimised copies of each app ? Take a look at what happened to CPU designs where the assumption was you'd recompile the app for each CPU version to get any useful performance.
If you are instead expressing it as "must be able to respond in time X" and "must be able to wake up from an event on an active device" then your interface is generic and hardware independant.
If "bouncing cows" says 'need to wake up every 0.3 seconds" you want the kernel to decide how best to do that. It will vary by hardware. On todays desktop PC thats probably a low power state limit. On some current embedded hardware it might be a special deep sleep mode. On one or two devices it might be 'suspend'. It might also be that the properties have been set to 2 seconds already so it gets told it can't have 0.3.
The app cannot be allowed to know platform specific stuff or your portability comes apart and you end up with a disaster area where each app only comes on a subset of devices. Express the requirement right and you get a simple clean interface that continues to work.
Express it wrong and you get a mess.
Quoted 3 lines
userspace implements / supports. If you don't want to suspend while looking at the bouncing-cow, you have to take a suspend blocker and make yourself a user-visible power-eater, or don't do
Thats a very big hammer and it doesn't express what I actually want, which is to allow the cows to run as efficiently as possible.
Quoted 4 lines
echo "opportunistic" >
/sys/power/policyin the first place.
But you can do this properly by having a per process idle requirement, and that can encompass things like hard real time as well (or even gaming). The suspend blockers break all the global policy, don't solve real time and don't allow for sensible expansion models. They don't solve our existing wakeup versus device problems either.
Quoted 2 lines
How does this address the loss of wakeup events while using suspend? (For example the 2 issues formulated by Alan Stern in [1])
In this environment the problem cannot occur in the first place unless there are kernel code bugs, if there are then they are in GPL code and can be fixed. But you are mixing up interfaces and implementations which I find is usually a bad idea. Doing the right thing badly gives you an interface to an implementation you can later fix. Doing the wrong thing well leaves you stuck down a hole.
Quoted 2 lines
p.s.:
dmk@schatten/usr/src/linux$ grep -r "setpidle" .
Yes I know - no point having a new function which has an in use name is there ? It's trivial to add per process idling or wakeup requirements.
Alan
Florian,
Quoted 5 lines · Florian Mickler
On the other hand, applications can say, they don't need that much power and userspace guaranties and not take a suspend blocker.
This is an option which they currently don't have.
Wrong. A well coded power aware application is very well able to express that in various ways already today. Admittedly it's far from perfect, but that can be fixed by adding interfaces which allow the power aware coder to express the requirements of his application actively, not by avoiding it.
suspend blockers are completely backwards as they basically disable the kernels ability to do resource management.
Also they enforce a black and white scheme (suspend or run) on the kernel which is stupid, as there are more options to efficiently save power than those two. While current android devices might not provide them, later hardware will have it and any atom based device has them already.
So what the kernel needs to know to make better decisions are things like:
- how much slack can timers have (exisiting interface)
- how much delay of wakeups is tolerated (missing interface)
and probably some others. That information would allow the kernel to make better decisions versus power states, grouping timers, race to idle and other things which influence the power consumption based on the hardware you are running on.
Quoted 6 lines
I don't think opportunistic suspend is a policy decision by the kernel. it is something new. Something which currently only the android userspace implements / supports. If you don't want to suspend while looking at the bouncing-cow, you have to take a suspend blocker and make yourself a user-visible power-eater, or don't do
Quoted 6 lines
echo "opportunistic" >
/sys/power/policyin the first place.
This "optionally being badly written, who cares?" is a new feature the kernel can provide to applications.
It's a misfeature which the kernel should not provide at all. It sends out the completely wrong message: Hey, we can deal with your crappy code, keep on coding that way.
While this seems to sound cool to certain people in the mobile space, it's completely backwards and will backfire in no time.
The power efficiency of a mobile device is depending on a sane overall software stack and not on the ability to mitigate crappy software in some obscure way which is prone to malfunction and disappoint users.
Thanks,
tglx
Quoted 3 lines
The power efficiency of a mobile device is depending on a sane overall software stack and not on the ability to mitigate crappy software in some obscure way which is prone to malfunction and disappoint users.
Even if you believe the kernel should be containing junk the model that works and is used for everything else is resource management. Not giving various tasks the ability to override rules, otherwise you end up needing suspend blocker blockers next week.
A model based on the idea that a task can set its desired wakeup behaviour *subject to hard limits* (ie soft/hard process wakeup) works both for the sane system where its elegantly managing hard RT, and for the crud where you sandbox it to stop it making a nasty mess.
Do we even need a syscall or will adding RLIMIT_WAKEUP or similar do the trick ?
Alan
Quoted 14 lines · On Wed, 26 May 2010 19:02:04 +0100 Alan Cox <[email protected]> wrote:
Quoted 3 lines
The power efficiency of a mobile device is depending on a sane overall software stack and not on the ability to mitigate crappy software in some obscure way which is prone to malfunction and disappoint users.
Even if you believe the kernel should be containing junk the model that works and is used for everything else is resource management. Not giving various tasks the ability to override rules, otherwise you end up needing suspend blocker blockers next week.
A model based on the idea that a task can set its desired wakeup behaviour *subject to hard limits* (ie soft/hard process wakeup) works both for the sane system where its elegantly managing hard RT, and for the crud where you sandbox it to stop it making a nasty mess.
Quoted 4 lines
Do we even need a syscall or will adding
RLIMIT_WAKEUPor similar do the trick ?Alan
Your approach definitely sounds better than the current solution. What about mapping suspend blocker functionality later on, when this interface exists, on to this new approach and deprecating it?
Cheers,
Flo
Quoted 14 lines · On Wed, 26 May 2010 19:02:04 +0100 Alan Cox <[email protected]> wrote:
Quoted 3 lines
The power efficiency of a mobile device is depending on a sane overall software stack and not on the ability to mitigate crappy software in some obscure way which is prone to malfunction and disappoint users.
Even if you believe the kernel should be containing junk the model that works and is used for everything else is resource management. Not giving various tasks the ability to override rules, otherwise you end up needing suspend blocker blockers next week.
A model based on the idea that a task can set its desired wakeup behaviour *subject to hard limits* (ie soft/hard process wakeup) works both for the sane system where its elegantly managing hard RT, and for the crud where you sandbox it to stop it making a nasty mess.
Quoted 4 lines
Do we even need a syscall or will adding
RLIMIT_WAKEUPor similar do the trick ?Alan
Your approach definitely sounds better than the current solution. What about mapping suspend blocker functionality later on, when this interface exists, on to this new approach and deprecating it?
Cheers,
Flo
Quoted 3 lines · Florian Mickler
Your approach definitely sounds better than the current solution. What about mapping suspend blocker functionality later on, when this interface exists, on to this new approach and deprecating it?
What about coming back after some while with the appropriate solution when it's ready instead of stubbornly pushing crap?
~Vitaly
Quoted 3 lines · Florian Mickler
Your approach definitely sounds better than the current solution. What about mapping suspend blocker functionality later on, when this interface exists, on to this new approach and deprecating it?
What about coming back after some while with the appropriate solution when it's ready instead of stubbornly pushing crap?
~Vitaly
Quoted 10 lines · On Wed, 26 May 2010 22:03:37 +0200 Vitaly Wool <[email protected]> wrote:
Quoted 3 lines · Florian Mickler
Your approach definitely sounds better than the current solution. What about mapping suspend blocker functionality later on, when this interface exists, on to this new approach and deprecating it?
What about coming back after some while with the appropriate solution when it's ready instead of stubbornly pushing crap?
~Vitaly
Because quite frankly, for a good part of linux users, suspend blockers is already in the kernel. It's just an historical mistake that they are not in the linux kernel's hosted on kernel.org.
So why don't we do what we always do? Improve existing interfaces step by step?
Top Down approaches fail from time to time. Also it is not clear, that that proposed interface works for the use cases. This has to be proven by providing an implementation.
Cheers,
Flo
Quoted 9 lines · Florian Mickler
Quoted 6 lines · On Wed, 26 May 2010 22:03:37 +0200 Vitaly Wool <[email protected]> wrote:
Quoted 3 lines · Florian Mickler
Your approach definitely sounds better than the current solution. What about mapping suspend blocker functionality later on, when this interface exists, on to this new approach and deprecating it?
Quoted 8 lines
Quoted 4 lines
What about coming back after some while with the appropriate solution when it's ready instead of stubbornly pushing crap?
~Vitaly
Because quite frankly, for a good part of linux users, suspend blockers is already in the kernel. It's just an historical mistake that they are not in the linux kernel's hosted on kernel.org.
No, it's not a historical mistake. It's a technical decision _NOT_ to merge crap. If we would accept every crappy patch which gets shipped in large quantities as a defacto part of the kernel we would have a completely unmaintainable mess since years.
Quoted 2 lines
So why don't we do what we always do? Improve existing interfaces step by step?
Exactly, that's what we are going to do. We improve and extend existing interfaces step by step, but not by creating a horrible and unmaintainable mess in the frist place which we can never get rid of anymore.
Quoted 3 lines
Top Down approaches fail from time to time. Also it is not clear, that that proposed interface works for the use cases. This has to be proven by providing an implementation.
Nobody prevents you to sit down and start with a prove of concept implementation.
Thanks,
tglx
Quoted 24 lines · On Thu, 27 May 2010 15:35:18 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 9 lines · Florian Mickler
Quoted 6 lines · On Wed, 26 May 2010 22:03:37 +0200 Vitaly Wool <[email protected]> wrote:
Quoted 3 lines · Florian Mickler
Your approach definitely sounds better than the current solution. What about mapping suspend blocker functionality later on, when this interface exists, on to this new approach and deprecating it?
Quoted 8 lines
Quoted 4 lines
What about coming back after some while with the appropriate solution when it's ready instead of stubbornly pushing crap?
~Vitaly
Because quite frankly, for a good part of linux users, suspend blockers is already in the kernel. It's just an historical mistake that they are not in the linux kernel's hosted on kernel.org.
No, it's not a historical mistake. It's a technical decision _NOT_ to merge crap. If we would accept every crappy patch which gets shipped in large quantities as a defacto part of the kernel we would have a completely unmaintainable mess since years.
Quoted 7 lines
Quoted 2 lines
So why don't we do what we always do? Improve existing interfaces step by step?
Exactly, that's what we are going to do. We improve and extend existing interfaces step by step, but not by creating a horrible and unmaintainable mess in the frist place which we can never get rid of anymore.
Ok to your two paragraphs. I can understand this.
Nonetheless, i'm convinced that there has to be some solution in mainline to allow for what android does. But perhaps it needs more refactoring and piggybagging on some more general constraint interface.
Quoted 7 lines
Quoted 4 lines
Top Down approaches fail from time to time. Also it is not clear, that that proposed interface works for the use cases. This has to be proven by providing an implementation.
Nobody prevents you to sit down and start with a prove of concept implementation.
Hmm... *scratch*... *lookaround* .. who?
Really, I'd first like to get the whole picture before doing anything.
Quoted 4 lines
Thanks,
tglx
Quoted 24 lines · On Thu, 27 May 2010 15:35:18 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 9 lines · Florian Mickler
Quoted 6 lines · On Wed, 26 May 2010 22:03:37 +0200 Vitaly Wool <[email protected]> wrote:
Quoted 3 lines · Florian Mickler
Your approach definitely sounds better than the current solution. What about mapping suspend blocker functionality later on, when this interface exists, on to this new approach and deprecating it?
Quoted 8 lines
Quoted 4 lines
What about coming back after some while with the appropriate solution when it's ready instead of stubbornly pushing crap?
~Vitaly
Because quite frankly, for a good part of linux users, suspend blockers is already in the kernel. It's just an historical mistake that they are not in the linux kernel's hosted on kernel.org.
No, it's not a historical mistake. It's a technical decision _NOT_ to merge crap. If we would accept every crappy patch which gets shipped in large quantities as a defacto part of the kernel we would have a completely unmaintainable mess since years.
Quoted 7 lines
Quoted 2 lines
So why don't we do what we always do? Improve existing interfaces step by step?
Exactly, that's what we are going to do. We improve and extend existing interfaces step by step, but not by creating a horrible and unmaintainable mess in the frist place which we can never get rid of anymore.
Ok to your two paragraphs. I can understand this.
Nonetheless, i'm convinced that there has to be some solution in mainline to allow for what android does. But perhaps it needs more refactoring and piggybagging on some more general constraint interface.
Quoted 7 lines
Quoted 4 lines
Top Down approaches fail from time to time. Also it is not clear, that that proposed interface works for the use cases. This has to be proven by providing an implementation.
Nobody prevents you to sit down and start with a prove of concept implementation.
Hmm... *scratch*... *lookaround* .. who?
Really, I'd first like to get the whole picture before doing anything.
Quoted 4 lines
Thanks,
tglx
Quoted 9 lines · Florian Mickler
Quoted 6 lines · On Wed, 26 May 2010 22:03:37 +0200 Vitaly Wool <[email protected]> wrote:
Quoted 3 lines · Florian Mickler
Your approach definitely sounds better than the current solution. What about mapping suspend blocker functionality later on, when this interface exists, on to this new approach and deprecating it?
Quoted 8 lines
Quoted 4 lines
What about coming back after some while with the appropriate solution when it's ready instead of stubbornly pushing crap?
~Vitaly
Because quite frankly, for a good part of linux users, suspend blockers is already in the kernel. It's just an historical mistake that they are not in the linux kernel's hosted on kernel.org.
No, it's not a historical mistake. It's a technical decision _NOT_ to merge crap. If we would accept every crappy patch which gets shipped in large quantities as a defacto part of the kernel we would have a completely unmaintainable mess since years.
Quoted 2 lines
So why don't we do what we always do? Improve existing interfaces step by step?
Exactly, that's what we are going to do. We improve and extend existing interfaces step by step, but not by creating a horrible and unmaintainable mess in the frist place which we can never get rid of anymore.
Quoted 3 lines
Top Down approaches fail from time to time. Also it is not clear, that that proposed interface works for the use cases. This has to be proven by providing an implementation.
Nobody prevents you to sit down and start with a prove of concept implementation.
Thanks,
tglx
Quoted 10 lines · On Wed, 26 May 2010 22:03:37 +0200 Vitaly Wool <[email protected]> wrote:
Quoted 3 lines · Florian Mickler
Your approach definitely sounds better than the current solution. What about mapping suspend blocker functionality later on, when this interface exists, on to this new approach and deprecating it?
What about coming back after some while with the appropriate solution when it's ready instead of stubbornly pushing crap?
~Vitaly
Because quite frankly, for a good part of linux users, suspend blockers is already in the kernel. It's just an historical mistake that they are not in the linux kernel's hosted on kernel.org.
So why don't we do what we always do? Improve existing interfaces step by step?
Top Down approaches fail from time to time. Also it is not clear, that that proposed interface works for the use cases. This has to be proven by providing an implementation.
Cheers,
Flo
Quoted 8 lines · Alan Cox
Quoted 3 lines
The power efficiency of a mobile device is depending on a sane overall software stack and not on the ability to mitigate crappy software in some obscure way which is prone to malfunction and disappoint users.
Even if you believe the kernel should be containing junk the model that works and is used for everything else is resource management. Not giving various tasks the ability to override rules, otherwise you end up needing suspend blocker blockers next week.
We definitely will need them when we want to optimize the kernel resource management on a QoS based scheme, which is the only sensible way to go IMNSHO.
Quoted 4 lines
A model based on the idea that a task can set its desired wakeup behaviour *subject to hard limits* (ie soft/hard process wakeup) works both for the sane system where its elegantly managing hard RT, and for the crud where you sandbox it to stop it making a nasty mess.
Right, the base system can set sensible defaults for "verified" apps, which will work most of the time except for those which have special requirements and need a skilled coder anyway. And for the sandbox crud the sensible default can be "very long time" and allow the kernel to ignore them at will.
Quoted 2 lines
Do we even need a syscall or will adding
RLIMIT_WAKEUPor similar do the trick ?
That might be a good starting point.
Thanks,
tglx
Quoted 8 lines · Alan Cox
Quoted 3 lines
The power efficiency of a mobile device is depending on a sane overall software stack and not on the ability to mitigate crappy software in some obscure way which is prone to malfunction and disappoint users.
Even if you believe the kernel should be containing junk the model that works and is used for everything else is resource management. Not giving various tasks the ability to override rules, otherwise you end up needing suspend blocker blockers next week.
We definitely will need them when we want to optimize the kernel resource management on a QoS based scheme, which is the only sensible way to go IMNSHO.
Quoted 4 lines
A model based on the idea that a task can set its desired wakeup behaviour *subject to hard limits* (ie soft/hard process wakeup) works both for the sane system where its elegantly managing hard RT, and for the crud where you sandbox it to stop it making a nasty mess.
Right, the base system can set sensible defaults for "verified" apps, which will work most of the time except for those which have special requirements and need a skilled coder anyway. And for the sandbox crud the sensible default can be "very long time" and allow the kernel to ignore them at will.
Quoted 2 lines
Do we even need a syscall or will adding
RLIMIT_WAKEUPor similar do the trick ?
That might be a good starting point.
Thanks,
tglx
Quoted 3 lines
The power efficiency of a mobile device is depending on a sane overall software stack and not on the ability to mitigate crappy software in some obscure way which is prone to malfunction and disappoint users.
Even if you believe the kernel should be containing junk the model that works and is used for everything else is resource management. Not giving various tasks the ability to override rules, otherwise you end up needing suspend blocker blockers next week.
A model based on the idea that a task can set its desired wakeup behaviour *subject to hard limits* (ie soft/hard process wakeup) works both for the sane system where its elegantly managing hard RT, and for the crud where you sandbox it to stop it making a nasty mess.
Do we even need a syscall or will adding RLIMIT_WAKEUP or similar do the trick ?
Alan
Quoted 7 lines · On Wed, 26 May 2010 19:22:16 +0200 (CEST) Thomas Gleixner <[email protected]>…
Florian,
Quoted 4 lines · Florian Mickler
On the other hand, applications can say, they don't need that much power and userspace guaranties and not take a suspend blocker.
Quoted 7 lines
Quoted 1 line
This is an option which they currently don't have.
Wrong. A well coded power aware application is very well able to express that in various ways already today. Admittedly it's far from perfect, but that can be fixed by adding interfaces which allow the power aware coder to express the requirements of his application actively, not by avoiding it.
Yeah, but a user can't say: "I don't
know programming, but I had this idea. Here try it out." to his friend. Because his friends phone then will crap out.
This is a negative. The phone just doesn't work well.
A knowledgeable programmer is able to do extra work to enable specific guarantees. A dummy-throw-away-programmer doesn't want to do any extra work.
Quoted 3 lines
suspend blockers are completely backwards as they basically disable the kernels ability to do resource management.
I don't think this is a defect in the approach but the point of it.
Quoted 6 lines
Also they enforce a black and white scheme (suspend or run) on the kernel which is stupid, as there are more options to efficiently save power than those two. While current android devices might not provide them, later hardware will have it and any atom based device has them already.
This is true. Nonetheless, in my opinion, implementing the "backwards approach" in any form (suspend blockers or some other sort of "sane" interface) is necessary in the long run. I also believe that Alan's approach is the more flexible one. But I'm not in a position to judge on this.
If it really is better and superior, I think userland will switch over to it, as soon as it is possible to do it. The impact to the drivers code is needed anyway. What looses the kernel by implementing suspend blockers, and later a more finegrained approach and mapping the userspace part of suspend blockers on that finegrained approach later on?
Quoted 5 lines
So what the kernel needs to know to make better decisions are things like:
- how much slack can timers have (exisiting interface)
I liked this idea of Arjan, to give some applications infinite timer slack. But I don't know if it can made work in a "dummy proof" way. (I.e. it is too complicated to get it right in general, except for the "infinity" or not kind of tuning)
Quoted 1 line
- how much delay of wakeups is tolerated (missing interface)
Doesn't solve the segregation problem and is probably overkill for most applications. I see this as an orthogonal thing (i.e. not affecting this merge).
Quoted 14 lines
and probably some others. That information would allow the kernel to make better decisions versus power states, grouping timers, race to idle and other things which influence the power consumption based on the hardware you are running on.
Quoted 8 lines
I don't think opportunistic suspend is a policy decision by the kernel. it is something new. Something which currently only the android userspace implements / supports. If you don't want to suspend while looking at the bouncing-cow, you have to take a suspend blocker and make yourself a user-visible power-eater, or don't do
echo "opportunistic" >
/sys/power/policy
Quoted 8 lines
Quoted 4 lines
in the first place.
This "optionally being badly written, who cares?" is a new feature the kernel can provide to applications.
It's a misfeature which the kernel should not provide at all. It sends out the completely wrong message: Hey, we can deal with your crappy code, keep on coding that way.
I can't really say anything against that. Or anything in favor of it. Except that this is probably a really hard decision for Linus to make.
Quoted 3 lines
While this seems to sound cool to certain people in the mobile space, it's completely backwards and will backfire in no time.
Maybe. It is something which seems to not come from the traditional "linux distribution" model of software deployment, where you have a party that codes and another party that packages that code.
It instead is more targeted at the decentralised 3rd-party-app approach under which windows is suffering.
Quoted 3 lines
The power efficiency of a mobile device is depending on a sane overall software stack and not on the ability to mitigate crappy software in some obscure way which is prone to malfunction and disappoint users.
True. But I wouldnt say, that it is the linux kernel who should force this politics onto its users.
Quoted 4 lines
Thanks,
tglx
Quoted 4 lines
Quoted 2 lines
suspend blockers are completely backwards as they basically disable the kernels ability to do resource management.
I don't think this is a defect in the approach but the point of it.
I think it's both. It's the point of it, and that itself is a defect. Its designed wrongly.
Quoted 4 lines
drivers code is needed anyway. What looses the kernel by implementing suspend blockers, and later a more finegrained approach and mapping the userspace part of suspend blockers on that finegrained approach later on?
The Linux approach is to do the job right. That means getting the interface right and so it works across all the interested parties (or as close as we can get).
Quoted 5 lines
Quoted 1 line
- how much delay of wakeups is tolerated (missing interface)
Doesn't solve the segregation problem and is probably overkill for most applications. I see this as an orthogonal thing (i.e. not affecting this merge).
The key question that matters for suspend management is 'what wakeup delay is tolerated'. So it's absolutely fundamental.
Quoted 2 lines
True. But I wouldnt say, that it is the linux kernel who should force this politics onto its users.
This is the Linux way of doing things. It's like the GPL and being shouted at by Linus. They are things you accept when you choose to take part. Google chose to use Linux, if they want a feature upstream then the way you get it there is to figure out how to solve the real problem and make *everyone* (within reason) happy.
We now have suggestions how to do the job properly so the right thing is probably to go and explore those suggestions not merge crap.
Merging crap won't help anyway. The rest of the kernel community can still simply stonewall those interfaces, and a volunteer community has ways of dealing with abuse of process, notably by simply not getting around to, or implementing things directly contrary to the crap bits.
So it's not even in the interest of people to play political games. Even if you get away with in the short term the people who rely on the junk will end up out on a limb and holding the baby when the crap hits the fan (see reiserfs)
Alan
Quoted 8 lines · On Wed, 26 May 2010 23:09:43 +0100 Alan Cox <[email protected]> wrote:
We now have suggestions how to do the job properly so the right thing is probably to go and explore those suggestions not merge crap.
Merging crap won't help anyway. The rest of the kernel community can still simply stonewall those interfaces, and a volunteer community has ways of dealing with abuse of process, notably by simply not getting around to, or implementing things directly contrary to the crap bits.
Quoted 6 lines
So it's not even in the interest of people to play political games. Even if you get away with in the short term the people who rely on the junk will end up out on a limb and holding the baby when the crap hits the fan (see reiserfs)
Alan
I'm not interested in "abusing processes". I just think, this is in limbo for too long already.
Just decide something. One way or the other. The world will continue.
Cheers,
Flo
Quoted 8 lines · On Wed, 26 May 2010 23:09:43 +0100 Alan Cox <[email protected]> wrote:
We now have suggestions how to do the job properly so the right thing is probably to go and explore those suggestions not merge crap.
Merging crap won't help anyway. The rest of the kernel community can still simply stonewall those interfaces, and a volunteer community has ways of dealing with abuse of process, notably by simply not getting around to, or implementing things directly contrary to the crap bits.
Quoted 6 lines
So it's not even in the interest of people to play political games. Even if you get away with in the short term the people who rely on the junk will end up out on a limb and holding the baby when the crap hits the fan (see reiserfs)
Alan
I'm not interested in "abusing processes". I just think, this is in limbo for too long already.
Just decide something. One way or the other. The world will continue.
Cheers,
Flo
Quoted 3 lines · Florian Mickler
I'm not interested in "abusing processes". I just think, this is in limbo for too long already.
Just decide something. One way or the other. The world will continue.
Oh man, you rule the world eh? :)
~Vitaly
Quoted 3 lines · Florian Mickler
I'm not interested in "abusing processes". I just think, this is in limbo for too long already.
Just decide something. One way or the other. The world will continue.
Oh man, you rule the world eh? :)
~Vitaly
Quoted 4 lines
Quoted 2 lines
suspend blockers are completely backwards as they basically disable the kernels ability to do resource management.
I don't think this is a defect in the approach but the point of it.
I think it's both. It's the point of it, and that itself is a defect. Its designed wrongly.
Quoted 4 lines
drivers code is needed anyway. What looses the kernel by implementing suspend blockers, and later a more finegrained approach and mapping the userspace part of suspend blockers on that finegrained approach later on?
The Linux approach is to do the job right. That means getting the interface right and so it works across all the interested parties (or as close as we can get).
Quoted 5 lines
Quoted 1 line
- how much delay of wakeups is tolerated (missing interface)
Doesn't solve the segregation problem and is probably overkill for most applications. I see this as an orthogonal thing (i.e. not affecting this merge).
The key question that matters for suspend management is 'what wakeup delay is tolerated'. So it's absolutely fundamental.
Quoted 2 lines
True. But I wouldnt say, that it is the linux kernel who should force this politics onto its users.
This is the Linux way of doing things. It's like the GPL and being shouted at by Linus. They are things you accept when you choose to take part. Google chose to use Linux, if they want a feature upstream then the way you get it there is to figure out how to solve the real problem and make *everyone* (within reason) happy.
We now have suggestions how to do the job properly so the right thing is probably to go and explore those suggestions not merge crap.
Merging crap won't help anyway. The rest of the kernel community can still simply stonewall those interfaces, and a volunteer community has ways of dealing with abuse of process, notably by simply not getting around to, or implementing things directly contrary to the crap bits.
So it's not even in the interest of people to play political games. Even if you get away with in the short term the people who rely on the junk will end up out on a limb and holding the baby when the crap hits the fan (see reiserfs)
Alan
Quoted 19 lines · Florian Mickler
Quoted 5 lines · On Wed, 26 May 2010 19:22:16 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 4 lines · Florian Mickler
On the other hand, applications can say, they don't need that much power and userspace guaranties and not take a suspend blocker.
Quoted 7 lines
Quoted 1 line
This is an option which they currently don't have.
Wrong. A well coded power aware application is very well able to express that in various ways already today. Admittedly it's far from perfect, but that can be fixed by adding interfaces which allow the power aware coder to express the requirements of his application actively, not by avoiding it.
Yeah, but a user can't say: "I don't
know programming, but I had this idea. Here try it out." to his friend. Because his friends phone then will crap out.
Quoted 5 lines
This is a negative. The phone just doesn't work well.
A knowledgeable programmer is able to do extra work to enable specific guarantees. A dummy-throw-away-programmer doesn't want to do any extra work.
Trying to solve that inside the kernel is the patently wrong approach. The only way to give Joe Clicker the ability to "code" his idea is to give him a restricted sandbox environment which takes care of the extra work and is created by knowledgable programmers with the Joe Clickers in mind.
Every Joe Clicker can "code" websites and does this happily in his sandbox which consists of a web server and a web application framework. There is no single line of code in the kernel to make this work.
As I said before we need new interfaces and new technologies to let the kernel do better power management, but definitely not a big hammer approach which is actively preventing the kernel to do smarter decisions.
The correct approach is QoS based and everything else is just a bandaid which is going to hurt us badly.
Quoted 5 lines
Quoted 3 lines
suspend blockers are completely backwards as they basically disable the kernels ability to do resource management.
I don't think this is a defect in the approach but the point of it.
I know that this is the point of the approach, but that does not make it less wrong. Me, Alan and others explained already in great length why it is the wrong approach, but you refuse to listen.
You remind me of my 14 year old son, who argues in circles to convince me that I must allow him something which is wrong. And if he would think about it w/o his primary goal of getting permission in mind he would concede that it's wrong.
Quoted 13 lines
Quoted 6 lines
Also they enforce a black and white scheme (suspend or run) on the kernel which is stupid, as there are more options to efficiently save power than those two. While current android devices might not provide them, later hardware will have it and any atom based device has them already.
This is true. Nonetheless, in my opinion, implementing the "backwards approach" in any form (suspend blockers or some other sort of "sane" interface) is necessary in the long run. I also believe that Alan's approach is the more flexible one. But I'm not in a position to judge on this.
Quoted 6 lines
If it really is better and superior, I think userland will switch over to it, as soon as it is possible to do it. The impact to the drivers code is needed anyway. What looses the kernel by implementing suspend blockers, and later a more finegrained approach and mapping the userspace part of suspend blockers on that finegrained approach later on?
The kernel loses the ability to remove suspend blockers once the interface is exposed to user space. That's the whole point. We would have to carry it on for a long time and trying to work around it when implementing a technical correct approach.
And we have never seen crap move to a better interface. It will stay there forever and hell will break lose when we break it.
Quoted 9 lines
Quoted 4 lines
So what the kernel needs to know to make better decisions are things like:
- how much slack can timers have (exisiting interface)
I liked this idea of Arjan, to give some applications infinite timer slack. But I don't know if it can made work in a "dummy proof" way. (I.e. it is too complicated to get it right in general, except for the "infinity" or not kind of tuning)
A mobile device can implement sensible defaults for the careless applications and let the "good" apps override them.
Quoted 3 lines
Quoted 1 line
- how much delay of wakeups is tolerated (missing interface)
Doesn't solve the segregation problem and is probably overkill for most
It solves the segregration problem quite nicely, as again it can be set to sensible defaults and to "very long" for the non verified apps.
Quoted 2 lines
applications. I see this as an orthogonal thing (i.e. not affecting this merge).
It's not orthogonal, it's essential to do QoS based power management, which is the only sensible technical solution to do, as it allows the kernel to optimize in various areas while at the same time guaranteeing the response time to applications which require them.
Blockers are not orthogonal at all, as they actively prevent clever decisions.
Quoted 6 lines
Quoted 3 lines
The power efficiency of a mobile device is depending on a sane overall software stack and not on the ability to mitigate crappy software in some obscure way which is prone to malfunction and disappoint users.
True. But I wouldnt say, that it is the linux kernel who should force this politics onto its users.
The kernel does not make politics. You and the folks who are pushing that blockers stuff with all might are making politics on the ground of a very bad argument. It does not matter at all whether android ships that blockers or not, it neither matters whether android folks consider this to be the best invention since sliced bread.
The only thing which matters is technical sanity of the approach and the maintainability of it. And none of those is given.
Thanks,
tglx
Quoted 19 lines · Florian Mickler
Quoted 5 lines · On Wed, 26 May 2010 19:22:16 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 4 lines · Florian Mickler
On the other hand, applications can say, they don't need that much power and userspace guaranties and not take a suspend blocker.
Quoted 7 lines
Quoted 1 line
This is an option which they currently don't have.
Wrong. A well coded power aware application is very well able to express that in various ways already today. Admittedly it's far from perfect, but that can be fixed by adding interfaces which allow the power aware coder to express the requirements of his application actively, not by avoiding it.
Yeah, but a user can't say: "I don't
know programming, but I had this idea. Here try it out." to his friend. Because his friends phone then will crap out.
Quoted 5 lines
This is a negative. The phone just doesn't work well.
A knowledgeable programmer is able to do extra work to enable specific guarantees. A dummy-throw-away-programmer doesn't want to do any extra work.
Trying to solve that inside the kernel is the patently wrong approach. The only way to give Joe Clicker the ability to "code" his idea is to give him a restricted sandbox environment which takes care of the extra work and is created by knowledgable programmers with the Joe Clickers in mind.
Every Joe Clicker can "code" websites and does this happily in his sandbox which consists of a web server and a web application framework. There is no single line of code in the kernel to make this work.
As I said before we need new interfaces and new technologies to let the kernel do better power management, but definitely not a big hammer approach which is actively preventing the kernel to do smarter decisions.
The correct approach is QoS based and everything else is just a bandaid which is going to hurt us badly.
Quoted 5 lines
Quoted 3 lines
suspend blockers are completely backwards as they basically disable the kernels ability to do resource management.
I don't think this is a defect in the approach but the point of it.
I know that this is the point of the approach, but that does not make it less wrong. Me, Alan and others explained already in great length why it is the wrong approach, but you refuse to listen.
You remind me of my 14 year old son, who argues in circles to convince me that I must allow him something which is wrong. And if he would think about it w/o his primary goal of getting permission in mind he would concede that it's wrong.
Quoted 13 lines
Quoted 6 lines
Also they enforce a black and white scheme (suspend or run) on the kernel which is stupid, as there are more options to efficiently save power than those two. While current android devices might not provide them, later hardware will have it and any atom based device has them already.
This is true. Nonetheless, in my opinion, implementing the "backwards approach" in any form (suspend blockers or some other sort of "sane" interface) is necessary in the long run. I also believe that Alan's approach is the more flexible one. But I'm not in a position to judge on this.
Quoted 6 lines
If it really is better and superior, I think userland will switch over to it, as soon as it is possible to do it. The impact to the drivers code is needed anyway. What looses the kernel by implementing suspend blockers, and later a more finegrained approach and mapping the userspace part of suspend blockers on that finegrained approach later on?
The kernel loses the ability to remove suspend blockers once the interface is exposed to user space. That's the whole point. We would have to carry it on for a long time and trying to work around it when implementing a technical correct approach.
And we have never seen crap move to a better interface. It will stay there forever and hell will break lose when we break it.
Quoted 9 lines
Quoted 4 lines
So what the kernel needs to know to make better decisions are things like:
- how much slack can timers have (exisiting interface)
I liked this idea of Arjan, to give some applications infinite timer slack. But I don't know if it can made work in a "dummy proof" way. (I.e. it is too complicated to get it right in general, except for the "infinity" or not kind of tuning)
A mobile device can implement sensible defaults for the careless applications and let the "good" apps override them.
Quoted 3 lines
Quoted 1 line
- how much delay of wakeups is tolerated (missing interface)
Doesn't solve the segregation problem and is probably overkill for most
It solves the segregration problem quite nicely, as again it can be set to sensible defaults and to "very long" for the non verified apps.
Quoted 2 lines
applications. I see this as an orthogonal thing (i.e. not affecting this merge).
It's not orthogonal, it's essential to do QoS based power management, which is the only sensible technical solution to do, as it allows the kernel to optimize in various areas while at the same time guaranteeing the response time to applications which require them.
Blockers are not orthogonal at all, as they actively prevent clever decisions.
Quoted 6 lines
Quoted 3 lines
The power efficiency of a mobile device is depending on a sane overall software stack and not on the ability to mitigate crappy software in some obscure way which is prone to malfunction and disappoint users.
True. But I wouldnt say, that it is the linux kernel who should force this politics onto its users.
The kernel does not make politics. You and the folks who are pushing that blockers stuff with all might are making politics on the ground of a very bad argument. It does not matter at all whether android ships that blockers or not, it neither matters whether android folks consider this to be the best invention since sliced bread.
The only thing which matters is technical sanity of the approach and the maintainability of it. And none of those is given.
Thanks,
tglx
Quoted 7 lines · On Wed, 26 May 2010 19:22:16 +0200 (CEST) Thomas Gleixner <[email protected]>…
Florian,
Quoted 4 lines · Florian Mickler
On the other hand, applications can say, they don't need that much power and userspace guaranties and not take a suspend blocker.
Quoted 7 lines
Quoted 1 line
This is an option which they currently don't have.
Wrong. A well coded power aware application is very well able to express that in various ways already today. Admittedly it's far from perfect, but that can be fixed by adding interfaces which allow the power aware coder to express the requirements of his application actively, not by avoiding it.
Yeah, but a user can't say: "I don't
know programming, but I had this idea. Here try it out." to his friend. Because his friends phone then will crap out.
This is a negative. The phone just doesn't work well.
A knowledgeable programmer is able to do extra work to enable specific guarantees. A dummy-throw-away-programmer doesn't want to do any extra work.
Quoted 3 lines
suspend blockers are completely backwards as they basically disable the kernels ability to do resource management.
I don't think this is a defect in the approach but the point of it.
Quoted 6 lines
Also they enforce a black and white scheme (suspend or run) on the kernel which is stupid, as there are more options to efficiently save power than those two. While current android devices might not provide them, later hardware will have it and any atom based device has them already.
This is true. Nonetheless, in my opinion, implementing the "backwards approach" in any form (suspend blockers or some other sort of "sane" interface) is necessary in the long run. I also believe that Alan's approach is the more flexible one. But I'm not in a position to judge on this.
If it really is better and superior, I think userland will switch over to it, as soon as it is possible to do it. The impact to the drivers code is needed anyway. What looses the kernel by implementing suspend blockers, and later a more finegrained approach and mapping the userspace part of suspend blockers on that finegrained approach later on?
Quoted 5 lines
So what the kernel needs to know to make better decisions are things like:
- how much slack can timers have (exisiting interface)
I liked this idea of Arjan, to give some applications infinite timer slack. But I don't know if it can made work in a "dummy proof" way. (I.e. it is too complicated to get it right in general, except for the "infinity" or not kind of tuning)
Quoted 1 line
- how much delay of wakeups is tolerated (missing interface)
Doesn't solve the segregation problem and is probably overkill for most applications. I see this as an orthogonal thing (i.e. not affecting this merge).
Quoted 14 lines
and probably some others. That information would allow the kernel to make better decisions versus power states, grouping timers, race to idle and other things which influence the power consumption based on the hardware you are running on.
Quoted 8 lines
I don't think opportunistic suspend is a policy decision by the kernel. it is something new. Something which currently only the android userspace implements / supports. If you don't want to suspend while looking at the bouncing-cow, you have to take a suspend blocker and make yourself a user-visible power-eater, or don't do
echo "opportunistic" >
/sys/power/policy
Quoted 8 lines
Quoted 4 lines
in the first place.
This "optionally being badly written, who cares?" is a new feature the kernel can provide to applications.
It's a misfeature which the kernel should not provide at all. It sends out the completely wrong message: Hey, we can deal with your crappy code, keep on coding that way.
I can't really say anything against that. Or anything in favor of it. Except that this is probably a really hard decision for Linus to make.
Quoted 3 lines
While this seems to sound cool to certain people in the mobile space, it's completely backwards and will backfire in no time.
Maybe. It is something which seems to not come from the traditional "linux distribution" model of software deployment, where you have a party that codes and another party that packages that code.
It instead is more targeted at the decentralised 3rd-party-app approach under which windows is suffering.
Quoted 3 lines
The power efficiency of a mobile device is depending on a sane overall software stack and not on the ability to mitigate crappy software in some obscure way which is prone to malfunction and disappoint users.
True. But I wouldnt say, that it is the linux kernel who should force this politics onto its users.
Quoted 4 lines
Thanks,
tglx
Florian,
Quoted 5 lines · Florian Mickler
On the other hand, applications can say, they don't need that much power and userspace guaranties and not take a suspend blocker.
This is an option which they currently don't have.
Wrong. A well coded power aware application is very well able to express that in various ways already today. Admittedly it's far from perfect, but that can be fixed by adding interfaces which allow the power aware coder to express the requirements of his application actively, not by avoiding it.
suspend blockers are completely backwards as they basically disable the kernels ability to do resource management.
Also they enforce a black and white scheme (suspend or run) on the kernel which is stupid, as there are more options to efficiently save power than those two. While current android devices might not provide them, later hardware will have it and any atom based device has them already.
So what the kernel needs to know to make better decisions are things like:
- how much slack can timers have (exisiting interface)
- how much delay of wakeups is tolerated (missing interface)
and probably some others. That information would allow the kernel to make better decisions versus power states, grouping timers, race to idle and other things which influence the power consumption based on the hardware you are running on.
Quoted 6 lines
I don't think opportunistic suspend is a policy decision by the kernel. it is something new. Something which currently only the android userspace implements / supports. If you don't want to suspend while looking at the bouncing-cow, you have to take a suspend blocker and make yourself a user-visible power-eater, or don't do
Quoted 6 lines
echo "opportunistic" >
/sys/power/policyin the first place.
This "optionally being badly written, who cares?" is a new feature the kernel can provide to applications.
It's a misfeature which the kernel should not provide at all. It sends out the completely wrong message: Hey, we can deal with your crappy code, keep on coding that way.
While this seems to sound cool to certain people in the mobile space, it's completely backwards and will backfire in no time.
The power efficiency of a mobile device is depending on a sane overall software stack and not on the ability to mitigate crappy software in some obscure way which is prone to malfunction and disappoint users.
Thanks,
tglx
Quoted 15 lines · On Wed, 26 May 2010 14:16:12 +0100 Alan Cox <[email protected]> wrote:
Quoted 7 lines
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
The problem you have is that this is policy. If I have the device wired to a big screen and I want cows bouncing on it I'll be most upset if instead it suspends. What you are essentially arguing for is for the kernel to disobey the userspace. It's as ridiculous (albeit usually less damaging) as a file system saying "Ooh thats a rude file name, the app can't have meant it, I'll put your document soemwhere else"
Quoted 6 lines
The whole API feels wrong to me. It's breaking rule #1 of technology "You cannot solve a social problem with technology". In this case you have a social/economic problem which is crap code. You solve it with an economics solution - creative incentives not to produce crap code like boxes that keep popping up saying "App XYZ is using all your battery" and red-amber-green powermeter scores in app stores.
I'm not saying that your argument is not valid. But why don't you look at suspend blockers as a contract between userspace and kernelspace? An Opt-In to the current guarantees the kernel provides in the non-suspend case.
<<If you want to use the rare resource "power" you have to take a suspend blocker. By this you assert that you are a well written application. If you are not well written, you will get the worst of our red-amber-green powermeter scores we have.>>
On the other hand, applications can say, they don't need that much power and userspace guaranties and not take a suspend blocker.
This is an option which they currently don't have.
I don't think opportunistic suspend is a policy decision by the kernel. it is something new. Something which currently only the android userspace implements / supports. If you don't want to suspend while looking at the bouncing-cow, you have to take a suspend blocker and make yourself a user-visible power-eater, or don't do
echo "opportunistic" > /sys/power/policy
in the first place.
This "optionally being badly written, who cares?" is a new feature the kernel can provide to applications.
That said, your proposed alternative implementation scheme looks like another possible approach.
Quoted 38 lines
That said if you want technical mitigation I think it makes more sense if you look at it from a different starting point. The starting point being this: We have idling logic in the kernel and improving this helps everyone. What is needed to improve the existing logic ?
- You don't know which processes should be ignored for the purpose of suspend (except for kernel threads) and there is no way to set this
- You don't know whether a move from a deep idle to a 'suspend' (which is just a really deep idle in truth anyway) might break wakeups requirements because a device has wake dependencies due to hardware design (eg a port that has no electronics to kick the box out of suspend into running). This is a problem we have already. [1]
That maps onto two existing ideas
Sandboxing/Resource Limits: handling apps that can't be trusted. So the phone runs the appstore code via something like
setpidle(getpid(), something); exec()where 'something' is a value with meaning to both user space and to the existing idling logic in the kernel that basically says to what extent it is permitted to block idling/suspend. That also seems to tie into some of the realtime + idle problems. This I think deals with Kevin Hillman's thoughts on dealing with untrustworthy app code more cleanly and avoids the need for userspace hackery like the blocker API.
And an entirely in kernel API where device drivers can indicate that in their current situation they require that the power level doesn't drop below some limit unless user requested. This is really important because the platform vendor of the phone/pda/tablet whatever effectively owns the kernel - so it's *their* problem, *their* control, *their* hardware and they can make it work as best for the device. Best of all it means its all free software stuff so if the vendor screws up you can still fix your phone.
Quoted 5 lines
Implementation-wise it probably ties into setpidle, its simply that a task has a pair of idle values, a dynamic one and a base one, the dynamic one being the base one but updatable temporarily by drivers.
Alan
How does this address the loss of wakeup events while using suspend? (For example the 2 issues formulated by Alan Stern in [1])
cheers,
Flo
[1]http://lkml.org/lkml/2010/5/21/458
p.s.:
dmk@schatten /usr/src/linux $ grep -r "setpidle" . dmk@schatten /usr/src/linux $
Quoted 5 lines · Alan Cox
[1] Note I disagree with Kevin here on static/dynamic power management. There are IMHO two types of PM but they are 'user invoked' and 'automatic'. "Static" simply means it's not been made fast enough yet but its just a policy divide dependant on the users 'acceptable' resume time (which for hard RT may just as well rule out some more usual power states)
Completely agree with this.
I used the static/dynamic names out of habit, but since on most embedded devices, there is really no difference in hardware power state, I agree that the difference is only a matter of wakeup latency.
Kevin
Quoted 11 lines · Alan Cox
Quoted 7 lines
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
The problem you have is that this is policy. If I have the device wired to a big screen and I want cows bouncing on it I'll be most upset if instead it suspends.
We never suspend when the screen is on. If the screen is off, I would not be upset if it suspends.
Quoted 2 lines
What you are essentially arguing for is for the
kernel to disobey the userspace.
No I'm not. User-space asked the kernel to suspend when possible. Suspend is an existing kernel feature. All opportunistic suspend adds is the ability to use it safely when there are wakeup event you cannot afford to ignore.
Quoted 11 lines
It's as ridiculous (albeit usually less
damaging) as a file system saying "Ooh thats a rude file name, the app can't have meant it, I'll put your document soemwhere else"The whole API feels wrong to me. It's breaking rule #1 of technology "You cannot solve a social problem with technology". In this case you have a social/economic problem which is crap code. You solve it with an economics solution - creative incentives not to produce crap code like boxes that keep popping up saying "App XYZ is using all your battery" and red-amber-green powermeter scores in app stores.
Quoted 5 lines
That said if you want technical mitigation I think it makes more sense if you look at it from a different starting point. The starting point being this: We have idling logic in the kernel and improving this helps everyone. What is needed to improve the existing logic ?
Our actual stating point is this: Some systems can only enter their lowest power state from suspend. So we added an api that allowed us to use suspend without loosing wakeup events. Since suspending also improves our battery life on platforms that enter the same power state from idle and suspend and we already have a way to safely use suspend, we would be crazy not to use it.
Quoted 9 lines
- You don't know which processes should be ignored for the purpose of suspend (except for kernel threads) and there is no way to set this
- You don't know whether a move from a deep idle to a 'suspend' (which is just a really deep idle in truth anyway) might break wakeups requirements because a device has wake dependencies due to hardware design (eg a port that has no electronics to kick the box out of suspend into running). This is a problem we have already. [1]
Quoted 4 lines
That maps onto two existing ideas
Sandboxing/Resource Limits: handling apps that can't be trusted. So the phone runs the appstore code via something like
Sandboxing is problematic on Android since there are a lot of cross process dependencies. When a call comes in I don't know where the name and picture to display comes from. With suspend blockers we block suspend when we get notified that we have an incoming call and we can call into any process and get a response.
Quoted 20 lines
setpidle(getpid(), something);
exec()where 'something' is a value with meaning to both user space and to the existing idling logic in the kernel that basically says to what extent it is permitted to block idling/suspend. That also seems to tie into some of the realtime + idle problems. This I think deals with Kevin Hillman's thoughts on dealing with untrustworthy app code more cleanly and avoids the need for userspace hackery like the blocker API.
And an entirely in kernel API where device drivers can indicate that in their current situation they require that the power level doesn't drop below some limit unless user requested. This is really important because the platform vendor of the phone/pda/tablet whatever effectively owns the kernel - so it's *their* problem, *their* control, *their* hardware and they can make it work as best for the device. Best of all it means its all free software stuff so if the vendor screws up you can still fix your phone.
Quoted 4 lines
Implementation-wise it probably ties into setpidle, its simply that a task has a pair of idle values, a dynamic one and a base one, the dynamic one being the base one but updatable temporarily by drivers.
What about platforms that currently cannot enter low power states from idle? Do you remove suspend support from the kernel?
Quoted 16 lines
Alan
--[1] Note I disagree with Kevin here on static/dynamic power management. There are IMHO two types of PM but they are 'user invoked' and 'automatic'. "Static" simply means it's not been made fast enough yet but its just a policy divide dependant on the users 'acceptable' resume time (which for hard RT may just as well rule out some more usual power states)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 1 line
Arve Hjønnevåg
Quoted 11 lines · Alan Cox
Quoted 7 lines
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
The problem you have is that this is policy. If I have the device wired to a big screen and I want cows bouncing on it I'll be most upset if instead it suspends.
We never suspend when the screen is on. If the screen is off, I would not be upset if it suspends.
Quoted 2 lines
What you are essentially arguing for is for the
kernel to disobey the userspace.
No I'm not. User-space asked the kernel to suspend when possible. Suspend is an existing kernel feature. All opportunistic suspend adds is the ability to use it safely when there are wakeup event you cannot afford to ignore.
Quoted 11 lines
It's as ridiculous (albeit usually less
damaging) as a file system saying "Ooh thats a rude file name, the app can't have meant it, I'll put your document soemwhere else"The whole API feels wrong to me. It's breaking rule #1 of technology "You cannot solve a social problem with technology". In this case you have a social/economic problem which is crap code. You solve it with an economics solution - creative incentives not to produce crap code like boxes that keep popping up saying "App XYZ is using all your battery" and red-amber-green powermeter scores in app stores.
Quoted 5 lines
That said if you want technical mitigation I think it makes more sense if you look at it from a different starting point. The starting point being this: We have idling logic in the kernel and improving this helps everyone. What is needed to improve the existing logic ?
Our actual stating point is this: Some systems can only enter their lowest power state from suspend. So we added an api that allowed us to use suspend without loosing wakeup events. Since suspending also improves our battery life on platforms that enter the same power state from idle and suspend and we already have a way to safely use suspend, we would be crazy not to use it.
Quoted 9 lines
- You don't know which processes should be ignored for the purpose of suspend (except for kernel threads) and there is no way to set this
- You don't know whether a move from a deep idle to a 'suspend' (which is just a really deep idle in truth anyway) might break wakeups requirements because a device has wake dependencies due to hardware design (eg a port that has no electronics to kick the box out of suspend into running). This is a problem we have already. [1]
Quoted 4 lines
That maps onto two existing ideas
Sandboxing/Resource Limits: handling apps that can't be trusted. So the phone runs the appstore code via something like
Sandboxing is problematic on Android since there are a lot of cross process dependencies. When a call comes in I don't know where the name and picture to display comes from. With suspend blockers we block suspend when we get notified that we have an incoming call and we can call into any process and get a response.
Quoted 20 lines
setpidle(getpid(), something);
exec()where 'something' is a value with meaning to both user space and to the existing idling logic in the kernel that basically says to what extent it is permitted to block idling/suspend. That also seems to tie into some of the realtime + idle problems. This I think deals with Kevin Hillman's thoughts on dealing with untrustworthy app code more cleanly and avoids the need for userspace hackery like the blocker API.
And an entirely in kernel API where device drivers can indicate that in their current situation they require that the power level doesn't drop below some limit unless user requested. This is really important because the platform vendor of the phone/pda/tablet whatever effectively owns the kernel - so it's *their* problem, *their* control, *their* hardware and they can make it work as best for the device. Best of all it means its all free software stuff so if the vendor screws up you can still fix your phone.
Quoted 4 lines
Implementation-wise it probably ties into setpidle, its simply that a task has a pair of idle values, a dynamic one and a base one, the dynamic one being the base one but updatable temporarily by drivers.
What about platforms that currently cannot enter low power states from idle? Do you remove suspend support from the kernel?
Quoted 16 lines
Alan
--[1] Note I disagree with Kevin here on static/dynamic power management. There are IMHO two types of PM but they are 'user invoked' and 'automatic'. "Static" simply means it's not been made fast enough yet but its just a policy divide dependant on the users 'acceptable' resume time (which for hard RT may just as well rule out some more usual power states)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 5 lines
Arve Hjønnevåg -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · On Wed, 26 May 2010 15:30:58 -0700 Arve Hjønnevåg <[email protected]> wrote:
Quoted 8 lines · Alan Cox
Quoted 7 lines
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
Quoted 6 lines
Quoted 3 lines
The problem you have is that this is policy. If I have the device wired to a big screen and I want cows bouncing on it I'll be most upset if instead it suspends.
We never suspend when the screen is on. If the screen is off, I would not be upset if it suspends.
This is policy and platform specific. The OLPC can suspend with the screen on. Should I write my app to know about this once for Android and once for OLPC (and no doubt once for Apple). In the OLPC case cows could indeed suspend to RAM between frames if the wakeup time was suitable.
My app simply should not have to know this sort of crap, that's the whole point of an OS.
Quoted 7 lines
Quoted 2 lines
What you are essentially arguing for is for the
kernel to disobey the userspace.No I'm not. User-space asked the kernel to suspend when possible. Suspend is an existing kernel feature. All opportunistic suspend adds is the ability to use it safely when there are wakeup event you cannot afford to ignore.
Don't get me wrong - opportunistic suspend isn't the problem. Suspend blockers are - or more precisely - the manner in which they express intent from userspace. Opportunistic suspend is wonderful stuff for all sorts of things and if it persuades people like netbook manufacturers to think harder, and Linux driver authors to optimise their suspend/resume paths we all win.
Quoted 6 lines
Our actual stating point is this: Some systems can only enter their lowest power state from suspend. So we added an api that allowed us to use suspend without loosing wakeup events. Since suspending also improves our battery life on platforms that enter the same power state from idle and suspend and we already have a way to safely use suspend, we would be crazy not to use it.
Opportunistic suspend isn't special. Suspend is just a very deep idle. In fact some of the low power states on processors look little different to suspend - the OS executes a whole pile of CPU state saving and cache flushing. It might be a hardware state machine, it might be buried in firmware or it might be quite explicit (eg mrst). So we already have differing degrees of doing additional work in different states.
User triggered suspend is a bit special in that the user is usually right in that case to override the power management policy.
Note I'm not suggesting we run off and restructure all our power management code to take this view right now. I'm suggesting we need a clean 'opportunistic suspend is not special' view by user space. How the kernel handles this is addressible later without app breakage, but only if we get the interface wrong to begin with.
Quoted 8 lines
Quoted 2 lines
Sandboxing/Resource Limits: handling apps that can't be trusted. So the phone runs the appstore code via something like
Sandboxing is problematic on Android since there are a lot of cross process dependencies. When a call comes in I don't know where the name and picture to display comes from. With suspend blockers we block suspend when we get notified that we have an incoming call and we can call into any process and get a response.
But you can express user suspend blocking in this manner. Your call incoming code would say 'I want good latency'. As someone needs good latency the box won't suspend. If your approach is to start with an initial 'anyone can set a low latency we don't care' then anyone can block suspends.
Equally your call handling example is about latency not about suspend. You want the phone to stay on, to fetch a picture and display it promptly.
So what are expressing
'I am using device 'screen' please keep it live' (which may or may not block suspend - see OLPC). I guess your display server and kernel support manage this bit.
'I want the photo to appear in a resonable timescale' (latency). It's not a suspend question - an imaginary non suspend idle mode with a 20 second latency would be just as annoying yes ?
At the moment we have a very real bigger problem that your problem is part of.
- Hard real time people want to be able to limit the CPU sleeping behaviour based upon what tasks are running
- Certain gaming types want their boxes to be good power citizens except when committing digital mass murder. Right now that involves wrapping the game in a script with bits occurring as root and that generally breaks if the game crashes so the script doesn't run nicely on exit
- Virtual machine people desperately want to see latency data to help schedule stuff in a power efficient manner. In a virtual machine environment its vital information about how you schedule a virtual machine, whether now is a good time to live migrate it and how best to optimise power/performance on the server end.
- Some drivers want to constrain idling because they know platform/hardware stuff the core power management code doesn't (eg serial ports at high speed). We want that expressed in a way that keeps the power management code clean of such device knowledge
Now I don't care if we have an elegant kernel interface and Android uses it as a big hammer - if that makes Android work well everyone can be happy. What I don't want is to have a big hammer when it doesn't solve the underlying big picture problem for everyone.
So my working position is summarised thusly
- Supporting Android needs well good
- Opportunistic suspend good
- Manner in which interface is expressed to userspace bad
- Latency constraint interface would be better
- Your existing behaviour can be implemented by a simplistic use of a latency constraint interface
- We can fix a pile of other directly connected things at the same time
- Implementation internals I care far less about because we can fix those later
- Suspend is just a power state
How does that fit your model and vision ?
Quoted 2 lines
What about platforms that currently cannot enter low power states from idle? Do you remove suspend support from the kernel?
I would actually expect a system that can't do any low power states to support the user API and blissfully ignore it. Applications will ask for various latency guarantees and of course always get them. The apps will be portable, the device will be offering it's best behaviour and everyone will be happy.
If your device only supports full on and suspend I don't see why opportunistic suspend couldn't be provided assuming sufficient wakeup support was present. It won't be the most exciting power management policy to write but it's perfectly doable and the apps again will not need recoding to handle it.
The latency goal data is also priceless for another consumer - in a virtual machine environment its vital information about how you schedule a virtual machine, whether now is a good time to live migrate it and how best to optimise power/performance on the server end.
Alan
2010/5/26 Alan Cox <[email protected]>:
Quoted 16 lines
Quoted 13 lines · On Wed, 26 May 2010 15:30:58 -0700 Arve Hjønnevåg <[email protected]> wrote:
Quoted 11 lines · Alan Cox
Quoted 7 lines
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
The problem you have is that this is policy. If I have the device wired to a big screen and I want cows bouncing on it I'll be most upset if instead it suspends.
Quoted 7 lines
Quoted 2 lines
We never suspend when the screen is on. If the screen is off, I would not be upset if it suspends.
This is policy and platform specific. The OLPC can suspend with the screen on. Should I write my app to know about this once for Android and once for OLPC (and no doubt once for Apple). In the OLPC case cows could indeed suspend to RAM between frames if the wakeup time was suitable.
Are you still talking about Linux suspend? If you can enter S3 from idle and still wake up for the next timer or interrupt, then do that. Suspend blockers should have not effect on this.
Quoted 4 lines
My app simply should not have to know this sort of crap, that's the whole point of an OS.
Most apps does not have to know about this with opportunistic suspend either. If the user is interacting with the device, we don't suspend. If your apps needs to run when the user is not interacting with the device, then you can block suspend.
Quoted 15 lines
Quoted 7 lines
Quoted 2 lines
What you are essentially arguing for is for the
kernel to disobey the userspace.No I'm not. User-space asked the kernel to suspend when possible. Suspend is an existing kernel feature. All opportunistic suspend adds is the ability to use it safely when there are wakeup event you cannot afford to ignore.
Don't get me wrong - opportunistic suspend isn't the problem. Suspend blockers are - or more precisely - the manner in which they express intent from userspace. Opportunistic suspend is wonderful stuff for all sorts of things and if it persuades people like netbook manufacturers to think harder, and Linux driver authors to optimise their suspend/resume paths we all win.
Quoted 8 lines
Quoted 6 lines
Our actual stating point is this: Some systems can only enter their lowest power state from suspend. So we added an api that allowed us to use suspend without loosing wakeup events. Since suspending also improves our battery life on platforms that enter the same power state from idle and suspend and we already have a way to safely use suspend, we would be crazy not to use it.
Opportunistic suspend isn't special. Suspend is just a very deep idle. In
Suspend as it is currently implemented in Linux is special. Regular timers stop, and only specially marked wakeup events can bring the system back to the normal state.
Quoted 9 lines
fact some of the low power states on processors look little different to suspend - the OS executes a whole pile of CPU state saving and cache flushing. It might be a hardware state machine, it might be buried in firmware or it might be quite explicit (eg mrst). So we already have differing degrees of doing additional work in different states.
User triggered suspend is a bit special in that the user is usually right in that case to override the power management policy.
On a phone this is not the case. The user manually can toggle the screen on and off, and we may or may not enter suspend when the screen is off. If we forced suspend when the user turned the screen off, we could miss phone calls.
Quoted 15 lines
Note I'm not suggesting we run off and restructure all our power management code to take this view right now. I'm suggesting we need a clean 'opportunistic suspend is not special' view by user space. How the kernel handles this is addressible later without app breakage, but only if we get the interface wrong to begin with.
Quoted 8 lines
Quoted 2 lines
Sandboxing/Resource Limits: handling apps that can't be trusted. So the phone runs the appstore code via something like
Sandboxing is problematic on Android since there are a lot of cross process dependencies. When a call comes in I don't know where the name and picture to display comes from. With suspend blockers we block suspend when we get notified that we have an incoming call and we can call into any process and get a response.
Quoted 9 lines
But you can express user suspend blocking in this manner. Your call incoming code would say 'I want good latency'. As someone needs good latency the box won't suspend. If your approach is to start with an initial 'anyone can set a low latency we don't care' then anyone can block suspends.
Equally your call handling example is about latency not about suspend. You want the phone to stay on, to fetch a picture and display it promptly.
I don't think a latency api is the right way to express this since the only latency values we would use is minimal-latency and any-latency. What we are expressing is that this works need to happen now, even if the user is not currently interacting with the device.
Quoted 50 lines
So what are expressing
'I am using device 'screen' please keep it live' (which may or may not block suspend - see OLPC). I guess your display server and kernel support manage this bit.
'I want the photo to appear in a resonable timescale' (latency). It's not a suspend question - an imaginary non suspend idle mode with a 20 second latency would be just as annoying yes ?
At the moment we have a very real bigger problem that your problem is part of.
- Hard real time people want to be able to limit the CPU sleeping behaviour based upon what tasks are running
- Certain gaming types want their boxes to be good power citizens except when committing digital mass murder. Right now that involves wrapping the game in a script with bits occurring as root and that generally breaks if the game crashes so the script doesn't run nicely on exit
- Virtual machine people desperately want to see latency data to help schedule stuff in a power efficient manner. In a virtual machine environment its vital information about how you schedule a virtual machine, whether now is a good time to live migrate it and how best to optimise power/performance on the server end.
- Some drivers want to constrain idling because they know platform/hardware stuff the core power management code doesn't (eg serial ports at high speed). We want that expressed in a way that keeps the power management code clean of such device knowledge
Now I don't care if we have an elegant kernel interface and Android uses it as a big hammer - if that makes Android work well everyone can be happy. What I don't want is to have a big hammer when it doesn't solve the underlying big picture problem for everyone.
So my working position is summarised thusly
- Supporting Android needs well good
- Opportunistic suspend good
- Manner in which interface is expressed to userspace bad
- Latency constraint interface would be better
- Your existing behaviour can be implemented by a simplistic use of a latency constraint interface
- We can fix a pile of other directly connected things at the same time
- Implementation internals I care far less about because we can fix those later
- Suspend is just a power state
Quoted 2 lines
How does that fit your model and vision ?
We have two main modes of operation. The user is interacting with the device and tasks and timers should run as requested. And, the user is not interacting with the device and the device should enter (and stay in) low power states regardless of running tasks and timers. Since some events (e.g. incoming phone call, alarm clock) will may cause the user to start interacting with the device, they need special treatment. A per thread latency api does not work for us. A global latency api could work, but since would only use minimal latency or any latency this seem like overkill. Also, with a global latency api, how do I know it the requested latency is meant to improve the experience while the user is interacting with the app, or if it meant the app needs to run when the user is not interacting with the device.
Quoted 5 lines
Quoted 2 lines
What about platforms that currently cannot enter low power states from idle? Do you remove suspend support from the kernel?
I would actually expect a system that can't do any low power states to support the user API and blissfully ignore it. Applications will ask for
I don't think you understood what I asked. Currently most x86 systems can enter much lower power states from suspend than they can from idle. Are you suggesting that we remove suspend support from Linux and try to enter the same power states on x86 from idle that we now enter from suspend? It is not clear to me if this is possible.
Quoted 17 lines
various latency guarantees and of course always get them. The apps will be portable, the device will be offering it's best behaviour and everyone will be happy.
If your device only supports full on and suspend I don't see why opportunistic suspend couldn't be provided assuming sufficient wakeup support was present. It won't be the most exciting power management policy to write but it's perfectly doable and the apps again will not need recoding to handle it.
The latency goal data is also priceless for another consumer - in a virtual machine environment its vital information about how you schedule a virtual machine, whether now is a good time to live migrate it and how best to optimise power/performance on the server end.
Alan
Signature · 1 line
Arve Hjønnevåg
2010/5/26 Alan Cox <[email protected]>:
Quoted 16 lines
Quoted 13 lines · On Wed, 26 May 2010 15:30:58 -0700 Arve Hjønnevåg <[email protected]> wrote:
Quoted 11 lines · Alan Cox
Quoted 7 lines
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
The problem you have is that this is policy. If I have the device wired to a big screen and I want cows bouncing on it I'll be most upset if instead it suspends.
Quoted 7 lines
Quoted 2 lines
We never suspend when the screen is on. If the screen is off, I would not be upset if it suspends.
This is policy and platform specific. The OLPC can suspend with the screen on. Should I write my app to know about this once for Android and once for OLPC (and no doubt once for Apple). In the OLPC case cows could indeed suspend to RAM between frames if the wakeup time was suitable.
Are you still talking about Linux suspend? If you can enter S3 from idle and still wake up for the next timer or interrupt, then do that. Suspend blockers should have not effect on this.
Quoted 4 lines
My app simply should not have to know this sort of crap, that's the whole point of an OS.
Most apps does not have to know about this with opportunistic suspend either. If the user is interacting with the device, we don't suspend. If your apps needs to run when the user is not interacting with the device, then you can block suspend.
Quoted 15 lines
Quoted 7 lines
Quoted 2 lines
What you are essentially arguing for is for the
kernel to disobey the userspace.No I'm not. User-space asked the kernel to suspend when possible. Suspend is an existing kernel feature. All opportunistic suspend adds is the ability to use it safely when there are wakeup event you cannot afford to ignore.
Don't get me wrong - opportunistic suspend isn't the problem. Suspend blockers are - or more precisely - the manner in which they express intent from userspace. Opportunistic suspend is wonderful stuff for all sorts of things and if it persuades people like netbook manufacturers to think harder, and Linux driver authors to optimise their suspend/resume paths we all win.
Quoted 8 lines
Quoted 6 lines
Our actual stating point is this: Some systems can only enter their lowest power state from suspend. So we added an api that allowed us to use suspend without loosing wakeup events. Since suspending also improves our battery life on platforms that enter the same power state from idle and suspend and we already have a way to safely use suspend, we would be crazy not to use it.
Opportunistic suspend isn't special. Suspend is just a very deep idle. In
Suspend as it is currently implemented in Linux is special. Regular timers stop, and only specially marked wakeup events can bring the system back to the normal state.
Quoted 9 lines
fact some of the low power states on processors look little different to suspend - the OS executes a whole pile of CPU state saving and cache flushing. It might be a hardware state machine, it might be buried in firmware or it might be quite explicit (eg mrst). So we already have differing degrees of doing additional work in different states.
User triggered suspend is a bit special in that the user is usually right in that case to override the power management policy.
On a phone this is not the case. The user manually can toggle the screen on and off, and we may or may not enter suspend when the screen is off. If we forced suspend when the user turned the screen off, we could miss phone calls.
Quoted 15 lines
Note I'm not suggesting we run off and restructure all our power management code to take this view right now. I'm suggesting we need a clean 'opportunistic suspend is not special' view by user space. How the kernel handles this is addressible later without app breakage, but only if we get the interface wrong to begin with.
Quoted 8 lines
Quoted 2 lines
Sandboxing/Resource Limits: handling apps that can't be trusted. So the phone runs the appstore code via something like
Sandboxing is problematic on Android since there are a lot of cross process dependencies. When a call comes in I don't know where the name and picture to display comes from. With suspend blockers we block suspend when we get notified that we have an incoming call and we can call into any process and get a response.
Quoted 9 lines
But you can express user suspend blocking in this manner. Your call incoming code would say 'I want good latency'. As someone needs good latency the box won't suspend. If your approach is to start with an initial 'anyone can set a low latency we don't care' then anyone can block suspends.
Equally your call handling example is about latency not about suspend. You want the phone to stay on, to fetch a picture and display it promptly.
I don't think a latency api is the right way to express this since the only latency values we would use is minimal-latency and any-latency. What we are expressing is that this works need to happen now, even if the user is not currently interacting with the device.
Quoted 50 lines
So what are expressing
'I am using device 'screen' please keep it live' (which may or may not block suspend - see OLPC). I guess your display server and kernel support manage this bit.
'I want the photo to appear in a resonable timescale' (latency). It's not a suspend question - an imaginary non suspend idle mode with a 20 second latency would be just as annoying yes ?
At the moment we have a very real bigger problem that your problem is part of.
- Hard real time people want to be able to limit the CPU sleeping behaviour based upon what tasks are running
- Certain gaming types want their boxes to be good power citizens except when committing digital mass murder. Right now that involves wrapping the game in a script with bits occurring as root and that generally breaks if the game crashes so the script doesn't run nicely on exit
- Virtual machine people desperately want to see latency data to help schedule stuff in a power efficient manner. In a virtual machine environment its vital information about how you schedule a virtual machine, whether now is a good time to live migrate it and how best to optimise power/performance on the server end.
- Some drivers want to constrain idling because they know platform/hardware stuff the core power management code doesn't (eg serial ports at high speed). We want that expressed in a way that keeps the power management code clean of such device knowledge
Now I don't care if we have an elegant kernel interface and Android uses it as a big hammer - if that makes Android work well everyone can be happy. What I don't want is to have a big hammer when it doesn't solve the underlying big picture problem for everyone.
So my working position is summarised thusly
- Supporting Android needs well good
- Opportunistic suspend good
- Manner in which interface is expressed to userspace bad
- Latency constraint interface would be better
- Your existing behaviour can be implemented by a simplistic use of a latency constraint interface
- We can fix a pile of other directly connected things at the same time
- Implementation internals I care far less about because we can fix those later
- Suspend is just a power state
Quoted 2 lines
How does that fit your model and vision ?
We have two main modes of operation. The user is interacting with the device and tasks and timers should run as requested. And, the user is not interacting with the device and the device should enter (and stay in) low power states regardless of running tasks and timers. Since some events (e.g. incoming phone call, alarm clock) will may cause the user to start interacting with the device, they need special treatment. A per thread latency api does not work for us. A global latency api could work, but since would only use minimal latency or any latency this seem like overkill. Also, with a global latency api, how do I know it the requested latency is meant to improve the experience while the user is interacting with the app, or if it meant the app needs to run when the user is not interacting with the device.
Quoted 5 lines
Quoted 2 lines
What about platforms that currently cannot enter low power states from idle? Do you remove suspend support from the kernel?
I would actually expect a system that can't do any low power states to support the user API and blissfully ignore it. Applications will ask for
I don't think you understood what I asked. Currently most x86 systems can enter much lower power states from suspend than they can from idle. Are you suggesting that we remove suspend support from Linux and try to enter the same power states on x86 from idle that we now enter from suspend? It is not clear to me if this is possible.
Quoted 17 lines
various latency guarantees and of course always get them. The apps will be portable, the device will be offering it's best behaviour and everyone will be happy.
If your device only supports full on and suspend I don't see why opportunistic suspend couldn't be provided assuming sufficient wakeup support was present. It won't be the most exciting power management policy to write but it's perfectly doable and the apps again will not need recoding to handle it.
The latency goal data is also priceless for another consumer - in a virtual machine environment its vital information about how you schedule a virtual machine, whether now is a good time to live migrate it and how best to optimise power/performance on the server end.
Alan
Signature · 5 lines
Arve Hjønnevåg -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 20 lines · Arve Hjønnevåg
2010/5/26 Alan Cox <[email protected]>:
Quoted 19 lines
Quoted 15 lines · On Wed, 26 May 2010 15:30:58 -0700 Arve Hjønnevåg <[email protected]> wrote:
Quoted 11 lines · Alan Cox
Quoted 7 lines
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
The problem you have is that this is policy. If I have the device wired to a big screen and I want cows bouncing on it I'll be most upset if instead it suspends.
We never suspend when the screen is on. If the screen is off, I would not be upset if it suspends.
Quoted 8 lines
Quoted 4 lines
This is policy and platform specific. The OLPC can suspend with the screen on. Should I write my app to know about this once for Android and once for OLPC (and no doubt once for Apple). In the OLPC case cows could indeed suspend to RAM between frames if the wakeup time was suitable.
Are you still talking about Linux suspend? If you can enter S3 from idle and still wake up for the next timer or interrupt, then do that. Suspend blockers should have not effect on this.
It does not matter whether it's S3 or any other power saving state / mechanism in a particular device.
What matters is that the kernel needs to know about the QoS requirements of the applications which are active to make optimal decisions for power management.
If we can go into any given power state from idle then the decision which power state to select needs to be made on the requirements of an application to react on the next event (timer, interrupt, ...).
So yes, we could go into S3 (with some effort) and arm the wakeup source which will bring us back when the requirements of the apps are known at the point where the decision is made.
Quoted 9 lines
Quoted 4 lines
My app simply should not have to know this sort of crap, that's the whole point of an OS.
Most apps does not have to know about this with opportunistic suspend either. If the user is interacting with the device, we don't suspend. If your apps needs to run when the user is not interacting with the device, then you can block suspend.
You can express that in QoS requirements as well. If you say "max wakeup latency 100ms" then the kernel will select a power state which will meet this requirement. So it can decide whether to go into full suspend on a given system or select some other better suiting power saving mechanism. But this allows us to express this in a completely hardware independent way. If the hardware does not provide a suitable state, then the box stays on.
Quoted 22 lines
Quoted 22 lines
Quoted 7 lines
Quoted 2 lines
What you are essentially arguing for is for the
kernel to disobey the userspace.No I'm not. User-space asked the kernel to suspend when possible. Suspend is an existing kernel feature. All opportunistic suspend adds is the ability to use it safely when there are wakeup event you cannot afford to ignore.
Don't get me wrong - opportunistic suspend isn't the problem. Suspend blockers are - or more precisely - the manner in which they express intent from userspace. Opportunistic suspend is wonderful stuff for all sorts of things and if it persuades people like netbook manufacturers to think harder, and Linux driver authors to optimise their suspend/resume paths we all win.
Quoted 6 lines
Our actual stating point is this: Some systems can only enter their lowest power state from suspend. So we added an api that allowed us to use suspend without loosing wakeup events. Since suspending also improves our battery life on platforms that enter the same power state from idle and suspend and we already have a way to safely use suspend, we would be crazy not to use it.
Quoted 5 lines
Quoted 1 line
Opportunistic suspend isn't special. Suspend is just a very deep idle. In
Suspend as it is currently implemented in Linux is special. Regular timers stop, and only specially marked wakeup events can bring the system back to the normal state.
That's a matter of the current implementation. We can change that and improve it to do better resource management. And this requirement is not restricted to the mobile phone space, it's true for laptops, virtualization and other areas as well.
Quoted 6 lines
Quoted 6 lines
But you can express user suspend blocking in this manner. Your call incoming code would say 'I want good latency'. As someone needs good latency the box won't suspend. If your approach is to start with an initial 'anyone can set a low latency we don't care' then anyone can block suspends.
Quoted 8 lines
Quoted 3 lines
Equally your call handling example is about latency not about suspend. You want the phone to stay on, to fetch a picture and display it promptly.
I don't think a latency api is the right way to express this since the only latency values we would use is minimal-latency and any-latency. What we are expressing is that this works need to happen now, even if the user is not currently interacting with the device.
You're mind is stuck in a black and white decision scheme, which you implemented with the suspend blockers big hammer approach.
There is a wide variety between minimal and any latency. It depends on the task at hand. An interactive application will want a latency which is in the range of acceptable user experience, but that's not necessarily the minimal latency which the system can guarantee and provide. A background task can say "I'm fine with 100ms" which allows the kernel to aggregate wakeups in a clever way.
Even if andorid decides that min and any are the only two which matter, then this approach will work for android, but lets us use the same mechanism and technology in other areas where people are interested to express more than the on/off QoS requirements.
Quoted 16 lines
Quoted 13 lines
So my working position is summarised thusly
- Supporting Android needs well good
- Opportunistic suspend good
- Manner in which interface is expressed to userspace bad
- Latency constraint interface would be better
- Your existing behaviour can be implemented by a simplistic use of a latency constraint interface
- We can fix a pile of other directly connected things at the same time
- Implementation internals I care far less about because we can fix those later
- Suspend is just a power stateQuoted 2 lines
How does that fit your model and vision ?
Quoted 12 lines
We have two main modes of operation. The user is interacting with the device and tasks and timers should run as requested. And, the user is not interacting with the device and the device should enter (and stay in) low power states regardless of running tasks and timers. Since some events (e.g. incoming phone call, alarm clock) will may cause the user to start interacting with the device, they need special treatment. A per thread latency api does not work for us. A global latency api could work, but since would only use minimal latency or any latency this seem like overkill. Also, with a global latency api, how do I know it the requested latency is meant to improve the experience while the user is interacting with the app, or if it meant the app needs to run when the user is not interacting with the device.
Again. You do not need a global latency API. A per thread and probably per device latency information is what matters. The global state is extracted from the per thread/device information.
With your global approach - which is basically the suspend blocker in a different disguise - you prevent actively that the kernel can do more clever decisions vs. power savings when there are more options than suspend or not suspend.
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines
What about platforms that currently cannot enter low power states from idle? Do you remove suspend support from the kernel?
I would actually expect a system that can't do any low power states to support the user API and blissfully ignore it. Applications will ask for
I don't think you understood what I asked. Currently most x86 systems can enter much lower power states from suspend than they can from idle. Are you suggesting that we remove suspend support from Linux and try to enter the same power states on x86 from idle that we now enter from suspend? It is not clear to me if this is possible.
That does not matter whether we can do that right now or whether it's possible at all on X86. The point is that the hardware is improving and implementing better power saving mechanisms which allow us fine grained control over the way we save power.
So if a system can't go into suspend from idle, then the kernel can simply ignore that all apps told the kernel that they don't care about latency and QoS at the moment. It just selects the lowest power state available. And if it has no power states at all, everything just works fine.
OTOH, when you have this fancy application which just blinks with the LED every two seconds for whatever reason, then your black and white approach might prevent entering suspend just because the suspend wakeup latency is 2.2 seconds and the kernel does not know that the LED blinker app does not care whether it's actually 2 or 2.5 seconds.
Power management has more than two states, and the most important information for selecting a state is the acceptable latency which a given application can tolerate for coming out of the state in order to meet the deadlines which can be given by a particular device fifo length or by not violating the user experience.
There is nothing which prevents you of using the black and white approach and just using the min and any latency values to express what you think is the best for android, but you do not prevent other people that way from taking a more sensible approach.
Thanks,
tglx
Quoted 20 lines · Arve Hjønnevåg
2010/5/26 Alan Cox <[email protected]>:
Quoted 19 lines
Quoted 15 lines · On Wed, 26 May 2010 15:30:58 -0700 Arve Hjønnevåg <[email protected]> wrote:
Quoted 11 lines · Alan Cox
Quoted 7 lines
Really, what are you getting at? Do you deny that there are programs, that prevent a device from sleeping? (Just think of the bouncing cows app)
And if you have two kernels, one with which your device is dead after 1 hour and one with which your device is dead after 10 hours. Which would you prefer? I mean really... this is ridiculous.
The problem you have is that this is policy. If I have the device wired to a big screen and I want cows bouncing on it I'll be most upset if instead it suspends.
We never suspend when the screen is on. If the screen is off, I would not be upset if it suspends.
Quoted 8 lines
Quoted 4 lines
This is policy and platform specific. The OLPC can suspend with the screen on. Should I write my app to know about this once for Android and once for OLPC (and no doubt once for Apple). In the OLPC case cows could indeed suspend to RAM between frames if the wakeup time was suitable.
Are you still talking about Linux suspend? If you can enter S3 from idle and still wake up for the next timer or interrupt, then do that. Suspend blockers should have not effect on this.
It does not matter whether it's S3 or any other power saving state / mechanism in a particular device.
What matters is that the kernel needs to know about the QoS requirements of the applications which are active to make optimal decisions for power management.
If we can go into any given power state from idle then the decision which power state to select needs to be made on the requirements of an application to react on the next event (timer, interrupt, ...).
So yes, we could go into S3 (with some effort) and arm the wakeup source which will bring us back when the requirements of the apps are known at the point where the decision is made.
Quoted 9 lines
Quoted 4 lines
My app simply should not have to know this sort of crap, that's the whole point of an OS.
Most apps does not have to know about this with opportunistic suspend either. If the user is interacting with the device, we don't suspend. If your apps needs to run when the user is not interacting with the device, then you can block suspend.
You can express that in QoS requirements as well. If you say "max wakeup latency 100ms" then the kernel will select a power state which will meet this requirement. So it can decide whether to go into full suspend on a given system or select some other better suiting power saving mechanism. But this allows us to express this in a completely hardware independent way. If the hardware does not provide a suitable state, then the box stays on.
Quoted 22 lines
Quoted 22 lines
Quoted 7 lines
Quoted 2 lines
What you are essentially arguing for is for the
kernel to disobey the userspace.No I'm not. User-space asked the kernel to suspend when possible. Suspend is an existing kernel feature. All opportunistic suspend adds is the ability to use it safely when there are wakeup event you cannot afford to ignore.
Don't get me wrong - opportunistic suspend isn't the problem. Suspend blockers are - or more precisely - the manner in which they express intent from userspace. Opportunistic suspend is wonderful stuff for all sorts of things and if it persuades people like netbook manufacturers to think harder, and Linux driver authors to optimise their suspend/resume paths we all win.
Quoted 6 lines
Our actual stating point is this: Some systems can only enter their lowest power state from suspend. So we added an api that allowed us to use suspend without loosing wakeup events. Since suspending also improves our battery life on platforms that enter the same power state from idle and suspend and we already have a way to safely use suspend, we would be crazy not to use it.
Quoted 5 lines
Quoted 1 line
Opportunistic suspend isn't special. Suspend is just a very deep idle. In
Suspend as it is currently implemented in Linux is special. Regular timers stop, and only specially marked wakeup events can bring the system back to the normal state.
That's a matter of the current implementation. We can change that and improve it to do better resource management. And this requirement is not restricted to the mobile phone space, it's true for laptops, virtualization and other areas as well.
Quoted 6 lines
Quoted 6 lines
But you can express user suspend blocking in this manner. Your call incoming code would say 'I want good latency'. As someone needs good latency the box won't suspend. If your approach is to start with an initial 'anyone can set a low latency we don't care' then anyone can block suspends.
Quoted 8 lines
Quoted 3 lines
Equally your call handling example is about latency not about suspend. You want the phone to stay on, to fetch a picture and display it promptly.
I don't think a latency api is the right way to express this since the only latency values we would use is minimal-latency and any-latency. What we are expressing is that this works need to happen now, even if the user is not currently interacting with the device.
You're mind is stuck in a black and white decision scheme, which you implemented with the suspend blockers big hammer approach.
There is a wide variety between minimal and any latency. It depends on the task at hand. An interactive application will want a latency which is in the range of acceptable user experience, but that's not necessarily the minimal latency which the system can guarantee and provide. A background task can say "I'm fine with 100ms" which allows the kernel to aggregate wakeups in a clever way.
Even if andorid decides that min and any are the only two which matter, then this approach will work for android, but lets us use the same mechanism and technology in other areas where people are interested to express more than the on/off QoS requirements.
Quoted 16 lines
Quoted 13 lines
So my working position is summarised thusly
- Supporting Android needs well good
- Opportunistic suspend good
- Manner in which interface is expressed to userspace bad
- Latency constraint interface would be better
- Your existing behaviour can be implemented by a simplistic use of a latency constraint interface
- We can fix a pile of other directly connected things at the same time
- Implementation internals I care far less about because we can fix those later
- Suspend is just a power stateQuoted 2 lines
How does that fit your model and vision ?
Quoted 12 lines
We have two main modes of operation. The user is interacting with the device and tasks and timers should run as requested. And, the user is not interacting with the device and the device should enter (and stay in) low power states regardless of running tasks and timers. Since some events (e.g. incoming phone call, alarm clock) will may cause the user to start interacting with the device, they need special treatment. A per thread latency api does not work for us. A global latency api could work, but since would only use minimal latency or any latency this seem like overkill. Also, with a global latency api, how do I know it the requested latency is meant to improve the experience while the user is interacting with the app, or if it meant the app needs to run when the user is not interacting with the device.
Again. You do not need a global latency API. A per thread and probably per device latency information is what matters. The global state is extracted from the per thread/device information.
With your global approach - which is basically the suspend blocker in a different disguise - you prevent actively that the kernel can do more clever decisions vs. power savings when there are more options than suspend or not suspend.
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines
What about platforms that currently cannot enter low power states from idle? Do you remove suspend support from the kernel?
I would actually expect a system that can't do any low power states to support the user API and blissfully ignore it. Applications will ask for
I don't think you understood what I asked. Currently most x86 systems can enter much lower power states from suspend than they can from idle. Are you suggesting that we remove suspend support from Linux and try to enter the same power states on x86 from idle that we now enter from suspend? It is not clear to me if this is possible.
That does not matter whether we can do that right now or whether it's possible at all on X86. The point is that the hardware is improving and implementing better power saving mechanisms which allow us fine grained control over the way we save power.
So if a system can't go into suspend from idle, then the kernel can simply ignore that all apps told the kernel that they don't care about latency and QoS at the moment. It just selects the lowest power state available. And if it has no power states at all, everything just works fine.
OTOH, when you have this fancy application which just blinks with the LED every two seconds for whatever reason, then your black and white approach might prevent entering suspend just because the suspend wakeup latency is 2.2 seconds and the kernel does not know that the LED blinker app does not care whether it's actually 2 or 2.5 seconds.
Power management has more than two states, and the most important information for selecting a state is the acceptable latency which a given application can tolerate for coming out of the state in order to meet the deadlines which can be given by a particular device fifo length or by not violating the user experience.
There is nothing which prevents you of using the black and white approach and just using the min and any latency values to express what you think is the best for android, but you do not prevent other people that way from taking a more sensible approach.
Thanks,
tglx
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
Opportunistic suspends are okay.
The proposed userspace API is too Android-specific.
More kernel mechanisms are needed for expressing processes' latency requirements.
The last one is obviously a longer-term issue, so let's ignore it for now. That leaves as the only point of contention the userspace suspend-blocker API.
The proposal I made a couple of days ago removes this API and leaves the other things (i.e., the in-kernel suspend blockers and opportunistic suspend) intact. In place of the userspace kernel-blocker API, Android would have to implement a power manager process that would essentially juggle all the latency requirements in userspace.
Communication between the power manager process and the kernel would be limited to adding a new "opportunistic" entry to /sys/power/state -- something which could well be useful in its own right. Even if this API turns out not to be good, it's simple enough that it could be removed pretty easily.
This answers Alan Cox's (and other's) desire not to implement a questionable or special-purpose API. And it also answers Thomas's desire to make scheduling decisions based on latency requirements (although the answer is simply to punt all these decisions out of the kernel and into userspace -- which is reasonable for now since the alternative would require a long-term kernel development effort).
Indeed, having a power manager thread may well turn out to be a useful thing -- but even if it doesn't, this scheme minimizes the damage while still allowing the Android platform to use a vanilla kernel with only limited modifications to their userspace.
Alan Stern
Quoted 4 lines · Alan Stern
Opportunistic suspends are okay.
The proposed userspace API is too Android-specific.
I would argue opportunistic suspends are not ok, and therefore the proposed API is utterly irrelevant.
Quoted 4 lines · Alan Stern
Opportunistic suspends are okay.
The proposed userspace API is too Android-specific.
I would argue opportunistic suspends are not ok, and therefore the proposed API is utterly irrelevant.
Quoted 8 lines · On Thu, 27 May 2010 17:09:16 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Alan Stern
Opportunistic suspends are okay.
The proposed userspace API is too Android-specific.
I would argue opportunistic suspends are not ok, and therefore the proposed API is utterly irrelevant.
Assuming you are happy that opportunistically entering C6 and the like is ok via ACPI can you explain why you have a problem with opportunistic suspend and why it is different to a very deep sleep CPU state such as we have now (and which on many embedded platforms we deal with *is* sleeping external devices too)
Alan
Quoted 9 lines · Alan Cox
Quoted 6 lines · On Thu, 27 May 2010 17:09:16 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Alan Stern
Opportunistic suspends are okay.
The proposed userspace API is too Android-specific.
Quoted 8 lines
Quoted 2 lines
I would argue opportunistic suspends are not ok, and therefore the proposed API is utterly irrelevant.
Assuming you are happy that opportunistically entering C6 and the like is ok via ACPI can you explain why you have a problem with opportunistic suspend and why it is different to a very deep sleep CPU state such as we have now (and which on many embedded platforms we deal with *is* sleeping external devices too)
Agreed, but I understood the opportunistic suspend line from Alan Stern to mean the echo opportunistic > /sys/power/foo thing.
If you view it as an extra deep idle state I have no problem with it (because its simply an idle state, nothing magic about those).
Quoted 9 lines · Alan Cox
Quoted 6 lines · On Thu, 27 May 2010 17:09:16 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Alan Stern
Opportunistic suspends are okay.
The proposed userspace API is too Android-specific.
Quoted 8 lines
Quoted 2 lines
I would argue opportunistic suspends are not ok, and therefore the proposed API is utterly irrelevant.
Assuming you are happy that opportunistically entering C6 and the like is ok via ACPI can you explain why you have a problem with opportunistic suspend and why it is different to a very deep sleep CPU state such as we have now (and which on many embedded platforms we deal with *is* sleeping external devices too)
Agreed, but I understood the opportunistic suspend line from Alan Stern to mean the echo opportunistic > /sys/power/foo thing.
If you view it as an extra deep idle state I have no problem with it (because its simply an idle state, nothing magic about those).
Quoted 13 lines · Peter Zijlstra
Quoted 12 lines · Alan Cox
Quoted 8 lines · On Thu, 27 May 2010 17:09:16 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Alan Stern
Opportunistic suspends are okay.
The proposed userspace API is too Android-specific.
I would argue opportunistic suspends are not ok, and therefore the proposed API is utterly irrelevant.
Quoted 8 lines
Quoted 5 lines
Assuming you are happy that opportunistically entering C6 and the like is ok via ACPI can you explain why you have a problem with opportunistic suspend and why it is different to a very deep sleep CPU state such as we have now (and which on many embedded platforms we deal with *is* sleeping external devices too)
Agreed, but I understood the opportunistic suspend line from Alan Stern to mean the echo opportunistic >
/sys/power/foothing.
Yes, that's what I meant. Why do you think it is any worse than "echo mem >/sys/power/state"? The only difference is that it will block until all in-kernel suspend blockers are disabled.
Or do you also think that "echo mem >/sys/power/state" is evil and should be removed from the kernel as soon as possible?
And to answer Thomas's question: The whole reason for having in-kernel suspend blockers is so that userspace can tell the system to suspend without losing wakeup events.
Suppose a key is pressed just as a user program writes "mem" to /sys/power/state. The keyboard driver handles the keystroke and queues an input event. Then the system suspends and doesn't wake up until some other event occurs -- even though the keypress was an important one and it should have prevented the system from suspending.
With in-kernel suspend blockers and opportunistic suspend, this scenario is prevented. That is their raison-d'etre.
Alan Stern
Quoted 13 lines · Peter Zijlstra
Quoted 12 lines · Alan Cox
Quoted 8 lines · On Thu, 27 May 2010 17:09:16 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Alan Stern
Opportunistic suspends are okay.
The proposed userspace API is too Android-specific.
I would argue opportunistic suspends are not ok, and therefore the proposed API is utterly irrelevant.
Quoted 8 lines
Quoted 5 lines
Assuming you are happy that opportunistically entering C6 and the like is ok via ACPI can you explain why you have a problem with opportunistic suspend and why it is different to a very deep sleep CPU state such as we have now (and which on many embedded platforms we deal with *is* sleeping external devices too)
Agreed, but I understood the opportunistic suspend line from Alan Stern to mean the echo opportunistic >
/sys/power/foothing.
Yes, that's what I meant. Why do you think it is any worse than "echo mem >/sys/power/state"? The only difference is that it will block until all in-kernel suspend blockers are disabled.
Or do you also think that "echo mem >/sys/power/state" is evil and should be removed from the kernel as soon as possible?
And to answer Thomas's question: The whole reason for having in-kernel suspend blockers is so that userspace can tell the system to suspend without losing wakeup events.
Suppose a key is pressed just as a user program writes "mem" to /sys/power/state. The keyboard driver handles the keystroke and queues an input event. Then the system suspends and doesn't wake up until some other event occurs -- even though the keypress was an important one and it should have prevented the system from suspending.
With in-kernel suspend blockers and opportunistic suspend, this scenario is prevented. That is their raison-d'etre.
Alan Stern
Quoted 35 lines · Alan Stern
Quoted 13 lines · Peter Zijlstra
Quoted 12 lines · Alan Cox
Quoted 8 lines · On Thu, 27 May 2010 17:09:16 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Alan Stern
Opportunistic suspends are okay.
The proposed userspace API is too Android-specific.
I would argue opportunistic suspends are not ok, and therefore the proposed API is utterly irrelevant.
Quoted 8 lines
Quoted 5 lines
Assuming you are happy that opportunistically entering C6 and the like is ok via ACPI can you explain why you have a problem with opportunistic suspend and why it is different to a very deep sleep CPU state such as we have now (and which on many embedded platforms we deal with *is* sleeping external devices too)
Agreed, but I understood the opportunistic suspend line from Alan Stern to mean the echo opportunistic >
/sys/power/foothing.Yes, that's what I meant. Why do you think it is any worse than "echo mem >/sys/power/state"? The only difference is that it will block until all in-kernel suspend blockers are disabled.
Or do you also think that "echo mem >/sys/power/state" is evil and should be removed from the kernel as soon as possible?
And to answer Thomas's question: The whole reason for having in-kernel suspend blockers is so that userspace can tell the system to suspend without losing wakeup events.
Quoted 8 lines
Suppose a key is pressed just as a user program writes "mem" to
/sys/power/state. The keyboard driver handles the keystroke and queues an input event. Then the system suspends and doesn't wake up until some other event occurs -- even though the keypress was an important one and it should have prevented the system from suspending.With in-kernel suspend blockers and opportunistic suspend, this scenario is prevented. That is their raison-d'etre.
I tend to disagree. You are still looking at suspend as some extra esoteric mechanism. We should stop doing this and look at suspend (to RAM) as an additional deep idle state, which is well defined in terms of power savings and wakeup latency. That's what I think opportunistic suspend is all about. Now if you look at our current idle states in x86 the incoming keystroke is never lost.
So when suspend does lose the wakeup event then we need to fix that, but why do we need suspend blockers for this ? Let's take your example:
Quoted 2 lines
The keyboard driver handles the keystroke and queues an input event. Then the system goes into suspend ....
Why do we go into suspend at all? If there is an event queued then something is woken up and got running, which is reason enough _not_ to enter suspend. If that's broken in the current implementation then we need to fix it, but not with a big hammer by adding another interface. We have that information already and obviously we do not use it, so lets figure out why before adding suspend blockers just because they paper over the underlying problem.
Thanks,
tglx
Quoted 35 lines · Alan Stern
Quoted 13 lines · Peter Zijlstra
Quoted 12 lines · Alan Cox
Quoted 8 lines · On Thu, 27 May 2010 17:09:16 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Alan Stern
Opportunistic suspends are okay.
The proposed userspace API is too Android-specific.
I would argue opportunistic suspends are not ok, and therefore the proposed API is utterly irrelevant.
Quoted 8 lines
Quoted 5 lines
Assuming you are happy that opportunistically entering C6 and the like is ok via ACPI can you explain why you have a problem with opportunistic suspend and why it is different to a very deep sleep CPU state such as we have now (and which on many embedded platforms we deal with *is* sleeping external devices too)
Agreed, but I understood the opportunistic suspend line from Alan Stern to mean the echo opportunistic >
/sys/power/foothing.Yes, that's what I meant. Why do you think it is any worse than "echo mem >/sys/power/state"? The only difference is that it will block until all in-kernel suspend blockers are disabled.
Or do you also think that "echo mem >/sys/power/state" is evil and should be removed from the kernel as soon as possible?
And to answer Thomas's question: The whole reason for having in-kernel suspend blockers is so that userspace can tell the system to suspend without losing wakeup events.
Quoted 8 lines
Suppose a key is pressed just as a user program writes "mem" to
/sys/power/state. The keyboard driver handles the keystroke and queues an input event. Then the system suspends and doesn't wake up until some other event occurs -- even though the keypress was an important one and it should have prevented the system from suspending.With in-kernel suspend blockers and opportunistic suspend, this scenario is prevented. That is their raison-d'etre.
I tend to disagree. You are still looking at suspend as some extra esoteric mechanism. We should stop doing this and look at suspend (to RAM) as an additional deep idle state, which is well defined in terms of power savings and wakeup latency. That's what I think opportunistic suspend is all about. Now if you look at our current idle states in x86 the incoming keystroke is never lost.
So when suspend does lose the wakeup event then we need to fix that, but why do we need suspend blockers for this ? Let's take your example:
Quoted 2 lines
The keyboard driver handles the keystroke and queues an input event. Then the system goes into suspend ....
Why do we go into suspend at all? If there is an event queued then something is woken up and got running, which is reason enough _not_ to enter suspend. If that's broken in the current implementation then we need to fix it, but not with a big hammer by adding another interface. We have that information already and obviously we do not use it, so lets figure out why before adding suspend blockers just because they paper over the underlying problem.
Thanks,
tglx
Quoted 42 lines · Thomas Gleixner
Quoted 41 lines · Alan Stern
Quoted 13 lines · Peter Zijlstra
Quoted 12 lines · Alan Cox
Quoted 8 lines · On Thu, 27 May 2010 17:09:16 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Alan Stern
Opportunistic suspends are okay.
The proposed userspace API is too Android-specific.
I would argue opportunistic suspends are not ok, and therefore the proposed API is utterly irrelevant.
Quoted 8 lines
Quoted 5 lines
Assuming you are happy that opportunistically entering C6 and the like is ok via ACPI can you explain why you have a problem with opportunistic suspend and why it is different to a very deep sleep CPU state such as we have now (and which on many embedded platforms we deal with *is* sleeping external devices too)
Agreed, but I understood the opportunistic suspend line from Alan Stern to mean the echo opportunistic >
/sys/power/foothing.Yes, that's what I meant. Why do you think it is any worse than "echo mem >/sys/power/state"? The only difference is that it will block until all in-kernel suspend blockers are disabled.
Or do you also think that "echo mem >/sys/power/state" is evil and should be removed from the kernel as soon as possible?
And to answer Thomas's question: The whole reason for having in-kernel suspend blockers is so that userspace can tell the system to suspend without losing wakeup events.
Suppose a key is pressed just as a user program writes "mem" to
/sys/power/state. The keyboard driver handles the keystroke and queues an input event. Then the system suspends and doesn't wake up until some other event occurs -- even though the keypress was an important one and it should have prevented the system from suspending.
Quoted 7 lines
Quoted 2 lines
With in-kernel suspend blockers and opportunistic suspend, this scenario is prevented. That is their raison-d'etre.
I tend to disagree. You are still looking at suspend as some extra esoteric mechanism. We should stop doing this and look at suspend (to RAM) as an additional deep idle state, which is well defined in terms of power savings and wakeup latency.
Well, the ACPI spec doesn't agree with you. :-)
Quoted 4 lines
That's what I think opportunistic suspend is all about. Now if you look at our current idle states in x86 the incoming keystroke is never lost.
So when suspend does lose the wakeup event then we need to fix that,
With ACPI, we can't, because we have to switch our wakeup sources from the "runtime" mode to the "system wakeup" mode in a racy fashion.
Quoted 6 lines
but why do we need suspend blockers for this ? Let's take your example:
Quoted 2 lines
The keyboard driver handles the keystroke and queues an input event. Then the system goes into suspend ....
Why do we go into suspend at all?
The decision to go to suspend may be made in parallel to the keystroke in such a way that we may not be able to detect it (that doesn't apply to the hardware Android currently runs on, though).
Quoted 3 lines
If there is an event queued then something is woken up and got running, which is reason enough _not_ to enter suspend. If that's broken in the current implementation then we need to fix it,
That's not a matter of implementation (which I admit can be improved).
Quoted 4 lines
but not with a big hammer by adding another
interface. We have that information already and obviously we do not use it, so lets figure out why before adding suspend blockers just because they paper over the underlying problem.
I'm not really sure what information you're referring to.
Rafael
Quoted 42 lines · Thomas Gleixner
Quoted 41 lines · Alan Stern
Quoted 13 lines · Peter Zijlstra
Quoted 12 lines · Alan Cox
Quoted 8 lines · On Thu, 27 May 2010 17:09:16 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Alan Stern
Opportunistic suspends are okay.
The proposed userspace API is too Android-specific.
I would argue opportunistic suspends are not ok, and therefore the proposed API is utterly irrelevant.
Quoted 8 lines
Quoted 5 lines
Assuming you are happy that opportunistically entering C6 and the like is ok via ACPI can you explain why you have a problem with opportunistic suspend and why it is different to a very deep sleep CPU state such as we have now (and which on many embedded platforms we deal with *is* sleeping external devices too)
Agreed, but I understood the opportunistic suspend line from Alan Stern to mean the echo opportunistic >
/sys/power/foothing.Yes, that's what I meant. Why do you think it is any worse than "echo mem >/sys/power/state"? The only difference is that it will block until all in-kernel suspend blockers are disabled.
Or do you also think that "echo mem >/sys/power/state" is evil and should be removed from the kernel as soon as possible?
And to answer Thomas's question: The whole reason for having in-kernel suspend blockers is so that userspace can tell the system to suspend without losing wakeup events.
Suppose a key is pressed just as a user program writes "mem" to
/sys/power/state. The keyboard driver handles the keystroke and queues an input event. Then the system suspends and doesn't wake up until some other event occurs -- even though the keypress was an important one and it should have prevented the system from suspending.
Quoted 7 lines
Quoted 2 lines
With in-kernel suspend blockers and opportunistic suspend, this scenario is prevented. That is their raison-d'etre.
I tend to disagree. You are still looking at suspend as some extra esoteric mechanism. We should stop doing this and look at suspend (to RAM) as an additional deep idle state, which is well defined in terms of power savings and wakeup latency.
Well, the ACPI spec doesn't agree with you. :-)
Quoted 4 lines
That's what I think opportunistic suspend is all about. Now if you look at our current idle states in x86 the incoming keystroke is never lost.
So when suspend does lose the wakeup event then we need to fix that,
With ACPI, we can't, because we have to switch our wakeup sources from the "runtime" mode to the "system wakeup" mode in a racy fashion.
Quoted 6 lines
but why do we need suspend blockers for this ? Let's take your example:
Quoted 2 lines
The keyboard driver handles the keystroke and queues an input event. Then the system goes into suspend ....
Why do we go into suspend at all?
The decision to go to suspend may be made in parallel to the keystroke in such a way that we may not be able to detect it (that doesn't apply to the hardware Android currently runs on, though).
Quoted 3 lines
If there is an event queued then something is woken up and got running, which is reason enough _not_ to enter suspend. If that's broken in the current implementation then we need to fix it,
That's not a matter of implementation (which I admit can be improved).
Quoted 4 lines
but not with a big hammer by adding another
interface. We have that information already and obviously we do not use it, so lets figure out why before adding suspend blockers just because they paper over the underlying problem.
I'm not really sure what information you're referring to.
Rafael
Quoted 14 lines · Thomas Gleixner
Quoted 4 lines · Alan Stern
And to answer Thomas's question: The whole reason for having in-kernel suspend blockers is so that userspace can tell the system to suspend without losing wakeup events.
Quoted 8 lines
Suppose a key is pressed just as a user program writes "mem" to
/sys/power/state. The keyboard driver handles the keystroke and queues an input event. Then the system suspends and doesn't wake up until some other event occurs -- even though the keypress was an important one and it should have prevented the system from suspending.With in-kernel suspend blockers and opportunistic suspend, this scenario is prevented. That is their raison-d'etre.
Quoted 7 lines
I tend to disagree. You are still looking at suspend as some extra esoteric mechanism. We should stop doing this and look at suspend (to RAM) as an additional deep idle state, which is well defined in terms of power savings and wakeup latency. That's what I think opportunistic suspend is all about. Now if you look at our current idle states in x86 the incoming keystroke is never lost.
For systems with runtime PM and deep idle states in cpuidle suspend is already fairly opportunistic. If sleep states (including suspend to RAM and CPU off) are factored in to cpuidle then it's very easy to get in to situations where everything simply shuts off automatically, which can be problematic if a platform doesn't expose any external wakeup sources.
Platforms still need to be able to establish some heuristics, whether this is via blocking certain state transitions or simply defining a maximum acceptable suspend depth irrespective of latency (at least we presently don't have a clean interface for preventing entry in to impossible to recover from idle states outside of latency hints via PM QoS, or at least not one that I'm aware of).
On the other hand, while this isn't that difficult for the UP case it does pose more problems for the SMP case. Presently the suspend paths (suspend-to-RAM/hibernate/kexec jump) all deal with disabling and enabling of non-boot CPUs via CPU hotplug explicitly, which will clear them from the online CPU map. We would have to rework the semantics a bit if cpuidle were also permitted to opportunistically offline CPUs.
Quoted 14 lines · Thomas Gleixner
Quoted 4 lines · Alan Stern
And to answer Thomas's question: The whole reason for having in-kernel suspend blockers is so that userspace can tell the system to suspend without losing wakeup events.
Quoted 8 lines
Suppose a key is pressed just as a user program writes "mem" to
/sys/power/state. The keyboard driver handles the keystroke and queues an input event. Then the system suspends and doesn't wake up until some other event occurs -- even though the keypress was an important one and it should have prevented the system from suspending.With in-kernel suspend blockers and opportunistic suspend, this scenario is prevented. That is their raison-d'etre.
Quoted 7 lines
I tend to disagree. You are still looking at suspend as some extra esoteric mechanism. We should stop doing this and look at suspend (to RAM) as an additional deep idle state, which is well defined in terms of power savings and wakeup latency. That's what I think opportunistic suspend is all about. Now if you look at our current idle states in x86 the incoming keystroke is never lost.
For systems with runtime PM and deep idle states in cpuidle suspend is already fairly opportunistic. If sleep states (including suspend to RAM and CPU off) are factored in to cpuidle then it's very easy to get in to situations where everything simply shuts off automatically, which can be problematic if a platform doesn't expose any external wakeup sources.
Platforms still need to be able to establish some heuristics, whether this is via blocking certain state transitions or simply defining a maximum acceptable suspend depth irrespective of latency (at least we presently don't have a clean interface for preventing entry in to impossible to recover from idle states outside of latency hints via PM QoS, or at least not one that I'm aware of).
On the other hand, while this isn't that difficult for the UP case it does pose more problems for the SMP case. Presently the suspend paths (suspend-to-RAM/hibernate/kexec jump) all deal with disabling and enabling of non-boot CPUs via CPU hotplug explicitly, which will clear them from the online CPU map. We would have to rework the semantics a bit if cpuidle were also permitted to opportunistically offline CPUs.
Quoted 7 lines · Paul Mundt
On the other hand, while this isn't that difficult for the UP case it does pose more problems for the SMP case. Presently the suspend paths (suspend-to-RAM/hibernate/kexec jump) all deal with disabling and enabling of non-boot CPUs via CPU hotplug explicitly, which will clear them from the online CPU map. We would have to rework the semantics a bit if cpuidle were also permitted to opportunistically offline CPUs.
That's definitely something we'd be interested in looking at. Some upcoming ARM v7 architecture SMP SoCs we're seeing will support full independent clock scaling and power gating for the individual cores -- if there's not enough work to keep the 2nd (or nth) cpu busy, there would be good power savings to be had shutting it down.
I haven't poked around too much with how things work in SMP environments -- are there per-cpu idle threads?
Brian
Quoted 7 lines · Paul Mundt
On the other hand, while this isn't that difficult for the UP case it does pose more problems for the SMP case. Presently the suspend paths (suspend-to-RAM/hibernate/kexec jump) all deal with disabling and enabling of non-boot CPUs via CPU hotplug explicitly, which will clear them from the online CPU map. We would have to rework the semantics a bit if cpuidle were also permitted to opportunistically offline CPUs.
That's definitely something we'd be interested in looking at. Some upcoming ARM v7 architecture SMP SoCs we're seeing will support full independent clock scaling and power gating for the individual cores -- if there's not enough work to keep the 2nd (or nth) cpu busy, there would be good power savings to be had shutting it down.
I haven't poked around too much with how things work in SMP environments -- are there per-cpu idle threads?
Brian
Quoted 3 lines · Brian Swetland
I haven't poked around too much with how things work in SMP environments -- are there per-cpu idle threads?
Yes, and we recently grew the infrastructure for asymmetric MP in the processing capacity sense.
Quoted 3 lines · Brian Swetland
I haven't poked around too much with how things work in SMP environments -- are there per-cpu idle threads?
Yes, and we recently grew the infrastructure for asymmetric MP in the processing capacity sense.
Quoted 8 lines · On Thu, 27 May 2010 17:09:16 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Alan Stern
Opportunistic suspends are okay.
The proposed userspace API is too Android-specific.
I would argue opportunistic suspends are not ok, and therefore the proposed API is utterly irrelevant.
Assuming you are happy that opportunistically entering C6 and the like is ok via ACPI can you explain why you have a problem with opportunistic suspend and why it is different to a very deep sleep CPU state such as we have now (and which on many embedded platforms we deal with *is* sleeping external devices too)
Alan
Quoted 6 lines
The proposal I made a couple of days ago removes this API and leaves the other things (i.e., the in-kernel suspend blockers and opportunistic suspend) intact. In place of the userspace kernel-blocker API, Android would have to implement a power manager process that would essentially juggle all the latency requirements in userspace.
On the kernel side you really want to add two arguments from day one which is the time in ms and the power state. We have enumerations of current power states (plus add suspend) so this is easy to do. The governors may not use them for a while but ACPI for example can use the latency pretty fast. You want the information there from day one so it is captured otherwise it ends up a right royal pain in the arse adjusting the API later. If the numbers are in but don't always get used it'll be a lot smoother.
Quoted 5 lines
Communication between the power manager process and the kernel would be limited to adding a new "opportunistic" entry to
/sys/power/state-- something which could well be useful in its own right. Even if this API turns out not to be good, it's simple enough that it could be removed pretty easily.
Yes. Probably it really should be linked to a cpufreq driver thing - cpufreq_android or whatever being the starting point but thats not a big deal and it doesn't leak into all the apps either. This is detail however.
Quoted 4 lines
Indeed, having a power manager thread may well turn out to be a useful thing -- but even if it doesn't, this scheme minimizes the damage while still allowing the Android platform to use a vanilla kernel with only limited modifications to their userspace.
There have been some horribly bad attempts to do this, but if it works for Android and its encapsulated in cpufreq_android.c maybe with a private interface to a single supporting daemon then it's not creating bad user APIs, its not peeing in anyone elses pond and the policy will all be in the kernel and a daemon which keeps the wrong platform knowledge out of the application space.
Alan
Quoted 6 lines
The proposal I made a couple of days ago removes this API and leaves the other things (i.e., the in-kernel suspend blockers and opportunistic suspend) intact. In place of the userspace kernel-blocker API, Android would have to implement a power manager process that would essentially juggle all the latency requirements in userspace.
On the kernel side you really want to add two arguments from day one which is the time in ms and the power state. We have enumerations of current power states (plus add suspend) so this is easy to do. The governors may not use them for a while but ACPI for example can use the latency pretty fast. You want the information there from day one so it is captured otherwise it ends up a right royal pain in the arse adjusting the API later. If the numbers are in but don't always get used it'll be a lot smoother.
Quoted 5 lines
Communication between the power manager process and the kernel would be limited to adding a new "opportunistic" entry to
/sys/power/state-- something which could well be useful in its own right. Even if this API turns out not to be good, it's simple enough that it could be removed pretty easily.
Yes. Probably it really should be linked to a cpufreq driver thing - cpufreq_android or whatever being the starting point but thats not a big deal and it doesn't leak into all the apps either. This is detail however.
Quoted 4 lines
Indeed, having a power manager thread may well turn out to be a useful thing -- but even if it doesn't, this scheme minimizes the damage while still allowing the Android platform to use a vanilla kernel with only limited modifications to their userspace.
There have been some horribly bad attempts to do this, but if it works for Android and its encapsulated in cpufreq_android.c maybe with a private interface to a single supporting daemon then it's not creating bad user APIs, its not peeing in anyone elses pond and the policy will all be in the kernel and a daemon which keeps the wrong platform knowledge out of the application space.
Alan
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Signature · 3 lines
balbi DefectiveByDesign.org
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no attention to latencies or other requirements.
Alan Stern
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no attention to latencies or other requirements.
Alan Stern
Quoted 4 lines · Alan Stern
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no attention to latencies or other requirements.
Those are a whole different beast, those are basically a quick-off button like thing. Forced suspend is conceptually a very different beast from power-saving a running system.
Quoted 4 lines · Alan Stern
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no attention to latencies or other requirements.
Those are a whole different beast, those are basically a quick-off button like thing. Forced suspend is conceptually a very different beast from power-saving a running system.
Quoted 9 lines · Peter Zijlstra
Quoted 4 lines · Alan Stern
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no attention to latencies or other requirements.
Those are a whole different beast, those are basically a quick-off button like thing. Forced suspend is conceptually a very different beast from power-saving a running system.
They may be different conceptually. Nevertheless, Android uses forced suspend as a form of power saving. Until better mechanisms are in place, it makes sense.
Alan Stern
Quoted 4 lines · Alan Stern
They may be different conceptually. Nevertheless, Android uses forced suspend as a form of power saving. Until better mechanisms are in place, it makes sense.
So let them, doesn't mean we have to merge it. Or will you saw your foot off too if google were to promotes it?
Quoted 8 lines · Peter Zijlstra
Quoted 4 lines · Alan Stern
They may be different conceptually. Nevertheless, Android uses forced suspend as a form of power saving. Until better mechanisms are in place, it makes sense.
So let them, doesn't mean we have to merge it. Or will you saw your foot off too if google were to promotes it?
Do you have to be offensive to people who disagree with you?
Alan simply wants to understand the _technical_ objections that people have to this patchset and you're not helping. So, could you please explain what exactly is your technical objection to it?
Rafael
Quoted 8 lines · Peter Zijlstra
Quoted 4 lines · Alan Stern
They may be different conceptually. Nevertheless, Android uses forced suspend as a form of power saving. Until better mechanisms are in place, it makes sense.
So let them, doesn't mean we have to merge it. Or will you saw your foot off too if google were to promotes it?
Do you have to be offensive to people who disagree with you?
Alan simply wants to understand the _technical_ objections that people have to this patchset and you're not helping. So, could you please explain what exactly is your technical objection to it?
Rafael
Quoted 4 lines · Alan Stern
They may be different conceptually. Nevertheless, Android uses forced suspend as a form of power saving. Until better mechanisms are in place, it makes sense.
So let them, doesn't mean we have to merge it. Or will you saw your foot off too if google were to promotes it?
Quoted 8 lines · On Thu, 27 May 2010 13:29:18 -0400 (EDT) Alan Stern…
Quoted 6 lines · Peter Zijlstra
Quoted 4 lines · Alan Stern
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no attention to latencies or other requirements.
Quoted 7 lines
Quoted 3 lines
Those are a whole different beast, those are basically a quick-off button like thing. Forced suspend is conceptually a very different beast from power-saving a running system.
They may be different conceptually. Nevertheless, Android uses forced suspend as a form of power saving. Until better mechanisms are in place, it makes sense.
For them, not for Linux.
Several vendors have exciting kernel drivers that do things like binary patch other modules. Until better mechanisms are in place it does *NOT* make sense to merge such stuff.
I don't care what they do in their own tree (consenting adults in their own home and all that) but what they do in the public tree is another matter.
Alan
Quoted 8 lines · On Thu, 27 May 2010 13:29:18 -0400 (EDT) Alan Stern…
Quoted 6 lines · Peter Zijlstra
Quoted 4 lines · Alan Stern
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no attention to latencies or other requirements.
Quoted 7 lines
Quoted 3 lines
Those are a whole different beast, those are basically a quick-off button like thing. Forced suspend is conceptually a very different beast from power-saving a running system.
They may be different conceptually. Nevertheless, Android uses forced suspend as a form of power saving. Until better mechanisms are in place, it makes sense.
For them, not for Linux.
Several vendors have exciting kernel drivers that do things like binary patch other modules. Until better mechanisms are in place it does *NOT* make sense to merge such stuff.
I don't care what they do in their own tree (consenting adults in their own home and all that) but what they do in the public tree is another matter.
Alan
Quoted 9 lines · Peter Zijlstra
Quoted 4 lines · Alan Stern
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no attention to latencies or other requirements.
Those are a whole different beast, those are basically a quick-off button like thing. Forced suspend is conceptually a very different beast from power-saving a running system.
They may be different conceptually. Nevertheless, Android uses forced suspend as a form of power saving. Until better mechanisms are in place, it makes sense.
Alan Stern
Quoted 9 lines · ext Alan Stern
Quoted 7 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
Quoted 7 lines
Quoted 3 lines
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no attention to latencies or other requirements.
no, not at all. I think they are also really useful. But I also think in-kernel suspend blockers are unnecessary. I think runtime pm + cpuidle + cpufreq is well enough for all cases. We just need to give those three information about desired latencies.
Signature · 3 lines
balbi DefectiveByDesign.org
Quoted 9 lines · ext Alan Stern
Quoted 7 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
Quoted 7 lines
Quoted 3 lines
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no attention to latencies or other requirements.
no, not at all. I think they are also really useful. But I also think in-kernel suspend blockers are unnecessary. I think runtime pm + cpuidle
+ cpufreq is well enough for all cases. We just need to give those three information about desired latencies.
Signature · 3 lines
balbi DefectiveByDesign.org
Quoted 9 lines · Alan Stern
Quoted 7 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
Quoted 6 lines
Quoted 3 lines
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no
mem should be replaced by an idle suspend to ram mechanism
Quoted 1 line
attention to latencies or other requirements.
s2disk is a totally different beast as it shuts down the box into the complete power off state.
Thanks,
tglx
Quoted 4 lines · Thomas Gleixner
Quoted 2 lines
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no
mem should be replaced by an idle suspend to ram mechanism
In other words, you are suggesting that not only should the Android patches not be accepted, in addition a large part of the PM suspend framework should be rewritten?
Alan Stern
Quoted 4 lines · Thomas Gleixner
Quoted 2 lines
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no
mem should be replaced by an idle suspend to ram mechanism
In other words, you are suggesting that not only should the Android patches not be accepted, in addition a large part of the PM suspend framework should be rewritten?
Alan Stern
Quoted 11 lines · Thomas Gleixner
Quoted 9 lines · Alan Stern
Quoted 7 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no
mem should be replaced by an idle suspend to ram mechanism
Well, what about when I want the machine to suspend _regardless_ of whether or not it's idle at the moment? That actually happens quite often to me. :-)
Quoted 4 lines
Quoted 1 line
attention to latencies or other requirements.
s2disk is a totally different beast as it shuts down the box into the complete power off state.
I don't see much difference between that and ACPI S3 other than the memory contents are preserved in S3. It also is complete power off state - except for memory refresh and wakeup sources (which also may be active in S4).
Rafael
Quoted 2 lines
Well, what about when I want the machine to suspend _regardless_ of whether or not it's idle at the moment? That actually happens quite often to me. :-)
I don't think it helps to combine them for this discussion ?
Quoted 3 lines
I don't see much difference between that and ACPI S3 other than the memory contents are preserved in S3. It also is complete power off state - except for memory refresh and wakeup sources (which also may be active in S4).
Agreed although I am pushed to think of many real world cases where it might matter. VM's maybe?
Alan
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Thomas Gleixner
Quoted 13 lines · Alan Stern
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no
mem should be replaced by an idle suspend to ram mechanism
Well, what about when I want the machine to suspend _regardless_ of whether or not it's idle at the moment? That actually happens quite often to me. :-)
Fair enough. Let's agree on a non ambigous terminology then:
forced:
suspend which you enforce via user interaction, which also implies that you risk losing wakeups depending on the hardware properties
opportunistic:
suspend driven from the idle context, which guarantees to not lose wakeups. Provided only when the hardware does provide the necessary capabilities.
Thanks,
tglx
Quoted 26 lines · Thomas Gleixner
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Thomas Gleixner
Quoted 13 lines · Alan Stern
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no
mem should be replaced by an idle suspend to ram mechanism
Well, what about when I want the machine to suspend _regardless_ of whether or not it's idle at the moment? That actually happens quite often to me. :-)
Quoted 7 lines
Fair enough. Let's agree on a non ambigous terminology then:
forced:
suspend which you enforce via user interaction, which also implies that you risk losing wakeups depending on the hardware properties
OK
Quoted 5 lines
opportunistic:
suspend driven from the idle context, which guarantees to not lose wakeups. Provided only when the hardware does provide the necessary capabilities.
I can accept that definition, but this is not what "opportunistic" means in the Arve's changelogs. What it means there is that he wants the system to suspend even when it is not technically idle (like in the updatedb example I gave in a previous message). Suspend blockers are supposed to be a mechanism by which the kernel and user space together may determine when to suspend (and it's somewhat orthogonal to idle).
Thanks,
Rafael
Quoted 37 lines · Rafael J. Wysocki
Quoted 26 lines · Thomas Gleixner
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Thomas Gleixner
Quoted 13 lines · Alan Stern
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no
mem should be replaced by an idle suspend to ram mechanism
Well, what about when I want the machine to suspend _regardless_ of whether or not it's idle at the moment? That actually happens quite often to me. :-)
Quoted 7 lines
Fair enough. Let's agree on a non ambigous terminology then:
forced:
suspend which you enforce via user interaction, which also implies that you risk losing wakeups depending on the hardware properties
OK
Quoted 7 lines
Quoted 5 lines
opportunistic:
suspend driven from the idle context, which guarantees to not lose wakeups. Provided only when the hardware does provide the necessary capabilities.
I can accept that definition, but this is not what "opportunistic" means in the
Is there a difference between this new definition of opportunistic and idle? I assume suspend here means low a low power sleep state since it is impossible to initiate and abort Linux suspend from idle since initiating suspend will cause the system to become not idle.
Quoted 6 lines
Arve's changelogs. What it means there is that he wants the system to suspend even when it is not technically idle (like in the updatedb example I gave in a previous message). Suspend blockers are supposed to be a mechanism by which the kernel and user space together may determine when to suspend (and it's somewhat orthogonal to idle).
Signature · 1 line
Arve Hjønnevåg
Quoted 37 lines · Rafael J. Wysocki
Quoted 26 lines · Thomas Gleixner
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Thomas Gleixner
Quoted 13 lines · Alan Stern
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no
mem should be replaced by an idle suspend to ram mechanism
Well, what about when I want the machine to suspend _regardless_ of whether or not it's idle at the moment? That actually happens quite often to me. :-)
Quoted 7 lines
Fair enough. Let's agree on a non ambigous terminology then:
forced:
suspend which you enforce via user interaction, which also implies that you risk losing wakeups depending on the hardware properties
OK
Quoted 7 lines
Quoted 5 lines
opportunistic:
suspend driven from the idle context, which guarantees to not lose wakeups. Provided only when the hardware does provide the necessary capabilities.
I can accept that definition, but this is not what "opportunistic" means in the
Is there a difference between this new definition of opportunistic and idle? I assume suspend here means low a low power sleep state since it is impossible to initiate and abort Linux suspend from idle since initiating suspend will cause the system to become not idle.
Quoted 6 lines
Arve's changelogs. What it means there is that he wants the system to suspend even when it is not technically idle (like in the updatedb example I gave in a previous message). Suspend blockers are supposed to be a mechanism by which the kernel and user space together may determine when to suspend (and it's somewhat orthogonal to idle).
Signature · 1 line
Arve Hjønnevåg
Quoted 26 lines · Thomas Gleixner
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Thomas Gleixner
Quoted 13 lines · Alan Stern
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no
mem should be replaced by an idle suspend to ram mechanism
Well, what about when I want the machine to suspend _regardless_ of whether or not it's idle at the moment? That actually happens quite often to me. :-)
Quoted 7 lines
Fair enough. Let's agree on a non ambigous terminology then:
forced:
suspend which you enforce via user interaction, which also implies that you risk losing wakeups depending on the hardware properties
OK
Quoted 5 lines
opportunistic:
suspend driven from the idle context, which guarantees to not lose wakeups. Provided only when the hardware does provide the necessary capabilities.
I can accept that definition, but this is not what "opportunistic" means in the Arve's changelogs. What it means there is that he wants the system to suspend even when it is not technically idle (like in the updatedb example I gave in a previous message). Suspend blockers are supposed to be a mechanism by which the kernel and user space together may determine when to suspend (and it's somewhat orthogonal to idle).
Thanks,
Rafael
Quoted 26 lines · On Thu, 27 May 2010 23:40:29 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Thomas Gleixner
Quoted 13 lines · Alan Stern
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no
mem should be replaced by an idle suspend to ram mechanism
Well, what about when I want the machine to suspend _regardless_ of whether or not it's idle at the moment? That actually happens quite often to me. :-)
Quoted 7 lines
Fair enough. Let's agree on a non ambigous terminology then:
forced:
suspend which you enforce via user interaction, which also implies that you risk losing wakeups depending on the hardware properties
Reasonable definition I think. However the current implementation doesn't exactly match it.
With the current implementation you risk losing wakeups *independent* of the hardware properties.
Even with ideal hardware events can be lost - by which I mean that they will not be seen until some other event effects a wake-up.
e.g. the interrupt which signals the event happens immediately before the suspend is requested (or maybe at the same time as), but the process which needs to handle the event doesn't get a chance to see it before the suspend procedure freezes that process, and even if it did it would have no way to abort the suspend.
So I submit that the current implementation doesn't match your description of "forced", is therefore buggy, and that if it were fixed, that would be sufficient to meet the immediate needs of android.
NeilBrown
Quoted 15 lines
opportunistic:
suspend driven from the idle context, which guarantees to not lose wakeups. Provided only when the hardware does provide the necessary capabilities.
Thanks,
tglx
--
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 33 lines · Neil Brown
Quoted 30 lines · On Thu, 27 May 2010 23:40:29 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Thomas Gleixner
Quoted 13 lines · Alan Stern
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no
mem should be replaced by an idle suspend to ram mechanism
Well, what about when I want the machine to suspend _regardless_ of whether or not it's idle at the moment? That actually happens quite often to me. :-)
Fair enough. Let's agree on a non ambigous terminology then:
forced:
Quoted 8 lines
Quoted 3 lines
suspend which you enforce via user interaction, which also implies that you risk losing wakeups depending on the hardware properties
Reasonable definition I think. However the current implementation doesn't exactly match it.
With the current implementation you risk losing wakeups *independent* of the hardware properties.
Define "losing", please.
Currently, we simply don't regard hardware signals occuring _during_ the suspend operation itself as wakeups (unless they are wakeup interrupts to be precise, because these _are_ taken into account by our current code).
The reason is that the meaning of given event may be _different_ at run time and after the system has been suspended. For example, consider a power button on a PC box. If it's pressed at run time, it usually means "power off the system" to the kernel. After the system has been suspended, however, it means "wake up". So, you have to switch from one interpretation of the event to the other and that's not an atomic operaition (to put it lightly).
Quoted 11 lines
Even with ideal hardware events can be lost - by which I mean that they will not be seen until some other event effects a wake-up.
e.g. the interrupt which signals the event happens immediately before the suspend is requested (or maybe at the same time as), but the process which needs to handle the event doesn't get a chance to see it before the suspend procedure freezes that process, and even if it did it would have no way to abort the suspend.So I submit that the current implementation doesn't match your description of "forced", is therefore buggy, and that if it were fixed, that would be sufficient to meet the immediate needs of android.
I don't really think it may be fixed with respect to every possible kind of hardware. On platforms where I/O interrupts are wakeup events it should work right now. On other platforms it may be impossible to overcome hardware limitations.
Thanks,
Rafael
Quoted 38 lines · On Tue, 1 Jun 2010 00:05:19 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 37 lines · Neil Brown
Quoted 33 lines · On Thu, 27 May 2010 23:40:29 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Thomas Gleixner
Quoted 13 lines · Alan Stern
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no
mem should be replaced by an idle suspend to ram mechanism
Well, what about when I want the machine to suspend _regardless_ of whether or not it's idle at the moment? That actually happens quite often to me. :-)
Fair enough. Let's agree on a non ambigous terminology then:
forced:
suspend which you enforce via user interaction, which also implies that you risk losing wakeups depending on the hardware properties
Quoted 6 lines
Quoted 4 lines
Reasonable definition I think. However the current implementation doesn't exactly match it.
With the current implementation you risk losing wakeups *independent* of the hardware properties.Define "losing", please.
I did. See next line in my original.
"... by which I mean that they will not be seen until some other event effects a wake-up". By "seen" I mean "a user-space process has had a chance to react to the event, including having the opportunity to abort the suspend (or ensure an immediate wake-up)".
Another way of saying it might be that the event - as an abstract concept - does not reach it's final destination promptly. This "final destination" may be well outside the kernel.
Quoted 11 lines
Currently, we simply don't regard hardware signals occuring _during_ the suspend operation itself as wakeups (unless they are wakeup interrupts to be precise, because these _are_ taken into account by our current code).
The reason is that the meaning of given event may be _different_ at run time and after the system has been suspended. For example, consider a power button on a PC box. If it's pressed at run time, it usually means "power off the system" to the kernel. After the system has been suspended, however, it means "wake up". So, you have to switch from one interpretation of the event to the other and that's not an atomic operaition (to put it lightly).
Yes, a suspend-toggle switch is inherently racy. It is only wake-up sources that are not inherently racy that are interesting. e.g. a serial line from a GSM device which reports "You have an SMS message".
I want to be able to turn my freerunner upside-down by which I tell it (via the accelerometers) that I am done and want it to turn off. If a TXT message comes in just then, I don't want it to suspend, I want it to make an alert noise.
I can put code in to ignore the accelerometer if a txt has just recently come in, but if the TXT arrives just as the write to /sys/power/state starts, the UART interrupt handler could have completed before it has the PRE_SUSPEND method called. So the suspend will complete and the wakeup from the UART will have been "lost" in that the event didn't get all the way to its
destination: my ear.
My freerunner has a single core so without CONFIG_PREEMPT it may be that there is no actual race-window - maybe the PRE_SUSPENDs will all run before a soft_irq thread has a chance to finish handling of the interrupt (my knowledge of these details is limits). But on a muilti-core device I think there would definitely be a race-window.
Thanks,
NeilBrown
Quoted 25 lines
Quoted 9 lines
Even with ideal hardware events can be lost - by which I mean that they will not be seen until some other event effects a wake-up.
e.g. the interrupt which signals the event happens immediately before the suspend is requested (or maybe at the same time as), but the process which needs to handle the event doesn't get a chance to see it before the suspend procedure freezes that process, and even if it did it would have no way to abort the suspend.Quoted 3 lines
So I submit that the current implementation doesn't match your description of "forced", is therefore buggy, and that if it were fixed, that would be sufficient to meet the immediate needs of android.
I don't really think it may be fixed with respect to every possible kind of hardware. On platforms where I/O interrupts are wakeup events it should work right now. On other platforms it may be impossible to overcome hardware limitations.
Thanks,
Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 46 lines · Neil Brown
Quoted 43 lines · On Tue, 1 Jun 2010 00:05:19 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 41 lines · Neil Brown
Quoted 26 lines · On Thu, 27 May 2010 23:40:29 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Thomas Gleixner
Quoted 13 lines · Alan Stern
Quoted 10 lines · Felipe Balbi
Quoted 5 lines · ext Alan Stern
If people don't mind, here is a greatly simplified summary of the comments and objections I have seen so far on this thread:
The in-kernel suspend blocker implementation is okay, even beneficial.
I disagree here. I believe expressing that as QoS is much better. Let the kernel decide which power state is better as long as I can say I need 100us IRQ latency or 100ms wakeup latency.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Does this mean you believe "echo mem >/sys/power/state" is bad and should be removed? Or "echo disk >/sys/power/state"? They pay no
mem should be replaced by an idle suspend to ram mechanism
Well, what about when I want the machine to suspend _regardless_ of whether or not it's idle at the moment? That actually happens quite often to me. :-)
Quoted 7 lines
Fair enough. Let's agree on a non ambigous terminology then:
forced:
suspend which you enforce via user interaction, which also implies that you risk losing wakeups depending on the hardware properties
Reasonable definition I think. However the current implementation doesn't exactly match it.
With the current implementation you risk losing wakeups *independent* of the hardware properties.
Quoted 5 lines
Quoted 1 line
Define "losing", please.
I did. See next line in my original.
"... by which I mean that they will not be seen until some other event effects a wake-up".
OK, sorry.
Quoted 11 lines
By "seen" I mean "a user-space process has had a chance
to react to the event, including having the opportunity to abort the suspend (or ensure an immediate wake-up)".
Another way of saying it might be that the event - as an abstract concept - does not reach it's final destination promptly. This "final destination" may be well outside the kernel.Quoted 4 lines
Currently, we simply don't regard hardware signals occuring _during_ the suspend operation itself as wakeups (unless they are wakeup interrupts to be precise, because these _are_ taken into account by our current code).
Quoted 8 lines
Quoted 6 lines
The reason is that the meaning of given event may be _different_ at run time and after the system has been suspended. For example, consider a power button on a PC box. If it's pressed at run time, it usually means "power off the system" to the kernel. After the system has been suspended, however, it means "wake up". So, you have to switch from one interpretation of the event to the other and that's not an atomic operaition (to put it lightly).
Yes, a suspend-toggle switch is inherently racy.
For this reason we generally have to assume that some events occuring during suspend will only be seen by user space after resume. Now, since we make such an assumption anyway, there's a little point working around some races related to it while leaving the others as they are (that wouldn't improve things all that much).
Quoted 4 lines
It is only wake-up sources that are not inherently racy that are interesting. e.g. a serial line from a GSM device which reports "You have an SMS message". I want to be able to turn my freerunner upside-down by which I tell it (via the accelerometers) that I am done and want it to turn off. If a TXT message
Quoted 8 lines
comes in just then, I don't want it to suspend, I want it to make an alert noise.
I can put code in to ignore the accelerometer if a txt has just recently come in, but if the TXT arrives just as the write to/sys/power/statestarts, the UART interrupt handler could have completed before it has thePRE_SUSPENDmethod called. So the suspend will complete and the wakeup from the UART will have been "lost" in that the event didn't get all the way to its
destination: my ear.
As I said before, we generally can't prevent such things from happening, because even if we handle the particular race described above, it still is possible that the event will be "lost" if it arrives just a bit later (eg. during a suspend-toggle switch). So the PRE_SUSPEND thing won't really solve the entire problem while increasing complexity.
Quoted 5 lines
My freerunner has a single core so without
CONFIG_PREEMPTit may be that there is no actual race-window - maybe thePRE_SUSPENDswill all run before asoft_irqthread has a chance to finish handling of the interrupt (my knowledge of these details is limits). But on a muilti-core device I think there would definitely be a race-window.
Yes, there always will be a race window. The only thing we can do is to narrow it, but we cannot really close it (at least not on a PC, but I'm not really sure it can be closed at all).
If you really want _all_ events to be delivered timely, the only way to go is to avoid using suspend (and use the idle framework for power management).
Thanks,
Rafael
Quoted 10 lines · Rafael J. Wysocki
Quoted 5 lines · Neil Brown
My freerunner has a single core so without
CONFIG_PREEMPTit may be that there is no actual race-window - maybe thePRE_SUSPENDswill all run before asoft_irqthread has a chance to finish handling of the interrupt (my knowledge of these details is limits). But on a muilti-core device I think there would definitely be a race-window.Yes, there always will be a race window. The only thing we can do is to narrow it, but we cannot really close it (at least not on a PC, but I'm not really sure it can be closed at all).
It can be closed, when the state transition from normal event delivery to wakeup mode is state safe, which it is on most platforms which are designed for the mobile space.
Not so the current PC style x86 platforms, which are not relevant for the problem at hand at all. Really, that stuff is going either to gain sane properties or it's just going into the irrelevant realm.
Any attempt to solve the current x86/ACPI/BIOS/mess is waste of time and is inevitably going to prevent progress.
Quoted 2 lines
If you really want _all_ events to be delivered timely, the only way to go is to avoid using suspend (and use the idle framework for power management).
Amen.
tglx
Quoted 10 lines · Rafael J. Wysocki
Quoted 5 lines · Neil Brown
My freerunner has a single core so without
CONFIG_PREEMPTit may be that there is no actual race-window - maybe thePRE_SUSPENDswill all run before asoft_irqthread has a chance to finish handling of the interrupt (my knowledge of these details is limits). But on a muilti-core device I think there would definitely be a race-window.Yes, there always will be a race window. The only thing we can do is to narrow it, but we cannot really close it (at least not on a PC, but I'm not really sure it can be closed at all).
It can be closed, when the state transition from normal event delivery to wakeup mode is state safe, which it is on most platforms which are designed for the mobile space.
Not so the current PC style x86 platforms, which are not relevant for the problem at hand at all. Really, that stuff is going either to gain sane properties or it's just going into the irrelevant realm.
Any attempt to solve the current x86/ACPI/BIOS/mess is waste of time and is inevitably going to prevent progress.
Quoted 2 lines
If you really want _all_ events to be delivered timely, the only way to go is to avoid using suspend (and use the idle framework for power management).
Amen.
tglx
Quoted 24 lines · On Tue, 1 Jun 2010 02:32:20 +0200 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 10 lines · Neil Brown
I want to be able to turn my freerunner upside-down by which I tell it (via the accelerometers) that I am done and want it to turn off. If a TXT message comes in just then, I don't want it to suspend, I want it to make an alert noise.
I can put code in to ignore the accelerometer if a txt has just recently come in, but if the TXT arrives just as the write to/sys/power/statestarts, the UART interrupt handler could have completed before it has thePRE_SUSPENDmethod called. So the suspend will complete and the wakeup from the UART will have been "lost" in that the event didn't get all the way to its
destination: my ear.As I said before, we generally can't prevent such things from happening, because even if we handle the particular race described above, it still is possible that the event will be "lost" if it arrives just a bit later (eg. during a suspend-toggle switch). So the
PRE_SUSPENDthing won't really solve the entire problem while increasing complexity.Quoted 5 lines
My freerunner has a single core so without
CONFIG_PREEMPTit may be that there is no actual race-window - maybe thePRE_SUSPENDswill all run before asoft_irqthread has a chance to finish handling of the interrupt (my knowledge of these details is limits). But on a muilti-core device I think there would definitely be a race-window.
Quoted 3 lines
Yes, there always will be a race window. The only thing we can do is to narrow it, but we cannot really close it (at least not on a PC, but I'm not really sure it can be closed at all).
Well you are the expert so I assume you are right, but I would really like to understand why this is.
I guess that if the event was delivered as an edge-triggered interrupt which the interrupt controller couldn't latch, then it might get lost. Is that what happens?
But if the event comes in as a level-triggered (or latched) interrupt, then the driver simply chooses not to acknowledge the interrupt after PRE_SUSPEND until RESUME. Then any suspend would immediately be woken. Maybe the window for ignoring interrupt would have to be a bit smaller than that, but it should be a well defined window that can be locked.
Why cannot we carry this sort of guarantee all the way up to user-space and beyond? Am I completely misunderstanding the hardware?
And if you are right that the race window cannot be closed, then the whole suspend-blocker infrastructure is pointless as the purpose of it is simply to close that window. If it really does not and cannot work, then it would be best to reject it for that reason rather than for less concrete aesthetic arguments.
But presumably it does work in practice on Android hardware so ..... confused.
Having just seen the email from Thomas, maybe you mean that it cannot be closed on devices using ACPI, but can on other devices. I can sort-of imagine how that would be the case (I tried reading an ACPI spec once - my hat is of to those of you who understand it).
That shouldn't prevent us from closing the race window on "sane" hardware that allows it. This would, I think, be sufficient for Android's needs.
I'm hoping we can get agreement on:
- there is a race with suspend
- it can be closed on the sort of hardware that is typically used in the mobile space
- closing it would address the need which lead to the suspend-block proposal.
If we have agreement on that, we can move on to
- should we close the race? (hopefully "yes" because bugs should be fixed).
- how should we close the race? (lots of room for exploration there).
Thanks,
NeilBrown
Quoted 14 lines · Neil Brown
And if you are right that the race window cannot be closed, then the whole suspend-blocker infrastructure is pointless as the purpose of it is simply to close that window. If it really does not and cannot work, then it would be best to reject it for that reason rather than for less concrete aesthetic arguments.
But presumably it does work in practice on Android hardware so ..... confused.Having just seen the email from Thomas, maybe you mean that it cannot be closed on devices using ACPI, but can on other devices. I can sort-of imagine how that would be the case (I tried reading an ACPI spec once - my hat is of to those of you who understand it).
That shouldn't prevent us from closing the race window on "sane" hardware that allows it. This would, I think, be sufficient for Android's needs.
Quoted 2 lines
I'm hoping we can get agreement on:
- there is a race with suspend
That's a matter of how you define "suspend".
If "suspend" is another deep idle state and the hardware is sane, there is no race at all - assumed that the driver/platform developer got it right. It's not rocket science to transition from "normal" irq delivery to wakeup based delivery raceless (except for PC style x86 hardware of today)
If "suspend" is the thing we are used to via /sys/power/state then the race will persist forever except for the suspend blocker workaround, which we can express in QoS terms as well w/o adding another suspend related user space API.
Thanks,
tglx
Quoted 14 lines · Neil Brown
And if you are right that the race window cannot be closed, then the whole suspend-blocker infrastructure is pointless as the purpose of it is simply to close that window. If it really does not and cannot work, then it would be best to reject it for that reason rather than for less concrete aesthetic arguments.
But presumably it does work in practice on Android hardware so ..... confused.Having just seen the email from Thomas, maybe you mean that it cannot be closed on devices using ACPI, but can on other devices. I can sort-of imagine how that would be the case (I tried reading an ACPI spec once - my hat is of to those of you who understand it).
That shouldn't prevent us from closing the race window on "sane" hardware that allows it. This would, I think, be sufficient for Android's needs.
Quoted 2 lines
I'm hoping we can get agreement on:
- there is a race with suspend
That's a matter of how you define "suspend".
If "suspend" is another deep idle state and the hardware is sane, there is no race at all - assumed that the driver/platform developer got it right. It's not rocket science to transition from "normal" irq delivery to wakeup based delivery raceless (except for PC style x86 hardware of today)
If "suspend" is the thing we are used to via /sys/power/state then the race will persist forever except for the suspend blocker workaround, which we can express in QoS terms as well w/o adding another suspend related user space API.
Thanks,
tglx
Quoted 15 lines · On Tue, 1 Jun 2010 03:49:37 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 14 lines · Neil Brown
And if you are right that the race window cannot be closed, then the whole suspend-blocker infrastructure is pointless as the purpose of it is simply to close that window. If it really does not and cannot work, then it would be best to reject it for that reason rather than for less concrete aesthetic arguments.
But presumably it does work in practice on Android hardware so ..... confused.Having just seen the email from Thomas, maybe you mean that it cannot be closed on devices using ACPI, but can on other devices. I can sort-of imagine how that would be the case (I tried reading an ACPI spec once - my hat is of to those of you who understand it).
That shouldn't prevent us from closing the race window on "sane" hardware that allows it. This would, I think, be sufficient for Android's needs.
Quoted 4 lines
Quoted 2 lines
I'm hoping we can get agreement on:
- there is a race with suspendThat's a matter of how you define "suspend".
I define "suspend" as
echo mem > /sys/power/state
Quoted 11 lines
If "suspend" is another deep idle state and the hardware is sane, there is no race at all - assumed that the driver/platform developer got it right. It's not rocket science to transition from "normal" irq delivery to wakeup based delivery raceless (except for PC style x86 hardware of today)
If "suspend" is the thing we are used to via
/sys/power/statethen the race will persist forever except for the suspend blocker workaround, which we can express in QoS terms as well w/o adding another suspend related user space API.
I'm not interested in adding another user-space API if it can possibly be avoided, and I think it can. But that is a later step in the process.
I think you have acknowledged that there is a race with suspend - thanks. Next step was "can it be closed".
You seem to suggest that it can, but you describe it as a "work around" rather than a "bug fix"...
Do you agree that the race is a "bug", and therefore it is appropriate to "fix" it assuming an acceptable fix can be found (which I think it can)?
If you agree that it is appropriate for try to fix this bug, then the next step would be to get the Android devs to agree that a fix could - in principle - address the need for which they created suspend-blockers.
Arve: can you confirm that?
Then, with a clear and agreed goal, we can look at possible fixes.
Thanks,
NeilBrown
Quoted 4 lines
Thanks,
tglx
Quoted 9 lines · On Tue, 1 Jun 2010 12:20:12 +1000 Neil Brown <[email protected]> wrote:
Quoted 5 lines · On Tue, 1 Jun 2010 03:49:37 +0200 (CEST) Thomas Gleixner <[email protected]>…
If "suspend" is another deep idle state and the hardware is sane, there is no race at all - assumed that the driver/platform developer got it right. It's not rocket science to transition from "normal" irq delivery to wakeup based delivery raceless (except for PC style x86 hardware of today)
Quoted 4 lines
Quoted 4 lines
If "suspend" is the thing we are used to via
/sys/power/statethen the race will persist forever except for the suspend blocker workaround, which we can express in QoS terms as well w/o adding another suspend related user space API.
Can you explain the difference between the /sys/power/state thing? Is it the reprogramming of wake-sources as mentioned by Raffael?
In an idle based suspend I assume there would be no new wake-sources on suspending.
Quoted 7 lines
I'm not interested in adding another user-space API if it can possibly be avoided, and I think it can. But that is a later step in the process.
I think you have acknowledged that there is a race with suspend - thanks. Next step was "can it be closed".
You seem to suggest that it can, but you describe it as a "work around" rather than a "bug fix"...
Well as far as I get it, the workaround is to not suspend in sitations where a race is likely to occur. (I.e. block suspend)
Quoted 9 lines
Do you agree that the race is a "bug", and therefore it is appropriate to "fix" it assuming an acceptable fix can be found (which I think it can)?
If you agree that it is appropriate for try to fix this bug, then the next step would be to get the Android devs to agree that a fix could - in principle - address the need for which they created suspend-blockers.
Arve: can you confirm that?
Quoted 9 lines
Then, with a clear and agreed goal, we can look at possible fixes.
Thanks,
NeilBrownQuoted 4 lines
Thanks,
tglx
cheers,
Flo
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
If "suspend" is the thing we are used to via
/sys/power/statethen theQuoted 1 line
Quoted 1 line
race will persist forever except for the suspend blocker workaround,
True, because device wakeups are enabled by device.driver.suspend() methods, which are invoked towards the end of the activities triggered by writing /sys/power/state.
Now, there can be platforms (mostly embedded) where the drivers adopt a policy that not only do they keep their devices in as low a power state as practical at all times, but they also keep the hardware wakeup mechanisms enabled (they may be needed to kick the hardware out of those low power states) ... That is, suspend() might be superfluous (a NOP) in those platforms' drivers.
Such platforms might also be (non-ACPI) ones where idle C-states and S3/STR have the same power consumption ... but that would be a platform-specific issue, not a generic thing which all Linux implementations could rely on.
- Dave
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
If "suspend" is the thing we are used to via
/sys/power/statethen theQuoted 1 line
Quoted 1 line
race will persist forever except for the suspend blocker workaround,
True, because device wakeups are enabled by device.driver.suspend() methods, which are invoked towards the end of the activities triggered by writing /sys/power/state.
Now, there can be platforms (mostly embedded) where the drivers adopt a policy that not only do they keep their devices in as low a power state as practical at all times, but they also keep the hardware wakeup mechanisms enabled (they may be needed to kick the hardware out of those low power states) ... That is, suspend() might be superfluous (a NOP) in those platforms' drivers.
Such platforms might also be (non-ACPI) ones where idle C-states and S3/STR have the same power consumption ... but that would be a platform-specific issue, not a generic thing which all Linux implementations could rely on.
- Dave
Quoted 9 lines · On Tue, 1 Jun 2010 12:20:12 +1000 Neil Brown <[email protected]> wrote:
Quoted 5 lines · On Tue, 1 Jun 2010 03:49:37 +0200 (CEST) Thomas Gleixner <[email protected]>…
If "suspend" is another deep idle state and the hardware is sane, there is no race at all - assumed that the driver/platform developer got it right. It's not rocket science to transition from "normal" irq delivery to wakeup based delivery raceless (except for PC style x86 hardware of today)
Quoted 4 lines
Quoted 4 lines
If "suspend" is the thing we are used to via
/sys/power/statethen the race will persist forever except for the suspend blocker workaround, which we can express in QoS terms as well w/o adding another suspend related user space API.
Can you explain the difference between the /sys/power/state thing? Is it the reprogramming of wake-sources as mentioned by Raffael?
In an idle based suspend I assume there would be no new wake-sources on suspending.
Quoted 7 lines
I'm not interested in adding another user-space API if it can possibly be avoided, and I think it can. But that is a later step in the process.
I think you have acknowledged that there is a race with suspend - thanks. Next step was "can it be closed".
You seem to suggest that it can, but you describe it as a "work around" rather than a "bug fix"...
Well as far as I get it, the workaround is to not suspend in sitations where a race is likely to occur. (I.e. block suspend)
Quoted 9 lines
Do you agree that the race is a "bug", and therefore it is appropriate to "fix" it assuming an acceptable fix can be found (which I think it can)?
If you agree that it is appropriate for try to fix this bug, then the next step would be to get the Android devs to agree that a fix could - in principle - address the need for which they created suspend-blockers.
Arve: can you confirm that?
Quoted 9 lines
Then, with a clear and agreed goal, we can look at possible fixes.
Thanks,
NeilBrownQuoted 4 lines
Thanks,
tglx
cheers,
Flo
Quoted 8 lines · Neil Brown
I think you have acknowledged that there is a race with suspend - thanks. Next step was "can it be closed".
You seem to suggest that it can, but you describe it as a "work around" rather than a "bug fix"...Do you agree that the race is a "bug", and therefore it is appropriate to "fix" it assuming an acceptable fix can be found (which I think it can)?
If we can fix it, yes we definitely should do and not work around it.
Thanks,
tglx
Quoted 8 lines · Neil Brown
I think you have acknowledged that there is a race with suspend - thanks. Next step was "can it be closed".
You seem to suggest that it can, but you describe it as a "work around" rather than a "bug fix"...Do you agree that the race is a "bug", and therefore it is appropriate to "fix" it assuming an acceptable fix can be found (which I think it can)?
If we can fix it, yes we definitely should do and not work around it.
Thanks,
tglx
PATCH 1/1 - race-free suspend. Was: Re: [linux-pm] [PATCH 0/8] Suspend block api (version 8)
Quoted 7 lines · On Tue, 1 Jun 2010 12:50:01 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 6 lines · Neil Brown
I think you have acknowledged that there is a race with suspend - thanks. Next step was "can it be closed".
You seem to suggest that it can, but you describe it as a "work around" rather than a "bug fix"...
Quoted 8 lines
Quoted 2 lines
Do you agree that the race is a "bug", and therefore it is appropriate to "fix" it assuming an acceptable fix can be found (which I think it can)?
If we can fix it, yes we definitely should do and not work around it.
Thanks,
tglx
OK.
Here is my suggestion.
While I think this patch would actually work, and hope the ugly aspects are reasonably balanced by the simplicity, I present it primarily as a base for improvement.
The important part is to present how drivers and user-space can co-operate to avoid losing wake-events. The details of what happens in the kernel are certainly up for discussion (as is everything else really of course).
The user-space suspend daemon avoids losing wake-events by using fcntl(F_OWNER) to ensure it gets a signal whenever any important wake-event is ready to be read by user-space. This may involve:
- the one daemon processing all wake events
- Both the suspend daemon and the main event handling daemon opening any given device that delivers wake events (this should work with input events ... unless grabbing is needed)
- The event handling daemon giving the suspend-daemon's pid as F_OWNER, and using poll/select to get the events itself.
When 'mem' is written to /sys/power/state, suspend_prepare waits in an interruptible wait until any wake-event that might have been initiated before the suspend was request, has had a chance to be queued for user-space and trigger kill_fasync.
Currently this wait is a configurable time after the last wake-event was initiated. This is hackish, but simple and probably adequate.
If more precise timing is needed and achievable, that can be added later. It would be an entirely internal change and would not affect the API further. Some of the code developed for suspend-blockers might be a starting point for this.
Drivers should call pm_suspend_delay() whenever a wake-event occurs. This simply records the time so that the suspend process knows if there is in fact any need to wait at all.
The delay to wait after the last pm_suspend_delay() is limited to 10 seconds and can be set by kernel parameter suspend_block_delay=number-of-milliseconds It defaults to 2 jiffies (which is possibly too short).
- Would this fix the "bug"??
- and address the issues that suspend-blockers was created to address?
- or are the requirements on user-space too onerous?
Thanks,
NeilBrown
include/linux/suspend.h +2 -0
@@ -142,11 +142,13 @@ extern void arch_suspend_disable_irqs(void);extern void arch_suspend_enable_irqs (void );extern int pm_suspend (suspend_state_t state); +extern void pm_suspend_delay (void );#else /* !CONFIG_SUSPEND */ #define suspend_valid_only_mem NULLstatic inline void suspend_set_ops (struct platform_suspend_ops *ops) {}static inline int pm_suspend (suspend_state_t state) {return -ENOSYS ; } +static inlint void pm_suspend_delay(void) {}#endif /* !CONFIG_SUSPEND */ /* struct pbe is used for creating lists of pages that should be restored
kernel/power/suspend.c +67 -0
79 lines not on this page · raw message
Re: [PATCH] - race-free suspend. Was: Re: [PATCH 0/8] Suspend block api (version 8)
Quoted 29 lines · Neil Brown
Quoted 7 lines · On Tue, 1 Jun 2010 12:50:01 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 6 lines · Neil Brown
I think you have acknowledged that there is a race with suspend - thanks. Next step was "can it be closed".
You seem to suggest that it can, but you describe it as a "work around" rather than a "bug fix"...Quoted 8 lines
Quoted 2 lines
Do you agree that the race is a "bug", and therefore it is appropriate to "fix" it assuming an acceptable fix can be found (which I think it can)?
If we can fix it, yes we definitely should do and not work around it.
Thanks,
tglx
OK.
Here is my suggestion.While I think this patch would actually work, and hope the ugly aspects are reasonably balanced by the simplicity, I present it primarily as a base for improvement.
The important part is to present how drivers and user-space can co-operate to avoid losing wake-events. The details of what happens in the kernel are certainly up for discussion (as is everything else really of course).
Quoted 4 lines
The user-space suspend daemon avoids losing wake-events by using
fcntl(F_OWNER)to ensure it gets a signal whenever any important wake-event is ready to be read by user-space. This may involve:
- the one daemon processing all wake events
Wake up events are not all processed by one daemon.
Quoted 3 lines
- Both the suspend daemon and the main event handling daemon opening any given device that delivers wake events (this should work with input events ... unless grabbing is needed)
Not all wakeup events are broadcast like input events so they cannot be read by both daemons. Not that this really matters, since reading the event from the suspend daemon does not mean that it has been delivered to and processed by the other daemon.
Quoted 2 lines
- The event handling daemon giving the suspend-daemon's pid as
F_OWNER, and using poll/select to get the events itself.
I don't like the idea of using signals for this. Without the hack Alan Stern suggested, you will temporarily block suspend if the wakeup event happened before the suspend daemon thread made it to the kernel, but abort suspend if it happened right after.
Quoted 5 lines
When 'mem' is written to
/sys/power/state,suspend_preparewaits in an interruptible wait until any wake-event that might have been initiated before the suspend was request, has had a chance to be queued for user-space and triggerkill_fasync.
And what happens if you are not waiting when this happens?
Quoted 2 lines
Currently this wait is a configurable time after the last wake-event was initiated. This is hackish, but simple and probably adequate.
Waiting after a wake event is the same as suspend_block_timeout. This is useful when passing events through layers of code that does no block suspend, but we should strive to avoid it. Other people had much stronger objections to this, which is why it is not included in the last suspend blocker patchset.
It also does not work for drivers that need to block suspend for more than a few seconds. For instance the gpio keypad matrix driver needs to block suspend while keys are pressed so it can scan the keypad.
Quoted 128 lines
If more precise timing is needed and achievable, that can be added later. It would be an entirely internal change and would not affect the API further. Some of the code developed for suspend-blockers might be a starting point for this.
Drivers should call
pm_suspend_delay()whenever a wake-event occurs. This simply records the time so that the suspend process knows if there is in fact any need to wait at all.The delay to wait after the last
pm_suspend_delay()is limited to 10 seconds and can be set by kernel parameter suspend_block_delay=number-of-milliseconds It defaults to 2 jiffies (which is possibly too short).- Would this fix the "bug"??
- and address the issues that suspend-blockers was created to address?
- or are the requirements on user-space too onerous?Thanks,
NeilBrownSigned-off-by NeilBrown <[email protected]>include/linux/suspend.h +2
-0@@ -142,11 +142,13 @@ extern void arch_suspend_disable_irqs(void); extern void arch_suspend_enable_irqs(void); extern int pm_suspend(suspend_state_t state); +extern void pm_suspend_delay (void ); #else /* !CONFIG_SUSPEND */ #define suspend_valid_only_mem NULL static inline void suspend_set_ops(struct platform_suspend_ops *ops) {} static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; } +static inlint void pm_suspend_delay(void) {} #endif /* !CONFIG_SUSPEND */ /* struct pbe is used for creating lists of pages that should be restoredkernel/power/suspend.c +67
-0@@ -46,6 +46,69 @@ bool valid_state(suspend_state_t state) return suspend_ops && suspend_ops->valid && suspend_ops->valid(state); } +/* +* Devices that process potential wake-up events report each +* wake-up events by pm_suspend_delay(); +* This ensures that suspend won't happen for a "little while" +* so the event has a chance to get to user-space. +* pm_suspend calls wait_for_blockers to wait the required +* "little while" and to check for signals. +* A process that requests a suspend should arrange (via +* fcntl(F_GETOWN)) to get signalled whenever a wake-up event +* is queued for user-space. This will ensure that if a suspend +* is requested at much the same time as a wakeup event arrives, either +* the suspend will be interrupted, or it will complete quickly. +* +* The "little while" is a heuristic to avoid having to explicitly +* track every event through the kernel with associated locking and unlocking. +* It should be more than the longest time it can take between an interrupt +* occurring and the corresponding event being queued to userspace +* (and the accompanying kill_fasync call). +* This duration is configurable at boot time, has a lower limit of 2 +* jiffies and an upper limit of 10 seconds. It defaults to the minimum. +*/ +static unsigned long little_while_jiffies =2 ; +static int __init setup_suspend_block_delay (char *str) +{ + unsigned long msec; + if (sscanf(str, "%lu", &msec) != 1) + return 1; + if (msec > 10000) + msec = 10000; + little_while_jiffies = msecs_to_jiffies(msec); + if (little_while_jiffies < 2) + little_while_jiffies = 2; + return 1; +} +__setup ("suspend_block_delay=" , setup_suspend_block_delay); + +static unsigned long next_little_while; +void pm_suspend_delay () +{ + unsigned long then = jiffies + little_while_jiffies; + + if (then != next_little_while) + next_little_while = then; +} +EXPORT_SYMBOL_GPL (pm_suspend_delay); + +static int wait_for_blockers (void ) +{ + unsigned long timeout; + + if (time_after(jiffies, next_little_while)) + return 0; + timeout = next_little_while - jiffies; + if (timeout > msecs_to_jiffies(10000)) + /* jiffy wrap */ + return 0; + + while (timeout && !signal_pending(current)) + timeout = schedule_timeout_interruptible(timeout); + if (signal_pending(current)) + return -EINTR; + return 0; +} /*** suspend_valid_only_mem - generic memory-only valid callback * @@ -89,6 +152,10 @@ static int suspend_prepare(void) if (error) goto Finish; + error = wait_for_blockers(); + if (error) + goto Finish; + error = usermodehelper_disable(); if (error) goto Finish;
Signature · 1 line
Arve Hjønnevåg
Re: [PATCH] - race-free suspend. Was: Re: [linux-pm] [PATCH 0/8] Suspend block api (version 8)
In reply to Neil BrownQuoted 29 lines · Neil Brown
Quoted 7 lines · On Tue, 1 Jun 2010 12:50:01 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 6 lines · Neil Brown
I think you have acknowledged that there is a race with suspend - thanks. Next step was "can it be closed".
You seem to suggest that it can, but you describe it as a "work around" rather than a "bug fix"...Quoted 8 lines
Quoted 2 lines
Do you agree that the race is a "bug", and therefore it is appropriate to "fix" it assuming an acceptable fix can be found (which I think it can)?
If we can fix it, yes we definitely should do and not work around it.
Thanks,
tglx
OK.
Here is my suggestion.While I think this patch would actually work, and hope the ugly aspects are reasonably balanced by the simplicity, I present it primarily as a base for improvement.
The important part is to present how drivers and user-space can co-operate to avoid losing wake-events. The details of what happens in the kernel are certainly up for discussion (as is everything else really of course).
Quoted 4 lines
The user-space suspend daemon avoids losing wake-events by using
fcntl(F_OWNER)to ensure it gets a signal whenever any important wake-event is ready to be read by user-space. This may involve:
- the one daemon processing all wake events
Wake up events are not all processed by one daemon.
Quoted 3 lines
- Both the suspend daemon and the main event handling daemon opening any given device that delivers wake events (this should work with input events ... unless grabbing is needed)
Not all wakeup events are broadcast like input events so they cannot be read by both daemons. Not that this really matters, since reading the event from the suspend daemon does not mean that it has been delivered to and processed by the other daemon.
Quoted 2 lines
- The event handling daemon giving the suspend-daemon's pid as
F_OWNER, and using poll/select to get the events itself.
I don't like the idea of using signals for this. Without the hack Alan Stern suggested, you will temporarily block suspend if the wakeup event happened before the suspend daemon thread made it to the kernel, but abort suspend if it happened right after.
Quoted 5 lines
When 'mem' is written to
/sys/power/state,suspend_preparewaits in an interruptible wait until any wake-event that might have been initiated before the suspend was request, has had a chance to be queued for user-space and triggerkill_fasync.
And what happens if you are not waiting when this happens?
Quoted 2 lines
Currently this wait is a configurable time after the last wake-event was initiated. This is hackish, but simple and probably adequate.
Waiting after a wake event is the same as suspend_block_timeout. This is useful when passing events through layers of code that does no block suspend, but we should strive to avoid it. Other people had much stronger objections to this, which is why it is not included in the last suspend blocker patchset.
It also does not work for drivers that need to block suspend for more than a few seconds. For instance the gpio keypad matrix driver needs to block suspend while keys are pressed so it can scan the keypad.
Quoted 128 lines
If more precise timing is needed and achievable, that can be added later. It would be an entirely internal change and would not affect the API further. Some of the code developed for suspend-blockers might be a starting point for this.
Drivers should call
pm_suspend_delay()whenever a wake-event occurs. This simply records the time so that the suspend process knows if there is in fact any need to wait at all.The delay to wait after the last
pm_suspend_delay()is limited to 10 seconds and can be set by kernel parameter suspend_block_delay=number-of-milliseconds It defaults to 2 jiffies (which is possibly too short).- Would this fix the "bug"??
- and address the issues that suspend-blockers was created to address?
- or are the requirements on user-space too onerous?Thanks,
NeilBrownSigned-off-by NeilBrown <[email protected]>include/linux/suspend.h +2
-0@@ -142,11 +142,13 @@ extern void arch_suspend_disable_irqs(void); extern void arch_suspend_enable_irqs(void); extern int pm_suspend(suspend_state_t state); +extern void pm_suspend_delay (void ); #else /* !CONFIG_SUSPEND */ #define suspend_valid_only_mem NULL static inline void suspend_set_ops(struct platform_suspend_ops *ops) {} static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; } +static inlint void pm_suspend_delay(void) {} #endif /* !CONFIG_SUSPEND */ /* struct pbe is used for creating lists of pages that should be restoredkernel/power/suspend.c +67
-0@@ -46,6 +46,69 @@ bool valid_state(suspend_state_t state) return suspend_ops && suspend_ops->valid && suspend_ops->valid(state); } +/* +* Devices that process potential wake-up events report each +* wake-up events by pm_suspend_delay(); +* This ensures that suspend won't happen for a "little while" +* so the event has a chance to get to user-space. +* pm_suspend calls wait_for_blockers to wait the required +* "little while" and to check for signals. +* A process that requests a suspend should arrange (via +* fcntl(F_GETOWN)) to get signalled whenever a wake-up event +* is queued for user-space. This will ensure that if a suspend +* is requested at much the same time as a wakeup event arrives, either +* the suspend will be interrupted, or it will complete quickly. +* +* The "little while" is a heuristic to avoid having to explicitly +* track every event through the kernel with associated locking and unlocking. +* It should be more than the longest time it can take between an interrupt +* occurring and the corresponding event being queued to userspace +* (and the accompanying kill_fasync call). +* This duration is configurable at boot time, has a lower limit of 2 +* jiffies and an upper limit of 10 seconds. It defaults to the minimum. +*/ +static unsigned long little_while_jiffies =2 ; +static int __init setup_suspend_block_delay (char *str) +{ + unsigned long msec; + if (sscanf(str, "%lu", &msec) != 1) + return 1; + if (msec > 10000) + msec = 10000; + little_while_jiffies = msecs_to_jiffies(msec); + if (little_while_jiffies < 2) + little_while_jiffies = 2; + return 1; +} +__setup ("suspend_block_delay=" , setup_suspend_block_delay); + +static unsigned long next_little_while; +void pm_suspend_delay () +{ + unsigned long then = jiffies + little_while_jiffies; + + if (then != next_little_while) + next_little_while = then; +} +EXPORT_SYMBOL_GPL (pm_suspend_delay); + +static int wait_for_blockers (void ) +{ + unsigned long timeout; + + if (time_after(jiffies, next_little_while)) + return 0; + timeout = next_little_while - jiffies; + if (timeout > msecs_to_jiffies(10000)) + /* jiffy wrap */ + return 0; + + while (timeout && !signal_pending(current)) + timeout = schedule_timeout_interruptible(timeout); + if (signal_pending(current)) + return -EINTR; + return 0; +} /*** suspend_valid_only_mem - generic memory-only valid callback * @@ -89,6 +152,10 @@ static int suspend_prepare(void) if (error) goto Finish; + error = wait_for_blockers(); + if (error) + goto Finish; + error = usermodehelper_disable(); if (error) goto Finish;
Signature · 5 lines
Arve Hjønnevåg -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] - race-free suspend. Was: Re: [PATCH 0/8] Suspend block api (version 8)
Quoted 30 lines · On Wed, 2 Jun 2010 00:05:14 -0700 Arve Hjønnevåg <[email protected]> wrote:
Quoted 29 lines · Neil Brown
Quoted 7 lines · On Tue, 1 Jun 2010 12:50:01 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 6 lines · Neil Brown
I think you have acknowledged that there is a race with suspend - thanks. Next step was "can it be closed".
You seem to suggest that it can, but you describe it as a "work around" rather than a "bug fix"...Quoted 8 lines
Quoted 2 lines
Do you agree that the race is a "bug", and therefore it is appropriate to "fix" it assuming an acceptable fix can be found (which I think it can)?
If we can fix it, yes we definitely should do and not work around it.
Thanks,
tglx
OK.
Here is my suggestion.While I think this patch would actually work, and hope the ugly aspects are reasonably balanced by the simplicity, I present it primarily as a base for improvement.
The important part is to present how drivers and user-space can co-operate to avoid losing wake-events. The details of what happens in the kernel are certainly up for discussion (as is everything else really of course).
Quoted 6 lines
Quoted 4 lines
The user-space suspend daemon avoids losing wake-events by using
fcntl(F_OWNER)to ensure it gets a signal whenever any important wake-event is ready to be read by user-space. This may involve:
- the one daemon processing all wake eventsWake up events are not all processed by one daemon.
Not with your current user-space code, no. Are you saying that you are not open to any significant change in the Android user-space code? That would make the situation a lot harder to resolve.
Quoted 9 lines
Quoted 4 lines
- Both the suspend daemon and the main event handling daemon opening any given device that delivers wake events (this should work with input events ... unless grabbing is needed)
Not all wakeup events are broadcast like input events so they cannot be read by both daemons. Not that this really matters, since reading the event from the suspend daemon does not mean that it has been delivered to and processed by the other daemon.
There would still need to be some sort of communication between the the suspend daemon on any event daemon to ensure that the events had been processed. This could be very light weight interaction. The point though is that with this patch it becomes possible to avoid races. Possible is better than impossible.
Quoted 8 lines
Quoted 3 lines
- The event handling daemon giving the suspend-daemon's pid as
F_OWNER, and using poll/select to get the events itself.I don't like the idea of using signals for this. Without the hack Alan Stern suggested, you will temporarily block suspend if the wakeup event happened before the suspend daemon thread made it to the kernel, but abort suspend if it happened right after.
I'm not sure why that difference matters. But I'm also not sure that it is true.
When any wakeup event happen, a signal will be delivered to the suspend daemon.
This will interrupt a pending suspend request, or a sleep, or whatever else the daemon is doing.
It can then go back to waiting for a good time to suspend, and then try to suspend again.
Quoted 8 lines
Quoted 6 lines
When 'mem' is written to
/sys/power/state,suspend_preparewaits in an interruptible wait until any wake-event that might have been initiated before the suspend was request, has had a chance to be queued for user-space and triggerkill_fasync.And what happens if you are not waiting when this happens?
I'm not sure I understand the question. Could you explain it please?
Either the initial event happens late enough to abort/resume the suspend, or the signal happens early enough to abort the suspend, or alert the daemon not to do a suspend. Either way we don't get stuck in suspend.
Quoted 9 lines
Quoted 3 lines
Currently this wait is a configurable time after the last wake-event was initiated. This is hackish, but simple and probably adequate.
Waiting after a wake event is the same as
suspend_block_timeout. This is useful when passing events through layers of code that does no block suspend, but we should strive to avoid it. Other people had much stronger objections to this, which is why it is not included in the last suspend blocker patchset.
Absolutely agree. The idea of of waiting was just a simple way to present code that actually could work. There are doubtlessly better ways and I assume they have been implemented in the suspend-blocker code.
We just need some way to wait for the suspend-block count to reach zero, with some confidence that this amount of time is limited.
(though to be honest ... the incredible simplicity of waiting a little while is very compelling.... :-))
Quoted 4 lines
It also does not work for drivers that need to block suspend for more than a few seconds. For instance the gpio keypad matrix driver needs to block suspend while keys are pressed so it can scan the keypad.
I cannot imagine why it would take multiple seconds to scan a keypad. Can you explain that?
Do you mean while keys are held pressed? Maybe you don't get a wake-up event on key-release? In that case your user-space daemon could block suspend while there are any pressed keys.... confused.
Thanks for the review,
NeilBrown
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
Re: [PATCH] - race-free suspend. Was: Re: [linux-pm] [PATCH 0/8] Suspend block api (version 8)
In reply to Arve HjønnevågQuoted 30 lines · On Wed, 2 Jun 2010 00:05:14 -0700 Arve Hjønnevåg <[email protected]> wrote:
Quoted 29 lines · Neil Brown
Quoted 7 lines · On Tue, 1 Jun 2010 12:50:01 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 6 lines · Neil Brown
I think you have acknowledged that there is a race with suspend - thanks. Next step was "can it be closed".
You seem to suggest that it can, but you describe it as a "work around" rather than a "bug fix"...Quoted 8 lines
Quoted 2 lines
Do you agree that the race is a "bug", and therefore it is appropriate to "fix" it assuming an acceptable fix can be found (which I think it can)?
If we can fix it, yes we definitely should do and not work around it.
Thanks,
tglx
OK.
Here is my suggestion.While I think this patch would actually work, and hope the ugly aspects are reasonably balanced by the simplicity, I present it primarily as a base for improvement.
The important part is to present how drivers and user-space can co-operate to avoid losing wake-events. The details of what happens in the kernel are certainly up for discussion (as is everything else really of course).
Quoted 6 lines
Quoted 4 lines
The user-space suspend daemon avoids losing wake-events by using
fcntl(F_OWNER)to ensure it gets a signal whenever any important wake-event is ready to be read by user-space. This may involve:
- the one daemon processing all wake eventsWake up events are not all processed by one daemon.
Not with your current user-space code, no. Are you saying that you are not open to any significant change in the Android user-space code? That would make the situation a lot harder to resolve.
Quoted 9 lines
Quoted 4 lines
- Both the suspend daemon and the main event handling daemon opening any given device that delivers wake events (this should work with input events ... unless grabbing is needed)
Not all wakeup events are broadcast like input events so they cannot be read by both daemons. Not that this really matters, since reading the event from the suspend daemon does not mean that it has been delivered to and processed by the other daemon.
There would still need to be some sort of communication between the the suspend daemon on any event daemon to ensure that the events had been processed. This could be very light weight interaction. The point though is that with this patch it becomes possible to avoid races. Possible is better than impossible.
Quoted 8 lines
Quoted 3 lines
- The event handling daemon giving the suspend-daemon's pid as
F_OWNER, and using poll/select to get the events itself.I don't like the idea of using signals for this. Without the hack Alan Stern suggested, you will temporarily block suspend if the wakeup event happened before the suspend daemon thread made it to the kernel, but abort suspend if it happened right after.
I'm not sure why that difference matters. But I'm also not sure that it is true.
When any wakeup event happen, a signal will be delivered to the suspend daemon.
This will interrupt a pending suspend request, or a sleep, or whatever else the daemon is doing.
It can then go back to waiting for a good time to suspend, and then try to suspend again.
Quoted 8 lines
Quoted 6 lines
When 'mem' is written to
/sys/power/state,suspend_preparewaits in an interruptible wait until any wake-event that might have been initiated before the suspend was request, has had a chance to be queued for user-space and triggerkill_fasync.And what happens if you are not waiting when this happens?
I'm not sure I understand the question. Could you explain it please?
Either the initial event happens late enough to abort/resume the suspend, or the signal happens early enough to abort the suspend, or alert the daemon not to do a suspend. Either way we don't get stuck in suspend.
Quoted 9 lines
Quoted 3 lines
Currently this wait is a configurable time after the last wake-event was initiated. This is hackish, but simple and probably adequate.
Waiting after a wake event is the same as
suspend_block_timeout. This is useful when passing events through layers of code that does no block suspend, but we should strive to avoid it. Other people had much stronger objections to this, which is why it is not included in the last suspend blocker patchset.
Absolutely agree. The idea of of waiting was just a simple way to present code that actually could work. There are doubtlessly better ways and I assume they have been implemented in the suspend-blocker code.
We just need some way to wait for the suspend-block count to reach zero, with some confidence that this amount of time is limited.
(though to be honest ... the incredible simplicity of waiting a little while is very compelling.... :-))
Quoted 4 lines
It also does not work for drivers that need to block suspend for more than a few seconds. For instance the gpio keypad matrix driver needs to block suspend while keys are pressed so it can scan the keypad.
I cannot imagine why it would take multiple seconds to scan a keypad. Can you explain that?
Do you mean while keys are held pressed? Maybe you don't get a wake-up event on key-release? In that case your user-space daemon could block suspend while there are any pressed keys.... confused.
Thanks for the review,
NeilBrown
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] - race-free suspend. Was: Re: [PATCH 0/8] Suspend block api (version 8)
Quoted 6 lines · On Wed, 2 Jun 2010 18:06:14 +1000 Neil Brown <[email protected]> wrote:
I cannot imagine why it would take multiple seconds to scan a keypad. Can you explain that?
Do you mean while keys are held pressed? Maybe you don't get a wake-up event on key-release? In that case your user-space daemon could block suspend while there are any pressed keys.... confused.
IIRC, the device sends interrupts only for first key-down and last key-up.
To detect simultaneous key-presses you must actively scan it after the first key-down.
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] - race-free suspend. Was: Re: [linux-pm] [PATCH 0/8] Suspend block api (version 8)
In reply to Neil BrownQuoted 6 lines · On Wed, 2 Jun 2010 18:06:14 +1000 Neil Brown <[email protected]> wrote:
I cannot imagine why it would take multiple seconds to scan a keypad. Can you explain that?
Do you mean while keys are held pressed? Maybe you don't get a wake-up event on key-release? In that case your user-space daemon could block suspend while there are any pressed keys.... confused.
IIRC, the device sends interrupts only for first key-down and last key-up.
To detect simultaneous key-presses you must actively scan it after the first key-down.
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] - race-free suspend. Was: Re: [linux-pm] [PATCH 0/8] Suspend block api (version 8)
Quoted 6 lines · On Wed, 2 Jun 2010 10:50:39 +0200 Florian Mickler <[email protected]> wrote:
Quoted 3 lines · On Wed, 2 Jun 2010 18:06:14 +1000 Neil Brown <[email protected]> wrote:
I cannot imagine why it would take multiple seconds to scan a keypad. Can you explain that?
Quoted 8 lines
Quoted 3 lines
Do you mean while keys are held pressed? Maybe you don't get a wake-up event on key-release? In that case your user-space daemon could block suspend while there are any pressed keys.... confused.
IIRC, the device sends interrupts only for first key-down and last key-up.
To detect simultaneous key-presses you must actively scan it after the first key-down.
That makes sense - thanks.
Presumably the first key-press gets to user-space promptly, so the user-space suspend daemon can be told not to suspend until the last key-up.
Thanks,
NeilBrown
Re: [PATCH] - race-free suspend. Was: Re: [PATCH 0/8] Suspend block api (version 8)
In reply to Florian MicklerQuoted 6 lines · On Wed, 2 Jun 2010 10:50:39 +0200 Florian Mickler <[email protected]> wrote:
Quoted 3 lines · On Wed, 2 Jun 2010 18:06:14 +1000 Neil Brown <[email protected]> wrote:
I cannot imagine why it would take multiple seconds to scan a keypad. Can you explain that?
Quoted 8 lines
Quoted 3 lines
Do you mean while keys are held pressed? Maybe you don't get a wake-up event on key-release? In that case your user-space daemon could block suspend while there are any pressed keys.... confused.
IIRC, the device sends interrupts only for first key-down and last key-up.
To detect simultaneous key-presses you must actively scan it after the first key-down.
That makes sense - thanks.
Presumably the first key-press gets to user-space promptly, so the user-space suspend daemon can be told not to suspend until the last key-up.
Thanks,
NeilBrown