Skip to contentSkip to conversation

PM: Add suspend block api.

PATCH James Kosin 4 participants 9 messages May 7, 2010 – May 24, 2010 6 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 4 lines · Tony Lindgren
Quoted 3 lines · Brian Swetland
Quoted 2 lines · Tony Lindgren
Quoted 1 line · Brian Swetland

On Wed, May 5, 2010 at 2:12 PM, Alan Stern <[email protected]> wrote:

<<-- snip -->>

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

At no point does the user program have to communicate anything to the modem driver, and at no point does it have to do anything out of the ordinary except to enable and disable a suspend blocker.

Exactly -- and you can use the same style of overlapping suspend blockers with other drivers than input, if the input interface is not suitable for the particular interaction.

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Would the suspend blockers still be needed somewhere in the example above?

How often would we retry suspending?

Well based on some timer, the same way the screen blanks? Or five seconds of no audio play? So if the suspend fails, then reset whatever userspace suspend policy timers.

Tony,
Wouldn't this be handled by the idle task, or task manager?

When all tasks are suspended and not doing anything that should be the first clue that a real suspend cycle could be attempted.

James

#7 lore raw
Quoted 24 lines · James Kosin
Quoted 4 lines · Tony Lindgren
Quoted 3 lines · Brian Swetland
Quoted 2 lines · Tony Lindgren
Quoted 1 line · Brian Swetland

On Wed, May 5, 2010 at 2:12 PM, Alan Stern <[email protected]> wrote:

<<-- snip -->>

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

At no point does the user program have to communicate anything to the modem driver, and at no point does it have to do anything out of the ordinary except to enable and disable a suspend blocker.

Exactly -- and you can use the same style of overlapping suspend blockers with other drivers than input, if the input interface is not suitable for the particular interaction.

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

Would the suspend blockers still be needed somewhere in the example above?

How often would we retry suspending?

Well based on some timer, the same way the screen blanks? Or five seconds of no audio play? So if the suspend fails, then reset whatever userspace suspend policy timers.

Quoted 6 lines

Tony,
Wouldn't this be handled by the idle task, or task manager?

When all tasks are suspended and not doing anything that should be the first clue that a real suspend cycle could be attempted.

One if the benefit we get from using suspend is that an unprivileged app that does not have access to suspend blockers cannot prevent suspend. You lose this advantage if you trigger suspend only from the idle task.

Signature · 1 line
Arve Hjønnevåg
#8 lore raw
Quoted 35 lines · Arve Hjønnevåg
Quoted 33 lines · James Kosin
Quoted 8 lines · Tony Lindgren
Quoted 6 lines · Brian Swetland
Quoted 4 lines · Tony Lindgren
Quoted 2 lines · Brian Swetland

On Wed, May 5, 2010 at 2:12 PM, Alan Stern <[email protected]> wrote:

<<-- snip -->>

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

At no point does the user program have to communicate anything to the modem driver, and at no point does it have to do anything out of the ordinary except to enable and disable a suspend blocker.

Exactly -- and you can use the same style of overlapping suspend blockers with other drivers than input, if the input interface is not suitable for the particular interaction.

Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

Would the suspend blockers still be needed somewhere in the example above?

How often would we retry suspending?

Well based on some timer, the same way the screen blanks? Or five seconds of no audio play? So if the suspend fails, then reset whatever userspace suspend policy timers.

Tony,
Wouldn't this be handled by the idle task, or task manager?

Quoted 10 lines
Quoted 4 lines

When all tasks are suspended and not doing anything that should be the first clue that a real suspend cycle could be attempted.

One if the benefit we get from using suspend is that an unprivileged app that does not have access to suspend blockers cannot prevent suspend. You lose this advantage if you trigger suspend only from the idle task.

If the process (privileged or unprivileged) doesn't want to suspend, why not just provide an interface to allow suspend to be turned off at the user level. This could block the suspend cycle in itself, and you shouldn't need fine grained off/on cycles. If an application really needs the system not to suspend then they (the user) should know the consequences and power requirements for such a task.

I didn't say it had to be only from the idle task; but, that is the most logical place. If the other threads are not idle then they really require work and will most likely already have a bock on the suspend anyway.

James

#9 lore raw

2010/5/6 James Kosin <[email protected]>:

Quoted 53 lines · Arve Hjønnevåg
Quoted 35 lines · James Kosin
Quoted 34 lines · Tony Lindgren
Quoted 9 lines · Brian Swetland
Quoted 7 lines · Tony Lindgren
Quoted 5 lines · Brian Swetland
Quoted 3 lines · Alan Stern

<<-- snip -->>

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

At no point does the user program have to communicate anything to the modem driver, and at no point does it have to do anything out of the ordinary except to enable and disable a suspend blocker.

Exactly -- and you can use the same style of overlapping suspend blockers with other drivers than input, if the input interface is not suitable for the particular interaction.

Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

Would the suspend blockers still be needed somewhere in the example above?

How often would we retry suspending?

Well based on some timer, the same way the screen blanks? Or five seconds of no audio play? So if the suspend fails, then reset whatever userspace suspend policy timers.

Tony,
Wouldn't this be handled by the idle task, or task manager?

Quoted 10 lines
Quoted 4 lines

When all tasks are suspended and not doing anything that should be the first clue that a real suspend cycle could be attempted.

One if the benefit we get from using suspend is that an unprivileged app that does not have access to suspend blockers cannot prevent suspend. You lose this advantage if you trigger suspend only from the idle task.

If the process (privileged or unprivileged) doesn't want to suspend, why not just provide an interface to allow suspend to be turned off at the user level.  This could block the suspend cycle in itself, and you shouldn't need fine grained off/on cycles.  If an application really needs the system not to suspend then they (the user) should know the consequences and power requirements for such a task.

Quoted 4 lines

I didn't say it had to be only from the idle task; but, that is the most logical place.  If the other threads are not idle then they really require work and will most likely already have a bock on the suspend anyway.

I think you missed my point. Unprivileged processes should not be allowed to prevent suspend.

Signature · 1 line
Arve Hjønnevåg
#10 lore raw
Quoted 70 lines · Arve Hjønnevåg

2010/5/6 James Kosin <[email protected]>:

Quoted 68 lines · Arve Hjønnevåg
Quoted 53 lines · James Kosin
Quoted 43 lines · Tony Lindgren
Quoted 8 lines · Brian Swetland
Quoted 5 lines · Tony Lindgren
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Brian Swetland
Quoted 5 lines · Alan Stern

<<-- snip -->>

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 10 lines
Quoted 5 lines

At no point does the user program have to communicate anything to the modem driver, and at no point does it have to do anything out of the ordinary except to enable and disable a suspend blocker.

Exactly -- and you can use the same style of overlapping suspend blockers with other drivers than input, if the input interface is not suitable for the particular interaction.

Would the suspend blockers still be needed somewhere in the example above?

Quoted 9 lines
Quoted 3 lines

How often would we retry suspending?

Well based on some timer, the same way the screen blanks? Or five seconds of no audio play? So if the suspend fails, then reset whatever userspace suspend policy timers.

Quoted 8 lines

Tony,
Wouldn't this be handled by the idle task, or task manager?

When all tasks are suspended and not doing anything that should be the first clue that a real suspend cycle could be attempted.

Quoted 7 lines

One if the benefit we get from using suspend is that an unprivileged app that does not have access to suspend blockers cannot prevent suspend. You lose this advantage if you trigger suspend only from the idle task.

If the process (privileged or unprivileged) doesn't want to suspend, why not just provide an interface to allow suspend to be turned off at the user level. This could block the suspend cycle in itself, and you shouldn't need fine grained off/on cycles. If an application really needs the system not to suspend then they (the user) should know the consequences and power requirements for such a task.

Quoted 9 lines
Quoted 5 lines

I didn't say it had to be only from the idle task; but, that is the most logical place. If the other threads are not idle then they really require work and will most likely already have a bock on the suspend anyway.

I think you missed my point. Unprivileged processes should not be allowed to prevent suspend.

Ah, you want a way for the system to suspend (and enforce the suspend) when only unprivileged processes are the only thing running....

That would mean a lot of work defining the unprivileged (or privileged) processes, and properly suspending (or enforcing) when needed. Yuck. Sorry I commented then, this is really getting deep into what I love to do at work.

#11 lore raw
Quoted 6 lines · James Kosin
Quoted 5 lines · Arve Hjønnevåg
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

One if the benefit we get from using suspend is that an unprivileged app that does not have access to suspend blockers cannot prevent suspend. You lose this advantage if you trigger suspend only from the idle task.

This assumes that you're using cached values for echo mem > /sys/power/state and the system keeps on running.

IMHO if you want to keep the system running, then you should just use cpuidle and implement good idle modes.

Then when someting in the userspace knows you've been idle long enough, you can suspend.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

If the process (privileged or unprivileged) doesn't want to suspend, why not just provide an interface to allow suspend to be turned off at the user level. This could block the suspend cycle in itself, and you shouldn't need fine grained off/on cycles. If an application really needs the system not to suspend then they (the user) should know the consequences and power requirements for such a task.

Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

I didn't say it had to be only from the idle task; but, that is the most logical place. If the other threads are not idle then they really require work and will most likely already have a bock on the suspend anyway.

I think you missed my point. Unprivileged processes should not be allowed to prevent suspend.

You could just freeze the GUI process based on some policy if you worry about misbehaving timers in various apps. This way the cpuidle modes will allow you to run some userspace policy daemon. And then that can suspend if needed based on how it's configured.

Quoted 7 lines

Ah, you want a way for the system to suspend (and enforce the suspend) when only unprivileged processes are the only thing running....

That would mean a lot of work defining the unprivileged (or privileged) processes, and properly suspending (or enforcing) when needed. Yuck. Sorry I commented then, this is really getting deep into what I love to do at work.

Hmm, yeah sounds a bit messy.

Tony

#12 lore raw
In reply to Arve Hjønnevåg
Quoted 14 lines
Quoted 14 lines
Quoted 7 lines

One if the benefit we get from using suspend is that an unprivileged app that does not have access to suspend blockers cannot prevent suspend. You lose this advantage if you trigger suspend only from the idle task.

If the process (privileged or unprivileged) doesn't want to suspend, why not just provide an interface to allow suspend to be turned off at the user level.  This could block the suspend cycle in itself, and you shouldn't need fine grained off/on cycles.  If an application really needs the system not to suspend then they (the user) should know the consequences and power requirements for such a task.

Quoted 7 lines
Quoted 4 lines

I didn't say it had to be only from the idle task; but, that is the most logical place.  If the other threads are not idle then they really require work and will most likely already have a bock on the suspend anyway.

I think you missed my point. Unprivileged processes should not be allowed to prevent suspend.

Currently, unpriviledged processes are allowed to eat power, for example while(1). We should keep that behaviour at least by default.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#13 lore raw
In reply to Arve Hjønnevåg

Hi!

Quoted 20 lines
Quoted 20 lines
Quoted 13 lines
Quoted 7 lines

Tony,
Wouldn't this be handled by the idle task, or task manager?

When all tasks are suspended and not doing anything that should be the first clue that a real suspend cycle could be attempted.

One if the benefit we get from using suspend is that an unprivileged app that does not have access to suspend blockers cannot prevent suspend. You lose this advantage if you trigger suspend only from the idle task.

If the process (privileged or unprivileged) doesn't want to suspend, why not just provide an interface to allow suspend to be turned off at the user level.  This could block the suspend cycle in itself, and you shouldn't need fine grained off/on cycles.  If an application really needs the system not to suspend then they (the user) should know the consequences and power requirements for such a task.

Quoted 6 lines
Quoted 3 lines

I didn't say it had to be only from the idle task; but, that is the most logical place.  If the other threads are not idle then they really require work and will most likely already have a bock on the suspend anyway.

I think you missed my point. Unprivileged processes should not be allowed to prevent suspend.

Currently, we do not suspend automatically, and not suspending when *anything* is running is clearly backwards compatible....

If suspend is disallowed, application doing while(1); will consume
more power than the one doing sleep(1) so.... I'm not sure how much sense such "security policy" makes.

Anyway, for android use case, maybe you could have something like ksuspendd, and adjust its priority? That way, you could have tasks below the priority of ksuspendd, and those would not block suspend.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#14 lore raw
In reply to James Kosin
Quoted 19 lines · James Kosin
Quoted 4 lines · Tony Lindgren
Quoted 3 lines · Brian Swetland
Quoted 2 lines · Tony Lindgren
Quoted 1 line · Brian Swetland

On Wed, May 5, 2010 at 2:12 PM, Alan Stern <[email protected]> wrote:

<<-- snip -->>

Quoted 13 lines
Quoted 12 lines
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines

At no point does the user program have to communicate anything to the modem driver, and at no point does it have to do anything out of the ordinary except to enable and disable a suspend blocker.

Exactly -- and you can use the same style of overlapping suspend blockers with other drivers than input, if the input interface is not suitable for the particular interaction.

Would the suspend blockers still be needed somewhere in the example above?

How often would we retry suspending?

Quoted 7 lines
Quoted 4 lines

Well based on some timer, the same way the screen blanks? Or five seconds of no audio play? So if the suspend fails, then reset whatever userspace suspend policy timers.

Tony,
Wouldn't this be handled by the idle task, or task manager?

My thinking is that suspend should be only triggered from the userspace based on a device specic policy. Suspend breaks standard Linux behaviour as all the timers will stop running.

You can already implement suspend-like idle states for various processors that are controlled by cpuidle.

In those cases the device hits suspend or off modes in the kernel idle loop. In this case the system keeps running waking every few seconds or so when idle, and the timers behave the normal way.

Of course there can be tens or even few hundred millisecond wake-up latencies in the case of hitting off and restoring the kernel during idle, so interrupt response time in those cases is longer.

Quoted 2 lines

When all tasks are suspended and not doing anything that should be the first clue that a real suspend cycle could be attempted.

Yeah, but I don't think there's a generic way of figuring out when it's OK to suspend. It depends on the device. It can also depend on how the user wants to configure things.

Regards,

Tony