wrong priority calc - SIMPLE test case
Subsystems (2)
Quoted 13 lines · Mike Galbraith
Quoted 11 lines · Con Kolivas
Quoted 7 lines · Mike Galbraith
Quoted 3 lines · Con Kolivas
See my followup patches that I have posted following "[PATCH 0/5] sched - interactivity updates". The first 3 patches are what you tested. These patches are being put up for testing hopefully in -mm.
Then the (buggy) version of my simple throttling patch will need to come out. (which is OK, I have a debugged potent++ version)
Your code need not be mutually exclusive with mine. I've simply damped the current behaviour. Your sanity throttling is a good idea.
Quoted 6 lines
I didn't mean to imply that they're mutually exclusive, and after doing some testing, I concluded that it (or something like it) is definitely still needed. The version that's in mm2 _is_ buggy however, so ripping it back out wouldn't hurt my delicate little feelings one bit. In fact, it would give me some more time to instrument and test integration with your changes.
Ok I've communicated this to Andrew (cc'ed here too) so he should remove your patch pending a new version from you.
Quoted 2 lines
(Which I think are good btw because they remove what I considered to be warts; the pipe and uninterruptible sleep barriers.
Yes I felt your abuse wrt to these in an earlier email...
Quoted 2 lines
Um... try irman2
now... pure evilness)
Hrm I've been using staircase which is immune for so long I'd all but forgotten about this test case. Looking at your code I assume your changes should help this?
Con
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 21 lines · Con Kolivas
Quoted 13 lines · Mike Galbraith
Quoted 11 lines · Con Kolivas
Quoted 7 lines · Mike Galbraith
Quoted 3 lines · Con Kolivas
See my followup patches that I have posted following "[PATCH 0/5] sched - interactivity updates". The first 3 patches are what you tested. These patches are being put up for testing hopefully in -mm.
Then the (buggy) version of my simple throttling patch will need to come out. (which is OK, I have a debugged potent++ version)
Your code need not be mutually exclusive with mine. I've simply damped the current behaviour. Your sanity throttling is a good idea.
Quoted 6 lines
I didn't mean to imply that they're mutually exclusive, and after doing some testing, I concluded that it (or something like it) is definitely still needed. The version that's in mm2 _is_ buggy however, so ripping it back out wouldn't hurt my delicate little feelings one bit. In fact, it would give me some more time to instrument and test integration with your changes.
Quoted 2 lines
Ok I've communicated this to Andrew (cc'ed here too) so he should remove your patch pending a new version from you.
(Ok, it took a while what with setting up a new test box, testing this and that, RL etc etc.)
What do you think of the below as an evaluation patch? It leaves the bits I'd really like to change (INTERACTIVE_SLEEP() for one), so it can be switched on and off for easy comparison and regression testing.
I really didn't want to add more to the task struct, but after trying different things, a timeout was the most effective means of keeping the nice burst aspect of the interactivity logic but still make sure that a burst doesn't turn into starvation.
The workings are dirt simple just as before. The goal is to keep sleep_avg and slice_avg balanced. When an imbalance starts, immediately cut off interactive bonus points. If the imbalance doesn't correct itself through normal sleep_avg usage, we'll soon hit the (1 dynamic prio) trigger point, which starts a countdown toward active intervention. The default setting is that a task can run at higher dynamic priority than it's cpu usage can justify for 5 seconds. After than, we start trying to work off the deficit, and if we don't succeeded within another second (ie it was a big deficit), we demote the offender to the rank his cpu usage indicates.
The strategy works well enough to take the wind out of irman2's sails, and interactive tasks can still do a nice reasonable burst of activity without being evicted. Down side to starvation control is that X is sometimes a serious cpu user, and _can_ end up in the expired array (not nice under load). I personally don't think that's a show stopper though... all you have to do is tell the scheduler that what it already noticed, that X is a piggy, but an OK piggy by renicing it. It becomes immune from active throttling, and all is well. I know that's not going to be popular, but you just can't let X have free rein without leaving the barn door wide open. (maybe that switch should stay since the majority of boxen are workstations, and default to off?).
'nuff words, patch follows.
-Mike
include/linux/sched.h renamed from include/linux/sched.h.org +1 -0
@@ -722,6 +722,7 @@unsigned short ioprio;unsigned long sleep_avg; +unsigned long slice_avg, last_slice, throttle_stamp;unsigned long long timestamp, last_ran;unsigned long long sched_time;/* sched_clock time spent running */ enum sleep_type sleep_type;
include/linux/sysctl.h renamed from include/linux/sysctl.h.org +2 -0
@@ -147,6 +147,8 @@KERN_SETUID_DUMPABLE =69 ,/* int: behaviour of dumps for setuid core */ KERN_SPIN_RETRY =70 ,/* int: number of spinlock retries */ KERN_ACPI_VIDEO_FLAGS =71 ,/* int: flags for setting up video after ACPI sleep */ +KERN_SCHED_THROTTLE1 =72 ,/* int: sleep_avg throttling enabled */ + KERN_SCHED_THROTTLE2=73, /* int: throttling grace period in secs */ };
kernel/sched.c renamed from kernel/sched.c.org +130 -8
234 lines not on this page · raw message
kernel/sysctl.c renamed from kernel/sysctl.c.org +31 -6
@@ -69,6 +69,9 @@extern int pid_max_min, pid_max_max;extern int sysctl_drop_caches;extern int percpu_pagelist_fraction; +extern int throttle; +extern int throttle_secs; +extern int throttle_secs_max;#if defined(CONFIG_X86_LOCAL_APIC ) && defined(CONFIG_X86 )int unknown_nmi_panic;
@@ -224,6 +227,12 @@ { .ctl_name = 0 } }; +/* Constants for minimum and maximum testing in vm_table and +* kern_table. We use these as one-element integer vectors. */ +static int zero; +static int one =1 ; +static int one_hundred =100 ; +static ctl_table kern_table[] = { { .ctl_name =KERN_OSTYPE ,
@@ -666,15 +675,31 @@ .proc_handler = &proc_dointvec, },#endif + { + .ctl_name = KERN_SCHED_THROTTLE1, + .procname = "sched_throttle", + .data = &throttle, + .maxlen = sizeof (int), + .mode = 0644, + .proc_handler = &proc_dointvec_minmax, + .strategy = &sysctl_intvec, + .extra1 = &zero, + .extra2 = &one, + }, + { + .ctl_name = KERN_SCHED_THROTTLE2, + .procname = "sched_throttle_secs", + .data = &throttle_secs, + .maxlen = sizeof (int), + .mode = 0644, + .proc_handler = &proc_dointvec_minmax, + .strategy = &sysctl_intvec, + .extra1 = &zero, + .extra2 = &throttle_secs_max, + }, { .ctl_name = 0 } }; -/* Constants for minimum and maximum testing in vm_table. -We use these as one-element integer vectors. */ -static int zero; -static int one_hundred =100 ; - -static ctl_table vm_table[] = { { .ctl_name =VM_OVERCOMMIT_MEMORY ,
Quoted 20 lines · MIke Galbraith
What do you think of the below as an evaluation patch? It leaves the bits I'd really like to change (
INTERACTIVE_SLEEP()for one), so it can be switched on and off for easy comparison and regression testing.I really didn't want to add more to the task struct, but after trying different things, a timeout was the most effective means of keeping the nice burst aspect of the interactivity logic but still make sure that a burst doesn't turn into starvation.
The workings are dirt simple just as before. The goal is to keep
sleep_avgandslice_avgbalanced. When an imbalance starts, immediately cut off interactive bonus points. If the imbalance doesn't correct itself through normalsleep_avgusage, we'll soon hit the (1 dynamic prio) trigger point, which starts a countdown toward active intervention. The default setting is that a task can run at higher dynamic priority than it's cpu usage can justify for 5 seconds. After than, we start trying to work off the deficit, and if we don't succeeded within another second (ie it was a big deficit), we demote the offender to the rank his cpu usage indicates.
Quoted 11 lines
The strategy works well enough to take the wind out of irman2's sails, and interactive tasks can still do a nice reasonable burst of activity without being evicted. Down side to starvation control is that X is sometimes a serious cpu user, and _can_ end up in the expired array (not nice under load). I personally don't think that's a show stopper though... all you have to do is tell the scheduler that what it already noticed, that X is a piggy, but an OK piggy by renicing it. It becomes immune from active throttling, and all is well. I know that's not going to be popular, but you just can't let X have free rein without leaving the barn door wide open. (maybe that switch should stay since the majority of boxen are workstations, and default to off?).
Sounds good but I have to disagree on the X renice thing. It's not that I have a religious objection to renicing things. The problem is that our mainline scheduler determines latency also by nice level. This means that if you -renice a bursty cpu hog like X, then audio applications will fail unless they too are reniced. Try it on your patch.
Con
Quoted 35 lines · Con Kolivas
Quoted 20 lines · MIke Galbraith
What do you think of the below as an evaluation patch? It leaves the bits I'd really like to change (
INTERACTIVE_SLEEP()for one), so it can be switched on and off for easy comparison and regression testing.I really didn't want to add more to the task struct, but after trying different things, a timeout was the most effective means of keeping the nice burst aspect of the interactivity logic but still make sure that a burst doesn't turn into starvation.
The workings are dirt simple just as before. The goal is to keep
sleep_avgandslice_avgbalanced. When an imbalance starts, immediately cut off interactive bonus points. If the imbalance doesn't correct itself through normalsleep_avgusage, we'll soon hit the (1 dynamic prio) trigger point, which starts a countdown toward active intervention. The default setting is that a task can run at higher dynamic priority than it's cpu usage can justify for 5 seconds. After than, we start trying to work off the deficit, and if we don't succeeded within another second (ie it was a big deficit), we demote the offender to the rank his cpu usage indicates.Quoted 11 lines
The strategy works well enough to take the wind out of irman2's sails, and interactive tasks can still do a nice reasonable burst of activity without being evicted. Down side to starvation control is that X is sometimes a serious cpu user, and _can_ end up in the expired array (not nice under load). I personally don't think that's a show stopper though... all you have to do is tell the scheduler that what it already noticed, that X is a piggy, but an OK piggy by renicing it. It becomes immune from active throttling, and all is well. I know that's not going to be popular, but you just can't let X have free rein without leaving the barn door wide open. (maybe that switch should stay since the majority of boxen are workstations, and default to off?).
Quoted 3 lines
Sounds good but I have to disagree on the X renice thing. It's not that I have a religious objection to renicing things. The problem is that our mainline scheduler determines latency also by nice level. This means that if you -renice a bursty cpu hog like X, then audio applications will fail unless
they too are reniced. Try it on your patch.
On the other hand, if X were reniced it would be possible to make the interactive bonus mechanism more strict on what it considers to be interactive. As I see it the main reason that non interactive sleeps get any consideration at all in determining whether a task is interactive is to make sure that X is classified interactive.
One of the things that I've noticed about the X server (with instrumented systems) is the its proportion of interruptible sleeps to total sleeps goes down when it becomes CPU intensive. This is because the high CPU usage is usually related to screen updates (e.g. try "ls -R /" in an xterm or similar) and not keyboard or mouse input. This means that during these periods the X server would lose most of its interactive bonus and just rely on its niceness allowing genuine interactive tasks to pip it (provided that X's nice value is sufficiently small e.g. 5).
Of course, for this to work all of the instances where interruptible sleeps aren't interactive would need to be labelled TASK_NONINTERACTIVE which would be a big job.
Anyway just my 2c worth.
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
Quoted 14 lines · Con Kolivas
Quoted 12 lines · MIke Galbraith
The strategy works well enough to take the wind out of irman2's sails, and interactive tasks can still do a nice reasonable burst of activity without being evicted. Down side to starvation control is that X is sometimes a serious cpu user, and _can_ end up in the expired array (not nice under load). I personally don't think that's a show stopper though... all you have to do is tell the scheduler that what it already noticed, that X is a piggy, but an OK piggy by renicing it. It becomes immune from active throttling, and all is well. I know that's not going to be popular, but you just can't let X have free rein without leaving the barn door wide open. (maybe that switch should stay since the majority of boxen are workstations, and default to off?).
Quoted 5 lines
Sounds good but I have to disagree on the X renice thing. It's not that I have a religious objection to renicing things. The problem is that our mainline scheduler determines latency also by nice level. This means that if you -renice a bursty cpu hog like X, then audio applications will fail unless they too are reniced. Try it on your patch.
True. If I renice, X can/will stomp all over xmms. However, I can use up to 30% cpu sustained before I would need to renice, so in the general case, this patch actually improves latency because it will pull X out of prio 16 much much sooner than before. In this regard, it makes sense to increase the scope, and throttle kernel threads as well. What really _should_ happen from the latency perspective is that as soon as we detect a prio boundary crossing, we should downgrade the task a level immediately, and then wait to see how things develope. That would allow the truely low latency tasks to preempt. When I compile a kernel for my PIII/500 over nfs with my P4, knfsd eats about 40% of the PIII's cpu, and all of it is there along side xmms.
What would be nice for the X case is a scheduling class that only meant I'm always in the active array. Open multimedia hardware, and you stay active, but can be throttled under load without turning the box into a brick.
Oh, while I'm thinking of it, if this thing makes it past discussion and evaluation, I think my definition of idle task boost should be used whether the active measures are applied or not. The comments on that code say idle tasks will only be promoted into the very bottom of the interactive priority range via one long sleep. INTERACTIVE_SLEEP_AVG() does that, and it helps. That's not enough however. What allows me to defeat [1] irman2 isn't scrubbing to perfectly match how much it sleeps, it is designed to sleep long between burns and hand over the baton to the next partner in crime, so if I measured slice_avg purely from issue time, slice_avg would match sleep_avg, and it would still be deadly. Detecting the beginning of a new slice and moving the stamp forward to match beginning of execution is what defeats it... the time he spends trading the cpu with his evil twins doesn't count.
-Mike
1. Defeat is actually too strong a word, it is still one hell of an unpleasant cpu hog in it's total... as any threaded app may be.