From: Kirill A. Shutemov <hidden> Date: 2011-10-11 16:15:43
From: "Kirill A. Shutemov" <redacted>
Every task_struct has timer_slack_ns value. This value uses to round up
poll() and select() timeout values. This feature can be useful in
mobile environment where combined wakeups are desired.
Originally, prctl() was the only way to change timer slack value of
a process. So you was not able change timer slack value of another
process.
cgroup subsys "timer_slack" implements timer slack controller. It
provides a way to set minimal timer slack value for a group of tasks.
If a task belongs to a cgroup with minimal timer slack value higher than
task's value, cgroup's value will be applied.
Timer slack controller allows to implement setting timer slack value of
a process based on a policy. For example, you can create foreground and
background cgroups and move tasks between them based on system state.
Idea-by: Jacob Pan [off-list ref]
Signed-off-by: Kirill A. Shutemov <redacted>
---
Documentation/cgroups/timer_slack.txt | 72 +++++++++++++++++++
include/linux/cgroup_subsys.h | 7 ++
include/linux/sched.h | 4 +
init/Kconfig | 8 ++
kernel/Makefile | 1 +
kernel/cgroup_timer_slack.c | 124 +++++++++++++++++++++++++++++++++
6 files changed, 216 insertions(+), 0 deletions(-)
create mode 100644 Documentation/cgroups/timer_slack.txt
create mode 100644 kernel/cgroup_timer_slack.c
@@ -0,0 +1,72 @@+Timer Slack Controller+======================++Overview+--------++Every task_struct has timer_slack_ns value. This value is used to round+up poll() and select() timeout values. This feature can be useful in+mobile environment where combined wakeups are desired.++Originally, prctl() was the only way to change timer slack value of+a process. So you was not able change timer slack value of another+process.++cgroup subsys "timer_slack" implements timer slack controller. It+provides a way to set minimal timer slack value for a group of tasks.+If a task belongs to a cgroup with minimal timer slack value higher than+task's value, cgroup's value will be applied.++Timer slack controller allows to implement setting timer slack value of+a process based on a policy. For example, you can create foreground and+background cgroups and move tasks between them based on system state.++User interface+--------------++To get timer slack controller functionality you need to enable it in+kernel configuration:++CONFIG_CGROUP_TIMER_SLACK=y++The controller provides two files:++# mount -t cgroup -o timer_slack none /sys/fs/cgroup+# ls /sys/fs/cgroup/timer_slack.*+/sys/fs/cgroup/timer_slack.effective_slack_ns+/sys/fs/cgroup/timer_slack.min_slack_ns++By default timer_slack.min_slack_ns is 0:++# cat /sys/fs/cgroup/timer_slack.min_slack_ns+0++You can set it to some value:++# echo 50000 > /sys/fs/cgroup/timer_slack.min_slack_ns+# cat /sys/fs/cgroup/timer_slack.min_slack_ns+50000++Tasks still can set task's value below 50000 using prctl(), but in this+case cgroup's value will be applied.++Timer slack controller supports hierarchical groups.++# mkdir /sys/fs/cgroup/a+# cat /sys/fs/cgroup/a/timer_slack.min_slack_ns+50000+# echo 70000 > /sys/fs/cgroup/a/timer_slack.min_slack_ns+# cat /sys/fs/cgroup/a/timer_slack.min_slack_ns+70000++You can set any value you want, but effective value will the highest value+up by hierarchy. You can see effective timer slack value for the cgroup from+timer_slack.effective_slack_ns file:++# cat /sys/fs/cgroup/a/timer_slack.effective_slack_ns+70000+# echo 100000 > /sys/fs/cgroup/timer_slack.min_slack_ns+# cat /sys/fs/cgroup/a/timer_slack.min_slack_ns+70000+# cat /sys/fs/cgroup/a/timer_slack.effective_slack_ns+100000
From: Kirill A. Shutemov <hidden> Date: 2011-10-11 16:15:43
From: "Kirill A. Shutemov" <redacted>
task_get_effective_timer_slack() returns timer slack value to be used
to configure per-task timers. It can be equal or higher than task's
timer slack value.
For now task_get_effective_timer_slack() returns timer_slack_ns of the
task. Timer slack cgroup controller will implement a bit more
sophisticated logic.
Signed-off-by: Kirill A. Shutemov <redacted>
---
fs/select.c | 7 ++-----
include/linux/sched.h | 6 ++++++
kernel/fork.c | 4 ++++
kernel/futex.c | 4 ++--
kernel/hrtimer.c | 2 +-
5 files changed, 15 insertions(+), 8 deletions(-)
From: Andrew Morton <akpm@linux-foundation.org> Date: 2011-10-14 22:43:53
On Tue, 11 Oct 2011 19:15:29 +0300
"Kirill A. Shutemov" [off-list ref] wrote:
Every task_struct has timer_slack_ns value. This value uses to round up
poll() and select() timeout values. This feature can be useful in
mobile environment where combined wakeups are desired.
Originally, prctl() was the only way to change timer slack value of
a process. So you was not able change timer slack value of another
process.
cgroup subsys "timer_slack" implements timer slack controller. It
provides a way to set minimal timer slack value for a group of tasks.
If a task belongs to a cgroup with minimal timer slack value higher than
task's value, cgroup's value will be applied.
Timer slack controller allows to implement setting timer slack value of
a process based on a policy. For example, you can create foreground and
background cgroups and move tasks between them based on system state.
I'm having trouble understanding the value of this feature. Users can
presently control the timer-slack of a group of processes via
inherit-over-fork.
Perhaps there's a case for providing a way for process A to set process
B's slack. And perhaps B's children. That would be a simpler patch
and would have the considerable advantage that it doesn't require
cgroups.
So.... why should we merge this?
From: Kirill A. Shutemov <hidden> Date: 2011-10-14 23:34:49
On Fri, Oct 14, 2011 at 03:43:48PM -0700, Andrew Morton wrote:
On Tue, 11 Oct 2011 19:15:29 +0300
"Kirill A. Shutemov" [off-list ref] wrote:
quoted
Every task_struct has timer_slack_ns value. This value uses to round up
poll() and select() timeout values. This feature can be useful in
mobile environment where combined wakeups are desired.
Originally, prctl() was the only way to change timer slack value of
a process. So you was not able change timer slack value of another
process.
cgroup subsys "timer_slack" implements timer slack controller. It
provides a way to set minimal timer slack value for a group of tasks.
If a task belongs to a cgroup with minimal timer slack value higher than
task's value, cgroup's value will be applied.
Timer slack controller allows to implement setting timer slack value of
a process based on a policy. For example, you can create foreground and
background cgroups and move tasks between them based on system state.
I'm having trouble understanding the value of this feature. Users can
presently control the timer-slack of a group of processes via
inherit-over-fork.
Perhaps there's a case for providing a way for process A to set process
B's slack. And perhaps B's children. That would be a simpler patch
and would have the considerable advantage that it doesn't require
cgroups.
So.... why should we merge this?
Putting a task to a cgroup isn't change task's timer slack, it may affect
"effective timer slack", if min timer slack for the cgroup > task's timer
slack.
Since we don't touch task's slack value we can drag tasks between cgroups
and always get the most relaxed slack value for a task without
saving/restoring it in userspace.
--
Kirill A. Shutemov
From: Lennart Poettering <hidden> Date: 2011-10-15 11:20:15
On Fri, 14.10.11 15:43, Andrew Morton (akpm@linux-foundation.org) wrote:
quoted
cgroup subsys "timer_slack" implements timer slack controller. It
provides a way to set minimal timer slack value for a group of tasks.
If a task belongs to a cgroup with minimal timer slack value higher than
task's value, cgroup's value will be applied.
Timer slack controller allows to implement setting timer slack value of
a process based on a policy. For example, you can create foreground and
background cgroups and move tasks between them based on system state.
I'm having trouble understanding the value of this feature. Users can
presently control the timer-slack of a group of processes via
inherit-over-fork.
Perhaps there's a case for providing a way for process A to set process
B's slack. And perhaps B's children. That would be a simpler patch
and would have the considerable advantage that it doesn't require
cgroups.
So.... why should we merge this?
Our usecase is basically this:
consider you have one or more desktop user sessions logged in, each one
in a timer slack cgroup. Now, userspace already tracks when sessions
become idle (i.e. currently desktop userspace then starts a screensaver,
or turns off the screen, or similar), and we'd like to increase the timer slack
for the session cgroups individually as the individual session becomes
idle, and decrease it again if the session stops being idle.
Matthew Garrett experimented with a logic like this based on existing
patches, and it showed quite positive effects on power consumption. If
you need hard data I am sure Matthew can fill you in (added him to CC).
What matters for us here is that the timer slack cgroup controller
provides us with a very nice way to change the timerslack for the whole
set of session processes in one go and from the outside. i.e. the idle
logic in userspace would be trivially easy to implement, since we
already track per-session idle states and with the timerlsack cgroup
controller we'd have to touch only a single kernel file to make our
changes.
Lennart
--
Lennart Poettering - Red Hat, Inc.
From: Peter Zijlstra <peterz@infradead.org> Date: 2011-10-15 19:24:07
On Sat, 2011-10-15 at 13:20 +0200, Lennart Poettering wrote:
On Fri, 14.10.11 15:43, Andrew Morton (akpm@linux-foundation.org) wrote:
quoted
quoted
cgroup subsys "timer_slack" implements timer slack controller. It
provides a way to set minimal timer slack value for a group of tasks.
If a task belongs to a cgroup with minimal timer slack value higher than
task's value, cgroup's value will be applied.
Timer slack controller allows to implement setting timer slack value of
a process based on a policy. For example, you can create foreground and
background cgroups and move tasks between them based on system state.
I'm having trouble understanding the value of this feature. Users can
presently control the timer-slack of a group of processes via
inherit-over-fork.
Perhaps there's a case for providing a way for process A to set process
B's slack. And perhaps B's children. That would be a simpler patch
and would have the considerable advantage that it doesn't require
cgroups.
So.... why should we merge this?
Our usecase is basically this:
consider you have one or more desktop user sessions logged in, each one
in a timer slack cgroup. Now, userspace already tracks when sessions
become idle (i.e. currently desktop userspace then starts a screensaver,
or turns off the screen, or similar), and we'd like to increase the timer slack
for the session cgroups individually as the individual session becomes
idle, and decrease it again if the session stops being idle.
What matters for us here is that the timer slack cgroup controller
provides us with a very nice way to change the timerslack for the whole
set of session processes in one go and from the outside. i.e. the idle
logic in userspace would be trivially easy to implement, since we
already track per-session idle states and with the timerlsack cgroup
controller we'd have to touch only a single kernel file to make our
changes.
I would argue this is an excellent reason not to merge this. This really
is in the camp of lets paper over shitty userspace instead of fix it.
Such a scheme takes away the immediate need to fix crap and therefore
crap will not get fixed. Why not focus on creating tools (I think
powertop really already does everything you need) and track down WTF
apps are firing so many timers when the screen if off.
Also, the downside of your approach is that you treat all applications
the same, what if there is a genuine need for reasonable timer response
and your 'policy' wrecks things?
From: Lennart Poettering <hidden> Date: 2011-10-17 01:39:25
On Sat, 15.10.11 21:11, Peter Zijlstra (peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org) wrote:
quoted
consider you have one or more desktop user sessions logged in, each one
in a timer slack cgroup. Now, userspace already tracks when sessions
become idle (i.e. currently desktop userspace then starts a screensaver,
or turns off the screen, or similar), and we'd like to increase the timer slack
for the session cgroups individually as the individual session becomes
idle, and decrease it again if the session stops being idle.
quoted
What matters for us here is that the timer slack cgroup controller
provides us with a very nice way to change the timerslack for the whole
set of session processes in one go and from the outside. i.e. the idle
logic in userspace would be trivially easy to implement, since we
already track per-session idle states and with the timerlsack cgroup
controller we'd have to touch only a single kernel file to make our
changes.
I would argue this is an excellent reason not to merge this. This really
is in the camp of lets paper over shitty userspace instead of fix it.
Such a scheme takes away the immediate need to fix crap and therefore
crap will not get fixed. Why not focus on creating tools (I think
powertop really already does everything you need) and track down WTF
apps are firing so many timers when the screen if off.
Well, maybe that works in fantasy land. In real life however there's
stuff like closed source crap, and all kinds of other things you cannot
fix. In a world where everybody wants "apps" (i.e. 3rd party code
running with limited privileges) your chance to fix every bit of code is
gone.
Despite that: even if all software was open source, and even if we had
the manpower to fix every single project: do you honestly believe it is
such a good idea to build the idle state tracking into each program so
that it can change the timer slack from the inside, if this could be
done in a much much simpler way from the outside?
So yeah, because there'll always be closed source userspace, and because
I believe hacking userspace software should be easy and accessible to
everybody, and because we also should make it difficult to fuck up
runtime behaviour of the machine (such as power usage) I believe
enforcing logic the way we can do it with timerslack cgroups is a good
thing, not a bad thing.
Also, the downside of your approach is that you treat all applications
the same, what if there is a genuine need for reasonable timer response
and your 'policy' wrecks things?
Well, if some thread needs reasonable timer response, then they probably
should be enabling RT anyway and IIRC the patch excludes RT threads when
it mucks with the timer slack. But I guess Kirill can comment on this
much better than I could.
Lennart
--
Lennart Poettering - Red Hat, Inc.
From: Matthew Garrett <hidden> Date: 2011-10-17 03:23:02
On Mon, Oct 17, 2011 at 03:39:21AM +0200, Lennart Poettering wrote:
On Sat, 15.10.11 21:11, Peter Zijlstra (peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org) wrote:
quoted
I would argue this is an excellent reason not to merge this. This really
is in the camp of lets paper over shitty userspace instead of fix it.
Such a scheme takes away the immediate need to fix crap and therefore
crap will not get fixed. Why not focus on creating tools (I think
powertop really already does everything you need) and track down WTF
apps are firing so many timers when the screen if off.
Well, maybe that works in fantasy land. In real life however there's
stuff like closed source crap, and all kinds of other things you cannot
fix. In a world where everybody wants "apps" (i.e. 3rd party code
running with limited privileges) your chance to fix every bit of code is
gone.
I agree. We can't assume perfect software, and I don't think *requiring*
the duplication of this functionality in every single session
application is sensible. We want to be able to shut down timer based
code when the session is idle. We could do this by exposing the slack in
/proc. We could do this by modifying every piece of code to listen for
session idle events and (independently) enact session-wide policy. Or we
could just accept that it's a problem that maps onto what people are
already using cgroups for and implement it in the same way.
--
Matthew Garrett | mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org
From: Arjan van de Ven <hidden> Date: 2011-10-17 05:21:57
On 10/16/2011 8:22 PM, Matthew Garrett wrote:
On Mon, Oct 17, 2011 at 03:39:21AM +0200, Lennart Poettering wrote:
quoted
On Sat, 15.10.11 21:11, Peter Zijlstra (peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org) wrote:
quoted
I would argue this is an excellent reason not to merge this. This really
is in the camp of lets paper over shitty userspace instead of fix it.
Such a scheme takes away the immediate need to fix crap and therefore
crap will not get fixed. Why not focus on creating tools (I think
powertop really already does everything you need) and track down WTF
apps are firing so many timers when the screen if off.
Well, maybe that works in fantasy land. In real life however there's
stuff like closed source crap, and all kinds of other things you cannot
fix. In a world where everybody wants "apps" (i.e. 3rd party code
running with limited privileges) your chance to fix every bit of code is
gone.
I agree. We can't assume perfect software, and I don't think *requiring*
the duplication of this functionality in every single session
application is sensible. We want to be able to shut down timer based
code when the session is idle. We could do this by exposing the slack in
/proc. We could do this by modifying every piece of code to listen for
session idle events and (independently) enact session-wide policy. Or we
could just accept that it's a problem that maps onto what people are
already using cgroups for and implement it in the same way.
and..it's not like we let the bad guys go free.
We actually seriously hurt their behavior while we throttle their timers
here.
From: Peter Zijlstra <peterz@infradead.org> Date: 2011-10-17 07:29:25
On Mon, 2011-10-17 at 03:39 +0200, Lennart Poettering wrote:
Well, maybe that works in fantasy land. In real life however there's
stuff like closed source crap, and all kinds of other things you cannot
fix. In a world where everybody wants "apps" (i.e. 3rd party code
running with limited privileges) your chance to fix every bit of code is
gone.
I don't care for closed source crap, and I'm the proof your stmt is
false since I don't want no fucking apps. That's the same kind of
'everybody' that makes GNOME the utter head-up-arse crap it is.
Despite that: even if all software was open source, and even if we had
the manpower to fix every single project: do you honestly believe it is
such a good idea to build the idle state tracking into each program so
that it can change the timer slack from the inside, if this could be
done in a much much simpler way from the outside?
That would be doing it wrong. You want your runtime enforcing this
stuff. Simply let X kill whomever issues a drawing request for a
nonvisible surface.
Also, no apps shouldn't change their timer slack, if you think that you
really just don't get it, go away! They shouldn't be using those timers
to begin with. Increasing the slack is a bandaid trying to sort of
compensate for wrong timer usage.
There's absolutely no point in firefox trying to animate a GIF in a
non-visible tab (all are non-visible when the screen if off). Yet it
does. Go and fix that.
As to the proprietary plugins, let firefox spawn one per tab and simply
SIGSTOP the thing when the tab becomes invisible or so, dunno.
So yeah, because there'll always be closed source userspace, and because
I believe hacking userspace software should be easy and accessible to
everybody, and because we also should make it difficult to fuck up
runtime behaviour of the machine (such as power usage) I believe
enforcing logic the way we can do it with timerslack cgroups is a good
thing, not a bad thing.
I'm of the absolute opposite camp, make the runtime unforgiving of
fuckups, like we are for memory protection violations. Apps that crash a
lot aren't popular like you can see in various app markets.
So improve the runtime to detect power unfriendly behaviour and simply
kill.
quoted
Also, the downside of your approach is that you treat all applications
the same, what if there is a genuine need for reasonable timer response
and your 'policy' wrecks things?
Well, if some thread needs reasonable timer response, then they probably
should be enabling RT anyway and IIRC the patch excludes RT threads when
it mucks with the timer slack. But I guess Kirill can comment on this
much better than I could.
That's nonsense, you shouldn't need RT privs in order to get a timer to
fire more than once every few seconds just because the screen if off.
From: Peter Zijlstra <peterz@infradead.org> Date: 2011-10-17 07:35:19
On Mon, 2011-10-17 at 04:22 +0100, Matthew Garrett wrote:
I agree. We can't assume perfect software, and I don't think *requiring*
the duplication of this functionality in every single session
application is sensible. We want to be able to shut down timer based
code when the session is idle. We could do this by exposing the slack in
/proc. We could do this by modifying every piece of code to listen for
session idle events and (independently) enact session-wide policy. Or we
could just accept that it's a problem that maps onto what people are
already using cgroups for and implement it in the same way.
So what about the app that is both screen oriented and has a server
part, say some multi-player game thing. Suppose you run one as a server
but leave the client idle (you go have dinner with a pretty lady instead
of playing quake, but leave your machine up to serve for your nerd
friends).
Should your friends get punished with a horrible gaming experience just
because you're having a good time IRL and your screen went blank?
Sure pushing up timer slack will save you power, but it will also hurt
people, what will you do for them? The same that you do for those that
want to run a CGROUP=n kernel?
From: Peter Zijlstra <peterz@infradead.org> Date: 2011-10-17 07:37:21
On Sun, 2011-10-16 at 22:21 -0700, Arjan van de Ven wrote:
and..it's not like we let the bad guys go free.
We actually seriously hurt their behavior while we throttle their timers
here.
How are they hurt? The app appears to behave properly (there are no
repercussions, the app doesn't crash, the developer doesn't get punched
in the face). This doesn't make the developer improve his app, nor make
him take greater care for the next app.
Such behaviour will in fact encourage crap since he seems to be getting
away with it.
From: Thomas Gleixner <hidden> Date: 2011-10-17 09:38:23
On Mon, 17 Oct 2011, Peter Zijlstra wrote:
On Sun, 2011-10-16 at 22:21 -0700, Arjan van de Ven wrote:
quoted
and..it's not like we let the bad guys go free.
We actually seriously hurt their behavior while we throttle their timers
here.
How are they hurt? The app appears to behave properly (there are no
repercussions, the app doesn't crash, the developer doesn't get punched
in the face). This doesn't make the developer improve his app, nor make
him take greater care for the next app.
Such behaviour will in fact encourage crap since he seems to be getting
away with it.
Unfortunately this is a full speed rolling trainwreck already. The
whole app space is made to encourage shitty applications. Android is
designed exactly in that way and it seems that all other desktop folks
have fully adopted that adsurdity.
Back when NOHZ was merged in the kernel, powertop made people fix crap
left and right in not time. Why should we add something which actively
fosters crappy applications today?
Thanks,
tglx
From: Matthew Garrett <hidden> Date: 2011-10-17 12:47:09
On Mon, Oct 17, 2011 at 11:38:03AM +0200, Thomas Gleixner wrote:
Unfortunately this is a full speed rolling trainwreck already. The
whole app space is made to encourage shitty applications. Android is
designed exactly in that way and it seems that all other desktop folks
have fully adopted that adsurdity.
Back when NOHZ was merged in the kernel, powertop made people fix crap
left and right in not time. Why should we add something which actively
fosters crappy applications today?
They're orthogonal. Sometimes you want timer-driven behaviour (how else
are you going to draw animations?) and that's obviously going to
generate wakeups. This is for the idle case, where the user is no longer
sitting in front of the machine but you don't want to trigger a full
system suspend. We either need every application that ever uses
timer-driven behaviour to support setting its own timer slack on some
sort of external policy decision, or we need a way to let the kernel
force them to.
--
Matthew Garrett | mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org
From: Peter Zijlstra <peterz@infradead.org> Date: 2011-10-17 13:06:52
On Mon, 2011-10-17 at 13:46 +0100, Matthew Garrett wrote:
On Mon, Oct 17, 2011 at 11:38:03AM +0200, Thomas Gleixner wrote:
quoted
Unfortunately this is a full speed rolling trainwreck already. The
whole app space is made to encourage shitty applications. Android is
designed exactly in that way and it seems that all other desktop folks
have fully adopted that adsurdity.
Back when NOHZ was merged in the kernel, powertop made people fix crap
left and right in not time. Why should we add something which actively
fosters crappy applications today?
They're orthogonal. Sometimes you want timer-driven behaviour (how else
are you going to draw animations?) and that's obviously going to
generate wakeups. This is for the idle case, where the user is no longer
sitting in front of the machine but you don't want to trigger a full
system suspend. We either need every application that ever uses
timer-driven behaviour to support setting its own timer slack on some
sort of external policy decision, or we need a way to let the kernel
force them to.
No!! you want that application to stop drawing stuff that is invisible.
Setting your own timerslack for something you know is pointless is worse
than doing something pointless, its down right stupid.
Please, work with the X folks and make it an error to draw to invisible
surfaces. And yes, I know that composition makes that a non-trivial
problem. But at least the blank screen case should be trivial, and I
suspect there's more tractable cases as well. Mostly the desktop is
still a very static place and a few extra timer ticks for when you're
spinning your desktop cube around isn't going to be a problem.
From: Lennart Poettering <hidden> Date: 2011-10-17 13:55:29
On Mon, 17.10.11 09:34, Peter Zijlstra (peterz@infradead.org) wrote:
On Mon, 2011-10-17 at 04:22 +0100, Matthew Garrett wrote:
quoted
I agree. We can't assume perfect software, and I don't think *requiring*
the duplication of this functionality in every single session
application is sensible. We want to be able to shut down timer based
code when the session is idle. We could do this by exposing the slack in
/proc. We could do this by modifying every piece of code to listen for
session idle events and (independently) enact session-wide policy. Or we
could just accept that it's a problem that maps onto what people are
already using cgroups for and implement it in the same way.
So what about the app that is both screen oriented and has a server
part, say some multi-player game thing. Suppose you run one as a server
but leave the client idle (you go have dinner with a pretty lady instead
of playing quake, but leave your machine up to serve for your nerd
friends).
Should your friends get punished with a horrible gaming experience just
because you're having a good time IRL and your screen went blank?
Well, there's already an API to ensure that sessions are not considered
idle, which is used by movie players and such to disable screen
savers.
Sure pushing up timer slack will save you power, but it will also hurt
people, what will you do for them? The same that you do for those that
want to run a CGROUP=n kernel?
As you might have noticed already I am not overly concerned about
those. And anyway, if you don't enable the timer slack cgroup controller
we won't make use of it, it's that easy.
Lennart
--
Lennart Poettering - Red Hat, Inc.
From: Matthew Garrett <hidden> Date: 2011-10-17 14:12:09
On Mon, Oct 17, 2011 at 03:06:26PM +0200, Peter Zijlstra wrote:
On Mon, 2011-10-17 at 13:46 +0100, Matthew Garrett wrote:
quoted
They're orthogonal. Sometimes you want timer-driven behaviour (how else
are you going to draw animations?) and that's obviously going to
generate wakeups. This is for the idle case, where the user is no longer
sitting in front of the machine but you don't want to trigger a full
system suspend. We either need every application that ever uses
timer-driven behaviour to support setting its own timer slack on some
sort of external policy decision, or we need a way to let the kernel
force them to.
No!! you want that application to stop drawing stuff that is invisible.
Setting your own timerslack for something you know is pointless is worse
than doing something pointless, its down right stupid.
Whether or not you want the animation to carry on animating is policy,
and you need something to be the policy agent. Let's say firefox is
invisible. I now grab a copy of its window contents. What do I get?
Please, work with the X folks and make it an error to draw to invisible
surfaces. And yes, I know that composition makes that a non-trivial
problem. But at least the blank screen case should be trivial, and I
suspect there's more tractable cases as well. Mostly the desktop is
still a very static place and a few extra timer ticks for when you're
spinning your desktop cube around isn't going to be a problem.
So, just to be clear on this, you want to change the semantics of X and
modify every piece of userspace that currently uses X (because it'll now
otherwise crash when the screen blanks) in preference to merging a piece
of code that's functionally consistent with the rest of the cgroups
infrastructure?
--
Matthew Garrett | mjg59@srcf.ucam.org
From: Peter Zijlstra <peterz@infradead.org> Date: 2011-10-17 14:28:49
On Mon, 2011-10-17 at 15:11 +0100, Matthew Garrett wrote:
On Mon, Oct 17, 2011 at 03:06:26PM +0200, Peter Zijlstra wrote:
quoted
On Mon, 2011-10-17 at 13:46 +0100, Matthew Garrett wrote:
quoted
They're orthogonal. Sometimes you want timer-driven behaviour (how else
are you going to draw animations?) and that's obviously going to
generate wakeups. This is for the idle case, where the user is no longer
sitting in front of the machine but you don't want to trigger a full
system suspend. We either need every application that ever uses
timer-driven behaviour to support setting its own timer slack on some
sort of external policy decision, or we need a way to let the kernel
force them to.
No!! you want that application to stop drawing stuff that is invisible.
Setting your own timerslack for something you know is pointless is worse
than doing something pointless, its down right stupid.
Whether or not you want the animation to carry on animating is policy,
and you need something to be the policy agent. Let's say firefox is
invisible. I now grab a copy of its window contents. What do I get?
An XDamage and repaint from the X client, after which your copy will
complete and you get what you asked for?
quoted
Please, work with the X folks and make it an error to draw to invisible
surfaces. And yes, I know that composition makes that a non-trivial
problem. But at least the blank screen case should be trivial, and I
suspect there's more tractable cases as well. Mostly the desktop is
still a very static place and a few extra timer ticks for when you're
spinning your desktop cube around isn't going to be a problem.
So, just to be clear on this, you want to change the semantics of X and
modify every piece of userspace that currently uses X (because it'll now
otherwise crash when the screen blanks)
Or even when I minimize firefox. That said, ff will probably crash as
soon as I open a second tab because the retarded thing will very likely
continue animating everything on the invisible tab anyway.
You could start by making the X lib of the day, is that XCB these days?,
issue an error print (you get plenty of those anyway) and progress to
full on crashing later.
This gives developers a migration window and incentive to fix up their
apps.
in preference to merging a piece
of code that's functionally consistent with the rest of the cgroups
infrastructure?
Yep.. because as of yet there isn't a sane use-case to warrant adding
the maintenance burden. Any cgroup controller is functionally
consistent, per definition, that doesn't make it useful or even sane.
From: Arjan van de Ven <hidden> Date: 2011-10-17 14:35:46
On 10/17/2011 7:28 AM, Peter Zijlstra wrote:
Or even when I minimize firefox. That said, ff will probably crash as
soon as I open a second tab because the retarded thing will very
likely continue animating everything on the invisible tab anyway. You
could start by making the X lib of the day, is that XCB these days?,
issue an error print (you get plenty of those anyway) and progress to
full on crashing later. This gives developers a migration window and
incentive to fix up their apps.
so back in the time that worked on a project that used Qt as their
toolkit (geez is it that long ago already ;-) )... we fixed Qt to stop
doing this.
The right level for this sort of thing is the toolkit level (which by
and large also does the animations), not Xlib.
The toolkit level also will then need to provide the right notifications
to the app for things the toolkit does not do
(eg "we're at least partially visible" versus "now none of our pixels
are on the screen").
It ended up being a thing for the toolkit and a minor tweak in the
compositor... and it worked quite ok, the app guys actually
asked for the API (because they knew I would beat them up for getting it
wrong)...
doing things on the xlib level (or even X level) means you take away the
chance for the App(tm) to do things the right way;
make it easy for the app, not hard.
From: Matthew Garrett <hidden> Date: 2011-10-17 14:40:59
On Mon, Oct 17, 2011 at 04:28:27PM +0200, Peter Zijlstra wrote:
On Mon, 2011-10-17 at 15:11 +0100, Matthew Garrett wrote:
quoted
Whether or not you want the animation to carry on animating is policy,
and you need something to be the policy agent. Let's say firefox is
invisible. I now grab a copy of its window contents. What do I get?
An XDamage and repaint from the X client, after which your copy will
complete and you get what you asked for?
An XDamage and then an asynchronous RPC call to the remote server to
identify the contents of the next frame before drawing them, plus some
sort of new synchronisation mechanism for blocking the X query until
that point?
quoted
in preference to merging a piece
of code that's functionally consistent with the rest of the cgroups
infrastructure?
Yep.. because as of yet there isn't a sane use-case to warrant adding
the maintenance burden. Any cgroup controller is functionally
consistent, per definition, that doesn't make it useful or even sane.
Timers are a resource. People want to manage that resource. cgroups are
a convenient mechanism for managing resources.
--
Matthew Garrett | mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org
From: Peter Zijlstra <peterz@infradead.org> Date: 2011-10-17 14:45:56
On Mon, 2011-10-17 at 07:35 -0700, Arjan van de Ven wrote:
On 10/17/2011 7:28 AM, Peter Zijlstra wrote:
quoted
Or even when I minimize firefox. That said, ff will probably crash as
soon as I open a second tab because the retarded thing will very
likely continue animating everything on the invisible tab anyway. You
could start by making the X lib of the day, is that XCB these days?,
issue an error print (you get plenty of those anyway) and progress to
full on crashing later. This gives developers a migration window and
incentive to fix up their apps.
so back in the time that worked on a project that used Qt as their
toolkit (geez is it that long ago already ;-) )... we fixed Qt to stop
doing this.
The right level for this sort of thing is the toolkit level (which by
and large also does the animations), not Xlib.
The toolkit level also will then need to provide the right notifications
to the app for things the toolkit does not do
(eg "we're at least partially visible" versus "now none of our pixels
are on the screen").
It ended up being a thing for the toolkit and a minor tweak in the
compositor... and it worked quite ok, the app guys actually
asked for the API (because they knew I would beat them up for getting it
wrong)...
doing things on the xlib level (or even X level) means you take away the
chance for the App(tm) to do things the right way;
make it easy for the app, not hard.
I'm not immediately seeing how enforcing these semantics through X makes
it harder for the app, or would in fact get in the way of the toolkit
providing similar features.
But they key point to my argument is that at whatever level you're going
to do this, it needs to be unforgivingly enforced. Otherwise its useless
because people either don't know or don't care.
Esp. when you then go do crap like proposed and fudge the timers so that
the impact of doing it wrong is dampened.
From: Peter Zijlstra <peterz@infradead.org> Date: 2011-10-17 14:49:57
On Mon, 2011-10-17 at 15:40 +0100, Matthew Garrett wrote:
On Mon, Oct 17, 2011 at 04:28:27PM +0200, Peter Zijlstra wrote:
quoted
On Mon, 2011-10-17 at 15:11 +0100, Matthew Garrett wrote:
quoted
Whether or not you want the animation to carry on animating is policy,
and you need something to be the policy agent. Let's say firefox is
invisible. I now grab a copy of its window contents. What do I get?
An XDamage and repaint from the X client, after which your copy will
complete and you get what you asked for?
An XDamage and then an asynchronous RPC call to the remote server to
identify the contents of the next frame before drawing them, plus some
sort of new synchronisation mechanism for blocking the X query until
that point?
Why would this be a problem?
I mean, why would getting a copy of an otherwise invisible surface be a
performance sensitive path? If the compositor needs the surface it would
make it visible and send the XDamage once and keep it visible henceforth
until the time it again becomes invisible, at which point you have to
stop updates again.
The normal case is where things are visible and things are kept
up-to-date, that doesn't change.
quoted
quoted
in preference to merging a piece
of code that's functionally consistent with the rest of the cgroups
infrastructure?
Yep.. because as of yet there isn't a sane use-case to warrant adding
the maintenance burden. Any cgroup controller is functionally
consistent, per definition, that doesn't make it useful or even sane.
Timers are a resource. People want to manage that resource. cgroups are
a convenient mechanism for managing resources.
Yes, and a ball is round (unless you're a USA-ian, in which case they're
ovoid), what's your point?
From: Matthew Garrett <hidden> Date: 2011-10-17 15:00:08
On Mon, Oct 17, 2011 at 04:49:29PM +0200, Peter Zijlstra wrote:
On Mon, 2011-10-17 at 15:40 +0100, Matthew Garrett wrote:
quoted
On Mon, Oct 17, 2011 at 04:28:27PM +0200, Peter Zijlstra wrote:
quoted
An XDamage and repaint from the X client, after which your copy will
complete and you get what you asked for?
An XDamage and then an asynchronous RPC call to the remote server to
identify the contents of the next frame before drawing them, plus some
sort of new synchronisation mechanism for blocking the X query until
that point?
Why would this be a problem?
I mean, why would getting a copy of an otherwise invisible surface be a
performance sensitive path? If the compositor needs the surface it would
make it visible and send the XDamage once and keep it visible henceforth
until the time it again becomes invisible, at which point you have to
stop updates again.
I'm not saying that it's a problem. I'm saying that your approach
changes behavioural semantics in a way that may violate application
expectations just as surely as changing the timer behaviour does.
There's no free approach.
quoted
Timers are a resource. People want to manage that resource. cgroups are
a convenient mechanism for managing resources.
Yes, and a ball is round (unless you're a USA-ian, in which case they're
ovoid), what's your point?
If there's no reason to want to manage that resource, why do we support
timer slack at all?
--
Matthew Garrett | mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org
From: Peter Zijlstra <peterz@infradead.org> Date: 2011-10-17 15:11:20
On Mon, 2011-10-17 at 15:59 +0100, Matthew Garrett wrote:
On Mon, Oct 17, 2011 at 04:49:29PM +0200, Peter Zijlstra wrote:
quoted
On Mon, 2011-10-17 at 15:40 +0100, Matthew Garrett wrote:
quoted
On Mon, Oct 17, 2011 at 04:28:27PM +0200, Peter Zijlstra wrote:
quoted
An XDamage and repaint from the X client, after which your copy will
complete and you get what you asked for?
An XDamage and then an asynchronous RPC call to the remote server to
identify the contents of the next frame before drawing them, plus some
sort of new synchronisation mechanism for blocking the X query until
that point?
Why would this be a problem?
I mean, why would getting a copy of an otherwise invisible surface be a
performance sensitive path? If the compositor needs the surface it would
make it visible and send the XDamage once and keep it visible henceforth
until the time it again becomes invisible, at which point you have to
stop updates again.
I'm not saying that it's a problem. I'm saying that your approach
changes behavioural semantics in a way that may violate application
expectations just as surely as changing the timer behaviour does.
There's no free approach.
I'm not saying its free, I'm saying its a much better approach since it
gets rid of the entire problem instead of papering over the worst of it.
quoted
quoted
Timers are a resource. People want to manage that resource. cgroups are
a convenient mechanism for managing resources.
Yes, and a ball is round (unless you're a USA-ian, in which case they're
ovoid), what's your point?
If there's no reason to want to manage that resource, why do we support
timer slack at all?
So that individual applications can provide their timing tolerance and
the OS can group these timers in order to optimize idle time or whatnot.
Indiscriminately changing the slack for a whole group of otherwise
unrelated applications will violate their timing tolerances and break
them in non-obvious ways.
What I'm saying is that its much better to attack the primary source of
evil in a manner that is unforgiving instead of trying to avoid the
worst excesses and cause non-obvious breakage.
For a while people were promoting the idea that its good to be lenient
in what you accept as input and strict in what you send out. I think
people are starting to realize that was a horrid mistake since now
they're getting utter crap and people don't even know what right is
anymore.
From: Peter Zijlstra <peterz@infradead.org> Date: 2011-10-17 15:18:52
On Mon, 2011-10-17 at 17:11 +0200, Peter Zijlstra wrote:
For a while people were promoting the idea that its good to be lenient
in what you accept as input and strict in what you send out. I think
people are starting to realize that was a horrid mistake since now
they're getting utter crap and people don't even know what right is
anymore.
Since different apps might have treated similar non-conformant input
differently and now no single behaviour is correct.
I think either dhowells or dwmw2 had a good blog post on that a while
back.
From: Matthew Garrett <hidden> Date: 2011-10-17 15:19:40
On Mon, Oct 17, 2011 at 05:11:00PM +0200, Peter Zijlstra wrote:
On Mon, 2011-10-17 at 15:59 +0100, Matthew Garrett wrote:
quoted
I'm not saying that it's a problem. I'm saying that your approach
changes behavioural semantics in a way that may violate application
expectations just as surely as changing the timer behaviour does.
There's no free approach.
I'm not saying its free, I'm saying its a much better approach since it
gets rid of the entire problem instead of papering over the worst of it.
It solves it for a specific case, ie animations. Any other timer driven
behaviour continues. It really does need to be tied to session idle, not
application visibility, and enforcement at the X level does nothing to
help that.
--
Matthew Garrett | mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org
From: Peter Zijlstra <peterz@infradead.org> Date: 2011-10-17 15:21:27
On Mon, 2011-10-17 at 16:19 +0100, Matthew Garrett wrote:
On Mon, Oct 17, 2011 at 05:11:00PM +0200, Peter Zijlstra wrote:
quoted
On Mon, 2011-10-17 at 15:59 +0100, Matthew Garrett wrote:
quoted
I'm not saying that it's a problem. I'm saying that your approach
changes behavioural semantics in a way that may violate application
expectations just as surely as changing the timer behaviour does.
There's no free approach.
I'm not saying its free, I'm saying its a much better approach since it
gets rid of the entire problem instead of papering over the worst of it.
It solves it for a specific case, ie animations. Any other timer driven
behaviour continues. It really does need to be tied to session idle, not
application visibility, and enforcement at the X level does nothing to
help that.
Well what other cases are there? Can we enumerate them and come up with
similar solutions?
Hard enforcement is very much better than papering over because it makes
the individual developer instantly aware that he's got a problem.
From: Matthew Garrett <hidden> Date: 2011-10-17 15:31:56
On Mon, Oct 17, 2011 at 05:21:10PM +0200, Peter Zijlstra wrote:
Well what other cases are there? Can we enumerate them and come up
with similar solutions?
Javascript has timers. We execute rather a lot of javascript from
sources we can't influence at all.
--
Matthew Garrett | mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org
Hard enforcement is very much better than papering over because it makes
the individual developer instantly aware that he's got a problem.
Not always
If you do weird container crap with timers than app authors will simply
point out that the weird container crap is buggy as it works properly in
a normal environment.
From: Peter Zijlstra <peterz@infradead.org> Date: 2011-10-17 16:34:25
On Mon, 2011-10-17 at 16:48 +0100, Alan Cox wrote:
quoted
Hard enforcement is very much better than papering over because it makes
the individual developer instantly aware that he's got a problem.
Not always
If you do weird container crap with timers than app authors will simply
point out that the weird container crap is buggy as it works properly in
a normal environment.
Oh agreed. I never said the hard enforcement would/should rely on
container crap. I'm very much in favour of a machine that's fully
functional with a CGROUP=n kernel, thank you very much.
Sadly a number of (userspace) wankers (some included on this thread)
seem hell bent on making that impossible.
From: Peter Zijlstra <peterz@infradead.org> Date: 2011-10-17 16:37:05
On Mon, 2011-10-17 at 16:31 +0100, Matthew Garrett wrote:
On Mon, Oct 17, 2011 at 05:21:10PM +0200, Peter Zijlstra wrote:
quoted
Well what other cases are there? Can we enumerate them and come up
with similar solutions?
Javascript has timers. We execute rather a lot of javascript from
sources we can't influence at all.
Which brings me to yet another gripe I've got with firefox, _WHY_ does
it run javascript for tabs I can't see? Simply freeze the interpreter.
Then again, what does JavaScript do with these timers? I don't really
see how javascript/random-native-binary are really different, something
needs doing. What something?
From: Matthew Garrett <hidden> Date: 2011-10-17 16:49:47
On Mon, Oct 17, 2011 at 06:36:44PM +0200, Peter Zijlstra wrote:
On Mon, 2011-10-17 at 16:31 +0100, Matthew Garrett wrote:
quoted
On Mon, Oct 17, 2011 at 05:21:10PM +0200, Peter Zijlstra wrote:
quoted
Well what other cases are there? Can we enumerate them and come up
with similar solutions?
Javascript has timers. We execute rather a lot of javascript from
sources we can't influence at all.
Which brings me to yet another gripe I've got with firefox, _WHY_ does
it run javascript for tabs I can't see? Simply freeze the interpreter.
Because people expect gmail to provide them with status updates even if
it's not the foreground tab.
Then again, what does JavaScript do with these timers? I don't really
see how javascript/random-native-binary are really different, something
needs doing. What something?
I agree that the thing that needs doing probably involves web developers
and threats of implied violence, but I suspect that web developers are
being created faster than we can reeducate them.
--
Matthew Garrett | mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org