Skip to contentSkip to conversation

Automatic suspend

RFD Rafael J. Wysocki 21 participants 379 messages Feb 15, 2009 – Mar 5, 2009 Page 2 of 2

lore
Share & tools
lore
#239 lore raw
In reply to Arve Hjønnevåg

Hi!

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

If you ignore wakelocks with timeouts, the current wakelock interface can be implemented with a global atomic_t to prevent suspend, and a per wakelock atomic_t to prevent a single client from changing the global reference count by more than one.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

There are a couple of reasons that I have not done this. It removes the ability to easily inspect the system when it is not suspending.

Care to elaborate?

If you have a single atomic_t and it is not 0, you do not know who incremented it.

Which is okay for already debugged system. For debugging, yes some support can be nice.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#240 lore raw
Quoted 10 lines · Pavel Machek

Hi!

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

If you ignore wakelocks with timeouts, the current wakelock interface can be implemented with a global atomic_t to prevent suspend, and a per wakelock atomic_t to prevent a single client from changing the global reference count by more than one.

There are a couple of reasons that I have not done this. It removes the ability to easily inspect the system when it is not suspending.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Care to elaborate?

If you have a single atomic_t and it is not 0, you do not know who incremented it.

Which is okay for already debugged system. For debugging, yes some support can be nice.

Yes, but installing an app can turn your debugged system into an undebugged system. I think is fine to have a kernel option to disable all debugging support, I just don't think it is the top priority. I have two options for making the no-stats no-timeout configuration faster. Option one, always use a reference count, and implement the other configurations on top of this. This makes the shipping configuration slower. Option two, use a completely separate implementation when stats or timeouts are enabled. This makes the fast version virtually untested. Neither of these are very appealing at the moment.

Signature · 1 line
Arve Hjønnevåg
#241 lore raw
In reply to Pavel Machek
Quoted 10 lines · Pavel Machek

Hi!

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

If you ignore wakelocks with timeouts, the current wakelock interface can be implemented with a global atomic_t to prevent suspend, and a per wakelock atomic_t to prevent a single client from changing the global reference count by more than one.

There are a couple of reasons that I have not done this. It removes the ability to easily inspect the system when it is not suspending.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Care to elaborate?

If you have a single atomic_t and it is not 0, you do not know who incremented it.

Which is okay for already debugged system. For debugging, yes some support can be nice.

Yes, but installing an app can turn your debugged system into an undebugged system. I think is fine to have a kernel option to disable all debugging support, I just don't think it is the top priority. I have two options for making the no-stats no-timeout configuration faster. Option one, always use a reference count, and implement the other configurations on top of this. This makes the shipping configuration slower. Option two, use a completely separate implementation when stats or timeouts are enabled. This makes the fast version virtually untested. Neither of these are very appealing at the moment.

Signature · 1 line
Arve Hjønnevåg
#242 lore raw
In reply to Arve Hjønnevåg

Hi!

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

If you ignore wakelocks with timeouts, the current wakelock interface can be implemented with a global atomic_t to prevent suspend, and a per wakelock atomic_t to prevent a single client from changing the global reference count by more than one.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

There are a couple of reasons that I have not done this. It removes the ability to easily inspect the system when it is not suspending.

Care to elaborate?

If you have a single atomic_t and it is not 0, you do not know who incremented it.

Which is okay for already debugged system. For debugging, yes some support can be nice.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#243 lore raw
In reply to Rafael J. Wysocki

Am Freitag 20 Februar 2009 16:56:59 schrieb Rafael J. Wysocki:

Quoted 4 lines

OK, so what about the following approach:

* Keep the decision making logic (power manager etc.) in user space.
Reasons: - It may be arbitrarily complicated

Therefore something functionally equivalent to wakelocks is needed.

Quoted 2 lines

- It may include such things as s2ram quirks or hal quirks needed for
some graphics adapters

If you can't do that I'd say the situation is hopeless. You need full support for all devices including graphics cards.

Quoted 2 lines

* Have a per-process (per-task or per-thread group, but the former would be easier IMO) "I_do_not_want_automatic_suspend_to_occur" flag.

I think you got the default logic inverted.

Quoted 10 lines

* Add a new callback, say ->acknowledge(), to the set of each driver's PM operations, that will be called to check if the driver has anything
against automatic suspend (true - suspend can happen right now, false - suspend can't happen).

* Introduce /sys/power/sleep that will work like /sys/power/state, but:
- First, it will call ->acknowledge() for each driver (via bus types) to check if any of them wants to postpone the suspend (this will prevent
tasks from being frozen unnecessarily if it is known in advance that the suspend should not happen at the moment).

Ideally most devices should be already suspended, so I am not sure a new callback is really needed. In any cases it is an optimization only.

Quoted 6 lines

- Next, it will check the "I_do_not_want_automatic_suspend_to_occur" flag of each process and the suspend will be aborted if it is true for any
of them (quite frankly, I think that should be integrated with the freezer, in particular the tasks that have TIF_FREEZE set shouldn't be able to set this flag and it should be checked in the freezer loop for every task with TIF_FREEZE unset).

Why in this order?

Quoted 8 lines

- Next, it will proceed with suspending just like /sys/power/state does
(the drivers that missed the opportunity to abort the suspend by returning 'false' from ->acknowledge() can still abort the suspend by failing their ->suspend() routines).

Then, the decision making logic will be able to use /sys/power/sleep whenever it wishes to and the kernel will be able to refuse to suspend if it's not desirable at the moment.

I think everything that uses a "trigger" logic from user space is not a good idea. This will necessary introduce a race between the decision and the execution during which circumstances can change.

So it seems to me that an allow/disallow system from user space would be better.

Regards
Oliver

#244 lore raw
Quoted 10 lines · Oliver Neukum

Am Freitag 20 Februar 2009 16:56:59 schrieb Rafael J. Wysocki:

Quoted 4 lines

OK, so what about the following approach:

* Keep the decision making logic (power manager etc.) in user space.
Reasons: - It may be arbitrarily complicated

Therefore something functionally equivalent to wakelocks is needed.

Quoted 6 lines
Quoted 2 lines

- It may include such things as s2ram quirks or hal quirks needed for
some graphics adapters

If you can't do that I'd say the situation is hopeless. You need full support for all devices including graphics cards.

We can't do the quirks from the kernel and that's one of the reasons why I think user space should start automatic suspend (it can do the quirks if necessary).

Quoted 4 lines
Quoted 2 lines

* Have a per-process (per-task or per-thread group, but the former would be easier IMO) "I_do_not_want_automatic_suspend_to_occur" flag.

I think you got the default logic inverted.

Well, it may be "suspend_possible_right_now" just as well. :-)

Quoted 11 lines
Quoted 10 lines

* Add a new callback, say ->acknowledge(), to the set of each driver's PM operations, that will be called to check if the driver has anything
against automatic suspend (true - suspend can happen right now, false - suspend can't happen).

* Introduce /sys/power/sleep that will work like /sys/power/state, but:
- First, it will call ->acknowledge() for each driver (via bus types) to check if any of them wants to postpone the suspend (this will prevent
tasks from being frozen unnecessarily if it is known in advance that the suspend should not happen at the moment).

Quoted 3 lines

Ideally most devices should be already suspended, so I am not sure a new callback is really needed. In any cases it is an optimization only.

Yes, it is, but an important one (the total time of freezing and thawing tasks can be substantial).

Quoted 8 lines
Quoted 6 lines

- Next, it will check the "I_do_not_want_automatic_suspend_to_occur" flag of each process and the suspend will be aborted if it is true for any
of them (quite frankly, I think that should be integrated with the freezer, in particular the tasks that have TIF_FREEZE set shouldn't be able to set this flag and it should be checked in the freezer loop for every task with TIF_FREEZE unset).

Why in this order?

Because the freezing of tasks takes time and it would be a bad idea to do it unnecessarily.

Quoted 5 lines
Quoted 5 lines

- Next, it will proceed with suspending just like /sys/power/state does
(the drivers that missed the opportunity to abort the suspend by returning 'false' from ->acknowledge() can still abort the suspend by failing their ->suspend() routines).

Quoted 7 lines
Quoted 3 lines

Then, the decision making logic will be able to use /sys/power/sleep whenever it wishes to and the kernel will be able to refuse to suspend if it's not desirable at the moment.

I think everything that uses a "trigger" logic from user space is not a good idea. This will necessary introduce a race between the decision and the execution during which circumstances can change.

Well, in this particulare case if the circumstances change in the meantime, the kernel will just refuse to suspend. Also, even if the kernel starts automatic suspend, it _still_ is possible that the conditions change in the meantime (for example, one of the tasks may enter a state in which it wouldn't like to the suspend to happen just after the operation is started and before it's frozen).

Quoted 2 lines

So it seems to me that an allow/disallow system from user space would be better.

I don't really see the benefit, but I can easily see drawbacks (the handling of graphics that requires user space quirks, for instance).

Thanks,
Rafael

#245 lore raw
In reply to Oliver Neukum
Quoted 10 lines · Oliver Neukum

Am Freitag 20 Februar 2009 16:56:59 schrieb Rafael J. Wysocki:

Quoted 4 lines

OK, so what about the following approach:

* Keep the decision making logic (power manager etc.) in user space.
Reasons: - It may be arbitrarily complicated

Therefore something functionally equivalent to wakelocks is needed.

Quoted 6 lines
Quoted 2 lines

- It may include such things as s2ram quirks or hal quirks needed for
some graphics adapters

If you can't do that I'd say the situation is hopeless. You need full support for all devices including graphics cards.

We can't do the quirks from the kernel and that's one of the reasons why I think user space should start automatic suspend (it can do the quirks if necessary).

Quoted 4 lines
Quoted 2 lines

* Have a per-process (per-task or per-thread group, but the former would be easier IMO) "I_do_not_want_automatic_suspend_to_occur" flag.

I think you got the default logic inverted.

Well, it may be "suspend_possible_right_now" just as well. :-)

Quoted 11 lines
Quoted 10 lines

* Add a new callback, say ->acknowledge(), to the set of each driver's PM operations, that will be called to check if the driver has anything
against automatic suspend (true - suspend can happen right now, false - suspend can't happen).

* Introduce /sys/power/sleep that will work like /sys/power/state, but:
- First, it will call ->acknowledge() for each driver (via bus types) to check if any of them wants to postpone the suspend (this will prevent
tasks from being frozen unnecessarily if it is known in advance that the suspend should not happen at the moment).

Quoted 3 lines

Ideally most devices should be already suspended, so I am not sure a new callback is really needed. In any cases it is an optimization only.

Yes, it is, but an important one (the total time of freezing and thawing tasks can be substantial).

Quoted 8 lines
Quoted 6 lines

- Next, it will check the "I_do_not_want_automatic_suspend_to_occur" flag of each process and the suspend will be aborted if it is true for any
of them (quite frankly, I think that should be integrated with the freezer, in particular the tasks that have TIF_FREEZE set shouldn't be able to set this flag and it should be checked in the freezer loop for every task with TIF_FREEZE unset).

Why in this order?

Because the freezing of tasks takes time and it would be a bad idea to do it unnecessarily.

Quoted 5 lines
Quoted 5 lines

- Next, it will proceed with suspending just like /sys/power/state does
(the drivers that missed the opportunity to abort the suspend by returning 'false' from ->acknowledge() can still abort the suspend by failing their ->suspend() routines).

Quoted 7 lines
Quoted 3 lines

Then, the decision making logic will be able to use /sys/power/sleep whenever it wishes to and the kernel will be able to refuse to suspend if it's not desirable at the moment.

I think everything that uses a "trigger" logic from user space is not a good idea. This will necessary introduce a race between the decision and the execution during which circumstances can change.

Well, in this particulare case if the circumstances change in the meantime, the kernel will just refuse to suspend. Also, even if the kernel starts automatic suspend, it _still_ is possible that the conditions change in the meantime (for example, one of the tasks may enter a state in which it wouldn't like to the suspend to happen just after the operation is started and before it's frozen).

Quoted 2 lines

So it seems to me that an allow/disallow system from user space would be better.

I don't really see the benefit, but I can easily see drawbacks (the handling of graphics that requires user space quirks, for instance).

Thanks,
Rafael

#246 lore raw
Quoted 3 lines · Rafael J. Wysocki

We can't do the quirks from the kernel and that's one of the reasons why I think user space should start automatic suspend (it can do the quirks if necessary).

Any sort of automatic suspend is simply impossible in a world where your drivers don't work properly. There's code for making intel and radeon handle suspend/resume themselves now, and nvidia before g80 should also be easy. More recent nvidia is going to be some work.

But yeah. Let's not have "Work around broken drivers" as a design goal. The argument against timeouts in wakelocks works just as well here.

Signature · 1 line
Matthew Garrett | [email protected]
#247 lore raw
In reply to Rafael J. Wysocki
Quoted 3 lines · Rafael J. Wysocki

We can't do the quirks from the kernel and that's one of the reasons why I think user space should start automatic suspend (it can do the quirks if necessary).

Any sort of automatic suspend is simply impossible in a world where your drivers don't work properly. There's code for making intel and radeon handle suspend/resume themselves now, and nvidia before g80 should also be easy. More recent nvidia is going to be some work.

But yeah. Let's not have "Work around broken drivers" as a design goal. The argument against timeouts in wakelocks works just as well here.

Signature · 1 line
Matthew Garrett | [email protected]
#248 lore raw
Quoted 6 lines · Matthew Garrett
Quoted 3 lines · Rafael J. Wysocki

We can't do the quirks from the kernel and that's one of the reasons why I think user space should start automatic suspend (it can do the quirks if necessary).

Quoted 6 lines

Any sort of automatic suspend is simply impossible in a world where your drivers don't work properly. There's code for making intel and radeon handle suspend/resume themselves now, and nvidia before g80 should also be easy. More recent nvidia is going to be some work.

But yeah. Let's not have "Work around broken drivers" as a design goal.

OK, I'm withdrawing it, then. :-)

Quoted 1 line

The argument against timeouts in wakelocks works just as well here.

So, what do you thing about the approach desribed earlier in this thread
(http://lkml.org/lkml/2009/2/20/182)?

Rafael

#249 lore raw
In reply to Matthew Garrett
Quoted 6 lines · Matthew Garrett
Quoted 3 lines · Rafael J. Wysocki

We can't do the quirks from the kernel and that's one of the reasons why I think user space should start automatic suspend (it can do the quirks if necessary).

Quoted 6 lines

Any sort of automatic suspend is simply impossible in a world where your drivers don't work properly. There's code for making intel and radeon handle suspend/resume themselves now, and nvidia before g80 should also be easy. More recent nvidia is going to be some work.

But yeah. Let's not have "Work around broken drivers" as a design goal.

OK, I'm withdrawing it, then. :-)

Quoted 1 line

The argument against timeouts in wakelocks works just as well here.

So, what do you thing about the approach desribed earlier in this thread
(http://lkml.org/lkml/2009/2/20/182)?

Rafael

#250 lore raw
In reply to Rafael J. Wysocki
Quoted 11 lines · Rafael J. Wysocki
Quoted 3 lines

I think everything that uses a "trigger" logic from user space is not a good idea. This will necessary introduce a race between the decision and the execution during which circumstances can change.

Well, in this particulare case if the circumstances change in the meantime, the kernel will just refuse to suspend. Also, even if the kernel starts automatic suspend, it _still_ is possible that the conditions change in the meantime (for example, one of the tasks may enter a state in which it wouldn't like to the suspend to happen just after the operation is started and before it's frozen).

Quoted 5 lines
Quoted 2 lines

So it seems to me that an allow/disallow system from user space would be better.

I don't really see the benefit, but I can easily see drawbacks (the handling of graphics that requires user space quirks, for instance).

This discussion is circling around an important point: How should auto-sleep be initiated?

If userspace holds any wakelocks then the system mustn't auto-sleep. So auto-sleep can be initiated when the last userspace wakelock is released. That requires calling into the kernel anyway, so it isn't a problem.

But what about kernel wakelocks? Again, the simplest approach is to initiate an auto-sleep when the last one is released. But now this depends on how the implementation works.

In Rafael's scheme there isn't really such a thing as a kernel wakelock. Instead there are driver methods, so the only way to find out whether auto-sleep is allowed is to poll every driver. This is not good for systems that want to auto-sleep as soon as possible.

A variant on the scheme would use a new field in the dev_pm_info structure. I don't know if this is better or worse the a new method; it seems likely that the new method would have to work by checking the value of some field anyway. In any case, it shares the drawback that polling is required.

If kernel wakelocks were implemented more like refcounts, then releasing the last one could immediately initiate an auto-sleep. The problem with refcounts is that you can't tell (for accounting or debugging purposes) who owns the outstanding references. However we ought to be able to come up with something intermediate between a full-blown wakelock and a simple refcount that would satisfy everybody.

For example, we could use _both_ a new field in dev_pm_info and a refcount. Or even a per-cpu refcount, to avoid cache-line contention since drivers are likely to acquire and release these things quite often.

What about the overhead of having a permanent kernel thread that does nothing but handle auto-sleeps? This might well be an acceptable tradeoff for many people. Besides, you need something like it if a driver wants to release the last wakelock while in interrupt context. Unless you fall back on polling -- and then you need a thread to do the polling.

Alan Stern

#251 lore raw
In reply to Rafael J. Wysocki
Quoted 11 lines · Rafael J. Wysocki
Quoted 3 lines

I think everything that uses a "trigger" logic from user space is not a good idea. This will necessary introduce a race between the decision and the execution during which circumstances can change.

Well, in this particulare case if the circumstances change in the meantime, the kernel will just refuse to suspend. Also, even if the kernel starts automatic suspend, it _still_ is possible that the conditions change in the meantime (for example, one of the tasks may enter a state in which it wouldn't like to the suspend to happen just after the operation is started and before it's frozen).

Quoted 5 lines
Quoted 2 lines

So it seems to me that an allow/disallow system from user space would be better.

I don't really see the benefit, but I can easily see drawbacks (the handling of graphics that requires user space quirks, for instance).

This discussion is circling around an important point: How should auto-sleep be initiated?

If userspace holds any wakelocks then the system mustn't auto-sleep. So auto-sleep can be initiated when the last userspace wakelock is released. That requires calling into the kernel anyway, so it isn't a problem.

But what about kernel wakelocks? Again, the simplest approach is to initiate an auto-sleep when the last one is released. But now this depends on how the implementation works.

In Rafael's scheme there isn't really such a thing as a kernel wakelock. Instead there are driver methods, so the only way to find out whether auto-sleep is allowed is to poll every driver. This is not good for systems that want to auto-sleep as soon as possible.

A variant on the scheme would use a new field in the dev_pm_info structure. I don't know if this is better or worse the a new method; it seems likely that the new method would have to work by checking the value of some field anyway. In any case, it shares the drawback that polling is required.

If kernel wakelocks were implemented more like refcounts, then releasing the last one could immediately initiate an auto-sleep. The problem with refcounts is that you can't tell (for accounting or debugging purposes) who owns the outstanding references. However we ought to be able to come up with something intermediate between a full-blown wakelock and a simple refcount that would satisfy everybody.

For example, we could use _both_ a new field in dev_pm_info and a refcount. Or even a per-cpu refcount, to avoid cache-line contention since drivers are likely to acquire and release these things quite often.

What about the overhead of having a permanent kernel thread that does nothing but handle auto-sleeps? This might well be an acceptable tradeoff for many people. Besides, you need something like it if a driver wants to release the last wakelock while in interrupt context. Unless you fall back on polling -- and then you need a thread to do the polling.

Alan Stern

#252 lore raw
Quoted 27 lines · Alan Stern
Quoted 11 lines · Rafael J. Wysocki
Quoted 3 lines

I think everything that uses a "trigger" logic from user space is not a good idea. This will necessary introduce a race between the decision and the execution during which circumstances can change.

Well, in this particulare case if the circumstances change in the meantime, the kernel will just refuse to suspend. Also, even if the kernel starts automatic suspend, it _still_ is possible that the conditions change in the meantime (for example, one of the tasks may enter a state in which it wouldn't like to the suspend to happen just after the operation is started and before it's frozen).

Quoted 5 lines
Quoted 2 lines

So it seems to me that an allow/disallow system from user space would be better.

I don't really see the benefit, but I can easily see drawbacks (the handling of graphics that requires user space quirks, for instance).

This discussion is circling around an important point: How should auto-sleep be initiated?

If userspace holds any wakelocks then the system mustn't auto-sleep. So auto-sleep can be initiated when the last userspace wakelock is released. That requires calling into the kernel anyway, so it isn't a problem.

Quoted 8 lines

But what about kernel wakelocks? Again, the simplest approach is to initiate an auto-sleep when the last one is released. But now this depends on how the implementation works.

In Rafael's scheme there isn't really such a thing as a kernel wakelock. Instead there are driver methods, so the only way to find out whether auto-sleep is allowed is to poll every driver. This is not good for systems that want to auto-sleep as soon as possible.

You have a valid point here, although I don't think it would be a problem in practice (I don't expect the systems using automatic suspend to have that many drivers).

Quoted 13 lines

A variant on the scheme would use a new field in the dev_pm_info structure. I don't know if this is better or worse the a new method; it seems likely that the new method would have to work by checking the value of some field anyway. In any case, it shares the drawback that polling is required.

If kernel wakelocks were implemented more like refcounts, then releasing the last one could immediately initiate an auto-sleep. The problem with refcounts is that you can't tell (for accounting or debugging purposes) who owns the outstanding references. However we ought to be able to come up with something intermediate between a full-blown wakelock and a simple refcount that would satisfy everybody.

Quoted 4 lines

For example, we could use _both_ a new field in dev_pm_info and a refcount. Or even a per-cpu refcount, to avoid cache-line contention since drivers are likely to acquire and release these things quite often.

Yes, I like this idea.

Automatic suspend will not occur if the refcount is greater than zero and then the debug/stats code can use the field in dev_pm_info to report who had increased it.

Quoted 6 lines

What about the overhead of having a permanent kernel thread that does nothing but handle auto-sleeps? This might well be an acceptable tradeoff for many people. Besides, you need something like it if a driver wants to release the last wakelock while in interrupt context. Unless you fall back on polling -- and then you need a thread to do the polling.

But that may be a user space process.

I generally think that deciding whether to start automatic suspend should belong to the user space, because it may involve some policies and user preferences etc.

If you agree with that, there are two possible approaches. First, there may be a kernel thread checking periodically if automatic suspend is possible and initiating it if that's the case. For this purpose, the user space has to be able to tell the kernel thread whether it wants automatic suspend to happen (this is where user space wakelocks are handy). Second, there may be a user space process calling the kernel whenever it finds that automatic suspend is desirable. I personally prefer the latter, since the user space process can listen to some events and react to them as soon as they occur (also, it adheres to the rule of thumb that if something can be implemented in user space, it better should be left in there ;-)).

In both cases we need to be able to abort an already started automatic suspend if the conditions change after the decision has been made and I think that using a per-process flag for that would be efficient, since we have to freeze the user space anyway, so we need to check some per-task flags for each task. Still, it may be optimized a bit by using a refcount (that may be the same refcount as for drivers IMO) that will be increased every time a process sets its "automatic_suspend_undesirable" flag. Then, we may export the refcount via sysfs so that the user space power manager can monitor it and take its value into account when deciding whether to start automatic suspend.

To summarize, we can:
* Use a refcount such that automatic suspend will only be possible if it's equal to zero (but that need not be the only criterion).
* Use a per-device flag in dev_pm_info that will be set whenever the device driver increases the refcount and unset whenever the driver decreases the refcount.
* Use a per-process flag that will be set whenever the process increases the refcount and unset whenever the process decreases the refcount.

Thanks,
Rafael

#253 lore raw
In reply to Alan Stern
Quoted 27 lines · Alan Stern
Quoted 11 lines · Rafael J. Wysocki
Quoted 3 lines

I think everything that uses a "trigger" logic from user space is not a good idea. This will necessary introduce a race between the decision and the execution during which circumstances can change.

Well, in this particulare case if the circumstances change in the meantime, the kernel will just refuse to suspend. Also, even if the kernel starts automatic suspend, it _still_ is possible that the conditions change in the meantime (for example, one of the tasks may enter a state in which it wouldn't like to the suspend to happen just after the operation is started and before it's frozen).

Quoted 5 lines
Quoted 2 lines

So it seems to me that an allow/disallow system from user space would be better.

I don't really see the benefit, but I can easily see drawbacks (the handling of graphics that requires user space quirks, for instance).

This discussion is circling around an important point: How should auto-sleep be initiated?

If userspace holds any wakelocks then the system mustn't auto-sleep. So auto-sleep can be initiated when the last userspace wakelock is released. That requires calling into the kernel anyway, so it isn't a problem.

Quoted 8 lines

But what about kernel wakelocks? Again, the simplest approach is to initiate an auto-sleep when the last one is released. But now this depends on how the implementation works.

In Rafael's scheme there isn't really such a thing as a kernel wakelock. Instead there are driver methods, so the only way to find out whether auto-sleep is allowed is to poll every driver. This is not good for systems that want to auto-sleep as soon as possible.

You have a valid point here, although I don't think it would be a problem in practice (I don't expect the systems using automatic suspend to have that many drivers).

Quoted 13 lines

A variant on the scheme would use a new field in the dev_pm_info structure. I don't know if this is better or worse the a new method; it seems likely that the new method would have to work by checking the value of some field anyway. In any case, it shares the drawback that polling is required.

If kernel wakelocks were implemented more like refcounts, then releasing the last one could immediately initiate an auto-sleep. The problem with refcounts is that you can't tell (for accounting or debugging purposes) who owns the outstanding references. However we ought to be able to come up with something intermediate between a full-blown wakelock and a simple refcount that would satisfy everybody.

Quoted 4 lines

For example, we could use _both_ a new field in dev_pm_info and a refcount. Or even a per-cpu refcount, to avoid cache-line contention since drivers are likely to acquire and release these things quite often.

Yes, I like this idea.

Automatic suspend will not occur if the refcount is greater than zero and then the debug/stats code can use the field in dev_pm_info to report who had increased it.

Quoted 6 lines

What about the overhead of having a permanent kernel thread that does nothing but handle auto-sleeps? This might well be an acceptable tradeoff for many people. Besides, you need something like it if a driver wants to release the last wakelock while in interrupt context. Unless you fall back on polling -- and then you need a thread to do the polling.

But that may be a user space process.

I generally think that deciding whether to start automatic suspend should belong to the user space, because it may involve some policies and user preferences etc.

If you agree with that, there are two possible approaches. First, there may be a kernel thread checking periodically if automatic suspend is possible and initiating it if that's the case. For this purpose, the user space has to be able to tell the kernel thread whether it wants automatic suspend to happen (this is where user space wakelocks are handy). Second, there may be a user space process calling the kernel whenever it finds that automatic suspend is desirable. I personally prefer the latter, since the user space process can listen to some events and react to them as soon as they occur (also, it adheres to the rule of thumb that if something can be implemented in user space, it better should be left in there ;-)).

In both cases we need to be able to abort an already started automatic suspend if the conditions change after the decision has been made and I think that using a per-process flag for that would be efficient, since we have to freeze the user space anyway, so we need to check some per-task flags for each task. Still, it may be optimized a bit by using a refcount (that may be the same refcount as for drivers IMO) that will be increased every time a process sets its "automatic_suspend_undesirable" flag. Then, we may export the refcount via sysfs so that the user space power manager can monitor it and take its value into account when deciding whether to start automatic suspend.

To summarize, we can:
* Use a refcount such that automatic suspend will only be possible if it's equal to zero (but that need not be the only criterion).
* Use a per-device flag in dev_pm_info that will be set whenever the device driver increases the refcount and unset whenever the driver decreases the refcount.
* Use a per-process flag that will be set whenever the process increases the refcount and unset whenever the process decreases the refcount.

Thanks,
Rafael

#254 lore raw
Quoted 9 lines

To summarize, we can:
* Use a refcount such that automatic suspend will only be possible if it's equal to zero (but that need not be the only criterion).
* Use a per-device flag in dev_pm_info that will be set whenever the device driver increases the refcount and unset whenever the driver decreases the refcount.
* Use a per-process flag that will be set whenever the process increases the refcount and unset whenever the process decreases the refcount.

Yes, that sounds sane, and that's how reasonable wakelock implementation should look like.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#255 lore raw
Quoted 10 lines · Pavel Machek
Quoted 9 lines

To summarize, we can:
* Use a refcount such that automatic suspend will only be possible if it's equal to zero (but that need not be the only criterion).
* Use a per-device flag in dev_pm_info that will be set whenever the device driver increases the refcount and unset whenever the driver decreases the refcount.
* Use a per-process flag that will be set whenever the process increases the refcount and unset whenever the process decreases the refcount.

Quoted 2 lines

Yes, that sounds sane, and that's how reasonable wakelock implementation should look like.

One small point: If you add a per-device flag and a per-process flag as described above, then drivers and processes must not acquire nested references.

Obviously this is fixable, but it's worth mentioning...

Alan Stern

#256 lore raw
In reply to Pavel Machek
Quoted 10 lines · Pavel Machek
Quoted 9 lines

To summarize, we can:
* Use a refcount such that automatic suspend will only be possible if it's equal to zero (but that need not be the only criterion).
* Use a per-device flag in dev_pm_info that will be set whenever the device driver increases the refcount and unset whenever the driver decreases the refcount.
* Use a per-process flag that will be set whenever the process increases the refcount and unset whenever the process decreases the refcount.

Quoted 2 lines

Yes, that sounds sane, and that's how reasonable wakelock implementation should look like.

One small point: If you add a per-device flag and a per-process flag as described above, then drivers and processes must not acquire nested references.

Obviously this is fixable, but it's worth mentioning...

Alan Stern

#257 lore raw
Quoted 12 lines · Alan Stern
Quoted 10 lines · Pavel Machek
Quoted 9 lines

To summarize, we can:
* Use a refcount such that automatic suspend will only be possible if it's equal to zero (but that need not be the only criterion).
* Use a per-device flag in dev_pm_info that will be set whenever the device driver increases the refcount and unset whenever the driver decreases the refcount.
* Use a per-process flag that will be set whenever the process increases the refcount and unset whenever the process decreases the refcount.

Quoted 8 lines
Quoted 2 lines

Yes, that sounds sane, and that's how reasonable wakelock implementation should look like.

One small point: If you add a per-device flag and a per-process flag as described above, then drivers and processes must not acquire nested references.

Obviously this is fixable, but it's worth mentioning...

Yes, it's important to remeber IMO.

Thanks,
Rafael

#258 lore raw
In reply to Alan Stern
Quoted 12 lines · Alan Stern
Quoted 10 lines · Pavel Machek
Quoted 9 lines

To summarize, we can:
* Use a refcount such that automatic suspend will only be possible if it's equal to zero (but that need not be the only criterion).
* Use a per-device flag in dev_pm_info that will be set whenever the device driver increases the refcount and unset whenever the driver decreases the refcount.
* Use a per-process flag that will be set whenever the process increases the refcount and unset whenever the process decreases the refcount.

Quoted 8 lines
Quoted 2 lines

Yes, that sounds sane, and that's how reasonable wakelock implementation should look like.

One small point: If you add a per-device flag and a per-process flag as described above, then drivers and processes must not acquire nested references.

Obviously this is fixable, but it's worth mentioning...

Yes, it's important to remeber IMO.

Thanks,
Rafael

#259 lore raw
In reply to Rafael J. Wysocki
Quoted 9 lines

To summarize, we can:
* Use a refcount such that automatic suspend will only be possible if it's equal to zero (but that need not be the only criterion).
* Use a per-device flag in dev_pm_info that will be set whenever the device driver increases the refcount and unset whenever the driver decreases the refcount.
* Use a per-process flag that will be set whenever the process increases the refcount and unset whenever the process decreases the refcount.

Yes, that sounds sane, and that's how reasonable wakelock implementation should look like.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#260 lore raw
In reply to Rafael J. Wysocki

Am Freitag 20 Februar 2009 16:56:59 schrieb Rafael J. Wysocki:

Quoted 4 lines

OK, so what about the following approach:

* Keep the decision making logic (power manager etc.) in user space.
Reasons: - It may be arbitrarily complicated

Therefore something functionally equivalent to wakelocks is needed.

Quoted 2 lines

- It may include such things as s2ram quirks or hal quirks needed for
some graphics adapters

If you can't do that I'd say the situation is hopeless. You need full support for all devices including graphics cards.

Quoted 2 lines

* Have a per-process (per-task or per-thread group, but the former would be easier IMO) "I_do_not_want_automatic_suspend_to_occur" flag.

I think you got the default logic inverted.

Quoted 10 lines

* Add a new callback, say ->acknowledge(), to the set of each driver's PM operations, that will be called to check if the driver has anything
against automatic suspend (true - suspend can happen right now, false - suspend can't happen).

* Introduce /sys/power/sleep that will work like /sys/power/state, but:
- First, it will call ->acknowledge() for each driver (via bus types) to check if any of them wants to postpone the suspend (this will prevent
tasks from being frozen unnecessarily if it is known in advance that the suspend should not happen at the moment).

Ideally most devices should be already suspended, so I am not sure a new callback is really needed. In any cases it is an optimization only.

Quoted 6 lines

- Next, it will check the "I_do_not_want_automatic_suspend_to_occur" flag of each process and the suspend will be aborted if it is true for any
of them (quite frankly, I think that should be integrated with the freezer, in particular the tasks that have TIF_FREEZE set shouldn't be able to set this flag and it should be checked in the freezer loop for every task with TIF_FREEZE unset).

Why in this order?

Quoted 8 lines

- Next, it will proceed with suspending just like /sys/power/state does
(the drivers that missed the opportunity to abort the suspend by returning 'false' from ->acknowledge() can still abort the suspend by failing their ->suspend() routines).

Then, the decision making logic will be able to use /sys/power/sleep whenever it wishes to and the kernel will be able to refuse to suspend if it's not desirable at the moment.

I think everything that uses a "trigger" logic from user space is not a good idea. This will necessary introduce a race between the decision and the execution during which circumstances can change.

So it seems to me that an allow/disallow system from user space would be better.

Regards
Oliver

#261 lore raw
In reply to Alan Stern

Hi!

Quoted 11 lines
Quoted 2 lines

Again, the decision to trigger automatic suspend has to be based on some well defined criteria and the (in)activity of devices seems to be one of them.

I don't know what criteria the system monitor would use. It might have to be platform-specific. The Android people seem to have a pretty good idea of what criteria will work for them.

Inactivity of devices isn't always a good criterion. There might be a background task which wakes up every few seconds to do something as long as the system is awake, thereby keeping some device always active. The activity from this background task shouldn't prevent an auto-sleep.

Then we'd need a interface to mark such background task... and what is reasonable use for such task, anyway? Either its job is neccessary, or it should not waste power.

IOW maybe it is easier to eliminate such stuff?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#262 lore raw
In reply to Alan Stern

Hi!

Quoted 11 lines
Quoted 2 lines

Again, the decision to trigger automatic suspend has to be based on some well defined criteria and the (in)activity of devices seems to be one of them.

I don't know what criteria the system monitor would use. It might have to be platform-specific. The Android people seem to have a pretty good idea of what criteria will work for them.

Inactivity of devices isn't always a good criterion. There might be a background task which wakes up every few seconds to do something as long as the system is awake, thereby keeping some device always active. The activity from this background task shouldn't prevent an auto-sleep.

Then we'd need a interface to mark such background task... and what is reasonable use for such task, anyway? Either its job is neccessary, or it should not waste power.

IOW maybe it is easier to eliminate such stuff?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#263 lore raw

Am Sonntag 22 Februar 2009 15:03:11 schrieb Pavel Machek:

Quoted 10 lines

Hi!

Quoted 8 lines
Quoted 3 lines

Again, the decision to trigger automatic suspend has to be based on some well defined criteria and the (in)activity of devices seems to be one of them.

I don't know what criteria the system monitor would use. It might have to be platform-specific. The Android people seem to have a pretty good idea of what criteria will work for them.

Quoted 8 lines
Quoted 4 lines

Inactivity of devices isn't always a good criterion. There might be a background task which wakes up every few seconds to do something as long as the system is awake, thereby keeping some device always active. The activity from this background task shouldn't prevent an auto-sleep.

Then we'd need a interface to mark such background task... and what is reasonable use for such task, anyway? Either its job is neccessary, or it should not waste power.

Why? We have decided that some tasks are more important than other tasks, to the point of starving some tasks. Posix real time already does that.

We can just as well have a class of tasks less important than power saving. They'd just run when power saving is not active for some other reason. Just like other such schemes we end up with the problem of priority inversion with locking.

Regards
Oliver

#264 lore raw
Quoted 20 lines · Oliver Neukum

Am Sonntag 22 Februar 2009 15:03:11 schrieb Pavel Machek:

Quoted 10 lines

Hi!

Quoted 8 lines
Quoted 3 lines

Again, the decision to trigger automatic suspend has to be based on some well defined criteria and the (in)activity of devices seems to be one of them.

I don't know what criteria the system monitor would use. It might have to be platform-specific. The Android people seem to have a pretty good idea of what criteria will work for them.

Quoted 8 lines
Quoted 4 lines

Inactivity of devices isn't always a good criterion. There might be a background task which wakes up every few seconds to do something as long as the system is awake, thereby keeping some device always active. The activity from this background task shouldn't prevent an auto-sleep.

Then we'd need a interface to mark such background task... and what is reasonable use for such task, anyway? Either its job is neccessary, or it should not waste power.

Quoted 8 lines

Why? We have decided that some tasks are more important than other tasks, to the point of starving some tasks. Posix real time already does that.

We can just as well have a class of tasks less important than power saving. They'd just run when power saving is not active for some other reason. Just like other such schemes we end up with the problem of priority inversion with locking.

Ok, I guess this could be interesting in some cases... maybe. What are real examples of such tasks?

Note that this will be fairly hard to implement due to all the priority inversions; so it better be pretty important.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#265 lore raw

Am Freitag 27 Februar 2009 11:18:18 schrieb Pavel Machek:

Quoted 7 lines
Quoted 4 lines

We can just as well have a class of tasks less important than power saving. They'd just run when power saving is not active for some other reason. Just like other such schemes we end up with the problem of priority inversion with locking.

Ok, I guess this could be interesting in some cases... maybe. What are real examples of such tasks?

The classical example is Seti@HOME. Any monitoring tool like umtsmon or kwifimanager.

Regards
Oliver

#266 lore raw
Quoted 10 lines · Oliver Neukum

Am Freitag 27 Februar 2009 11:18:18 schrieb Pavel Machek:

Quoted 7 lines
Quoted 4 lines

We can just as well have a class of tasks less important than power saving. They'd just run when power saving is not active for some other reason. Just like other such schemes we end up with the problem of priority inversion with locking.

Ok, I guess this could be interesting in some cases... maybe. What are real examples of such tasks?

The classical example is Seti@HOME.

So it is okay for you to waste 30W on seti on running machine on battery power but you can't waste those remaining 10W...? I guess I'd either expect seti to stop at battery power...

suspended machine 0.3W
awake machine 10W
machine running seti 40W

...? (thinkpad x60).

Ok... for something less computing intensive, it might make sense... but I guess those examples are less widespread than you expect.

Quoted 2 lines

Any monitoring tool like umtsmon
or kwifimanager.

I'd expect desktop environment to stop wasting cycles/electrons on that when user can't see the screen.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#267 lore raw
In reply to Oliver Neukum
Quoted 10 lines · Oliver Neukum

Am Freitag 27 Februar 2009 11:18:18 schrieb Pavel Machek:

Quoted 7 lines
Quoted 4 lines

We can just as well have a class of tasks less important than power saving. They'd just run when power saving is not active for some other reason. Just like other such schemes we end up with the problem of priority inversion with locking.

Ok, I guess this could be interesting in some cases... maybe. What are real examples of such tasks?

The classical example is Seti@HOME.

So it is okay for you to waste 30W on seti on running machine on battery power but you can't waste those remaining 10W...? I guess I'd either expect seti to stop at battery power...

suspended machine 0.3W
awake machine 10W
machine running seti 40W

...? (thinkpad x60).

Ok... for something less computing intensive, it might make sense... but I guess those examples are less widespread than you expect.

Quoted 2 lines

Any monitoring tool like umtsmon
or kwifimanager.

I'd expect desktop environment to stop wasting cycles/electrons on that when user can't see the screen.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#268 lore raw
In reply to Pavel Machek

Am Freitag 27 Februar 2009 11:18:18 schrieb Pavel Machek:

Quoted 7 lines
Quoted 4 lines

We can just as well have a class of tasks less important than power saving. They'd just run when power saving is not active for some other reason. Just like other such schemes we end up with the problem of priority inversion with locking.

Ok, I guess this could be interesting in some cases... maybe. What are real examples of such tasks?

The classical example is Seti@HOME. Any monitoring tool like umtsmon or kwifimanager.

Regards
Oliver

#269 lore raw
In reply to Pavel Machek
Quoted 9 lines · Pavel Machek
Quoted 4 lines · Oliver Neukum

We can just as well have a class of tasks less important than power saving. They'd just run when power saving is not active for some other reason. Just like other such schemes we end up with the problem of priority inversion with locking.

Ok, I guess this could be interesting in some cases... maybe. What are real examples of such tasks?

Some people might put casual system monitoring tools into this category--top, xload, gkrellm, xclock, etc.

It'd be nice if the animated banner ad in my web browser could be treated this way. :)

Chris

#270 lore raw
In reply to Pavel Machek
Quoted 9 lines · Pavel Machek
Quoted 4 lines · Oliver Neukum

We can just as well have a class of tasks less important than power saving. They'd just run when power saving is not active for some other reason. Just like other such schemes we end up with the problem of priority inversion with locking.

Ok, I guess this could be interesting in some cases... maybe. What are real examples of such tasks?

Some people might put casual system monitoring tools into this category--top, xload, gkrellm, xclock, etc.

It'd be nice if the animated banner ad in my web browser could be treated this way. :)

Chris

#271 lore raw
Quoted 8 lines · Chris Friesen
Quoted 7 lines · Pavel Machek
Quoted 4 lines · Oliver Neukum

We can just as well have a class of tasks less important than power saving. They'd just run when power saving is not active for some other reason. Just like other such schemes we end up with the problem of priority inversion with locking.

Quoted 5 lines
Quoted 2 lines

Ok, I guess this could be interesting in some cases... maybe. What are real examples of such tasks?

Some people might put casual system monitoring tools into this category--top, xload, gkrellm, xclock, etc.

I guess system monitoring should stop itself when screen is blanked... no need to compute list of processes if user can't see the output.

But I see that may be slightly hard for command-line tool like top. .... but it still seems like right solution. Why waste power/cycles displaying xclock at tty9 when user is looking at tty10?

Quoted 2 lines

It'd be nice if the animated banner ad in my web browser could be treated this way. :)

Well, my web browser already has an option 'animate once'. No need to waste power with that at all :-).
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#272 lore raw
In reply to Chris Friesen
Quoted 8 lines · Chris Friesen
Quoted 7 lines · Pavel Machek
Quoted 4 lines · Oliver Neukum

We can just as well have a class of tasks less important than power saving. They'd just run when power saving is not active for some other reason. Just like other such schemes we end up with the problem of priority inversion with locking.

Quoted 5 lines
Quoted 2 lines

Ok, I guess this could be interesting in some cases... maybe. What are real examples of such tasks?

Some people might put casual system monitoring tools into this category--top, xload, gkrellm, xclock, etc.

I guess system monitoring should stop itself when screen is blanked... no need to compute list of processes if user can't see the output.

But I see that may be slightly hard for command-line tool like top. .... but it still seems like right solution. Why waste power/cycles displaying xclock at tty9 when user is looking at tty10?

Quoted 2 lines

It'd be nice if the animated banner ad in my web browser could be treated this way. :)

Well, my web browser already has an option 'animate once'. No need to waste power with that at all :-).
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#273 lore raw
In reply to Oliver Neukum
Quoted 20 lines · Oliver Neukum

Am Sonntag 22 Februar 2009 15:03:11 schrieb Pavel Machek:

Quoted 10 lines

Hi!

Quoted 8 lines
Quoted 3 lines

Again, the decision to trigger automatic suspend has to be based on some well defined criteria and the (in)activity of devices seems to be one of them.

I don't know what criteria the system monitor would use. It might have to be platform-specific. The Android people seem to have a pretty good idea of what criteria will work for them.

Quoted 8 lines
Quoted 4 lines

Inactivity of devices isn't always a good criterion. There might be a background task which wakes up every few seconds to do something as long as the system is awake, thereby keeping some device always active. The activity from this background task shouldn't prevent an auto-sleep.

Then we'd need a interface to mark such background task... and what is reasonable use for such task, anyway? Either its job is neccessary, or it should not waste power.

Quoted 8 lines

Why? We have decided that some tasks are more important than other tasks, to the point of starving some tasks. Posix real time already does that.

We can just as well have a class of tasks less important than power saving. They'd just run when power saving is not active for some other reason. Just like other such schemes we end up with the problem of priority inversion with locking.

Ok, I guess this could be interesting in some cases... maybe. What are real examples of such tasks?

Note that this will be fairly hard to implement due to all the priority inversions; so it better be pretty important.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#274 lore raw
In reply to Pavel Machek

Am Sonntag 22 Februar 2009 15:03:11 schrieb Pavel Machek:

Quoted 10 lines

Hi!

Quoted 8 lines
Quoted 3 lines

Again, the decision to trigger automatic suspend has to be based on some well defined criteria and the (in)activity of devices seems to be one of them.

I don't know what criteria the system monitor would use. It might have to be platform-specific. The Android people seem to have a pretty good idea of what criteria will work for them.

Quoted 8 lines
Quoted 4 lines

Inactivity of devices isn't always a good criterion. There might be a background task which wakes up every few seconds to do something as long as the system is awake, thereby keeping some device always active. The activity from this background task shouldn't prevent an auto-sleep.

Then we'd need a interface to mark such background task... and what is reasonable use for such task, anyway? Either its job is neccessary, or it should not waste power.

Why? We have decided that some tasks are more important than other tasks, to the point of starving some tasks. Posix real time already does that.

We can just as well have a class of tasks less important than power saving. They'd just run when power saving is not active for some other reason. Just like other such schemes we end up with the problem of priority inversion with locking.

Regards
Oliver

#275 lore raw
In reply to Alan Stern
Quoted 9 lines · Alan Stern
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines

If some devices are autosuspended after a local inactivity timeout, I don't want to wait for those devices to autosuspend if I know the code that needed to run is done. This could cause delays in the normal case,

Isn't it a matter of adjusting the inactivity timeouts in a suitable way?

Quoted 8 lines

It's not that simple. A single device driver has a very local view, not suitable for deciding whether the entire system should go to sleep.

So for example, a disk driver might think it's appropriate to spin down the disk after 10 seconds of inactivity. But an overall system monitor might realize that nothing is going on right now and want to put the system to sleep immediately, without waiting the 10 seconds for the disk to autosuspend.

Hmm, I'm not sure. If system is so busy that it keeps the disk up, it may not be good idea to sleep whole system.

Example: "idle fileserver". Current command is done, so we seem to be idle; but when we sleep, new command comes. While system really is idle, it is bad idea to suspend.

If the overall system monitor can decide disk will not be used, it can just sleep the disk.

Quoted 11 lines
Quoted 6 lines
Quoted 2 lines

and it could prevent suspend if a background process (not using wakelocks) is accessing a disk more frequently than its idle timeout.

Well, actually, shouldn't it prevent suspend from happening? Arguably, it just means that the disk is continuously being accessed with respect to the inactive timeout granularity.

That's true, but it shows the problem of making the autosleep decision based on disk activity. An auto-sleep should not have to wait for every device (or some suitable subset) to become idle for some minimum time; it should be able to kick in at short notice.

I believe we do want to wake for timeouts, as not all sources of wakeup are local.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#276 lore raw
In reply to Alan Stern
Quoted 9 lines · Alan Stern
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines

If some devices are autosuspended after a local inactivity timeout, I don't want to wait for those devices to autosuspend if I know the code that needed to run is done. This could cause delays in the normal case,

Isn't it a matter of adjusting the inactivity timeouts in a suitable way?

Quoted 8 lines

It's not that simple. A single device driver has a very local view, not suitable for deciding whether the entire system should go to sleep.

So for example, a disk driver might think it's appropriate to spin down the disk after 10 seconds of inactivity. But an overall system monitor might realize that nothing is going on right now and want to put the system to sleep immediately, without waiting the 10 seconds for the disk to autosuspend.

Hmm, I'm not sure. If system is so busy that it keeps the disk up, it may not be good idea to sleep whole system.

Example: "idle fileserver". Current command is done, so we seem to be idle; but when we sleep, new command comes. While system really is idle, it is bad idea to suspend.

If the overall system monitor can decide disk will not be used, it can just sleep the disk.

Quoted 11 lines
Quoted 6 lines
Quoted 2 lines

and it could prevent suspend if a background process (not using wakelocks) is accessing a disk more frequently than its idle timeout.

Well, actually, shouldn't it prevent suspend from happening? Arguably, it just means that the disk is continuously being accessed with respect to the inactive timeout granularity.

That's true, but it shows the problem of making the autosleep decision based on disk activity. An auto-sleep should not have to wait for every device (or some suitable subset) to become idle for some minimum time; it should be able to kick in at short notice.

I believe we do want to wake for timeouts, as not all sources of wakeup are local.
Pavel

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

Hi!

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

Phase 3: Probably explicit control left to open/close.

While that's generally a good idea, it's important to recognize that some devices should be runtime-suspended even while they are open.

Quoted 7 lines
Quoted 2 lines

From the kernel side, yes (and that should be transparent to the user space having them open). By the user space, no.

Allowing user space to suspend input devices while they are still open is useful. The user-space code that reads from the input devices does not need to know if the device is suspended or not, and the kernel cannot auto suspend input devices based on inactivity.

Actually, I'd like you to fix your userspace and close input devices when it does not need them. Given the way you control the platform it should not be that hard. I do not see why we'd want to invent new interface for "uhuh, I have opened the keyboard but I am not really interested in keys being pressed".
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#278 lore raw

Am Sonntag 01 März 2009 23:56:47 schrieb Pavel Machek:

Quoted 10 lines
Quoted 4 lines

Allowing user space to suspend input devices while they are still open is useful. The user-space code that reads from the input devices does not need to know if the device is suspended or not, and the kernel cannot auto suspend input devices based on inactivity.

Actually, I'd like you to fix your userspace and close input devices when it does not need them. Given the way you control the platform it should not be that hard. I do not see why we'd want to invent new interface for "uhuh, I have opened the keyboard but I am not really interested in keys being pressed".

Generally you can't do this. A task has an open fd.

- you cannot assume it can open the device again (fd may be inherited)
- keeping the device open makes sure you are talking to the same device
- you may want to avoid repeating expensive initialisations
- some input devices also do output

Regards
Oliver

#279 lore raw
Quoted 12 lines · Oliver Neukum

Am Sonntag 01 März 2009 23:56:47 schrieb Pavel Machek:

Quoted 10 lines
Quoted 4 lines

Allowing user space to suspend input devices while they are still open is useful. The user-space code that reads from the input devices does not need to know if the device is suspended or not, and the kernel cannot auto suspend input devices based on inactivity.

Actually, I'd like you to fix your userspace and close input devices when it does not need them. Given the way you control the platform it should not be that hard. I do not see why we'd want to invent new interface for "uhuh, I have opened the keyboard but I am not really interested in keys being pressed".

Quoted 4 lines

Generally you can't do this. A task has an open fd.

- you cannot assume it can open the device again (fd may be inherited)

Well, those tasks that matter - X servers and similar - usually can.

Quoted 1 line

- keeping the device open makes sure you are talking to the same device

Well, you have to handle hotplug anyway, so... and the name will not change unless you unplug/replug.

Quoted 1 line

- you may want to avoid repeating expensive initialisations

That kind of initializations should perhaps be done at insmod, not open time?

Quoted 1 line

- some input devices also do output

I guess you want to separate those to two different devices, then.

Anyway...

* I'd prefer "close to powersave". I can see that can be tricky to use. So the alternative is

* ioctl() "I'm not interested in exact keys, powersave" is something that makes sense. It should really be discussed with input people.

I'd hate to see

* magic /sys/.../file where you echo 1 to powersave. It is too disconnected from the input fd, and while it may make it easier to retrofit powermanagement without modifying Xservers etc... it will ultimately result in pretty ugly hacks.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#280 lore raw
In reply to Oliver Neukum
Quoted 12 lines · Oliver Neukum

Am Sonntag 01 März 2009 23:56:47 schrieb Pavel Machek:

Quoted 10 lines
Quoted 4 lines

Allowing user space to suspend input devices while they are still open is useful. The user-space code that reads from the input devices does not need to know if the device is suspended or not, and the kernel cannot auto suspend input devices based on inactivity.

Actually, I'd like you to fix your userspace and close input devices when it does not need them. Given the way you control the platform it should not be that hard. I do not see why we'd want to invent new interface for "uhuh, I have opened the keyboard but I am not really interested in keys being pressed".

Quoted 4 lines

Generally you can't do this. A task has an open fd.

- you cannot assume it can open the device again (fd may be inherited)

Well, those tasks that matter - X servers and similar - usually can.

Quoted 1 line

- keeping the device open makes sure you are talking to the same device

Well, you have to handle hotplug anyway, so... and the name will not change unless you unplug/replug.

Quoted 1 line

- you may want to avoid repeating expensive initialisations

That kind of initializations should perhaps be done at insmod, not open time?

Quoted 1 line

- some input devices also do output

I guess you want to separate those to two different devices, then.

Anyway...

* I'd prefer "close to powersave". I can see that can be tricky to use. So the alternative is

* ioctl() "I'm not interested in exact keys, powersave" is something that makes sense. It should really be discussed with input people.

I'd hate to see

* magic /sys/.../file where you echo 1 to powersave. It is too disconnected from the input fd, and while it may make it easier to retrofit powermanagement without modifying Xservers etc... it will ultimately result in pretty ugly hacks.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#281 lore raw
In reply to Oliver Neukum
Quoted 1 line · On Mon, 2 Mar 2009 09:24:36 +0100 Oliver Neukum <[email protected]> wrote:

- you may want to avoid repeating expensive initialisations

btw this "expensive intialization" for a correct driver... is the same thing you need to do to get the device out of power saving mode..

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#282 lore raw
In reply to Oliver Neukum
Quoted 1 line · On Mon, 2 Mar 2009 09:24:36 +0100 Oliver Neukum <[email protected]> wrote:

- you may want to avoid repeating expensive initialisations

btw this "expensive intialization" for a correct driver... is the same thing you need to do to get the device out of power saving mode..

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#283 lore raw
In reply to Pavel Machek

Am Sonntag 01 März 2009 23:56:47 schrieb Pavel Machek:

Quoted 10 lines
Quoted 4 lines

Allowing user space to suspend input devices while they are still open is useful. The user-space code that reads from the input devices does not need to know if the device is suspended or not, and the kernel cannot auto suspend input devices based on inactivity.

Actually, I'd like you to fix your userspace and close input devices when it does not need them. Given the way you control the platform it should not be that hard. I do not see why we'd want to invent new interface for "uhuh, I have opened the keyboard but I am not really interested in keys being pressed".

Generally you can't do this. A task has an open fd.

- you cannot assume it can open the device again (fd may be inherited)
- keeping the device open makes sure you are talking to the same device
- you may want to avoid repeating expensive initialisations
- some input devices also do output

Regards
Oliver

#284 lore raw
In reply to Arve Hjønnevåg

Hi!

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

Phase 3: Probably explicit control left to open/close.

While that's generally a good idea, it's important to recognize that some devices should be runtime-suspended even while they are open.

Quoted 7 lines
Quoted 2 lines

From the kernel side, yes (and that should be transparent to the user space having them open). By the user space, no.

Allowing user space to suspend input devices while they are still open is useful. The user-space code that reads from the input devices does not need to know if the device is suspended or not, and the kernel cannot auto suspend input devices based on inactivity.

Actually, I'd like you to fix your userspace and close input devices when it does not need them. Given the way you control the platform it should not be that hard. I do not see why we'd want to invent new interface for "uhuh, I have opened the keyboard but I am not really interested in keys being pressed".
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#285 lore raw
In reply to Arjan van de Ven

Am Monday 16 February 2009 18:31:08 schrieb Arjan van de Ven:

Quoted 7 lines
Quoted 4 lines · On Mon, 16 Feb 2009 17:48:06 +0100 Oliver Neukum <[email protected]> wrote:
Quoted 3 lines

Userspace should just be the part that says "I'm interested in link notifications". The driver then just goes to the lowest power state for its device that still gives those notifications.

Quoted 8 lines
Quoted 3 lines

Should there be a channel through which drivers can tell user space what the consequences in terms of reaching a sleep state are if a service is requested?

Personally, I don't think so.
Think about it: what would userspace do?
Not ask for the functionality if it means no sleep state? Maybe it should just never ask for it then as a required functionality!

1. You may have a human being using the information to make the tradeoff.
2. User space may be able to select among several devices the one cheapest to use

Regards
Oliver

#286 lore raw
Quoted 12 lines · Oliver Neukum

Am Monday 16 February 2009 18:31:08 schrieb Arjan van de Ven:

Quoted 11 lines
Quoted 7 lines · On Mon, 16 Feb 2009 17:48:06 +0100 Oliver Neukum <[email protected]> wrote:
Quoted 3 lines

Userspace should just be the part that says "I'm interested in link notifications". The driver then just goes to the lowest power state for its device that still gives those notifications.

Should there be a channel through which drivers can tell user space what the consequences in terms of reaching a sleep state are if a service is requested?

Quoted 8 lines
Quoted 4 lines

Personally, I don't think so.
Think about it: what would userspace do?
Not ask for the functionality if it means no sleep state? Maybe it should just never ask for it then as a required functionality!

1. You may have a human being using the information to make the tradeoff.
2. User space may be able to select among several devices the one cheapest to use

Well, that sounds complex/fragile... and it is really exporting hardware impormation driver does not even neccessarily know.

If this is for user, perhaps it should be in documentation and/or hardware user manual?

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#287 lore raw
In reply to Oliver Neukum
Quoted 12 lines · Oliver Neukum

Am Monday 16 February 2009 18:31:08 schrieb Arjan van de Ven:

Quoted 11 lines
Quoted 7 lines · On Mon, 16 Feb 2009 17:48:06 +0100 Oliver Neukum <[email protected]> wrote:
Quoted 3 lines

Userspace should just be the part that says "I'm interested in link notifications". The driver then just goes to the lowest power state for its device that still gives those notifications.

Should there be a channel through which drivers can tell user space what the consequences in terms of reaching a sleep state are if a service is requested?

Quoted 8 lines
Quoted 4 lines

Personally, I don't think so.
Think about it: what would userspace do?
Not ask for the functionality if it means no sleep state? Maybe it should just never ask for it then as a required functionality!

1. You may have a human being using the information to make the tradeoff.
2. User space may be able to select among several devices the one cheapest to use

Well, that sounds complex/fragile... and it is really exporting hardware impormation driver does not even neccessarily know.

If this is for user, perhaps it should be in documentation and/or hardware user manual?

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#288 lore raw
In reply to Arjan van de Ven

Am Monday 16 February 2009 18:31:08 schrieb Arjan van de Ven:

Quoted 7 lines
Quoted 4 lines · On Mon, 16 Feb 2009 17:48:06 +0100 Oliver Neukum <[email protected]> wrote:
Quoted 3 lines

Userspace should just be the part that says "I'm interested in link notifications". The driver then just goes to the lowest power state for its device that still gives those notifications.

Quoted 8 lines
Quoted 3 lines

Should there be a channel through which drivers can tell user space what the consequences in terms of reaching a sleep state are if a service is requested?

Personally, I don't think so.
Think about it: what would userspace do?
Not ask for the functionality if it means no sleep state? Maybe it should just never ask for it then as a required functionality!

1. You may have a human being using the information to make the tradeoff.
2. User space may be able to select among several devices the one cheapest to use

Regards
Oliver

#289 lore raw
In reply to Arjan van de Ven

Am Monday 16 February 2009 16:40:48 schrieb Arjan van de Ven:

Quoted 7 lines
Quoted 3 lines

Why shouldn't user space know the consequences of still requesting a service and be able to decide on that basis which services to request?

That's not what I said. Userspace should not be the part that goes "oh this is a realtek not an intel nic, so ..."
That is the drivers job.

True.

Quoted 3 lines

Userspace should just be the part that says "I'm interested in link notifications". The driver then just goes to the lowest power state for its device that still gives those notifications.

Should there be a channel through which drivers can tell user space what the consequences in terms of reaching a sleep state are if a service is requested?

Regards
Oliver

#290 lore raw
In reply to Arjan van de Ven

Am Monday 16 February 2009 03:20:12 schrieb Arjan van de Ven:

Quoted 10 lines
Quoted 4 lines

or
network or similar where the driver cannot shut the device down without losing the ability to detect activity (ie, switch your PHY off is nice but you lose the ability to monitor the link for example).

what this needs is a separation between "interface down, all off" and "interface down enough so that link detection works".
Some NICs can go all the way down and still do link detection, others cannot. This is obviously something the driver will know, nothing else in the system should know.

Why shouldn't user space know the consequences of still requesting a service and be able to decide on that basis which services to request?

Regards
Oliver

#291 lore raw
In reply to Arjan van de Ven
Quoted 7 lines
Quoted 2 lines

(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

For (2), for me the answer is very obvious:

The Device Driver needs to make the decision to put the device to sleep. There are no ifs and buts about this.

For PC-like systems this is probably all that needs to be said. However for highly integrated SoC systems (as Android is obviously targeting) there is another level of complexity due to the interdependency among various devices... eg things like if I know the SD controller and the wifi chip are both asleep then I can put my SDIO controller to sleep; and if the SDIO controller and the NAND controller are both asleep then I can stop clock X and save more power; etc etc.

This is what the PowerOp/DPM work was all about. Unfortunately that doesn't seem to have made much progress upstream. But there's no doubt in my mind that we need some framework beyond individual drivers that manages the system's power as a whole. And the current device tree is probably not sufficient -- eg the bus hierarchy of a device may not match up with the clock tree at all.

- R.

#292 lore raw
In reply to Arjan van de Ven
Quoted 7 lines
Quoted 2 lines

(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

For (2), for me the answer is very obvious:

The Device Driver needs to make the decision to put the device to sleep. There are no ifs and buts about this.

For PC-like systems this is probably all that needs to be said. However for highly integrated SoC systems (as Android is obviously targeting) there is another level of complexity due to the interdependency among various devices... eg things like if I know the SD controller and the wifi chip are both asleep then I can put my SDIO controller to sleep; and if the SDIO controller and the NAND controller are both asleep then I can stop clock X and save more power; etc etc.

This is what the PowerOp/DPM work was all about. Unfortunately that doesn't seem to have made much progress upstream. But there's no doubt in my mind that we need some framework beyond individual drivers that manages the system's power as a whole. And the current device tree is probably not sufficient -- eg the bus hierarchy of a device may not match up with the clock tree at all.

- R.

#293 lore raw
Quoted 9 lines · On Sun, 15 Feb 2009 22:23:04 -0800 Roland Dreier <[email protected]> wrote:
Quoted 8 lines
Quoted 3 lines

(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

For (2), for me the answer is very obvious:

The Device Driver needs to make the decision to put the device to sleep. There are no ifs and buts about this.

Quoted 8 lines

For PC-like systems this is probably all that needs to be said. However for highly integrated SoC systems (as Android is obviously targeting) there is another level of complexity due to the interdependency among various devices... eg things like if I know the SD controller and the wifi chip are both asleep then I can put my SDIO controller to sleep; and if the SDIO controller and the NAND controller are both asleep then I can stop clock X and save more power; etc etc.

This does not change the rules.
The individual drivers still make up the decision of what state their own block should be in.

What you're talking about is coordination. Some systems do this in silicon, and others, like you mention, need a small software layer to do this coordination. Fine. But this doesn't change the fundamentals.

Quoted 3 lines

This is what the PowerOp/DPM work was all about. Unfortunately that doesn't seem to have made much progress upstream.

PowerOP/DPM were... more or less hampered because they operated in global "modes". Everyone (including the OMAP guys) has pretty much gone away from the idea that modes are global. Power management is not global; if you treat it as global then you're in trouble, since the decisions really are local (and in better hw, even done in the hw)

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#294 lore raw
In reply to Roland Dreier
Quoted 9 lines · On Sun, 15 Feb 2009 22:23:04 -0800 Roland Dreier <[email protected]> wrote:
Quoted 8 lines
Quoted 3 lines

(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

For (2), for me the answer is very obvious:

The Device Driver needs to make the decision to put the device to sleep. There are no ifs and buts about this.

Quoted 8 lines

For PC-like systems this is probably all that needs to be said. However for highly integrated SoC systems (as Android is obviously targeting) there is another level of complexity due to the interdependency among various devices... eg things like if I know the SD controller and the wifi chip are both asleep then I can put my SDIO controller to sleep; and if the SDIO controller and the NAND controller are both asleep then I can stop clock X and save more power; etc etc.

This does not change the rules.
The individual drivers still make up the decision of what state their own block should be in.

What you're talking about is coordination. Some systems do this in silicon, and others, like you mention, need a small software layer to do this coordination. Fine. But this doesn't change the fundamentals.

Quoted 3 lines

This is what the PowerOp/DPM work was all about. Unfortunately that doesn't seem to have made much progress upstream.

PowerOP/DPM were... more or less hampered because they operated in global "modes". Everyone (including the OMAP guys) has pretty much gone away from the idea that modes are global. Power management is not global; if you treat it as global then you're in trouble, since the decisions really are local (and in better hw, even done in the hw)

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#295 lore raw
In reply to Roland Dreier
Quoted 16 lines · Roland Dreier
Quoted 7 lines
Quoted 2 lines

(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

For (2), for me the answer is very obvious:

The Device Driver needs to make the decision to put the device to sleep. There are no ifs and buts about this.

For PC-like systems this is probably all that needs to be said. However for highly integrated SoC systems (as Android is obviously targeting) there is another level of complexity due to the interdependency among various devices... eg things like if I know the SD controller and the wifi chip are both asleep then I can put my SDIO controller to sleep; and if the SDIO controller and the NAND controller are both asleep then I can stop clock X and save more power; etc etc.

Quoted 6 lines

This is what the PowerOp/DPM work was all about. Unfortunately that doesn't seem to have made much progress upstream. But there's no doubt in my mind that we need some framework beyond individual drivers that manages the system's power as a whole. And the current device tree is probably not sufficient -- eg the bus hierarchy of a device may not match up with the clock tree at all.

Well, that's why clock framework exists. But none of this is visible to userland.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#296 lore raw
In reply to Roland Dreier
Quoted 16 lines · Roland Dreier
Quoted 7 lines
Quoted 2 lines

(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

For (2), for me the answer is very obvious:

The Device Driver needs to make the decision to put the device to sleep. There are no ifs and buts about this.

For PC-like systems this is probably all that needs to be said. However for highly integrated SoC systems (as Android is obviously targeting) there is another level of complexity due to the interdependency among various devices... eg things like if I know the SD controller and the wifi chip are both asleep then I can put my SDIO controller to sleep; and if the SDIO controller and the NAND controller are both asleep then I can stop clock X and save more power; etc etc.

Quoted 6 lines

This is what the PowerOp/DPM work was all about. Unfortunately that doesn't seem to have made much progress upstream. But there's no doubt in my mind that we need some framework beyond individual drivers that manages the system's power as a whole. And the current device tree is probably not sufficient -- eg the bus hierarchy of a device may not match up with the clock tree at all.

Well, that's why clock framework exists. But none of this is visible to userland.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#297 lore raw
In reply to Arjan van de Ven

Am Monday 16 February 2009 01:44:56 schrieb Arjan van de Ven:

Quoted 16 lines
Quoted 9 lines · On Mon, 16 Feb 2009 00:10:15 +0100 "Rafael J. Wysocki" <[email protected]> wrote:

Hi,

The recent descussion about the Android PM patches sent by Arve shows that there is a need to introduce a mechanism allowing us to:
(1) automatically put the system as a whole into a sleep state (eg. suspend to RAM) when it is found to be "idle", where the meaning of "idle" has to be defined too,
(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

For (2), for me the answer is very obvious:

Quoted 7 lines

The Device Driver needs to make the decision to put the device to sleep. There are no ifs and buts about this.

It's the driver who
a) knows if there's any activity, such as open users and
b) is in the right position to know how to put things to sleep.

I think you need third option between decides to put to sleep and refuses to put to sleep. It is probably necessary to let drivers state that they would want to go along if the whole system goes to sleep.

Quoted 6 lines

Of course, the subsystem the driver belongs to can provide helpers (such as generic activity timeout handlers etc).

For many cases, the drivers do this today already.
There are cases where doing this has side effects, mostly in terms of latency. It is reasonable to have a general mechanism that provides a

Exactly.

Regards
Oliver

#298 lore raw
In reply to Arjan van de Ven

Am Monday 16 February 2009 01:44:56 schrieb Arjan van de Ven:

Quoted 16 lines
Quoted 9 lines · On Mon, 16 Feb 2009 00:10:15 +0100 "Rafael J. Wysocki" <[email protected]> wrote:

Hi,

The recent descussion about the Android PM patches sent by Arve shows that there is a need to introduce a mechanism allowing us to:
(1) automatically put the system as a whole into a sleep state (eg. suspend to RAM) when it is found to be "idle", where the meaning of "idle" has to be defined too,
(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

For (2), for me the answer is very obvious:

Quoted 7 lines

The Device Driver needs to make the decision to put the device to sleep. There are no ifs and buts about this.

It's the driver who
a) knows if there's any activity, such as open users and
b) is in the right position to know how to put things to sleep.

I think you need third option between decides to put to sleep and refuses to put to sleep. It is probably necessary to let drivers state that they would want to go along if the whole system goes to sleep.

Quoted 6 lines

Of course, the subsystem the driver belongs to can provide helpers (such as generic activity timeout handlers etc).

For many cases, the drivers do this today already.
There are cases where doing this has side effects, mostly in terms of latency. It is reasonable to have a general mechanism that provides a

Exactly.

Regards
Oliver

#299 lore raw
In reply to Arjan van de Ven
Quoted 19 lines · Arjan van de Ven
Quoted 9 lines · On Mon, 16 Feb 2009 00:10:15 +0100 "Rafael J. Wysocki" <[email protected]> wrote:

Hi,

The recent descussion about the Android PM patches sent by Arve shows that there is a need to introduce a mechanism allowing us to:
(1) automatically put the system as a whole into a sleep state (eg. suspend to RAM) when it is found to be "idle", where the meaning of "idle" has to be defined too,
(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

For (2), for me the answer is very obvious:

The Device Driver needs to make the decision to put the device to sleep. There are no ifs and buts about this.

Quoted 7 lines

It's the driver who
a) knows if there's any activity, such as open users and
b) is in the right position to know how to put things to sleep.

Of course, the subsystem the driver belongs to can provide helpers (such as generic activity timeout handlers etc).

While I generally agree, there is a difficulty that the driver itself need not have control over all of the bits needed to power manage the device. For example, we're going to make the PCI bus type handle the changing of PCI devices' power states, so the registers used for this purpose will be controlled by the PCI subsystem rather than by individual drivers.

In such cases we may need a mechanism by which the drivers can notify the higher layer that the device is inactive, so that the higher layer can put it into a low power state.

Quoted 6 lines

For many cases, the drivers do this today already.
There are cases where doing this has side effects, mostly in terms of latency. It is reasonable to have a general mechanism that provides a central mechanism to track tolerable latencies; in fact PMQOS provides this on a high level, and I can imagine that PMQOS needs to be extended to provide a wider range of type of latencies.

That indeed would be useful.

Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

Rafael

#300 lore raw
In reply to Arjan van de Ven
Quoted 19 lines · Arjan van de Ven
Quoted 9 lines · On Mon, 16 Feb 2009 00:10:15 +0100 "Rafael J. Wysocki" <[email protected]> wrote:

Hi,

The recent descussion about the Android PM patches sent by Arve shows that there is a need to introduce a mechanism allowing us to:
(1) automatically put the system as a whole into a sleep state (eg. suspend to RAM) when it is found to be "idle", where the meaning of "idle" has to be defined too,
(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

For (2), for me the answer is very obvious:

The Device Driver needs to make the decision to put the device to sleep. There are no ifs and buts about this.

Quoted 7 lines

It's the driver who
a) knows if there's any activity, such as open users and
b) is in the right position to know how to put things to sleep.

Of course, the subsystem the driver belongs to can provide helpers (such as generic activity timeout handlers etc).

While I generally agree, there is a difficulty that the driver itself need not have control over all of the bits needed to power manage the device. For example, we're going to make the PCI bus type handle the changing of PCI devices' power states, so the registers used for this purpose will be controlled by the PCI subsystem rather than by individual drivers.

In such cases we may need a mechanism by which the drivers can notify the higher layer that the device is inactive, so that the higher layer can put it into a low power state.

Quoted 6 lines

For many cases, the drivers do this today already.
There are cases where doing this has side effects, mostly in terms of latency. It is reasonable to have a general mechanism that provides a central mechanism to track tolerable latencies; in fact PMQOS provides this on a high level, and I can imagine that PMQOS needs to be extended to provide a wider range of type of latencies.

That indeed would be useful.

Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

Rafael

#301 lore raw
Quoted 7 lines · Rafael J. Wysocki
Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

Sounds like a recipe for disaster.

#302 lore raw
In reply to Rafael J. Wysocki
Quoted 7 lines · Rafael J. Wysocki
Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

Sounds like a recipe for disaster.

#303 lore raw
In reply to Rafael J. Wysocki
Quoted 8 lines · On Mon, 16 Feb 2009 22:48:32 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

I would think that that is a bad mistake to do. It basically breaks the contract that the kernel has with userspace....

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#304 lore raw
In reply to Rafael J. Wysocki
Quoted 8 lines · On Mon, 16 Feb 2009 22:48:32 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

I would think that that is a bad mistake to do. It basically breaks the contract that the kernel has with userspace....

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#305 lore raw
Quoted 7 lines · Arjan van de Ven
Quoted 4 lines · On Mon, 16 Feb 2009 22:48:32 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

Quoted 7 lines
Quoted 4 lines

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

I would think that that is a bad mistake to do. It basically breaks the contract that the kernel has with userspace....

OK, so I think there are two things that user space may be allowed to do as far as putting devices into low power states is concerned:
* disable/enable the automatic power management of the device (provided that the driver supports the automatic PM)
* check what power states devices are in.

Thanks,
Rafael

#306 lore raw
In reply to Arjan van de Ven
Quoted 7 lines · Arjan van de Ven
Quoted 4 lines · On Mon, 16 Feb 2009 22:48:32 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

Quoted 7 lines
Quoted 4 lines

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

I would think that that is a bad mistake to do. It basically breaks the contract that the kernel has with userspace....

OK, so I think there are two things that user space may be allowed to do as far as putting devices into low power states is concerned:
* disable/enable the automatic power management of the device (provided that the driver supports the automatic PM)
* check what power states devices are in.

Thanks,
Rafael

#307 lore raw
Quoted 4 lines · Rafael J. Wysocki

OK, so I think there are two things that user space may be allowed to do as far as putting devices into low power states is concerned:
* disable/enable the automatic power management of the device (provided that the driver supports the automatic PM)

Set the automatic PM parameters (idle timeout, state to go to, etc.). And disabling automatic PM altogether (effectively the same as setting the idle timeout to infinity).

Quoted 1 line

* check what power states devices are in.

What about situations where we want to distinguish between the power state of the device itself and the power state of the link? For a disk drive we may want to power the link on and off quite a lot, as that has low latency, but spinning the disk up and down takes a long time and so should have a longer idle-time value.

Alan Stern

#308 lore raw
In reply to Rafael J. Wysocki
Quoted 4 lines · Rafael J. Wysocki

OK, so I think there are two things that user space may be allowed to do as far as putting devices into low power states is concerned:
* disable/enable the automatic power management of the device (provided that the driver supports the automatic PM)

Set the automatic PM parameters (idle timeout, state to go to, etc.). And disabling automatic PM altogether (effectively the same as setting the idle timeout to infinity).

Quoted 1 line

* check what power states devices are in.

What about situations where we want to distinguish between the power state of the device itself and the power state of the link? For a disk drive we may want to power the link on and off quite a lot, as that has low latency, but spinning the disk up and down takes a long time and so should have a longer idle-time value.

Alan Stern

#309 lore raw
Quoted 11 lines · On Mon, 16 Feb 2009 17:40:10 -0500 (EST) Alan Stern…
Quoted 4 lines · Rafael J. Wysocki

OK, so I think there are two things that user space may be allowed to do as far as putting devices into low power states is concerned:
* disable/enable the automatic power management of the device (provided that the driver supports the automatic PM)

Set the automatic PM parameters (idle timeout, state to go to, etc.). And disabling automatic PM altogether (effectively the same as setting the idle timeout to infinity).

shouldn't idle timeout etc be internal to the driver?
Yes policy preferences / constraints makes sense to communicate, actual settings do not. For one they keep changing fast all the time anyway.

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#310 lore raw
In reply to Alan Stern
Quoted 11 lines · On Mon, 16 Feb 2009 17:40:10 -0500 (EST) Alan Stern…
Quoted 4 lines · Rafael J. Wysocki

OK, so I think there are two things that user space may be allowed to do as far as putting devices into low power states is concerned:
* disable/enable the automatic power management of the device (provided that the driver supports the automatic PM)

Set the automatic PM parameters (idle timeout, state to go to, etc.). And disabling automatic PM altogether (effectively the same as setting the idle timeout to infinity).

shouldn't idle timeout etc be internal to the driver?
Yes policy preferences / constraints makes sense to communicate, actual settings do not. For one they keep changing fast all the time anyway.

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#311 lore raw
Quoted 15 lines · Arjan van de Ven
Quoted 11 lines · On Mon, 16 Feb 2009 17:40:10 -0500 (EST) Alan Stern…
Quoted 4 lines · Rafael J. Wysocki

OK, so I think there are two things that user space may be allowed to do as far as putting devices into low power states is concerned:
* disable/enable the automatic power management of the device (provided that the driver supports the automatic PM)

Set the automatic PM parameters (idle timeout, state to go to, etc.). And disabling automatic PM altogether (effectively the same as setting the idle timeout to infinity).

Quoted 4 lines

shouldn't idle timeout etc be internal to the driver?
Yes policy preferences / constraints makes sense to communicate, actual settings do not. For one they keep changing fast all the time anyway.

Usually different devices are handled by the same driver. I don't really think the same value will be suitable for all of them, so the users should at least be able to override the driver default, IMO.

Thanks,
Rafael

#312 lore raw
In reply to Arjan van de Ven
Quoted 15 lines · Arjan van de Ven
Quoted 11 lines · On Mon, 16 Feb 2009 17:40:10 -0500 (EST) Alan Stern…
Quoted 4 lines · Rafael J. Wysocki

OK, so I think there are two things that user space may be allowed to do as far as putting devices into low power states is concerned:
* disable/enable the automatic power management of the device (provided that the driver supports the automatic PM)

Set the automatic PM parameters (idle timeout, state to go to, etc.). And disabling automatic PM altogether (effectively the same as setting the idle timeout to infinity).

Quoted 4 lines

shouldn't idle timeout etc be internal to the driver?
Yes policy preferences / constraints makes sense to communicate, actual settings do not. For one they keep changing fast all the time anyway.

Usually different devices are handled by the same driver. I don't really think the same value will be suitable for all of them, so the users should at least be able to override the driver default, IMO.

Thanks,
Rafael

#313 lore raw
In reply to Arjan van de Ven
Quoted 9 lines · Arjan van de Ven
Quoted 4 lines

Set the automatic PM parameters (idle timeout, state to go to, etc.). And disabling automatic PM altogether (effectively the same as setting the idle timeout to infinity).

shouldn't idle timeout etc be internal to the driver?
Yes policy preferences / constraints makes sense to communicate, actual settings do not. For one they keep changing fast all the time anyway.

Sorry, I don't agree. A single driver may control many different kinds of device -- it may not even be aware of the distinction! Consider the SCSI disk driver: It has to handle both traditional rotating media and solid-state disks. Clearly they should have different runtime PM parameters. But the driver isn't in a good position to know what those parameters should be.

Alan Stern

#314 lore raw
Quoted 12 lines · On Mon, 16 Feb 2009 21:43:52 -0500 (EST) Alan Stern…
Quoted 9 lines · Arjan van de Ven
Quoted 4 lines

Set the automatic PM parameters (idle timeout, state to go to, etc.). And disabling automatic PM altogether (effectively the same as setting the idle timeout to infinity).

shouldn't idle timeout etc be internal to the driver?
Yes policy preferences / constraints makes sense to communicate, actual settings do not. For one they keep changing fast all the time anyway.

Quoted 6 lines

Sorry, I don't agree. A single driver may control many different kinds of device -- it may not even be aware of the distinction! Consider the SCSI disk driver: It has to handle both traditional rotating media and solid-state disks. Clearly they should have different runtime PM parameters. But the driver isn't in a good position to know what those parameters should be.

... and userspace is ?
Sorry I don't buy that. Kernel is supposed to abstract the hardware... That's its fundamental task. Now if the driver doesn't know it can get help from the subsystem, that's perfectly fine.

(and quiet often the kernel gets updated more often as the userspace)

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#315 lore raw
In reply to Alan Stern
Quoted 12 lines · On Mon, 16 Feb 2009 21:43:52 -0500 (EST) Alan Stern…
Quoted 9 lines · Arjan van de Ven
Quoted 4 lines

Set the automatic PM parameters (idle timeout, state to go to, etc.). And disabling automatic PM altogether (effectively the same as setting the idle timeout to infinity).

shouldn't idle timeout etc be internal to the driver?
Yes policy preferences / constraints makes sense to communicate, actual settings do not. For one they keep changing fast all the time anyway.

Quoted 6 lines

Sorry, I don't agree. A single driver may control many different kinds of device -- it may not even be aware of the distinction! Consider the SCSI disk driver: It has to handle both traditional rotating media and solid-state disks. Clearly they should have different runtime PM parameters. But the driver isn't in a good position to know what those parameters should be.

... and userspace is ?
Sorry I don't buy that. Kernel is supposed to abstract the hardware... That's its fundamental task. Now if the driver doesn't know it can get help from the subsystem, that's perfectly fine.

(and quiet often the kernel gets updated more often as the userspace)

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#316 lore raw
Quoted 5 lines · Arjan van de Ven
Quoted 5 lines
Quoted 4 lines

shouldn't idle timeout etc be internal to the driver?
Yes policy preferences / constraints makes sense to communicate, actual settings do not. For one they keep changing fast all the time anyway.

Quoted 8 lines
Quoted 6 lines

Sorry, I don't agree. A single driver may control many different kinds of device -- it may not even be aware of the distinction! Consider the SCSI disk driver: It has to handle both traditional rotating media and solid-state disks. Clearly they should have different runtime PM parameters. But the driver isn't in a good position to know what those parameters should be.

... and userspace is ?

Certainly it is. Programs like hal can maintain databases of device IDs and appropriate timeout values, and allow the user to change the values as needed. Such databases don't belong in the kernel.

Furthermore, the user may have a better idea of the kind of workload he wants to impose and his latency requirements than the kernel does.

Quoted 3 lines

Sorry I don't buy that. Kernel is supposed to abstract the hardware... That's its fundamental task. Now if the driver doesn't know it can get help from the subsystem, that's perfectly fine.

There are various levels of abstraction. If the kernel really abstracted _everything_ then we wouldn't need ioctl. :-)

Quoted 1 line

(and quiet often the kernel gets updated more often as the userspace)

(That's hardly a valid argument for putting something into the kernel when it belongs in userspace.)

Alan Stern

#317 lore raw
In reply to Arjan van de Ven
Quoted 5 lines · Arjan van de Ven
Quoted 5 lines
Quoted 4 lines

shouldn't idle timeout etc be internal to the driver?
Yes policy preferences / constraints makes sense to communicate, actual settings do not. For one they keep changing fast all the time anyway.

Quoted 8 lines
Quoted 6 lines

Sorry, I don't agree. A single driver may control many different kinds of device -- it may not even be aware of the distinction! Consider the SCSI disk driver: It has to handle both traditional rotating media and solid-state disks. Clearly they should have different runtime PM parameters. But the driver isn't in a good position to know what those parameters should be.

... and userspace is ?

Certainly it is. Programs like hal can maintain databases of device IDs and appropriate timeout values, and allow the user to change the values as needed. Such databases don't belong in the kernel.

Furthermore, the user may have a better idea of the kind of workload he wants to impose and his latency requirements than the kernel does.

Quoted 3 lines

Sorry I don't buy that. Kernel is supposed to abstract the hardware... That's its fundamental task. Now if the driver doesn't know it can get help from the subsystem, that's perfectly fine.

There are various levels of abstraction. If the kernel really abstracted _everything_ then we wouldn't need ioctl. :-)

Quoted 1 line

(and quiet often the kernel gets updated more often as the userspace)

(That's hardly a valid argument for putting something into the kernel when it belongs in userspace.)

Alan Stern

#318 lore raw
In reply to Alan Stern
Quoted 8 lines · Alan Stern
Quoted 4 lines · Rafael J. Wysocki

OK, so I think there are two things that user space may be allowed to do as far as putting devices into low power states is concerned:
* disable/enable the automatic power management of the device (provided that the driver supports the automatic PM)

Set the automatic PM parameters (idle timeout, state to go to, etc.).

Yes. I'm not sure about the state part, though.

Quoted 2 lines

And disabling automatic PM altogether (effectively the same as setting the idle timeout to infinity).

Yes.

Quoted 7 lines
Quoted 1 line

* check what power states devices are in.

What about situations where we want to distinguish between the power state of the device itself and the power state of the link? For a disk drive we may want to power the link on and off quite a lot, as that has low latency, but spinning the disk up and down takes a long time and so should have a longer idle-time value.

Well, I'm not sure at the moment.

Do you have any suggestions?

Rafael

#319 lore raw
In reply to Alan Stern
Quoted 8 lines · Alan Stern
Quoted 4 lines · Rafael J. Wysocki

OK, so I think there are two things that user space may be allowed to do as far as putting devices into low power states is concerned:
* disable/enable the automatic power management of the device (provided that the driver supports the automatic PM)

Set the automatic PM parameters (idle timeout, state to go to, etc.).

Yes. I'm not sure about the state part, though.

Quoted 2 lines

And disabling automatic PM altogether (effectively the same as setting the idle timeout to infinity).

Yes.

Quoted 7 lines
Quoted 1 line

* check what power states devices are in.

What about situations where we want to distinguish between the power state of the device itself and the power state of the link? For a disk drive we may want to power the link on and off quite a lot, as that has low latency, but spinning the disk up and down takes a long time and so should have a longer idle-time value.

Well, I'm not sure at the moment.

Do you have any suggestions?

Rafael

#320 lore raw
Quoted 11 lines · Rafael J. Wysocki
Quoted 8 lines · Alan Stern
Quoted 4 lines · Rafael J. Wysocki

OK, so I think there are two things that user space may be allowed to do as far as putting devices into low power states is concerned:
* disable/enable the automatic power management of the device (provided that the driver supports the automatic PM)

Set the automatic PM parameters (idle timeout, state to go to, etc.).

Yes. I'm not sure about the state part, though.

Maybe, maybe not. IMO it's too early to tell whether anyone will need this ability, so we shouldn't rule it out.

Quoted 9 lines
Quoted 5 lines

What about situations where we want to distinguish between the power state of the device itself and the power state of the link? For a disk drive we may want to power the link on and off quite a lot, as that has low latency, but spinning the disk up and down takes a long time and so should have a longer idle-time value.

Well, I'm not sure at the moment.

Do you have any suggestions?

Not very well fleshed-out ones. I've got a vague idea for allowing a disk to have a 3-level power arrangement: full power, link disabled but drive still spinning, and device suspended. Arranging for automatic transitions among those states will be a little clumsy but it can be done. As an example of the clumsiness, this scheme requires that the drive has _two_ idle-timeout values, one for the link and one for the drive itself.

Another possibility is to set up independent runtime PM for the transport and the device. This means allowing the possibility that the transport is suspended while its child (the device) is not. This is a little simpler (there's only one idle-timeout per device, since the link is treated as an independent device), but it violates the principle of never suspending a parent while there is an active child.

Alan Stern

#321 lore raw
In reply to Rafael J. Wysocki
Quoted 11 lines · Rafael J. Wysocki
Quoted 8 lines · Alan Stern
Quoted 4 lines · Rafael J. Wysocki

OK, so I think there are two things that user space may be allowed to do as far as putting devices into low power states is concerned:
* disable/enable the automatic power management of the device (provided that the driver supports the automatic PM)

Set the automatic PM parameters (idle timeout, state to go to, etc.).

Yes. I'm not sure about the state part, though.

Maybe, maybe not. IMO it's too early to tell whether anyone will need this ability, so we shouldn't rule it out.

Quoted 9 lines
Quoted 5 lines

What about situations where we want to distinguish between the power state of the device itself and the power state of the link? For a disk drive we may want to power the link on and off quite a lot, as that has low latency, but spinning the disk up and down takes a long time and so should have a longer idle-time value.

Well, I'm not sure at the moment.

Do you have any suggestions?

Not very well fleshed-out ones. I've got a vague idea for allowing a disk to have a 3-level power arrangement: full power, link disabled but drive still spinning, and device suspended. Arranging for automatic transitions among those states will be a little clumsy but it can be done. As an example of the clumsiness, this scheme requires that the drive has _two_ idle-timeout values, one for the link and one for the drive itself.

Another possibility is to set up independent runtime PM for the transport and the device. This means allowing the possibility that the transport is suspended while its child (the device) is not. This is a little simpler (there's only one idle-timeout per device, since the link is treated as an independent device), but it violates the principle of never suspending a parent while there is an active child.

Alan Stern

#322 lore raw
Quoted 23 lines · Alan Stern
Quoted 11 lines · Rafael J. Wysocki
Quoted 8 lines · Alan Stern
Quoted 4 lines · Rafael J. Wysocki

OK, so I think there are two things that user space may be allowed to do as far as putting devices into low power states is concerned:
* disable/enable the automatic power management of the device (provided that the driver supports the automatic PM)

Set the automatic PM parameters (idle timeout, state to go to, etc.).

Yes. I'm not sure about the state part, though.

Maybe, maybe not. IMO it's too early to tell whether anyone will need this ability, so we shouldn't rule it out.

Quoted 6 lines
Quoted 5 lines

What about situations where we want to distinguish between the power state of the device itself and the power state of the link? For a disk drive we may want to power the link on and off quite a lot, as that has low latency, but spinning the disk up and down takes a long time and so should have a longer idle-time value.

Quoted 7 lines
Quoted 3 lines

Well, I'm not sure at the moment.

Do you have any suggestions?

Not very well fleshed-out ones. I've got a vague idea for allowing a disk to have a 3-level power arrangement: full power, link disabled but drive still spinning, and device suspended.

I was thinking about that too.

Quoted 4 lines

Arranging for automatic transitions among those states will be a little clumsy but it can be done. As an example of the clumsiness, this scheme requires that the drive has _two_ idle-timeout values, one for the link and one for the drive itself.

Well, this generally is the case for PCI devices supporting more than two power states.

Quoted 6 lines

Another possibility is to set up independent runtime PM for the transport and the device. This means allowing the possibility that the transport is suspended while its child (the device) is not. This is a little simpler (there's only one idle-timeout per device, since the link is treated as an independent device), but it violates the principle of never suspending a parent while there is an active child.

Well, I think the first approach would be better.

Thanks,
Rafael

#323 lore raw
In reply to Alan Stern
Quoted 23 lines · Alan Stern
Quoted 11 lines · Rafael J. Wysocki
Quoted 8 lines · Alan Stern
Quoted 4 lines · Rafael J. Wysocki

OK, so I think there are two things that user space may be allowed to do as far as putting devices into low power states is concerned:
* disable/enable the automatic power management of the device (provided that the driver supports the automatic PM)

Set the automatic PM parameters (idle timeout, state to go to, etc.).

Yes. I'm not sure about the state part, though.

Maybe, maybe not. IMO it's too early to tell whether anyone will need this ability, so we shouldn't rule it out.

Quoted 6 lines
Quoted 5 lines

What about situations where we want to distinguish between the power state of the device itself and the power state of the link? For a disk drive we may want to power the link on and off quite a lot, as that has low latency, but spinning the disk up and down takes a long time and so should have a longer idle-time value.

Quoted 7 lines
Quoted 3 lines

Well, I'm not sure at the moment.

Do you have any suggestions?

Not very well fleshed-out ones. I've got a vague idea for allowing a disk to have a 3-level power arrangement: full power, link disabled but drive still spinning, and device suspended.

I was thinking about that too.

Quoted 4 lines

Arranging for automatic transitions among those states will be a little clumsy but it can be done. As an example of the clumsiness, this scheme requires that the drive has _two_ idle-timeout values, one for the link and one for the drive itself.

Well, this generally is the case for PCI devices supporting more than two power states.

Quoted 6 lines

Another possibility is to set up independent runtime PM for the transport and the device. This means allowing the possibility that the transport is suspended while its child (the device) is not. This is a little simpler (there's only one idle-timeout per device, since the link is treated as an independent device), but it violates the principle of never suspending a parent while there is an active child.

Well, I think the first approach would be better.

Thanks,
Rafael

#324 lore raw

Am Wednesday 18 February 2009 00:26:53 schrieb Rafael J. Wysocki:

Quoted 8 lines
Quoted 6 lines

Another possibility is to set up independent runtime PM for the transport and the device.  This means allowing the possibility that the transport is suspended while its child (the device) is not.  This is a little simpler (there's only one idle-timeout per device, since the link is treated as an independent device), but it violates the principle of never suspending a parent while there is an active child.

Well, I think the first approach would be better.

I am afraid it wouldn't be. How do you deal with shared transports?

Regards
Oliver

#325 lore raw
Quoted 9 lines · On Wed, 18 Feb 2009 09:53:48 +0100 Oliver Neukum <[email protected]> wrote:

Am Wednesday 18 February 2009 00:26:53 schrieb Rafael J. Wysocki:

Quoted 8 lines
Quoted 7 lines

Another possibility is to set up independent runtime PM for the transport and the device.  This means allowing the possibility that the transport is suspended while its child (the device) is not.  This is a little simpler (there's only one idle-timeout per device, since the link is treated as an independent device), but it violates the principle of never suspending a parent while there is an active child.

Quoted 4 lines
Quoted 1 line

Well, I think the first approach would be better.

I am afraid it wouldn't be. How do you deal with shared transports?

realistically, something like this you need to design like this Step 1) Assume the hardware is smart and can do this for you on the fly,
but it might need guidance.
(For many busses there are platforms that do this)
Step 2) For hardware that is not smart, emulate the smartness in the
driver, with help of the subsystem. These two together have the right knowledge to make such decisions.

Signature · 7 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#326 lore raw
In reply to Oliver Neukum
Quoted 9 lines · On Wed, 18 Feb 2009 09:53:48 +0100 Oliver Neukum <[email protected]> wrote:

Am Wednesday 18 February 2009 00:26:53 schrieb Rafael J. Wysocki:

Quoted 8 lines
Quoted 7 lines

Another possibility is to set up independent runtime PM for the transport and the device.  This means allowing the possibility that the transport is suspended while its child (the device) is not.  This is a little simpler (there's only one idle-timeout per device, since the link is treated as an independent device), but it violates the principle of never suspending a parent while there is an active child.

Quoted 4 lines
Quoted 1 line

Well, I think the first approach would be better.

I am afraid it wouldn't be. How do you deal with shared transports?

realistically, something like this you need to design like this Step 1) Assume the hardware is smart and can do this for you on the fly,
but it might need guidance.
(For many busses there are platforms that do this)
Step 2) For hardware that is not smart, emulate the smartness in the
driver, with help of the subsystem. These two together have the right knowledge to make such decisions.

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#327 lore raw

Am Wednesday 18 February 2009 15:51:58 schrieb Arjan van de Ven:

Quoted 17 lines
Quoted 9 lines · On Wed, 18 Feb 2009 09:53:48 +0100 Oliver Neukum <[email protected]> wrote:

Am Wednesday 18 February 2009 00:26:53 schrieb Rafael J. Wysocki:

Quoted 8 lines
Quoted 7 lines

Another possibility is to set up independent runtime PM for the transport and the device.  This means allowing the possibility that the transport is suspended while its child (the device) is not.  This is a little simpler (there's only one idle-timeout per device, since the link is treated as an independent device), but it violates the principle of never suspending a parent while there is an active child.

Quoted 4 lines
Quoted 1 line

Well, I think the first approach would be better.

I am afraid it wouldn't be. How do you deal with shared transports?

Quoted 7 lines

realistically, something like this you need to design like this Step 1) Assume the hardware is smart and can do this for you on the fly,
but it might need guidance.
(For many busses there are platforms that do this)
Step 2) For hardware that is not smart, emulate the smartness in the
driver, with help of the subsystem. These two together have the right knowledge to make such decisions.

But the transport and the driver may be in different subsystems, e.g. usb storage.

Regards
Oliver

#328 lore raw
Quoted 2 lines · Oliver Neukum

But the transport and the driver may be in different subsystems, e.g. usb storage.

We would have to add a part of usb-storage into the SCSI subsystem, by creating a USB transport class. Perhaps this class could be shared with Firewire/IEEE1394.

Alan Stern

#329 lore raw
In reply to Oliver Neukum
Quoted 2 lines · Oliver Neukum

But the transport and the driver may be in different subsystems, e.g. usb storage.

We would have to add a part of usb-storage into the SCSI subsystem, by creating a USB transport class. Perhaps this class could be shared with Firewire/IEEE1394.

Alan Stern

#330 lore raw

Am Wednesday 18 February 2009 16:10:48 schrieb Alan Stern:

Quoted 8 lines · Oliver Neukum
Quoted 3 lines

But the transport and the driver may be in different subsystems, e.g. usb storage.

We would have to add a part of usb-storage into the SCSI subsystem, by creating a USB transport class. Perhaps this class could be shared with Firewire/IEEE1394.

That would be a specific solution. But the problem is generic. Take for example HID. Several drivers may share one transport, but the transport may be USB 2.0/3.0 or bluetooth.

Regards
Oliver

#331 lore raw
Quoted 6 lines · Oliver Neukum

Am Wednesday 18 February 2009 16:10:48 schrieb Alan Stern:

Quoted 5 lines · Oliver Neukum
Quoted 3 lines

But the transport and the driver may be in different subsystems, e.g. usb storage.

Quoted 7 lines
Quoted 3 lines

We would have to add a part of usb-storage into the SCSI subsystem, by creating a USB transport class. Perhaps this class could be shared with Firewire/IEEE1394.

That would be a specific solution. But the problem is generic. Take for example HID. Several drivers may share one transport, but the transport may be USB 2.0/3.0 or bluetooth.

In essence what you're saying is that we won't be able to do link-suspend for HID until something like HID transport classes (or something simpler, devoted specifically to runtime PM) is implemented. And likewise for other subsystems. I can't argue with this conclusion.

Alan Stern

#332 lore raw
In reply to Oliver Neukum
Quoted 6 lines · Oliver Neukum

Am Wednesday 18 February 2009 16:10:48 schrieb Alan Stern:

Quoted 5 lines · Oliver Neukum
Quoted 3 lines

But the transport and the driver may be in different subsystems, e.g. usb storage.

Quoted 7 lines
Quoted 3 lines

We would have to add a part of usb-storage into the SCSI subsystem, by creating a USB transport class. Perhaps this class could be shared with Firewire/IEEE1394.

That would be a specific solution. But the problem is generic. Take for example HID. Several drivers may share one transport, but the transport may be USB 2.0/3.0 or bluetooth.

In essence what you're saying is that we won't be able to do link-suspend for HID until something like HID transport classes (or something simpler, devoted specifically to runtime PM) is implemented. And likewise for other subsystems. I can't argue with this conclusion.

Alan Stern

#333 lore raw

Am Wednesday 18 February 2009 17:39:21 schrieb Alan Stern:

Quoted 4 lines

In essence what you're saying is that we won't be able to do link-suspend for HID until something like HID transport classes (or something simpler, devoted specifically to runtime PM) is implemented. And likewise for other subsystems.  I can't argue with this conclusion.

I'd say, if it has sensible operations, it is a device and should be in the tree as such.

Regards
Oliver

#334 lore raw
In reply to Alan Stern

Am Wednesday 18 February 2009 17:39:21 schrieb Alan Stern:

Quoted 4 lines

In essence what you're saying is that we won't be able to do link-suspend for HID until something like HID transport classes (or something simpler, devoted specifically to runtime PM) is implemented. And likewise for other subsystems.  I can't argue with this conclusion.

I'd say, if it has sensible operations, it is a device and should be in the tree as such.

Regards
Oliver

#335 lore raw
In reply to Arjan van de Ven

Am Wednesday 18 February 2009 15:51:58 schrieb Arjan van de Ven:

Quoted 17 lines
Quoted 9 lines · On Wed, 18 Feb 2009 09:53:48 +0100 Oliver Neukum <[email protected]> wrote:

Am Wednesday 18 February 2009 00:26:53 schrieb Rafael J. Wysocki:

Quoted 8 lines
Quoted 7 lines

Another possibility is to set up independent runtime PM for the transport and the device.  This means allowing the possibility that the transport is suspended while its child (the device) is not.  This is a little simpler (there's only one idle-timeout per device, since the link is treated as an independent device), but it violates the principle of never suspending a parent while there is an active child.

Quoted 4 lines
Quoted 1 line

Well, I think the first approach would be better.

I am afraid it wouldn't be. How do you deal with shared transports?

Quoted 7 lines

realistically, something like this you need to design like this Step 1) Assume the hardware is smart and can do this for you on the fly,
but it might need guidance.
(For many busses there are platforms that do this)
Step 2) For hardware that is not smart, emulate the smartness in the
driver, with help of the subsystem. These two together have the right knowledge to make such decisions.

But the transport and the driver may be in different subsystems, e.g. usb storage.

Regards
Oliver

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

#336 lore raw
In reply to Arjan van de Ven
Quoted 17 lines · Arjan van de Ven
Quoted 9 lines · On Wed, 18 Feb 2009 09:53:48 +0100 Oliver Neukum <[email protected]> wrote:

Am Wednesday 18 February 2009 00:26:53 schrieb Rafael J. Wysocki:

Quoted 8 lines
Quoted 7 lines

Another possibility is to set up independent runtime PM for the transport and the device.  This means allowing the possibility that the transport is suspended while its child (the device) is not.  This is a little simpler (there's only one idle-timeout per device, since the link is treated as an independent device), but it violates the principle of never suspending a parent while there is an active child.

Quoted 4 lines
Quoted 1 line

Well, I think the first approach would be better.

I am afraid it wouldn't be. How do you deal with shared transports?

Quoted 7 lines

realistically, something like this you need to design like this Step 1) Assume the hardware is smart and can do this for you on the fly,
but it might need guidance.
(For many busses there are platforms that do this)
Step 2) For hardware that is not smart, emulate the smartness in the
driver, with help of the subsystem. These two together have the right knowledge to make such decisions.

Arjan, you're missing the point. This part of the discussion is already focussed on your Step 2. The question we are concerned with
is: _How_ shall the driver and subsystem go about emulating the smartness?

Oliver's comment is a good one. The principle of not suspending a parent with active children has never been set in stone; with care we should be able to circumvent it.

Alan Stern

#337 lore raw
In reply to Arjan van de Ven
Quoted 17 lines · Arjan van de Ven
Quoted 9 lines · On Wed, 18 Feb 2009 09:53:48 +0100 Oliver Neukum <[email protected]> wrote:

Am Wednesday 18 February 2009 00:26:53 schrieb Rafael J. Wysocki:

Quoted 8 lines
Quoted 7 lines

Another possibility is to set up independent runtime PM for the transport and the device.  This means allowing the possibility that the transport is suspended while its child (the device) is not.  This is a little simpler (there's only one idle-timeout per device, since the link is treated as an independent device), but it violates the principle of never suspending a parent while there is an active child.

Quoted 4 lines
Quoted 1 line

Well, I think the first approach would be better.

I am afraid it wouldn't be. How do you deal with shared transports?

Quoted 7 lines

realistically, something like this you need to design like this Step 1) Assume the hardware is smart and can do this for you on the fly,
but it might need guidance.
(For many busses there are platforms that do this)
Step 2) For hardware that is not smart, emulate the smartness in the
driver, with help of the subsystem. These two together have the right knowledge to make such decisions.

Arjan, you're missing the point. This part of the discussion is already focussed on your Step 2. The question we are concerned with
is: _How_ shall the driver and subsystem go about emulating the smartness?

Oliver's comment is a good one. The principle of not suspending a parent with active children has never been set in stone; with care we should be able to circumvent it.

Alan Stern

#338 lore raw
In reply to Rafael J. Wysocki

Am Wednesday 18 February 2009 00:26:53 schrieb Rafael J. Wysocki:

Quoted 8 lines
Quoted 6 lines

Another possibility is to set up independent runtime PM for the transport and the device.  This means allowing the possibility that the transport is suspended while its child (the device) is not.  This is a little simpler (there's only one idle-timeout per device, since the link is treated as an independent device), but it violates the principle of never suspending a parent while there is an active child.

Well, I think the first approach would be better.

I am afraid it wouldn't be. How do you deal with shared transports?

Regards
Oliver

#339 lore raw
In reply to Rafael J. Wysocki

Hi!

Quoted 7 lines
Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

I don't think we should do this... of you want device to be powered down, just don't keep it open. revoke should be enough :-).

...one execption here is the disk driver; unmounting filesystems to let the disk spin down is probably too heavy.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#340 lore raw
In reply to Rafael J. Wysocki

Hi!

Quoted 7 lines
Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

I don't think we should do this... of you want device to be powered down, just don't keep it open. revoke should be enough :-).

...one execption here is the disk driver; unmounting filesystems to let the disk spin down is probably too heavy.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#341 lore raw
Quoted 11 lines · On Mon, 16 Feb 2009 23:51:16 +0100 Pavel Machek <[email protected]> wrote:

Hi!

Quoted 8 lines
Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

Quoted 5 lines

I don't think we should do this... of you want device to be powered down, just don't keep it open. revoke should be enough :-).

...one execption here is the disk driver; unmounting filesystems to let the disk spin down is probably too heavy.

but spin down happens on non-activity ;)
it's more a slumber than a power down

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#342 lore raw
In reply to Pavel Machek
Quoted 11 lines · On Mon, 16 Feb 2009 23:51:16 +0100 Pavel Machek <[email protected]> wrote:

Hi!

Quoted 8 lines
Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

Quoted 5 lines

I don't think we should do this... of you want device to be powered down, just don't keep it open. revoke should be enough :-).

...one execption here is the disk driver; unmounting filesystems to let the disk spin down is probably too heavy.

but spin down happens on non-activity ;)
it's more a slumber than a power down

Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#343 lore raw
In reply to Pavel Machek
Quoted 10 lines · Pavel Machek

Hi!

Quoted 7 lines
Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

Quoted 5 lines

I don't think we should do this... of you want device to be powered down, just don't keep it open. revoke should be enough :-).

...one execption here is the disk driver; unmounting filesystems to let the disk spin down is probably too heavy.

Well, I don't think it's viable to make any exceptions here. Either we do it or we don't. And the agreement appears to be that we don't.

Thanks,
Rafael

#344 lore raw
In reply to Pavel Machek
Quoted 10 lines · Pavel Machek

Hi!

Quoted 7 lines
Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

Quoted 5 lines

I don't think we should do this... of you want device to be powered down, just don't keep it open. revoke should be enough :-).

...one execption here is the disk driver; unmounting filesystems to let the disk spin down is probably too heavy.

Well, I don't think it's viable to make any exceptions here. Either we do it or we don't. And the agreement appears to be that we don't.

Thanks,
Rafael

#345 lore raw
Quoted 11 lines · Rafael J. Wysocki
Quoted 10 lines · Pavel Machek

Hi!

Quoted 7 lines
Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

Quoted 8 lines
Quoted 5 lines

I don't think we should do this... of you want device to be powered down, just don't keep it open. revoke should be enough :-).

...one execption here is the disk driver; unmounting filesystems to let the disk spin down is probably too heavy.

Well, I don't think it's viable to make any exceptions here. Either we do it or we don't. And the agreement appears to be that we don't.

We already have interface to force disk down (for disk protectioon stuff), so this is already done for other reasons.

But in general, close(joystick) is nicer interface then 'echo turn-off-joystick-even-when-open > /sys/somewhere'.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#346 lore raw
In reply to Rafael J. Wysocki
Quoted 11 lines · Rafael J. Wysocki
Quoted 10 lines · Pavel Machek

Hi!

Quoted 7 lines
Quoted 3 lines

Userland should never ever control the state of a device like this directly. It should do so by a) closing the device and b) setting latency / functional requirements.

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

Quoted 8 lines
Quoted 5 lines

I don't think we should do this... of you want device to be powered down, just don't keep it open. revoke should be enough :-).

...one execption here is the disk driver; unmounting filesystems to let the disk spin down is probably too heavy.

Well, I don't think it's viable to make any exceptions here. Either we do it or we don't. And the agreement appears to be that we don't.

We already have interface to force disk down (for disk protectioon stuff), so this is already done for other reasons.

But in general, close(joystick) is nicer interface then 'echo turn-off-joystick-even-when-open > /sys/somewhere'.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#347 lore raw
In reply to Pavel Machek

Am Monday 16 February 2009 23:51:16 schrieb Pavel Machek:

Quoted 6 lines
Quoted 3 lines

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

I don't think we should do this... of you want device to be powered down, just don't keep it open. revoke should be enough :-).

Keeping a device open also guarantees identity. Secondly you may not have opened a device yourself and indeed be unable to do so.

Regards
Oliver

#348 lore raw
In reply to Pavel Machek

Am Monday 16 February 2009 23:51:16 schrieb Pavel Machek:

Quoted 6 lines
Quoted 3 lines

The user, however, may want to forcibly put a device into a low power state without stopping all of the applications that depend on it (eg. have it open). Do you think that we shouldn't allow users to do such things?

I don't think we should do this... of you want device to be powered down, just don't keep it open. revoke should be enough :-).

Keeping a device open also guarantees identity. Secondly you may not have opened a device yourself and indeed be unable to do so.

Regards
Oliver

#349 lore raw
In reply to Rafael J. Wysocki

Hi!

Quoted 5 lines

The recent descussion about the Android PM patches sent by Arve shows that there is a need to introduce a mechanism allowing us to:
(1) automatically put the system as a whole into a sleep state (eg. suspend to RAM) when it is found to be "idle", where the meaning of "idle" has to be defined too,

Well; I'd prefer to keep the interface very minimal.

If no devices are being used, and next wakeup is far enough in the future, just put system to sleep. Long enough == so far away that suspend/wakeup is short compared to that... like 20 seconds on PC.

Ok, it probably needs to be opt-in: echo auto-mem > /sys/power/state should do the trick.

This will need either fixing all the applications not to poll, or maybe someone SIGSTOP-ing apps that are in background and poll too often.

Quoted 2 lines

(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

Arjan said this nicely...

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#350 lore raw
In reply to Rafael J. Wysocki

Hi!

Quoted 5 lines

The recent descussion about the Android PM patches sent by Arve shows that there is a need to introduce a mechanism allowing us to:
(1) automatically put the system as a whole into a sleep state (eg. suspend to RAM) when it is found to be "idle", where the meaning of "idle" has to be defined too,

Well; I'd prefer to keep the interface very minimal.

If no devices are being used, and next wakeup is far enough in the future, just put system to sleep. Long enough == so far away that suspend/wakeup is short compared to that... like 20 seconds on PC.

Ok, it probably needs to be opt-in: echo auto-mem > /sys/power/state should do the trick.

This will need either fixing all the applications not to poll, or maybe someone SIGSTOP-ing apps that are in background and poll too often.

Quoted 2 lines

(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

Arjan said this nicely...

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#351 lore raw
Quoted 3 lines · Pavel Machek

If no devices are being used, and next wakeup is far enough in the future, just put system to sleep. Long enough == so far away that suspend/wakeup is short compared to that... like 20 seconds on PC.

This is intrinsically difficult with PCs, since we have such a poorly defined set of wakeup events. We can't wakeup on generic network traffic, just WoL. Many machines won't wake up on keyboard events. Meanwhile, on embedded it's becoming a less interesting problem because idle and suspended are often now equivalent states. Concentrating on runtime PM of as much hardware as possible is arguably more interesting for the majority of use cases.

Signature · 1 line
Matthew Garrett | [email protected]
#352 lore raw
In reply to Pavel Machek
Quoted 3 lines · Pavel Machek

If no devices are being used, and next wakeup is far enough in the future, just put system to sleep. Long enough == so far away that suspend/wakeup is short compared to that... like 20 seconds on PC.

This is intrinsically difficult with PCs, since we have such a poorly defined set of wakeup events. We can't wakeup on generic network traffic, just WoL. Many machines won't wake up on keyboard events. Meanwhile, on embedded it's becoming a less interesting problem because idle and suspended are often now equivalent states. Concentrating on runtime PM of as much hardware as possible is arguably more interesting for the majority of use cases.

Signature · 1 line
Matthew Garrett | [email protected]
#353 lore raw
Quoted 9 lines · Matthew Garrett
Quoted 3 lines · Pavel Machek

If no devices are being used, and next wakeup is far enough in the future, just put system to sleep. Long enough == so far away that suspend/wakeup is short compared to that... like 20 seconds on PC.

This is intrinsically difficult with PCs, since we have such a poorly defined set of wakeup events. We can't wakeup on generic network traffic, just WoL.

At least e1000 in thinkpad can wakeup on generic network traffic. If particular network card can't, you just can't sleep when network is up.

Quoted 1 line

Many machines won't wake up on keyboard events.

Too bad. You'll have to close the lid for autosuspend to work on such hw. (Or maybe you can do some hack telling the kernel to suspend anyway if just keyboard prevents it.)

Quoted 2 lines

Meanwhile, on embedded it's becoming a less interesting problem because idle and suspended are often now equivalent states.

Android people tell us otherwise.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#354 lore raw
In reply to Matthew Garrett
Quoted 9 lines · Matthew Garrett
Quoted 3 lines · Pavel Machek

If no devices are being used, and next wakeup is far enough in the future, just put system to sleep. Long enough == so far away that suspend/wakeup is short compared to that... like 20 seconds on PC.

This is intrinsically difficult with PCs, since we have such a poorly defined set of wakeup events. We can't wakeup on generic network traffic, just WoL.

At least e1000 in thinkpad can wakeup on generic network traffic. If particular network card can't, you just can't sleep when network is up.

Quoted 1 line

Many machines won't wake up on keyboard events.

Too bad. You'll have to close the lid for autosuspend to work on such hw. (Or maybe you can do some hack telling the kernel to suspend anyway if just keyboard prevents it.)

Quoted 2 lines

Meanwhile, on embedded it's becoming a less interesting problem because idle and suspended are often now equivalent states.

Android people tell us otherwise.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#356 lore raw

[Matthew Garrett <[email protected]>]

Quoted 9 lines · Pavel Machek
Quoted 5 lines · Matthew Garrett
Quoted 2 lines

Meanwhile, on embedded it's becoming a less interesting problem because idle and suspended are often now equivalent states.

Android people tell us otherwise.

https://lists.linux-foundation.org/pipermail/linux-pm/2009-January/019493.html
says that they're the same on their current platform.

Well on the Qualcomm MSM72xx SoCs, yeah they're pretty similar -- we can reasonably enter power collapse (full shutdown of the ARM11 and peripherals) from idle. But this is not (to my knowledge) true of *all* SoCs out there. Also, resuming from this state can take 5-30ms (depending on how distracted the baseband processor is by what's going on on the network).

Brian

#357 lore raw
Quoted 10 lines · Brian Swetland

[Matthew Garrett <[email protected]>]

Quoted 2 lines

https://lists.linux-foundation.org/pipermail/linux-pm/2009-January/019493.html
says that they're the same on their current platform.

Well on the Qualcomm MSM72xx SoCs, yeah they're pretty similar -- we can reasonably enter power collapse (full shutdown of the ARM11 and peripherals) from idle. But this is not (to my knowledge) true of *all* SoCs out there. Also, resuming from this state can take 5-30ms (depending on how distracted the baseband processor is by what's going on on the network).

Mm. Resume from deep idle on x86 is typically in the usec range, but this is the kind of constraint that pm_qos exposes nicely.

Signature · 1 line
Matthew Garrett | [email protected]
#358 lore raw
In reply to Brian Swetland
Quoted 10 lines · Brian Swetland

[Matthew Garrett <[email protected]>]

Quoted 2 lines

https://lists.linux-foundation.org/pipermail/linux-pm/2009-January/019493.html
says that they're the same on their current platform.

Well on the Qualcomm MSM72xx SoCs, yeah they're pretty similar -- we can reasonably enter power collapse (full shutdown of the ARM11 and peripherals) from idle. But this is not (to my knowledge) true of *all* SoCs out there. Also, resuming from this state can take 5-30ms (depending on how distracted the baseband processor is by what's going on on the network).

Mm. Resume from deep idle on x86 is typically in the usec range, but this is the kind of constraint that pm_qos exposes nicely.

Signature · 1 line
Matthew Garrett | [email protected]
#359 lore raw
In reply to Matthew Garrett
Quoted 6 lines · Matthew Garrett
Quoted 3 lines · Pavel Machek

If no devices are being used, and next wakeup is far enough in the future, just put system to sleep. Long enough == so far away that suspend/wakeup is short compared to that... like 20 seconds on PC.

Quoted 7 lines

This is intrinsically difficult with PCs, since we have such a poorly defined set of wakeup events. We can't wakeup on generic network traffic, just WoL. Many machines won't wake up on keyboard events. Meanwhile, on embedded it's becoming a less interesting problem because idle and suspended are often now equivalent states. Concentrating on runtime PM of as much hardware as possible is arguably more interesting for the majority of use cases.

Putting the wake on key event issue aside, is it possible to have wake up's on the ms time scale? I ask because I thought the XO did exactly this (but left the screen live). Why does it take 20 sec to get into or out of S3 on my laptop?

--mgross

Quoted 3 lines
Signature · 2 lines
-- 
Matthew Garrett | [email protected]
#360 lore raw
Quoted 4 lines · mark gross

Putting the wake on key event issue aside, is it possible to have wake up's on the ms time scale? I ask because I thought the XO did exactly this (but left the screen live). Why does it take 20 sec to get into or out of S3 on my laptop?

Graphics reinit, dumping graphics contents back into RAM, us resuming devices in series, that kind of thing. On some hardware you'll spend a noticable amount of time in the BIOS before any of the Linux resume code gets touched. I thought the XO had got sub second, but I wasn't sure that they were in the low ms range.

Signature · 1 line
Matthew Garrett | [email protected]
#361 lore raw
In reply to mark gross
Quoted 4 lines · mark gross

Putting the wake on key event issue aside, is it possible to have wake up's on the ms time scale? I ask because I thought the XO did exactly this (but left the screen live). Why does it take 20 sec to get into or out of S3 on my laptop?

Graphics reinit, dumping graphics contents back into RAM, us resuming devices in series, that kind of thing. On some hardware you'll spend a noticable amount of time in the BIOS before any of the Linux resume code gets touched. I thought the XO had got sub second, but I wasn't sure that they were in the low ms range.

Signature · 1 line
Matthew Garrett | [email protected]
#362 lore raw
Quoted 11 lines · Matthew Garrett
Quoted 4 lines · mark gross

Putting the wake on key event issue aside, is it possible to have wake up's on the ms time scale? I ask because I thought the XO did exactly this (but left the screen live). Why does it take 20 sec to get into or out of S3 on my laptop?

Graphics reinit, dumping graphics contents back into RAM, us resuming devices in series, that kind of thing. On some hardware you'll spend a noticable amount of time in the BIOS before any of the Linux resume code gets touched. I thought the XO had got sub second, but I wasn't sure that they were in the low ms range.

IME a good chunk of it is BIOS time. On my x200s resume is very fast (on the order of a second or two though I haven't measured), while on my Eee and T61 machines it's much slower, even though they're all using Intel gfx.

Of course we should really be shooting for sub-second times or about the time it takes you to open your lid (or even much faster in the case of demand suspend/resume for servers/desktops).

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#363 lore raw
In reply to Matthew Garrett
Quoted 11 lines · Matthew Garrett
Quoted 4 lines · mark gross

Putting the wake on key event issue aside, is it possible to have wake up's on the ms time scale? I ask because I thought the XO did exactly this (but left the screen live). Why does it take 20 sec to get into or out of S3 on my laptop?

Graphics reinit, dumping graphics contents back into RAM, us resuming devices in series, that kind of thing. On some hardware you'll spend a noticable amount of time in the BIOS before any of the Linux resume code gets touched. I thought the XO had got sub second, but I wasn't sure that they were in the low ms range.

IME a good chunk of it is BIOS time. On my x200s resume is very fast (on the order of a second or two though I haven't measured), while on my Eee and T61 machines it's much slower, even though they're all using Intel gfx.

Of course we should really be shooting for sub-second times or about the time it takes you to open your lid (or even much faster in the case of demand suspend/resume for servers/desktops).

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#364 lore raw
Quoted 17 lines

From: Jesse Barnes [mailto:[email protected]]
Sent: Tuesday, February 17, 2009 4:19 PM

Quoted 11 lines · Matthew Garrett
Quoted 4 lines · mark gross

Putting the wake on key event issue aside, is it possible to have wake up's on the ms time scale? I ask because I thought the XO did exactly this (but left the screen live). Why does it take 20 sec to get into or out of S3 on my laptop?

Graphics reinit, dumping graphics contents back into RAM, us resuming devices in series, that kind of thing. On some hardware you'll spend a noticable amount of time in the BIOS before any of the Linux resume code gets touched. I thought the XO had got sub second, but I wasn't sure that they were in the low ms range.

Quoted 7 lines

IME a good chunk of it is BIOS time. On my x200s resume is very fast (on the order of a second or two though I haven't measured), while on my Eee and T61 machines it's much slower, even though they're all using Intel gfx.

Of course we should really be shooting for sub-second times or about the time it takes you to open your lid (or even much faster in the case of demand suspend/resume for servers/desktops).

This is good example of embedded ARM time scales not matching up with x86 ones. For OMAP3 our resumption from OFF mode (full SOC context lost) software budget was in the 10s of milliSeconds. There is no BIOS and we must generate most of the code.

As such very frequent fast OFF mode transitions are useful and possible. As I said in another part of the thread, the slow part is Voltage ramp time. Also clock setup time of external oscillator can be 5-10mS by itself.

This tight timing was the requirement of some modems which required a response ASAP when data was coming. Not every modem is so tight but some are.

Regards,
Richard W.

#365 lore raw
In reply to Jesse Barnes
Quoted 17 lines

From: Jesse Barnes [mailto:[email protected]]
Sent: Tuesday, February 17, 2009 4:19 PM

Quoted 11 lines · Matthew Garrett
Quoted 4 lines · mark gross

Putting the wake on key event issue aside, is it possible to have wake up's on the ms time scale? I ask because I thought the XO did exactly this (but left the screen live). Why does it take 20 sec to get into or out of S3 on my laptop?

Graphics reinit, dumping graphics contents back into RAM, us resuming devices in series, that kind of thing. On some hardware you'll spend a noticable amount of time in the BIOS before any of the Linux resume code gets touched. I thought the XO had got sub second, but I wasn't sure that they were in the low ms range.

Quoted 7 lines

IME a good chunk of it is BIOS time. On my x200s resume is very fast (on the order of a second or two though I haven't measured), while on my Eee and T61 machines it's much slower, even though they're all using Intel gfx.

Of course we should really be shooting for sub-second times or about the time it takes you to open your lid (or even much faster in the case of demand suspend/resume for servers/desktops).

This is good example of embedded ARM time scales not matching up with x86 ones. For OMAP3 our resumption from OFF mode (full SOC context lost) software budget was in the 10s of milliSeconds. There is no BIOS and we must generate most of the code.

As such very frequent fast OFF mode transitions are useful and possible. As I said in another part of the thread, the slow part is Voltage ramp time. Also clock setup time of external oscillator can be 5-10mS by itself.

This tight timing was the requirement of some modems which required a response ASAP when data was coming. Not every modem is so tight but some are.

Regards,
Richard W.

#366 lore raw
In reply to Jesse Barnes
Quoted 13 lines · Jesse Barnes
Quoted 11 lines · Matthew Garrett
Quoted 4 lines · mark gross

Putting the wake on key event issue aside, is it possible to have wake up's on the ms time scale? I ask because I thought the XO did exactly this (but left the screen live). Why does it take 20 sec to get into or out of S3 on my laptop?

Graphics reinit, dumping graphics contents back into RAM, us resuming devices in series, that kind of thing. On some hardware you'll spend a noticable amount of time in the BIOS before any of the Linux resume code gets touched. I thought the XO had got sub second, but I wasn't sure that they were in the low ms range.

Quoted 7 lines

IME a good chunk of it is BIOS time. On my x200s resume is very fast (on the order of a second or two though I haven't measured), while on my Eee and T61 machines it's much slower, even though they're all using Intel gfx.

Of course we should really be shooting for sub-second times or about the time it takes you to open your lid (or even much faster in the case of demand suspend/resume for servers/desktops).

yeah I was thinking vertical blank refresh times.

We would need a state where the graphics stayed on somehow too.

--mgross

#367 lore raw
In reply to Jesse Barnes
Quoted 13 lines · Jesse Barnes
Quoted 11 lines · Matthew Garrett
Quoted 4 lines · mark gross

Putting the wake on key event issue aside, is it possible to have wake up's on the ms time scale? I ask because I thought the XO did exactly this (but left the screen live). Why does it take 20 sec to get into or out of S3 on my laptop?

Graphics reinit, dumping graphics contents back into RAM, us resuming devices in series, that kind of thing. On some hardware you'll spend a noticable amount of time in the BIOS before any of the Linux resume code gets touched. I thought the XO had got sub second, but I wasn't sure that they were in the low ms range.

Quoted 7 lines

IME a good chunk of it is BIOS time. On my x200s resume is very fast (on the order of a second or two though I haven't measured), while on my Eee and T61 machines it's much slower, even though they're all using Intel gfx.

Of course we should really be shooting for sub-second times or about the time it takes you to open your lid (or even much faster in the case of demand suspend/resume for servers/desktops).

yeah I was thinking vertical blank refresh times.

We would need a state where the graphics stayed on somehow too.

--mgross

#368 lore raw
In reply to mark gross

Hi Mark,

Quoted 3 lines

Putting the wake on key event issue aside, is it possible to have wake up's on the ms time scale? I ask because I thought the XO did exactly this (but left the screen live).

We're currently at 890ms for suspend+resume with USB on, and 180ms for suspend+resume when booted "nousb". Anything done upstream to make the first number closer to the second one will be very valuable to us.

Quoted 1 line

Why does it take 20 sec to get into or out of S3 on my laptop?

We found that the SMM version of S3 in our original development BIOS also took that long. We switched to using Open Firmware, turned off ACPI, worked out exactly which registers to use to enter S3, and scheduled device reinitialization such that hardware-required delays (such as clock stabilization for our GPU) start in the right order to keep the critical path short.

The main difference was the switch away from the vendor BIOS, though -- we were seeing something like a five-second delay between Linux entering S3 and the hardware noticing and putting the system into suspend, for example. There's not much market pressure to write efficient EC code for suspend/resume. (Or, we discovered, to write EC code that's able to handle suspend/resume more than a hundred times per boot without crashing.)

- Chris.

Signature · 1 line
Chris Ball   <[email protected]>
#369 lore raw
In reply to mark gross

Hi Mark,

Quoted 3 lines

Putting the wake on key event issue aside, is it possible to have wake up's on the ms time scale? I ask because I thought the XO did exactly this (but left the screen live).

We're currently at 890ms for suspend+resume with USB on, and 180ms for suspend+resume when booted "nousb". Anything done upstream to make the first number closer to the second one will be very valuable to us.

Quoted 1 line

Why does it take 20 sec to get into or out of S3 on my laptop?

We found that the SMM version of S3 in our original development BIOS also took that long. We switched to using Open Firmware, turned off ACPI, worked out exactly which registers to use to enter S3, and scheduled device reinitialization such that hardware-required delays (such as clock stabilization for our GPU) start in the right order to keep the critical path short.

The main difference was the switch away from the vendor BIOS, though -- we were seeing something like a five-second delay between Linux entering S3 and the hardware noticing and putting the system into suspend, for example. There's not much market pressure to write efficient EC code for suspend/resume. (Or, we discovered, to write EC code that's able to handle suspend/resume more than a hundred times per boot without crashing.)

- Chris.

Signature · 1 line
Chris Ball   <[email protected]>
#370 lore raw
In reply to Matthew Garrett
Quoted 6 lines · Matthew Garrett
Quoted 3 lines · Pavel Machek

If no devices are being used, and next wakeup is far enough in the future, just put system to sleep. Long enough == so far away that suspend/wakeup is short compared to that... like 20 seconds on PC.

Quoted 7 lines

This is intrinsically difficult with PCs, since we have such a poorly defined set of wakeup events. We can't wakeup on generic network traffic, just WoL. Many machines won't wake up on keyboard events. Meanwhile, on embedded it's becoming a less interesting problem because idle and suspended are often now equivalent states. Concentrating on runtime PM of as much hardware as possible is arguably more interesting for the majority of use cases.

Putting the wake on key event issue aside, is it possible to have wake up's on the ms time scale? I ask because I thought the XO did exactly this (but left the screen live). Why does it take 20 sec to get into or out of S3 on my laptop?

--mgross

Quoted 3 lines
Signature · 2 lines
-- 
Matthew Garrett | [email protected]
#371 lore raw
In reply to Pavel Machek
Quoted 11 lines · Pavel Machek

Hi!

Quoted 5 lines

The recent descussion about the Android PM patches sent by Arve shows that there is a need to introduce a mechanism allowing us to:
(1) automatically put the system as a whole into a sleep state (eg. suspend to RAM) when it is found to be "idle", where the meaning of "idle" has to be defined too,

Well; I'd prefer to keep the interface very minimal.

If no devices are being used,

We'll need some kind of infrastructure to detect such situations.

Quoted 1 line

and next wakeup is far enough in the future,

What exactly do you mean by "next wakeup"?

Quoted 2 lines

just put system to sleep. Long enough == so far away that suspend/wakeup is short compared to that... like 20 seconds on PC.

Well 10s will be fine on the majority of my test boxes, but that's a detail.

Quoted 2 lines

Ok, it probably needs to be opt-in: echo auto-mem > /sys/power/state should do the trick.

Agreed.

Quoted 3 lines

This will need either fixing all the applications not to poll, or maybe someone SIGSTOP-ing apps that are in background and poll too often.

Polling in general is not PM-friendly, so we'll need to deal with it somehow at one point anyway.

Thanks,
Rafael

#372 lore raw
In reply to Pavel Machek
Quoted 11 lines · Pavel Machek

Hi!

Quoted 5 lines

The recent descussion about the Android PM patches sent by Arve shows that there is a need to introduce a mechanism allowing us to:
(1) automatically put the system as a whole into a sleep state (eg. suspend to RAM) when it is found to be "idle", where the meaning of "idle" has to be defined too,

Well; I'd prefer to keep the interface very minimal.

If no devices are being used,

We'll need some kind of infrastructure to detect such situations.

Quoted 1 line

and next wakeup is far enough in the future,

What exactly do you mean by "next wakeup"?

Quoted 2 lines

just put system to sleep. Long enough == so far away that suspend/wakeup is short compared to that... like 20 seconds on PC.

Well 10s will be fine on the majority of my test boxes, but that's a detail.

Quoted 2 lines

Ok, it probably needs to be opt-in: echo auto-mem > /sys/power/state should do the trick.

Agreed.

Quoted 3 lines

This will need either fixing all the applications not to poll, or maybe someone SIGSTOP-ing apps that are in background and poll too often.

Polling in general is not PM-friendly, so we'll need to deal with it somehow at one point anyway.

Thanks,
Rafael

#373 lore raw

Hi!

Quoted 11 lines
Quoted 9 lines
Quoted 5 lines

The recent descussion about the Android PM patches sent by Arve shows that there is a need to introduce a mechanism allowing us to:
(1) automatically put the system as a whole into a sleep state (eg. suspend to RAM) when it is found to be "idle", where the meaning of "idle" has to be defined too,

Well; I'd prefer to keep the interface very minimal.

If no devices are being used,

We'll need some kind of infrastructure to detect such situations.

Yes, I like the latest 'atomic_t + bit in struct device' ideas...

Quoted 3 lines
Quoted 1 line

and next wakeup is far enough in the future,

What exactly do you mean by "next wakeup"?

Next timer in kernel and next sleep/select timeout in userspace.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#374 lore raw
In reply to Rafael J. Wysocki

Hi!

Quoted 11 lines
Quoted 9 lines
Quoted 5 lines

The recent descussion about the Android PM patches sent by Arve shows that there is a need to introduce a mechanism allowing us to:
(1) automatically put the system as a whole into a sleep state (eg. suspend to RAM) when it is found to be "idle", where the meaning of "idle" has to be defined too,

Well; I'd prefer to keep the interface very minimal.

If no devices are being used,

We'll need some kind of infrastructure to detect such situations.

Yes, I like the latest 'atomic_t + bit in struct device' ideas...

Quoted 3 lines
Quoted 1 line

and next wakeup is far enough in the future,

What exactly do you mean by "next wakeup"?

Next timer in kernel and next sleep/select timeout in userspace.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#375 lore raw
In reply to Rafael J. Wysocki
Quoted 7 lines · Rafael J. Wysocki

Hi,

The recent descussion about the Android PM patches sent by Arve shows that there is a need to introduce a mechanism allowing us to:
(1) automatically put the system as a whole into a sleep state (eg. suspend to RAM) when it is found to be "idle", where the meaning of "idle" has to be defined too,

Can a fast STR state be created for the generic kernel across architectures? Something that can go into and out of SRT in < 20ms? (I picked 20ms as that gives 50Hz screen refresh) I guess the XO does something like this between keystrokes.

Note: I don't know (but I should) if such a PM design popping into and out of STR at worst every 20ms is worth doing on IA but lets assume its not so bad for the sake of argument.

One could assume the system would be idle except for selects on HID events when operating in this mode.

Quoted 2 lines

(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

This is a driver deal to drop the hardware they control into lower power states. Give information for PM-QOS the drivers could do the right things here. (or should be able too)

Also how do we attempt to coordinate this with an automatic STR state?

How to coexist with user requested STR?

Do we need to more carefully define what STR really means? (I'm thinking we do)

Quoted 22 lines

To allow these two things to happen, the Andriod patches introduced the wakelocks with the associated infrastructure and the "early suspend" mechanism. However, quite a number of reviewers did not like these patches, for various reasons, so they cannot be regarded as generally acceptable. For this reason, I think, we should discuss the problem in detail from the beginning and try to find a solution that everyone interested will be comfortable with.

For this purpose, IMO, we should at least reach an agreement on what the kernel's and the userland's roles in (1) and (2) are going to be. There also are quite a few questions that need to be answered. For instance, what conditions are going to be used to decide whether or not the system is idle enough so that we can put it into a sleep state? How are we going to check these conditions? What is going to happen if one (or more) of them changes while a system-wide power transition (eg. suspend) is in progress? Are we going to allow the user space to take part in this and if so, to what extent? What mechanisms are going be used to put devices into low power states at run time (ie. before starting any system-wide power transition) and how are they going to be related to the suspend-resume infrastructure used during system-wide power transitions? The answers to these (and other related) questions will likely affect all of the future Linux PM developlent, so IMO this is a very important matter.

Quoted 2 lines

Opinions and comments welcome.

thank you for starting this FRD.

--mgross

Quoted 2 lines

Thanks,
Rafael

#376 lore raw
Quoted 11 lines · mark gross
Quoted 7 lines · Rafael J. Wysocki

Hi,

The recent descussion about the Android PM patches sent by Arve shows that there is a need to introduce a mechanism allowing us to:
(1) automatically put the system as a whole into a sleep state (eg. suspend to RAM) when it is found to be "idle", where the meaning of "idle" has to be defined too,

Can a fast STR state be created for the generic kernel across architectures? Something that can go into and out of SRT in < 20ms?

I don't think it's generally doable on PCs.

Quoted 10 lines

(I picked 20ms as that gives 50Hz screen refresh) I guess the XO does something like this between keystrokes.

Note: I don't know (but I should) if such a PM design popping into and out of STR at worst every 20ms is worth doing on IA but lets assume its not so bad for the sake of argument.

One could assume the system would be idle except for selects on HID events when operating in this mode.

Quoted 6 lines
Quoted 2 lines

(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

This is a driver deal to drop the hardware they control into lower power states. Give information for PM-QOS the drivers could do the right things here. (or should be able too)

That may also depend on the bus the driver is on (like PCI for one example).

Quoted 1 line

Also how do we attempt to coordinate this with an automatic STR state?

That's one thing to think about. In principle we can avoid suspending devices that already are in low power states before a system-wide transition is started (caveat: wake-up devices on ACPI systems).

Quoted 4 lines

How to coexist with user requested STR?

Do we need to more carefully define what STR really means? (I'm thinking we do)

Well, yes and no. In fact ACPI defines STR as one of the system sleep states in which the CPU does not execute instructions, but the ACPI definition need not be applicable to non-ACPI platforms.

Quoted 22 lines
Quoted 22 lines

To allow these two things to happen, the Andriod patches introduced the wakelocks with the associated infrastructure and the "early suspend" mechanism. However, quite a number of reviewers did not like these patches, for various reasons, so they cannot be regarded as generally acceptable. For this reason, I think, we should discuss the problem in detail from the beginning and try to find a solution that everyone interested will be comfortable with.

For this purpose, IMO, we should at least reach an agreement on what the kernel's and the userland's roles in (1) and (2) are going to be. There also are quite a few questions that need to be answered. For instance, what conditions are going to be used to decide whether or not the system is idle enough so that we can put it into a sleep state? How are we going to check these conditions? What is going to happen if one (or more) of them changes while a system-wide power transition (eg. suspend) is in progress? Are we going to allow the user space to take part in this and if so, to what extent? What mechanisms are going be used to put devices into low power states at run time (ie. before starting any system-wide power transition) and how are they going to be related to the suspend-resume infrastructure used during system-wide power transitions? The answers to these (and other related) questions will likely affect all of the future Linux PM developlent, so IMO this is a very important matter.

Quoted 4 lines
Quoted 2 lines

Opinions and comments welcome.

thank you for starting this FRD.

No big deal. :-)

Thanks,
Rafael

#377 lore raw
In reply to mark gross
Quoted 11 lines · mark gross
Quoted 7 lines · Rafael J. Wysocki

Hi,

The recent descussion about the Android PM patches sent by Arve shows that there is a need to introduce a mechanism allowing us to:
(1) automatically put the system as a whole into a sleep state (eg. suspend to RAM) when it is found to be "idle", where the meaning of "idle" has to be defined too,

Can a fast STR state be created for the generic kernel across architectures? Something that can go into and out of SRT in < 20ms?

I don't think it's generally doable on PCs.

Quoted 10 lines

(I picked 20ms as that gives 50Hz screen refresh) I guess the XO does something like this between keystrokes.

Note: I don't know (but I should) if such a PM design popping into and out of STR at worst every 20ms is worth doing on IA but lets assume its not so bad for the sake of argument.

One could assume the system would be idle except for selects on HID events when operating in this mode.

Quoted 6 lines
Quoted 2 lines

(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

This is a driver deal to drop the hardware they control into lower power states. Give information for PM-QOS the drivers could do the right things here. (or should be able too)

That may also depend on the bus the driver is on (like PCI for one example).

Quoted 1 line

Also how do we attempt to coordinate this with an automatic STR state?

That's one thing to think about. In principle we can avoid suspending devices that already are in low power states before a system-wide transition is started (caveat: wake-up devices on ACPI systems).

Quoted 4 lines

How to coexist with user requested STR?

Do we need to more carefully define what STR really means? (I'm thinking we do)

Well, yes and no. In fact ACPI defines STR as one of the system sleep states in which the CPU does not execute instructions, but the ACPI definition need not be applicable to non-ACPI platforms.

Quoted 22 lines
Quoted 22 lines

To allow these two things to happen, the Andriod patches introduced the wakelocks with the associated infrastructure and the "early suspend" mechanism. However, quite a number of reviewers did not like these patches, for various reasons, so they cannot be regarded as generally acceptable. For this reason, I think, we should discuss the problem in detail from the beginning and try to find a solution that everyone interested will be comfortable with.

For this purpose, IMO, we should at least reach an agreement on what the kernel's and the userland's roles in (1) and (2) are going to be. There also are quite a few questions that need to be answered. For instance, what conditions are going to be used to decide whether or not the system is idle enough so that we can put it into a sleep state? How are we going to check these conditions? What is going to happen if one (or more) of them changes while a system-wide power transition (eg. suspend) is in progress? Are we going to allow the user space to take part in this and if so, to what extent? What mechanisms are going be used to put devices into low power states at run time (ie. before starting any system-wide power transition) and how are they going to be related to the suspend-resume infrastructure used during system-wide power transitions? The answers to these (and other related) questions will likely affect all of the future Linux PM developlent, so IMO this is a very important matter.

Quoted 4 lines
Quoted 2 lines

Opinions and comments welcome.

thank you for starting this FRD.

No big deal. :-)

Thanks,
Rafael

#378 lore raw
In reply to Rafael J. Wysocki
Quoted 7 lines · Rafael J. Wysocki

Hi,

The recent descussion about the Android PM patches sent by Arve shows that there is a need to introduce a mechanism allowing us to:
(1) automatically put the system as a whole into a sleep state (eg. suspend to RAM) when it is found to be "idle", where the meaning of "idle" has to be defined too,

Can a fast STR state be created for the generic kernel across architectures? Something that can go into and out of SRT in < 20ms? (I picked 20ms as that gives 50Hz screen refresh) I guess the XO does something like this between keystrokes.

Note: I don't know (but I should) if such a PM design popping into and out of STR at worst every 20ms is worth doing on IA but lets assume its not so bad for the sake of argument.

One could assume the system would be idle except for selects on HID events when operating in this mode.

Quoted 2 lines

(2) put given subset of devices into low power states whenever they are not used, without putting the entire system into a sleep state.

This is a driver deal to drop the hardware they control into lower power states. Give information for PM-QOS the drivers could do the right things here. (or should be able too)

Also how do we attempt to coordinate this with an automatic STR state?

How to coexist with user requested STR?

Do we need to more carefully define what STR really means? (I'm thinking we do)

Quoted 22 lines

To allow these two things to happen, the Andriod patches introduced the wakelocks with the associated infrastructure and the "early suspend" mechanism. However, quite a number of reviewers did not like these patches, for various reasons, so they cannot be regarded as generally acceptable. For this reason, I think, we should discuss the problem in detail from the beginning and try to find a solution that everyone interested will be comfortable with.

For this purpose, IMO, we should at least reach an agreement on what the kernel's and the userland's roles in (1) and (2) are going to be. There also are quite a few questions that need to be answered. For instance, what conditions are going to be used to decide whether or not the system is idle enough so that we can put it into a sleep state? How are we going to check these conditions? What is going to happen if one (or more) of them changes while a system-wide power transition (eg. suspend) is in progress? Are we going to allow the user space to take part in this and if so, to what extent? What mechanisms are going be used to put devices into low power states at run time (ie. before starting any system-wide power transition) and how are they going to be related to the suspend-resume infrastructure used during system-wide power transitions? The answers to these (and other related) questions will likely affect all of the future Linux PM developlent, so IMO this is a very important matter.

Quoted 2 lines

Opinions and comments welcome.

thank you for starting this FRD.

--mgross

Quoted 2 lines

Thanks,
Rafael