Modular Scheduler Core and Completely Fair Scheduler [CFS]
Subsystems (11)
PATCH 1/1 Modular Scheduler Core and Completely Fair Scheduler [CFS]
[announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS]
i'm pleased to announce the first release of the "Modular Scheduler Core and Completely Fair Scheduler [CFS]" patchset:
http://redhat.com/~mingo/cfs-scheduler/sched-modular+cfs.patch
This project is a complete rewrite of the Linux task scheduler. My goal is to address various feature requests and to fix deficiencies in the vanilla scheduler that were suggested/found in the past few years, both for desktop scheduling and for server scheduling workloads.
[ QuickStart: apply the patch to v2.6.21-rc6, recompile, reboot. The
new scheduler will be active by default and all tasks will default to the new SCHED_FAIR interactive scheduling class. ]
Highlights are:
- the introduction of Scheduling Classes: an extensible hierarchy of scheduler modules. These modules encapsulate scheduling policy details and are handled by the scheduler core without the core code assuming about them too much.
- sched_fair.c implements the 'CFS desktop scheduler': it is a replacement for the vanilla scheduler's SCHED_OTHER interactivity code.
i'd like to give credit to Con Kolivas for the general approach here:
he has proven via RSDL/SD that 'fair scheduling' is possible and that it results in better desktop scheduling. Kudos Con!
The CFS patch uses a completely different approach and implementation from RSDL/SD. My goal was to make CFS's interactivity quality exceed that of RSDL/SD, which is a high standard to meet :-) Testing feedback is welcome to decide this one way or another. [ and, in any case, all of SD's logic could be added via a kernel/sched_sd.c module as well, if Con is interested in such an approach. ]
CFS's design is quite radical: it does not use runqueues, it uses a time-ordered rbtree to build a 'timeline' of future task execution, and thus has no 'array switch' artifacts (by which both the vanilla scheduler and RSDL/SD are affected).
CFS uses nanosecond granularity accounting and does not rely on any jiffies or other HZ detail. Thus the CFS scheduler has no notion of 'timeslices' and has no heuristics whatsoever. There is only one central tunable:
/proc/sys/kernel/sched_granularity_ns
which can be used to tune the scheduler from 'desktop' (low latencies) to 'server' (good batching) workloads. It defaults to a setting suitable for desktop workloads. SCHED_BATCH is handled by the CFS scheduler module too.
due to its design, the CFS scheduler is not prone to any of the 'attacks' that exist today against the heuristics of the stock
scheduler: fiftyp.c, thud.c, chew.c, ring-test.c, massive_intr.c all work fine and do not impact interactivity and produce the expected behavior.
the CFS scheduler has a much stronger handling of nice levels and
SCHED_BATCH: both types of workloads should be isolated much more agressively than under the vanilla scheduler.
( another rdetail: due to nanosec accounting and timeline sorting,
sched_yield() support is very simple under CFS, and in fact under CFS sched_yield() behaves much better than under any other scheduler i have tested so far. )
- sched_rt.c implements SCHED_FIFO and SCHED_RR semantics, in a simpler way than the vanilla scheduler does. It uses 100 runqueues (for all 100 RT priority levels, instead of 140 in the vanilla scheduler) and it needs no expired array.
- reworked/sanitized SMP load-balancing: the runqueue-walking assumptions are gone from the load-balancing code now, and iterators of the scheduling modules are used. The balancing code got quite a bit simpler as a result.
the core scheduler got smaller by more than 700 lines:
kernel/sched.c | 1454 ++++++++++++++++------------------------------------------------ 1 file changed, 372 insertions(+), 1082 deletions(-)
and even adding all the scheduling modules, the total size impact is relatively small:
18 files changed, 1454 insertions(+), 1133 deletions(-)
most of the increase is due to extensive comments. The kernel size impact is in fact a small negative:
text data bss dec hex filename 23366 4001 24 27391 6aff kernel/sched.o.vanilla 24159 2705 56 26920 6928 kernel/sched.o.CFS
(this is mainly due to the benefit of getting rid of the expired array and its data structure overhead.)
thanks go to Thomas Gleixner and Arjan van de Ven for review of this patchset.
as usual, any sort of feedback, bugreports, fixes and suggestions are more than welcome,
Ingo
Quoted 1 line · Ingo Molnar
[announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS]
...
Quoted 6 lines
The CFS patch uses a completely different approach and implementation from RSDL/SD. My goal was to make CFS's interactivity quality exceed that of RSDL/SD, which is a high standard to meet :-) Testing feedback is welcome to decide this one way or another. [ and, in any case, all of SD's logic could be added via a
kernel/sched_sd.cmodule as well, if Con is interested in such an approach. ]
Ingo,
Con has been asking for module support for years if I understand your patch corectly. You'll also need this for -rt as well with regards to bandwidth scheduling. Good to see that you're moving in this direction.
bill
Quoted 2 lines · Bill Huey
Con has been asking for module support for years if I understand your patch corectly. [...]
Yeah. Note that there are some subtle but crutial differences between PlugSched (which Con used, and which i opposed in the past) and this approach.
PlugSched cuts the interfaces at a high level in a monolithic way and introduces kernel/scheduler.c that uses one pluggable scheduler (represented via the 'scheduler' global template) at a time.
while in this CFS patchset i'm using modularization ('scheduler classes') to simplify the _existing_ multi-policy implementation of the scheduler. These 'scheduler classes' are in a hierarchy and are stacked on top of each other. They are in use at once. Currently there's two of
them: sched_ops_rt is stacked ontop of sched_ops_fair. Fortunately the performance impact is minimal.
So scheduler classes are mainly a simplification of the design of the scheduler - not just a mere facility to select multiple schedulers. Their ability to also facilitate easier experimentation with schedulers is 'just' a happy side-effect. So all in one: it's a fairly different model from PlugSched (and that's why i didnt reuse PlugSched) - but there's indeed overlap.
Quoted 2 lines
[...] You'll also need this for -rt as well with regards to bandwidth scheduling.
yeah.
scheduler classes are also useful for other purposes like containers and virtualization, hierarchical/group scheduling, security encapsulation, etc. - features that can be on-demand layered, and which we dont necessarily want to have enabled all the time.
Quoted 1 line
[...] Good to see that you're moving in this direction.
thanks! :)
Ingo
Quoted 6 lines · Ingo Molnar
Yeah. Note that there are some subtle but crutial differences between PlugSched (which Con used, and which i opposed in the past) and this approach.
PlugSched cuts the interfaces at a high level in a monolithic way and introduceskernel/scheduler.cthat uses one pluggable scheduler (represented via the 'scheduler' global template) at a time.
What I originally did did so for a good reason, which was that it was intended to support far more radical reorganizations, for instance, things that changed the per-cpu runqueue affairs for gang scheduling. I wrote a top-level driver that did support scheduling classes in a similar fashion, though it didn't survive others maintaining the patches.
-- wli
Quoted 8 lines · William Lee Irwin III
Quoted 6 lines · Ingo Molnar
Yeah. Note that there are some subtle but crutial differences between PlugSched (which Con used, and which i opposed in the past) and this approach.
PlugSched cuts the interfaces at a high level in a monolithic way and introduceskernel/scheduler.cthat uses one pluggable scheduler (represented via the 'scheduler' global template) at a time.
Quoted 5 lines
What I originally did did so for a good reason, which was that it was intended to support far more radical reorganizations, for instance, things that changed the per-cpu runqueue affairs for gang scheduling. I wrote a top-level driver that did support scheduling classes in a similar fashion, though it didn't survive others maintaining the patches.
Also, gang scheduling is needed to solve virtualization issues regarding spinlocks in a guest image. You could potentally be spinning on a thread that isn't currently running which, needless to say, is very bad.
bill
Quoted 6 lines · William Lee Irwin III
What I originally did did so for a good reason, which was that it was intended to support far more radical reorganizations, for instance, things that changed the per-cpu runqueue affairs for gang scheduling. I wrote a top-level driver that did support scheduling classes in a similar fashion, though it didn't survive others maintaining the patches.
yeah - i looked at plugsched-6.5-for-2.6.20.patch in particular.
Ingo
Quoted 11 lines · Ingo Molnar
and even adding all the scheduling modules, the total size impact is relatively small:
18 files changed, 1454 insertions(+), 1133 deletions(-)most of the increase is due to extensive comments. The kernel size impact is in fact a small negative:
text data bss dec hex filename 23366 4001 24 27391 6aff kernel/sched.o.vanilla 24159 2705 56 26920 6928 kernel/sched.o.CFS
update: these were older numbers, here are the stats redone with the latest patch:
text data bss dec hex filename
23366 4001 24 27391 6aff kernel/sched.o.vanilla
23671 4548 24 28243 6e53 kernel/sched.o.sd.v40
23349 2705 24 26078 65de kernel/sched.o.cfsso CFS is now a win both for text and for data size :)
Ingo
Ingo Molnar napisał(a):
Quoted 7 lines
[announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS]
i'm pleased to announce the first release of the "Modular Scheduler Core and Completely Fair Scheduler [CFS]" patchset:
http://redhat.com/~mingo/cfs-scheduler/sched-modular+cfs.patch
Friday the 13th, my lucky day :).
/mnt/md0/devel/linux-msc-cfs/usr/include/linux/sched.h requires linux/rbtree.h, which does not exist in exported headers
make[3]: *** No rule to make target /mnt/md0/devel/linux-msc-cfs/usr/include/linux/.check.sched.h', needed by __headerscheck'. Stop. make[2]: *** [linux] Error 2
make[1]: *** [headers_check] Error 2
make: *** [vmlinux] Error 2
Regards,
Michal
Signature · 18 lines
Michal K. K. Piotrowski LTG - Linux Testers Group (PL) (http://www.stardust.webpages.pl/ltg/) LTG - Linux Testers Group (EN) (http://www.stardust.webpages.pl/linux_testers_group_en/) Signed-off-by: Michal Piotrowski <[email protected]> --- linux-msc-cfs-clean/include/linux/Kbuild 2007-04-13 23:52:47.000000000 +0200 +++ linux-msc-cfs/include/linux/Kbuild 2007-04-13 23:49:41.000000000 +0200 @@ -133,6 +133,7 @@ header-y += quotaio_v1.h header-y += quotaio_v2.h header-y += radeonfb.h header-y += raw.h +header-y += rbtree.h header-y += resource.h header-y += rose.h header-y += smbno.h
Quoted 11 lines · Ingo Molnar
[announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS]
i'm pleased to announce the first release of the "Modular Scheduler Core and Completely Fair Scheduler [CFS]" patchset:
http://redhat.com/~mingo/cfs-scheduler/sched-modular+cfs.patch
This project is a complete rewrite of the Linux task scheduler. My goal is to address various feature requests and to fix deficiencies in the vanilla scheduler that were suggested/found in the past few years, both for desktop scheduling and for server scheduling workloads.
I'm not in love with the current or other schedulers, so I'm indifferent to this change. However, I was reviewing your release notes and the patch and found myself wonder what the logarithmic complexity of this new scheduler is .. I assumed it would also be constant time , but the __enqueue_task_fair doesn't appear to be constant time (rbtree insert complexity).. Maybe that's not a critical path , but I thought I would at least comment on it.
Daniel
Quoted 6 lines · Daniel Walker
I'm not in love with the current or other schedulers, so I'm indifferent to this change. However, I was reviewing your release notes and the patch and found myself wonder what the logarithmic complexity of this new scheduler is .. I assumed it would also be constant time , but the
__enqueue_task_fairdoesn't appear to be constant time (rbtree insert complexity).. [...]
i've been worried about that myself and i've done extensive measurements before choosing this implementation. The rbtree turned out to be a quite compact data structure: we get it quite cheaply as part of the task structure cachemisses - which have to be touched anyway. For 1000 tasks it's a loop of ~10 - that's still very fast and bound in practice.
here's a test i did under CFS. Lets take some ridiculous load: 1000 infinite loop tasks running at SCHED_BATCH on a single CPU (all inserted into the same rbtree), and lets run lat_ctx:
neptune:~/l> uptime
22:51:23 up 8 min, 2 users, load average: 713.06, 254.64, 91.51
neptune:~/l> ./lat_ctx -s 0 2
"size=0k ovr=1.61
2 1.41
lets stop the 1000 tasks and only have ~2 tasks in the runqueue:
neptune:~/l> ./lat_ctx -s 0 2
"size=0k ovr=1.70
2 1.16
so the overhead is 0.25 usecs. Considering the load (1000 tasks trash the cache like crazy already), this is more than acceptable.
Ingo
Quoted 10 lines · Ingo Molnar
Quoted 6 lines · Daniel Walker
I'm not in love with the current or other schedulers, so I'm indifferent to this change. However, I was reviewing your release notes and the patch and found myself wonder what the logarithmic complexity of this new scheduler is .. I assumed it would also be constant time , but the
__enqueue_task_fairdoesn't appear to be constant time (rbtree insert complexity).. [...]
Quoted 5 lines
i've been worried about that myself and i've done extensive measurements before choosing this implementation. The rbtree turned out to be a quite compact data structure: we get it quite cheaply as part of the task structure cachemisses - which have to be touched anyway. For 1000 tasks it's a loop of ~10 - that's still very fast and bound in practice.
I'm not worried at all by O(log(n)) algorithms, and generally prefer smart log(n) than dumb O(1).
In a userland TCP stack I started to write 2 years ago, I used a comparable scheduler and could reach a sustained rate of 145000 connections/s at 4 millions of concurrent connections. And yes, each time a packet was sent or received, a task was queued/dequeued (so about 450k/s with 4 million tasks, on an athlon 1.5 GHz). So that seems much higher than what we currently need.
Regards,
Willy
One other thing, what happens in the case of slow, frequency changing, are/or inaccurate clocks .. Is the old sched_clock behavior still tolerated?
Daniel
Quoted 3 lines · Daniel Walker
One other thing, what happens in the case of slow, frequency changing, are/or inaccurate clocks .. Is the old
sched_clockbehavior still tolerated?
yeah, good question. Yesterday i did a quick testboot with that too, and it seemed to behave pretty OK with the low-res [jiffies based] sched_clock() too. Although in that case things are much more of an approximation and rounding/arithmetics artifacts are possible. CFS works best with a high-resolution cycle counter.
Ingo
Quoted 11 lines · Ingo Molnar
[announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS] i'm pleased to announce the first release of the "Modular Scheduler Core and Completely Fair Scheduler [CFS]" patchset:
http://redhat.com/~mingo/cfs-scheduler/sched-modular+cfs.patch
This project is a complete rewrite of the Linux task scheduler. My goal is to address various feature requests and to fix deficiencies in the vanilla scheduler that were suggested/found in the past few years, both for desktop scheduling and for server scheduling workloads.
[ QuickStart: apply the patch to v2.6.21-rc6, recompile, reboot. The
new scheduler will be active by default and all tasks will default to the newSCHED_FAIRinteractive scheduling class. ]
A pleasant surprise, though I did see it coming.
Quoted 5 lines · Ingo Molnar
Highlights are:
- the introduction of Scheduling Classes: an extensible hierarchy of scheduler modules. These modules encapsulate scheduling policy details and are handled by the scheduler core without the core code assuming about them too much.
It probably needs further clarification that they're things on the order of SCHED_FIFO, SCHED_RR, SCHED_NORMAL, etc.; some prioritization amongst the classes is furthermore assumed, and so on. They're not quite capable of being full-blown alternative policies, though quite a bit can be crammed into them.
There are issues with the per- scheduling class data not being very well-abstracted. A union for per-class data might help, if not a dynamically allocated scheduling class -private structure. Getting an alternative policy floating around that actually clashes a little with the stock data in the task structure would help clarify what's needed.
Quoted 6 lines · Ingo Molnar
-
sched_fair.cimplements the 'CFS desktop scheduler': it is a replacement for the vanilla scheduler'sSCHED_OTHERinteractivity code.
i'd like to give credit to Con Kolivas for the general approach here:
he has proven via RSDL/SD that 'fair scheduling' is possible and that it results in better desktop scheduling. Kudos Con!
Bob Mullens banged out a virtual deadline interactive task scheduler for Multics back in 1976 or thereabouts. ISTR the name Ferranti in connection with deadline task scheduling for UNIX in particular. I've largely seen deadline schedulers as a realtime topic, though. In any event, it's not so radical as to lack a fair number of precedents.
Quoted 10 lines · Ingo Molnar
The CFS patch uses a completely different approach and implementation from RSDL/SD. My goal was to make CFS's interactivity quality exceed that of RSDL/SD, which is a high standard to meet :-) Testing feedback is welcome to decide this one way or another. [ and, in any case, all of SD's logic could be added via a
kernel/sched_sd.cmodule as well, if Con is interested in such an approach. ] CFS's design is quite radical: it does not use runqueues, it uses a time-ordered rbtree to build a 'timeline' of future task execution, and thus has no 'array switch' artifacts (by which both the vanilla scheduler and RSDL/SD are affected).
A binomial heap would likely serve your purposes better than rbtrees. It's faster to have the next item to dequeue at the root of the tree structure rather than a leaf, for one. There are, of course, other priority queue structures (e.g. van Emde Boas) able to exploit the limited precision of the priority key for faster asymptotics, though actual performance is an open question.
Another advantage of heaps is that they support decreasing priorities directly, so that instead of removal and reinsertion, a less invasive movement within the tree is possible. This nets additional constant factor improvements beyond those for the next item to dequeue for the case where a task remains runnable, but is preempted and its priority decreased while it remains runnable.
Quoted 9 lines · Ingo Molnar
CFS uses nanosecond granularity accounting and does not rely on any jiffies or other HZ detail. Thus the CFS scheduler has no notion of 'timeslices' and has no heuristics whatsoever. There is only one central tunable:
/proc/sys/kernel/sched_granularity_ns
which can be used to tune the scheduler from 'desktop' (low latencies) to 'server' (good batching) workloads. It defaults to a setting suitable for desktop workloads.SCHED_BATCHis handled by the CFS scheduler module too.
I like not relying on timeslices. Timeslices ultimately get you into a 2.4.x -like epoch expiry scenarios and introduce a number of RR-esque artifacts therefore.
Quoted 5 lines · Ingo Molnar
due to its design, the CFS scheduler is not prone to any of the 'attacks' that exist today against the heuristics of the stock
scheduler:fiftyp.c,thud.c,chew.c,ring-test.c,massive_intr.call work fine and do not impact interactivity and produce the expected behavior.
I'm always suspicious of these claims. A moderately formal regression test suite needs to be assembled and the testcases rather seriously cleaned up so they e.g. run for a deterministic period of time, have their parameters passable via command-line options instead of editing and recompiling, don't need Lindenting to be legible, and so on. With that in hand, a battery of regression tests can be run against scheduler modifications to verify their correctness and to detect any disturbance in scheduling semantics they might cause.
A very serious concern is that while a fresh scheduler may pass all these tests, later modifications may later cause failures unnoticed because no one's doing the regression tests and there's no obvious test suite for testing types to latch onto. Another is that the testcases themselves may bitrot if they're not maintainable code.
Quoted 3 lines · Ingo Molnar
the CFS scheduler has a much stronger handling of nice levels and
SCHED_BATCH: both types of workloads should be isolated much more agressively than under the vanilla scheduler.
Speaking of regression tests, let's please at least state intended nice semantics and get a regression test for CPU bandwidth distribution by nice levels going.
Quoted 4 lines · Ingo Molnar
( another rdetail: due to nanosec accounting and timeline sorting,
sched_yield()support is very simple under CFS, and in fact under CFSsched_yield()behaves much better than under any other scheduler i have tested so far. )
And there's another one. sched_yield() semantics need a regression test more transparent than VolanoMark or other macrobenchmarks.
At some point we really need to decide what our sched_yield() is intended to do and get something out there to detect whether it's behaving as intended.
Quoted 4 lines · Ingo Molnar
- reworked/sanitized SMP load-balancing: the runqueue-walking assumptions are gone from the load-balancing code now, and iterators of the scheduling modules are used. The balancing code got quite a bit simpler as a result.
The SMP load balancing class operations strike me as unusual and likely to trip over semantic issues in alternative scheduling classes. Getting some alternative scheduling classes out there to clarify the issues would help here, too.
A more general question here is what you mean by "completely fair;" there doesn't appear to be inter-tgrp, inter-pgrp, inter-session, or inter-user fairness going on, though one might argue those are relatively obscure notions of fairness. Complete fairness arguably precludes static prioritization by nice levels, so there is also that. There is also the issue of what a fair CPU bandwidth distribution between tasks of varying desired in-isolation CPU utilization might be. I suppose my thorniest point is where the demonstration of fairness is as, say, a testcase. Perhaps it's fair now; when will we find out when that fairness has been disturbed?
What these things mean when there are multiple CPU's to schedule across may also be of concern.
I propose the following two testcases:
(1) CPU bandwidth distribution of CPU-bound tasks of varying nice levels Create a number of tasks at varying nice levels. Measure the CPU bandwidth allocated to each.
Success depends on intent: we decide up-front that a given nice level should correspond to a given share of CPU bandwidth. Check to see how far from the intended distribution of CPU bandwidth according to those decided-up-front shares the actual distribution of CPU bandwidth is for the test.
(2) CPU bandwidth distribution of tasks with varying CPU demands Create a number of tasks that would in isolation consume varying %cpu. Measure the CPU bandwidth allocated to each. Success depends on intent here, too. Decide up-front that a given %cpu that would be consumed in isolation should correspond to a given share of CPU bandwidth and check the actual distribution of CPU bandwidth vs. what was intended. Note that the shares need not linearly correspond to the %cpu; various sorts of things related to interactivity will make this nonlinear.
A third testcase for sched_yield() should be brewed up.
These testcases are oblivious to SMP. This will demand that a scheduling policy integrate with load balancing to the extent that load balancing occurs for the sake of distributing CPU bandwidth according to nice level. Some explicit decision should be made regarding that.
-- wli
Quoted 13 lines · William Lee Irwin III
Quoted 11 lines · Ingo Molnar
[announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS] i'm pleased to announce the first release of the "Modular Scheduler Core and Completely Fair Scheduler [CFS]" patchset:
http://redhat.com/~mingo/cfs-scheduler/sched-modular+cfs.patch
This project is a complete rewrite of the Linux task scheduler. My goal is to address various feature requests and to fix deficiencies in the vanilla scheduler that were suggested/found in the past few years, both for desktop scheduling and for server scheduling workloads.
[ QuickStart: apply the patch to v2.6.21-rc6, recompile, reboot. The
new scheduler will be active by default and all tasks will default to the newSCHED_FAIRinteractive scheduling class. ]
Quoted 1 line
A pleasant surprise, though I did see it coming.
hey ;)
Quoted 10 lines · Ingo Molnar
Quoted 5 lines
Highlights are:
- the introduction of Scheduling Classes: an extensible hierarchy of scheduler modules. These modules encapsulate scheduling policy details and are handled by the scheduler core without the core code assuming about them too much.It probably needs further clarification that they're things on the order of
SCHED_FIFO,SCHED_RR,SCHED_NORMAL, etc.; some prioritization amongst the classes is furthermore assumed, and so on. [...]
yep - they are linked via sched_ops->next pointer, with NULL delimiting the last one.
Quoted 2 lines
[...] They're not quite capable of being full-blown alternative policies, though quite a bit can be crammed into them.
yeah, they are not full-blown: i extended them on-demand, for the specific purposes of sched_fair.c and sched_rt.c. More can be done too.
Quoted 2 lines
There are issues with the per- scheduling class data not being very well-abstracted. [...]
yes. It's on my TODO list: i'll work more on extending the cleanups to those fields too.
Quoted 6 lines
A binomial heap would likely serve your purposes better than rbtrees. It's faster to have the next item to dequeue at the root of the tree structure rather than a leaf, for one. There are, of course, other priority queue structures (e.g. van Emde Boas) able to exploit the limited precision of the priority key for faster asymptotics, though actual performance is an open question.
i'm caching the leftmost leaf, which serves as an alternate, task-pick centric root in essence.
Quoted 6 lines
Another advantage of heaps is that they support decreasing priorities directly, so that instead of removal and reinsertion, a less invasive movement within the tree is possible. This nets additional constant factor improvements beyond those for the next item to dequeue for the case where a task remains runnable, but is preempted and its priority decreased while it remains runnable.
yeah. (Note that in CFS i'm not decreasing priorities anywhere though - all the priority levels in CFS stay constant, fairness is not achieved via rotating priorities or similar, it is achieved via the accounting code.)
Quoted 8 lines · Ingo Molnar
Quoted 5 lines
due to its design, the CFS scheduler is not prone to any of the 'attacks' that exist today against the heuristics of the stock
scheduler:fiftyp.c,thud.c,chew.c,ring-test.c,massive_intr.call work fine and do not impact interactivity and produce the expected behavior.I'm always suspicious of these claims. [...]
hey, sure - but please give it a go nevertheless, i _did_ test all these ;)
Quoted 1 line
A moderately formal regression test suite needs to be assembled [...]
by all means feel free! ;)
Quoted 1 line
A more general question here is what you mean by "completely fair;"
by that i mean the most common-sense definition: with N tasks running each gets 1/N CPU time if observed for a reasonable amount of time. Now extend this to arbitrary scheduling patterns, the end result should still be completely fair, according to the fundamental 1/N(time) rule individually applied to all the small scheduling patterns that the scheduling patterns give. (this assumes that the scheduling patterns are reasonably independent of each other - if they are not then there's no reasonable definition of fairness that makes sense, and we might as well use the 1/N rule for those cases too.)
Quoted 3 lines
there doesn't appear to be inter-tgrp, inter-pgrp, inter-session, or inter-user fairness going on, though one might argue those are relatively obscure notions of fairness. [...]
sure, i mainly concentrated on what we have in Linux today. The things you mention are add-ons that i can see handling via new scheduling
classes: all the CKRM and containers type of CPU time management facilities.
Quoted 2 lines
What these things mean when there are multiple CPU's to schedule across may also be of concern.
that is handled by the existing smp-nice load balancer, that logic is preserved under CFS.
Quoted 5 lines
These testcases are oblivious to SMP. This will demand that a scheduling policy integrate with load balancing to the extent that load balancing occurs for the sake of distributing CPU bandwidth according to nice level. Some explicit decision should be made regarding that.
this should already work reasonably fine with CFS: try massive_intr.c on an SMP box.
Ingo
Quoted 6 lines · William Lee Irwin III
Quoted 6 lines
A binomial heap would likely serve your purposes better than rbtrees. It's faster to have the next item to dequeue at the root of the tree structure rather than a leaf, for one. There are, of course, other priority queue structures (e.g. van Emde Boas) able to exploit the limited precision of the priority key for faster asymptotics, though actual performance is an open question.
Quoted 2 lines · Ingo Molnar
i'm caching the leftmost leaf, which serves as an alternate, task-pick centric root in essence.
I noticed that, yes. It seemed a better idea to me to use a data structure that has what's needed built-in, but I suppose it's not gospel.
Quoted 6 lines · William Lee Irwin III
Quoted 6 lines
Another advantage of heaps is that they support decreasing priorities directly, so that instead of removal and reinsertion, a less invasive movement within the tree is possible. This nets additional constant factor improvements beyond those for the next item to dequeue for the case where a task remains runnable, but is preempted and its priority decreased while it remains runnable.
Quoted 4 lines · Ingo Molnar
yeah. (Note that in CFS i'm not decreasing priorities anywhere though - all the priority levels in CFS stay constant, fairness is not achieved via rotating priorities or similar, it is achieved via the accounting code.)
Sorry, "priority" here would be from the POV of the queue data structure. From the POV of the scheduler it would be resetting the deadline or whatever the nomenclature cooked up for things is, most obviously in requeue_task_fair() and task_tick_fair().
Quoted 1 line · William Lee Irwin III
Quoted 1 line
I'm always suspicious of these claims. [...]
Quoted 2 lines · Ingo Molnar
hey, sure - but please give it a go nevertheless, i _did_ test all these ;)
The suspicion essentially centers around how long the state of affairs will hold up because comprehensive re-testing is not noticeably done upon updates to scheduling code or kernel point releases.
Quoted 1 line · William Lee Irwin III
Quoted 1 line
A moderately formal regression test suite needs to be assembled [...]
Quoted 1 line · Ingo Molnar
by all means feel free! ;)
I can only do so much, but I have done work to clean up other testcases going around. I'm mostly looking at testcases as I go over them or develop some interest in the subject and rewriting those that already exist or hammering out new ones as I need them. The main contribution toward this is that I've sort of made a mental note to stash the results of the effort somewhere and pass them along to those who do regular testing on kernels or otherwise import test suites into their collections.
Quoted 1 line · William Lee Irwin III
Quoted 1 line
A more general question here is what you mean by "completely fair;"
Quoted 9 lines · Ingo Molnar
by that i mean the most common-sense definition: with N tasks running each gets 1/N CPU time if observed for a reasonable amount of time. Now extend this to arbitrary scheduling patterns, the end result should still be completely fair, according to the fundamental 1/N(time) rule individually applied to all the small scheduling patterns that the scheduling patterns give. (this assumes that the scheduling patterns are reasonably independent of each other - if they are not then there's no reasonable definition of fairness that makes sense, and we might as well use the 1/N rule for those cases too.)
I'd start with identically-behaving CPU-bound tasks here. It's easy enough to hammer out a testcase that starts up N CPU-bound tasks, runs them for a few minutes, stops them, collects statistics on their runtime, and gives us an idea of whether 1/N came out properly. I'll get around to that at some point.
Where it gets complex is when the behavior patterns vary, e.g. they're not entirely CPU-bound and their desired in-isolation CPU utilization varies, or when nice levels vary, or both vary. I went on about testcases for those in particular in the prior post, though not both at once. The nice level one in particular needs an up-front goal for distribution of CPU bandwidth in a mixture of competing tasks with varying nice levels.
There are different ways to define fairness, but a uniform distribution of CPU bandwidth across a set of identical competing tasks is a good, testable definition.
Quoted 3 lines · William Lee Irwin III
Quoted 3 lines
there doesn't appear to be inter-tgrp, inter-pgrp, inter-session, or inter-user fairness going on, though one might argue those are relatively obscure notions of fairness. [...]
Quoted 4 lines · Ingo Molnar
sure, i mainly concentrated on what we have in Linux today. The things you mention are add-ons that i can see handling via new scheduling
classes: all the CKRM and containers type of CPU time management facilities.
At some point the CKRM and container people should be pinged to see what (if anything) they need to achieve these sorts of things. It's not clear to me that the specific cases I cited are considered relevant to anyone. I presume that if they are, someone will pipe up with a feature request. It was more a sort of catalogue of different notions of fairness that could arise than any sort of suggestion.
Quoted 2 lines · William Lee Irwin III
Quoted 2 lines
What these things mean when there are multiple CPU's to schedule across may also be of concern.
Quoted 2 lines · Ingo Molnar
that is handled by the existing smp-nice load balancer, that logic is preserved under CFS.
Given the things going wrong, I'm curious as to whether that works, and if so, how well. I'll drop that into my list of testcases that should be arranged for, though I won't guarantee that I'll get to it myself in any sort of timely fashion.
What this ultimately needs is specifying the semantics of nice levels so that we can say that a mixture of competing tasks with varying nice levels should have an ideal distribution of CPU bandwidth to check for.
Quoted 5 lines · William Lee Irwin III
Quoted 5 lines
These testcases are oblivious to SMP. This will demand that a scheduling policy integrate with load balancing to the extent that load balancing occurs for the sake of distributing CPU bandwidth according to nice level. Some explicit decision should be made regarding that.
Quoted 2 lines · Ingo Molnar
this should already work reasonably fine with CFS: try
massive_intr.con an SMP box.
Where is massive_intr.c, BTW?
-- wli
Quoted 3 lines · William Lee Irwin III
Where it gets complex is when the behavior patterns vary, e.g. they're not entirely CPU-bound and their desired in-isolation CPU utilization varies, or when nice levels vary, or both vary. [...]
yes. I tested things like 'massive_intr.c' (attached, written by Satoru Takeuchi) which starts N tasks which each work for 8msec then sleep 1msec:
from its output, the second column is the CPU time each thread got, the more even, the fairer the scheduling. On vanilla i get:
mercury:~> ./massive_intr 10 10
024873 00000150 024874 00000123 024870 00000069 024868 00000068 024866 00000051 024875 00000206 024872 00000093 024869 00000138 024867 00000078 024871 00000223
on CFS i get:
neptune:~> ./massive_intr 10 10
002266 00000112 002260 00000113 002261 00000112 002267 00000112 002269 00000112 002265 00000112 002262 00000113 002268 00000113 002264 00000112 002263 00000113
so it is quite a bit more even ;)
another related test-utility is one i wrote:
http://people.redhat.com/mingo/scheduler-patches/ring-test.c
this is a ring of 100 tasks each doing work for 100 msecs and then sleeping for 1 msec. I usually test this by also running a CPU hog in parallel to it, and checking whether it gets ~50.0% of CPU time under CFS. (it does)
Ingo
#if 0
Hi Ingo and all,
When I was executing massive interactive processes, I found that some of them occupy CPU time and the others hardly run.
It seems that some of processes which occupy CPU time always has max effective prio (default+5) and the others have max - 1. What happen here is...
1. If there are moderate number of max interactive processes, they can be re-inserted into active queue without falling down its priority again and again.
2. In this case, the others seldom run, and can't get max effective priority at next exhausting because scheduler considers them to sleep too long.
3. Goto 1, OOPS!
Unfortunately I haven't been able to make the patch resolving this problem yet. Any idea?
I also attach the test program which easily recreates this problem.
Test program flow:
1. First process starts child proesses and wait for 5 minutes.
2. Each child process executes "work 8 msec and sleep 1 msec" loop continuously.
3. After 3 minits have passed, each child processes prints the # of loops which executed.
What expected:
Each child processes execute nearly equal # of loops.
Test environment:
- kernel: 2.6.20(*1)
- # of CPUs: 1 or 2
- # of child processes: 200 or 400
- nice value: 0 or 20(*2)
*1) I confirmed that 2.6.21-rc5 has no change regarding this problem. *2) If a process have nice 20, scheduler never regards it as interactive.
Test results:
-----------+----------------+------+------------------------------------
# of CPUs | # of processes | nice | result
-----------+----------------+------+------------------------------------
| | 20 | looks good
1(i386) | +------+------------------------------------
| | 0 | 4 processes occupy 98% of CPU time
-----------+ 200 +------+------------------------------------
| | 20 | looks good
| +------+------------------------------------
| | 0 | 8 processes occupy 72% of CPU time
2(ia64) +----------------+------+------------------------------------
| 400 | 20 | looks good
| +------+------------------------------------
| | 0 | 8 processes occupy 98% of CPU time
-----------+----------------+------+------------------------------------FYI. 2.6.21-rc3-mm1 (enabling RSDL scheduler) works fine in the all casees :-)
Thanks,
Satoru
-------------------------------------------------------------------------------
#endif
/*
* massive_intr - run @nproc interactive processes and print the number of
* loops(*1) each process executes in @runtime secs.
*
* *1) "work 8 msec and sleep 1msec" loop
*
* Usage: massive_intr <nproc> <runtime>
*
* @nproc: number of processes
* @runtime: execute time[sec]
*
* ex) If you want to run 300 processes for 5 mins, issue the
* command as follows:
*
* $ massive_intr 300 300
*
* How to build:
*
* cc -o massive_intr massive_intr.c -lrt
*
*
* Copyright (C) 2007 Satoru Takeuchi <[email protected]> *
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
* This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
#include <semaphore.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <errno.h>
#include <err.h>
#define WORK_MSECS 8
#define SLEEP_MSECS 1
#define MAX_PROC 1024
#define SAMPLE_COUNT 1000000000
#define USECS_PER_SEC 1000000
#define USECS_PER_MSEC 1000
#define NSECS_PER_MSEC 1000000
#define SHMEMSIZE 4096
static const char *shmname = "/sched_interactive_shmem"; static void *shmem;
static sem_t *printsem;
static int nproc;
static int runtime;
static int fd;
static time_t *first;
static pid_t pid[MAX_PROC];
static int return_code;
static void cleanup_resources(void)
{
if (sem_destroy(printsem) < 0)
warn("sem_destroy() failed");
if (munmap(shmem, SHMEMSIZE) < 0)
warn("munmap() failed");
if (close(fd) < 0)
warn("close() failed");
} static void abnormal_exit(void)
{
if (kill(getppid(), SIGUSR2) < 0)
err(EXIT_FAILURE, "kill() failed");
}static void sighandler(int signo)
{
}
static void sighandler2(int signo)
{
return_code = EXIT_FAILURE;
}static void loopfnc(int nloop)
{
int i;
for (i = 0; i < nloop; i++)
;
}static int loop_per_msec(void)
{
struct timeval tv[2];
int before, after;
if (gettimeofday(&tv[0], NULL) < 0)
return -1;
loopfnc(SAMPLE_COUNT);
if (gettimeofday(&tv[1], NULL) < 0)
return -1;
before = tv[0].tv_sec*USECS_PER_SEC+tv[0].tv_usec;
after = tv[1].tv_sec*USECS_PER_SEC+tv[1].tv_usec;
return SAMPLE_COUNT/(after - before)*USECS_PER_MSEC;
}static void *test_job(void *arg)
{
int l = (int)arg;
int count = 0;
time_t current;
sigset_t sigset;
struct sigaction sa;
struct timespec ts = { 0, NSECS_PER_MSEC*SLEEP_MSECS};
sa.sa_handler = sighandler;
if (sigemptyset(&sa.sa_mask) < 0) {
warn("sigemptyset() failed");
abnormal_exit();
}
sa.sa_flags = 0;
if (sigaction(SIGUSR1, &sa, NULL) < 0) {
warn("sigaction() failed");
abnormal_exit();
}
if (sigemptyset(&sigset) < 0) {
warn("sigfillset() failed");
abnormal_exit();
}
sigsuspend(&sigset);
if (errno != EINTR) {
warn("sigsuspend() failed");
abnormal_exit();
}
/* main loop */
do {
loopfnc(WORK_MSECS*l);
if (nanosleep(&ts, NULL) < 0) {
warn("nanosleep() failed");
abnormal_exit();
}
count++;
if (time(¤t) == -1) {
warn("time() failed");
abnormal_exit();
}
} while (difftime(current, *first) < runtime);
if (sem_wait(printsem) < 0) {
warn("sem_wait() failed");
abnormal_exit();
}
printf("%06d\t%08d\n", getpid(), count);
if (sem_post(printsem) < 0) {
warn("sem_post() failed");
abnormal_exit();
}
exit(EXIT_SUCCESS);
}static void usage(void)
{
fprintf(stderr,
"Usage : massive_intr <nproc> <runtime>\n"
"\t\tnproc : number of processes\n"
"\t\truntime : execute time[sec]\n");
exit(EXIT_FAILURE);
}int main(int argc, char **argv)
{
int i, j;
int status;
sigset_t sigset;
struct sigaction sa;
int c;
if (argc != 3)
usage();
nproc = strtol(argv[1], NULL, 10);
if (errno || nproc < 1 || nproc > MAX_PROC)
err(EXIT_FAILURE, "invalid multinum");
runtime = strtol(argv[2], NULL, 10);
if (errno || runtime <= 0)
err(EXIT_FAILURE, "invalid runtime");
sa.sa_handler = sighandler2;
if (sigemptyset(&sa.sa_mask) < 0)
err(EXIT_FAILURE, "sigemptyset() failed");
sa.sa_flags = 0;
if (sigaction(SIGUSR2, &sa, NULL) < 0)
err(EXIT_FAILURE, "sigaction() failed");
if (sigemptyset(&sigset) < 0)
err(EXIT_FAILURE, "sigemptyset() failed");
if (sigaddset(&sigset, SIGUSR1) < 0)
err(EXIT_FAILURE, "sigaddset() failed");
if (sigaddset(&sigset, SIGUSR2) < 0)
err(EXIT_FAILURE, "sigaddset() failed");
if (sigprocmask(SIG_BLOCK, &sigset, NULL) < 0)
err(EXIT_FAILURE, "sigprocmask() failed");
/* setup shared memory */
if ((fd = shm_open(shmname, O_CREAT | O_RDWR, 0644)) < 0)
err(EXIT_FAILURE, "shm_open() failed");
if (shm_unlink(shmname) < 0) {
warn("shm_unlink() failed");
goto err_close;
}
if (ftruncate(fd, SHMEMSIZE) < 0) {
warn("ftruncate() failed");
goto err_close;
}
shmem = mmap(NULL, SHMEMSIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (shmem == (void *)-1) {
warn("mmap() failed");
goto err_unmap;
}
printsem = shmem;
first = shmem + sizeof(*printsem);
/* initialize semaphore */
if ((sem_init(printsem, 1, 1)) < 0) {
warn("sem_init() failed");
goto err_unmap;
}
if ((c = loop_per_msec()) < 0) {
fprintf(stderr, "loop_per_msec() failed\n");
goto err_sem;
}
for (i = 0; i < nproc; i++) {
pid[i] = fork();
if (pid[i] == -1) {
warn("fork() failed\n");
for (j = 0; j < i; j++)
if (kill(pid[j], SIGKILL) < 0)
warn("kill() failed");
goto err_sem;
}
if (pid[i] == 0)
test_job((void *)c);
}
if (sigemptyset(&sigset) < 0) {
warn("sigemptyset() failed");
goto err_proc;
}
if (sigaddset(&sigset, SIGUSR2) < 0) {
warn("sigaddset() failed");
goto err_proc;
}
if (sigprocmask(SIG_UNBLOCK, &sigset, NULL) < 0) {
warn("sigprocmask() failed");
goto err_proc;
}
if (time(first) < 0) {
warn("time() failed");
goto err_proc;
}
if ((kill(0, SIGUSR1)) == -1) {
warn("kill() failed");
goto err_proc;
}
for (i = 0; i < nproc; i++) {
if (wait(&status) < 0) {
warn("wait() failed");
goto err_proc;
}
}
cleanup_resources();
exit(return_code);
err_proc:
for (i = 0; i < nproc; i++)
if (kill(pid[i], SIGKILL) < 0)
if (errno != ESRCH)
warn("kill() failed");
err_sem:
if (sem_destroy(printsem) < 0)
warn("sem_destroy() failed");
err_unmap:
if (munmap(shmem, SHMEMSIZE) < 0)
warn("munmap() failed");
err_close:
if (close(fd) < 0)
warn("close() failed");
exit(EXIT_FAILURE);
}Quoted 3 lines · William Lee Irwin III
Quoted 3 lines
Where it gets complex is when the behavior patterns vary, e.g. they're not entirely CPU-bound and their desired in-isolation CPU utilization varies, or when nice levels vary, or both vary. [...]
Quoted 3 lines · Ingo Molnar
yes. I tested things like '
massive_intr.c' (attached, written by Satoru Takeuchi) which starts N tasks which each work for 8msec then sleep 1msec:
[...]
Quoted 6 lines
another related test-utility is one i wrote:
http://people.redhat.com/mingo/scheduler-patches/ring-test.c
this is a ring of 100 tasks each doing work for 100 msecs and then sleeping for 1 msec. I usually test this by also running a CPU hog in parallel to it, and checking whether it gets ~50.0% of CPU time under CFS. (it does)
These are both tremendously useful. The code is also in rather good shape so only minimal modifications (for massive_intr.c I'm not even sure if any are needed at all) are needed to plug them into the test harness I'm aware of. I'll queue them both for me to adjust and send over to testers I don't want to burden with hacking on testcases I myself am asking them to add to their suites.
-- wli
Quoted 12 lines · William Lee Irwin III
Quoted 10 lines · Ingo Molnar
The CFS patch uses a completely different approach and implementation from RSDL/SD. My goal was to make CFS's interactivity quality exceed that of RSDL/SD, which is a high standard to meet :-) Testing feedback is welcome to decide this one way or another. [ and, in any case, all of SD's logic could be added via a
kernel/sched_sd.cmodule as well, if Con is interested in such an approach. ] CFS's design is quite radical: it does not use runqueues, it uses a time-ordered rbtree to build a 'timeline' of future task execution, and thus has no 'array switch' artifacts (by which both the vanilla scheduler and RSDL/SD are affected).
Quoted 6 lines
A binomial heap would likely serve your purposes better than rbtrees. It's faster to have the next item to dequeue at the root of the tree structure rather than a leaf, for one. There are, of course, other priority queue structures (e.g. van Emde Boas) able to exploit the limited precision of the priority key for faster asymptotics, though actual performance is an open question.
Haven't looked at the scheduler code yet, but for a similar problem I use a time ring. The ring has Ns (2 power is better) slots (where tasks are queued - in my case they were som sort of timers), and it has a current base index (Ib), a current base time (Tb) and a time granularity (Tg). It also has a bitmap with bits telling you which slots contains queued tasks. An item (task) that has to be scheduled at time T, will be queued in the slot:
S = Ib + min((T - Tb) / Tg, Ns - 1);
Items with T longer than Ns*Tg will be scheduled in the relative last slot (chosing a proper Ns and Tg can minimize this).
Queueing is O(1) and de-queueing is O(Ns). You can play with Ns and Tg to suite to your needs.
This is a simple bench between time-ring (TR) and CFS queueing:
http://www.xmailserver.org/smart-queue.c
In my box (Dual Opteron 252):
davide@alien:~$ ./smart-queue -n 8 CFS = 142.21 cycles/loop TR = 72.33 cycles/loop davide@alien:~$ ./smart-queue -n 16 CFS = 188.74 cycles/loop TR = 83.79 cycles/loop davide@alien:~$ ./smart-queue -n 32 CFS = 221.36 cycles/loop TR = 75.93 cycles/loop davide@alien:~$ ./smart-queue -n 64 CFS = 242.89 cycles/loop TR = 81.29 cycles/loop
- Davide
Quoted 8 lines · Davide Libenzi
Haven't looked at the scheduler code yet, but for a similar problem I use a time ring. The ring has Ns (2 power is better) slots (where tasks are queued - in my case they were som sort of timers), and it has a current base index (Ib), a current base time (Tb) and a time granularity (Tg). It also has a bitmap with bits telling you which slots contains queued tasks. An item (task) that has to be scheduled at time T, will be queued in the slot:
S = Ib +
min((T - Tb) / Tg, Ns - 1);
... mod Ns, of course ;)
- Davide
Quoted 1 line · William Lee Irwin III
Quoted 1 line
A binomial heap would likely serve your purposes better than rbtrees.
[...]
Quoted 11 lines · Davide Libenzi
Haven't looked at the scheduler code yet, but for a similar problem I use a time ring. The ring has Ns (2 power is better) slots (where tasks are queued - in my case they were som sort of timers), and it has a current base index (Ib), a current base time (Tb) and a time granularity (Tg). It also has a bitmap with bits telling you which slots contains queued tasks. An item (task) that has to be scheduled at time T, will be queued in the slot:
S = Ib +min((T - Tb) / Tg, Ns - 1);
Items with T longer than Ns*Tg will be scheduled in the relative last slot (chosing a proper Ns and Tg can minimize this).
Queueing is O(1) and de-queueing is O(Ns). You can play with Ns and Tg to suite to your needs.
I used a similar sort of queue in the virtual deadline scheduler I wrote in 2003 or thereabouts. CFS uses queue priorities with too high a precision to map directly to this (queue priorities are marked as "key" in the cfs code and should not be confused with task priorities). The elder virtual deadline scheduler used millisecond resolution and a rather different calculation for its equivalent of ->key, which explains how it coped with a limited priority space.
The two basic attacks on such large priority spaces are the near future vs. far future subdivisions and subdividing the priority space into (most often regular) intervals. Subdividing the priority space into intervals is the most obvious; you simply use some O(lg(n)) priority queue as the bucket discipline in the "time ring," queue by the upper bits of the queue priority in the time ring, and by the lower bits in the O(lg(n)) bucket discipline. The near future vs. far future subdivision is maintaining the first N tasks in a low-constant-overhead structure like a sorted list and the remainder in some other sort of queue structure intended to handle large numbers of elements gracefully. The distribution of queue priorities strongly influences which of the methods is most potent, though it should be clear the methods can be used in combination.
-- wli
Quoted 7 lines · William Lee Irwin III
The two basic attacks on such large priority spaces are the near future vs. far future subdivisions and subdividing the priority space into (most often regular) intervals. Subdividing the priority space into intervals is the most obvious; you simply use some O(lg(n)) priority queue as the bucket discipline in the "time ring," queue by the upper bits of the queue priority in the time ring, and by the lower bits in the O(lg(n)) bucket discipline.
Sure. If you really need sub-millisecond precision, you can replace the bucket's list_head with an rb_root. It may be not necessary though for a cpu scheduler (still, didn't read Ingo's code yet).
- Davide
Quoted 20 lines · Davide Libenzi
Haven't looked at the scheduler code yet, but for a similar problem I use a time ring. The ring has Ns (2 power is better) slots (where tasks are queued - in my case they were som sort of timers), and it has a current base index (Ib), a current base time (Tb) and a time granularity (Tg). It also has a bitmap with bits telling you which slots contains queued tasks. An item (task) that has to be scheduled at time T, will be queued in the slot:
S = Ib +
min((T - Tb) / Tg, Ns - 1);Items with T longer than Ns*Tg will be scheduled in the relative last slot (chosing a proper Ns and Tg can minimize this).
Queueing is O(1) and de-queueing is O(Ns). You can play with Ns and Tg to suite to your needs.
This is a simple bench between time-ring (TR) and CFS queueing:http://www.xmailserver.org/smart-queue.c
In my box (Dual Opteron 252):
Quoted 12 lines
davide@alien:~$ ./smart-queue -n 8 CFS = 142.21 cycles/loop TR = 72.33 cycles/loop davide@alien:~$ ./smart-queue -n 16 CFS = 188.74 cycles/loop TR = 83.79 cycles/loop davide@alien:~$ ./smart-queue -n 32 CFS = 221.36 cycles/loop TR = 75.93 cycles/loop davide@alien:~$ ./smart-queue -n 64 CFS = 242.89 cycles/loop TR = 81.29 cycles/loop
Hello all,
I cannot help myself to not report results with GAVL tree algorithm there as an another race competitor. I believe, that it is better solution for large priority queues than RB-tree and even heap trees. It could be disputable if the scheduler needs such scalability on the other hand. The AVL heritage guarantees lower height which results in shorter search times which could be profitable for other uses in kernel.
GAVL algorithm is AVL tree based, so it does not suffer from "infinite" priorities granularity there as TR does. It allows use for generalized case where tree is not fully balanced. This allows to cut the first item withour rebalancing. This leads to the degradation of the tree by one more level (than non degraded AVL gives) in maximum, which is still considerably better than RB-trees maximum.
http://cmp.felk.cvut.cz/~pisa/linux/smart-queue-v-gavl.c
The description behind the code is there
http://cmp.felk.cvut.cz/~pisa/ulan/gavl.pdf
The code is part of much more covering uLUt library
http://cmp.felk.cvut.cz/~pisa/ulan/ulut.pdf
http://sourceforge.net/project/showfiles.php?group_id=118937&package_id=130840
I have included all required GAVL code directly into smart-queue-v-gavl.c to provide it for easy testing.
There are tests run on my little dated computer - Duron 600 MHz. Test are run twice to suppress run order influence.
./smart-queue-v-gavl -n 1 -l 2000000gavl_cfs = 55.66 cycles/loop
CFS = 88.33 cycles/loop
TR = 141.78 cycles/loop
CFS = 90.45 cycles/loopgavl_cfs = 55.38 cycles/loop
./smart-queue-v-gavl -n 2 -l 2000000gavl_cfs = 82.85 cycles/loop
CFS = 104.18 cycles/loop
TR = 145.21 cycles/loop
CFS = 102.74 cycles/loopgavl_cfs = 82.05 cycles/loop
./smart-queue-v-gavl -n 4 -l 2000000gavl_cfs = 137.45 cycles/loop
CFS = 156.47 cycles/loop
TR = 142.00 cycles/loop
CFS = 152.65 cycles/loopgavl_cfs = 139.38 cycles/loop
./smart-queue-v-gavl -n 10 -l 2000000gavl_cfs = 229.22 cycles/loop (WORSE)
CFS = 206.26 cycles/loop
TR = 140.81 cycles/loop
CFS = 208.29 cycles/loopgavl_cfs = 223.62 cycles/loop (WORSE)
./smart-queue-v-gavl -n 100 -l 2000000gavl_cfs = 257.66 cycles/loop
CFS = 329.68 cycles/loop
TR = 142.20 cycles/loop
CFS = 319.34 cycles/loopgavl_cfs = 260.02 cycles/loop
./smart-queue-v-gavl -n 1000 -l 2000000gavl_cfs = 258.41 cycles/loop
CFS = 393.04 cycles/loop
TR = 134.76 cycles/loop
CFS = 392.20 cycles/loopgavl_cfs = 260.93 cycles/loop
./smart-queue-v-gavl -n 10000 -l 2000000gavl_cfs = 259.45 cycles/loop
CFS = 605.89 cycles/loop
TR = 196.69 cycles/loop
CFS = 622.60 cycles/loopgavl_cfs = 262.72 cycles/loop
./smart-queue-v-gavl -n 100000 -l 2000000gavl_cfs = 258.21 cycles/loop
CFS = 845.62 cycles/loop
TR = 315.37 cycles/loop
CFS = 860.21 cycles/loopgavl_cfs = 258.94 cycles/loop
The GAVL code has not been tuned by any "likely"/"unlikely" constructs. It brings even some other overhead from it generic design which is not necessary for this use - it keeps permanently even pointer to the last element, ensures, that the insertion order is preserved for same key values etc. But it still proves much better scalability then kernel used RB-tree code. On the other hand, it does not encode color/height in one of the pointers and requires additional field for height.
May it be, that difference is due some bug in my testing, then I would be interrested in correction. The test case is oversimplified probably. I have already run more different tests against GAVL code in the past to compare it with different tree and queues implementations and I have not found case with real performance degradation. On the other hand, there are cases for small items counts where GAVL is sometimes a little worse than others (array based heap-tree for example).
The GAVL code itself is used in more opensource and commercial projects and we have noticed no problems after one small fix at the time of the first release in 2004.
Best wishes
Pavel Pisa
e-mail: [email protected]
www: http://cmp.felk.cvut.cz/~pisa
work: http://www.pikron.com
Quoted 17 lines · Pavel Pisa
I cannot help myself to not report results with GAVL tree algorithm there as an another race competitor. I believe, that it is better solution for large priority queues than RB-tree and even heap trees. It could be disputable if the scheduler needs such scalability on the other hand. The AVL heritage guarantees lower height which results in shorter search times which could be profitable for other uses in kernel.
GAVL algorithm is AVL tree based, so it does not suffer from "infinite" priorities granularity there as TR does. It allows use for generalized case where tree is not fully balanced. This allows to cut the first item withour rebalancing. This leads to the degradation of the tree by one more level (than non degraded AVL gives) in maximum, which is still considerably better than RB-trees maximum.
Here are the results on my Opteron 252:
Testing N=1gavl_cfs = 187.20 cycles/loop
CFS = 194.16 cycles/loop
TR = 314.87 cycles/loop
CFS = 194.15 cycles/loopgavl_cfs = 187.15 cycles/loop
Testing N=2gavl_cfs = 268.94 cycles/loop
CFS = 305.53 cycles/loop
TR = 313.78 cycles/loop
CFS = 289.58 cycles/loopgavl_cfs = 266.02 cycles/loop
Testing N=4gavl_cfs = 452.13 cycles/loop
CFS = 518.81 cycles/loop
TR = 311.54 cycles/loop
CFS = 516.23 cycles/loopgavl_cfs = 450.73 cycles/loop
Testing N=8gavl_cfs = 609.29 cycles/loop
CFS = 644.65 cycles/loop
TR = 308.11 cycles/loop
CFS = 667.01 cycles/loopgavl_cfs = 592.89 cycles/loop
Testing N=16gavl_cfs = 686.30 cycles/loop
CFS = 807.41 cycles/loop
TR = 317.20 cycles/loop
CFS = 810.24 cycles/loopgavl_cfs = 688.42 cycles/loop
Testing N=32gavl_cfs = 756.57 cycles/loop
CFS = 852.14 cycles/loop
TR = 301.22 cycles/loop
CFS = 876.12 cycles/loopgavl_cfs = 758.46 cycles/loop
Testing N=64gavl_cfs = 831.97 cycles/loop
CFS = 997.16 cycles/loop
TR = 304.74 cycles/loop
CFS = 1003.26 cycles/loopgavl_cfs = 832.83 cycles/loop
Testing N=128gavl_cfs = 897.33 cycles/loop
CFS = 1030.36 cycles/loop
TR = 295.65 cycles/loop
CFS = 1035.29 cycles/loopgavl_cfs = 892.51 cycles/loop
Testing N=256gavl_cfs = 963.17 cycles/loop
CFS = 1146.04 cycles/loop
TR = 295.35 cycles/loop
CFS = 1162.04 cycles/loopgavl_cfs = 966.31 cycles/loop
Testing N=512gavl_cfs = 1029.82 cycles/loop
CFS = 1218.34 cycles/loop
TR = 288.78 cycles/loop
CFS = 1257.97 cycles/loopgavl_cfs = 1029.83 cycles/loop
Testing N=1024gavl_cfs = 1091.76 cycles/loop
CFS = 1318.47 cycles/loop
TR = 287.74 cycles/loop
CFS = 1311.72 cycles/loopgavl_cfs = 1093.29 cycles/loop
Testing N=2048gavl_cfs = 1153.03 cycles/loop
CFS = 1398.84 cycles/loop
TR = 286.75 cycles/loop
CFS = 1438.68 cycles/loopgavl_cfs = 1149.97 cycles/loop
There seem to be some difference from your numbers. This is with:
gcc version 4.1.2
and -O2. But then and Opteron can behave quite differentyl than a Duron on a bench like this ;)
- Davide
Quoted 107 lines · Davide Libenzi
Quoted 17 lines · Pavel Pisa
I cannot help myself to not report results with GAVL tree algorithm there as an another race competitor. I believe, that it is better solution for large priority queues than RB-tree and even heap trees. It could be disputable if the scheduler needs such scalability on the other hand. The AVL heritage guarantees lower height which results in shorter search times which could be profitable for other uses in kernel.
GAVL algorithm is AVL tree based, so it does not suffer from "infinite" priorities granularity there as TR does. It allows use for generalized case where tree is not fully balanced. This allows to cut the first item withour rebalancing. This leads to the degradation of the tree by one more level (than non degraded AVL gives) in maximum, which is still considerably better than RB-trees maximum.
Here are the results on my Opteron 252:
Testing N=1
gavl_cfs= 187.20 cycles/loop
CFS = 194.16 cycles/loop
TR = 314.87 cycles/loop
CFS = 194.15 cycles/loopgavl_cfs= 187.15 cycles/loopTesting N=2
gavl_cfs= 268.94 cycles/loop
CFS = 305.53 cycles/loop
TR = 313.78 cycles/loop
CFS = 289.58 cycles/loopgavl_cfs= 266.02 cycles/loopTesting N=4
gavl_cfs= 452.13 cycles/loop
CFS = 518.81 cycles/loop
TR = 311.54 cycles/loop
CFS = 516.23 cycles/loopgavl_cfs= 450.73 cycles/loopTesting N=8
gavl_cfs= 609.29 cycles/loop
CFS = 644.65 cycles/loop
TR = 308.11 cycles/loop
CFS = 667.01 cycles/loopgavl_cfs= 592.89 cycles/loopTesting N=16
gavl_cfs= 686.30 cycles/loop
CFS = 807.41 cycles/loop
TR = 317.20 cycles/loop
CFS = 810.24 cycles/loopgavl_cfs= 688.42 cycles/loopTesting N=32
gavl_cfs= 756.57 cycles/loop
CFS = 852.14 cycles/loop
TR = 301.22 cycles/loop
CFS = 876.12 cycles/loopgavl_cfs= 758.46 cycles/loopTesting N=64
gavl_cfs= 831.97 cycles/loop
CFS = 997.16 cycles/loop
TR = 304.74 cycles/loop
CFS = 1003.26 cycles/loopgavl_cfs= 832.83 cycles/loopTesting N=128
gavl_cfs= 897.33 cycles/loop
CFS = 1030.36 cycles/loop
TR = 295.65 cycles/loop
CFS = 1035.29 cycles/loopgavl_cfs= 892.51 cycles/loopTesting N=256
gavl_cfs= 963.17 cycles/loop
CFS = 1146.04 cycles/loop
TR = 295.35 cycles/loop
CFS = 1162.04 cycles/loopgavl_cfs= 966.31 cycles/loopTesting N=512
gavl_cfs= 1029.82 cycles/loop
CFS = 1218.34 cycles/loop
TR = 288.78 cycles/loop
CFS = 1257.97 cycles/loopgavl_cfs= 1029.83 cycles/loopTesting N=1024
gavl_cfs= 1091.76 cycles/loop
CFS = 1318.47 cycles/loop
TR = 287.74 cycles/loop
CFS = 1311.72 cycles/loopgavl_cfs= 1093.29 cycles/loopTesting N=2048
gavl_cfs= 1153.03 cycles/loop
CFS = 1398.84 cycles/loop
TR = 286.75 cycles/loop
CFS = 1438.68 cycles/loopgavl_cfs= 1149.97 cycles/loop
Quoted 6 lines
There seem to be some difference from your numbers. This is with:
gcc version 4.1.2
and -O2. But then and Opteron can behave quite differentyl than a Duron on a bench like this ;)
Thanks for testing, but yours numbers are more correct than my first report. My numbers seemed to be over-optimistic even to me, In the fact I have been surprised that difference is so high. But I have tested bad version of code without GAVL_FAFTER option set. The code pushed to the web page has been the correct one. I have not get to look into case until now because I have busy day to prepare some Linux based labs at university.
Without GAVL_FAFTER option, insert operation does fail if item with same key is already inserted (intended feature of the code) and as result of that, not all items have been inserted in the test. The meaning of GAVL_FAFTER is find/insert after all items with the same key value. Default behavior is operate on unique keys in tree and reject duplicates.
My results are even worse for GAVL than yours.
It is possible to try tweak code and optimize it more (likely/unlikely/do not keep last ptr etc) for this actual usage. May it be, that I try this exercise, but I do not expect that the result after tuning would be so much better, that it would outweight some redesign work. I could see some advantages of AVL still, but it has its own drawbacks with need of separate height field and little worse delete in the middle timing.
So excuse me for disturbance. I have been only curious how GAVL code would behave in the comparison of other algorithms and I did not kept my premature enthusiasm under the lock.
Best wishes
Pavel Pisa
./smart-queue-v-gavl -n 4gavl_cfs = 279.02 cycles/loop
CFS = 200.87 cycles/loop
TR = 229.55 cycles/loop
CFS = 201.23 cycles/loopgavl_cfs = 276.08 cycles/loop
./smart-queue-v-gavl -n 8gavl_cfs = 310.92 cycles/loop
CFS = 288.45 cycles/loop
TR = 192.46 cycles/loop
CFS = 284.94 cycles/loopgavl_cfs = 357.02 cycles/loop
./smart-queue-v-gavl -n 16gavl_cfs = 350.45 cycles/loop
CFS = 354.01 cycles/loop
TR = 189.79 cycles/loop
CFS = 320.08 cycles/loopgavl_cfs = 387.43 cycles/loop
./smart-queue-v-gavl -n 32gavl_cfs = 419.23 cycles/loop
CFS = 406.88 cycles/loop
TR = 198.10 cycles/loop
CFS = 398.15 cycles/loopgavl_cfs = 412.57 cycles/loop
./smart-queue-v-gavl -n 64gavl_cfs = 442.81 cycles/loop
CFS = 429.62 cycles/loop
TR = 235.40 cycles/loop
CFS = 389.54 cycles/loopgavl_cfs = 433.56 cycles/loop
./smart-queue-v-gavl -n 128gavl_cfs = 358.20 cycles/loop
CFS = 605.49 cycles/loop
TR = 236.01 cycles/loop
CFS = 458.50 cycles/loopgavl_cfs = 455.05 cycles/loop
./smart-queue-v-gavl -n 256gavl_cfs = 529.72 cycles/loop
CFS = 530.98 cycles/loop
TR = 193.75 cycles/loop
CFS = 533.75 cycles/loopgavl_cfs = 471.47 cycles/loop
./smart-queue-v-gavl -n 512gavl_cfs = 525.80 cycles/loop
CFS = 550.63 cycles/loop
TR = 188.71 cycles/loop
CFS = 549.81 cycles/loopgavl_cfs = 494.73 cycles/loop
./smart-queue-v-gavl -n 1024gavl_cfs = 544.91 cycles/loop
CFS = 561.68 cycles/loop
TR = 230.97 cycles/loop
CFS = 522.68 cycles/loopgavl_cfs = 542.40 cycles/loop
./smart-queue-v-gavl -n 2048gavl_cfs = 567.46 cycles/loop
CFS = 581.85 cycles/loop
TR = 229.69 cycles/loop
CFS = 585.41 cycles/loopgavl_cfs = 563.22 cycles/loop
Hi Ingo,
Quoted 1 line · Ingo Molnar
[announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS]
(...)
Quoted 4 lines
CFS's design is quite radical: it does not use runqueues, it uses a time-ordered rbtree to build a 'timeline' of future task execution, and thus has no 'array switch' artifacts (by which both the vanilla scheduler and RSDL/SD are affected).
I have a high confidence this will work better : I've been using time-ordered trees in userland projects for several years, and never found anything better. To be honnest, I never understood the concept behind the array switch, but as I never felt brave enough to hack something in this kernel area, I simply preferred to shut up (not enough knowledge and not enough time).
However, I have been using a very fast struct timeval-ordered RADIX tree. I found generic rbtree code to generally be slower, certainly because of the call to a function with arguments on every node. Both trees are O(log(n)), the rbtree being balanced and the radix tree being unbalanced. If you're interested, I can try to see how that would fit (but not this week-end).
Also, I had spent much time in the past doing paper work on how to improve fairness between interactive tasks and batch tasks. I came up with the conclusion that for perfectness, tasks should not be ordered by their expected wakeup time, but by their expected completion time, which automatically takes account of their allocated and used timeslice. It would also allow both types of workloads to share equal CPU time with better responsiveness for the most interactive one through the reallocation of a "credit" for the tasks which have not consumed all of their timeslices. I remember we had discussed this with Mike about one year ago when he fixed lots of problems in mainline scheduler. The downside is that I never found how to make this algo fit in O(log(n)). I always ended in something like O(n.log(n)) IIRC.
But maybe this is overkill for real life anyway. Given that a basic two arrays switch (which I never understood) was sufficient for many people, probably that a basic tree will be an order of magnitude better.
Quoted 11 lines
CFS uses nanosecond granularity accounting and does not rely on any jiffies or other HZ detail. Thus the CFS scheduler has no notion of 'timeslices' and has no heuristics whatsoever. There is only one central tunable:
/proc/sys/kernel/sched_granularity_nswhich can be used to tune the scheduler from 'desktop' (low latencies) to 'server' (good batching) workloads. It defaults to a setting suitable for desktop workloads.
SCHED_BATCHis handled by the CFS scheduler module too.
I find this useful, but to be fair with Mike and Con, they both have proposed similar tuning knobs in the past and you said you did not want to add that complexity for admins. People can sometimes be demotivated by seeing their proposals finally used by people who first rejected them. And since both Mike and Con both have done a wonderful job in that area, we need their experience and continued active participation more than ever.
Quoted 5 lines
due to its design, the CFS scheduler is not prone to any of the 'attacks' that exist today against the heuristics of the stock
scheduler:fiftyp.c,thud.c,chew.c,ring-test.c,massive_intr.call work fine and do not impact interactivity and produce the expected behavior.
I'm very pleased to read this. Because as I have already said it, my major concern with 2.6 was the stock scheduler. Recently, RSDL fixed most of the basic problems for me to the point that I switched the default lilo entry on my notebook to 2.6 ! I hope that whatever the next scheduler will be, we'll definitely get rid of any heuristics. Heuristics are good in 95% of situations and extremely bad in the remaining 5%. I prefer something reasonably good in 100% of situations.
Quoted 14 lines
the CFS scheduler has a much stronger handling of nice levels and
SCHED_BATCH: both types of workloads should be isolated much more agressively than under the vanilla scheduler.( another rdetail: due to nanosec accounting and timeline sorting,
sched_yield()support is very simple under CFS, and in fact under CFSsched_yield()behaves much better than under any other scheduler i have tested so far. )-
sched_rt.cimplementsSCHED_FIFOandSCHED_RRsemantics, in a simpler way than the vanilla scheduler does. It uses 100 runqueues (for all 100 RT priority levels, instead of 140 in the vanilla scheduler) and it needs no expired array.
Quoted 4 lines
- reworked/sanitized SMP load-balancing: the runqueue-walking assumptions are gone from the load-balancing code now, and iterators of the scheduling modules are used. The balancing code got quite a bit simpler as a result.
Will this have any impact on NUMA/HT/multi-core/etc... ?
Quoted 1 line
the core scheduler got smaller by more than 700 lines:
Well done !
Cheers,
Willy
Quoted 4 lines · Willy Tarreau
Quoted 4 lines
central tunable:
/proc/sys/kernel/sched_granularity_ns
Quoted 8 lines
Quoted 4 lines
which can be used to tune the scheduler from 'desktop' (low latencies) to 'server' (good batching) workloads. It defaults to a setting suitable for desktop workloads.
SCHED_BATCHis handled by the CFS scheduler module too.I find this useful, but to be fair with Mike and Con, they both have proposed similar tuning knobs in the past and you said you did not want to add that complexity for admins. [...]
yeah. [ Note that what i opposed in the past was mostly the 'export all the zillion of sched.c knobs to /sys and let people mess with them' kind of patches which did exist and still exist. A _single_ knob, which represents basically the totality of parameters within sched_fair.c is less of a problem. I dont think i ever objected to this knob within staircase/SD. (If i did then i was dead wrong.) ]
Quoted 4 lines
[...] People can sometimes be demotivated by seeing their proposals finally used by people who first rejected them. And since both Mike and Con both have done a wonderful job in that area, we need their experience and continued active participation more than ever.
very much so! Both Con and Mike has contributed regularly to upstream sched.c:
$ git-log kernel/sched.c | grep 'by: Con Kolivas' 1 | wc -l 19
$ git-log kernel/sched.c | grep 'by: Mike' | wc -l 6
and i'd very much like both counts to increase steadily in the future too :)
Quoted 6 lines
Quoted 4 lines
- reworked/sanitized SMP load-balancing: the runqueue-walking assumptions are gone from the load-balancing code now, and iterators of the scheduling modules are used. The balancing code got quite a bit simpler as a result.
Will this have any impact on NUMA/HT/multi-core/etc... ?
it will inevitably have some sort of effect - and if it's negative, i'll try to fix it.
I got rid of the explicit cache-hot tracking code and replaced it with a more natural pure 'pick the next-to-run task first, that is likely the most cache-cold one' logic. That just derives naturally from the rbtree approach.
Quoted 3 lines
Quoted 1 line
the core scheduler got smaller by more than 700 lines:
Well done !
thanks :)
Ingo
Quoted 2 lines · Ingo Molnar
very much so! Both Con and Mike has contributed regularly to upstream
sched.c:
The problem here is tha Con can get demotivated (and rather upset) when an idea gets proposed, like SchedPlug, only to have people be hostile to it and then sudden turn around an adopt this idea. It give the impression that you, in this specific case, were more interested in controlling a situation and the track of development instead of actually being inclusive of the development process with discussion and serious consideration, etc...
This is how the Linux community can be perceived as elitist. The old guard would serve the community better if people were more mindful and sensitive to developer issues. There was a particular speech that I was turned off by at OLS 2006 that pretty much pandering to the "old guard's" needs over newer developers. Since I'm a some what established engineer in -rt (being the only other person that mapped the lock hierarchy out for full preemptibility), I had the confidence to pretty much ignored it while previously this could have really upset me and be highly discouraging to a relatively new developer.
As Linux gets larger and larger this is going to be an increasing problem when folks come into the community with new ideas and the community will need to change if it intends to integrate these folks. IMO, a lot of these flame ware wouldn't need to exist if folks listent ot each other better and permit co-ownership of code like the scheduler since it needs multipule hands in it adapt to new loads and situations, etc...
I'm saying this nicely now since I can be nasty about it.
bill
Quoted 8 lines · Ingo Molnar
[announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS]
i'm pleased to announce the first release of the "Modular Scheduler Core and Completely Fair Scheduler [CFS]" patchset:
http://redhat.com/~mingo/cfs-scheduler/sched-modular+cfs.patch
[...]
Quoted 3 lines
as usual, any sort of feedback, bugreports, fixes and suggestions are more than welcome,
Compile error here.
...
CC kernel/sched.okernel/sched.c: In function '__rq_clock':kernel/sched.c:219: error: 'struct rq' has no member named 'cpu' kernel/sched.c:219: warning: type defaults to 'int' in declaration of '__ret_warn_once' kernel/sched.c:219: error: 'struct rq' has no member named 'cpu' kernel/sched.c: In function 'rq_clock':kernel/sched.c:230: error: 'struct rq' has no member named 'cpu' kernel/sched.c: In function 'sched_init':kernel/sched.c:6013: warning: unused variable 'j'
make[1]: *** [kernel/sched.o] Error 1
make: *** [kernel] Error 2
==> ERROR: Build Failed. Aborting...
...
There the config :
http://frugalware.org/~crazy/other/kernel/config
Quoted 4 lines
Ingo
-
Regards,
Gabriel
Quoted 4 lines · Gabriel C
Quoted 2 lines
as usual, any sort of feedback, bugreports, fixes and suggestions are more than welcome,
Compile error here.
ah, !CONFIG_SMP. Does the patch below do the trick for you? (I've also updated the full patch at the cfs-scheduler URL)
Ingo
----------------------->
From: Ingo Molnar <[email protected]>
Subject: [cfs] fix !CONFIG_SMP build
fix the !CONFIG_SMP build error reported by Gabriel C
kernel/sched.c +10 -10
@@ -257,16 +257,6 @@ static inline unsigned long long __rq_clreturn rq->rq_clock; } -static inline unsigned long long rq_clock (struct rq *rq) -{ -int this_cpu =smp_processor_id (); - -if (this_cpu == rq->cpu) -return __rq_clock (rq); - -return rq->rq_clock; -} -static inline int cpu_of (struct rq *rq) {#ifdef CONFIG_SMP
@@ -276,6 +266,16 @@ static inline int cpu_of(struct rq *rq)#endif } +static inline unsigned long long rq_clock (struct rq *rq) +{ +int this_cpu =smp_processor_id (); + +if (this_cpu ==cpu_of (rq)) +return __rq_clock (rq); + +return rq->rq_clock; +} +/* * The domain tree (rq->sd) is protected by RCU's quiescent state transition. * See detach_destroy_domains: synchronize_sched for details.
Quoted 10 lines · Ingo Molnar
Quoted 4 lines · Gabriel C
Quoted 2 lines
as usual, any sort of feedback, bugreports, fixes and suggestions are more than welcome,
Compile error here.
ah, !CONFIG_SMP. Does the patch below do the trick for you? (I've also updated the full patch at the cfs-scheduler URL)
Yes it does , thx :) , only the " warning: unused variable 'j' " left.
Quoted 2 lines
Ingo
Regards,
Gabriel
Quoted 6 lines · Ingo Molnar
[announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS]
i'm pleased to announce the first release of the "Modular Scheduler Core and Completely Fair Scheduler [CFS]" patchset:
http://redhat.com/~mingo/cfs-scheduler/sched-modular+cfs.patch
Always good to see another contender ;)
Quoted 9 lines
This project is a complete rewrite of the Linux task scheduler. My goal is to address various feature requests and to fix deficiencies in the vanilla scheduler that were suggested/found in the past few years, both for desktop scheduling and for server scheduling workloads.
[ QuickStart: apply the patch to v2.6.21-rc6, recompile, reboot. The
new scheduler will be active by default and all tasks will default to the newSCHED_FAIRinteractive scheduling class. ]
I don't know why there is such noise about fairness right now... I thought fairness was one of the fundamental properties of a good CPU scheduler, and my scheduler definitely always aims for that above most other things. Why not just keep SCHED_OTHER?
Quoted 6 lines
Highlights are:
- the introduction of Scheduling Classes: an extensible hierarchy of scheduler modules. These modules encapsulate scheduling policy details and are handled by the scheduler core without the core code assuming about them too much.
Don't really like this, but anyway...
Quoted 7 lines
-
sched_fair.cimplements the 'CFS desktop scheduler': it is a replacement for the vanilla scheduler'sSCHED_OTHERinteractivity code.i'd like to give credit to Con Kolivas for the general approach here:
he has proven via RSDL/SD that 'fair scheduling' is possible and that it results in better desktop scheduling. Kudos Con!
I guess the 2.4 and earlier scheduler kind of did that as well.
Quoted 6 lines
The CFS patch uses a completely different approach and implementation from RSDL/SD. My goal was to make CFS's interactivity quality exceed that of RSDL/SD, which is a high standard to meet :-) Testing feedback is welcome to decide this one way or another. [ and, in any case, all of SD's logic could be added via a
kernel/sched_sd.cmodule as well, if Con is interested in such an approach. ]
Comment about the code: shouldn't you be requeueing the task in the rbtree wherever you change wait_runtime? eg. task_new_fair? (I've only had a quick look so far).
Quoted 8 lines
CFS's design is quite radical: it does not use runqueues, it uses a time-ordered rbtree to build a 'timeline' of future task execution, and thus has no 'array switch' artifacts (by which both the vanilla scheduler and RSDL/SD are affected).
CFS uses nanosecond granularity accounting and does not rely on any jiffies or other HZ detail. Thus the CFS scheduler has no notion of 'timeslices' and has no heuristics whatsoever.
Well, I guess there is still some mechanism to decide which process is most eligible to run? ;) Considering that question has no "right" answer for SCHED_OTHER scheduling, I guess you could say it has heuristics. But granted they are obviously fairly elegant in contrast to the O(1) scheduler ;)
Quoted 4 lines
There is only one
central tunable:
/proc/sys/kernel/sched_granularity_ns
Suppose you have 2 CPU hogs running, is sched_granularity_ns the frequency at which they will context switch?
Quoted 4 lines
( another rdetail: due to nanosec accounting and timeline sorting,
sched_yield()support is very simple under CFS, and in fact under CFSsched_yield()behaves much better than under any other scheduler i have tested so far. )
What is better behaviour for sched_yield?
Thanks,
Nick
Quoted 9 lines · Nick Piggin
Quoted 6 lines
The CFS patch uses a completely different approach and implementation from RSDL/SD. My goal was to make CFS's interactivity quality exceed that of RSDL/SD, which is a high standard to meet :-) Testing feedback is welcome to decide this one way or another. [ and, in any case, all of SD's logic could be added via a
kernel/sched_sd.cmodule as well, if Con is interested in such an approach. ]Comment about the code: shouldn't you be requeueing the task in the rbtree wherever you change
wait_runtime? eg.task_new_fair? [...]
yes: the task's position within the rbtree is updated every time wherever wait_runtime is change. task_new_fair is the method during new task creation, but indeed i forgot to requeue the parent. I've fixed this in my tree (see the delta patch below) - thanks!
Ingo
----------->
From: Ingo Molnar <[email protected]>
Subject: [cfs] fix parent's rbtree position
Nick noticed that upon fork we change parent->wait_runtime but we do not requeue it within the rbtree.
kernel/sched_fair.c +2 -0
@@ -524,6 +524,8 @@ static void task_new_fair(struct rq *rq, p->wait_runtime = parent->wait_runtime/2 ; parent->wait_runtime /=2 ; +requeue_task_fair (rq, parent); +/* * For the first timeslice we allow child threads * to move their parent-inherited fairness back
Quoted 2 lines · Ingo Molnar
Nick noticed that upon fork we change
parent->wait_runtimebut we do not requeue it within the rbtree.
this fix is not complete - because the child runqueue is locked here, not the parent's. I've fixed this properly in my tree and have uploaded a new sched-modular+cfs.patch. (the effects of the original bug are mostly harmless, the rbtree position gets corrected the first time the parent reschedules. The fix might improve heavy forker handling.)
Ingo
Quoted 11 lines · Ingo Molnar
Quoted 2 lines · Ingo Molnar
Nick noticed that upon fork we change
parent->wait_runtimebut we do not requeue it within the rbtree.this fix is not complete - because the child runqueue is locked here, not the parent's. I've fixed this properly in my tree and have uploaded a new sched-modular+cfs.patch. (the effects of the original bug are mostly harmless, the rbtree position gets corrected the first time the parent reschedules. The fix might improve heavy forker handling.)
It looks like it did not reach your public dir yet.
BTW, I've given it a try. It seems pretty usable. I have also tried the usual meaningless "glxgears" test with 12 of them at the same time, and they rotate very smoothly, there is absolutely no pause in any of them. But they don't all run at same speed, and top reports their CPU load varying from 3.4 to 10.8%, with what looks like more CPU is assigned to the first processes, and less CPU for the last ones. But this is just a rough observation on a stupid test, I would not call that one scientific in any way (and X has its share in the test too).
I'll perform other tests when I can rebuild with your fixed patch.
Cheers,
Willy
Quoted 15 lines · Willy Tarreau
Quoted 11 lines · Ingo Molnar
Quoted 2 lines · Ingo Molnar
Nick noticed that upon fork we change
parent->wait_runtimebut we do not requeue it within the rbtree.this fix is not complete - because the child runqueue is locked here, not the parent's. I've fixed this properly in my tree and have uploaded a new sched-modular+cfs.patch. (the effects of the original bug are mostly harmless, the rbtree position gets corrected the first time the parent reschedules. The fix might improve heavy forker handling.)
It looks like it did not reach your public dir yet.
Quoted 8 lines
BTW, I've given it a try. It seems pretty usable. I have also tried the usual meaningless "glxgears" test with 12 of them at the same time, and they rotate very smoothly, there is absolutely no pause in any of them. But they don't all run at same speed, and top reports their CPU load varying from 3.4 to 10.8%, with what looks like more CPU is assigned to the first processes, and less CPU for the last ones. But this is just a rough observation on a stupid test, I would not call that one scientific in any way (and X has its share in the test too).
Follow-up: I think this is mostly X-related. I've started 100 scheddos, and all get the same CPU percentage. Interestingly, mpg123 in parallel does never skip at all because it needs quite less than 1% CPU and gets its fair share at a load of 112. Xterms are slow to respond to typing with the 12 gears and 100 scheddos, and expectedly it was X which was starving. renicing it to -5 restores normal feeling with very slow but smooth gear rotations. Leaving X niced at 0 and killing the gears also restores normal behaviour.
All in all, it seems logical that processes which serve many others become a bottleneck for them.
Forking becomes very slow above a load of 100 it seems. Sometimes, the shell takes 2 or 3 seconds to return to prompt after I run "scheddos &"
Those are very promising results, I nearly observe the same responsiveness as I had on a solaris 10 with 10k running processes on a bigger machine.
I would be curious what a mysql test result would look like now.
Regards,
Willy
Quoted 3 lines · Willy Tarreau
Forking becomes very slow above a load of 100 it seems. Sometimes, the shell takes 2 or 3 seconds to return to prompt after I run "scheddos &"
this might be changed/impacted by the parent-requeue fix that is in the updated (for real, promise! ;) patch. Right now on CFS a forking parent shares its own run stats with the child 50%/50%. This means that heavy forkers are indeed penalized. Another logical choice would be 100%/0%: a child has to earn its own right.
i kept the 50%/50% rule from the old scheduler, but maybe it's a more pristine (and smaller/faster) approach to just not give new children any stats history to begin with. I've implemented an add-on patch that implements this, you can find it at:
http://redhat.com/~mingo/cfs-scheduler/sched-fair-fork.patch
Quoted 3 lines
Those are very promising results, I nearly observe the same responsiveness as I had on a solaris 10 with 10k running processes on a bigger machine.
cool and thanks for the feedback! (Btw., as another test you could also try to renice "scheddos" to +19. While that does not push the scheduler nearly as hard as nice 0, it is perhaps more indicative of how a truly abusive many-tasks workload would be run in practice.)
Ingo
Quoted 13 lines · Ingo Molnar
Quoted 3 lines · Willy Tarreau
Forking becomes very slow above a load of 100 it seems. Sometimes, the shell takes 2 or 3 seconds to return to prompt after I run "scheddos &"
this might be changed/impacted by the parent-requeue fix that is in the updated (for real, promise! ;) patch. Right now on CFS a forking parent shares its own run stats with the child 50%/50%. This means that heavy forkers are indeed penalized. Another logical choice would be 100%/0%: a child has to earn its own right.
Quoted 6 lines
i kept the 50%/50% rule from the old scheduler, but maybe it's a more pristine (and smaller/faster) approach to just not give new children any stats history to begin with. I've implemented an add-on patch that implements this, you can find it at:
http://redhat.com/~mingo/cfs-scheduler/sched-fair-fork.patch
Not tried yet, it already looks better with the update and sched-fair-hog. Now xterm open "instantly" even with 1000 running processes.
Quoted 8 lines
Quoted 3 lines
Those are very promising results, I nearly observe the same responsiveness as I had on a solaris 10 with 10k running processes on a bigger machine.
cool and thanks for the feedback! (Btw., as another test you could also try to renice "scheddos" to +19. While that does not push the scheduler nearly as hard as nice 0, it is perhaps more indicative of how a truly abusive many-tasks workload would be run in practice.)
Good idea. The machine I'm typing from now has 1000 scheddos running at +19, and 12 gears at nice 0. Top keeps reporting different cpu usages for all gears, but I'm pretty sure that it's a top artifact now because the cumulated times are roughly identical :
14:33:13 up 13 min, 7 users, load average: 900.30, 443.75, 177.70
1088 processes: 80 sleeping, 1008 running, 0 zombie, 0 stopped
CPU0 states: 56.0% user 43.0% system 23.0% nice 0.0% iowait 0.0% idle
CPU1 states: 94.0% user 5.0% system 0.0% nice 0.0% iowait 0.0% idle
Mem: 1034764k av, 223788k used, 810976k free, 0k shrd, 7192k buff
104400k active, 51904k inactiveSwap: 497972k av, 0k used, 497972k free 68020k cached
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND 1325 root 20 0 69240 9400 3740 R 27.6 0.9 4:46 1 X 1412 willy 20 0 6284 2552 1740 R 14.2 0.2 1:09 1 glxgears 1419 willy 20 0 6256 2384 1612 R 10.7 0.2 1:09 1 glxgears 1409 willy 20 0 2824 1940 788 R 8.9 0.1 0:25 1 top 1414 willy 20 0 6280 2544 1728 S 8.9 0.2 1:08 0 glxgears 1415 willy 20 0 6256 2376 1600 R 8.9 0.2 1:07 1 glxgears 1417 willy 20 0 6256 2384 1612 S 8.9 0.2 1:05 1 glxgears 1420 willy 20 0 6284 2552 1740 R 8.9 0.2 1:07 1 glxgears 1410 willy 20 0 6256 2372 1600 S 7.1 0.2 1:11 1 glxgears 1413 willy 20 0 6260 2388 1612 S 7.1 0.2 1:08 0 glxgears 1416 willy 20 0 6284 2544 1728 S 6.2 0.2 1:06 0 glxgears 1418 willy 20 0 6252 2384 1612 S 6.2 0.2 1:09 0 glxgears 1411 willy 20 0 6280 2548 1740 S 5.3 0.2 1:15 1 glxgears 1421 willy 20 0 6280 2536 1728 R 5.3 0.2 1:05 1 glxgears
Quoted 1 line
From time to time, one of the 12 aligned gears will quickly perform a full
quarter of round while others slowly turn by a few degrees. In fact, while I don't know this process's CPU usage pattern, there's something useful in it : it allows me to visually see when process accelerate/deceleraet. What would be best would be just a clock requiring low X ressources and eating vast amounts of CPU between movements. It will help visually monitor CPU distribution without being too much impacted by X.
I've just added another 100 scheddos at nice 0, and the system is still amazingly usable. I just tried exchanging a 1-byte token between 188 "dd" processes which communicate through circular pipes. The context switch rate is rather high but this has no impact on the rest :
willy@pcw:c$ dd if=/tmp/fifo bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | dd bs=1 | (echo -n a;dd bs=1) | dd bs=1 of=/tmp/fifo
procs memory swap io system cpu
r b w swpd free buff cache si so bi bo in cs us sy id
1105 0 1 0 781108 8364 68180 0 0 0 12 5 82187 59 41 0 1114 0 1 0 781108 8364 68180 0 0 0 0 0 81528 58 42 0 1112 0 1 0 781108 8364 68180 0 0 0 0 1 80899 58 42 0 1113 0 1 0 781108 8364 68180 0 0 0 0 26 83466 58 42 0 1106 0 2 0 781108 8376 68168 0 0 0 8 91 83193 58 42 0 1107 0 1 0 781108 8376 68180 0 0 0 4 7 79951 58 42 0 1106 0 1 0 781108 8376 68180 0 0 0 0 46 80939 57 43 0 1114 0 1 0 781108 8376 68180 0 0 0 0 21 82019 56 44 0 1116 0 1 0 781108 8376 68180 0 0 0 0 16 85134 56 44 0 1114 0 3 0 781108 8388 68168 0 0 0 16 20 85871 56 44 0 1112 0 1 0 781108 8388 68168 0 0 0 0 15 80412 57 43 0 1112 0 1 0 781108 8388 68180 0 0 0 0 101 83002 58 42 0 1113 0 1 0 781108 8388 68180 0 0 0 0 25 82230 56 44 0
Playing with the sched_max_hog_history_ns does not seem to change anything. Maybe it's useful for other workloads. Anyway, I have nothing to complain about, because it's not common for me to be able to normally type a mail on a system with more than 1000 running processes ;-)
Also, mixed with this load, I have started injecting HTTP requests between two local processes. The load is stable at 7700 req/s (11800 when alone), and what I was interested in is the response time. It's perfectly stable between 9.0 and 9.4 ms with a standard deviation of about 6.0 ms. Those were varying a lot under stock scheduler, with some sessions sometimes pausing for seconds. (RSDL fixed this though).
Well, I'll stop heating the room for now as I get out of ideas about how to defeat it. I'm convinced. I'm impatient to read about Mike's feedback with his workload which behaves strangely on RSDL. If it works OK here, it will be the proof that heuristics should not be needed.
Congrats !
Willy
Quoted 3 lines · Willy Tarreau
Well, I'll stop heating the room for now as I get out of ideas about how to defeat it.
Ah, I found something nasty.
If I start large batches of processes like this :
$ for i in $(seq 1 1000); do ./scheddos2 4000 4000 & done
the ramp up slows down after 700-800 processes, but something very strange happens. If I'm under X, I can switch the focus to all xterms (the WM is still alive) but all xterms are frozen. On the console, after one moment I simply cannot switch to another VT anymore while I can still start commands locally. But "chvt 2" simply blocks. SysRq-K killed everything and restored full control. Dmesg shows lots of :
SAK: killed process xxxx (scheddos2): process_session(p)==tty->session.
I wonder if part of the problem would be too many processes bound to the same tty :-/
I'll investigate a bit.
Willy
Quoted 19 lines · Willy Tarreau
Quoted 3 lines · Willy Tarreau
Well, I'll stop heating the room for now as I get out of ideas about how to defeat it.
Ah, I found something nasty.
If I start large batches of processes like this :$ for i in $(seq 1 1000); do ./scheddos2 4000 4000 & donethe ramp up slows down after 700-800 processes, but something very strange happens. If I'm under X, I can switch the focus to all xterms (the WM is still alive) but all xterms are frozen. On the console, after one moment I simply cannot switch to another VT anymore while I can still start commands locally. But "chvt 2" simply blocks. SysRq-K killed everything and restored full control. Dmesg shows lots of :
SAK: killed process xxxx (scheddos2): process_session(p)==tty->session.
Quoted 2 lines
I wonder if part of the problem would be too many processes bound to the same tty :-/
Does not seem easy to reproduce, it looks like some resource pools are kept pre-allocated after a first run, because if I kill scheddos during the ramp up then start it again, it can go further. The problem happens when the parent is forking. Also, I modified scheddos to close(0,1,2) and to perform the forks itself and it does not cause any problem, even with 4000 processes running. So I really suspect that the problem I encountered above was tty-related.
BTW, I've tried your fork patch. It definitely helps forking because it takes below one second to create 4000 processes, then the load slowly increases. As you said, the children have to earn their share, and I find that it makes it easier to conserve control of the whole system's stability.
Regards,
Willy
Quoted 5 lines · Willy Tarreau
BTW, I've tried your fork patch. It definitely helps forking because it takes below one second to create 4000 processes, then the load slowly increases. As you said, the children have to earn their share, and I find that it makes it easier to conserve control of the whole system's stability.
ok, thanks for testing this out, i think i'll integrate this one back into the core. (I'm still unsure about the cpu-hog one.) And it saves some code-size too:
text data bss dec hex filename 23349 2705 24 26078 65de kernel/sched.o.cfs-v1 23189 2705 24 25918 653e kernel/sched.o.cfs-before 23052 2705 24 25781 64b5 kernel/sched.o.cfs-after
23366 4001 24 27391 6aff kernel/sched.o.vanilla 23671 4548 24 28243 6e53 kernel/sched.o.sd.v40
Ingo
Quoted 17 lines · Willy Tarreau
Quoted 3 lines · Willy Tarreau
Well, I'll stop heating the room for now as I get out of ideas about how to defeat it.
Ah, I found something nasty.
If I start large batches of processes like this :$ for i in $(seq 1 1000); do ./scheddos2 4000 4000 & donethe ramp up slows down after 700-800 processes, but something very strange happens. If I'm under X, I can switch the focus to all xterms (the WM is still alive) but all xterms are frozen. On the console, after one moment I simply cannot switch to another VT anymore while I can still start commands locally. But "chvt 2" simply blocks. SysRq-K killed everything and restored full control. Dmesg shows lots of :
Quoted 4 lines
SAK: killed process xxxx (scheddos2): process_session(p)==tty->session.
I wonder if part of the problem would be too many processes bound to the same tty :-/
hm, that's really weird. I've Cc:-ed the tty experts (Erik, Jiri, Alan), maybe this description rings a bell with them?
Ingo
Quoted 12 lines · Ingo Molnar
Quoted 10 lines · Willy Tarreau
Quoted 3 lines · Willy Tarreau
Well, I'll stop heating the room for now as I get out of ideas about how to defeat it.
Ah, I found something nasty.
If I start large batches of processes like this :$ for i in $(seq 1 1000); do ./scheddos2 4000 4000 & done
Quoted 8 lines
Quoted 8 lines
the ramp up slows down after 700-800 processes, but something very strange happens. If I'm under X, I can switch the focus to all xterms (the WM is still alive) but all xterms are frozen. On the console, after one moment I simply cannot switch to another VT anymore while I can still start commands locally. But "chvt 2" simply blocks. SysRq-K killed everything and restored full control. Dmesg shows lots of :
SAK: killed process xxxx (scheddos2): process_session(p)==tty->session.
This. Yes. SAK is noisy and tells you everything it kills.
Quoted 5 lines
Quoted 2 lines
I wonder if part of the problem would be too many processes bound to the same tty :-/
hm, that's really weird. I've Cc:-ed the tty experts (Erik, Jiri, Alan), maybe this description rings a bell with them?
Is there any swapping going on?
I'm inclined to suspect that it is a problem that has more to do with the number of processes and has nothing to do with ttys.
Anyway you can easily rule out ttys by having your startup program detach from a controlling tty before you start everything.
I'm more inclined to guess something is reading /proc a lot, or doing something that holds the tasklist lock, a lot or something like that, if the problem isn't that you are being kicked into swap.
Eric
Hi Eric,
[...]
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
the ramp up slows down after 700-800 processes, but something very strange happens. If I'm under X, I can switch the focus to all xterms (the WM is still alive) but all xterms are frozen. On the console, after one moment I simply cannot switch to another VT anymore while I can still start commands locally. But "chvt 2" simply blocks. SysRq-K killed everything and restored full control. Dmesg shows lots of :
SAK: killed process xxxx (scheddos2): process_session(p)==tty->session.
This. Yes. SAK is noisy and tells you everything it kills.
OK, that's what I suspected, but I did not know if the fact that it talked about the session was systematic or related to any particular state when it killed the task.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I wonder if part of the problem would be too many processes bound to the same tty :-/
hm, that's really weird. I've Cc:-ed the tty experts (Erik, Jiri, Alan), maybe this description rings a bell with them?
Is there any swapping going on?
Not at all.
Quoted 2 lines
I'm inclined to suspect that it is a problem that has more to do with the number of processes and has nothing to do with ttys.
It is clearly possible. What I found strange is that I could still fork processes (eg: ls, dmesg|tail), ... but not switch to another VT anymore. It first happened under X with frozen xterms but a perfectly usable WM, then I reproduced it on pure console to rule out any potential X problem.
Quoted 6 lines
Anyway you can easily rule out ttys by having your startup program detach from a controlling tty before you start everything.
I'm more inclined to guess something is reading /proc a lot, or doing something that holds the tasklist lock, a lot or something like that, if the problem isn't that you are being kicked into swap.
Oh I'm sorry you were invited into the discussion without a first description of the context. I was giving a try to Ingo's new scheduler, and trying to reach corner cases with lots of processes competing for CPU.
I simply used a "for" loop in bash to fork 1000 processes, and this problem happened between 700-800 children. The program only uses a busy loop and a pause. I then changed my program to close 0,1,2 and perform the fork itself, and the problem vanished. So there are two differences here :
- bash not forking anymore
- far less FDs on /dev/tty1
At first, I had around 2200 fds on /dev/tty1, reason why I suspected something in this area.
I agree that this is not normal usage at all, I'm just trying to attack Ingo's scheduler to ensure it is more robust than the stock one. But sometimes brute force methods can make other sleeping problems pop up.
Thinking about it, I don't know if there are calls to schedule() while switching from tty1 to tty2. Alt-F2 had no effect anymore, and "chvt 2" simply blocked. It would have been possible that a schedule() call somewhere got starved due to the load, I don't know.
Thanks,
Willy
Quoted 47 lines · Willy Tarreau
Hi Eric,
[...]
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
the ramp up slows down after 700-800 processes, but something very strange happens. If I'm under X, I can switch the focus to all xterms (the WM is still alive) but all xterms are frozen. On the console, after one moment I simply cannot switch to another VT anymore while I can still start commands locally. But "chvt 2" simply blocks. SysRq-K killed everything and restored full control. Dmesg shows lots of :
SAK: killed process xxxx (scheddos2): process_session(p)==tty->session.
This. Yes. SAK is noisy and tells you everything it kills.
OK, that's what I suspected, but I did not know if the fact that it talked about the session was systematic or related to any particular state when it killed the task.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I wonder if part of the problem would be too many processes bound to the same tty :-/
hm, that's really weird. I've Cc:-ed the tty experts (Erik, Jiri, Alan), maybe this description rings a bell with them?
Is there any swapping going on?
Not at all.
Quoted 2 lines
I'm inclined to suspect that it is a problem that has more to do with the number of processes and has nothing to do with ttys.
It is clearly possible. What I found strange is that I could still fork processes (eg: ls, dmesg|tail), ... but not switch to another VT anymore. It first happened under X with frozen xterms but a perfectly usable WM, then I reproduced it on pure console to rule out any potential X problem.
Quoted 6 lines
Anyway you can easily rule out ttys by having your startup program detach from a controlling tty before you start everything.
I'm more inclined to guess something is reading /proc a lot, or doing something that holds the tasklist lock, a lot or something like that, if the problem isn't that you are being kicked into swap.
Oh I'm sorry you were invited into the discussion without a first description of the context. I was giving a try to Ingo's new scheduler, and trying to reach corner cases with lots of processes competing for CPU.
Quoted 7 lines
I simply used a "for" loop in bash to fork 1000 processes, and this problem happened between 700-800 children. The program only uses a busy loop and a pause. I then changed my program to close 0,1,2 and perform the fork itself, and the problem vanished. So there are two differences here :
- bash not forking anymore
- far less FDs on/dev/tty1
Yes. But with /dev/tty1 being the controlling terminal in both cases, as you haven't dropped your session, or disassociated your tty.
The bash problem may have something to setpgid or scheduling effects. Hmm. I just looked and setpgid does grab the tasklist lock for writing so we may possibly have some contention there.
Quoted 6 lines
At first, I had around 2200 fds on
/dev/tty1, reason why I suspected something in this area.I agree that this is not normal usage at all, I'm just trying to attack Ingo's scheduler to ensure it is more robust than the stock one. But sometimes brute force methods can make other sleeping problems pop up.
Yep. If we can narrow it down to one that would be interesting. Of course that also means when we start finding other possibly sleeping problems people are working in areas of code the don't normally touch, so we must investigate.
Quoted 4 lines
Thinking about it, I don't know if there are calls to
schedule()while switching from tty1 to tty2. Alt-F2 had no effect anymore, and "chvt 2" simply blocked. It would have been possible that aschedule()call somewhere got starved due to the load, I don't know.
It looks like there is a call to schedule_work.
There are two pieces of the path. If you are switching in and out of a tty controlled by something like X. User space has to grant permission before the operation happens. Where there isn't a gate keeper I know it is cheaper but I don't know by how much, I suspect there is still a schedule happening in there.
Eric
Quoted 6 lines · Eric W. Biederman
Quoted 4 lines
Thinking about it, I don't know if there are calls to
schedule()while switching from tty1 to tty2. Alt-F2 had no effect anymore, and "chvt 2" simply blocked. It would have been possible that aschedule()call somewhere got starved due to the load, I don't know.It looks like there is a call to
schedule_work.
so this goes over keventd, right?
Quoted 5 lines
There are two pieces of the path. If you are switching in and out of a tty controlled by something like X. User space has to grant permission before the operation happens. Where there isn't a gate keeper I know it is cheaper but I don't know by how much, I suspect there is still a schedule happening in there.
Could keventd perhaps be starved? Willy, to exclude this possibility, could you perhaps chrt keventd to RT priority? If events/0 is PID 5 then the command to set it to SCHED_FIFO:50 would be:
chrt -f -p 50 5
but ... events/0 is reniced to -5 by default, so it should definitely not be starved.
Ingo
Quoted 18 lines · Ingo Molnar
Quoted 6 lines · Eric W. Biederman
Quoted 4 lines
Thinking about it, I don't know if there are calls to
schedule()while switching from tty1 to tty2. Alt-F2 had no effect anymore, and "chvt 2" simply blocked. It would have been possible that aschedule()call somewhere got starved due to the load, I don't know.It looks like there is a call to
schedule_work.so this goes over keventd, right?
Quoted 5 lines
There are two pieces of the path. If you are switching in and out of a tty controlled by something like X. User space has to grant permission before the operation happens. Where there isn't a gate keeper I know it is cheaper but I don't know by how much, I suspect there is still a schedule happening in there.
Quoted 8 lines
Could keventd perhaps be starved? Willy, to exclude this possibility, could you perhaps chrt keventd to RT priority? If events/0 is PID 5 then the command to set it to SCHED_FIFO:50 would be:
chrt -f -p 50 5
but ... events/0 is reniced to -5 by default, so it should definitely not be starved.
Well, since I merged the fair-fork patch, I cannot reproduce (in fact, bash forks 1000 processes, then progressively execs scheddos, but it takes some time). So I'm rebuilding right now. But I think that Linus has an interesting clue about GPM and notification before switching the terminal. I think it was enabled in console mode. I don't know how that translates to frozen xterms, but let's attack the problems one at a time.
Willy
Quoted 28 lines · Willy Tarreau
Quoted 18 lines · Ingo Molnar
Quoted 6 lines · Eric W. Biederman
Quoted 4 lines
Thinking about it, I don't know if there are calls to
schedule()while switching from tty1 to tty2. Alt-F2 had no effect anymore, and "chvt 2" simply blocked. It would have been possible that aschedule()call somewhere got starved due to the load, I don't know.It looks like there is a call to
schedule_work.so this goes over keventd, right?
Quoted 5 lines
There are two pieces of the path. If you are switching in and out of a tty controlled by something like X. User space has to grant permission before the operation happens. Where there isn't a gate keeper I know it is cheaper but I don't know by how much, I suspect there is still a schedule happening in there.
Quoted 8 lines
Could keventd perhaps be starved? Willy, to exclude this possibility, could you perhaps chrt keventd to RT priority? If events/0 is PID 5 then the command to set it to SCHED_FIFO:50 would be:
chrt -f -p 50 5
but ... events/0 is reniced to -5 by default, so it should definitely not be starved.
Quoted 7 lines
Well, since I merged the fair-fork patch, I cannot reproduce (in fact, bash forks 1000 processes, then progressively execs scheddos, but it takes some time). So I'm rebuilding right now. But I think that Linus has an interesting clue about GPM and notification before switching the terminal. I think it was enabled in console mode. I don't know how that translates to frozen xterms, but let's attack the problems one at a time.
I think it is a good clue. However the intention of the mechanism is that only processes that change the video mode on a VT are supposed to use it. So I really don't think gpm is the culprit. However it easily could be something else that has similar characteristics.
I just realized we do have proof that schedule_work is actually working because SAK works, and we can't sanely do SAK from interrupt context so we call schedule work.
Eric
Quoted 38 lines · Eric W. Biederman
Quoted 28 lines · Willy Tarreau
Quoted 18 lines · Ingo Molnar
Quoted 6 lines · Eric W. Biederman
Quoted 4 lines
Thinking about it, I don't know if there are calls to
schedule()while switching from tty1 to tty2. Alt-F2 had no effect anymore, and "chvt 2" simply blocked. It would have been possible that aschedule()call somewhere got starved due to the load, I don't know.It looks like there is a call to
schedule_work.so this goes over keventd, right?
Quoted 5 lines
There are two pieces of the path. If you are switching in and out of a tty controlled by something like X. User space has to grant permission before the operation happens. Where there isn't a gate keeper I know it is cheaper but I don't know by how much, I suspect there is still a schedule happening in there.
Quoted 8 lines
Could keventd perhaps be starved? Willy, to exclude this possibility, could you perhaps chrt keventd to RT priority? If events/0 is PID 5 then the command to set it to SCHED_FIFO:50 would be:
chrt -f -p 50 5
but ... events/0 is reniced to -5 by default, so it should definitely not be starved.
Quoted 7 lines
Well, since I merged the fair-fork patch, I cannot reproduce (in fact, bash forks 1000 processes, then progressively execs scheddos, but it takes some time). So I'm rebuilding right now. But I think that Linus has an interesting clue about GPM and notification before switching the terminal. I think it was enabled in console mode. I don't know how that translates to frozen xterms, but let's attack the problems one at a time.
Quoted 8 lines
I think it is a good clue. However the intention of the mechanism is that only processes that change the video mode on a VT are supposed to use it. So I really don't think gpm is the culprit. However it easily could be something else that has similar characteristics.
I just realized we do have proof that
schedule_workis actually working because SAK works, and we can't sanely do SAK from interrupt context so we call schedule work.
Eric,
I can say that Linus, Ingo and you all got on the right track. I could reproduce, I got a hung tty around 1400 running processes. Fortunately, it was the one with the root shell which was reniced to -19.
I could strace chvt 2 :
20:44:23.761117 open("/dev/tty", O_RDONLY) = 3 <0.004000> 20:44:23.765117 ioctl(3, KDGKBTYPE, 0xbfa305a3) = 0 <0.024002> 20:44:23.789119 ioctl(3, VIDIOC_G_COMP or VT_ACTIVATE, 0x3) = 0 <0.000000> 20:44:23.789119 ioctl(3, VIDIOC_S_COMP or VT_WAITACTIVE <unfinished ...>
Then I applied Ingo's suggestion about changing keventd prio :
root@pcw:~# ps auxw|grep event root 8 0.0 0.0 0 0 ? SW< 20:31 0:00 [events/0] root 9 0.0 0.0 0 0 ? RW< 20:31 0:00 [events/1]
root@pcw:~# rtprio -s 1 -p 50 8 9 (I don't have chrt but it does the same)
My VT immediately switched as soon as I hit Enter. Everything's working fine again now. So the good news is that it's not a bug in the tty code, nor a deadlock.
Now, maybe keventd should get a higher prio ? It seems worrying to me that it may starve when it seems so much sensible.
Also, that may explain why I couldn't reproduce with the fork patch. Since all new processes got no runtime at first, their impact on existing ones must have been lower. But I think that if I had waited longer, I would have had the problem again (though I did not see it even under a load of 7800).
Regards,
Willy
Quoted 7 lines · Willy Tarreau
Well, since I merged the fair-fork patch, I cannot reproduce (in fact, bash forks 1000 processes, then progressively execs scheddos, but it takes some time). So I'm rebuilding right now. But I think that Linus has an interesting clue about GPM and notification before switching the terminal. I think it was enabled in console mode. I don't know how that translates to frozen xterms, but let's attack the problems one at a time.
to debug this, could you try to apply this add-on as well:
http://redhat.com/~mingo/cfs-scheduler/sched-fair-print.patch
with this patch applied you should have a /proc/sched_debug file that prints all runnable tasks and other interesting info from the runqueue.
[ i've refreshed all the patches on the CFS webpage, so if this doesnt
apply cleanly to your current tree then you'll probably have to refresh one of the patches.]
The output should look like this:
Sched Debug Version: v0.01
now at 226761724575 nsecs
cpu: 0
.nr_running : 3 .raw_weighted_load : 384 .nr_switches : 13666 .nr_uninterruptible : 0 .next_balance : 4294947416 .curr->pid : 2179 .rq_clock : 241337421233 .fair_clock : 7503791206 .wait_runtime : 2269918379
runnable tasks:
task | PID | tree-key | -delta | waiting | switches
-----------------------------------------------------------------
+ cat 2179 7501930066 -1861140 1861140 2
loop_silent 2149 7503010354 -780852 0 911
loop_silent 2148 7503510048 -281158 280753 918now for your workload the list should be considerably larger. If there's starvation going on then the 'switches' field (number of context switches) of one of the tasks would never increase while you have this 'cannot switch consoles' problem.
maybe you'll have to unapply the fair-fork patch to make it trigger again. (fair-fork does not fix anything, so it probably just hides a real bug.)
(i'm meanwhile busy running your scheddos utilities to reproduce it locally as well :)
Ingo
Hi Ingo,
Quoted 11 lines · Ingo Molnar
Quoted 7 lines · Willy Tarreau
Well, since I merged the fair-fork patch, I cannot reproduce (in fact, bash forks 1000 processes, then progressively execs scheddos, but it takes some time). So I'm rebuilding right now. But I think that Linus has an interesting clue about GPM and notification before switching the terminal. I think it was enabled in console mode. I don't know how that translates to frozen xterms, but let's attack the problems one at a time.
Quoted 6 lines
to debug this, could you try to apply this add-on as well:
http://redhat.com/~mingo/cfs-scheduler/sched-fair-print.patch
with this patch applied you should have a
/proc/sched_debugfile that prints all runnable tasks and other interesting info from the runqueue.
I don't know if you have seen my mail from yesterday evening (here). I found that changing keventd prio fixed the problem. You may be interested in the description. I sent it at 21:01 (+200).
Quoted 3 lines
[ i've refreshed all the patches on the CFS webpage, so if this doesnt
apply cleanly to your current tree then you'll probably have to refresh one of the patches.]
Fine, I'll have a look. I already had to rediff the sched-fair-fork patch last time.
Quoted 16 lines
The output should look like this:
Sched Debug Version: v0.01
now at 226761724575 nsecscpu: 0
.nr_running : 3 .raw_weighted_load : 384 .nr_switches : 13666 .nr_uninterruptible : 0 .next_balance : 4294947416 .curr->pid : 2179 .rq_clock : 241337421233 .fair_clock : 7503791206 .wait_runtime : 2269918379
Quoted 6 lines
runnable tasks:
task | PID | tree-key | -delta | waiting | switches
-----------------------------------------------------------------+ cat 2179 7501930066 -1861140 1861140 2 loop_silent 2149 7503010354 -780852 0 911 loop_silent 2148 7503510048 -281158 280753 918
Nice.
Quoted 11 lines
now for your workload the list should be considerably larger. If there's starvation going on then the 'switches' field (number of context switches) of one of the tasks would never increase while you have this 'cannot switch consoles' problem.
maybe you'll have to unapply the fair-fork patch to make it trigger again. (fair-fork does not fix anything, so it probably just hides a real bug.)
(i'm meanwhile busy running your scheddos utilities to reproduce it locally as well :)
I discovered I had the frame-buffer enabled (I did not notice it first because I do not have the logo and the resolution is the same as text). It's matroxfb with a G400, if that can help. It may be possible that it needs some CPU that it cannot get to clear the display before switching, I don't know.
However I won't try this right now, I'm deep in userland at the moment.
Regards,
Willy
Quoted 11 lines · Willy Tarreau
Quoted 7 lines
to debug this, could you try to apply this add-on as well:
http://redhat.com/~mingo/cfs-scheduler/sched-fair-print.patch
with this patch applied you should have a
/proc/sched_debugfile that prints all runnable tasks and other interesting info from the runqueue.I don't know if you have seen my mail from yesterday evening (here). I found that changing keventd prio fixed the problem. You may be interested in the description. I sent it at 21:01 (+200).
ah, indeed i missed that mail - the response to the patches was quite overwhelming (and i naively thought people dont do Linux hacking over the weekends anymore ;).
so Linus was right: this was caused by scheduler starvation. I can see one immediate problem already: the 'nice offset' is not divided by nr_running as it should. The patch below should fix this but i have yet to test it accurately, this change might as well render nice levels unacceptably ineffective under high loads.
Ingo
--------->
--- kernel/sched_fair.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/sched_fair.c +3 -1
@@ -31,7 +31,9 @@ static void __enqueue_task_fair(struct rint leftmost =1 ;long long key; - key = rq->fair_clock - p->wait_runtime + p->nice_offset; + key = rq->fair_clock - p->wait_runtime; +if (unlikely (p->nice_offset)) + key += p->nice_offset / rq->nr_running; p->fair_key = key;
Quoted 5 lines · Ingo Molnar
so Linus was right: this was caused by scheduler starvation. I can see one immediate problem already: the 'nice offset' is not divided by
nr_runningas it should. The patch below should fix this but i have yet to test it accurately, this change might as well render nice levels unacceptably ineffective under high loads.
I've been suggesting testing CPU bandwidth allocation as influenced by nice numbers for a while now for a reason.
-- wli
Quoted 9 lines · William Lee Irwin III
Quoted 5 lines · Ingo Molnar
so Linus was right: this was caused by scheduler starvation. I can see one immediate problem already: the 'nice offset' is not divided by
nr_runningas it should. The patch below should fix this but i have yet to test it accurately, this change might as well render nice levels unacceptably ineffective under high loads.I've been suggesting testing CPU bandwidth allocation as influenced by nice numbers for a while now for a reason.
Oh I was very much testing "CPU bandwidth allocation as influenced by nice numbers" - it's one of the basic things i do when modifying the scheduler. An automated tool, while nice (all automation is nice) wouldnt necessarily show such bugs though, because here too it needed thousands of running tasks to trigger in practice. Any volunteers? ;)
Ingo
Quoted 2 lines · William Lee Irwin III
Quoted 2 lines
I've been suggesting testing CPU bandwidth allocation as influenced by nice numbers for a while now for a reason.
Quoted 5 lines · Ingo Molnar
Oh I was very much testing "CPU bandwidth allocation as influenced by nice numbers" - it's one of the basic things i do when modifying the scheduler. An automated tool, while nice (all automation is nice) wouldnt necessarily show such bugs though, because here too it needed thousands of running tasks to trigger in practice. Any volunteers? ;)
Worse comes to worse I might actually get around to doing it myself. Any more detailed descriptions of the test for a rainy day?
-- wli
Quoted 9 lines · William Lee Irwin III
Quoted 5 lines · Ingo Molnar
Oh I was very much testing "CPU bandwidth allocation as influenced by nice numbers" - it's one of the basic things i do when modifying the scheduler. An automated tool, while nice (all automation is nice) wouldnt necessarily show such bugs though, because here too it needed thousands of running tasks to trigger in practice. Any volunteers? ;)
Worse comes to worse I might actually get around to doing it myself. Any more detailed descriptions of the test for a rainy day?
the main complication here is that the handling of nice levels is still typically a 2nd or 3rd degree design factor when writing schedulers. The reason isnt carelessness, the reason is simply that users typically only care about a single nice level: the one that all tasks run under by default.
Also, often there's just one or two good ways to attack the problem within a given scheduler approach and the quality of nice levels often suffers under other, more important design factors like performance.
This means that for example for the vanilla scheduler the distribution of CPU power depends on HZ, on the number of tasks and on the scheduling pattern. The distribution of CPU power amongst nice levels is basically a function of _everything_. That makes any automated test pretty challenging. Both with SD and with CFS there's a good chance to actually formalize the meaning of nice levels, but i'd not go as far as to mandate any particular behavior by rigidly saying "pass this automated tool, else ...", other than "make nice levels resonable". All the other more formal CPU resource limitation techniques are then a matter of CKRM-alike patches, which offer much more finegrained mechanisms than pure nice levels anyway.
so to answer your question: it's pretty much freely defined. Make up your mind about it and figure out the ways how people use nice levels and think about which aspects of that experience are worth testing for intelligently.
Ingo
Quoted 2 lines · William Lee Irwin III
Quoted 2 lines
Worse comes to worse I might actually get around to doing it myself. Any more detailed descriptions of the test for a rainy day?
Quoted 5 lines · Ingo Molnar
the main complication here is that the handling of nice levels is still typically a 2nd or 3rd degree design factor when writing schedulers. The reason isnt carelessness, the reason is simply that users typically only care about a single nice level: the one that all tasks run under by default.
I'm a bit unconvinced here. Support for prioritization is a major scheduler feature IMHO.
Quoted 6 lines · Ingo Molnar
Also, often there's just one or two good ways to attack the problem within a given scheduler approach and the quality of nice levels often suffers under other, more important design factors like performance. This means that for example for the vanilla scheduler the distribution of CPU power depends on HZ, on the number of tasks and on the scheduling pattern. The distribution of CPU power amongst nice levels is basically
Quoted 8 lines
a function of _everything_. That makes any automated test pretty challenging. Both with SD and with CFS there's a good chance to actually formalize the meaning of nice levels, but i'd not go as far as to mandate any particular behavior by rigidly saying "pass this automated tool, else ...", other than "make nice levels resonable". All the other more formal CPU resource limitation techniques are then a matter of CKRM-alike patches, which offer much more finegrained mechanisms than pure nice levels anyway.
Some of the issues with respect to the number of tasks and scheduling patterns can be made part of the test; one can furthermore insist that the system be quiescent in a variety of ways. I'm not convinced that formalization of nice levels is a bad idea. They're the standard UNIX prioritization facility, and it should work with some definite value of "work."
Even supposing one doesn't care to bolt down the semantics of nice levels, there should at least be some awareness of what those semantics are and when and how they're changing. So in that respect a test for CPU bandwidth distribution according to nice level remains valuable even supposing that the semantics aren't required to be rigidly fixed.
As far as CKRM goes, I'm wild about it. I wish things would get in shape to be merged (if they're not already) and merged ASAP on that front. I think with so much agreement in concept we can work with changing out implementations as-needed with it sitting in mainline once the the user API/ABI is decided upon, and I think it already is.
I'm not entirely convinced CKRM answers this, though. If the scheduler can't support nice levels, how is it supposed to support prioritization or CPU bandwidth allocation according to CKRM configurations? I'm relatively certain schedulers must be able to support prioritization with deterministic CPU bandwidth as essential functionality. This is, of course, not to say my certainty about things sets the standards for what testcases are considered meaningful and valid.
Quoted 4 lines · Ingo Molnar
so to answer your question: it's pretty much freely defined. Make up your mind about it and figure out the ways how people use nice levels and think about which aspects of that experience are worth testing for intelligently.
Looking for usage cases is a good idea; I'll do that before coding any testcase for nice semantics.
-- wli
Quoted 5 lines · Ingo Molnar
so Linus was right: this was caused by scheduler starvation. I can see one immediate problem already: the 'nice offset' is not divided by
nr_runningas it should. The patch below should fix this but i have yet to test it accurately, this change might as well render nice levels unacceptably ineffective under high loads.
erm, rather the updated patch below if you want to use this on a 32-bit system. But ... i think you should wait until i have all this re-tested.
Ingo
--- include/linux/sched.h | 2 +- kernel/sched_fair.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)
include/linux/sched.h +1 -1
@@ -839,7 +839,7 @@ struct task_struct {s64 wait_runtime;u64 exec_runtime, fair_key; -s64 nice_offset, hog_limit; +s32 nice_offset, hog_limit;unsigned long policy;cpumask_t cpus_allowed;
kernel/sched_fair.c +3 -1
@@ -31,7 +31,9 @@ static void __enqueue_task_fair(struct rint leftmost =1 ;long long key; - key = rq->fair_clock - p->wait_runtime + p->nice_offset; + key = rq->fair_clock - p->wait_runtime; +if (unlikely (p->nice_offset)) + key += p->nice_offset / (rq->nr_running +1 ); p->fair_key = key;
Quoted 3 lines · Willy Tarreau
It is clearly possible. What I found strange is that I could still fork processes (eg: ls, dmesg|tail), ... but not switch to another VT anymore.
Considering the patches in question, it's almost definitely just a CPU scheduling problem with starvation.
The VT switching is obviously done by the kernel, but the kernel will signal and wait for the "controlling process" for the VT. The most obvious case of that is X, of course, but even in text mode I think gpm will have taken control of the VT's it runs on (all of them), which means that when you initiate a VT switch, the kernel will actually signal the controlling process (gpm), and wait for it to acknowledge the switch.
If gpm doesn't get a timeslice for some reason (and it sounds like there may be some serious unfairness after "fork()"), your behaviour is explainable.
(NOTE! I've never actually looked at gpm sources or what it really does, so maybe I'm wrong, and it doesn't try to do the controlling VT thing, and something else is going on, but quite frankly, it sounds like the obvious candidate for this bug. Explaining it with some non-scheduler-related thing sounds unlikely, considering the patch in question).
Linus
Quoted 4 lines · Willy Tarreau
Well, I'll stop heating the room for now as I get out of ideas about how to defeat it. I'm convinced. I'm impatient to read about Mike's feedback with his workload which behaves strangely on RSDL. If it works OK here, it will be the proof that heuristics should not be needed.
You mean the X + mp3 player + audio visualization test? X+Gforce visualization have problems getting half of my box in the presence of two other heavy cpu using tasks. Behavior is _much_ better than RSDL/SD, but the synchronous nature of X/client seems to be a problem.
With this scheduler, renicing X/client does cure it, whereas with SD it did not help one bit. (I know a trivial way to cure that, and this framework makes that possible without dorking up fairness as a general policy.)
-Mike
Quoted 8 lines · Mike Galbraith
Quoted 5 lines · Willy Tarreau
Well, I'll stop heating the room for now as I get out of ideas about how to defeat it. I'm convinced. I'm impatient to read about Mike's feedback with his workload which behaves strangely on RSDL. If it works OK here, it will be the proof that heuristics should not be needed.
Quoted 7 lines
You mean the X + mp3 player + audio visualization test? X+Gforce visualization have problems getting half of my box in the presence of two other heavy cpu using tasks. Behavior is _much_ better than RSDL/SD, but the synchronous nature of X/client seems to be a problem.
With this scheduler, renicing X/client does cure it, whereas with SD it did not help one bit. [...]
thanks for testing it! I was quite worried about your setup - two tasks using up 50%/50% of CPU time, pitted against a kernel rebuild workload seems to be a hard workload to get right.
Quoted 2 lines
[...] (I know a trivial way to cure that, and this framework makes that possible without dorking up fairness as a general policy.)
great! Please send patches so i can add them (once you are happy with the solution) - i think your workload isnt special in any way and could hit other people too.
Ingo
Quoted 8 lines · Ingo Molnar
Quoted 2 lines · Mike Galbraith
[...] (I know a trivial way to cure that, and this framework makes that possible without dorking up fairness as a general policy.)
great! Please send patches so i can add them (once you are happy with the solution) - i think your workload isnt special in any way and could hit other people too.
I'll give it a shot. (have to read and actually understand your new code first though, then see if it's really viable)
-Mike
Quoted 8 lines · Willy Tarreau
Good idea. The machine I'm typing from now has 1000 scheddos running at +19, and 12 gears at nice 0. [...]
From time to time, one of the 12 aligned gears will quickly perform a full quarter of round while others slowly turn by a few degrees. In fact, while I don't know this process's CPU usage pattern, there's something useful in it : it allows me to visually see when process accelerate/decelerate. [...]
cool idea - i have just tried this and it rocks - you can easily see the 'nature' of CPU time distribution just via visual feedback. (Is there any easy way to start up 12 glxgears fully aligned, or does one always have to mouse around to get them into proper position?)
btw., i am using another method to quickly judge X's behavior: i started the 'snowflakes' plugin in Beryl on Fedora 7, which puts a nice smooth opengl-rendered snow fall on the desktop background. That gives me an idea about how well X is scheduling under various workloads, without having to instrument it explicitly.
Ingo
Hi Ingo,
Quoted 12 lines · Ingo Molnar
Quoted 8 lines · Willy Tarreau
Good idea. The machine I'm typing from now has 1000 scheddos running at +19, and 12 gears at nice 0. [...]
From time to time, one of the 12 aligned gears will quickly perform a full quarter of round while others slowly turn by a few degrees. In fact, while I don't know this process's CPU usage pattern, there's something useful in it : it allows me to visually see when process accelerate/decelerate. [...]
Quoted 4 lines
cool idea - i have just tried this and it rocks - you can easily see the 'nature' of CPU time distribution just via visual feedback. (Is there any easy way to start up 12 glxgears fully aligned, or does one always have to mouse around to get them into proper position?)
-- Replying quickly, I'm short in time --
You can certainly script it with -geometry. But it is the wrong application for this matter, because you benchmark X more than glxgears itself. What would be better is something like a line rotating 360 degrees and doing some short stuff between each degree, so that X is not much sollicitated, but the CPU would be spent more on the processes themselves.
Benchmarking interactions between X and multiple clients is a completely different test IMHO. Glxgears is between those two, making it inappropriate for scheduler tuning.
Regards,
Willy
Quoted 6 lines · Willy Tarreau
You can certainly script it with -geometry. But it is the wrong application for this matter, because you benchmark X more than glxgears itself. What would be better is something like a line rotating 360 degrees and doing some short stuff between each degree, so that X is not much sollicitated, but the CPU would be spent more on the processes themselves.
at least on my setup glxgears goes via DRI/DRM so there's no X scheduling inbetween at all, and the visual appearance of glxgears is a direct function of its scheduling.
Ingo
Quoted 8 lines · Ingo Molnar
Quoted 6 lines · Willy Tarreau
You can certainly script it with -geometry. But it is the wrong application for this matter, because you benchmark X more than glxgears itself. What would be better is something like a line rotating 360 degrees and doing some short stuff between each degree, so that X is not much sollicitated, but the CPU would be spent more on the processes themselves.
Quoted 5 lines
at least on my setup glxgears goes via DRI/DRM so there's no X scheduling inbetween at all, and the visual appearance of glxgears is a direct function of its scheduling.
Ingo
That doesn't appear to be the case here Ingo. Even when I know the rest of the system is lagged, glxgears continues to show very smooth and steady movement.
Signature · 5 lines
Cheers, Gene "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Yow! I just went below the poverty line!
Quoted 10 lines · Ingo Molnar
Quoted 6 lines · Willy Tarreau
You can certainly script it with -geometry. But it is the wrong application for this matter, because you benchmark X more than glxgears itself. What would be better is something like a line rotating 360 degrees and doing some short stuff between each degree, so that X is not much sollicitated, but the CPU would be spent more on the processes themselves.
Quoted 3 lines
at least on my setup glxgears goes via DRI/DRM so there's no X scheduling inbetween at all, and the visual appearance of glxgears is a direct function of its scheduling.
OK, I thought that somethink looking like a clock would be useful, especially if we could tune the amount of CPU spent per task instead of being limited by graphics drivers.
I searched freashmeat for a clock and found "orbitclock" by Jeremy Weatherford, which was exactly what I was looking for :
- small
- C only
- X11 only
- needed less than 5 minutes and no knowledge of X11 for the complete hack ! => Kudos to its author, sincerely !
I hacked it a bit to make it accept two parameters :
-R <run_time_in_microsecond> : time spent burning CPU cycles at each round -S <sleep_time_in_microsecond> : time spent getting a rest
It now advances what it thinks is a second at each iteration, so that it makes it easy to compare its progress with other instances (there are seconds, minutes and hours, so it's easy to visually count up to around 43200).
The modified code is here :
http://linux.1wt.eu/sched/orbitclock-0.2bench.tgz
What is interesting to note is that it's easy to make X work a lot (99%) by using 0 as the sleeping time, and it's easy to make the process work a lot by using large values for the running time associated with very low values (or 0) for the sleep time.
Ah, and it supports -geometry ;-)
It could become a useful scheduler benchmark !
Have fun !
Willy
Quoted 13 lines · Willy Tarreau
I hacked it a bit to make it accept two parameters :
-R <run_time_in_microsecond> : time spent burning CPU cycles at each round -S <sleep_time_in_microsecond> : time spent getting a restIt now advances what it thinks is a second at each iteration, so that it makes it easy to compare its progress with other instances (there are seconds, minutes and hours, so it's easy to visually count up to around 43200).
The modified code is here :
Quoted 8 lines
What is interesting to note is that it's easy to make X work a lot (99%) by using 0 as the sleeping time, and it's easy to make the process work a lot by using large values for the running time associated with very low values (or 0) for the sleep time.
Ah, and it supports -geometry ;-)
It could become a useful scheduler benchmark !
i just tried ocbench-0.3, and it is indeed very nice!
Would it make sense perhaps to (optionally?) also log some sort of periodic text feedback to stdout, about the quality of scheduling? Maybe even a 'run this many seconds' option plus a summary text output at the end (which would output measured runtime, observed longest/smallest latency and standard deviation of latencies maybe)? That would make it directly usable both as a 'consistency of X app scheduling' visual test and as an easily shareable benchmark with an objective numeric result as well.
Ingo
Quoted 9 lines · Ingo Molnar
Quoted 9 lines
The modified code is here :
http://linux.1wt.eu/sched/orbitclock-0.2bench.tgz
What is interesting to note is that it's easy to make X work a lot (99%) by using 0 as the sleeping time, and it's easy to make the process work a lot by using large values for the running time associated with very low values (or 0) for the sleep time.
Quoted 5 lines
Quoted 3 lines
Ah, and it supports -geometry ;-)
It could become a useful scheduler benchmark !
i just tried ocbench-0.3, and it is indeed very nice!
another thing i just noticed: when starting up lots of ocbench tasks (say -x 6 -y 6) then they (naturally) get started up with an already visible offset. It's nice to observe the startup behavior, but after that it would be useful if it were possible to 'resync' all those ocbench tasks so that they start at the same offset. [ Maybe a "killall -SIGUSR1 ocbench" could serve this purpose, without having to synchronize the tasks explicitly? ]
Ingo
Quoted 3 lines · Ingo Molnar
Quoted 1 line
It could become a useful scheduler benchmark !
i just tried ocbench-0.3, and it is indeed very nice!
another thing i noticed: when using a -y larger then 1, then the window title (at least on Metacity) overlaps and thus the ocbench tasks have different X overhead and get scheduled a bit assymetrically as well. Is there any way to start them up title-less perhaps?
Ingo
Hi Ingo,
I'm replying to your 3 mails at once.
Quoted 6 lines · Ingo Molnar
Quoted 3 lines · Ingo Molnar
Quoted 1 line
It could become a useful scheduler benchmark !
i just tried ocbench-0.3, and it is indeed very nice!
So as you've noticed just one minute after I put it there, I've updated the tool and renamed it ocbench. For others, it's here :
http://linux.1wt.eu/sched/
Useful news are proper positionning, automatic forking, and more visible progress with smaller windows, which eat less of X ressources.
Now about your idea of making it report information on stdout, I don't know if it would be that useful. There are many other command line tools for this purpose. This one's goal is to eat CPU with a visual control of CPU distribution only.
Concerning your idea of using a signal to resync every process, I agree with you. Running at 8x8 shows a noticeable offset. I've just uploaded v0.4 which supports your idea of sending USR1.
Quoted 4 lines
another thing i noticed: when using a -y larger then 1, then the window title (at least on Metacity) overlaps and thus the ocbench tasks have different X overhead and get scheduled a bit assymetrically as well. Is there any way to start them up title-less perhaps?
It has annoyed me a bit too, but I'm no X developer at all, so I don't know at all if it's possible nor how to do this. I know that my window manager even adds title bars to xeyes, so I'm not sure we can do this.
Right now, I've added a "-B <border size>" argument so that you can skip the size of your title bar. It's dirty but it's not my main job :-)
Thanks for your feedback
Willy
Hi,
Quoted 11 lines · Willy Tarreau
Quoted 4 lines
another thing i noticed: when using a -y larger then 1, then the window title (at least on Metacity) overlaps and thus the ocbench tasks have different X overhead and get scheduled a bit assymetrically as well. Is there any way to start them up title-less perhaps?
It has annoyed me a bit too, but I'm no X developer at all, so I don't know at all if it's possible nor how to do this. I know that my window manager even adds title bars to xeyes, so I'm not sure we can do this.
Right now, I've added a "-B <border size>" argument so that you can skip the size of your title bar. It's dirty but it's not my main job :-)
Here's a small patch that makes the windows unmanaged, which also causes ocbench to start up quite a bit faster on my box with larger number of windows, so it probably avoids some window manager overhead, which is a nice side-effect.
Björn
--
ocbench.c +6 -2
@@ -213,6 +213,7 @@int main (int argc,char *argv[]) {Window root;XGCValues gc_setup; +XSetWindowAttributes swa;int c, index, proc_x, proc_y, pid;int *pcount[] = {&HOUR , &MIN , &SEC };char *p, *q;
@@ -342,8 +343,11 @@alloc_color (fg, &orange);alloc_color (fg2, &blue); - win =XCreateSimpleWindow (dpy, root,X ,Y , width, height,0 , - black.pixel, black.pixel); + swa.override_redirect =1 ; + + win =XCreateWindow (dpy, root,X ,Y , width, height,0 , + CopyFromParent, InputOutput, CopyFromParent, + CWOverrideRedirect, &swa);XStoreName (dpy, win,"ocbench" );XSelectInput (dpy, win, ExposureMask | StructureNotifyMask);
Only in ocbench-0.4.1/: .README.swp
Hi Björn,
Quoted 12 lines · Björn Steinbrink
Hi,
Quoted 9 lines · Willy Tarreau
Quoted 4 lines
another thing i noticed: when using a -y larger then 1, then the window title (at least on Metacity) overlaps and thus the ocbench tasks have different X overhead and get scheduled a bit assymetrically as well. Is there any way to start them up title-less perhaps?
It has annoyed me a bit too, but I'm no X developer at all, so I don't know at all if it's possible nor how to do this. I know that my window manager even adds title bars to xeyes, so I'm not sure we can do this.
Quoted 7 lines
Quoted 2 lines
Right now, I've added a "-B <border size>" argument so that you can skip the size of your title bar. It's dirty but it's not my main job :-)
Here's a small patch that makes the windows unmanaged, which also causes ocbench to start up quite a bit faster on my box with larger number of windows, so it probably avoids some window manager overhead, which is a nice side-effect.
Excellent ! I've just merged it but conditionned it to a "-u" argument so that we can keep previous behaviour (moving the windows is useful especially when there are few of them).
So the new version 0.5 is available there :
I believe it's the last one for today as I'm late on some work.
Thanks !
Willy
Quoted 11 lines · Ingo Molnar
Quoted 6 lines · Willy Tarreau
You can certainly script it with -geometry. But it is the wrong application for this matter, because you benchmark X more than glxgears itself. What would be better is something like a line rotating 360 degrees and doing some short stuff between each degree, so that X is not much sollicitated, but the CPU would be spent more on the processes themselves.
at least on my setup glxgears goes via DRI/DRM so there's no X scheduling inbetween at all, and the visual appearance of glxgears is a direct function of its scheduling.
How much of the subjective interactiveness-feel of the desktop is at the mercy of the X server's scheduling and not the cpu scheduler?
I've noticed that video playback is significantly smoother and resistant to other load, when using MPlayer's opengl output, especially if "heavy" programs are running at the same time. Especially firefox and ksysguard seem to have found a way to cause video through Xv to look annoyingly jittery.
Quoted 9 lines · Jan Knutar
Quoted 8 lines · Ingo Molnar
Quoted 6 lines · Willy Tarreau
You can certainly script it with -geometry. But it is the wrong application for this matter, because you benchmark X more than glxgears itself. What would be better is something like a line rotating 360 degrees and doing some short stuff between each degree, so that X is not much sollicitated, but the CPU would be spent more on the processes themselves.
Quoted 6 lines
Quoted 3 lines
at least on my setup glxgears goes via DRI/DRM so there's no X scheduling inbetween at all, and the visual appearance of glxgears is a direct function of its scheduling.
How much of the subjective interactiveness-feel of the desktop is at the mercy of the X server's scheduling and not the cpu scheduler?
probably a lot. Hence the reason why I wanted something visually noticeable but using far less X resources than glxgears. The modified orbitclock is perfect IMHO.
Regards,
Willy
Quoted 15 lines · Ingo Molnar
Quoted 8 lines · Willy Tarreau
Good idea. The machine I'm typing from now has 1000 scheddos running at +19, and 12 gears at nice 0. [...]
From time to time, one of the 12 aligned gears will quickly perform a full quarter of round while others slowly turn by a few degrees. In fact, while I don't know this process's CPU usage pattern, there's something useful in it : it allows me to visually see when process accelerate/decelerate. [...]
cool idea - i have just tried this and it rocks - you can easily see the 'nature' of CPU time distribution just via visual feedback. (Is there any easy way to start up 12 glxgears fully aligned, or does one always have to mouse around to get them into proper position?)
Quoted 6 lines
btw., i am using another method to quickly judge X's behavior: i started the 'snowflakes' plugin in Beryl on Fedora 7, which puts a nice smooth opengl-rendered snow fall on the desktop background. That gives me an idea about how well X is scheduling under various workloads, without having to instrument it explicitly.
yes, its a cute idea, till you switch away from that screen to check progress on something else, like to compose this message.
===========
5913 frames in 5.0 seconds = 1182.499 FPS
6238 frames in 5.0 seconds = 1247.556 FPS
11380 frames in 5.0 seconds = 2275.905 FPS
10691 frames in 5.0 seconds = 2138.173 FPS
8707 frames in 5.0 seconds = 1741.305 FPS
10669 frames in 5.0 seconds = 2133.708 FPS
11392 frames in 5.0 seconds = 2278.037 FPS
11379 frames in 5.0 seconds = 2275.711 FPS
11310 frames in 5.0 seconds = 2261.861 FPS
11386 frames in 5.0 seconds = 2277.081 FPS
11292 frames in 5.0 seconds = 2258.353 FPS
11352 frames in 5.0 seconds = 2270.297 FPS
11415 frames in 5.0 seconds = 2282.886 FPS
11406 frames in 5.0 seconds = 2281.037 FPS
11483 frames in 5.0 seconds = 2296.533 FPS
11510 frames in 5.0 seconds = 2301.883 FPS
11123 frames in 5.0 seconds = 2224.266 FPS
8980 frames in 5.0 seconds = 1795.861 FPS
=======
The over 2000fps reports were while I was either looking at htop, or starting this message, both on different screens. htop said it was using 95+ % of the cpu even when its display was going to /dev/null. So 'Kewl' doesn't seem to get us apples to apples numbers we can go to the window and bet win-place-show based on them alone.
FWIW, running the nvidia-9755 drivers here.
So if we are going to use that as a judgement operator, it obviously needs some intelligently applied scaling before they are worth more than a subjective feel is.
Quoted 6 lines
Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 6 lines
Cheers, Gene "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) The confusion of a staff member is measured by the length of his memos. -- New York Times, Jan. 20, 1981
Quoted 3 lines · Ingo Molnar
i kept the 50%/50% rule from the old scheduler, but maybe it's a more pristine (and smaller/faster) approach to just not give new children any stats history to begin with. I've implemented an add-on patch that implements this, you can find it at:
http://redhat.com/~mingo/cfs-scheduler/sched-fair-fork.patch
I've been running my desktop (single-core Pentium-M w/2GB RAM, Kubuntu Dapper) with the new CFS for much of this morning now, with the odd switch back to the stock scheduler for comparison.
Here, CFS really works and feels better than the stock scheduler.
Even with a "make -j2" kernel rebuild happening (no manual renice, either!) things "just work" about as smoothly as ever. That's something which RSDL never achieved for me, though I have not retested RSDL beyond v0.34 or so.
Well done, Ingo! I *want* this as my default scheduler.
Things seemed slightly less smooth when I had the CPU hogs and fair-fork extension patches both applied.
I'm going to try again now with just the fair-fork added on.
Cheers
Mark
Quoted 6 lines · Willy Tarreau
Forking becomes very slow above a load of 100 it seems. Sometimes, the shell takes 2 or 3 seconds to return to prompt after I run "scheddos &"
Those are very promising results, I nearly observe the same responsiveness as I had on a solaris 10 with 10k running processes on a bigger machine. I would be curious what a mysql test result would look like now.
Where is scheddos?
-- wli
Quoted 9 lines · William Lee Irwin III
Quoted 6 lines · Willy Tarreau
Forking becomes very slow above a load of 100 it seems. Sometimes, the shell takes 2 or 3 seconds to return to prompt after I run "scheddos &"
Those are very promising results, I nearly observe the same responsiveness as I had on a solaris 10 with 10k running processes on a bigger machine. I would be curious what a mysql test result would look like now.Where is scheddos?
I will send it to you off-list. I've been avoiding to publish it for a long time because the stock scheduler was *very* sensible to trivial attacks (freezes larger than 30s, impossible to log in). It's very basic, and I have no problem sending it to anyone who requests it, it's just that as long as some distros ship early 2.6 kernels I do not want it to appear on mailing list archives for anyone to grab it and annoy their admins for free.
Cheers,
Willy
Quoted 8 lines · Willy Tarreau
Quoted 6 lines
this fix is not complete - because the child runqueue is locked here, not the parent's. I've fixed this properly in my tree and have uploaded a new sched-modular+cfs.patch. (the effects of the original bug are mostly harmless, the rbtree position gets corrected the first time the parent reschedules. The fix might improve heavy forker handling.)
It looks like it did not reach your public dir yet.
oops, forgot to do the last step - should be fixed now.
Quoted 9 lines
BTW, I've given it a try. It seems pretty usable. I have also tried the usual meaningless "glxgears" test with 12 of them at the same time, and they rotate very smoothly, there is absolutely no pause in any of them. But they don't all run at same speed, and top reports their CPU load varying from 3.4 to 10.8%, with what looks like more CPU is assigned to the first processes, and less CPU for the last ones. But this is just a rough observation on a stupid test, I would not call that one scientific in any way (and X has its share in the test too).
ok, i'll try that too - there should be nothing particularly special about glxgears.
there's another tweak you could try:
echo 500000 > /proc/sys/kernel/sched_granularity_ns
note that this causes preemption to be done as fast as the scheduler can do it. (in practice it will be mainly driven by CONFIG_HZ, so to get the best results a CONFIG_HZ of 1000 is useful.)
plus there's an add-on to CFS at:
http://redhat.com/~mingo/cfs-scheduler/sched-fair-hog.patch
this makes the 'CPU usage history cutoff' configurable and sets it to a default of 100 msecs. This means that CPU hogs (tasks which actively kept other tasks from running) will be remembered, for up to 100 msecs of their 'hogness'.
Setting this limit back to 0 gives the 'vanilla' CFS scheduler's behavior:
echo 0 > /proc/sys/kernel/sched_max_hog_history_ns
(So when trying this you dont have to reboot with this patch applied/unapplied, just set this value.)
Quoted 1 line
I'll perform other tests when I can rebuild with your fixed patch.
cool, thanks!
Ingo
13 Nis 2007 Cum tarihinde, Ingo Molnar şunları yazmıştı:
Quoted 5 lines
[announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS]
i'm pleased to announce the first release of the "Modular Scheduler Core and Completely Fair Scheduler [CFS]" patchset:
Currently im using Linus's current git + your extra patches + CFS for a while. Kaffeine constantly freezes (and uses %80+ CPU time) [1] if i seek forward/backward while its playing a video with some workload (checking out SVN repositories, compiling something). Stopping other process didn't help kaffeine so it stays freezed stated until i kill it.
I'm not sure whether its a xine-lib or kaffeine bug (cause mplayer didn't have that problem) but i can't reproduce this with mainline or mainline + sd-0.39.
[1] http://cekirdek.pardus.org.tr/~caglar/psaux
Signature · 4 lines
S.Çağlar Onur <[email protected]> http://cekirdek.pardus.org.tr/~caglar/ Linux is like living in a teepee. No Windows, no Gates and an Apache in house!
Quoted 9 lines · S.Çağlar Onur
Quoted 2 lines
i'm pleased to announce the first release of the "Modular Scheduler Core and Completely Fair Scheduler [CFS]" patchset:
Currently im using Linus's current git + your extra patches + CFS for a while. Kaffeine constantly freezes (and uses %80+ CPU time) [1] if i seek forward/backward while its playing a video with some workload (checking out SVN repositories, compiling something). Stopping other process didn't help kaffeine so it stays freezed stated until i kill it.
hm, could you try to strace it and/or attach gdb to it and figure out what's wrong? (perhaps involving the Kaffeine developers too?) As long as it's not a kernel level crash i cannot see how the scheduler could directly cause this - other than by accident creating a scheduling pattern that triggers a user-space bug more often than with other schedulers.
Quoted 1 line
looks quite weird!
Ingo
14 Nis 2007 Cts tarihinde, Ingo Molnar şunları yazmıştı:
Quoted 6 lines
hm, could you try to strace it and/or attach gdb to it and figure out what's wrong? (perhaps involving the Kaffeine developers too?) As long as it's not a kernel level crash i cannot see how the scheduler could directly cause this - other than by accident creating a scheduling pattern that triggers a user-space bug more often than with other schedulers.
...
futex(0x89ac218, FUTEX_WAIT, 2, NULL) = 0 futex(0x89ac218, FUTEX_WAIT, 2, NULL) = 0 futex(0x89ac218, FUTEX_WAIT, 2, NULL) = 0 futex(0x89ac218, FUTEX_WAIT, 2, NULL) = 0 futex(0x89ac218, FUTEX_WAIT, 2, NULL) = 0 futex(0x89ac218, FUTEX_WAIT, 2, NULL) = -1 EINTR (Interrupted system call)
--- SIGINT (Interrupt) @ 0 (0) ---
+++ killed by SIGINT +++
is where freeze occurs. Full log can be found at [1]
Quoted 3 lines
Quoted 1 line
looks quite weird!
:)
[1] http://cekirdek.pardus.org.tr/~caglar/strace.kaffeine
Signature · 4 lines
S.Çağlar Onur <[email protected]> http://cekirdek.pardus.org.tr/~caglar/ Linux is like living in a teepee. No Windows, no Gates and an Apache in house!
Re: Kaffeine problem with CFS
Quoted 17 lines · S.Çağlar Onur
Quoted 6 lines
hm, could you try to strace it and/or attach gdb to it and figure out what's wrong? (perhaps involving the Kaffeine developers too?) As long as it's not a kernel level crash i cannot see how the scheduler could directly cause this - other than by accident creating a scheduling pattern that triggers a user-space bug more often than with other schedulers.
...
futex(0x89ac218, FUTEX_WAIT, 2, NULL) = 0 futex(0x89ac218, FUTEX_WAIT, 2, NULL) = 0 futex(0x89ac218, FUTEX_WAIT, 2, NULL) = 0 futex(0x89ac218, FUTEX_WAIT, 2, NULL) = 0 futex(0x89ac218, FUTEX_WAIT, 2, NULL) = 0 futex(0x89ac218, FUTEX_WAIT, 2, NULL) = -1 EINTR (Interrupted system call)killed by SIGINT +++ renamed from SIGINT (Interrupt) @ 0 (0) --- +0
-0
Quoted 3 lines
is where freeze occurs. Full log can be found at [1]
thanks. This does has the appearance of a userspace race condition of some sorts. Can you trigger this hang with the patch below applied to the vanilla tree as well? (with no CFS patch applied)
if yes then this would suggest that Kaffeine has some sort of child-runs-first problem. (which CFS changes to parent-runs-first. Kaffeine starts a couple of threads and the futex calls are a sign of thread<->thread communication.)
[ i have also Cc:-ed the Kaffeine folks - maybe your strace gives them
an idea about what the problem could be :) ]
Ingo
--- kernel/sched.c | 70 ++------------------------------------------------------- 1 file changed, 3 insertions(+), 67 deletions(-)
kernel/sched.c +3 -67
@@ -1653,77 +1653,13 @@ void fastcall sched_fork(struct task_str*/ void fastcall wake_up_new_task(struct task_struct *p, unsigned long clone_flags) { -struct rq *rq, *this_rq;unsigned long flags; -int this_cpu, cpu; +struct rq *rq; rq =task_rq_lock (p, &flags);BUG_ON (p->state !=TASK_RUNNING ); - this_cpu =smp_processor_id (); - cpu =task_cpu (p); - -/* -* We decrease the sleep average of forking parents -* and children as well, to keep max-interactive tasks -* from forking tasks that are max-interactive. The parent -* (current) is done further down, under its lock. -*/ - p->sleep_avg =JIFFIES_TO_NS (CURRENT_BONUS (p) * -CHILD_PENALTY /100 *MAX_SLEEP_AVG /MAX_BONUS ); - - p->prio =effective_prio (p); - -if (likely (cpu == this_cpu)) { -if (!(clone_flags &CLONE_VM )) { -/* -* The VM isn't cloned, so we're in a good position to -* do child-runs-first in anticipation of an exec. This -* usually avoids a lot of COW overhead. -*/ -if (unlikely (!current->array)) -__activate_task (p, rq); -else { - p->prio = current->prio; - p->normal_prio = current->normal_prio; -list_add_tail (&p->run_list, ¤t->run_list); - p->array = current->array; - p->array->nr_active++; -inc_nr_running (p, rq); - } -set_need_resched (); - }else -/* Run child last */ -__activate_task (p, rq); -/* -* We skip the following code due to cpu == this_cpu -* -* task_rq_unlock(rq, &flags); -* this_rq = task_rq_lock(current, &flags); -*/ - this_rq = rq; - }else { - this_rq =cpu_rq (this_cpu); - -/* -* Not the local CPU - must adjust timestamp. This should -* get optimised away in the !CONFIG_SMP case. -*/ - p->timestamp = (p->timestamp - this_rq->most_recent_timestamp) - + rq->most_recent_timestamp; -__activate_task (p, rq); -if (TASK_PREEMPTS_CURR (p, rq)) -resched_task (rq->curr); - -/* -* Parent and child are on different CPUs, now get the -* parent runqueue to update the parent's ->sleep_avg: -*/ -task_rq_unlock (rq, &flags); - this_rq =task_rq_lock (current, &flags); - } - current->sleep_avg =JIFFIES_TO_NS (CURRENT_BONUS (current) * -PARENT_PENALTY /100 *MAX_SLEEP_AVG /MAX_BONUS ); -task_rq_unlock (this_rq, &flags); +__activate_task (p, rq); +task_rq_unlock (rq, &flags); }/*
Re: Kaffeine problem with CFS
Quoted 5 lines · Ingo Molnar
Quoted 1 line
thanks. This does has the appearance of a userspace race condition of some sorts. Can you trigger this hang with the patch below applied to the vanilla tree as well? (with no CFS patch applied)
oops, please use the patch below instead.
Ingo
--- kernel/sched.c | 69 ++++----------------------------------------------------- 1 file changed, 5 insertions(+), 64 deletions(-)
kernel/sched.c +5 -64
@@ -1653,77 +1653,18 @@ void fastcall sched_fork(struct task_str*/ void fastcall wake_up_new_task(struct task_struct *p, unsigned long clone_flags) { -struct rq *rq, *this_rq;unsigned long flags; -int this_cpu, cpu; +struct rq *rq; rq =task_rq_lock (p, &flags);BUG_ON (p->state !=TASK_RUNNING ); - this_cpu =smp_processor_id (); - cpu =task_cpu (p); - -/* -* We decrease the sleep average of forking parents -* and children as well, to keep max-interactive tasks -* from forking tasks that are max-interactive. The parent -* (current) is done further down, under its lock. -*/ - p->sleep_avg =JIFFIES_TO_NS (CURRENT_BONUS (p) * -CHILD_PENALTY /100 *MAX_SLEEP_AVG /MAX_BONUS ); p->prio =effective_prio (p); +__activate_task (p, rq); +if (TASK_PREEMPTS_CURR (p, rq)) +resched_task (rq->curr); -if (likely (cpu == this_cpu)) { -if (!(clone_flags &CLONE_VM )) { -/* -* The VM isn't cloned, so we're in a good position to -* do child-runs-first in anticipation of an exec. This -* usually avoids a lot of COW overhead. -*/ -if (unlikely (!current->array)) -__activate_task (p, rq); -else { - p->prio = current->prio; - p->normal_prio = current->normal_prio; -list_add_tail (&p->run_list, ¤t->run_list); - p->array = current->array; - p->array->nr_active++; -inc_nr_running (p, rq); - } -set_need_resched (); - }else -/* Run child last */ -__activate_task (p, rq); -/* -* We skip the following code due to cpu == this_cpu -* -* task_rq_unlock(rq, &flags); -* this_rq = task_rq_lock(current, &flags); -*/ - this_rq = rq; - }else { - this_rq =cpu_rq (this_cpu); - -/* -* Not the local CPU - must adjust timestamp. This should -* get optimised away in the !CONFIG_SMP case. -*/ - p->timestamp = (p->timestamp - this_rq->most_recent_timestamp) - + rq->most_recent_timestamp; -__activate_task (p, rq); -if (TASK_PREEMPTS_CURR (p, rq)) -resched_task (rq->curr); - -/* -* Parent and child are on different CPUs, now get the -* parent runqueue to update the parent's ->sleep_avg: -*/ -task_rq_unlock (rq, &flags); - this_rq =task_rq_lock (current, &flags); - } - current->sleep_avg =JIFFIES_TO_NS (CURRENT_BONUS (current) * -PARENT_PENALTY /100 *MAX_SLEEP_AVG /MAX_BONUS ); -task_rq_unlock (this_rq, &flags); +task_rq_unlock (rq, &flags); }/*
Re: Kaffeine problem with CFS
Hi,
2007/4/15, Ingo Molnar <[email protected]>:
Quoted 4 lines · Ingo Molnar
Quoted 2 lines
Quoted 2 lines
Could you try xine-ui or gxine? Because I suspect rather xine-lib for freezing issues. In any way I think a gdb backtrace would be much nicer - but if you can't reproduce the freeze issue with other xine based players and want to run kaffeine in gdb, you need to execute "gdb --args kaffeine --nofork".
Quoted 7 lines
Quoted 3 lines
thanks. This does has the appearance of a userspace race condition of some sorts. Can you trigger this hang with the patch below applied to the vanilla tree as well? (with no CFS patch applied)
oops, please use the patch below instead.
Ingo
<snip>
Christoph
Re: Kaffeine problem with CFS
15 Nis 2007 Paz tarihinde, Christoph Pfister şunları yazmıştı:
Quoted 5 lines
Could you try xine-ui or gxine? Because I suspect rather xine-lib for freezing issues. In any way I think a gdb backtrace would be much nicer - but if you can't reproduce the freeze issue with other xine based players and want to run kaffeine in gdb, you need to execute "gdb --args kaffeine --nofork".
I just tested xine-ui and i can easily reproduce exact same problem with xine-ui also so you are right, it seems a xine-lib problem trigger by CFS changes.
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
thanks. This does has the appearance of a userspace race condition of some sorts. Can you trigger this hang with the patch below applied to the vanilla tree as well? (with no CFS patch applied)
oops, please use the patch below instead.
Tomorrow i'll test that patch and also try to get a backtrace.
Cheers
Signature · 4 lines
S.Çağlar Onur <[email protected]> http://cekirdek.pardus.org.tr/~caglar/ Linux is like living in a teepee. No Windows, no Gates and an Apache in house!
Re: Kaffeine problem with CFS
In reply to Christoph Pfister[ i've Cc:-ed Ulrich Drepper, this CFS-triggered hang seems to have some
futex and pthread_cond_wait() relevance. ]
Quoted 7 lines · Christoph Pfister
Quoted 1 line
Quoted 1 line
Quoted 1 line
Could you try xine-ui or gxine? Because I suspect rather xine-lib for freezing issues. In any way I think a gdb backtrace would be much nicer - but if you can't reproduce the freeze issue with other xine based players and want to run kaffeine in gdb, you need to execute "gdb --args kaffeine --nofork".
update: i've reproduced one kind of a hang but i'm not sure it's the same hang Ismail is seeing. It was quite hard to trigger it under CFS, i had to do wild forward/backward button seeks on a real DVD and i mixed it with CPU-intense workloads on the same box. Here are the straces and gdb backtraces:
kaffeine thread PID 9303, waiting for other threads to do something, stuck in pthread_mutex_lock():
futex(0xb07409e0, FUTEX_WAIT, 2, NULL <unfinished ...>
backtrace:
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2538ce in __lll_mutex_lock_wait () from /lib/libpthread.so.0 #2 0x4a24f71c in _L_mutex_lock_79 () from /lib/libpthread.so.0 #3 0x4a24f24d in pthread_mutex_lock () from /lib/libpthread.so.0 #4 0xb79f64f9 in xine_play () from /usr/lib/libxine.so.1 #5 0xb7a9b0fb in KXineWidget::slotSeekToPosition () from /usr/lib/kde3/libxinepart.so #6 0xb7a9b3bc in KXineWidget::wheelEvent () from /usr/lib/kde3/libxinepart.so #7 0x4b5f9150 in QWidget::event () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #8 0x4b55353b in QApplication::internalNotify () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #9 0x4b55526e in QApplication::notify () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#10 0x4a72065e in KApplication::notify () from /usr/lib/libkdecore.so.4
#11 0x4b4dd5de in QETWidget::translateWheelEvent () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#12 0x4b4eb41d in QETWidget::translateMouseEvent () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#13 0x4b4e9766 in QApplication::x11ProcessEvent () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#14 0x4b4fb38b in QEventLoop::processEvents () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#15 0x4b56ce30 in QEventLoop::enterLoop () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#16 0x4b56cce6 in QEventLoop::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #17 0x4b55317f in QApplication::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #18 0x0806fc1a in QWidget::setUpdatesEnabled ()
#19 0x49f9df10 in __libc_start_main () from /lib/libc.so.6
#20 0x0806f7e1 in QWidget::setUpdatesEnabled ()
Kaffeine thread 9324, seems to be in an infinite pthread_cond_wait() loop that does:
futex(0xb0740b78, FUTEX_WAIT, 3559, NULL) = 0
futex(0xb0740b5c, FUTEX_WAKE, 1) = 0
munmap(0xaacb1000, 1662976) = 0
mmap2(NULL, 1662976, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xaacb1000 gettimeofday({1176891363, 347259}, NULL) = 0
munmap(0xab309000, 1662976) = 0
backtrace:
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2510c6 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0 #2 0xb79fd1a8 in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #3 0xb7a030ab in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #4 0x4a24d2db in start_thread () from /lib/libpthread.so.0 #5 0x4a05820e in clone () from /lib/libc.so.6
Kaffine thread 9325 does a loop of short pthread_cond_wait() futex sleeps:
1176891721.419314 futex(0xb07527e8, FUTEX_WAIT, 8537, NULL) = 0 <0.011710> 1176891721.431068 futex(0xb07527cc, FUTEX_WAKE, 1) = 0 <0.000006> 1176891721.431429 futex(0xb0740c04, 0x5 /* FUTEX_??? */, 1) = 1 <0.000008> 1176891721.431458 futex(0xb0740be8, FUTEX_WAKE, 1) = 1 <0.000012> 1176891721.431489 futex(0xb07527e8, FUTEX_WAIT, 8539, NULL) = 0 <0.007339> 1176891721.439008 futex(0xb07527cc, FUTEX_WAKE, 1) = 0 <0.000052> 1176891721.439510 futex(0xb0740c04, 0x5 /* FUTEX_??? */, 1) = 1 <0.000055> 1176891721.439636 futex(0xb0740be8, FUTEX_WAKE, 1) = 1 <0.000089> 1176891721.439789 futex(0xb07527e8, FUTEX_WAIT, 8541, NULL) = 0 <0.007045> 1176891721.447017 futex(0xb07527cc, FUTEX_WAKE, 1) = 0 <0.000054> 1176891721.447682 futex(0xb0740c04, 0x5 /* FUTEX_??? */, 1) = 1 <0.000065>
backtrace:
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2510c6 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0 #2 0xb79fd1a8 in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #3 0xb7a04079 in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #4 0x4a24d2db in start_thread () from /lib/libpthread.so.0 #5 0x4a05820e in clone () from /lib/libc.so.6
library versions:
xine-lib-1.1.5-1.fc7
xine-plugin-1.0-3.fc7
glibc-headers-2.5.90-21
glibc-common-2.5.90-21
glibc-2.5.90-21
glibc-devel-2.5.90-21
gxine-0.5.11-3.fc7
kaffeine-0.8.3-4.fc7
xine-0.99.4-11.lvn7
xine-lib-extras-1.1.5-1.fc7
gxine-mozplugin-0.5.11-3.fc7
what's weird is that all threads are in a pthread op and seem to be kind of busy-looping. Maybe xine-lib has some buggy use of pthread condvars that CFS happens to trigger? (If CFS broke futexes in general i think we'd be seeing far more widespread breakage.)
Ingo
Re: Kaffeine problem with CFS
Hi,
2007/4/18, Ingo Molnar <[email protected]>:
Quoted 59 lines
[ i've Cc:-ed Ulrich Drepper, this CFS-triggered hang seems to have some
futex andpthread_cond_wait()relevance. ]Quoted 7 lines · Christoph Pfister
Quoted 1 line
Quoted 1 line
Quoted 1 line
Could you try xine-ui or gxine? Because I suspect rather xine-lib for freezing issues. In any way I think a gdb backtrace would be much nicer - but if you can't reproduce the freeze issue with other xine based players and want to run kaffeine in gdb, you need to execute "gdb --args kaffeine --nofork".
update: i've reproduced one kind of a hang but i'm not sure it's the same hang Ismail is seeing. It was quite hard to trigger it under CFS, i had to do wild forward/backward button seeks on a real DVD and i mixed it with CPU-intense workloads on the same box. Here are the straces and gdb backtraces:
kaffeine thread PID 9303, waiting for other threads to do something, stuck in
pthread_mutex_lock():futex(0xb07409e0,
FUTEX_WAIT, 2, NULL <unfinished ...>backtrace:
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2538ce in __lll_mutex_lock_wait () from /lib/libpthread.so.0 #2 0x4a24f71c in _L_mutex_lock_79 () from /lib/libpthread.so.0 #3 0x4a24f24d in pthread_mutex_lock () from /lib/libpthread.so.0 #4 0xb79f64f9 in xine_play () from /usr/lib/libxine.so.1 #5 0xb7a9b0fb in KXineWidget::slotSeekToPosition () from /usr/lib/kde3/libxinepart.so #6 0xb7a9b3bc in KXineWidget::wheelEvent () from /usr/lib/kde3/libxinepart.so #7 0x4b5f9150 in QWidget::event () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #8 0x4b55353b in QApplication::internalNotify () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #9 0x4b55526e in QApplication::notify () from /usr/lib/qt-3.3/lib/libqt-mt.so.3#10
0x4a72065einKApplication::notify() from/usr/lib/libkdecore.so.4
#110x4b4dd5deinQETWidget::translateWheelEvent() from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#120x4b4eb41dinQETWidget::translateMouseEvent() from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#130x4b4e9766inQApplication::x11ProcessEvent() from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#140x4b4fb38binQEventLoop::processEvents() from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#150x4b56ce30inQEventLoop::enterLoop() from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#160x4b56cce6inQEventLoop::exec() from/usr/lib/qt-3.3/lib/libqt-mt.so.3#170x4b55317finQApplication::exec() from/usr/lib/qt-3.3/lib/libqt-mt.so.3#180x0806fc1ainQWidget::setUpdatesEnabled()
#190x49f9df10in__libc_start_main() from/lib/libc.so.6
#200x0806f7e1inQWidget::setUpdatesEnabled()Kaffeine thread 9324, seems to be in an infinite
pthread_cond_wait()loop that does:
futex(0xb0740b78, FUTEX_WAIT, 3559, NULL)= 0
futex(0xb0740b5c, FUTEX_WAKE, 1)= 0
munmap(0xaacb1000, 1662976)= 0
mmap2(NULL, 1662976, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)=0xaacb1000gettimeofday({1176891363, 347259}, NULL)= 0
munmap(0xab309000, 1662976)= 0
Quoted 8 lines
backtrace:
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2510c6 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0 #2 0xb79fd1a8 in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #3 0xb7a030ab in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #4 0x4a24d2db in start_thread () from /lib/libpthread.so.0 #5 0x4a05820e in clone () from /lib/libc.so.6
This backtrace is useless - QWidget::setUpdatesEnabled() is certainly _not_ defined in libxine. So the function names in #2 and #3 are wrong because the addresses seem to belong to libxine.
Quoted 15 lines
Kaffine thread 9325 does a loop of short
pthread_cond_wait()futex sleeps:1176891721.419314
futex(0xb07527e8, FUTEX_WAIT, 8537, NULL)= 0 <0.011710> 1176891721.431068futex(0xb07527cc, FUTEX_WAKE, 1)= 0 <0.000006> 1176891721.431429futex(0xb0740c04, 0x5 /* FUTEX_??? */, 1)= 1 <0.000008> 1176891721.431458futex(0xb0740be8, FUTEX_WAKE, 1)= 1 <0.000012> 1176891721.431489futex(0xb07527e8, FUTEX_WAIT, 8539, NULL)= 0 <0.007339> 1176891721.439008futex(0xb07527cc, FUTEX_WAKE, 1)= 0 <0.000052> 1176891721.439510futex(0xb0740c04, 0x5 /* FUTEX_??? */, 1)= 1 <0.000055> 1176891721.439636futex(0xb0740be8, FUTEX_WAKE, 1)= 1 <0.000089> 1176891721.439789futex(0xb07527e8, FUTEX_WAIT, 8541, NULL)= 0 <0.007045> 1176891721.447017futex(0xb07527cc, FUTEX_WAKE, 1)= 0 <0.000054> 1176891721.447682futex(0xb0740c04, 0x5 /* FUTEX_??? */, 1)= 1 <0.000065>
Quoted 8 lines
backtrace:
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2510c6 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0 #2 0xb79fd1a8 in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #3 0xb7a04079 in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #4 0x4a24d2db in start_thread () from /lib/libpthread.so.0 #5 0x4a05820e in clone () from /lib/libc.so.6
Dito.
Quoted 14 lines
library versions:
xine-lib-1.1.5-1.fc7
xine-plugin-1.0-3.fc7
glibc-headers-2.5.90-21
glibc-common-2.5.90-21
glibc-2.5.90-21
glibc-devel-2.5.90-21
gxine-0.5.11-3.fc7
kaffeine-0.8.3-4.fc7
xine-0.99.4-11.lvn7
xine-lib-extras-1.1.5-1.fc7
gxine-mozplugin-0.5.11-3.fc7
Quoted 6 lines
what's weird is that all threads are in a pthread op and seem to be kind of busy-looping. Maybe xine-lib has some buggy use of pthread condvars that CFS happens to trigger? (If CFS broke futexes in general i think we'd be seeing far more widespread breakage.)
Ingo
Christoph
Re: Kaffeine problem with CFS
Quoted 10 lines · Christoph Pfister
Quoted 9 lines
backtrace:
#0
0xffffe410in__kernel_vsyscall()
#10x4a2510c6in pthread_cond_wait@@GLIBC_2.3.2 () from/lib/libpthread.so.0#2 0xb79fd1a8 in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #3 0xb7a030ab in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #4 0x4a24d2db in start_thread () from /lib/libpthread.so.0 #5 0x4a05820e in clone () from /lib/libc.so.6
Quoted 3 lines
This backtrace is useless -
QWidget::setUpdatesEnabled()is certainly _not_ defined in libxine. So the function names in #2 and #3 are wrong because the addresses seem to belong to libxine.
are the updated backtraces in the followup mail i just sent more useful? (I still have that stuck session running so i can whatever debugging you'd like to see done.)
Ingo
Re: Kaffeine problem with CFS
Quoted 12 lines · Ingo Molnar
Quoted 10 lines · Christoph Pfister
Quoted 9 lines
backtrace:
#0
0xffffe410in__kernel_vsyscall()
#10x4a2510c6in pthread_cond_wait@@GLIBC_2.3.2 () from/lib/libpthread.so.0#2 0xb79fd1a8 in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #3 0xb7a030ab in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #4 0x4a24d2db in start_thread () from /lib/libpthread.so.0 #5 0x4a05820e in clone () from /lib/libc.so.6
Quoted 7 lines
Quoted 3 lines
This backtrace is useless -
QWidget::setUpdatesEnabled()is certainly _not_ defined in libxine. So the function names in #2 and #3 are wrong because the addresses seem to belong to libxine.are the updated backtraces in the followup mail i just sent more useful? (I still have that stuck session running so i can whatever debugging you'd like to see done.)
The xine website release note says there are problems with playback with xine-lib version 1.1.5, so people encountering this may want to check to see if they're running 1.1.5, and either upgrade to the latest, or downgrade to 1.1.4.
<snippet from xine website>
18.04.2007 xine-lib 1.1.6 A new xine-lib version is now available.
This is mainly a bug-fix release; 1.1.5 has CD audio and DVD playback problems and a couple of X-related build problems.
-Mike
Re: Kaffeine problem with CFS
In reply to Ingo Molnar2007/4/18, Ingo Molnar <[email protected]>:
Quoted 13 lines · Christoph Pfister
Quoted 11 lines
Quoted 10 lines
backtrace:
#0
0xffffe410in__kernel_vsyscall()
#10x4a2510c6in pthread_cond_wait@@GLIBC_2.3.2 () from/lib/libpthread.so.0#2 0xb79fd1a8 in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #3 0xb7a030ab in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #4 0x4a24d2db in start_thread () from /lib/libpthread.so.0 #5 0x4a05820e in clone () from /lib/libc.so.6
Quoted 7 lines
Quoted 3 lines
This backtrace is useless -
QWidget::setUpdatesEnabled()is certainly _not_ defined in libxine. So the function names in #2 and #3 are wrong because the addresses seem to belong to libxine.are the updated backtraces in the followup mail i just sent more useful? (I still have that stuck session running so i can whatever debugging you'd like to see done.)
QWidget::setUpdatesEnabled() is (wrongly) present in every thread except the main. So I'm afraid there's nothing which can be done :-/ Btw the main thread is waiting for the first frame being displayed after the seek.
Quoted 1 line
Ingo
Christoph
Re: Kaffeine problem with CFS
Quoted 8 lines · Christoph Pfister
Quoted 3 lines
are the updated backtraces in the followup mail i just sent more useful? (I still have that stuck session running so i can whatever debugging you'd like to see done.)
QWidget::setUpdatesEnabled()is (wrongly) present in every thread except the main. So I'm afraid there's nothing which can be done :-/ Btw the main thread is waiting for the first frame being displayed after the seek.
i didnt have all the debuginfo packages installed. I installed some (but not all yet), here's an updated backtrace:
(gdb) bt
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2539e1 in __lll_mutex_unlock_wake () from /lib/libpthread.so.0 #2 0x4a2506f9 in _L_mutex_unlock_99 () from /lib/libpthread.so.0 #3 0x4a250370 in __pthread_mutex_unlock_usercnt () from /lib/libpthread.so.0 #4 0x4a2506f0 in pthread_mutex_unlock () from /lib/libpthread.so.0 #5 0xb79fce5a in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #6 0xb7a4b90b in dvd_plugin_free_buffer (buf=0xb0745470) at input_dvd.c:570 #7 0xb7a030a2 in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #8 0x4a24d2db in start_thread () from /lib/libpthread.so.0 #9 0x4a05820e in clone () from /lib/libc.so.6
at least the dvd_plugin_free_buffer() call has been resolved now. (I'll hunt for the other debuginfo packages too.)
which thread would be the most interesting to you - 9324?
Ingo
Re: Kaffeine problem with CFS
2007/4/18, Ingo Molnar <[email protected]>:
Quoted 27 lines · Christoph Pfister
Quoted 9 lines
Quoted 4 lines
are the updated backtraces in the followup mail i just sent more useful? (I still have that stuck session running so i can whatever debugging you'd like to see done.)
QWidget::setUpdatesEnabled()is (wrongly) present in every thread except the main. So I'm afraid there's nothing which can be done :-/ Btw the main thread is waiting for the first frame being displayed after the seek.i didnt have all the debuginfo packages installed. I installed some (but not all yet), here's an updated backtrace:
(gdb) bt
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2539e1 in __lll_mutex_unlock_wake () from /lib/libpthread.so.0 #2 0x4a2506f9 in _L_mutex_unlock_99 () from /lib/libpthread.so.0 #3 0x4a250370 in __pthread_mutex_unlock_usercnt () from /lib/libpthread.so.0 #4 0x4a2506f0 in pthread_mutex_unlock () from /lib/libpthread.so.0 #5 0xb79fce5a in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #6 0xb7a4b90b in dvd_plugin_free_buffer (buf=0xb0745470) at input_dvd.c:570 #7 0xb7a030a2 in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #8 0x4a24d2db in start_thread () from /lib/libpthread.so.0 #9 0x4a05820e in clone () from /lib/libc.so.6
Quoted 4 lines
at least the
dvd_plugin_free_buffer()call has been resolved now. (I'll hunt for the other debuginfo packages too.)which thread would be the most interesting to you - 9324?
The thread which should wake the main thread - but hmm ... 9303 seems to be rather dead-locked than doing pthread_cond_timedwait() ?
Quoted 1 line
Ingo
Christoph
Re: Kaffeine problem with CFS
Quoted 4 lines · Christoph Pfister
Quoted 1 line
which thread would be the most interesting to you - 9324?
The thread which should wake the main thread - but hmm ... 9303 seems to be rather dead-locked than doing
pthread_cond_timedwait()?
ok, here it is, 9303 with better symbol names:
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2538ce in __lll_mutex_lock_wait () from /lib/libpthread.so.0 #2 0x4a24f71c in _L_mutex_lock_79 () from /lib/libpthread.so.0 #3 0x4a24f24d in pthread_mutex_lock () from /lib/libpthread.so.0 #4 0xb79f64f9 in xine_play () from /usr/lib/libxine.so.1 #5 0xb7a9b0fb in KXineWidget::slotSeekToPosition () from /usr/lib/kde3/libxinepart.so #6 0xb7a9b3bc in KXineWidget::wheelEvent () from /usr/lib/kde3/libxinepart.so #7 0x4b5f9150 in QWidget::event () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #8 0x4b55353b in QApplication::internalNotify ()
from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#9 0x4b55526e in QApplication::notify ()
from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#10 0x4a72065e in KApplication::notify () from /usr/lib/libkdecore.so.4 #11 0x4b4dd5de in QETWidget::translateWheelEvent ()
from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#12 0x4b4eb41d in QETWidget::translateMouseEvent ()
from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#13 0x4b4e9766 in QApplication::x11ProcessEvent ()
from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#14 0x4b4fb38b in QEventLoop::processEvents ()
from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#15 0x4b56ce30 in QEventLoop::enterLoop ()
from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#16 0x4b56cce6 in QEventLoop::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #17 0x4b55317f in QApplication::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #18 0x0806fc1a in QWidget::setUpdatesEnabled ()
#19 0x49f9df10 in __libc_start_main () from /lib/libc.so.6
#20 0x0806f7e1 in QWidget::setUpdatesEnabled ()
does this make more sense to you?
Ingo
Re: Kaffeine problem with CFS
2007/4/18, Ingo Molnar <[email protected]>:
Quoted 40 lines · Christoph Pfister
Quoted 5 lines
Quoted 2 lines
which thread would be the most interesting to you - 9324?
The thread which should wake the main thread - but hmm ... 9303 seems to be rather dead-locked than doing
pthread_cond_timedwait()?ok, here it is, 9303 with better symbol names:
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2538ce in __lll_mutex_lock_wait () from /lib/libpthread.so.0 #2 0x4a24f71c in _L_mutex_lock_79 () from /lib/libpthread.so.0 #3 0x4a24f24d in pthread_mutex_lock () from /lib/libpthread.so.0 #4 0xb79f64f9 in xine_play () from /usr/lib/libxine.so.1 #5 0xb7a9b0fb in KXineWidget::slotSeekToPosition () from /usr/lib/kde3/libxinepart.so #6 0xb7a9b3bc in KXineWidget::wheelEvent () from /usr/lib/kde3/libxinepart.so #7 0x4b5f9150 in QWidget::event () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #8 0x4b55353b in QApplication::internalNotify ()from
/usr/lib/qt-3.3/lib/libqt-mt.so.3
#90x4b55526einQApplication::notify()
from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#100x4a72065einKApplication::notify() from/usr/lib/libkdecore.so.4#110x4b4dd5deinQETWidget::translateWheelEvent()
from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#120x4b4eb41dinQETWidget::translateMouseEvent()
from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#130x4b4e9766inQApplication::x11ProcessEvent()
from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#140x4b4fb38binQEventLoop::processEvents()
from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#150x4b56ce30inQEventLoop::enterLoop()
from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#160x4b56cce6inQEventLoop::exec() from/usr/lib/qt-3.3/lib/libqt-mt.so.3#170x4b55317finQApplication::exec() from/usr/lib/qt-3.3/lib/libqt-mt.so.3#180x0806fc1ainQWidget::setUpdatesEnabled()
#190x49f9df10in__libc_start_main() from/lib/libc.so.6
#200x0806f7e1inQWidget::setUpdatesEnabled()
Quoted 1 line
does this make more sense to you?
It's nearly impossible for me to find out which mutex is deadlocking. There are 4 mutexs locked / released during xine_play (or one of the possibly inlined functions) and to be honest I have little idea which other thread is also involved in the deadlock (maybe some xine-lib junkie could help you more with that).
It would be great if you could reproduce the same problem with a xine-lib which has been compiled with debug support (so you'd get line numbers in the back trace - that makes life _a lot_ easier and maybe I could identify the problem that way) and the least optimization possible ... :-)
Quoted 1 line
Ingo
Christoph
Re: Kaffeine problem with CFS
2007/4/18, Christoph Pfister <[email protected]>:
Quoted 43 lines
2007/4/18, Ingo Molnar <[email protected]>:
Quoted 40 lines · Christoph Pfister
Quoted 5 lines
Quoted 2 lines
which thread would be the most interesting to you - 9324?
The thread which should wake the main thread - but hmm ... 9303 seems to be rather dead-locked than doing
pthread_cond_timedwait()?ok, here it is, 9303 with better symbol names:
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2538ce in __lll_mutex_lock_wait () from /lib/libpthread.so.0 #2 0x4a24f71c in _L_mutex_lock_79 () from /lib/libpthread.so.0 #3 0x4a24f24d in pthread_mutex_lock () from /lib/libpthread.so.0 #4 0xb79f64f9 in xine_play () from /usr/lib/libxine.so.1 #5 0xb7a9b0fb in KXineWidget::slotSeekToPosition () from /usr/lib/kde3/libxinepart.so #6 0xb7a9b3bc in KXineWidget::wheelEvent () from /usr/lib/kde3/libxinepart.so #7 0x4b5f9150 in QWidget::event () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #8 0x4b55353b in QApplication::internalNotify ()from
/usr/lib/qt-3.3/lib/libqt-mt.so.3
#90x4b55526einQApplication::notify()
from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#100x4a72065einKApplication::notify() from/usr/lib/libkdecore.so.4#110x4b4dd5deinQETWidget::translateWheelEvent()
from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#120x4b4eb41dinQETWidget::translateMouseEvent()
from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#130x4b4e9766inQApplication::x11ProcessEvent()
from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#140x4b4fb38binQEventLoop::processEvents()
from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#150x4b56ce30inQEventLoop::enterLoop()
from/usr/lib/qt-3.3/lib/libqt-mt.so.3
#160x4b56cce6inQEventLoop::exec() from/usr/lib/qt-3.3/lib/libqt-mt.so.3#170x4b55317finQApplication::exec() from/usr/lib/qt-3.3/lib/libqt-mt.so.3#180x0806fc1ainQWidget::setUpdatesEnabled()
#190x49f9df10in__libc_start_main() from/lib/libc.so.6
#200x0806f7e1inQWidget::setUpdatesEnabled()Quoted 1 line
does this make more sense to you?
Quoted 12 lines
It's nearly impossible for me to find out which mutex is deadlocking. There are 4 mutexs locked / released during
xine_play(or one of the possibly inlined functions) and to be honest I have little idea which other thread is also involved in the deadlock (maybe some xine-lib junkie could help you more with that).
It would be great if you could reproduce the same problem with a xine-lib which has been compiled with debug support (so you'd get line numbers in the back trace - that makes life _alot_easier and maybe I could identify the problem that way) and the least optimization possible ... :-)Quoted 1 line
Ingo
Or I could try playing around a bit with your patchset and trying to reproduce it over here. Because I already have debug builds for xine-lib and compiling a new kernel can take place in the background it wouldn't be much effort for me.
Christoph
Re: Kaffeine problem with CFS
In reply to Christoph PfisterQuoted 1 line · Christoph Pfister
It's nearly impossible for me to find out which mutex is deadlocking.
i've disassembled the xine_play function, and here are the function calls in it:
<unresolved widget call?>
pthread_mutex_lock()
xine_log()
<unresolved widget call?>
function pointer call
right after it: pthread_mutex_lock()
this second pthread_mutex_lock() in question is the one that deadlocks. It comes right after that function pointer call, maybe that identifies it?
[some time passes]
i rebuilt the library from source and while the installed library is different from it, looking at the disassembly i'm quite sure it's this pthread_mutex_lock() in xine_play_internal():
pthread_mutex_lock( &stream->demux_lock );
src/xine-engine/xine.c:1201
the function pointer call was:
stream->xine->port_ticket->acquire(stream->xine->port_ticket, 1);
right before the pthread_mutex_lock() call.
Quoted 5 lines
It would be great if you could reproduce the same problem with a xine-lib which has been compiled with debug support (so you'd get line numbers in the back trace - that makes life _a
lot_easier and maybe I could identify the problem that way) and the least optimization possible ... :-)
ok, i'll try that too (but it will take some more time), but given how hard it was for me to trigger it, i wanted to get maximum info out of it before having to kill the threads.
Ingo
Re: Kaffeine problem with CFS
hm. I've reviewed all uses of demux_lock. ./src/xine-engine/demux.c does this:
pthread_mutex_unlock( &stream->demux_lock );
lprintf ("sched_yield\n");
sched_yield();
pthread_mutex_lock( &stream->demux_lock );why is this done? CFS has definitely changed the yield implementation so there could be some connection.
OTOH, in the 'hung' state none of the straces suggests any yield() call.
Ingo
Re: Kaffeine problem with CFS
Quoted 2 lines · Ingo Molnar
hm. I've reviewed all uses of
demux_lock../src/xine-engine/demux.cdoes this:
plus it does this too:
pthread_mutex_unlock( &stream->demux_lock );
xine_usec_sleep(100000);
pthread_mutex_lock( &stream->demux_lock );this would explain the nanosleep() strace entries. But the task stuck on demux_lock never gets the unlock event. Weird.
Ingo
Re: Kaffeine problem with CFS
Quoted 11 lines · Ingo Molnar
Quoted 2 lines
hm. I've reviewed all uses of
demux_lock../src/xine-engine/demux.cdoes this:plus it does this too:
pthread_mutex_unlock( &stream->demux_lock ); xine_usec_sleep(100000); pthread_mutex_lock( &stream->demux_lock );this would explain the
nanosleep()strace entries. But the task stuck ondemux_locknever gets the unlock event. Weird.
9303 is stuck here on demux_lock:
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2538ce in __lll_mutex_lock_wait () from /lib/libpthread.so.0 #2 0x4a24f71c in _L_mutex_lock_79 () from /lib/libpthread.so.0 #3 0x4a24f24d in pthread_mutex_lock () from /lib/libpthread.so.0 #4 0xb79f64f9 in xine_play () from /usr/lib/libxine.so.1
that mutex related futex is at address 0xb07409e0, but the only sign in the strace of that futex being touched is:
9303 futex(0xb07409e0, FUTEX_WAIT, 2, NULL <unfinished ...>
no other event ever happens on futex 0xb07409e0. Other threads dont touch it.
Maybe thread 9324 is the owner of that mutex, and it's looping somewhere that does xine_xmalloc_aligned(), with the lock held? It did this:
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2539e1 in __lll_mutex_unlock_wake () from /lib/libpthread.so.0 #2 0x4a2506f9 in _L_mutex_unlock_99 () from /lib/libpthread.so.0 #3 0x4a250370 in __pthread_mutex_unlock_usercnt () from /lib/libpthread.so.0 #4 0x4a2506f0 in pthread_mutex_unlock () from /lib/libpthread.so.0 #5 0xb79fce5a in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #6 0xb7a4b90b in dvd_plugin_free_buffer (buf=0xb0745470) at input_dvd.c:570 #7 0xb7a030a2 in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #8 0x4a24d2db in start_thread () from /lib/libpthread.so.0 #9 0x4a05820e in clone () from /lib/libc.so.6
Ingo
Re: Kaffeine problem with CFS
In reply to Ingo MolnarQuoted 10 lines · Ingo Molnar
hm. I've reviewed all uses of
demux_lock../src/xine-engine/demux.cdoes this:pthread_mutex_unlock( &stream->demux_lock ); lprintf ("sched_yield\n"); sched_yield(); pthread_mutex_lock( &stream->demux_lock );
Quoted 5 lines
why is this done? CFS has definitely changed the yield implementation so there could be some connection.
OTOH, in the 'hung' state none of the straces suggests any
yield()call.
yeah, there's no yield() call in any of the straces so i'd exclude this as a possibility .
Ingo
Re: Kaffeine problem with CFS
In reply to Ingo MolnarQuoted 5 lines · Ingo Molnar
update: i've reproduced one kind of a hang but i'm not sure it's the same hang Ismail is seeing. It was quite hard to trigger it under CFS, i had to do wild forward/backward button seeks on a real DVD and i mixed it with CPU-intense workloads on the same box. Here are the straces and gdb backtraces:
these were only the threads that showed up in htop. Here's a full analysis about what all threads are doing:
Process 9303: stuck in xine_play()/pthread_mutex_lock()
Process 9319: stuck in pthread_cond_timedwait()
Process 9320: stuck in pthread_cond_timedwait()
Process 9321: loop of ~3 msec nanosleeps
Process 9322: loop of poll() calls every 335 msecs
Process 9323: stuck in pthread_cond_timedwait()
Process 9324: stuck in a loop of 1-second futex-waits + mmap/munmap (malloc)
Process 9325: stuck in pthread_cond_timedwait() Process 9326: stuck in pthread_cond_timedwait() Process 9327: stuck in pthread_cond_timedwait()
now here's a weird thing: occasionally, when i strace one of the threads, i can get a single frame refreshed in the Kaffeine window - but the general picture does not change, the same 'stuck' state is still there.
most threads are sitting in:
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a25134c in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib/libpthread.so.0 #2 0xb79f9a05 in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #3 0x4a24d2db in start_thread () from /lib/libpthread.so.0 #4 0x4a05820e in clone () from /lib/libc.so.6
9324 is looping around this place, apparently in the opengl video output driver, but the backtrace is not always this one:
(gdb) bt
#0 0x49ff7257 in memset () from /lib/libc.so.6
#1 0x49ff1877 in calloc () from /lib/libc.so.6
#2 0xb7a224d6 in xine_xmalloc_aligned () from /usr/lib/libxine.so.1
#3 0xb708c8f6 in QWidget::setUpdatesEnabled ()
from /usr/lib/xine/plugins/1.1.5/xineplug_vo_out_opengl.so
#4 0xb7a0525a in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1
#5 0xb78944e4 in QWidget::setUpdatesEnabled ()
from /usr/lib/xine/plugins/1.1.5/post/xineplug_post_tvtime.so
#6 0xb7895234 in QWidget::setUpdatesEnabled ()
from /usr/lib/xine/plugins/1.1.5/post/xineplug_post_tvtime.so
#7 0xad4e5439 in QWidget::setUpdatesEnabled ()
from /usr/lib/xine/plugins/1.1.5/xineplug_decode_mpeg2.so
#8 0xad4fa8e1 in QWidget::setUpdatesEnabled ()
from /usr/lib/xine/plugins/1.1.5/xineplug_decode_mpeg2.so #9 0xb7a032d6 in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #10 0x4a24d2db in start_thread () from /lib/libpthread.so.0 #11 0x4a05820e in clone () from /lib/libc.so.6
9321 is sitting in:
(gdb) bt
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2544a6 in nanosleep () from /lib/libpthread.so.0 #2 0xb7a222fa in xine_usec_sleep () from /usr/lib/libxine.so.1 #3 0xb7a073bb in QWidget::setUpdatesEnabled () from /usr/lib/libxine.so.1 #4 0x4a24d2db in start_thread () from /lib/libpthread.so.0 #5 0x4a05820e in clone () from /lib/libc.so.6
9322 is in poll():
(gdb) bt
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a04e533 in poll () from /lib/libc.so.6 #2 0xb12e1f75 in QWidget::setUpdatesEnabled () from /usr/lib/xine/plugins/1.1.5/xineplug_ao_out_alsa.so #3 0x4a24d2db in start_thread () from /lib/libpthread.so.0 #4 0x4a05820e in clone () from /lib/libc.so.6
9303 is stuck in xine_play(), pthread_mutex_lock():
#0 0xffffe410 in __kernel_vsyscall () #1 0x4a2538ce in __lll_mutex_lock_wait () from /lib/libpthread.so.0 #2 0x4a24f71c in _L_mutex_lock_79 () from /lib/libpthread.so.0 #3 0x4a24f24d in pthread_mutex_lock () from /lib/libpthread.so.0 #4 0xb79f64f9 in xine_play () from /usr/lib/libxine.so.1 #5 0xb7a9b0fb in KXineWidget::slotSeekToPosition () from /usr/lib/kde3/libxinepart.so #6 0xb7a9b3bc in KXineWidget::wheelEvent () from /usr/lib/kde3/libxinepart.so #7 0x4b5f9150 in QWidget::event () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #8 0x4b55353b in QApplication::internalNotify () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #9 0x4b55526e in QApplication::notify () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#10 0x4a72065e in KApplication::notify () from /usr/lib/libkdecore.so.4
#11 0x4b4dd5de in QETWidget::translateWheelEvent () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#12 0x4b4eb41d in QETWidget::translateMouseEvent () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#13 0x4b4e9766 in QApplication::x11ProcessEvent () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#14 0x4b4fb38b in QEventLoop::processEvents () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#15 0x4b56ce30 in QEventLoop::enterLoop () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#16 0x4b56cce6 in QEventLoop::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #17 0x4b55317f in QApplication::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3 #18 0x0806fc1a in QWidget::setUpdatesEnabled ()
#19 0x49f9df10 in __libc_start_main () from /lib/libc.so.6
#20 0x0806f7e1 in QWidget::setUpdatesEnabled ()
library versions:
xine-lib-1.1.5-1.fc7
xine-plugin-1.0-3.fc7
glibc-headers-2.5.90-21
glibc-common-2.5.90-21
glibc-2.5.90-21
glibc-devel-2.5.90-21
gxine-0.5.11-3.fc7
kaffeine-0.8.3-4.fc7
xine-0.99.4-11.lvn7
xine-lib-extras-1.1.5-1.fc7
gxine-mozplugin-0.5.11-3.fc7
Ingo
Re: Kaffeine problem with CFS
Quoted 10 lines · Ingo Molnar
these were only the threads that showed up in htop. Here's a full analysis about what all threads are doing:
Process 9303: stuck in xine_play()/pthread_mutex_lock()
Process 9319: stuck inpthread_cond_timedwait()
Process 9320: stuck inpthread_cond_timedwait()
Process 9321: loop of ~3 msec nanosleeps
Process 9322: loop ofpoll()calls every 335 msecs
Process 9323: stuck inpthread_cond_timedwait()
Process 9324: stuck in a loop of 1-second futex-waits + mmap/munmap (malloc)
Quoted 3 lines
Process 9325: stuck in pthread_cond_timedwait() Process 9326: stuck in pthread_cond_timedwait() Process 9327: stuck in pthread_cond_timedwait()
and here's a top snapshot:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 9324 mingo 20 0 300m 59m 17m R 96.4 6.8 21:00.55 kaffeine 9325 mingo 20 0 300m 59m 17m S 2.0 6.8 0:15.57 kaffeine 9327 mingo 20 0 300m 59m 17m S 2.0 6.8 0:20.10 kaffeine
so 9324 doing the mpeg decoding seems to be stuck somehow?
Ingo
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: Kaffeine problem with CFS
18 Nis 2007 Çar tarihinde, Christoph Pfister şunları yazmıştı:
Quoted 5 lines
Quoted 5 lines
Okay - so here are some results (it's strange that gdb goes nuts inside the
xine_playcall). I have three bts (seems to be fairly easy to reproduce that behaviour over here): Twice while playing an audio cd and once while playing a normal file. The hang usually ends if you wait long enough (something around 30 secs over here).
I can confirm this, freeze ends after some wait period (~20-30 secs) if kaffine is the only active process. I didn't notice that cause most probably CPU is busy with compiling kernel at that time...
Now i'm testing Ingo's msleep patch + xine-lib-1.1.6...
Cheers
Signature · 4 lines
S.Çağlar Onur <[email protected]> http://cekirdek.pardus.org.tr/~caglar/ Linux is like living in a teepee. No Windows, no Gates and an Apache in house!
Re: Kaffeine problem with CFS
In reply to a message not in the archive2007/4/18, Christoph Pfister <[email protected]>:
Quoted 38 lines
[ Sorry for accidentally dropping CCs ]
2007/4/18, Christoph Pfister <[email protected]>:
Quoted 35 lines
2007/4/18, Ingo Molnar <[email protected]>:
Quoted 20 lines · Christoph Pfister
Quoted 5 lines
Or I could try playing around a bit with your patchset and trying to reproduce it over here. Because I already have debug builds for xine-lib and compiling a new kernel can take place in the background it wouldn't be much effort for me.
that would be great :) Here are the URLs for it. CFS is based on v2.6.21-rc7:
http://kernel.org/pub/linux/kernel/v2.6/testing/linux-2.6.21-rc7.tar.bz2
And the CFS patch is at:
http://people.redhat.com/mingo/cfs-scheduler/sched-cfs-v2.patch
rebuild your kernel as usual and boot into it. No extra configuration is needed, you'll get CFS by default.
Quoted 8 lines
if this kernel builds/boots fine for you then you might also want to send me a quick note about how it feels, interactivity-wise. And of course i'm interested in any sort of feedback about problems as well. I'd like to make CFS as media-playback friendly as possible, so if there's any problem in that area it would be nice for me to know about it as soon as possible.
Ingo
Okay - so here are some results (it's strange that gdb goes nuts inside the
xine_playcall). I have three bts (seems to be fairly easy to reproduce that behaviour over here): Twice while playing an audio cd and once while playing a normal file. The hang usually ends if you wait long enough (something around 30 secs over here).
<big snip>
Quoted 5 lines
Quoted 4 lines
Christoph
PS: Haven't analyzed them yet - but doing so now :-)
Quoted 8 lines
Ok - one nice thing: In all those bts
demux_loopis at demux.c:285 - meaing thatdemux_lockis held andxine_playis waiting for it ... The lock should be temporilary unreleased with asched_yieldso that the main thread can access it. As you wrote the implementation of this function seems to have changed a bit - so I'll replace it with a short sleep and try again ...Christoph
Replacing the sched_yield in demux.c with an usleep(10) stopped those seeking hangs here (at least I was able to pull the slider back and forth during 2 mins without trouble compared to the few secs I need earlier to get a hang).
Christoph
Re: Kaffeine problem with CFS
18 Nis 2007 Çar tarihinde, Christoph Pfister şunları yazmıştı:
Quoted 4 lines
Replacing the
sched_yieldindemux.cwith an usleep(10) stopped those seeking hangs here (at least I was able to pull the slider back and forth during 2 mins without trouble compared to the few secs I need earlier to get a hang).
kernel/sched.c +1 -1
@@ -3785,7 +3785,7 @@ asmlinkage long sys_sched_yield(void)_raw_spin_unlock (&rq->lock);preempt_enable_no_resched (); -schedule (); +msleep (1 );return 0 ; }
which Ingo sends me to try also has the same effect on me. I cannot reproduce hangs anymore with that patch applied top of CFS while one console checks out SVN repos and other one compiles a small test software.
Cheers
Signature · 4 lines
S.Çağlar Onur <[email protected]> http://cekirdek.pardus.org.tr/~caglar/ Linux is like living in a teepee. No Windows, no Gates and an Apache in house!
Re: Kaffeine problem with CFS
Quoted 7 lines · S.Çağlar Onur
(quoted diff) +1
-1- schedule(); + msleep(1);which Ingo sends me to try also has the same effect on me. I cannot reproduce hangs anymore with that patch applied top of CFS while one console checks out SVN repos and other one compiles a small test software.
great! Could you please unapply the hack above and try the proper fix below, does this one solve the hangs too?
Ingo
kernel/sched_fair.c +18 -4
@@ -264,15 +264,26 @@ static void dequeue_task_fair(struct rq/* * sched_yield() support is very simple via the rbtree, we just -* dequeue and enqueue the task, which causes the task to -* roundrobin to the end of the tree: +* dequeue the task and move it to the rightmost position, which +* causes the task to roundrobin to the end of the tree. */ static void requeue_task_fair (struct rq *rq,struct task_struct *p) {dequeue_task_fair (rq, p); p->on_rq =0 ; -enqueue_task_fair (rq, p); +/* +* Temporarily insert at the last position of the tree: +*/ + p->fair_key =LLONG_MAX ; +__enqueue_task_fair (rq, p); p->on_rq =1 ; + +/* +* Update the key to the real value, so that when all other +* tasks from before the rightmost position have executed, +* this task is picked up again: +*/ + p->fair_key = rq->fair_clock - p->wait_runtime + p->nice_offset; }/*
@@ -380,7 +391,10 @@ static void task_tick_fair(struct rq *rq* Dequeue and enqueue the task to update its * position within the tree: */ -requeue_task_fair (rq, curr); +dequeue_task_fair (rq, curr); + curr->on_rq =0 ; +enqueue_task_fair (rq, curr); + curr->on_rq =1 ;/* * Reschedule if another task tops the current one.
Re: Kaffeine problem with CFS
Quoted 8 lines · Ingo Molnar
static void
requeue_task_fair(struct rq *rq, struct task_struct *p){kernel/sched_fair.c +3
-1dequeue_task_fair (rq, p); p->on_rq =0 ; -enqueue_task_fair (rq, p); +/* +* Temporarily insert at the last position of the tree: +*/
kernel/sched_fair.c static void dequeue_task_fair(struct rq · line 286
Quoted 10 lines
kernel/sched_fair.c +9
-0+ p->fair_key =LLONG_MAX ; +__enqueue_task_fair (rq, p); p->on_rq =1 ; + +/* +* Update the key to the real value, so that when all other +* tasks from before the rightmost position have executed, +* this task is picked up again: +*/ + p->fair_key = rq->fair_clock - p->wait_runtime + p->nice_offset;
At this point you might as well call the requeue operation something having to do with yield. I also suspect what goes on during the timer tick may eventually become something different from requeueing the current task, and furthermore class-dependent.
-- wli
Re: Kaffeine problem with CFS
Quoted 2 lines · William Lee Irwin III
At this point you might as well call the requeue operation something having to do with yield. [...]
agreed - i've just done a requeue_task -> yield_task rename in my tree. (patch below)
Quoted 3 lines
[...] I also suspect what goes on during the timer tick may eventually become something different from requeueing the current task, and furthermore class-dependent.
it already is, scheduler tick processing is done in class->task_tick().
Ingo
--- include/linux/sched.h | 2 +- kernel/sched.c | 7 +------ kernel/sched_fair.c | 4 ++-- kernel/sched_rt.c | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-)
include/linux/sched.h +1 -1
@@ -796,7 +796,7 @@ struct sched_class {void (*enqueue_task) (struct rq *rq,struct task_struct *p);void (*dequeue_task) (struct rq *rq,struct task_struct *p); -void (*requeue_task) (struct rq *rq,struct task_struct *p); +void (*yield_task) (struct rq *rq,struct task_struct *p);void (*check_preempt_curr) (struct rq *rq,struct task_struct *p);
kernel/sched.c +1 -6
@@ -560,11 +560,6 @@ static void dequeue_task(struct rq *rq, p->on_rq =0 ; } -static void requeue_task (struct rq *rq,struct task_struct *p) -{ - p->sched_class->requeue_task (rq, p); -} -/* * __normal_prio - return the priority that is based on the static prio */
@@ -3773,7 +3768,7 @@ asmlinkage long sys_sched_yield(void)schedstat_inc (rq, yld_cnt);if (rq->nr_running ==1 )schedstat_inc (rq, yld_act_empty); -requeue_task (rq, current); + current->sched_class->yield_task (rq, current);/* * Since we are going to call schedule() anyway, there's
kernel/sched_fair.c +2 -2
@@ -273,7 +273,7 @@ static void dequeue_task_fair(struct rq* dequeue the task and move it to the rightmost position, which * causes the task to roundrobin to the end of the tree. */ -static void requeue_task_fair (struct rq *rq,struct task_struct *p) +static void yield_task_fair (struct rq *rq,struct task_struct *p) {dequeue_task_fair (rq, p); p->on_rq =0 ;
@@ -509,7 +509,7 @@ static void task_init_fair(struct rq *rqstruct sched_class fair_sched_class__read_mostly = { .enqueue_task = enqueue_task_fair, .dequeue_task = dequeue_task_fair, - .requeue_task = requeue_task_fair, + .yield_task = yield_task_fair, .check_preempt_curr = check_preempt_curr_fair,
kernel/sched_rt.c +1 -1
@@ -165,7 +165,7 @@ static void task_init_rt(struct rq *rq,static struct sched_class rt_sched_class__read_mostly = { .enqueue_task = enqueue_task_rt, .dequeue_task = dequeue_task_rt, - .requeue_task = requeue_task_rt, + .yield_task = requeue_task_rt, .check_preempt_curr = check_preempt_curr_rt,
Re: Kaffeine problem with CFS
In reply to Ingo Molnar18 Nis 2007 Çar tarihinde, Ingo Molnar şunları yazmıştı:
Quoted 11 lines · S.Çağlar Onur
Quoted 7 lines
(quoted diff) +1
-1- schedule(); + msleep(1);which Ingo sends me to try also has the same effect on me. I cannot reproduce hangs anymore with that patch applied top of CFS while one console checks out SVN repos and other one compiles a small test software.
great! Could you please unapply the hack above and try the proper fix below, does this one solve the hangs too?
Instead of that one, i tried CFSv3 and i cannot reproduce the hang anymore, Thanks!...
Cheers
Signature · 4 lines
S.Çağlar Onur <[email protected]> http://cekirdek.pardus.org.tr/~caglar/ Linux is like living in a teepee. No Windows, no Gates and an Apache in house!
Re: Kaffeine problem with CFS
Quoted 5 lines · S.Çağlar Onur
Quoted 2 lines
great! Could you please unapply the hack above and try the proper fix below, does this one solve the hangs too?
Instead of that one, i tried CFSv3 and i cannot reproduce the hang anymore, Thanks!...
cool, thanks for the quick turnaround!
Ingo
Re: Kaffeine problem with CFS
In reply to S.Çağlar OnurQuoted 5 lines · S.Çag(lar Onur
18 Nis 2007 Çar tarihinde, Ingo Molnar s,unlar? yazm?s,t?:
Quoted 4 lines · S.Çag(lar Onur
Quoted 3 lines
(quoted diff) +1
-1- schedule(); + msleep(1);
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
which Ingo sends me to try also has the same effect on me. I cannot reproduce hangs anymore with that patch applied top of CFS while one console checks out SVN repos and other one compiles a small test software.
great! Could you please unapply the hack above and try the proper fix below, does this one solve the hangs too?
Instead of that one, i tried CFSv3 and i cannot reproduce the hang anymore, Thanks!...
And that explains why CFS-v3 on 21-rc7-git3 wouldn't show me the hang. As a matter of fact, nothing I did showed any bad behavior! Note that I was doing actual badly behaved things which do sometimes glitch the standard scheduler, not running benchmarks.
This scheduler is boring, everything works. I am going to try some tests on a uniprocessor, though, I have been running everything on either SMP or HT CPUs. But so far it looks fine.
Signature · 3 lines
Bill Davidsen <[email protected]> "We have more to fear from the bungling of the incompetent than from the machinations of the wicked." - from Slashdot
Re: Kaffeine problem with CFS
Quoted 9 lines · Bill Davidsen
Quoted 2 lines
Instead of that one, i tried CFSv3 and i cannot reproduce the hang anymore, Thanks!...
And that explains why CFS-v3 on 21-rc7-git3 wouldn't show me the hang. As a matter of fact, nothing I did showed any bad behavior! Note that I was doing actual badly behaved things which do sometimes glitch the standard scheduler, not running benchmarks.
This scheduler is boring, everything works. [...]
hehe :) Having a 'boring' scheduler in the end is the main goal :)
Quoted 3 lines
[...] I am going to try some tests on a uniprocessor, though, I have been running everything on either SMP or HT CPUs. But so far it looks fine.
yeah, please do - while i do test UP frequently, most of my CFS testing was on SMP.
Ingo
Re: Kaffeine problem with CFS
In reply to Christoph PfisterQuoted 4 lines · Christoph Pfister
Replacing the
sched_yieldindemux.cwith an usleep(10) stopped those seeking hangs here (at least I was able to pull the slider back and forth during 2 mins without trouble compared to the few secs I need earlier to get a hang).
great - thanks for figuring it out!
Ingo
Quoted 6 lines · Ingo Molnar
[announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS]
i'm pleased to announce the first release of the "Modular Scheduler Core and Completely Fair Scheduler [CFS]" patchset:
Quoted 6 lines
http://redhat.com/~mingo/cfs-scheduler/sched-modular+cfs.patch
This project is a complete rewrite of the Linux task scheduler. My goal is to address various feature requests and to fix deficiencies in the vanilla scheduler that were suggested/found in the past few years, both for desktop scheduling and for server scheduling workloads.
The casual observer will be completely confused by what on earth has happened here so let me try to demystify things for them.
1. I tried in vain some time ago to push a working extensable pluggable cpu scheduler framework (based on wli's work) for the linux kernel. It was perma-vetoed by Linus and Ingo (and Nick also said he didn't like it) as being absolutely the wrong approach and that we should never do that. Oddly enough the linux-kernel-mailing list was -dead- at the time and the discussion did not make it to the mailing list. Every time I've tried to forward it to the mailing list the spam filter decided to drop it so most people have not even seen this original veto-forever discussion.
2. Since then I've been thinking/working on a cpu scheduler design that takes away all the guesswork out of scheduling and gives very predictable, as fair as possible, cpu distribution and latency while preserving as solid interactivity as possible within those confines. For weeks now, Ingo has said that the interactivity regressions were showstoppers and we should address them, never mind the fact that the so-called regressions were purely "it slows down linearly with load" which to me is perfectly desirable behaviour. While this was not perma-vetoed, I predicted pretty accurately your intent was to veto it based on this.
People kept claiming scheduling problems were few and far between but what was really happening is users were terrified of lkml and instead used 1. windows and 2. 2.4 kernels. The problems were there.
So where are we now? Here is where your latest patch comes in.
As a solution to the many scheduling problems we finally all agree exist, you propose a patch that adds 1. a limited pluggable framework and 2. a fairness based cpu scheduler policy... o_O
So I should be happy at last now that the things I was promoting you are also promoting, right? Well I'll fill in the rest of the gaps and let other people decide how I should feel.
Quoted 2 lines
as usual, any sort of feedback, bugreports, fixes and suggestions are more than welcome,
In the last 4 weeks I've spent time lying in bed drugged to the eyeballs and having trips in and out of hospitals for my condition. I appreciate greatly the sympathy and patience from people in this regard. However at one stage I virtually begged for support with my attempts and help with the code. Dmitry Adamushko is the only person who actually helped me with the code in the interim, while others poked sticks at it. Sure the sticks helped at times but the sticks always seemed to have their ends kerosene doused and flaming for reasons I still don't get. No other help was forthcoming.
Now that you're agreeing my direction was correct you've done the usual Linux kernel thing - ignore all my previous code and write your own version. Oh well, that I've come to expect; at least you get a copyright notice in the bootup and somewhere in the comments give me credit for proving it's possible. Let's give some other credit here too. William Lee Irwin provided the major architecture behind plugsched at my request and I simply finished the work and got it working. He is also responsible for many IRC discussions I've had about cpu scheduling fairness, designs, programming history and code help. Even though he did not contribute code directly to SD, his comments have been invaluable.
So let's look at the code.
kernel/sched.ckernel/sched_fair.ckernel/sched_rt.c
It turns out this is not a pluggable cpu scheduler framework at all, and I guess you didn't really promote it as such. It's a "modular scheduler core". Which means you moved code from sched.c into sched_fair.c and sched_rt.c. This abstracts out each _scheduling policy's_ functions into struct sched_class and allows each scheduling policy's functions to be in a separate file etc.
Ok so what it means is that instead of whole cpu schedulers being able to be plugged into this framework we can plug in only cpu scheduling policies.... hrm... So let's look on
-#define SCHED_NORMAL 0
Ok once upon a time we rename SCHED_OTHER which every other unix calls the standard policy 99.9% of applications used into a more meaningful name, SCHED_NORMAL. That's fine since all it did was change the description internally for those reading the code. Let's see what you've done now:
+#define SCHED_FAIR 0
You've renamed it again. This is, I don't know what exactly to call it, but an interesting way of making it look like there is now more choice. Well, whatever you call it, everything in linux spawned from init without specifying a policy still gets policy 0. This is SCHED_OTHER still, renamed SCHED_NORMAL and now SCHED_FAIR.
You encouraged me to create a sched_sd.c to add onto your design as well. Well, what do I do with that? I need to create another scheduling policy for that code to even be used. A separate scheduling policy requires a userspace change to even benefit from it. Even if I make that sched_sd.c patch, people cannot use SD as their default scheduler unless they hack SCHED_FAIR 0 to read SCHED_SD 0 or similar. The same goes for original staircase cpusched, nicksched, zaphod, spa_ws, ebs and so on.
So what you've achieved with your patch is - replaced the current scheduler with another one and moved it into another file. There is no choice, and no pluggability, just code trumping.
Do I support this? In this form.... no.
It's not that I don't like your new scheduler. Heck it's beautiful like most of your _serious_ code. It even comes with a catchy name that's bound to give people hard-ons (even though many schedulers aim to be completely fair, yours has been named that for maximum selling power). The complaint I have is that you are not providing quite what you advertise (on the modular front), or perhaps you're advertising it as such to make it look more appealing; I'm not sure.
Since we'll just end up with your code, don't pretend SCHED_NORMAL is anything different, and that this is anything other than your NIH (Not Invented Here) cpu scheduling policy rewrite which will probably end up taking it's position in mainline after yet another truckload of regression/performance tests and so on. I haven't seen an awful lot of comparisons with SD yet, just people jumping on your bandwagon which is fine I guess. Maybe a few tiny tests showing less than 5% variation in their fairness from what I can see. Either way, I already feel you've killed off SD... like pretty much everything else I've done lately. At least I no longer have to try and support my code mostly by myself.
In the interest of putting aside any ego concerns since this is about linux and not me...
Because... You are a hair's breadth away from producing something that I would support, which _does_ do what you say and produces the pluggability we're all begging for with only tiny changes to the code you've already done. Make Kconfig let you choose which sched_*.c gets built into the kernel, and make SCHED_OTHER choose which SCHED_* gets chosen as the default from Kconfig and even choose one of the alternative built in ones with boot parametersyour code has more clout than mine will (ie do exactly what plugsched does). Then we can have 7 schedulers in linux kernel within a few weeks. Oh no! This is the very thing Linus didn't want in specialisation with the cpu schedulers! Does this mean this idea will be vetoed yet again? In all likelihood, yes.
I guess I have lots to put into -ck still... sigh.
Quoted 1 line
Ingo
Signature · 1 line
-ck
On Sun, Apr 15, 2007 at 01:27:13PM +1000, Con Kolivas wrote:
...
Quoted 10 lines
Now that you're agreeing my direction was correct you've done the usual Linux kernel thing - ignore all my previous code and write your own version. Oh well, that I've come to expect; at least you get a copyright notice in the bootup and somewhere in the comments give me credit for proving it's possible. Let's give some other credit here too. William Lee Irwin provided the major architecture behind plugsched at my request and I simply finished the work and got it working. He is also responsible for many IRC discussions I've had about cpu scheduling fairness, designs, programming history and code help. Even though he did not contribute code directly to SD, his comments have been invaluable.
Hello folks,
I think the main failure I see here is that Con wasn't included in this design or privately in review process. There could have been better co-ownership of the code. This could also have been done openly on lkml (since this is kind of what this medium is about to significant degree) so that consensus can happen (Con can be reasoned with). It would have achieved the same thing but probably more smoothly if folks just listened, considered an idea and then, in this case, created something that would allow for experimentation from outsiders in a fluid fashion.
If these issues aren't fixed, you're going to stuck with the same kind of creeping elitism that has gradually killed the FreeBSD project and other BSDs. I can't comment on the code implementation. I'm focus on other things now that I'm at NetApp and I can't help out as much as I could. Being former BSDi, I had a first hand account of these issues as they played out.
A development process like this is likely to exclude smart people from wanting to contribute to Linux and folks should be conscious about this issues. It's basically a lot of code and concept that at least two individuals have worked on (wli and con) only to have it be rejected and then sudden replaced by code from a community gatekeeper. In this case, this results in both Con and Bill Irwin being woefully under utilized.
If I were one of these people. I'd be mighty pissed.
bill
Quoted 6 lines · Bill Huey
Hello folks,
I think the main failure I see here is that Con wasn't included in this design or privately in review process. There could have been better co-ownership of the code. This could also have been done openly on lkml [...]
Bill, you come from a BSD background and you are still relatively new to Linux development, so i dont at all fault you for misunderstanding this situation, and fortunately i have a really easy resolution for your
worries: i did exactly that! :)
i wrote the first line of code of the CFS patch this week, 8am Wednesday morning, and released it to lkml 62 hours later, 22pm on Friday. (I've listed the file timestamps of my backup patches further below, for all the fine details.)
I prefer such early releases to lkml _alot_ more than any private review process. I released the CFS code about 6 hours after i thought "okay, this looks pretty good" and i spent those final 6 hours on testing it (making sure it doesnt blow up on your box, etc.), in the final 2 hours i showed it to two folks i could reach on IRC (Arjan and Thomas) and on various finishing touches. It doesnt get much faster than that and i definitely didnt want to sit on it even one day longer because i very much thought that Con and others should definitely see this work!
And i very much credited (and still credit) Con for the whole fairness angle:
|| i'd like to give credit to Con Kolivas for the general approach here: || he has proven via RSDL/SD that 'fair scheduling' is possible and that || it results in better desktop scheduling. Kudos Con!
the 'design consultation' phase you are talking about is _NOW_! :)
I got the v1 code out to Con, to Mike and to many others ASAP. That's how you are able to comment on this thread and be part of the development process to begin with, in a 'private consultation' setup you'd not have had any opportunity to see _any_ of this.
In the BSD space there seem to be more 'political' mechanisms for development, but Linux is truly about doing things out in the open, and doing it immediately.
Okay? ;-)
Here's the timestamps of all my backups of the patch, from its humble 4K beginnings to the 100K first-cut v1 result:
-rw-rw-r-- 1 mingo mingo 4230 Apr 11 08:47 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 7653 Apr 11 09:12 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 7728 Apr 11 09:26 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 14416 Apr 11 10:08 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 24211 Apr 11 10:41 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 27878 Apr 11 10:45 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 33807 Apr 11 11:05 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 34524 Apr 11 11:09 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 39650 Apr 11 11:19 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 40231 Apr 11 11:34 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 40627 Apr 11 11:48 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 40638 Apr 11 11:54 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 42733 Apr 11 12:19 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 42817 Apr 11 12:31 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 43270 Apr 11 12:41 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 43531 Apr 11 12:48 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 44331 Apr 11 12:51 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 45173 Apr 11 12:56 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 45288 Apr 11 12:59 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 45368 Apr 11 13:06 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 45370 Apr 11 13:06 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 45815 Apr 11 13:14 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 45887 Apr 11 13:19 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 45914 Apr 11 13:25 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 45850 Apr 11 13:29 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 49196 Apr 11 13:39 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 64317 Apr 11 13:45 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 64403 Apr 11 13:52 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 65199 Apr 11 14:03 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 65199 Apr 11 14:07 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 68995 Apr 11 14:50 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 69919 Apr 11 15:23 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 71065 Apr 11 16:26 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 70642 Apr 11 16:28 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 72334 Apr 11 16:49 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 71624 Apr 11 17:01 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 71854 Apr 11 17:20 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 73571 Apr 11 17:42 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 74708 Apr 11 17:49 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 74708 Apr 11 17:51 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 75144 Apr 11 17:57 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 80722 Apr 11 18:19 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 80727 Apr 11 18:41 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 80727 Apr 11 18:59 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 89356 Apr 11 21:32 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 95278 Apr 12 08:36 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 97749 Apr 12 10:49 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 97687 Apr 12 10:58 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 97722 Apr 12 11:06 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 97933 Apr 12 11:22 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 98167 Apr 12 12:04 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 98167 Apr 12 12:09 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 100405 Apr 12 12:29 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 100380 Apr 12 12:50 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 101631 Apr 12 13:32 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 102293 Apr 12 14:12 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 102431 Apr 12 14:28 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 102502 Apr 12 14:53 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 102128 Apr 13 11:13 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 102473 Apr 13 12:12 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 102536 Apr 13 12:24 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 102481 Apr 13 12:30 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 103408 Apr 13 13:08 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 103441 Apr 13 13:31 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 104759 Apr 13 14:19 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 104815 Apr 13 14:39 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 104762 Apr 13 15:04 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 105978 Apr 13 16:18 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 105977 Apr 13 16:26 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 106761 Apr 13 17:08 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 106358 Apr 13 17:40 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 107802 Apr 13 19:04 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 104427 Apr 13 19:35 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 103927 Apr 13 19:40 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 101867 Apr 13 20:30 patches/sched-fair.patch -rw-rw-r-- 1 mingo mingo 101011 Apr 13 21:05 patches/sched-fair.patch
i hope this helps :)
Ingo
Quoted 18 lines · Ingo Molnar
I prefer such early releases to lkml _alot_ more than any private review process. I released the CFS code about 6 hours after i thought "okay, this looks pretty good" and i spent those final 6 hours on testing it (making sure it doesnt blow up on your box, etc.), in the final 2 hours i showed it to two folks i could reach on IRC (Arjan and Thomas) and on various finishing touches. It doesnt get much faster than that and i definitely didnt want to sit on it even one day longer because i very much thought that Con and others should definitely see this work!
And i very much credited (and still credit) Con for the whole fairness angle:
|| i'd like to give credit to Con Kolivas for the general approach here: || he has proven via RSDL/SD that 'fair scheduling' is possible and that || it results in better desktop scheduling. Kudos Con!the 'design consultation' phase you are talking about is _NOW_! :)
Quoted 8 lines
I got the v1 code out to Con, to Mike and to many others ASAP. That's how you are able to comment on this thread and be part of the development process to begin with, in a 'private consultation' setup you'd not have had any opportunity to see _any_ of this.
In the BSD space there seem to be more 'political' mechanisms for development, but Linux is truly about doing things out in the open, and doing it immediately.
I can't even begin to talk about how screwed up BSD development is. Maybe another time privately.
Ok, Linux development and inclusiveness can be improved. I'm not trying to "call you out" (slang for accusing you with the sole intention to call you crazy in a highly confrontative manner). This is discussed publically here to bring this issue to light, open a communication channel as a means to resolve it.
Quoted 1 line
Okay? ;-)
It's cool. We're still getting to know each other professionally and it's okay to a certain degree to have a communication disconnect but only as long as it clears. Your productivity is amazing BTW. But here's the problem, there's this perception that NIH is the default mentality here in Linux.
Con feels that this kind of action is intentional and has a malicious quality to it as means of "churn squating" sections of the kernel tree. The perception here is that there is that there is this expectation that sections of the Linux kernel are intentionally "churn squated" to prevent any other ideas from creeping in other than of the owner of that subsytem (VM, scheduling, etc...) because of lack of modularity in the kernel. This isn't an API question but a question possibly general code quality and how maintenance () of it can .
This was predicted by folks and then this perception was *realized* when you wrote the equivalent kind of code that has technical overlap with SDL (this is just one dry example). To a person that is writing new code for Linux, having one of the old guards write equivalent code to that of a newcomer has the effect of displacing that person both with regards to code and responsibility with that. When this happens over and over again and folks get annoyed by it, it starts seeming that Linux development seems elitist.
I know this because I heard (read) Con's IRC chats all the time about these matters all of the time. This is not just his view but a view of other kernel folks that differing views as to. The closing talk at OLS 2006 was highly disturbing in many ways. It went "Christoph" is right everybody else is wrong which sends a highly negative message to new kernel developers that, say, don't work for RH directly or any of the other mainstream Linux companies. After a while, it starts seeming like this kind of behavior is completely intentional and that Linux is full of arrogant bastards.
What I would have done here was to contact Peter Williams, Bill Irwin and Con about what your doing and reach a common concensus about how to create something that would be inclusive of all of their ideas. Discussions can technically heated but that's ok, the discussion is happening and it brings down the wall of this perception. Bill and Con are on oftc.net/#offtopic2. Riel is there as well as Peter Zijlstra. It might be very useful, it might not be. Folks are all stubborn about there ideas and hold on to them for dear life. Effective leaders can deconstruct this hostility and animosity. I don't claim to be one.
Because of past hostility to something like schedplugin, the hostility and terseness of responses can be percieved simply as "I'm right, you're wrong" which is condescending. This effects discussion and outright destroys a constructive process if this happens continually since it reenforces that view of "You're an outsider, we don't care about you". Nobody is listening to each other at that point, folks get pissed. Then they think about "I'm going to NIH this person with patc X because he/she did the same here" which is dysfunctional.
Oddly enough, sometimes you're the best person to get a new idea into the tree. What's not happening here is communication. That takes sensitivity, careful listening which is a difficult skill, and then understanding of the characters involved to unify creative energies.
That's a very difficult thing to do for folks that are use to working solo. It take time to develop trust in those relationships so that a true collaboration can happen. I know that there is a lot of creativity in folks like Con and Bill. It would be wise to develop a dialog with them to see if they can offload some of your work for you (we all know you're really busy) yet have you be a key facilitator of their and your ideas. That's a really tough thing to do and it requires practice. Just imagine (assuming they can follow through) what could have positively happened if there collective knowledge was leveraged better. It's not all clear and rosy, but I think these people are more on your side that you might realized and it might be a good thing to discover that.
This is tough because I know the personalities involved and I know kind of how people function and malfunction in this discussion on a personal basis.
[We can continue privately. This not just about you but applicable to open source development in general]
The tone of this email is intellectually critical (not ment as personality attack) and calm. If I'm otherwise, them I'm a bastard. :)
bill
Quoted 3 lines · hui Bill Huey
The perception here is that there is that there is this expectation that sections of the Linux kernel are intentionally "churn squated" to prevent any other ideas from creeping in other than of the owner of that subsytem
Strangely enough, my perception is that Ingo is simply trying to address the issues Mike's testing discovered in RDSL and SD. It's not surprising Ingo made it a separate patch set as Con has repeatedly stated that the "problems" are in fact by design and won't be fixed.
Quoted 9 lines · Pekka Enberg
Quoted 3 lines · hui Bill Huey
The perception here is that there is that there is this expectation that sections of the Linux kernel are intentionally "churn squated" to prevent any other ideas from creeping in other than of the owner of that subsytem
Strangely enough, my perception is that Ingo is simply trying to address the issues Mike's testing discovered in RDSL and SD. It's not surprising Ingo made it a separate patch set as Con has repeatedly stated that the "problems" are in fact by design and won't be fixed.
That's not exactly the problem. There are people who work very hard to try to improve some areas of the kernel. They progress slowly, and acquire more and more skills. Sometimes they feel like they need to change some concepts and propose those changes which are required for them to go further, or to develop faster. Those are rejected. So they are constrained to work in a delimited perimeter from which it is difficult for them to escape.
Then, the same person who rejected their changes comes with something shiny new, better and which took him far less time. But he sort of broke the rules because what was forbidden to the first persons is suddenly permitted. Maybe for very good reasons, I'm not discussing that. The good reason should have been valid the first time too.
The fact is that when changes are rejected, we should not simply say "no", but explain why and define what would be acceptable. Some people here have excellent teaching skills for this, but most others do not. Anyway, the rules should be the same for everybody.
Also, there is what can be perceived as marketting here. Con worked on his idea with convictions, he took time to write some generous documentation, but he hit a wall where his concept was suboptimal on a given workload. But at least, all the work was oriented on a technical basis : design + code + doc.
Then, Ingo comes in with something looking amazingly better, with virtually no documentation, an appealing announcement, and a shiny advertising at boot. All this implemented without the constraints other people had to respect. It already looks like definitive work which will be merge as-is without many changes except a few bugfixes.
If those were two companies, the first one would simply have accused the second one of not having respected contracts and having employed heaving marketting to take the first place.
People here do not code for a living, they do it at least because they believe in what they are doing, and some of them want a bit of gratitude for their work. I've met people who were proud to say they implement this or that feature in the kernel, so it is something important for them. And being cited in an email is nothing compared to advertising at boot time.
When the discussion was blocked between Con and Mike concerning the design problems, it is where a new discussion should have taken place. Ingo could have publicly spoken with them about his ideas of killing the O(1) scheduler and replacing it with an rbtree-based one, and using part of Bill's work to speed up development.
It is far easier to resign when people explain what concepts are wrong and how they think they will do than when they suddenly present something out of nowhere which is already better.
And it's not specific to Ingo (though I think his ability to work that fast alone makes him tend to practise this more often than others).
Imagine if Con had worked another full week on his scheduler with better results on Mike's workload, but still not as good as Ingo's, and they both published at the same time. You certainly can imagine he would have preferred to be informed first that it was pointless to continue in that direction.
Now I hope he and Bill will get over this and accept to work on improving this scheduler, because I really find it smarter than a dumb O(1). I even agree with Mike that we now have a solid basis for future work. But for this, maybe a good starting point would be to remove the selfish printk at boot, revert useless changes (SCHED_NORMAL->SCHED_FAIR come to mind) and improve the documentation a bit so that people can work together on the new design, without feeling like their work will only server to promote X or Y.
Regards,
Willy
Quoted 3 lines · Willy Tarreau
Ingo could have publicly spoken with them about his ideas of killing the O(1) scheduler and replacing it with an rbtree-based one, and using part of Bill's work to speed up development.
He did exactly that and he did it with a patch. Nothing new here. This is how development on LKML proceeds when you have two or more competing designs. There's absolutely no need to get upset or hurt your feelings over it. It's not malicious, it's how we do Linux development.
Quoted 9 lines · Pekka J Enberg
Quoted 3 lines · Willy Tarreau
Ingo could have publicly spoken with them about his ideas of killing the O(1) scheduler and replacing it with an rbtree-based one, and using part of Bill's work to speed up development.
He did exactly that and he did it with a patch. Nothing new here. This is how development on LKML proceeds when you have two or more competing designs. There's absolutely no need to get upset or hurt your feelings over it. It's not malicious, it's how we do Linux development.
Yes. Exactly. This is what it's all about, this is what makes it work.
-Mike
Quoted 8 lines · Mike Galbraith
Quoted 5 lines · Pekka J Enberg
He did exactly that and he did it with a patch. Nothing new here. This is how development on LKML proceeds when you have two or more competing designs. There's absolutely no need to get upset or hurt your feelings over it. It's not malicious, it's how we do Linux development.
Yes. Exactly. This is what it's all about, this is what makes it work.
I obviously agree, but I will also add that one of the most motivating things there *is* in open source is "personal pride".
It's a really good thing, and it means that if somebody shows that your code is flawed in some way (by, for example, making a patch that people claim gets better behaviour or numbers), any *good* programmer that actually cares about his code will obviously suddenly be very motivated to out-do the out-doer!
Does this mean that there will be tension and rivalry? Hell yes. But that's kind of the point. Life is a game, and if you aren't in it to win, what the heck are you still doing here?
As long as it's reasonably civil (I'm not personally a huge believer in being too polite or "politically correct", so I think the "reasonably" is more important than the "civil" part!), and as long as the end result is judged on TECHNICAL MERIT, it's all good.
We don't want to play politics. But encouraging peoples competitive feelings? Oh, yes.
Linus
Quoted 5 lines · Linus Torvalds
It's a really good thing, and it means that if somebody shows that your code is flawed in some way (by, for example, making a patch that people claim gets better behaviour or numbers), any *good* programmer that actually cares about his code will obviously suddenly be very motivated to out-do the out-doer!
"No one who cannot rejoice in the discovery of his own mistakes deserves to be called a scholar."
--Don Foster, "literary sleuth", on retracting his attribution of "A Funerall Elegye" to Shakespeare (it's more likely John Ford's work).
Quoted 10 lines · Jonathan Lundell
Quoted 8 lines · Linus Torvalds
It's a really good thing, and it means that if somebody shows that your
code is flawed in some way (by, for example, making a patch that people
claim gets better behaviour or numbers), any *good* programmer that actually cares about his code will obviously suddenly be very motivated to
out-do the out-doer!
Quoted 2 lines
"No one who cannot rejoice in the discovery of his own mistakes deserves to be called a scholar."
Lovely comment. I realise this is not truly directed at me but clearly in the context it has been said people will assume it is directed my way, so while we're all spinning lkml quality rhetoric, let me have a right of reply.
One thing I have never tried to do was to ignore bug reports. I'm forever joking that I keep pulling code out of my arse to improve what I've done. RSDL/SD was no exception; heck it had 40 iterations. The reason I could not reply to bug report A with "Oh that is problem B so I'll fix it with code C" was, as I've said many many times over, health related. I did indeed try to fix many of them without spending hours replying to sometimes unpleasant emails. If health wasn't an issue there might have been 1000 iterations of SD.
There was only ever _one_ thing that I was absolutely steadfast on as a concept that I refused to fix that people might claim was "a mistake I did not rejoice in to be a scholar". That was that the _correct_ behaviour for a scheduler is to be fair such that proportional slowdown with load is (using that awful pun) a feature, not a bug. Now there are people who will still disagree violently with me on that. SD attempted to be a fairness first virtual-deadline design. If I failed on that front, then so be it (and at least one person certainly has said in lovely warm fuzzy friendly communication that I'm a global failure on all fronts with SD). But let me point out now that Ingo's shiny new scheduler is a fairness-first virtual-deadline design which will have proportional slowdown with load. So it will have a very similar feature. I dare anyone to claim that proportional slowdown with load is a bug, because I will no longer feel like I'm standing alone with a BFG9000 trying to defend my standpoint. Others can take up the post at last.
Signature · 1 line
-ck
Quoted 18 lines · Con Kolivas
Quoted 10 lines · Jonathan Lundell
Quoted 8 lines · Linus Torvalds
It's a really good thing, and it means that if somebody shows that your
code is flawed in some way (by, for example, making a patch that people
claim gets better behaviour or numbers), any *good* programmer that actually cares about his code will obviously suddenly be very motivated to
out-do the out-doer!Quoted 2 lines
"No one who cannot rejoice in the discovery of his own mistakes deserves to be called a scholar."
Lovely comment. I realise this is not truly directed at me but clearly in the context it has been said people will assume it is directed my way, so while we're all spinning lkml quality rhetoric, let me have a right of reply.
Quoted 8 lines
One thing I have never tried to do was to ignore bug reports. I'm forever joking that I keep pulling code out of my arse to improve what I've done. RSDL/SD was no exception; heck it had 40 iterations. The reason I could not reply to bug report A with "Oh that is problem B so I'll fix it with code C" was, as I've said many many times over, health related. I did indeed try to fix many of them without spending hours replying to sometimes unpleasant emails. If health wasn't an issue there might have been 1000 iterations of SD.
Well what matters is the code and development. I don't think Ingo's scheduler is the final word, although I worry that Linus might jump the gun and merge something "just to give it a test", which we then get stuck with :P
I don't know how anybody can think Ingo's new scheduler is anything but a good thing (so long as it has to compete before being merged). And that's coming from someone who wants *their* scheduler to get merged... I think mine can compete ;) and if it can't, then I'd rather be using the scheduler that beats it.
Quoted 5 lines
There was only ever _one_ thing that I was absolutely steadfast on as a concept that I refused to fix that people might claim was "a mistake I did not rejoice in to be a scholar". That was that the _correct_ behaviour for a scheduler is to be fair such that proportional slowdown with load is (using that awful pun) a feature, not a bug.
If something is using more than a fair share of CPU time, over some macro period, in order to be interactive, then definitely it should get throttled. I've always maintained (since starting scheduler work) that the 2.6 scheduler is horrible because it allows these cases where some things can get more CPU time just by how they behave.
Glad people are starting to come around on that point.
So, on to something productive, we have 3 candidates for a new scheduler so far. How do we decide which way to go? (and yes, I still think switchable schedulers is wrong and a copout) This is one area where it is virtually impossible to discount any decent design on correctness/performance/etc. and even testing in -mm isn't really enough.
Quoted 5 lines · Nick Piggin
So, on to something productive, we have 3 candidates for a new scheduler so far. How do we decide which way to go? (and yes, I still think switchable schedulers is wrong and a copout) This is one area where it is virtually impossible to discount any decent design on correctness/performance/etc. and even testing in -mm isn't really enough.
We're in agreement! YAY!
Actually this is simpler than that. I'm taking SD out of the picture. It has served it's purpose of proving that we need to seriously address all the scheduling issues and did more than a half decent job at it. Unfortunately I also cannot sit around supporting it forever by myself. My own life is more important, so consider SD not even running the race any more.
I'm off to continue maintaining permanent-out-of-tree leisurely code at my own pace. What's more is, I think I'll just stick to staircase Gen I version blah and shelve SD and try to have fond memories of SD as an intellectual prompting exercise only.
Signature · 1 line
-ck
Quoted 15 lines · Con Kolivas
Quoted 5 lines · Nick Piggin
So, on to something productive, we have 3 candidates for a new scheduler so far. How do we decide which way to go? (and yes, I still think switchable schedulers is wrong and a copout) This is one area where it is virtually impossible to discount any decent design on correctness/performance/etc. and even testing in -mm isn't really enough.
We're in agreement! YAY!
Actually this is simpler than that. I'm taking SD out of the picture. It has served it's purpose of proving that we need to seriously address all the scheduling issues and did more than a half decent job at it. Unfortunately I also cannot sit around supporting it forever by myself. My own life is more important, so consider SD not even running the race any more.
Quoted 4 lines
I'm off to continue maintaining permanent-out-of-tree leisurely code at my own pace. What's more is, I think I'll just stick to staircase Gen I version blah and shelve SD and try to have fond memories of SD as an intellectual prompting exercise only.
Well I would hope that _if_ we decide to switch schedulers, then you get a chance to field something (and I hope you will decide to and have time to), and I hope we don't rush into the decision.
We've had the current scheduler for so many years now that it is much more important to make sure we take the time to do the right thing rather than absolutely have to merge a new scheduler right now ;)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 13 lines · Matthew Hawkins
Quoted 5 lines · Nick Piggin
So, on to something productive, we have 3 candidates for a new scheduler so
far. How do we decide which way to go? (and yes, I still think switchable schedulers is wrong and a copout)I'm with you on that one. It sounds good as a concept however there's various kernel structures etc that simply cannot be altered at runtime, which throws away the only advantage I can see of plugsched - a test/debug framework.
Quoted 11 lines
I think the best way is for those working on this stuff to keep producing their separate patches against mainline and people being encouraged to test. THEN
(and here comes the fun part) subsystem maintainers have to be prepared to accept code that is not their own or that of their IRC buddies. I'm noticing this disturbing trend that Linux kernel development is becoming more and more like BSD where only the elite few ever get anywhere. Con Kolivas, having a medical not CS degree, bruises the egos of those with CS degrees when he comes up with fairly clean, working, and widely-tested implementations of things like the staircase scheduler, R(SD)L,SCHED_ISO, swap prefetch, etc. when they can't. We should be encouraging guys like
The thing is, it is really hard for anybody to change anything in page reclaim or CPU scheduler. A few people saying a change is good for them doesn't really mean anything because of the huge amount of diversity in usages.
I've got my own CPU scheduler for 4 years and I and a few others think it is better than mainline. I've tried to make many many VM changes that haven't gone in.
Add to that, I don't actually know or care what sort of education most kernel hackers have. I do know at least one of the more brilliant ones does not have a CS degree, and I was able to get quite a few things in before I had a degree (eg. rewrote IO scheduler and multiprocessor CPU scheduler).
Quoted 1 line
It's all about the patches, baby
I don't know what would give anyone the idea that it isn't... patches and numbers.
Nick
Quoted 8 lines · Willy Tarreau
Now I hope he and Bill will get over this and accept to work on improving this scheduler, because I really find it smarter than a dumb O(1). I even agree with Mike that we now have a solid basis for future work. But for this, maybe a good starting point would be to remove the selfish printk at boot, revert useless changes (
SCHED_NORMAL->SCHED_FAIRcome to mind) and improve the documentation a bit so that people can work together on the new design, without feeling like their work will only server to promote X or Y.
While I appreciate people coming to my defense, or at least the good intentions behind such, my only actual interest in pointing out 4-year-old work is getting some acknowledgment of having done something relevant at all. Sometimes it has "I told you so" value. At other times it's merely clarifying what went on when people refer to it since in a number of cases the patches are no longer extant, so they can't actually look at it to get an idea of what was or wasn't done. At other times I'm miffed about not being credited, whether I should've been or whether dead and buried code has an implementation of the same idea resurfacing without the author(s) having any knowledge of my prior work.
One should note that in this case, the first work of mine this trips over (scheduling classes) was never publicly posted as it was only a part of the original plugsched (an alternate scheduler implementation devised to demonstrate plugsched's flexibility with respect to scheduling policies), and a part that was dropped by subsequent maintainers. The second work of mine this trips over, a virtual deadline scheduler named "vdls," was also never publicly posted. Both are from around the same time period, which makes them approximately 4 years dead. Neither of the codebases are extant, having been lost in a transition between employers, though various people recall having been sent them privately, and plugsched survives in a mutated form as maintained by Peter Williams, who's been very good about acknowledging my original contribution.
If I care to become a direct participant in scheduler work, I can do so easily enough.
I'm not entirely sure what this is about a basis for future work. By and large one should alter the API's and data structures to fit the policy being implemented. While the array swapping was nice for algorithmically improving 2.4.x -style epoch expiry, most algorithms not based on the 2.4.x scheduler (in however mutated a form) should use a different queue structure, in fact, one designed around their policy's specific algorithmic needs. IOW, when one alters the scheduler, one should also alter the queue data structure appropriately. I'd not expect the priority queue implementation in cfs to continue to be used unaltered as it matures, nor would I expect any significant modification of the scheduler to necessarily use a similar one.
By and large I've been mystified as to why there is such a penchant for preserving the existing queue structures in the various scheduler patches floating around. I am now every bit as mystified at the point of view that seems to be emerging that a change of queue structure is particularly significant. These are all largely internal changes to sched.c, and as such, rather small changes in and of themselves. While they do tend to have user-visible effects, from this point of view even changing out every line of sched.c is effectively a micropatch.
Something more significant might be altering the schedule() API to take a mandatory description of the intention of the call to it, or breaking up schedule() into several different functions to distinguish between different sorts of uses of it to which one would then respond differently. Also more significant would be adding a new state beyond TASK_INTERRUPTIBLE, TASK_UNINTERRUPTIBLE, and TASK_RUNNING for some tasks to respond only to fatal signals, then sweeping TASK_UNINTERRUPTIBLE users to use the new state and handle those fatal signals. While not quite as ostentatious in their user-visible effects as SCHED_OTHER policy affairs, they are tremendously more work than switching out the implementation of a single C file, and so somewhat more respectable.
Even as scheduling semantics go, these are micropatches. So SCHED_OTHER changes a little. Where are the gang schedulers? Where are the batch schedulers (SCHED_BATCH is not truly such)? Where are the isochronous (frame) schedulers? I suppose there is some CKRM work that actually has a semantic impact despite being largely devoted to SCHED_OTHER, and there's some spufs gang scheduling going on, though not all that much. And to reiterate a point from other threads, even as SCHED_OTHER patches go, I see precious little verification that things like the semantics of nice numbers or other sorts of CPU bandwidth allocation between competing tasks of various natures are staying the same while other things are changed, or at least being consciously modified in such a fashion as to improve them. I've literally only seen one or two tests (and rather inflexible ones with respect to sleep and running time mixtures) with any sort of quantification of how CPU bandwidth is distributed get run on all this.
So from my point of view, there's a lot of churn and craziness going on in one tiny corner of the kernel and people don't seem to have a very solid grip on what effects their changes have or how they might potentially break userspace. So I've developed a sudden interest in regression testing of the scheduler in order to ensure that various sorts of semantics on which userspace relies are not broken, and am trying to spark more interest in general in nailing down scheduling semantics and verifying that those semantics are honored and remain honored by whatever future scheduler implementations might be merged.
Thus far, the laundry list of semantics I'd like to have nailed down are specifically:
(1) CPU bandwidth allocation according to nice numbers
(2) CPU bandwidth allocation among mixtures of tasks with varying sleep/wakeup behavior e.g. that consume some percentage of cpu in isolation, perhaps also varying the granularity of their sleep/wakeup patterns
(3) sched_yield(), so multitier userspace locking doesn't go haywire
(4) How these work with SMP; most people agree it should be mostly the same as it works on UP, but it's not being verified, as most testcases are barely SMP-aware if at all, and corner cases where proportionality breaks down aren't considered
The sorts of like explicit decisions I'd like to be made for these are:
(1) In a mixture of tasks with varying nice numbers, a given nice number corresponds to some share of CPU bandwidth. Implementations should not have the freedom to change this arbitrarily according to some intention.
(2) A given scheduler _implementation_ intends to distribute CPU bandwidth among mixtures of tasks that would each consume some percentage of the CPU in isolation varying across tasks in some particular pattern. For example, maybe some scheduler implementation assigns a share of 1/%cpu to a task that would consume %cpu in isolation, for a CPU bandwidth allocation of (1/%cpu)/(sum 1/%cpu(t)) as t ranges over all competing tasks (this is not to say that such a policy makes sense).
(3) sched_yield() is intended to result in some particular scheduling pattern in a given scheduler implementation. For instance, an implementation may intend that a set of CPU hogs calling sched_yield() between repeatedly printf()'ing their pid's will see their printf()'s come out in an approximately consistent order as the scheduler cycles between them.
(4) What an implementation intends to do with respect to SMP CPU bandwidth allocation when precise emulation of UP behavior is impossible, considering sched_yield() scheduling patterns when possible as well. For instance, perhaps an implementation intends to ensure equal CPU bandwidth among competing CPU-bound tasks of equal priority at all costs, and so triggers migration and/or load balancing to make it so. Or perhaps an implementation intends to ensure precise sched_yield() ordering at all costs even on SMP. Some sort of specification of the intention, then a verification that the intention is carried out in a testcase.
Also, if there's a semantic issue to be resolved, I want it to have something describing it and verifying it. For instance, characterizing whatever sort of scheduling artifacts queue-swapping causes in the mainline scheduler and then a testcase to demonstrate the artifact and its resolution in a given scheduler rewrite would be a good design statement and verification. For instance, if someone wants to go back to queue-swapping or other epoch expiry semantics, it would make them (and hopefully everyone else) conscious of the semantic issue the change raises, or possibly serve as a demonstration that the artifacts can be mitigated in some implementation retaining epoch expiry semantics.
As I become aware of more potential issues I'll add more to my laundry list, and I'll hammer out testcases as I go. My concern with the scheduler is that this sort of basic functionality may be significantly disturbed with no one noticing at all until a distro issues a prerelease and benchmarks go haywire, and furthermore that changes to this kind of basic behavior may be signs of things going awry, particularly as more churn happens.
So now that I've clarified my role in all this to date and my point of view on it, it should be clear that accepting something and working on some particular scheduler implementation don't make sense as suggestions to me.
-- wli
Quoted 5 lines · William Lee Irwin III
The sorts of like explicit decisions I'd like to be made for these are:
(1) In a mixture of tasks with varying nice numbers, a given nice number corresponds to some share of CPU bandwidth. Implementations should not have the freedom to change this arbitrarily according to some intention.
The first question that comes to my mind is whether nice levels should be linear or not. I would lean towards nonlinear as it allows a wider range (although of course at the expense of precision). Maybe something like "each nice level gives X times the cpu of the previous"? I think a value of X somewhere between 1.15 and 1.25 might be reasonable.
What about also having something that looks at latency, and how latency changes with niceness?
What about specifying the timeframe over which the cpu bandwidth is measured? I currently have a system where the application designers would like it to be totally fair over a period of 1 second. As you can imagine, mainline doesn't do very well in this case.
Chris
Quoted 5 lines · William Lee Irwin III
Quoted 5 lines
The sorts of like explicit decisions I'd like to be made for these are:
(1) In a mixture of tasks with varying nice numbers, a given nice number corresponds to some share of CPU bandwidth. Implementations should not have the freedom to change this arbitrarily according to some intention.
Quoted 11 lines · Chris Friesen
The first question that comes to my mind is whether nice levels should be linear or not. I would lean towards nonlinear as it allows a wider range (although of course at the expense of precision). Maybe something like "each nice level gives X times the cpu of the previous"? I think a value of X somewhere between 1.15 and 1.25 might be reasonable. What about also having something that looks at latency, and how latency changes with niceness?
What about specifying the timeframe over which the cpu bandwidth is measured? I currently have a system where the application designers would like it to be totally fair over a period of 1 second. As you can imagine, mainline doesn't do very well in this case.
It's unclear how latency enters the picture as the semantics of nice levels relevant to such are essentially priority preemption, which is not particularly easy to mess up. I suppose tests to ensure priority preemption occurs properly are in order.
I don't really have a preference regarding specific semantics for nice numbers, just that they should be deterministic and specified somewhere. It's not really for us to decide what those semantics are as it's more of a userspace ABI/API issue.
The timeframe is also relevant, but I suspect it's more of a performance metric than a strict requirement.
-- wli
Quoted 9 lines · Chris Friesen
Quoted 5 lines · William Lee Irwin III
The sorts of like explicit decisions I'd like to be made for these are:
(1) In a mixture of tasks with varying nice numbers, a given nice number corresponds to some share of CPU bandwidth. Implementations should not have the freedom to change this arbitrarily according to some intention.The first question that comes to my mind is whether nice levels should be linear or not.
No. That squishes one end of the table too much. It needs to be (approximately) piecewise linear around nice == 0. Here's the mapping I use in my entitlement based schedulers:
#define NICE_TO_LP(nice) ((nice >=0) ? (20 - (nice)) : (20 + (nice) * (nice)))
It has the (good) feature that a nice == 19 task has 1/20th the entitlement of a nice == 0 task and a nice == -20 task has 21 times the entitlement of a nice == 0 task. It's not strictly linear for negative nice values but is very cheap to calculate and quite easy to invert if necessary.
Quoted 6 lines
I would lean towards nonlinear as it allows a wider
range (although of course at the expense of precision). Maybe something like "each nice level gives X times the cpu of the previous"? I think a value of X somewhere between 1.15 and 1.25 might be reasonable.What about also having something that looks at latency, and how latency changes with niceness?
What about specifying the timeframe over which the cpu bandwidth is measured? I currently have a system where the application designers would like it to be totally fair over a period of 1 second.
Have you tried the spa_ebs scheduler? The half life is no longer a run time configurable parameter (as making it highly adjustable results in less efficient code) but it could be adjusted to be approximately equivalent to 0.5 seconds by changing some constants in the code.
Quoted 2 lines
As you can
imagine, mainline doesn't do very well in this case.
You should look back through the plugsched patches where many of these ideas have been experimented with.
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
Quoted 9 lines · Chris Friesen
Quoted 5 lines · William Lee Irwin III
The sorts of like explicit decisions I'd like to be made for these are:
(1) In a mixture of tasks with varying nice numbers, a given nice number corresponds to some share of CPU bandwidth. Implementations should not have the freedom to change this arbitrarily according to some intention.The first question that comes to my mind is whether nice levels should be linear or not. I would lean towards nonlinear as it allows a wider range (although of course at the expense of precision). Maybe something like "each nice level gives X times the cpu of the previous"? I think a value of X somewhere between 1.15 and 1.25 might be reasonable.
Nonlinear is a must IMO. I would suggest X = exp(ln(10)/10) ~= 1.2589
That value has the property that a nice=10 task gets 1/10th the cpu of a nice=0 task, and a nice=20 task gets 1/100 of nice=0. I think that would be fairly easy to explain to admins and users so that they can know what to expect from nicing tasks.
Quoted 1 line
What about also having something that looks at latency, and how latency changes with niceness?
I think this would be a lot harder to pin down, since it's a function of all the other tasks running and their nice levels. Do you have any of the RT-derived analysis models in mind?
Quoted 1 line
What about specifying the timeframe over which the cpu bandwidth is measured? I currently have a system where the application designers would like it to be totally fair over a period of 1 second. As you can imagine, mainline doesn't do very well in this case.
It might be easier to specify the maximum deviation from the ideal bandwidth over a certain period. I.e. something like "over a period of one second, each task receives within 10% of the expected bandwidth".
- Jim Bruce
Quoted 5 lines · James Bruce
Nonlinear is a must IMO. I would suggest X = exp(ln(10)/10) ~= 1.2589 That value has the property that a nice=10 task gets 1/10th the cpu of a nice=0 task, and a nice=20 task gets 1/100 of nice=0. I think that would be fairly easy to explain to admins and users so that they can know what to expect from nicing tasks.
[...additional good commentary trimmed...]
Lots of good ideas here. I'll follow them.
-- wli
Quoted 2 lines · Willy Tarreau
Ingo could have publicly spoken with them about his ideas of killing the O(1) scheduler and replacing it with an rbtree-based one, [...]
yes, that's precisely what i did, via a patchset :)
[ I can even tell you when it all started: i was thinking about Mike's
throttling patches while watching Manchester United beat the crap out of AS Roma (7 to 1 end result), Thuesday evening. I started coding it Wednesday morning and sent the patch Friday evening. I very much believe in low-latency when it comes to development too ;) ]
(if this had been done via a comittee then today we'd probably still be trying to find a suitable timeslot for the initial conference call where we'd discuss the election of a chair who would be tasked with writing up an initial document of feature requests, on which we'd take a vote, possibly this year already, because the matter is really urgent you know ;-)
Quoted 1 line
[...] and using part of Bill's work to speed up development.
ok, let me make this absolutely clear: i didnt use any bit of plugsched
- in fact the most difficult bits of the modularization was for areas of sched.c that plugsched never even touched AFAIK. (the load-balancer for example.)
Plugsched simply does something else: i modularized scheduling policies in essence that have to cooperate with each other, while plugsched modularized complete schedulers which are compile-time or boot-time selected, with no runtime cooperation between them. (one has to be selected at a time)
(and i have no trouble at all with crediting Will's work either: a few years ago i used Will's PID rework concepts for an NPTL related speedup and Will is very much credited for it in today's kernel/pid.c and he continued to contribute to it later on.)
(the tree walking bits of sched_fair.c were in fact derived from kernel/hrtimer.c, the rbtree code written by Thomas and me :-)
Ingo
Quoted 1 line · Willy Tarreau
Quoted 1 line
[...] and using part of Bill's work to speed up development.
Quoted 7 lines · Ingo Molnar
ok, let me make this absolutely clear: i didnt use any bit of plugsched
- in fact the most difficult bits of the modularization was for areas ofsched.cthat plugsched never even touched AFAIK. (the load-balancer for example.)
Plugsched simply does something else: i modularized scheduling policies in essence that have to cooperate with each other, while plugsched modularized complete schedulers which are compile-time or boot-time
Quoted 8 lines
selected, with no runtime cooperation between them. (one has to be selected at a time)
(and i have no trouble at all with crediting Will's work either: a few years ago i used Will's PID rework concepts for an NPTL related speedup and Will is very much credited for it in today'skernel/pid.cand he continued to contribute to it later on.)
(the tree walking bits ofsched_fair.cwere in fact derived fromkernel/hrtimer.c, the rbtree code written by Thomas and me :-)
The extant plugsched patches have nothing to do with cfs; I suspect what everyone else is going on about is terminological confusion. The 4-year-old sample policy with scheduling classes for the original plugsched is something you had no way of knowing about, as it was never publicly posted. There isn't really anything all that interesting going on here, apart from pointing out that it's been done before.
-- wli
Quoted 12 lines · Ingo Molnar
Quoted 1 line · Willy Tarreau
Ingo could have publicly spoken with them about his ideas of killing the O(1) scheduler and replacing it with an rbtree-based one, [...]
yes, that's precisely what i did, via a patchset :)
[ I can even tell you when it all started: i was thinking about Mike's
throttling patches while watching Manchester United beat the crap out of AS Roma (7 to 1 end result), Thuesday evening. I started coding it Wednesday morning and sent the patch Friday evening. I very much believe in low-latency when it comes to development too ;) ]
Quoted 7 lines
(if this had been done via a comittee then today we'd probably still be trying to find a suitable timeslot for the initial conference call where we'd discuss the election of a chair who would be tasked with writing up an initial document of feature requests, on which we'd take a vote, possibly this year already, because the matter is really urgent you know ;-)
Quoted 1 line
[...] and using part of Bill's work to speed up development.
ok, let me make this absolutely clear: i didnt use any bit of plugsched
- in fact the most difficult bits of the modularization was for areas ofsched.cthat plugsched never even touched AFAIK. (the load-balancer for example.)
This sounds like your new scheduler intends to increase the coupling between scheduling and load balancing. I think that this would be a mistake and lead (down the track) to spiralling complexity as you make changes to the code to address the corner conditions that it will create.
Quoted 2 lines
Plugsched simply does something else: i modularized scheduling policies in essence that have to cooperate with each other, while plugsched modularized complete schedulers which are compile-time or boot-time selected, with no runtime cooperation between them. (one has to be selected at a time)
You can't really have more than one scheduler operating in the same priority range on the same CPU as they will be fighting each other trying to achieve their separate and not necessarily compatible (in fact highly likely to be incompatible) aims. Multiple schedulers on the same CPU have to have a pecking order just like SCHED_OTHER and real time policies. It wouldn't be hard to prove that SCHED_RR and SCHED_FIFO is a problem in waiting if ever someone tried to use them both on a highly real time system.
Quoted 6 lines
(and i have no trouble at all with crediting Will's work either: a few years ago i used Will's PID rework concepts for an NPTL related speedup and Will is very much credited for it in today's
kernel/pid.cand he continued to contribute to it later on.)(the tree walking bits of
sched_fair.cwere in fact derived fromkernel/hrtimer.c, the rbtree code written by Thomas and me :-)Ingo
Are your new patches available somewhere for easy download or do I have to try to dig them out of the mailing list archive? Or could you mail them to me separately? I'm keen to see how you new scheduler proposal works.
Thanks
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
Quoted 2 lines · Peter Williams
Are your new patches available somewhere for easy download or do I have to try to dig them out of the mailing list archive? Or could you mail them to me separately? I'm keen to see how you new scheduler proposal works.
Forget about this. I found the patch.
After a quick look, I like a lot of what I see especially the removal of the dual arrays in the run queue.
Some minor suggestions:
1. having defined DEFAULT_PRIO in sched.h shouldn't you use it to initialize the task structure in init_task.h.
2. the on_rq field in the task structure is unnecessary as many years of experience with ingosched in plugsched indicates that !list_empty(&(p)->run_list does the job provided list_del_init() is used when dequeueing and there is no noticeable overhead incurred so there's no gain by caching the result. Also it removes the possibility of errors creeping in due the value of on_rq being inconsistent with the task's actual state.
3. having modular load balancing is a good idea but it should be decoupled form the scheduler and provided as a separate interface. This would enable different schedulers to use the same load balancer if they desired.
4. why rename SCHED_OTHER to SCHED_FAIR? SCHED_OTHER's supposed to be fair(ish) anyway.
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
Quoted 6 lines · Peter Williams
Quoted 2 lines · Peter Williams
Are your new patches available somewhere for easy download or do I have to try to dig them out of the mailing list archive? Or could you mail them to me separately? I'm keen to see how you new scheduler proposal works.
Forget about this. I found the patch.
Quoted 8 lines
After a quick look, I like a lot of what I see especially the removal of the dual arrays in the run queue.
Some minor suggestions:
1. having defined
DEFAULT_PRIOinsched.hshouldn't you use it to initialize the task structure ininit_task.h.
2. theon_rqfield in the task structure is unnecessary as many years of experience with ingosched in plugsched indicates that !list_empty(&(p)->run_list does the job providedlist_del_init()is used when dequeueing and there is no noticeable overhead incurred so there's no gain by caching the result. Also it removes the possibility of errors creeping in due the value ofon_rqbeing inconsistent with the task's actual state.
3. having modular load balancing is a good idea but it should be decoupled form the scheduler and provided as a separate interface. This would enable different schedulers to use the same load balancer if they desired.
4. why renameSCHED_OTHERtoSCHED_FAIR? SCHED_OTHER's supposed to be fair(ish) anyway.
One more quick comment. The claim that there is no concept of time slice in the new scheduler is only true in the sense of the rather arcane implementation of time slices extant in the O(1) scheduler. Your new parameter sched_granularity_ns is equivalent to the concept of time slice in most other kernels that I've peeked inside and computing literature in general (going back over several decades e.g. the magic garden).
Welcome to the mainstream,
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
Quoted 3 lines · Peter Williams
One more quick comment. The claim that there is no concept of time slice in the new scheduler is only true in the sense of the rather arcane implementation of time slices extant in the O(1) scheduler.
yeah. AFAIK most other mainstream OSs also still often use similarly 'arcane' concepts (i'm here ignoring literature, you can find everything and its opposite suggested in literature) so i felt the need to point out the difference ;) After all Linux is about doing a better mainstream OS, it is not about beating the OS literature at lunacy ;-)
The precise statement would be: "there's no concept of giving out a time-slice to a task and sticking to it unless a higher-prio task comes along, nor is there a concept of having a low-res granularity ->time_slice thing. There is accurate accounting of how much CPU time a task used up, and there is a granularity setting that together gives the current task a fairness advantage of a given amount of nanoseconds - which has similar [but not equivalent] effects to traditional timeslices that most mainstream OSs use".
Quoted 4 lines
Your new parameter
sched_granularity_nsis equivalent to the concept of time slice in most other kernels that I've peeked inside and computing literature in general (going back over several decades e.g. the magic garden).
note that you can set it to 0 and the box still functions - so sched_granularity_ns, while useful for performance/bandwidth workloads, isnt truly inherent to the design.
So in the announcement i just opted for a short sentence: "there's no concept of timeslices", albeit like most short stentences it's not a technically 100% accurate statement - but still it conveyed the intended information more effectively to the interested lkml reader than the longer version could ever have =B-)
Ingo
Quoted 7 lines · Ingo Molnar
Quoted 1 line · Peter Williams
One more quick comment. The claim that there is no concept of time slice in the new scheduler is only true in the sense of the rather arcane implementation of time slices extant in the O(1) scheduler.
yeah. AFAIK most other mainstream OSs also still often use similarly 'arcane' concepts (i'm here ignoring literature, you can find everything and its opposite suggested in literature) so i felt the need to point out the difference ;) After all Linux is about doing a better mainstream OS, it is not about beating the OS literature at lunacy ;-)
The precise statement would be: "there's no concept of giving out a time-slice to a task and sticking to it unless a higher-prio task comes along,
I would have said "no concept of using tile slices to implement nice" which always seemed strange to me.
If it really does what you just said then a (malicious or otherwise) CPU intensive task that never sleeps, once it got the CPU, would completely hog the CPU.
Quoted 3 lines
nor is there a concept of having a low-res granularity
->time_slice thing. There is accurate accounting of how much CPU time a
task used up, and there is a granularity setting that together gives the current task a fairness advantage of a given amount of nanoseconds - which has similar [but not equivalent] effects to traditional timeslices that most mainstream OSs use".
Most traditional OSes have more or less fixed time slices and do the scheduling by fiddling the dynamic priority.
Using total CPU used will also come to grief when used for long running tasks. Eventually, even very low bandwidth tasks will accumulate enough total CPU to look busy. The CPU bandwidth the task is using is what needs to be controlled.
Or have I not looked closely enough at what sched_granularity_ns does? Is it really a control for the decay rate of a CPU usage bandwidth metric?
Quoted 4 lines
Quoted 2 lines
Your new parameter
sched_granularity_nsis equivalent to the concept of time slice in most other kernels that I've peeked inside and computing literature in general (going back over several decades e.g. the magic garden).note that you can set it to 0 and the box still functions - so
sched_granularity_ns, while useful for performance/bandwidth workloads, isnt truly inherent to the design.
Just like my SPA schedulers. But if you set it to zero you'll get a fairly high context switch rate with associated overhead, won't you?
Quoted 2 lines
So in the announcement i just opted for a short sentence: "there's no concept of timeslices", albeit like most short stentences it's not a technically 100% accurate statement - but still it conveyed the intended information more effectively to the interested lkml reader than the longer version could ever have =B-)
I hope that I implied that I was being picky :-) (I meant to -- imply I was being picky, that is).
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
Quoted 9 lines · Pekka Enberg
Quoted 3 lines · hui Bill Huey
The perception here is that there is that there is this expectation that sections of the Linux kernel are intentionally "churn squated" to prevent any other ideas from creeping in other than of the owner of that subsytem
Strangely enough, my perception is that Ingo is simply trying to address the issues Mike's testing discovered in RDSL and SD. It's not surprising Ingo made it a separate patch set as Con has repeatedly stated that the "problems" are in fact by design and won't be fixed.
I won't get into the middle of this just yet, not having decided which dog I should bet on yet. I've been running 2.6.21-rc6 + Con's 0.40 patch for about 24 hours, its been generally usable, but gzip still causes lots of 5 to 10+ second lags when its running. I'm coming to the conclusion that gzip simply doesn't play well with others...
Amazing to me, the cpu its using stays generally below 80%, and often below 60%, even while the kmail composer has a full sentence in its buffer that it still hasn't shown me when I switch to the htop screen to check, and back to the kmail screen to see if its updated yet. The screen switch doesn't seem to lag so I don't think renicing x would be helpfull. Those are the obvious lags, and I'll build & reboot to the CFS patch at some point this morning (whats left of it that is :). And report in due time of course
Signature · 5 lines
Cheers, Gene "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) knot in cables caused data stream to become twisted and kinked
Quoted 12 lines · Gene Heskett
Quoted 10 lines · Pekka Enberg
Quoted 4 lines · hui Bill Huey
The perception here is that there is that there is this expectation that sections of the Linux kernel are intentionally "churn squated" to prevent any other ideas from creeping in other than of the owner of that subsytem
Strangely enough, my perception is that Ingo is simply trying to address the issues Mike's testing discovered in RDSL and SD. It's not surprising Ingo made it a separate patch set as Con has repeatedly stated that the "problems" are in fact by design and won't be fixed.
Quoted 5 lines
I won't get into the middle of this just yet, not having decided which dog I should bet on yet. I've been running 2.6.21-rc6 + Con's 0.40 patch for about 24 hours, its been generally usable, but gzip still causes lots of 5 to 10+ second lags when its running. I'm coming to the conclusion that gzip simply doesn't play well with others...
Actually Gene I think you're being bitten here by something I/O bound since the cpu usage never tops out. If that's the case and gzip is dumping truckloads of writes then you're suffering something that irks me even more than the scheduler in linux, and that's how much writes hurt just about everything else. Try your testcase with bzip2 instead (since that won't be i/o bound), or drop your dirty ratio to as low as possible which helps a little bit (5% is the minimum)
echo 5 > /proc/sys/vm/dirty_ratio
and finally try the braindead noop i/o scheduler as well.
echo noop > /sys/block/sda/queue/scheduler
(replace sda with your drive obviously).
I'd wager a big one that's what causes your gzip pain. If it wasn't for the fact that I've decided to all but give up ever trying to provide code for mainline again, trying my best to make writes hurt less on linux would be my next big thing [tm].
Oh and for the others watching, (points to vm hackers) I found a bug when playing with the dirty ratio code. If you modify it to allow it drop below 5% but still above the minimum in the vm code, stalls happen somewhere in the vm where nothing much happens for sometimes 20 or 30 seconds worst case scenario. I had to drop a patch in 2.6.19 that allowed the dirty ratio to be set ultra low because these stalls were gross.
Quoted 8 lines
Amazing to me, the cpu its using stays generally below 80%, and often below 60%, even while the kmail composer has a full sentence in its buffer that it still hasn't shown me when I switch to the htop screen to check, and back to the kmail screen to see if its updated yet. The screen switch doesn't seem to lag so I don't think renicing x would be helpfull. Those are the obvious lags, and I'll build & reboot to the CFS patch at some point this morning (whats left of it that is :). And report in due time of course
Signature · 1 line
-ck
Quoted 31 lines · Con Kolivas
Quoted 12 lines · Gene Heskett
Quoted 10 lines · Pekka Enberg
Quoted 4 lines · hui Bill Huey
The perception here is that there is that there is this expectation that sections of the Linux kernel are intentionally "churn squated" to prevent any other ideas from creeping in other than of the owner of that subsytem
Strangely enough, my perception is that Ingo is simply trying to address the issues Mike's testing discovered in RDSL and SD. It's not surprising Ingo made it a separate patch set as Con has repeatedly stated that the "problems" are in fact by design and won't be fixed.
Quoted 5 lines
I won't get into the middle of this just yet, not having decided which dog I should bet on yet. I've been running 2.6.21-rc6 + Con's 0.40 patch for about 24 hours, its been generally usable, but gzip still causes lots of 5 to 10+ second lags when its running. I'm coming to the conclusion that gzip simply doesn't play well with others...
Actually Gene I think you're being bitten here by something I/O bound since the cpu usage never tops out. If that's the case and gzip is dumping truckloads of writes then you're suffering something that irks me even more than the scheduler in linux, and that's how much writes hurt just about everything else. Try your testcase with bzip2 instead (since that won't be i/o bound), or drop your dirty ratio to as low as possible which helps a little bit (5% is the minimum)
echo 5 >
/proc/sys/vm/dirty_ratioand finally try the braindead noop i/o scheduler as well.
Quoted 8 lines
echo noop >
/sys/block/sda/queue/scheduler(replace sda with your drive obviously).
I'd wager a big one that's what causes your gzip pain. If it wasn't for the fact that I've decided to all but give up ever trying to provide code for mainline again, trying my best to make writes hurt less on linux would be my next big thing [tm].
Chuckle, possibly but then I'm not anything even remotely close to an expert here Con, just reporting what I get. And I just rebooted to 2.6.21-rc6 + sched-mike-5.patch for grins and giggles, or frowns and profanity as the case may call for.
Quoted 6 lines
Oh and for the others watching, (points to vm hackers) I found a bug when playing with the dirty ratio code. If you modify it to allow it drop below 5% but still above the minimum in the vm code, stalls happen somewhere in the vm where nothing much happens for sometimes 20 or 30 seconds worst case scenario. I had to drop a patch in 2.6.19 that allowed the dirty ratio to be set ultra low because these stalls were gross.
I think I'd need a bit of tutoring on how to do that. I recall that one other time, several weeks back, I thought I would try one of those famous echo this
Quoted 1 line
/proc/thatideas that went by on this list, but even though I was root,
apparently /proc was read-only AFAIWC.
Quoted 8 lines
Quoted 8 lines
Amazing to me, the cpu its using stays generally below 80%, and often below 60%, even while the kmail composer has a full sentence in its buffer that it still hasn't shown me when I switch to the htop screen to check, and back to the kmail screen to see if its updated yet. The screen switch doesn't seem to lag so I don't think renicing x would be helpfull. Those are the obvious lags, and I'll build & reboot to the CFS patch at some point this morning (whats left of it that is :). And report in due time of course
And now I wonder if I applied the right patch. This one feels good ATM, but I don't think its the CFS thingy. No, I'm sure of it now, none of the patches I've saved say a thing about CFS. Backtrack up the list time I guess, ignore me for the nonce.
Signature · 7 lines
Cheers, Gene "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Microsoft: Re-inventing square wheels -- From a Slashdot.org post
Quoted 4 lines · Gene Heskett
Chuckle, possibly but then I'm not anything even remotely close to an expert here Con, just reporting what I get. And I just rebooted to 2.6.21-rc6 + sched-mike-5.patch for grins and giggles, or frowns and profanity as the case may call for.
Erm, that patch is embarrassingly buggy, so profanity should dominate.
-Mike
Quoted 9 lines · Mike Galbraith
Quoted 4 lines · Gene Heskett
Chuckle, possibly but then I'm not anything even remotely close to an expert here Con, just reporting what I get. And I just rebooted to 2.6.21-rc6 + sched-mike-5.patch for grins and giggles, or frowns and profanity as the case may call for.
Erm, that patch is embarrassingly buggy, so profanity should dominate.
-Mike
Chuckle, ROTFLMAO even.
I didn't run it that long as I immediately rebuilt and rebooted when I found I'd used the wrong patch, and in fact had tested that one and found it sub-optimal before I'd built and ran Con's -0.40 version. As for bugs of the type that make it to the screen or logs, I didn't see any. OTOH, my eyesight is slowly going downhill, now 20/25. It was 20/10 30 years ago. Now thats reason for profanity...
Signature · 6 lines
Cheers, Gene
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Unix weanies are as bad at this as anyone.
-- Larry Wall in <[email protected]>Quoted 2 lines · In article <[email protected]> you wrote:
A development process like this is likely to exclude smart people from wanting to contribute to Linux and folks should be conscious about this issues.
Nobody is excluded, you can always have a next iteration.
Gruss
Bernd
Quoted 9 lines · Con Kolivas
Quoted 8 lines · Ingo Molnar
[announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS]
i'm pleased to announce the first release of the "Modular Scheduler Core and Completely Fair Scheduler [CFS]" patchset:
http://redhat.com/~mingo/cfs-scheduler/sched-modular+cfs.patch
Quoted 7 lines
Quoted 4 lines
This project is a complete rewrite of the Linux task scheduler. My goal is to address various feature requests and to fix deficiencies in the vanilla scheduler that were suggested/found in the past few years, both for desktop scheduling and for server scheduling workloads.
The casual observer will be completely confused by what on earth has happened here so let me try to demystify things for them.
[...]
Demystify what? The casual observer need only read either your attempt
at writing a scheduler, or my attempts at fixing the one we have, to see that it was high time for someone with the necessary skills to step in. Now progress can happen, which was _not_ happening before.
-Mike
Quoted 3 lines · Mike Galbraith
[...]
Demystify what? The casual observer need only read either your attempt
Here's the problem. You're a casual observer and obviously not paying attention.
Quoted 3 lines
at writing a scheduler, or my attempts at fixing the one we have, to see that it was high time for someone with the necessary skills to step in. Now progress can happen, which was _not_ happening before.
I think that's inaccurate and there are plenty of folks that have that technical skill and background. The scheduler code isn't a deep mystery and there are plenty of good kernel hackers out here across many communities. Ingo isn't the only person on this planet to have deep scheduler knowledge. Priority heaps are not new and Solaris has had a pluggable scheduler framework for years.
Con's characterization is something that I'm more prone to believe about how Linux kernel development works versus your view. I think it's a great shame to have folks like Bill Irwin and Con to have waste time trying to do something right only to have their ideas attack, then copied and held as the solution for this kind of technical problem as complete reversal of technical opinion as it suits a moment. This is just wrong in so many ways.
It outlines the problems with Linux kernel development and questionable elistism regarding ownership of certain sections of the kernel code.
I call it "churn squat" and instances like this only support that view which I would rather it be completely wrong and inaccurate instead.
bill
Quoted 12 lines · Bill Huey
Quoted 3 lines · Mike Galbraith
[...]
Demystify what? The casual observer need only read either your attempt
Here's the problem. You're a casual observer and obviously not paying attention.
Quoted 3 lines
at writing a scheduler, or my attempts at fixing the one we have, to see that it was high time for someone with the necessary skills to step in. Now progress can happen, which was _not_ happening before.
Quoted 5 lines
I think that's inaccurate and there are plenty of folks that have that technical skill and background. The scheduler code isn't a deep mystery and there are plenty of good kernel hackers out here across many communities. Ingo isn't the only person on this planet to have deep scheduler knowledge.
Ok <shrug>, I'm not paying attention, and you can't read. We're even. Have a nice life.
-Mike
Quoted 8 lines · Bill Huey
Quoted 4 lines · Mike Galbraith
[...]
Demystify what? The casual observer need only read either your attempt
Here's the problem. You're a casual observer and obviously not paying attention.
guys, please calm down. Judging by the number of contributions to sched.c the main folks who are not 'observers' here and who thus have an unalienable right to be involved in a nasty flamewar about scheduler interactivity are Con, Mike, Nick and me ;-) Everyone else is just a happy bystander, ok? ;-)
Ingo
Quoted 5 lines · Ingo Molnar
guys, please calm down. Judging by the number of contributions to
sched.cthe main folks who are not 'observers' here and who thus have an unalienable right to be involved in a nasty flamewar about scheduler interactivity are Con, Mike, Nick and me ;-) Everyone else is just a happy bystander, ok? ;-)
just to make sure: this is a short (and incomplete) list of contributors related to scheduler interactivity code. The full list of contributors to sched.c includes many other people as well: Peter, Suresh, Christoph, Kenneth and many others. Even the git logs, which only span 2 years out of 15, already list 79 individual contributors to kernel/sched.c.
Ingo
Quoted 3 lines
It outlines the problems with Linux kernel development and questionable elistism regarding ownership of certain sections of the kernel code.
I have to step in and disagree here....
Linux is not about who writes the code.
Linux is about getting the best solution for a problem. Who wrote which line of the code is irrelevant in the big picture.
that often means that multiple implementations happen, and that the a darwinistic process decides that the best solution wins.
This darwinistic process often happens in the form of discussion, and that discussion can happen with words or with code. In this case it happened with a code proposal.
To make this specific: it has happened many times to me that when I solved an issue with code, someone else stepped in and wrote a different solution (although that was usually for smaller pieces). Was I upset about that? No! I was happy because my *problem got solved* in the best possible way.
Now this doesn't mean that people shouldn't be nice to each other, not cooperate or steal credits, but I don't get the impression that that is happening here. Ingo is taking part in the discussion with a counter proposal for discussion *on the mailing list*. What more do you want?? If you or anyone else can improve it or do better, take part of this discussion and show what you mean either in words or in code.
Your qualification of the discussion as a elitist takeover... I disagree with that. It's a *discussion*. Now if you agree that Ingo's patch is better technically, you and others should be happy about that because your problem is getting solved better. If you don't agree that his patch is better technically, take part in the technical discussion.
Signature · 2 lines
if you want to mail me at work (you don't), use arjan (at) linux.intel.com Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org
Quoted 4 lines · Arjan van de Ven
Now this doesn't mean that people shouldn't be nice to each other, not cooperate or steal credits, but I don't get the impression that that is happening here. Ingo is taking part in the discussion with a counter proposal for discussion *on the mailing list*. What more do you want??
Con should have been CCed from the first moment this was put into motion to limit the perception of exclusion. That was mistake number one and big time failures to understand this dynamic. After it was Con's idea. Why the hell he was excluded from Ingo's development process is baffling to me and him (most likely).
He put int a lot of effort into SDL and his experiences with scheduling should still be seriously considered in this development process even if he doesn't write a single line of code from this moment on.
What should have happened is that our very busy associate at RH by the name of Ingo Molnar should have leverage more of Con's and Bill's work and use them as a proxy for his own ideas. They would have loved to have contributed more and our very busy Ingo Molnar would have gotten a lot of his work and ideas implemented without him even opening a single source file for editting. They would have happily done this work for Ingo. Ingo could have been used for something else more important like making KVM less of a freaking ugly hack and we all would have benefitted from this.
He could have been working on SystemTap so that you stop losing accounts to Sun and Solaris 10's Dtrace. He could have been working with Riel to fix your butt ugly page scanning problem causing horrible contention via the Clock/Pro algorithm, etc... He could have been fixing the ugly futex rwsem mapping problem that's killing -rt and anything that uses Posix threads. He could have created a userspace thread control block (TCB) with Mr. Drepper so that we can turn off preemption in userspace (userspace per CPU local storage) and implement a very quick non-kernel crossing implementation of priority ceilings (userspace check for priority and flags at preempt_schedule() in the TCB) so that our -rt Posix API doesn't suck donkey shit... Need I say more ?
As programmers like Ingo get spread more thinly, he needs super smart folks like Bill Irwin and Con to help him out and learn to resist NIH folk's stuff out of some weird fear. When this happens, folks like Ingo must learn to "facilitate" development in addition to implementing it with those kind of folks.
This takes time and practice to entrust folks to do things for him. Ingo is the best method of getting new Linux kernel ideas and communicate them to Linus. His value goes beyond just just code and is often the biggest hammer we have in the Linux community to get stuff into the kernel. "Facilitation" of others is something that solo programmers must need when groups like the Linux kernel get larger and large every year.
Understand ? Are we in embarrassing agreement here ?
bill
Quoted 11 lines · Bill Huey
Quoted 4 lines · Arjan van de Ven
Now this doesn't mean that people shouldn't be nice to each other, not cooperate or steal credits, but I don't get the impression that that is happening here. Ingo is taking part in the discussion with a counter proposal for discussion *on the mailing list*. What more do you want??
Con should have been CCed from the first moment this was put into motion to limit the perception of exclusion. That was mistake number one and big time failures to understand this dynamic. After it was Con's idea. Why the hell he was excluded from Ingo's development process is baffling to me and him (most likely).
Ingo's scheduler is completely different to any I've seen proposed for Linux. And after he did an initial implementation, he did post it to everyone.
Maybe something he said offended someone, but the process followed is exactly how Linux kernel development works (ie. if you think you can do better, then write the code). Sometimes you can give suggestions, but other times if you come up with a different idea then it is better just to do it yourself.
Con's code is still out there. If it is better than Ingo's then it should win out. Nobody has a monopoly on schedulers or ideas or posting patches.
Quoted 14 lines
He put int a lot of effort into SDL and his experiences with scheduling should still be seriously considered in this development process even if he doesn't write a single line of code from this moment on.
What should have happened is that our very busy associate at RH by the name of Ingo Molnar should have leverage more of Con's and Bill's work and use them as a proxy for his own ideas. They would have loved to have contributed more and our very busy Ingo Molnar would have gotten a lot of his work and ideas implemented without him even opening a single source file for editting. They would have happily done this work for Ingo. Ingo could have been used for something else more important like making KVM less of a freaking ugly hack and we all would have benefitted from this.
Quoted 11 lines
He could have been working on SystemTap so that you stop losing accounts to Sun and Solaris 10's Dtrace. He could have been working with Riel to fix your butt ugly page scanning problem causing horrible contention via the Clock/Pro algorithm, etc... He could have been fixing the ugly futex rwsem mapping problem that's killing -rt and anything that uses Posix threads. He could have created a userspace thread control block (TCB) with Mr. Drepper so that we can turn off preemption in userspace (userspace per CPU local storage) and implement a very quick non-kernel crossing implementation of priority ceilings (userspace check for priority and flags at
preempt_schedule()in the TCB) so that our -rt Posix API doesn't suck donkey shit... Need I say more ?
Well that's some pretty strong criticism of Linux and of someone who does a great deal to improve things... Let's stick to the topic of schedulers in this thread and try keeping it constructive.
Quoted 14 lines · Mike Galbraith
Quoted 13 lines · Con Kolivas
Quoted 12 lines · Ingo Molnar
[announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS]
i'm pleased to announce the first release of the "Modular Scheduler Core and Completely Fair Scheduler [CFS]" patchset:
http://redhat.com/~mingo/cfs-scheduler/sched-modular+cfs.patch
This project is a complete rewrite of the Linux task scheduler. My goal is to address various feature requests and to fix deficiencies in the vanilla scheduler that were suggested/found in the past few years, both for desktop scheduling and for server scheduling workloads.
Quoted 7 lines
Quoted 1 line
The casual observer will be completely confused by what on earth has happened here so let me try to demystify things for them.
[...]
Demystify what? The casual observer need only read either your attempt
at writing a scheduler, or my attempts at fixing the one we have, to see that it was high time for someone with the necessary skills to step in.
Make that "someone with the necessary clout".
Quoted 2 lines
Now progress can happen, which was _not_ happening before.
This is true.
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
Quoted 7 lines · Peter Williams
Quoted 4 lines · Mike Galbraith
Demystify what? The casual observer need only read either your attempt
at writing a scheduler, or my attempts at fixing the one we have, to see that it was high time for someone with the necessary skills to step in.Make that "someone with the necessary clout".
No, I was brutally honest to both of us, but quite correct.
Quoted 4 lines
Quoted 2 lines
Now progress can happen, which was _not_ happening before.
This is true.
Yup, and progress _is_ happening now, quite rapidly.
-Mike
Quoted 9 lines · Mike Galbraith
Quoted 7 lines · Peter Williams
Quoted 4 lines · Mike Galbraith
Demystify what? The casual observer need only read either your attempt
at writing a scheduler, or my attempts at fixing the one we have, to see that it was high time for someone with the necessary skills to step in.Make that "someone with the necessary clout".
Quoted 8 lines
No, I was brutally honest to both of us, but quite correct.
Quoted 4 lines
Quoted 2 lines
Now progress can happen, which was _not_ happening before.
This is true.
Yup, and progress _is_ happening now, quite rapidly.
Progress as in progress on Ingo's scheduler. I still don't know how we'd decide when to replace the mainline scheduler or with what.
I don't think we can say Ingo's is better than the alternatives, can we? If there is some kind of bakeoff, then I'd like one of Con's designs to be involved, and mine, and Peter's...
Maybe the progress is that more key people are becoming open to the idea of changing the scheduler.
Quoted 8 lines · Nick Piggin
Quoted 1 line · Mike Galbraith
Yup, and progress _is_ happening now, quite rapidly.
Progress as in progress on Ingo's scheduler. I still don't know how we'd decide when to replace the mainline scheduler or with what.
I don't think we can say Ingo's is better than the alternatives, can we?
No, that would require massive performance testing of all alternatives.
Quoted 2 lines
If there is some kind of bakeoff, then I'd like one of Con's designs to be involved, and mine, and Peter's...
The trouble with a bakeoff is that it's pretty darn hard to get people to test in the first place, and then comes weighting the subjective and hard performance numbers. If they're close in numbers, do you go with the one which starts the least flamewars or what?
Quoted 2 lines
Maybe the progress is that more key people are becoming open to the idea of changing the scheduler.
Could be. All was quiet for quite a while, but when RSDL showed up, it aroused enough interest to show that scheduling woes is on folks radar.
-Mike
Quoted 12 lines · Mike Galbraith
Quoted 8 lines · Nick Piggin
Quoted 1 line · Mike Galbraith
Yup, and progress _is_ happening now, quite rapidly.
Progress as in progress on Ingo's scheduler. I still don't know how we'd decide when to replace the mainline scheduler or with what.
I don't think we can say Ingo's is better than the alternatives, can we?
No, that would require massive performance testing of all alternatives.
Quoted 7 lines
Quoted 2 lines
If there is some kind of bakeoff, then I'd like one of Con's designs to be involved, and mine, and Peter's...
The trouble with a bakeoff is that it's pretty darn hard to get people to test in the first place, and then comes weighting the subjective and hard performance numbers. If they're close in numbers, do you go with the one which starts the least flamewars or what?
I don't know how you'd do it. I know you wouldn't count people telling you how good they are (getting people to tell you how bad they are, and whether others do better in a given situation might be slightly move viable).
But we have to choose somehow. I'd hope that is going to be based solely on the results and technical properties of the code, so... if we were to somehow determine that the results are exactly the same, we'd go for the the simpler one, wouldn't we?
Quoted 5 lines
Quoted 2 lines
Maybe the progress is that more key people are becoming open to the idea of changing the scheduler.
Could be. All was quiet for quite a while, but when RSDL showed up, it aroused enough interest to show that scheduling woes is on folks radar.
Well I know people have had woes with the scheduler for ever (I guess that isn't going to change :P). I think people generally lost a bit of interest in trying to improve the situation because of the upstream problem.
Quoted 3 lines · Nick Piggin
Well I know people have had woes with the scheduler for ever (I guess that isn't going to change :P). I think people generally lost a bit of interest in trying to improve the situation because of the upstream problem.
Yes.
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
Quoted 9 lines · Nick Piggin
Quoted 6 lines
Quoted 2 lines
Maybe the progress is that more key people are becoming open to the idea of changing the scheduler.
Could be. All was quiet for quite a while, but when RSDL showed up, it aroused enough interest to show that scheduling woes is on folks radar.
Well I know people have had woes with the scheduler for ever (I guess that isn't going to change :P). [...]
yes, that part isnt going to change, because the CPU is a _scarce resource_ that is perhaps the most frequently overcommitted physical computer resource in existence, and because the kernel does not (yet) track eye movements of humans to figure out which tasks are more important them. So critical human constraints are unknown to the scheduler and thus complaints will always come.
The upstream scheduler thought it had enough information: the sleep average. So now the attempt is to go back and _simplify_ the scheduler and remove that information, and concentrate on getting fairness precisely right. The magic thing about 'fairness' is that it's a pretty good default policy if we decide that we simply have not enough information to do an intelligent choice.
( Lets be cautious though: the jury is still out whether people actually
like this more than the current approach. While CFS feedback looks promising after a whopping 3 days of it being released [ ;-) ], the test coverage of all 'fairness centric' schedulers, even considering years of availability is less than 1% i'm afraid, and that < 1% was mostly self-selecting. )
Ingo
Quoted 8 lines · Ingo Molnar
Quoted 3 lines · Nick Piggin
Quoted 2 lines
Quoted 1 line
Maybe the progress is that more key people are becoming open to the idea of changing the scheduler.
Could be. All was quiet for quite a while, but when RSDL showed up, it aroused enough interest to show that scheduling woes is on folks radar.
Well I know people have had woes with the scheduler for ever (I guess that isn't going to change :P). [...]
yes, that part isnt going to change, because the CPU is a
_scarceresource_that is perhaps the most frequently overcommitted physical computer resource in existence, and because the kernel does not (yet) track eye movements of humans to figure out which tasks are more important them. So critical human constraints are unknown to the scheduler and thus complaints will always come.
Quoted 8 lines
The upstream scheduler thought it had enough information: the sleep average. So now the attempt is to go back and _simplify_ the scheduler and remove that information, and concentrate on getting fairness precisely right. The magic thing about 'fairness' is that it's a pretty good default policy if we decide that we simply have not enough information to do an intelligent choice.
( Lets be cautious though: the jury is still out whether people actually
like this more than the current approach. While CFS feedback looks promising after a whopping 3 days of it being released [ ;-) ], the test coverage of all 'fairness centric' schedulers, even considering years of availability is less than 1% i'm afraid, and that < 1% was mostly self-selecting. )
At this point I'd like to make the observation that spa_ebs is a very fair scheduler if you consider "nice" to be an indication of the relative entitlement of tasks to CPU bandwidth.
It works by mapping nice to shares using a function very similar to the one for calculating p->load weight except it's not offset by the RT priorities as RT is handled separately. In theory, a runnable task's entitlement to CPU bandwidth at any time is the ratio of its shares to the total shares held by runnable tasks on the same CPU (in reality, a smoothed average of this sum is used to make scheduling smoother). The dynamic priorities of the runnable tasks are then fiddled to try to keep each tasks CPU bandwidth usage in proportion to its entitlement.
That's the theory anyway.
The actual implementation looks a bit different due to efficiency considerations. The modifications to the above theory boil down to keeping a running measure of the (recent) highest CPU bandwidth use per share for tasks running on the CPU -- I call this the yardstick for this CPU. When it's time to put a task on the run queue it's dynamic priority is determined by comparing its CPU bandwidth per share value with the yardstick for its CPU. If it's greater than the yardstick this value becomes the new yardstick and the task gets given the lowest possible dynamic priority (for its scheduling class). If the value is zero it gets the highest possible priority (for its scheduling class) which would be MAX_RT_PRIO for a SCHED_OTHER task. Otherwise it gets given a priority between these two extremes proportional to ratio of its CPU bandwidth per share value and the yardstick. Quite simple really.
The other way in which the code deviates from the original as that (for a few years now) I no longer calculated CPU bandwidth usage directly. I've found that the overhead is less if I keep a running average of the size of a tasks CPU bursts and the length of its scheduling cycle (i.e. from on CPU one time to on CPU next time) and using the ratio of these values as a measure of bandwidth usage.
Anyway it works and gives very predictable allocations of CPU bandwidth based on nice.
Another good feature is that (in this pure form) it's starvation free. However, if you fiddle with it and do things like giving bonus priority boosts to interactive tasks it becomes susceptible to starvation. This can be fixed by using an anti starvation mechanism such as SPA's promotion scheme and that's what spa_ebs does.
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
Quoted 9 lines · Peter Williams
The other way in which the code deviates from the original as that (for a few years now) I no longer calculated CPU bandwidth usage directly. I've found that the overhead is less if I keep a running average of the size of a tasks CPU bursts and the length of its scheduling cycle (i.e. from on CPU one time to on CPU next time) and using the ratio of these values as a measure of bandwidth usage.
Anyway it works and gives very predictable allocations of CPU bandwidth based on nice.
Works, that is, right up until you add nonlinear interactions with CPU speed scaling. From my perspective as an embedded platform integrator, clock/voltage scaling is the elephant in the scheduler's living room. Patch in DPM (now OpPoint?) to scale the clock based on what task is being scheduled, and suddenly the dynamic priority calculations go wild. Nip this in the bud by putting an RT priority on the relevant threads (which you have to do anyway if you need remotely audio-grade latency), and the lock affinity heuristics break, so you have to hand-tune all the thread priorities. Blecch.
Not to mention the likelihood that the task whose clock speed you're trying to crank up (say, a WiFi soft MAC) needs to be _lower_ priority than the application. (You want to crank the CPU for this task because it runs with the RF hot, which may cost you as much power as the rest of the platform.) You'd better hope you can remove it from the dynamic priority heuristics with SCHED_BATCH. Otherwise everything _else_ has to be RT priority (or it'll be starved by the soft MAC) and you've basically tossed SCHED_NORMAL in the bin. Double blecch!
Is it too much to ask for someone with actual engineering training (not me, unfortunately) to sit down and build a negative-feedback control system that handles soft-real-time _and_ dynamic-priority _and_ batch loads, CPU _and_ I/O scheduling, preemption _and_ clock scaling? And actually separates the accounting and control mechanisms from the heuristics, so the latter can be tuned (within a well documented stable range) to reflect the expected system usage patterns?
It's not like there isn't a vast literature in this area over the past decade, including some dealing specifically with clock scaling consistent with low-latency applications. It's a pity that people doing academic work in this area rarely wade into LKML, even when they're hacking on a Linux fork. But then, there's not much economic incentive for them to do so, and they can usually get their fill of citation politics and dominance games without leaving their home department. :-P
Seriously, though. If you're really going to put the mainline scheduler through this kind of churn, please please pretty please knit in per-task clock scaling (possibly even rejigged during the slice; see e. g. Yuan and Nahrstedt's GRACE-OS papers) and some sort of linger mechanism to keep from taking context switch hits when you're confident that an I/O will complete quickly.
Cheers,
- Michael
Quoted 9 lines · Michael K. Edwards
Works, that is, right up until you add nonlinear interactions with CPU speed scaling. From my perspective as an embedded platform integrator, clock/voltage scaling is the elephant in the scheduler's living room. Patch in DPM (now OpPoint?) to scale the clock based on what task is being scheduled, and suddenly the dynamic priority calculations go wild. Nip this in the bud by putting an RT priority on the relevant threads (which you have to do anyway if you need remotely audio-grade latency), and the lock affinity heuristics break, so you have to hand-tune all the thread priorities. Blecch.
[...not terribly enlightening stuff trimmed...]
The ongoing scheduler work is on a much more basic level than these affairs I'm guessing you googled. When the basics work as intended it will be possible to move on to more advanced issues.
-- wli
Quoted 3 lines · William Lee Irwin III
The ongoing scheduler work is on a much more basic level than these affairs I'm guessing you googled. When the basics work as intended it will be possible to move on to more advanced issues.
OK, let me try this in smaller words for people who can't tell bitter experience from Google hits. CPU clock scaling for power efficiency is already the only thing that matters about the Linux scheduler in my world, because battery-powered device vendors in their infinite wisdom are abandoning real RTOSes in favor of Linux now that WiFi is the "in" thing (again). And on the timescale that anyone will actually be _using_ this shiny new scheduler of Ingo's, it'll be nearly the only thing that matters about the Linux scheduler in anyone's world, because the amount of work the CPU can get done in a given minute will depend mostly on how intelligently it can spend its heat dissipation budget.
Clock scaling schemes that aren't integral to the scheduler design make a bad situation (scheduling embedded loads with shotgun heuristics tuned for desktop CPUs) worse, because the opaque heuristics are now being applied to distorted data. Add a "smoothing" scheme for the distorted data, and you may find that you have introduced an actual control-path instability. A small fluctuation in the data (say, two bursts of interrupt traffic at just the right interval) can result in a long-lasting oscillation in some task's "dynamic priority" -- and, on a fully loaded CPU, in the time that task actually gets. If anything else depends on how much work this task gets done each time around, the oscillation can easily propagate throughout the system. Thrash city.
(If you haven't seen this happen on real production systems under what shouldn't be a pathological load, you haven't been around long. The classic mechanisms that triggered oscillations in, say, early SMP Solaris boxes haven't bitten recently, perhaps because most modern CPUs don't lose their marbles so comprehensively on context switch. But I got to live this nightmare again recently on ARM Linux, due to some impressively broken application-level threading/locking "design", whose assumptions about scheduler behavior got broken when I switched to an NPTL toolchain.)
I don't have the training to design a scheduler that isn't vulnerable to control-feedback oscillations. Neither do you, if you haven't taken (and excelled at) a control theory course, which nowadays seems to be taught by applied math and ECE departments and too often skipped by CS types. But I can recognize an impending train wreck when I see it.
Cheers,
- Michael
Quoted 4 lines · Michael K. Edwards
Quoted 3 lines · William Lee Irwin III
The ongoing scheduler work is on a much more basic level than these affairs I'm guessing you googled. When the basics work as intended it will be possible to move on to more advanced issues.
...
Will probably shouldn't have dismissed your points but he probably means that can't even get at this stuff until fundamental are in place.
Quoted 4 lines
Clock scaling schemes that aren't integral to the scheduler design make a bad situation (scheduling embedded loads with shotgun heuristics tuned for desktop CPUs) worse, because the opaque heuristics are now being applied to distorted data. Add a "smoothing"
Quoted 8 lines
scheme for the distorted data, and you may find that you have introduced an actual control-path instability. A small fluctuation in the data (say, two bursts of interrupt traffic at just the right interval) can result in a long-lasting oscillation in some task's "dynamic priority" -- and, on a fully loaded CPU, in the time that task actually gets. If anything else depends on how much work this task gets done each time around, the oscillation can easily propagate throughout the system. Thrash city.
Hyperthreading issues are quite similar that clock scaling issues. Con's infrastructures changes to move things in that direction were rejected, as well as other infrastructure changes, further infuritating Con to drop development on RSDL and derivatives.
bill
Quoted 49 lines · Michael K. Edwards
Quoted 9 lines · Peter Williams
The other way in which the code deviates from the original as that (for a few years now) I no longer calculated CPU bandwidth usage directly. I've found that the overhead is less if I keep a running average of the size of a tasks CPU bursts and the length of its scheduling cycle (i.e. from on CPU one time to on CPU next time) and using the ratio of these values as a measure of bandwidth usage.
Anyway it works and gives very predictable allocations of CPU bandwidth based on nice.
Works, that is, right up until you add nonlinear interactions with CPU speed scaling. From my perspective as an embedded platform integrator, clock/voltage scaling is the elephant in the scheduler's living room. Patch in DPM (now OpPoint?) to scale the clock based on what task is being scheduled, and suddenly the dynamic priority calculations go wild. Nip this in the bud by putting an RT priority on the relevant threads (which you have to do anyway if you need remotely audio-grade latency), and the lock affinity heuristics break, so you have to hand-tune all the thread priorities. Blecch.
Not to mention the likelihood that the task whose clock speed you're trying to crank up (say, a WiFi soft MAC) needs to be _lower_ priority than the application. (You want to crank the CPU for this task because it runs with the RF hot, which may cost you as much power as the rest of the platform.) You'd better hope you can remove it from the dynamic priority heuristics with
SCHED_BATCH. Otherwise everything _else_ has to be RT priority (or it'll be starved by the soft MAC) and you've basically tossedSCHED_NORMALin the bin. Double blecch!Is it too much to ask for someone with actual engineering training (not me, unfortunately) to sit down and build a negative-feedback control system that handles soft-real-time _and_ dynamic-priority _and_ batch loads, CPU _and_ I/O scheduling, preemption _and_ clock scaling? And actually separates the accounting and control mechanisms from the heuristics, so the latter can be tuned (within a well documented stable range) to reflect the expected system usage patterns?
It's not like there isn't a vast literature in this area over the past decade, including some dealing specifically with clock scaling consistent with low-latency applications. It's a pity that people doing academic work in this area rarely wade into LKML, even when they're hacking on a Linux fork. But then, there's not much economic incentive for them to do so, and they can usually get their fill of citation politics and dominance games without leaving their home department. :-P
Quoted 6 lines
Seriously, though. If you're really going to put the mainline scheduler through this kind of churn, please please pretty please knit in per-task clock scaling (possibly even rejigged during the slice; see e. g. Yuan and Nahrstedt's GRACE-OS papers) and some sort of linger mechanism to keep from taking context switch hits when you're confident that an I/O will complete quickly.
I think that this doesn't effect the basic design principles of spa_ebs but just means that the statistics that it uses need to be rethought. E.g. instead of measuring average CPU usage per burst in terms of wall clock time spent on the CPU measure it in terms of CPU capacity (for the want of a better word) used per burst.
I don't have suitable hardware for investigating this line of attack further, unfortunately, and have no idea what would be the best way to calculate this new statistic.
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
Quoted 7 lines · Ingo Molnar
( Lets be cautious though: the jury is still out whether people actually
like this more than the current approach. While CFS feedback looks promising after a whopping 3 days of it being released [ ;-) ], the test coverage of all 'fairness centric' schedulers, even considering years of availability is less than 1% i'm afraid, and that < 1% was mostly self-selecting. )
All of my testing has been on desktop machines, although in most cases they were really loaded desktops which had load avg 10..100 from time to time, and none were low memory machines. Up to CFS v3 I thought nicksched was my winner, now CFSv3 looks better, by not having stumbles under stupid loads.
I have not tested:
1 - server loads, nntp, smtp, etc
2 - low memory machines
3 - uniprocessor systems
I think this should be done before drawing conclusions. Or if someone has tried this, perhaps they would report what they saw. People are talking about smoothness, but not how many pages per second come out of their overloaded web server.
Signature · 3 lines
Bill Davidsen <[email protected]> "We have more to fear from the bungling of the incompetent than from the machinations of the wicked." - from Slashdot
Quoted 9 lines · Bill Davidsen
Quoted 7 lines · Ingo Molnar
( Lets be cautious though: the jury is still out whether people actually
like this more than the current approach. While CFS feedback looks promising after a whopping 3 days of it being released [ ;-) ], the test coverage of all 'fairness centric' schedulers, even considering years of availability is less than 1% i'm afraid, and that < 1% was mostly self-selecting. )
Quoted 5 lines
All of my testing has been on desktop machines, although in most cases they were really loaded desktops which had load avg 10..100 from time to time, and none were low memory machines. Up to CFS v3 I thought nicksched was my winner, now CFSv3 looks better, by not having stumbles under stupid loads.
What base_timeslice were you using for nicksched, and what HZ?
Quoted 5 lines · Bill Davidsen
All of my testing has been on desktop machines, although in most cases they were really loaded desktops which had load avg 10..100 from time to time, and none were low memory machines. Up to CFS v3 I thought nicksched was my winner, now CFSv3 looks better, by not having stumbles under stupid loads.
nice! I hope CFSv4 kept that good tradition too ;)
Quoted 9 lines
I have not tested:
1 - server loads, nntp, smtp, etc
2 - low memory machines
3 - uniprocessor systemsI think this should be done before drawing conclusions. Or if someone has tried this, perhaps they would report what they saw. People are talking about smoothness, but not how many pages per second come out of their overloaded web server.
i tested heavily swapping systems. (make -j50 workloads easily trigger that) I also tested UP systems and a handful of SMP systems. I have also tested massive_intr.c which i believe is an indicator of how fairly CPU time is distributed between partly sleeping partly running server threads. But i very much agree that diverse feedback is sought and welcome, both from those who are happy with the current scheduler and those who are unhappy about it.
Ingo
Re: [Announce] [patch] Modular Scheduler Core and Completely FairScheduler [CFS]
In reply to Mike GalbraithQuoted 15 lines · Mike Galbraith
Subject: Re: [Announce] [patch] Modular Scheduler Core and Completely
FairScheduler [CFS]Quoted 8 lines · Nick Piggin
Quoted 1 line · Mike Galbraith
Yup, and progress _is_ happening now, quite rapidly.
Progress as in progress on Ingo's scheduler. I still don't know how we'd decide when to replace the mainline scheduler or with what.
I don't think we can say Ingo's is better than the alternatives, can we?
No, that would require massive performance testing of all alternatives.
Quoted 7 lines
Quoted 2 lines
If there is some kind of bakeoff, then I'd like one of Con's designs to be involved, and mine, and Peter's...
The trouble with a bakeoff is that it's pretty darn hard to get people to test in the first place, and then comes weighting the subjective and hard performance numbers. If they're close in numbers, do you go with the one which starts the least flamewars or what?
it's especially hard if the people doing the testing need to find the latest patch and apply it.
even having a compile-time option to switch between them at least means that the testers can have confidence that the various patches haven't bitrotted.
boot time options would be even better, but I understand from previous discussions I've watched that this is performance critical enough that the overhead of this would throw off the results.
David Lang
Quoted 11 lines · Mike Galbraith
Quoted 7 lines · Nick Piggin
Quoted 1 line · Mike Galbraith
Yup, and progress _is_ happening now, quite rapidly.
Progress as in progress on Ingo's scheduler. I still don't know how we'd decide when to replace the mainline scheduler or with what.
I don't think we can say Ingo's is better than the alternatives, can we?
No, that would require massive performance testing of all alternatives.
Quoted 8 lines
Quoted 2 lines
If there is some kind of bakeoff, then I'd like one of Con's designs to be involved, and mine, and Peter's...
The trouble with a bakeoff is that it's pretty darn hard to get people to test in the first place, and then comes weighting the subjective and hard performance numbers. If they're close in numbers, do you go with the one which starts the least flamewars or what?
Here we disagree... I picked a scheduler not by running benchmarks, but by running loads which piss me off with the mainline scheduler. And then I ran the other schedulers for a while to find the things, normal things I do, which resulted in bad behavior. And when I found one which had (so far) no such cases I called it my winner, but I haven't tested it under server load, so I can't begin to say it's "the best."
What we need is for lots of people to run every scheduler in real life, and do "worst case analysis" by finding the cases which cause bad behavior. And if there were a way to easily choose another scheduler, call it plugable, modular, or Russian Roulette, people who found a worst case would report it (aka bitch about it) and try another. But the average user is better able to boot with an option like "sched=cfs" (or sc, or nick, or ...) than to patch and build a kernel. So if we don't get easily switched schedulers people will not test nearly as well.
The best scheduler isn't the one 2% faster than the rest, it's the one with the fewest jackpot cases where it sucks. And if the mainline had multiple schedulers this testing would get done, authors would get more reports and have a better chance of fixing corner cases.
Note that we really need multiple schedulers to make people happy, because fairness is not the most desirable behavior on all machines, and adding knobs probably isn't the answer. I want a server to degrade gently, I want my desktop to show my movie and echo my typing, and if that's hard on compiles or the file transfer, so be it. Con doesn't want to compromise his goals, I agree but want to have an option if I don't share them.
Signature · 3 lines
Bill Davidsen <[email protected]> "We have more to fear from the bungling of the incompetent than from the machinations of the wicked." - from Slashdot
Quoted 12 lines · Nick Piggin
Quoted 11 lines · Mike Galbraith
Quoted 5 lines · Peter Williams
Quoted 3 lines · Mike Galbraith
Demystify what? The casual observer need only read either your attempt
at writing a scheduler, or my attempts at fixing the one we have, to see that it was high time for someone with the necessary skills to step in.Make that "someone with the necessary clout".
No, I was brutally honest to both of us, but quite correct.
Quoted 3 lines
Quoted 2 lines
Now progress can happen, which was _not_ happening before.
This is true.
Quoted 8 lines
Quoted 1 line
Yup, and progress _is_ happening now, quite rapidly.
Progress as in progress on Ingo's scheduler. I still don't know how we'd decide when to replace the mainline scheduler or with what.
I don't think we can say Ingo's is better than the alternatives, can we? If there is some kind of bakeoff, then I'd like one of Con's designs to be involved, and mine, and Peter's...
I myself was thinking of this as the chance for a much needed simplification of the scheduling code and if this can be done with the result being "reasonable" it then gives us the basis on which to propose improvements based on the ideas of others such as you mention.
As the size of the cpusched indicates, trying to evaluate alternative proposals based on the current O(1) scheduler is fraught. Hopefully, this initiative can fix this problem. Then we just need Ingo to listen to suggestions and he's showing signs of being willing to do this :-)
Quoted 3 lines
Maybe the progress is that more key people are becoming open to the idea of changing the scheduler.
That too.
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
Quoted 22 lines · Peter Williams
Quoted 12 lines · Nick Piggin
Quoted 11 lines · Mike Galbraith
Quoted 5 lines · Peter Williams
Quoted 3 lines · Mike Galbraith
Demystify what? The casual observer need only read either your attempt
at writing a scheduler, or my attempts at fixing the one we have, to see that it was high time for someone with the necessary skills to step in.Make that "someone with the necessary clout".
No, I was brutally honest to both of us, but quite correct.
Quoted 3 lines
Quoted 2 lines
Now progress can happen, which was _not_ happening before.
This is true.
Quoted 8 lines
Quoted 1 line
Yup, and progress _is_ happening now, quite rapidly.
Progress as in progress on Ingo's scheduler. I still don't know how we'd decide when to replace the mainline scheduler or with what.
I don't think we can say Ingo's is better than the alternatives, can we? If there is some kind of bakeoff, then I'd like one of Con's designs to be involved, and mine, and Peter's...
Quoted 7 lines
I myself was thinking of this as the chance for a much needed simplification of the scheduling code and if this can be done with the result being "reasonable" it then gives us the basis on which to propose improvements based on the ideas of others such as you mention.
As the size of the cpusched indicates, trying to evaluate alternative proposals based on the current O(1) scheduler is fraught. Hopefully,
I don't know why. The problem is that you can't really evaluate good proposals by looking at the code (you can say that one is bad, ie. the current one, which has a huge amount of temporal complexity and is explicitly unfair), but it is pretty hard to say one behaves well.
And my scheduler for example cuts down the amount of policy code and code size significantly. I haven't looked at Con's ones for a while, but I believe they are also much more straightforward than mainline...
For example, let's say all else is equal between them, then why would we go with the O(logN) implementation rather than the O(1)?
Hi Nick,
On Tue, Apr 17, 2007 at 06:29:54AM +0200, Nick Piggin wrote:
(...)
Quoted 6 lines
And my scheduler for example cuts down the amount of policy code and code size significantly. I haven't looked at Con's ones for a while, but I believe they are also much more straightforward than mainline...
For example, let's say all else is equal between them, then why would we go with the O(logN) implementation rather than the O(1)?
Of course, if this is the case, the question will be raised. But as a general rule, I don't see much potential in O(1) to finely tune scheduling according to several criteria. In O(logN), you can adjust scheduling in realtime at a very low cost. Better processing of varying priorities or fork() comes to mind.
Regards,
Willy
Quoted 8 lines · Willy Tarreau
Hi Nick,
On Tue, Apr 17, 2007 at 06:29:54AM +0200, Nick Piggin wrote:
(...)Quoted 4 lines
And my scheduler for example cuts down the amount of policy code and code size significantly. I haven't looked at Con's ones for a while, but I believe they are also much more straightforward than mainline...
Quoted 6 lines
Quoted 2 lines
For example, let's say all else is equal between them, then why would we go with the O(logN) implementation rather than the O(1)?
Of course, if this is the case, the question will be raised. But as a general rule, I don't see much potential in O(1) to finely tune scheduling according to several criteria.
What do you mean? By what criteria?
Quoted 3 lines
In O(logN), you can adjust scheduling in
realtime at a very low cost. Better processing of varying priorities orfork()comes to mind.
The main problem as I see it is choosing which task to run next and how much time to run it for. And given that there are typically far less than 58 (the number of priorities in nicksched) runnable tasks for a desktop system, I don't find it at all constraining to quantize my "next runnable" criteria onto that size of key.
Even if you do expect a huge number of runnable tasks, you would hope for fewer interactive ones toward the higher end of the priority scale.
Handwaving or even detailed design descriptions is simply not the best way to decide on a new scheduler, is all I'm saying.
Quoted 6 lines · Peter Williams
Quoted 6 lines
I myself was thinking of this as the chance for a much needed simplification of the scheduling code and if this can be done with the result being "reasonable" it then gives us the basis on which to propose improvements based on the ideas of others such as you mention. As the size of the cpusched indicates, trying to evaluate alternative proposals based on the current O(1) scheduler is fraught. Hopefully,
Quoted 9 lines · Nick Piggin
I don't know why. The problem is that you can't really evaluate good proposals by looking at the code (you can say that one is bad, ie. the current one, which has a huge amount of temporal complexity and is explicitly unfair), but it is pretty hard to say one behaves well. And my scheduler for example cuts down the amount of policy code and code size significantly. I haven't looked at Con's ones for a while, but I believe they are also much more straightforward than mainline... For example, let's say all else is equal between them, then why would we go with the O(logN) implementation rather than the O(1)?
All things are not equal; they all have different properties. I like getting rid of the queue-swapping artifacts as ebs and cfs have done, as the artifacts introduced there are nasty IMNSHO. I'm queueing up a demonstration of epoch expiry scheduling artifacts as a testcase, albeit one with no pass/fail semantics for its results, just detecting scheduler properties.
That said, inequality/inequivalence is not a superiority/inferiority ranking per se. What needs to come out of these discussions is a set of standards which a candidate for mainline must pass to be considered correct and a set of performance metrics by which to rank them. Video game framerates and some sort of way to automate window wiggle tests sound like good ideas, but automating such is beyond my userspace programming abilities. An organization able to devote manpower to devising such testcases will likely have to get involved for them to happen, I suspect.
On a random note, limitations on kernel address space make O(lg(n)) effectively O(1), albeit with large upper bounds on the worst case and an expected case much faster than the worst case.
-- wli
Quoted 19 lines · William Lee Irwin III
Quoted 6 lines · Peter Williams
Quoted 6 lines
I myself was thinking of this as the chance for a much needed simplification of the scheduling code and if this can be done with the result being "reasonable" it then gives us the basis on which to propose improvements based on the ideas of others such as you mention. As the size of the cpusched indicates, trying to evaluate alternative proposals based on the current O(1) scheduler is fraught. Hopefully,
Quoted 9 lines · Nick Piggin
I don't know why. The problem is that you can't really evaluate good proposals by looking at the code (you can say that one is bad, ie. the current one, which has a huge amount of temporal complexity and is explicitly unfair), but it is pretty hard to say one behaves well. And my scheduler for example cuts down the amount of policy code and code size significantly. I haven't looked at Con's ones for a while, but I believe they are also much more straightforward than mainline... For example, let's say all else is equal between them, then why would we go with the O(logN) implementation rather than the O(1)?
Quoted 1 line
All things are not equal; they all have different properties. I like
Exactly. So we have to explore those properties and evaluate performance (in all meanings of the word). That's only logical.
Quoted 3 lines
On a random note, limitations on kernel address space make O(lg(n)) effectively O(1), albeit with large upper bounds on the worst case and an expected case much faster than the worst case.
Yeah. O(n!) is also O(1) if you can put an upper bound on n ;)
Quoted 1 line · William Lee Irwin III
Quoted 1 line
All things are not equal; they all have different properties. I like
Quoted 2 lines · Nick Piggin
Exactly. So we have to explore those properties and evaluate performance (in all meanings of the word). That's only logical.
Any chance you'd be willing to put down a few thoughts on what sorts of standards you'd like to set for both correctness (i.e. the bare minimum a scheduler implementation must do to be considered valid beyond not oopsing) and performance metrics (i.e. things that produce numbers for each scheduler you can compare to say "this scheduler is better than this other scheduler at this.").
-- wli
Quoted 7 lines · William Lee Irwin III
Quoted 1 line · William Lee Irwin III
Quoted 1 line
All things are not equal; they all have different properties. I like
Quoted 2 lines · Nick Piggin
Exactly. So we have to explore those properties and evaluate performance (in all meanings of the word). That's only logical.
Quoted 6 lines
Any chance you'd be willing to put down a few thoughts on what sorts of standards you'd like to set for both correctness (i.e. the bare minimum a scheduler implementation must do to be considered valid beyond not oopsing) and performance metrics (i.e. things that produce numbers for each scheduler you can compare to say "this scheduler is better than this other scheduler at this.").
Yeah I guess that's the hard part :)
For correctness, I guess fairness is an easy one. I think that unfairness is basically a bug and that it would be very unfortunate to merge something unfair. But this is just within the context of a single runqueue... for better or worse, we allow some unfairness in multiprocessors for performance reasons of course.
Latency. Given N tasks in the system, an arbitrary task should get onto the CPU in a bounded amount of time (excluding events like freak IRQ holdoffs and such, obviously -- ie. just considering the context of the scheduler's state machine).
I wouldn't like to see a significant drop in any micro or macro benchmarks or even worse real workloads, but I could accept some if it means haaving a fair scheduler by default.
Now it isn't actually too hard to achieve the above, I think. The hard bit is trying to compare interactivity. Ideally, we'd be able to get scripted dumps of login sessions, and measure scheduling latencies of key proceses (sh/X/wm/xmms/firefox/etc). People would send a dump if they were having problems with any scheduler, and we could compare all of them against it. Wishful thinking!
Quoted 6 lines · William Lee Irwin III
Quoted 6 lines
Any chance you'd be willing to put down a few thoughts on what sorts of standards you'd like to set for both correctness (i.e. the bare minimum a scheduler implementation must do to be considered valid beyond not oopsing) and performance metrics (i.e. things that produce numbers for each scheduler you can compare to say "this scheduler is better than this other scheduler at this.").
Quoted 6 lines · Nick Piggin
Yeah I guess that's the hard part :)
For correctness, I guess fairness is an easy one. I think that unfairness is basically a bug and that it would be very unfortunate to merge something unfair. But this is just within the context of a single runqueue... for better or worse, we allow some unfairness in multiprocessors for performance reasons of course.
Requiring that identical tasks be allocated equal shares of CPU bandwidth is the easy part here. ringtest.c exercises another aspect of fairness that is extremely important. Generalizing ringtest.c is a good idea for fairness testing.
But another aspect of fairness is that "controlled unfairness" is also intended to exist, in no small part by virtue of nice levels, but also in the form of favoring tasks that are considered interactive somehow. Testing various forms of controlled unfairness to ensure that they are indeed controlled and otherwise have the semantics intended is IMHO the more difficult aspect of fairness testing.
Quoted 4 lines · Nick Piggin
Latency. Given N tasks in the system, an arbitrary task should get onto the CPU in a bounded amount of time (excluding events like freak IRQ holdoffs and such, obviously -- ie. just considering the context of the scheduler's state machine).
ISTR Davide Libenzi having a scheduling latency test a number of years ago. Resurrecting that and tuning it to the needs of this kind of testing sounds relevant here. The test suite Peter Willliams mentioned would also help.
Quoted 3 lines · Nick Piggin
I wouldn't like to see a significant drop in any micro or macro benchmarks or even worse real workloads, but I could accept some if it means haaving a fair scheduler by default.
Quoted 6 lines · Nick Piggin
Now it isn't actually too hard to achieve the above, I think. The hard bit is trying to compare interactivity. Ideally, we'd be able to get scripted dumps of login sessions, and measure scheduling latencies of key proceses (sh/X/wm/xmms/firefox/etc). People would send a dump if they were having problems with any scheduler, and we could compare all of them against it. Wishful thinking!
That's a pretty good idea. I'll queue up writing something of that form as well.
-- wli
Quoted 10 lines · William Lee Irwin III
Quoted 4 lines · Nick Piggin
Latency. Given N tasks in the system, an arbitrary task should get onto the CPU in a bounded amount of time (excluding events like freak IRQ holdoffs and such, obviously -- ie. just considering the context of the scheduler's state machine).
ISTR Davide Libenzi having a scheduling latency test a number of years ago. Resurrecting that and tuning it to the needs of this kind of testing sounds relevant here. The test suite Peter Willliams mentioned would also help.
That helped me a lot at that time. At every context switch was sampling critical scheduler parameters for both entering and exiting task (and associated timestamps). Then the data was collected through a /dev/idontremember from userspace for analysis. It'd very useful to have it those days, to study what really happens under the hook (scheduler internal parameters variations and such) when those wierd loads make the scheduler unstable.
- Davide
Quoted 15 lines · Nick Piggin
Quoted 7 lines · William Lee Irwin III
Quoted 1 line · William Lee Irwin III
Quoted 1 line
All things are not equal; they all have different properties. I like
Quoted 2 lines · Nick Piggin
Exactly. So we have to explore those properties and evaluate performance (in all meanings of the word). That's only logical.
Quoted 6 lines
Any chance you'd be willing to put down a few thoughts on what sorts of standards you'd like to set for both correctness (i.e. the bare minimum a scheduler implementation must do to be considered valid beyond not oopsing) and performance metrics (i.e. things that produce numbers for each scheduler you can compare to say "this scheduler is better than this other scheduler at this.").
Quoted 7 lines
Yeah I guess that's the hard part :)
For correctness, I guess fairness is an easy one. I think that unfairness is basically a bug and that it would be very unfortunate to merge something unfair. But this is just within the context of a single runqueue... for better or worse, we allow some unfairness in multiprocessors for performance reasons of course.
I'm a big fan of fairness, but I think it's a bit early to declare it a mandatory feature. Bounded unfairness is probably something we can agree on, ie "if we decide to be unfair, no process suffers more than a factor of x".
Quoted 4 lines
Latency. Given N tasks in the system, an arbitrary task should get onto the CPU in a bounded amount of time (excluding events like freak IRQ holdoffs and such, obviously -- ie. just considering the context of the scheduler's state machine).
This is a slightly stronger statement than starvation-free (which is obviously mandatory). I think you're looking for something like "worst-case scheduling latency is proportional to the number of runnable tasks". Which I think is quite a reasonable requirement.
I'm pretty sure the stock scheduler falls short of both of these guarantees though.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 31 lines · Matt Mackall
Quoted 12 lines · Nick Piggin
Quoted 11 lines · William Lee Irwin III
Quoted 1 line · William Lee Irwin III
Quoted 1 line
All things are not equal; they all have different properties. I like
Quoted 2 lines · Nick Piggin
Exactly. So we have to explore those properties and evaluate performance (in all meanings of the word). That's only logical.
Any chance you'd be willing to put down a few thoughts on what sorts of standards you'd like to set for both correctness (i.e. the bare minimum a scheduler implementation must do to be considered valid beyond not oopsing) and performance metrics (i.e. things that produce numbers for each scheduler you can compare to say "this scheduler is better than this other scheduler at this.").
Quoted 7 lines
Yeah I guess that's the hard part :)
For correctness, I guess fairness is an easy one. I think that unfairness is basically a bug and that it would be very unfortunate to merge something unfair. But this is just within the context of a single runqueue... for better or worse, we allow some unfairness in multiprocessors for performance reasons of course.
I'm a big fan of fairness, but I think it's a bit early to declare it a mandatory feature. Bounded unfairness is probably something we can agree on, ie "if we decide to be unfair, no process suffers more than a factor of x".
Quoted 4 lines
Latency. Given N tasks in the system, an arbitrary task should get onto the CPU in a bounded amount of time (excluding events like freak IRQ holdoffs and such, obviously -- ie. just considering the context of the scheduler's state machine).
Quoted 4 lines
This is a slightly stronger statement than starvation-free (which is obviously mandatory). I think you're looking for something like "worst-case scheduling latency is proportional to the number of runnable tasks".
add "taking into consideration nice and/or real time priorities of runnable tasks". I.e. if a task is nice 19 it can expect to wait longer to get onto the CPU than if it was nice 0.
Quoted 5 lines
Which I think is quite a reasonable requirement.
I'm pretty sure the stock scheduler falls short of both of these guarantees though.
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
Quoted 34 lines · Peter Williams
Quoted 33 lines · Matt Mackall
Quoted 14 lines · Nick Piggin
Quoted 11 lines · William Lee Irwin III
Quoted 1 line · William Lee Irwin III
Quoted 1 line
All things are not equal; they all have different properties. I like
Quoted 2 lines · Nick Piggin
Exactly. So we have to explore those properties and evaluate performance (in all meanings of the word). That's only logical.
Any chance you'd be willing to put down a few thoughts on what sorts of standards you'd like to set for both correctness (i.e. the bare minimum a scheduler implementation must do to be considered valid beyond not oopsing) and performance metrics (i.e. things that produce numbers for each scheduler you can compare to say "this scheduler is better than this other scheduler at this.").
Yeah I guess that's the hard part :)
Quoted 7 lines
For correctness, I guess fairness is an easy one. I think that unfairness is basically a bug and that it would be very unfortunate to merge something
unfair. But this is just within the context of a single runqueue... for better or worse, we allow some unfairness in multiprocessors for performance
reasons of course.I'm a big fan of fairness, but I think it's a bit early to declare it a mandatory feature. Bounded unfairness is probably something we can agree on, ie "if we decide to be unfair, no process suffers more than a factor of x".
Quoted 4 lines
Latency. Given N tasks in the system, an arbitrary task should get onto the CPU in a bounded amount of time (excluding events like freak IRQ holdoffs and such, obviously -- ie. just considering the context of the scheduler's state machine).
Quoted 8 lines
Quoted 4 lines
This is a slightly stronger statement than starvation-free (which is obviously mandatory). I think you're looking for something like "worst-case scheduling latency is proportional to the number of runnable tasks".
add "taking into consideration nice and/or real time priorities of runnable tasks". I.e. if a task is nice 19 it can expect to wait longer to get onto the CPU than if it was nice 0.
Yes. Assuming we meet the "bounded unfairness" criterion above, this follows.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 24 lines · Matt Mackall
Quoted 15 lines · Nick Piggin
Quoted 7 lines · William Lee Irwin III
Quoted 1 line · William Lee Irwin III
Quoted 1 line
All things are not equal; they all have different properties. I like
Quoted 2 lines · Nick Piggin
Exactly. So we have to explore those properties and evaluate performance (in all meanings of the word). That's only logical.
Quoted 6 lines
Any chance you'd be willing to put down a few thoughts on what sorts of standards you'd like to set for both correctness (i.e. the bare minimum a scheduler implementation must do to be considered valid beyond not oopsing) and performance metrics (i.e. things that produce numbers for each scheduler you can compare to say "this scheduler is better than this other scheduler at this.").
Quoted 7 lines
Yeah I guess that's the hard part :)
For correctness, I guess fairness is an easy one. I think that unfairness is basically a bug and that it would be very unfortunate to merge something unfair. But this is just within the context of a single runqueue... for better or worse, we allow some unfairness in multiprocessors for performance reasons of course.
Quoted 4 lines
I'm a big fan of fairness, but I think it's a bit early to declare it a mandatory feature. Bounded unfairness is probably something we can agree on, ie "if we decide to be unfair, no process suffers more than a factor of x".
I don't know why this would be a useful feature (of course I'm talking about processes at the same nice level). One of the big problems with the current scheduler is that it is unfair in some corner cases. It works OK for most people, but when it breaks down it really hurts. At least if you start with a fair scheduler, you can alter priorities until it satisfies your need... with an unfair one your guess is as good as mine.
So on what basis would you allow unfairness? On the basis that it doesn't seem to harm anyone? It doesn't seem to harm testers?
I think we should aim for something better.
Quoted 9 lines
Quoted 4 lines
Latency. Given N tasks in the system, an arbitrary task should get onto the CPU in a bounded amount of time (excluding events like freak IRQ holdoffs and such, obviously -- ie. just considering the context of the scheduler's state machine).
This is a slightly stronger statement than starvation-free (which is obviously mandatory). I think you're looking for something like "worst-case scheduling latency is proportional to the number of runnable tasks". Which I think is quite a reasonable requirement.
Yes, bounded and proportional to.
Quoted 2 lines
I'm pretty sure the stock scheduler falls short of both of these guarantees though.
And I think that's what its main problems are. It's interactivity obviously can't be too bad for most people. It's performance seems to be pretty good.
Quoted 15 lines · Nick Piggin
Quoted 5 lines · Matt Mackall
I'm a big fan of fairness, but I think it's a bit early to declare it a mandatory feature. Bounded unfairness is probably something we can agree on, ie "if we decide to be unfair, no process suffers more than a factor of x".
I don't know why this would be a useful feature (of course I'm talking about processes at the same nice level). One of the big problems with the current scheduler is that it is unfair in some corner cases. It works OK for most people, but when it breaks down it really hurts. At least if you start with a fair scheduler, you can alter priorities until it satisfies your need... with an unfair one your guess is as good as mine.
Quoted 2 lines
So on what basis would you allow unfairness? On the basis that it doesn't seem to harm anyone? It doesn't seem to harm testers?
Well, there's short term fair and long term fair. Seems to me a burst load having to always merge with a steady stream load using a short term fairness yardstick absolutely must 'starve' relative to the steady load, so to be long term fair, you have to add some short term unfairness. The mainline scheduler is more long term fair (discounting the rather obnoxious corner cases).
-Mike
Quoted 19 lines · Mike Galbraith
Quoted 15 lines · Nick Piggin
Quoted 5 lines · Matt Mackall
I'm a big fan of fairness, but I think it's a bit early to declare it a mandatory feature. Bounded unfairness is probably something we can agree on, ie "if we decide to be unfair, no process suffers more than a factor of x".
I don't know why this would be a useful feature (of course I'm talking about processes at the same nice level). One of the big problems with the current scheduler is that it is unfair in some corner cases. It works OK for most people, but when it breaks down it really hurts. At least if you start with a fair scheduler, you can alter priorities until it satisfies your need... with an unfair one your guess is as good as mine.
Quoted 2 lines
So on what basis would you allow unfairness? On the basis that it doesn't seem to harm anyone? It doesn't seem to harm testers?
Quoted 6 lines
Well, there's short term fair and long term fair. Seems to me a burst load having to always merge with a steady stream load using a short term fairness yardstick absolutely must 'starve' relative to the steady load, so to be long term fair, you have to add some short term unfairness. The mainline scheduler is more long term fair (discounting the rather obnoxious corner cases).
Oh yes definitely I mean long term fair. I guess it is impossible to be completely fair so long as we have to timeshare the CPU :)
So a constant delta is fine and unavoidable. But I don't think I agree with a constant factor: that means you can pick a time where process 1 is allowed an arbitrary T more CPU time than process 2.
Quoted 14 lines · Nick Piggin
Quoted 6 lines · Mike Galbraith
Quoted 4 lines · Nick Piggin
So on what basis would you allow unfairness? On the basis that it doesn't seem to harm anyone? It doesn't seem to harm testers?
Quoted 6 lines
Well, there's short term fair and long term fair. Seems to me a burst load having to always merge with a steady stream load using a short term fairness yardstick absolutely must 'starve' relative to the steady load, so to be long term fair, you have to add some short term unfairness. The mainline scheduler is more long term fair (discounting the rather obnoxious corner cases).
Quoted 6 lines
Oh yes definitely I mean long term fair. I guess it is impossible to be completely fair so long as we have to timeshare the CPU :)
So a constant delta is fine and unavoidable. But I don't think I agree with a constant factor: that means you can pick a time where process 1 is allowed an arbitrary T more CPU time than process 2.
Definitely. Using constants with no consideration of what else is running is what causes the fairness mechanism in mainline to break down under load.
(aside: What I was experimenting with before this new scheduler came along was to turn the sleep_avg thing into an off-cpu period thing. Once a time slice begins execution [runqueue wait doesn't count], that task has the right to use it's slice in one go, and _anything_ that knocked it off the cpu added to it's credit. Knocking someone else off detracts from credit, and to get to the point where you can knock others off costs you stored credit proportional to the dynamic priority you attain by using it. All tasks that have credit stay active, no favorites.)
-Mike
Quoted 38 lines · Nick Piggin
Quoted 24 lines · Matt Mackall
Quoted 15 lines · Nick Piggin
Quoted 7 lines · William Lee Irwin III
Quoted 1 line · William Lee Irwin III
Quoted 1 line
All things are not equal; they all have different properties. I like
Quoted 2 lines · Nick Piggin
Exactly. So we have to explore those properties and evaluate performance (in all meanings of the word). That's only logical.
Quoted 6 lines
Any chance you'd be willing to put down a few thoughts on what sorts of standards you'd like to set for both correctness (i.e. the bare minimum a scheduler implementation must do to be considered valid beyond not oopsing) and performance metrics (i.e. things that produce numbers for each scheduler you can compare to say "this scheduler is better than this other scheduler at this.").
Quoted 7 lines
Yeah I guess that's the hard part :)
For correctness, I guess fairness is an easy one. I think that unfairness is basically a bug and that it would be very unfortunate to merge something unfair. But this is just within the context of a single runqueue... for better or worse, we allow some unfairness in multiprocessors for performance reasons of course.
Quoted 4 lines
I'm a big fan of fairness, but I think it's a bit early to declare it a mandatory feature. Bounded unfairness is probably something we can agree on, ie "if we decide to be unfair, no process suffers more than a factor of x".
I don't know why this would be a useful feature (of course I'm talking about processes at the same nice level). One of the big problems with the current scheduler is that it is unfair in some corner cases. It works OK for most people, but when it breaks down it really hurts. At least if you start with a fair scheduler, you can alter priorities until it satisfies your need... with an unfair one your guess is as good as mine.
Quoted 2 lines
So on what basis would you allow unfairness? On the basis that it doesn't seem to harm anyone? It doesn't seem to harm testers?
On the basis that there's only anecdotal evidence thus far that fairness is the right approach.
It's not yet clear that a fair scheduler can do the right thing with X, with various kernel threads, etc. without fiddling with nice levels. Which makes it no longer "completely fair".
It's also not yet clear that a scheduler can't be taught to do the right thing with X without fiddling with nice levels.
So I'm just not yet willing to completely rule out systems that aren't "completely fair".
But I think we should rule out schedulers that don't have rigid bounds on that unfairness. That's where the really ugly behavior lies.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 13 lines · Matt Mackall
Quoted 11 lines · Nick Piggin
I don't know why this would be a useful feature (of course I'm talking about processes at the same nice level). One of the big problems with the current scheduler is that it is unfair in some corner cases. It works OK for most people, but when it breaks down it really hurts. At least if you start with a fair scheduler, you can alter priorities until it satisfies your need... with an unfair one your guess is as good as mine.
So on what basis would you allow unfairness? On the basis that it doesn't seem to harm anyone? It doesn't seem to harm testers?
Quoted 6 lines
On the basis that there's only anecdotal evidence thus far that fairness is the right approach.
It's not yet clear that a fair scheduler can do the right thing with X, with various kernel threads, etc. without fiddling with nice levels. Which makes it no longer "completely fair".
Of course I mean SCHED_OTHER tasks at the same nice level. Otherwise I would be arguing to make nice basically a noop.
Quoted 2 lines
It's also not yet clear that a scheduler can't be taught to do the right thing with X without fiddling with nice levels.
Being fair doesn't prevent that. Implicit unfairness is wrong though, because it will bite people.
What's wrong with allowing X to get more than it's fair share of CPU time by "fiddling with nice levels"? That's what they're there for.
Quoted 5 lines
So I'm just not yet willing to completely rule out systems that aren't "completely fair".
But I think we should rule out schedulers that don't have rigid bounds on that unfairness. That's where the really ugly behavior lies.
Been a while since I really looked at the mainline scheduler, but I don't think it can permanently starve something, so I don't know what your bounded unfairness would help with.
Quoted 8 lines · Nick Piggin
Quoted 2 lines
It's also not yet clear that a scheduler can't be taught to do the right thing with X without fiddling with nice levels.
Being fair doesn't prevent that. Implicit unfairness is wrong though, because it will bite people.
What's wrong with allowing X to get more than it's fair share of CPU time by "fiddling with nice levels"? That's what they're there for.
Why is X special? Because it does work on behalf of other processes? Lots of things do this. Perhaps a scheduler should focus entirely on the implicit and directed wakeup matrix and optimizing that instead[1].
Why are processes special? Should user A be able to get more CPU time for his job than user B by splitting it into N parallel jobs? Should we be fair per process, per user, per thread group, per session, per controlling terminal? Some weighted combination of the preceding?[2]
Why is the measure CPU time? I can imagine a scheduler that weighed memory bandwidth in the equation. Or power consumption. Or execution unit usage.
Fairness is nice. It's simple, it's obvious, it's predictable. But it's just not clear that it's optimal. If the question is (and it was!) "what should the basic requirements for the scheduler be?" it's not clear that fairness is a requirement or even how to pick a metric for fairness that's obviously and uniquely superior.
It's instead much easier to try to recognize and rule out really bad behaviour with bounded latencies, minimum service guarantees, etc.
[1] That's basically how Google decides to prioritize webpages, which it seems to do moderately well. And how a number of other optimization problems are solved.
[2] It's trivial to construct two or more perfectly reasonable and desirable definitions of fairness that are mutually incompatible.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 11 lines · Matt Mackall
Quoted 8 lines · Nick Piggin
Quoted 2 lines
It's also not yet clear that a scheduler can't be taught to do the right thing with X without fiddling with nice levels.
Being fair doesn't prevent that. Implicit unfairness is wrong though, because it will bite people.
What's wrong with allowing X to get more than it's fair share of CPU time by "fiddling with nice levels"? That's what they're there for.
Why is X special? Because it does work on behalf of other processes?
The high level reason is that giving it more than its fair share of CPU allows a desktop to remain interactive under load. And it isn't just about doing work on behalf of other processes. Mouse interrupts are a big part of it, for example.
Quoted 3 lines
Lots of things do this. Perhaps a scheduler should focus entirely on the implicit and directed wakeup matrix and optimizing that instead[1].
You could do that, and I tried a variant of it at one point. The problem was that it leads to unexpected bad things too.
UNIX programs more or less expect fair SCHED_OTHER scheduling, and given the principle of least surprise...
Quoted 4 lines
Why are processes special? Should user A be able to get more CPU time for his job than user B by splitting it into N parallel jobs? Should we be fair per process, per user, per thread group, per session, per controlling terminal? Some weighted combination of the preceding?[2]
I don't know how that supports your argument for unfairness, but processes are special only because that's how we've always done scheduling. I'm not precluding other groupings for fairness, though.
Quoted 3 lines
Why is the measure CPU time? I can imagine a scheduler that weighed memory bandwidth in the equation. Or power consumption. Or execution unit usage.
Feel free. And I'd also argue that once you schedule for those metrics then fairness is also important there too.
Quoted 5 lines
Fairness is nice. It's simple, it's obvious, it's predictable. But it's just not clear that it's optimal. If the question is (and it was!) "what should the basic requirements for the scheduler be?" it's not clear that fairness is a requirement or even how to pick a metric for fairness that's obviously and uniquely superior.
What do you mean optimal? If your criteria is fairness, then of course it is optimal. If your criteria is throughput, then it probably isn't.
Considering it is simple and what we've always done, measuring fairness by CPU time per process is obvious for a general purpose scheduler. If you accept that, then I argue that fairness is an optimal property given that the alternative is unfairness.
Quoted 2 lines
It's instead much easier to try to recognize and rule out really bad behaviour with bounded latencies, minimum service guarantees, etc.
It's the bad behaviour that you didn't recognize that is the problem. If you start with explicit fairness, then unfairness will never be one of those problems.
Quoted 3 lines
[1] That's basically how Google decides to prioritize webpages, which it seems to do moderately well. And how a number of other optimization problems are solved.
This is not an optimization problem, it is a heuristic. There is no right and wrong answer.
Quoted 2 lines
[2] It's trivial to construct two or more perfectly reasonable and desirable definitions of fairness that are mutually incompatible.
Probably not if you use common sense, and in the context of a replacement for the 2.6 scheduler.
Quoted 1 line · Nick Piggin
I don't know how that supports your argument for unfairness,
I never had such an argument. I like fairness.
My argument is that -you- don't have an argument for making fairness a -requirement-.
Quoted 2 lines
processes are special only because that's how we've always done scheduling. I'm not precluding other groupings for fairness, though.
If you make one form of fairness a -requirement- for all acceptable algorithms, your -are- precluding most other forms of fairness.
If you refuse to define what "fairness" means when specifying your requirement, what's the point of requiring it?
Quoted 2 lines
What do you mean optimal? If your criteria is fairness, then of course it is optimal. If your criteria is throughput, then it probably isn't.
I don't know what optimal behavior is. And neither do you. It may or may not be fair. It very likely includes small deviations from fair.
Quoted 5 lines
Quoted 2 lines
[2] It's trivial to construct two or more perfectly reasonable and desirable definitions of fairness that are mutually incompatible.
Probably not if you use common sense, and in the context of a replacement for the 2.6 scheduler.
Ok, trivial example. You cannot allocate equal CPU time to processes/tasks and simultaneously allocate equal time to thread groups. Is it common sense that a heavily-threaded app should be able to get hugely more CPU than a well-written app? No. I don't want Joe's stupid Java app to make my compile crawl.
On the other hand, if my heavily threaded app is, say, a voicemail server serving 30 customers, I probably want it to get 30x the CPU of my gzip job.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 7 lines · Matt Mackall
Quoted 1 line · Nick Piggin
I don't know how that supports your argument for unfairness,
I never had such an argument. I like fairness.
My argument is that -you- don't have an argument for making fairness a -requirement-.
It seems easy enough that there is no point accepting unfair behaviour like the old scheduler if we're going to go to all this trouble to replace it. The old scheduler seems to have bounded unfairness and bounded starvation, so let the good times roll.
Quoted 8 lines
Quoted 2 lines
processes are special only because that's how we've always done scheduling. I'm not precluding other groupings for fairness, though.
If you make one form of fairness a -requirement- for all acceptable algorithms, your -are- precluding most other forms of fairness.
If you refuse to define what "fairness" means when specifying your requirement, what's the point of requiring it?
I don't refuse. I'm talking about per-process CPU time fairness. My paragraph above was pointing out that subsequent work to add other classes of fairness are not excluded as configurable features, but this basic type of fairness should be included.
Quoted 5 lines
Quoted 2 lines
What do you mean optimal? If your criteria is fairness, then of course it is optimal. If your criteria is throughput, then it probably isn't.
I don't know what optimal behavior is. And neither do you. It may or may not be fair. It very likely includes small deviations from fair.
You misunderstand me. There is no single "optimal" when you're talking about fairness (or most other scheduler things). So pondering whether fairness is optimal or not doesn't really make sense.
I'm saying it should be a basic axiom, not that it is quantitively better. It isn't a refutable argument. I state it because that it is what users and programs expect.
You can reject that, and fine. I guess if a scheduler comes along that does exactly the right thing for everyone, then it is better than any fair scheduler. So OK, while we're talking theoretical, I won't dismiss an unfair scheduler out of hand.
Quoted 12 lines
Quoted 5 lines
Quoted 2 lines
[2] It's trivial to construct two or more perfectly reasonable and desirable definitions of fairness that are mutually incompatible.
Probably not if you use common sense, and in the context of a replacement for the 2.6 scheduler.
Ok, trivial example. You cannot allocate equal CPU time to processes/tasks and simultaneously allocate equal time to thread groups. Is it common sense that a heavily-threaded app should be able to get hugely more CPU than a well-written app? No. I don't want Joe's stupid Java app to make my compile crawl.
Quoted 3 lines
On the other hand, if my heavily threaded app is, say, a voicemail server serving 30 customers, I probably want it to get 30x the CPU of my gzip job.
So that might be a nice addition, but the base funcionality is threads simply because that's what we've always done. Just common sense.
Quoted 13 lines · Matt Mackall
Quoted 4 lines · Nick Piggin
Quoted 2 lines
[2] It's trivial to construct two or more perfectly reasonable and desirable definitions of fairness that are mutually incompatible.
Probably not if you use common sense, and in the context of a replacement for the 2.6 scheduler.
Ok, trivial example. You cannot allocate equal CPU time to processes/tasks and simultaneously allocate equal time to thread groups. Is it common sense that a heavily-threaded app should be able to get hugely more CPU than a well-written app? No. I don't want Joe's stupid Java app to make my compile crawl.
Quoted 4 lines
On the other hand, if my heavily threaded app is, say, a voicemail server serving 30 customers, I probably want it to get 30x the CPU of my gzip job.
Matt, you tickled a thought... on one hand we have a single user running a threaded application, and it ideally should get the same total CPU as a user running a single thread process. On the other hand we have a threaded application, call it sendmail, nnrpd, httpd, bind, whatever. In that case each thread is really providing service for an independent user, and should get an appropriate share of the CPU.
Perhaps the solution is to add a means for identifying server processes, by capability, or by membership in a "server" group, or by having the initiating process set some flag at exec() time. That doesn't necessarily solve problems, but it may provide more information to allow them to be soluble.
Signature · 3 lines
Bill Davidsen <[email protected]> "We have more to fear from the bungling of the incompetent than from the machinations of the wicked." - from Slashdot
Quoted 4 lines · Matt Mackall
Why are processes special? Should user A be able to get more CPU time for his job than user B by splitting it into N parallel jobs? Should we be fair per process, per user, per thread group, per session, per controlling terminal? Some weighted combination of the preceding?[2]
On a side note, I think a combination of all of the above is a very good idea, plus process groups (pgrp's). All the make -j loads should come up in one pgrp of one session for one user and hence should be automatically kept isolated in its own corner by such policies. Thread bombs, forkbombs, and so on get handled too, which is good when on e.g. a compileserver and someone rudely spawns too many tasks.
Thinking of the scheduler as a CPU bandwidth allocator, this means handing out shares of CPU bandwidth to all users on the system, which in turn hand out shares of bandwidth to all sessions, which in turn hand out shares of bandwidth to all process groups, which in turn hand out shares of bandwidth to all thread groups, which in turn hand out shares of bandwidth to threads. The event handlers for the scheduler need not deal with this apart from task creation and exit and various sorts of process ID changes (e.g. setsid(), setpgrp(), setuid(), etc.). They just determine what the scheduler sees as ->load_weight or some analogue of ->static_prio, though it is possible to do this by means of data structure organization instead of numerical prioritization. It'd probably have to be calculated on the fly by, say, doing fixpoint arithmetic something like
user_share(p)*session_share(p)*pgrp_share(p)*tgrp_share(p)*task_share(p)
so that readjusting the shares of aggregates doesn't have to traverse lists and remains O(1). Each of the share computations can instead just do some analogue of the calculation p->load_weight/rq->raw_weighted_load in fixpoint, though precision issues with this make me queasy. There is maybe a slight nasty point in that the ->raw_weighted_load analogue for users or whatever the highest level chosen is ends up being global. One might as well get users in there and omit intermediate levels if any are to be omitted so that the truly global state is as read-only as possible.
I suppose jacking up the fixpoint precision to 128-bit or 256-bit all below the radix point (our max is 1.0 after all) until precision issues vanish can be done but the idea of that much number crunching in the scheduler makes me rather uncomfortable. I hope u64 or u32 [2] can be gotten away with as far as fixpoint goes.
-- wli
Quoted 8 lines · William Lee Irwin III
Thinking of the scheduler as a CPU bandwidth allocator, this means handing out shares of CPU bandwidth to all users on the system, which in turn hand out shares of bandwidth to all sessions, which in turn hand out shares of bandwidth to all process groups, which in turn hand out shares of bandwidth to all thread groups, which in turn hand out shares of bandwidth to threads. The event handlers for the scheduler need not deal with this apart from task creation and exit and various sorts of process ID changes (e.g.
setsid(),setpgrp(),setuid(), etc.).
Yes, it really becomes a hierarchical problem once you consider user and processes. Top level sees a "user" can be scheduled (put itself on the virtual run queue), and passes the ball to the "process" scheduler inside the "user" container, down to maybe "threads". With all the "key" calculation parameters kept at each level (with up-propagation).
- Davide
Quoted 5 lines · Matt Mackall
Why is X special? Because it does work on behalf of other processes? Lots of things do this. Perhaps a scheduler should focus entirely on the implicit and directed wakeup matrix and optimizing that instead[1].
I 100% agree - the perfect scheduler would indeed take into account where the wakeups come from, and try to "weigh" processes that help other processes make progress more. That would naturally give server processes more CPU power, because they help others
I don't believe for a second that "fairness" means "give everybody the same amount of CPU". That's a totally illogical measure of fairness. All processes are _not_ created equal.
That said, even trying to do "fairness by effective user ID" would probably already do a lot. In a desktop environment, X would get as much CPU time as the user processes, simply because it's in a different protection domain (and that's really what "effective user ID" means: it's not about "users", it's really about "protection domains").
And "fairness by euid" is probably a hell of a lot easier to do than trying to figure out the wakeup matrix.
Linus
Quoted 2 lines · Linus Torvalds
And "fairness by euid" is probably a hell of a lot easier to do than trying to figure out the wakeup matrix.
For the record, you actually don't need to track a whole NxN matrix (or do the implied O(n**3) matrix inversion!) to get to the same result. You can converge on the same node weightings (ie dynamic priorities) by applying a damped function at each transition point (directed wakeup, preemption, fork, exit).
The trouble with any scheme like this is that it needs careful tuning of the damping factor to converge rapidly and not oscillate and precise numerical attention to the transition functions so that the sum of dynamic priorities is conserved.
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 8 lines · Matt Mackall
Quoted 2 lines · Linus Torvalds
And "fairness by euid" is probably a hell of a lot easier to do than trying to figure out the wakeup matrix.
For the record, you actually don't need to track a whole NxN matrix (or do the implied
O(n**3)matrix inversion!) to get to the same result.
I'm sure you can do things differently, but the reason I think "fairness by euid" is actually worth looking at is that it's pretty much the *identical* issue that we'll have with "fairness by virtual machine" and a number of other "container" issues.
The fact is:
- "fairness" is *not* about giving everybody the same amount of CPU time (scaled by some niceness level or not). Anybody who thinks that is "fair" is just being silly and hasn't thought it through.
- "fairness" is multi-level. You want to be fair to threads within a thread group (where "process" may be one good approximation of what a "thread group" is, but not necessarily the only one).
But you *also* want to be fair in between those "thread groups", and then you want to be fair across "containers" (where "user" may be one such container).
So I claim that anything that cannot be fair by user ID is actually really REALLY unfair. I think it's absolutely humongously STUPID to call something the "Completely Fair Scheduler", and then just be fair on a thread level. That's not fair AT ALL! It's the anti-thesis of being fair!
So if you have 2 users on a machine running CPU hogs, you should *first* try to be fair among users. If one user then runs 5 programs, and the other one runs just 1, then the *one* program should get 50% of the CPU time (the users fair share), and the five programs should get 10% of CPU time each. And if one of them uses two threads, each thread should get 5%.
So you should see one thread get 50& CPU (single thread of one user), 4 threads get 10% CPU (their fair share of that users time), and 2 threads get 5% CPU (the fair share within that thread group!).
Any scheduling argument that just considers the above to be "7 threads total" and gives each thread 14% of CPU time "fairly" is *anything* but fair. It's a joke if that kind of scheduler then calls itself CFS!
And yes, that's largely what the current scheduler will do, but at least the current scheduler doesn't claim to be fair! So the current scheduler is a lot *better* if only in the sense that it doesn't make ridiculous claims that aren't true!
Linus
Quoted 5 lines · Linus Torvalds
The fact is:
- "fairness" is *not* about giving everybody the same amount of CPU time (scaled by some niceness level or not). Anybody who thinks that is "fair" is just being silly and hasn't thought it through.
yeah, very much so.
But note that most of the reported CFS interactivity wins, as surprising as it might be, were due to fairness between _the same user's tasks_. In the typical case, 99% of the desktop CPU time is executed either as X (root user) or under the uid of the logged in user, and X is just one task. Even with a bad hack of making X super-high-prio, interactivity as experienced by users still sucks without having fairness between the other 100-200 user tasks that a desktop system is typically using.
'renicing X to -10' is a broken way of achieving: 'root uid should get its share of CPU time too, no matter how many user tasks are running'. We can do this much cleaner by saying: 'each uid, if it has any tasks running, should get its fair share of CPU time, independently of the number of tasks it is running'.
In that sense 'fairness' is not global (and in fact it is almost _never_ a global property, as X runs under root uid [*]), it is only the most lowlevel scheduling machinery that can then be built upon. Higher-level controls to allocate CPU power between groups of tasks very much make sense - but according to the CFS interactivity test results i got from people so far, they very much need this basic fairness machinery _within_ the uid group too. So 'fairness' is still a powerful lower level scheduling concept. And this all makes lots of sense to me.
One purpose of doing the hierarchical scheduling classes stuff was to enable such higher scope task group decisions too. Next i'll try to figure out whether 'task group bandwidth' logic should live right within sched_fair.c itself, or whether it should be layered separately as a sched_group.c. Intutively i'd say it should live within sched_fair.c.
Ingo
[*] There are distributions where X does not run under root uid anymore.
Quoted 4 lines · Ingo Molnar
In that sense 'fairness' is not global (and in fact it is almost _never_ a global property, as X runs under root uid [*]), it is only the most lowlevel scheduling machinery that can then be built upon. [...]
perhaps a more fitting term would be 'precise group-scheduling'. Within the lowest level task group entity (be that thread group or uid group, etc.) 'precise scheduling' is equivalent to 'fairness'.
Ingo
Quoted 4 lines · Ingo Molnar
perhaps a more fitting term would be 'precise group-scheduling'. Within the lowest level task group entity (be that thread group or uid group, etc.) 'precise scheduling' is equivalent to 'fairness'.
Yes. Absolutely. Except I think that at least if you're going to name somethign "complete" (or "perfect" or "precise"), you should also admit that groups can be hierarchical.
The "threads in a process" thing is a great example of a hierarchical group. Imagine if X was running as a collection of threads - then each server thread would no longer be more important than the clients! But if you have a mix of "bags of threads" and "single process" kind applications, then very arguably the single thread in a single traditional process should get as much time as the "bag of threads" process gets total.
So it really should be a hierarchical notion, where each thread is owned by one "process", and each process is owned by one "user", and each user is in one "virtual machine" - there's at least three different levels to this, and you'd want to schedule this thing top-down: virtual machines should be given CPU time "fairly" (which doesn't need to mean "equally", of course - nice-values could very well work at that level too), and then within each virtual machine users or "scheduling groups" should be scheduled fairly, and then within each scheduling group the processes should be scheduled, and within each process threads should equally get their fair share at _that_ level.
And no, I don't think we necessarily need to do something quite that elaborate. But I think that's the kind of "obviously good goal" to keep in mind. Can we perhaps _approximate_ something like that by other means?
For example, maybe we can approximate it by spreading out the statistics:
right now you have things like
- last_ran, wait_runtime, sum_wait_runtime..
be per-thread things. Maybe some of those can be spread out, so that you put a part of them in the "struct vm_struct" thing (to approximate processes), part of them in the "struct user" struct (to approximate the user-level thing), and part of it in a per-container thing for when/if we support that kind of thing?
IOW, I don't think the scheduling "groups" have to be explicit boxes or anything like that. I suspect you can make do with just heurstics that penalize the same "struct user" and "struct vm_struct" to get overly much scheduling time, and you'll get the same _effect_.
And I don't think it's wrong to look at the "one hundred processes by the same user" case as being an important case. But it should not be the *only* case or even necessarily the *main* case that matters. I think a benchmark that literally does
pid_t pid = fork();
if (pid < 0)
exit(1);
if (pid) {
if (setuid(500) < 0)
exit(2);
for (;;)
/* Do nothing */;
}
if (setuid(501) < 0)
exit(3);
fork();
for (;;)
/* Do nothing in two processes */;and I think that it's a really valid benchmark: if the scheduler gives 25% of time to each of the two processes of user 501, and 50% to user 500, then THAT is a good scheduler.
If somebody wants to actually write and test the above as a test-script, and add it to a collection of scheduler tests, I think that could be a good thing.
Linus
Quoted 6 lines · Linus Torvalds
For example, maybe we can approximate it by spreading out the
statistics: right now you have things like-
last_ran,wait_runtime,sum_wait_runtime..be per-thread things. [...]
yes, yes, yes! :) My thinking is "struct sched_group" embedded into _arbitrary_ other resource containers and abstractions, which sched_group's are then in a simple hierarchy and are driven by the core scheduling machinery.
Quoted 5 lines
[...] Maybe some of those can be spread out, so that you put a part of them in the "struct
vm_struct" thing (to approximate processes), part of them in the "struct user" struct (to approximate the user-level thing), and part of it in a per-container thing for when/if we support that kind of thing?
yes.
Ingo
Quoted 10 lines · Linus Torvalds
For example, maybe we can approximate it by spreading out the statistics:
right now you have things like-
last_ran,wait_runtime,sum_wait_runtime..be per-thread things. Maybe some of those can be spread out, so that you put a part of them in the "struct
vm_struct" thing (to approximate processes), part of them in the "struct user" struct (to approximate the user-level thing), and part of it in a per-container thing for when/if we support that kind of thing?
I think Ingo's idea of a new sched_group to contain the generic parameters needed for the "key" calculation, works better than adding more fields to existing strctures (that would, of course, host pointers to it). Otherwise I can already the the struct_signal being the target for other unrelated fields :)
- Davide
Quoted 5 lines · Davide Libenzi
I think Ingo's idea of a new
sched_groupto contain the generic parameters needed for the "key" calculation, works better than adding more fields to existing strctures (that would, of course, host pointers to it). Otherwise I can already the thestruct_signalbeing the target for other unrelated fields :)
yeah. Another detail is that for global containers like uids, the statistics will have to be percpu_alloc()-ed, both for correctness (runqueues are per CPU) and for performance.
That's one reason why i dont think it's necessarily a good idea to group-schedule threads, we dont really want to do a per thread group percpu_alloc().
In fact for threads the _reverse_ problem exists, threaded apps tend to _strive_ for more performance - hence their desperation of using the threaded programming model to begin with ;) (just think of media playback apps which are typically multithreaded)
I dont think threads are all that different. Also, the resource-conserving act of using CLONE_VM to share the VM (and to use a different programming environment like Java) should not be 'punished' by forcing the thread group to be accounted as a single, shared entity against other 'fat' tasks.
so my current impression is that we want per UID accounting to solve the X problem, the kernel threads problem and the many-users problem, but i'd not want to do it for threads just yet because for them there's not really any apparent problem to be solved.
Ingo
Quoted 3 lines · Ingo Molnar
That's one reason why i dont think it's necessarily a good idea to group-schedule threads, we dont really want to do a per thread group
percpu_alloc().
I still do not have clear how much overhead this will bring into the table, but I think (like Linus was pointing out) the hierarchy should look like:
Top (VCPU maybe?)
User
Process
Thread
The "run_queue" concept (and data) that now is bound to a CPU, need to be replicated in:
ROOT <- VCPUs add themselves here
VCPU <- USERs add themselves here
USER <- PROCs add themselves here
PROC <- THREADs add themselves here
THREAD (ultimate fine grained scheduling unit)
So ROOT, VCPU, USER and PROC will have their own "run_queue". Picking up a new task would mean:
VCPU = ROOT->lookup();
USER = VCPU->lookup();
PROC = USER->lookup();
THREAD = PROC->lookup();
Run-time statistics should propagate back the other way around.
Quoted 4 lines
In fact for threads the _reverse_ problem exists, threaded apps tend to _strive_ for more performance - hence their desperation of using the threaded programming model to begin with ;) (just think of media playback apps which are typically multithreaded)
The same user nicing two different multi-threaded processes would expect a predictable CPU distribution too. Doing that efficently (the old per-cpu run-queue is pretty nice from many POVs) is the real challenge.
- Davide
Quoted 25 lines · Davide Libenzi
Quoted 3 lines
That's one reason why i dont think it's necessarily a good idea to group-schedule threads, we dont really want to do a per thread group
percpu_alloc().I still do not have clear how much overhead this will bring into the table, but I think (like Linus was pointing out) the hierarchy should look like:
Top (VCPU maybe?)
User
Process
ThreadThe "
run_queue" concept (and data) that now is bound to a CPU, need to be replicated in:ROOT <- VCPUs add themselves here
VCPU <- USERs add themselves here
USER <- PROCs add themselves here
PROC <- THREADs add themselves here
THREAD (ultimate fine grained scheduling unit)So ROOT, VCPU, USER and PROC will have their own "
run_queue". Picking up a new task would mean:
Quoted 6 lines
VCPU =
ROOT->lookup();
USER =VCPU->lookup();
PROC =USER->lookup();
THREAD =PROC->lookup();Run-time statistics should propagate back the other way around.
yeah, but this looks quite bad from an overhead POV ... i think we can do alot simpler to solve X and kernel threads prioritization.
Quoted 7 lines
Quoted 4 lines
In fact for threads the _reverse_ problem exists, threaded apps tend to _strive_ for more performance - hence their desperation of using the threaded programming model to begin with ;) (just think of media playback apps which are typically multithreaded)
The same user nicing two different multi-threaded processes would expect a predictable CPU distribution too. [...]
i disagree that the user 'would expect' this. Some users might. Others would say: 'my 10-thread rendering engine is more important than a 1-thread job because it's using 10 threads for a reason'. And the CFS feedback so far strengthens this point: the default behavior of treating the thread as a single scheduling (and CPU time accounting) unit works pretty well on the desktop.
think about it in another, 'kernel policy' way as well: we'd like to _encourage_ more parallel user applications. Hurting them by accounting all threads together sends the exact opposite message.
Quoted 2 lines
[...] Doing that efficently (the old per-cpu run-queue is pretty nice from many POVs) is the real challenge.
yeah.
Ingo
Quoted 10 lines · Ingo Molnar
i disagree that the user 'would expect' this. Some users might. Others would say: 'my 10-thread rendering engine is more important than a 1-thread job because it's using 10 threads for a reason'. And the CFS feedback so far strengthens this point: the default behavior of treating the thread as a single scheduling (and CPU time accounting) unit works pretty well on the desktop.
think about it in another, 'kernel policy' way as well: we'd like to _encourage_ more parallel user applications. Hurting them by accounting all threads together sends the exact opposite message.
There are counter argouments too. Like, not every user knows if a certain process is MT or not. I agree though that doing accounting and fairness at a depth lower then USER is messy, and not only for performance.
- Davide
Quoted 6 lines · Ingo Molnar
Quoted 1 line · Davide Libenzi
The same user nicing two different multi-threaded processes would expect a predictable CPU distribution too. [...]
i disagree that the user 'would expect' this. Some users might. Others would say: 'my 10-thread rendering engine is more important than a 1-thread job because it's using 10 threads for a reason'. And the CFS feedback so far strengthens this point: the default behavior of treating the thread as a single scheduling (and CPU time accounting) unit works pretty well on the desktop.
If by desktop you mean "one and only one interactive user," that's true. On a shared machine it's very hard to preserve any semblance of fairness when one user gets far more than another, based not on the value of what they're doing but the tools they use to to it.
Quoted 2 lines
think about it in another, 'kernel policy' way as well: we'd like to _encourage_ more parallel user applications. Hurting them by accounting all threads together sends the exact opposite message.
Why is that? There are lots of things which are intrinsically single threaded, how are we hurting hurting multi-threaded applications by refusing to give them more CPU than an application running on behalf of another user? By accounting all threads together we encourage writing an application in the most logical way. Threads are a solution, not a goal in themselves.
Quoted 5 lines
Quoted 1 line
[...] Doing that efficently (the old per-cpu run-queue is pretty nice from many POVs) is the real challenge.
yeah.
Ingo
Signature · 3 lines
Bill Davidsen <[email protected]> "We have more to fear from the bungling of the incompetent than from the machinations of the wicked." - from Slashdot
Quoted 4 lines · In article <[email protected]> you…
Top (VCPU maybe?)
User
Process
Thread
The problem with that is, that not all Schedulers might work on the User level. You can think of Batch/Job, Parent, Group, Session or namespace level. That would be IMHO a generic Top, with no need for a level above.
Greetings
Bernd
Quoted 4 lines · Ingo Molnar
so my current impression is that we want per UID accounting to solve the X problem, the kernel threads problem and the many-users problem, but i'd not want to do it for threads just yet because for them there's not really any apparent problem to be solved.
If you really mean UID vs EUID as Linus mentioned, I suppose I could learn to login as !root, and set KDE up to always give me root shells.
With a heavily reniced X (perfectly fine), that should indeed solve my daily usage pattern nicely (always need godmode for shells, but not for mozilla and ilk. 50/50 split automatic without renice of entire gui)
-Mike
Quoted 4 lines · Mike Galbraith
With a heavily reniced X (perfectly fine), that should indeed solve my daily usage pattern nicely (always need godmode for shells, but not for mozilla and ilk. 50/50 split automatic without renice of entire gui)
how about the first-approximation solution i suggested in the previous
mail: to add a per UID default nice level? (With this default defaulting to '-10' for all root-owned processes, and defaulting to '0' for everything else.) That would solve most of the current CFS regressions at hand.
Ingo
Quoted 7 lines · Ingo Molnar
Quoted 4 lines · Mike Galbraith
With a heavily reniced X (perfectly fine), that should indeed solve my daily usage pattern nicely (always need godmode for shells, but not for mozilla and ilk. 50/50 split automatic without renice of entire gui)
Quoted 5 lines
how about the first-approximation solution i suggested in the previous
mail: to add a per UID default nice level? (With this default defaulting to '-10' for all root-owned processes, and defaulting to '0' for everything else.) That would solve most of the current CFS regressions at hand.
That would make my kernel builds etc interfere with my other self's surfing and whatnot. With it by EUID, when I'm surfing or whatnot, the X portion of my Joe-User activity pushes the compile portion of root down in bandwidth utilization automagically, which is exactly the right thing, because the root me in not as important as the Joe-User me using the GUI at that time. If the idea of X disturbing root upsets some, they can move X to another UID. Generally, it seems perfect for here.
-Mike
Quoted 14 lines · Mike Galbraith
Quoted 7 lines · Ingo Molnar
Quoted 4 lines · Mike Galbraith
With a heavily reniced X (perfectly fine), that should indeed solve my daily usage pattern nicely (always need godmode for shells, but not for mozilla and ilk. 50/50 split automatic without renice of entire gui)
Quoted 5 lines
how about the first-approximation solution i suggested in the previous
mail: to add a per UID default nice level? (With this default defaulting to '-10' for all root-owned processes, and defaulting to '0' for everything else.) That would solve most of the current CFS regressions at hand.
Quoted 7 lines
That would make my kernel builds etc interfere with my other self's surfing and whatnot. With it by EUID, when I'm surfing or whatnot, the X portion of my Joe-User activity pushes the compile portion of root down in bandwidth utilization automagically, which is exactly the right thing, because the root me in not as important as the Joe-User me using the GUI at that time. If the idea of X disturbing root upsets some, they can move X to another UID. Generally, it seems perfect for here.
Now guys, I did not follow the whole lengthy and feisty thread, but IIRC Con's scheduler has been attacked because, among other argouments, was requiring X to be reniced. This happened like a month ago IINM. I did not have time to look at Con's scheduler, and I only had a brief look at Ingo's one (looks very promising IMO, but so was the initial O(1) post before all the corner-cases fixes went in).
But this is not a about technical merit, this is about applying the same rules of judgement to others as well to ourselves.
We went from a "renicing X to -10 is bad because the scheduler should be able to correctly handle the problem w/out additional external plugs" to a totally opposite "let's renice -10 X, the whole SCHED_NORMAL kthreads class, on top of all the tasks owned by root" [1].
Quoted 1 line
From a spectator POV like myself in this case, this looks rather "unfair".
[1] I think, before and now, that that's more a duck tape patch than a real solution. OTOH if the "solution" is gonna be another maze of macros and heuristics filled with pretty bad corner cases, I may prefer the former.
- Davide
Quoted 24 lines · Davide Libenzi
Quoted 14 lines · Mike Galbraith
Quoted 7 lines · Ingo Molnar
Quoted 4 lines · Mike Galbraith
With a heavily reniced X (perfectly fine), that should indeed solve my daily usage pattern nicely (always need godmode for shells, but not for mozilla and ilk. 50/50 split automatic without renice of entire gui)
Quoted 5 lines
how about the first-approximation solution i suggested in the previous
mail: to add a per UID default nice level? (With this default defaulting to '-10' for all root-owned processes, and defaulting to '0' for everything else.) That would solve most of the current CFS regressions at hand.Quoted 7 lines
That would make my kernel builds etc interfere with my other self's surfing and whatnot. With it by EUID, when I'm surfing or whatnot, the X portion of my Joe-User activity pushes the compile portion of root down in bandwidth utilization automagically, which is exactly the right thing, because the root me in not as important as the Joe-User me using the GUI at that time. If the idea of X disturbing root upsets some, they can move X to another UID. Generally, it seems perfect for here.
Quoted 3 lines
Now guys, I did not follow the whole lengthy and feisty thread, but IIRC Con's scheduler has been attacked because, among other argouments, was requiring X to be reniced. This happened like a month ago IINM.
I don't object to renicing X if you want it to receive _more_ than it's fair share. I do object to having to renice X in order for it to _get_ it's fair share. That's what I attacked.
Quoted 5 lines
I did not have time to look at Con's scheduler, and I only had a brief look at Ingo's one (looks very promising IMO, but so was the initial O(1) post before all the corner-cases fixes went in).
But this is not a about technical merit, this is about applying the same rules of judgement to others as well to ourselves.
I'm running the same tests with CFS that I ran for RSDL/SD. It falls short in one key area (to me) in that X+client cannot yet split my box 50/50 with two concurrent tasks. In the CFS case, renicing both X and client does work, but it should not be necessary IMHO. With RSDL/SD renicing didn't help.
Quoted 5 lines
We went from a "renicing X to -10 is bad because the scheduler should be able to correctly handle the problem w/out additional external plugs" to a totally opposite "let's renice -10 X, the whole
SCHED_NORMALkthreads class, on top of all the tasks owned by root" [1].Quoted 1 line
From a spectator POV like myself in this case, this looks rather "unfair".
Well, for me, the renicing I mentioned above is only interesting as a way to improve long term fairness with schedulers with no history.
I found Linus' EUID idea intriguing in that by putting the server together with a steady load in one 'fair' domain, and clients in another, X can, if prioritized to empower it to do so, modulate the steady load in it's domain (but can't starve it!), the clients modulate X, and the steady load gets it all when X and clients are idle. The nice level of X determines to what _extent_ X can modulate the constant load rather like a mixer slider. The synchronous (I'm told) nature of X/client then becomes kind of an asset to the desktop instead of a liability.
The specific case I was thinking about is the X+Gforce test where both RSDL and CFS fail to provide fairness (as defined by me;). X and Gforce are mostly not concurrent. The make -j2 I put them up against are mostly concurrent. I don't call giving 1/3 of my CPU to X+Client fair at _all_, but that's what you'll get if your fairstick of the instant generally can't see the fourth competing task. Seemed pretty cool to me because it creates the missing connection between client and server, though also likely complicated (and maybe full of perils, who knows).
-Mike
Quoted 7 lines · Mike Galbraith
Quoted 4 lines · Ingo Molnar
so my current impression is that we want per UID accounting to solve the X problem, the kernel threads problem and the many-users problem, but i'd not want to do it for threads just yet because for them there's not really any apparent problem to be solved.
Quoted 6 lines
If you really mean UID vs EUID as Linus mentioned, I suppose I could learn to login as !root, and set KDE up to always give me root shells.
With a heavily reniced X (perfectly fine), that should indeed solve my daily usage pattern nicely (always need godmode for shells, but not for mozilla and ilk. 50/50 split automatic without renice of entire gui)
Backward, needs to be EUID as Linus suggested. Kernel builds etc along with reniced X in root's bucket, surfing and whatnot in Joe-User's bucket.
-Mike
Quoted 7 lines · Linus Torvalds
Quoted 3 lines
perhaps a more fitting term would be 'precise group-scheduling'. Within the lowest level task group entity (be that thread group or uid group, etc.) 'precise scheduling' is equivalent to 'fairness'.
Yes. Absolutely. Except I think that at least if you're going to name somethign "complete" (or "perfect" or "precise"), you should also admit that groups can be hierarchical.
yes. Am i correct to sum up your impression as:
" Ingo, for you the hierarchy still appears to be an after-thought,
while in practice it's easily the most important thing! Why are you so hung up about 'fairness', it makes no sense!"
right?
and you would definitely be right if you suggested that i neglected the 'group scheduling' aspects of CFS (except for a minimalistic nice level implementation, which is a poor-man's-non-automatic-group-scheduling), but i very much know its important and i'll definitely fix it for -v4.
But please let me explain my reasons for my different focus:
yes, group scheduling in practice is the most important first-layer thing, and without it any of the other 'CFS wins' can easily be useless.
Firstly, i have not neglected the group scheduling related CFS regressions at all, mainly because there _is_ already a quick hack to check whether group scheduling would solve these regressions: renice. And it was tried in both of the two CFS regression cases i'm aware of:
Mike's X starvation problem and Willy's "kevents starvation with thousands of scheddos tasks running" problem. And in both cases, applying the renice hack [which should be properly and automatically implemented as uid group scheduling] fixed the regression for them! So i was not worried at all, group scheduling _provably solves_ these CFS regressions. I rather concentrated on the CFS regressions that were much less clear.
But PLEASE believe me: even with perfect cross-group CPU allocation but with a simple non-heuristic scheduler underlying it, you can _easily_ get a sucky desktop experience! I know it because i tried it and others tried it too. (in fact the first version of sched_fair.c was tick based and low-res, and it sucked)
Two more things were needed:
- the high precision of nsec/64-bit accounting
('reliability of scheduling')
- extremely even time-distribution of CPU power
('determinism/smoothness, human perception')
(i'm expanding on these two concepts further below)
take out any of these and group scheduling or not, you are easily going to have a sucky desktop! (We know that from years of experiments: many people tried to rip out the unfairness from the scheduler and there were always nasty corner cases that 'should' have worked but didnt.)
Without these we'd in essence start again at square one, just at a different square, this time with another group of people being irritated!
But the biggest and hardest to achieve _wins_ of CFS are _NOT_ achieved via a simple 'get rid of the unfairness of the upstream scheduler and apply group scheduling'. (I know that because i tried it before and because others tried it before, for many many years.) You will _easily_ get sucky desktop experience. The other two things are very much needed too:
- the high precision of nsec/64-bit accounting, and the many corner-cases this solves. (For example on a typical desktop there are _lots_ of timing-driven workloads that are in essence 'invisible' to low-resolution, timer-tick based accounting and are heavily skewed.)
- extremely even time-distribution of CPU power. CFS behaves pretty well even under the dreaded 'make -jN in an xterm' kernel build workload as reported by Mark Lord, because it also distributes CPU power in a _finegrained_ way. A shell prompt under CFS still behaves acceptably on a single-CPU testbox of mine with a "make -j50" workload. (yes, fifty) Humans react alot more negatively to sudden changes in application behavior ('lags', pauses, short hangs) than they react to fine, gradual, all-encompassing slowdowns. This is a key property of CFS.
( Otherwise renicing X to -10 would have solved most of the
interactivity complaints against the vanilla scheduler, otherwise renicing X to -10 would have fixed Mike's setup under SD (it didnt) while it worked much better under CFS, otherwise Gene wouldnt have found CFS markedly better than SD, etc., etc. So getting rid of the heuristics is less than 50% of the road to the perfect desktop scheduler. )
and i claim that these were the really hard bits, and i spent most of the CFS coding only on getting _these_ details 100% right under various workloads, and it makes a night and day difference _even without any group scheduling help_.
and note another reason here: group scheduling _masks_ many other scheduling deficiencies that are possible in scheduler. So since CFS doesnt do group scheduling, i get a _fuller_ picture of the behavior of the core "precise scheduling" engine. At the initial stage i didnt want to hide bugs by masking them via group scheduling, especially because the renice workaround/hack was available.
Guess how nice it all will get if we also add group scheduling to the mix, and people wouldnt have to add nasty and fragile renice based hacks, it will 'just work' out of box?
Ingo
Quoted 3 lines · Ingo Molnar
But note that most of the reported CFS interactivity wins, as surprising as it might be, were due to fairness between
_thesame user'stasks_.
And *ALL* of the CFS interactivity *losses* and complaints have been because it did the wrong thing _between different user's tasks_
So what's your point? Your point was that when people try it out as a single user, it is indeed fair. But that's no point at all, since it totally missed _my_ point.
The problems with X scheduling is exactly that "other user" kind of thing.
The problem with kernel thread starvation due to user threads getting all the CPU time is exactly the same issue.
As logn as you think that all threads are equal, and should be treated equally, you CANNOT make it work well. People can say "ok, you can renice X", but the whole problem stems from the fact that you're trying to be fair based on A TOTALLY INVALID NOTION of what "fair" is.
Quoted 3 lines
In the typical case, 99% of the desktop CPU time is executed either as X (root user) or under the uid of the logged in user, and X is just one task.
So? You are ignoring the argument again. You're totally bringing up a red herring:
Quoted 3 lines
Even with a bad hack of making X super-high-prio, interactivity as experienced by users still sucks without having fairness between the other 100-200 user tasks that a desktop system is typically using.
I didn't say that you should be *unfair* within one user group. What kind of *idiotic* argument are you trying to put forth?
OF COURSE you should be fair "within the user group". Nobody contests that the "other 100-200 user tasks" should be scheduled fairly _amongst themselves_.
The only point I had was that you cannot just lump all threads together and say "these threads are equally important". The 100-200 user tasks may be equally important, and should get equal amounts of preference, but that has absolutely _zero_ bearing on the _single_ task run in another "scheduling group", ie by other users or by X.
I'm not arguing against fairness. I'm arguing against YOUR notion of fairness, which is obviously bogus. It is *not* fair to try to give out CPU time evenly!
Linus
Quoted 3 lines · Linus Torvalds
I'm not arguing against fairness. I'm arguing against YOUR notion of fairness, which is obviously bogus. It is *not* fair to try to give out CPU time evenly!
"Perhaps on the rare occasion pursuing the right course demands an act of
unfairness, unfairness itself can be the right course?"
- Davide
Quoted 3 lines · Davide Libenzi
"Perhaps on the rare occasion pursuing the right course demands an act of
unfairness, unfairness itself can be the right course?"
I don't think that's the right issue.
It's just that "fairness" != "equal".
Do you think it "fair" to pay everybody the same regardless of how good a job they do? I don't think anybody really believes that.
Equating "fair" and "equal" is simply a very fundamental mistake. They're not the same thing. Never have been, and never will.
Now, there's no question that "equal" is much easier to implement, if only because it's a lot easier to agree what it means. "Equal parts" is somethign everybody can agree on. "Fair parts" automatically involves a balancing act, and people will invariably count things differently and thus disagree about what is "fair" and what is not.
I don't think we can ever get a "perfect" setup for that reason, but I think we can get something that at least gets reasonably close, at least for the obvious cases.
So my suggested test-case of running one process as one user and two processes as another one has a fairly "obviously correct" solution if you have just one CPU's, and you can probably be pretty fair in practice on two CPU's (there's an obvious theoretical solution, whether you can get there with a practical algorithm is another thing). On three or more CPU's, you obviously wouldn't even *want* to be fair, since you can very naturally just give a CPU to each..
Linus
Quoted 7 lines · Linus Torvalds
Quoted 3 lines · Davide Libenzi
"Perhaps on the rare occasion pursuing the right course demands an act of
unfairness, unfairness itself can be the right course?"I don't think that's the right issue.
Quoted 7 lines
It's just that "fairness" != "equal".
Do you think it "fair" to pay everybody the same regardless of how good a job they do? I don't think anybody really believes that.
Equating "fair" and "equal" is simply a very fundamental mistake. They're not the same thing. Never have been, and never will.
I know, we agree there. But that did not fit my "Pirates of the Caribbean" quote :)
- Davide
Quoted 2 lines · Davide Libenzi
I know, we agree there. But that did not fit my "Pirates of the Caribbean" quote :)
Ahh, I'm clearly not cultured enough, I didn't catch that reference.
Linus "yes, I've seen the movie, but it
apparently left more of a mark in other people" Torvalds
Quoted 7 lines · Linus Torvalds
So I claim that anything that cannot be fair by user ID is actually really REALLY unfair. I think it's absolutely humongously STUPID to call something the "Completely Fair Scheduler", and then just be fair on a thread level. That's not fair AT ALL! It's the anti-thesis of being fair! So if you have 2 users on a machine running CPU hogs, you should *first* try to be fair among users. If one user then runs 5 programs, and the other one runs just 1, then the *one* program should get 50% of the CPU
Quoted 8 lines
time (the users fair share), and the five programs should get 10% of CPU time each. And if one of them uses two threads, each thread should get 5%. So you should see one thread get 50& CPU (single thread of one user), 4 threads get 10% CPU (their fair share of that users time), and 2 threads get 5% CPU (the fair share within that thread group!).
Any scheduling argument that just considers the above to be "7 threads total" and gives each thread 14% of CPU time "fairly" is *anything* but fair. It's a joke if that kind of scheduler then calls itself CFS!
I don't think it's completely fair [sic] to come down on it that hard. It does largely achieve the sort of fairness it set out for itself as its design goal. One should also note that the queueing mechanism is more than flexible enough to handle prioritization by a number of different methods, and the large precision of its priorities is useful there. So a rather broad variety of policies can be implemented by changing the ->fair_key calculations.
In some respects, the vast priority space and very high clock precision are two of its most crucial advantages.
Quoted 4 lines · Linus Torvalds
And yes, that's largely what the current scheduler will do, but at least the current scheduler doesn't claim to be fair! So the current scheduler is a lot *better* if only in the sense that it doesn't make ridiculous claims that aren't true!
The name chosen was somewhat buzzwordy. I'd have named it something more descriptive of the algorithm, though what's implemented in the current dynamic priority (i.e. ->fair_key) calculations are somewhat difficult to precisely categorize.
-- wli
Quoted 6 lines · William Lee Irwin III
It does largely achieve the sort of fairness it set out for itself as its design goal. One should also note that the queueing mechanism is more than flexible enough to handle prioritization by a number of different methods, and the large precision of its priorities is useful there. So a rather broad variety of policies can be implemented by changing the ->fair_key calculations.
yeah. Note that i concentrated on the bit that makes the largest interactivity improvement: to implement "precise scheduling" (a'ka complete fairness) between the 100+ user tasks that do a complex scheduling dance on a typical desktop on various workloads.
Ingo
Quoted 6 lines · On Wed, 18 Apr 2007 10:22:59 -0700 (PDT) Linus Torvalds…
So if you have 2 users on a machine running CPU hogs, you should *first* try to be fair among users. If one user then runs 5 programs, and the other one runs just 1, then the *one* program should get 50% of the CPU time (the users fair share), and the five programs should get 10% of CPU time each. And if one of them uses two threads, each thread should get 5%.
This sounds great, to me.
One minor question: is it even possible to be completely fair on SMP? For instance, if you have a 2-way SMP box running 3 applications, one of which has 2 threads, will the threaded app have an advantage here? (The current system seems to try to keep each thread on a specific CPU, to reduce cache thrashing, which means threads and processes alike each get 50% of the CPU.)
Mark
Quoted 6 lines · Mark Glines
One minor question: is it even possible to be completely fair on SMP? For instance, if you have a 2-way SMP box running 3 applications, one of which has 2 threads, will the threaded app have an advantage here? (The current system seems to try to keep each thread on a specific CPU, to reduce cache thrashing, which means threads and processes alike each get 50% of the CPU.)
I think the ideal in this case would be to have both threads on one cpu, with the other app on the other cpu. This gives inter-process fairness while minimizing the amount of task migration required.
More interesting is the case of three processes on a 2-cpu system. Do we constantly migrate one of them back and forth to ensure that each of them gets 66% of a cpu?
Chris
Quoted 10 lines · Chris Friesen
Quoted 6 lines · Mark Glines
One minor question: is it even possible to be completely fair on SMP? For instance, if you have a 2-way SMP box running 3 applications, one of which has 2 threads, will the threaded app have an advantage here? (The current system seems to try to keep each thread on a specific CPU, to reduce cache thrashing, which means threads and processes alike each get 50% of the CPU.)
I think the ideal in this case would be to have both threads on one cpu, with the other app on the other cpu. This gives inter-process fairness while minimizing the amount of task migration required.
Solving this sort of issue was one of the reasons for the smpnice patches.
Quoted 2 lines
More interesting is the case of three processes on a 2-cpu system. Do we constantly migrate one of them back and forth to ensure that each of them gets 66% of a cpu?
Depends how keen you are on fairness. Unless the process are long term continuously active tasks that never sleep it's probably not an issue as they'll probably move around enough in the long term for them each to get 66% over the long term.
Exact load balancing for real work loads (where tasks are coming and going, sleeping and waking semi randomly and over relatively brief periods) is probably unattainable because by the time you've work out the ideal placement of the currently runnable tasks on the available CPUs it's all changed and the solution is invalid. The best you can hope for that change isn't so great as to completely invalidate the solution and the changes you make as a result are an improvement on the current allocation of processes to CPUs.
The above probably doesn't hold for some systems such as those large super computer jobs that run for several days but they're probably best served by explicit allocation of processes to CPUs using the process affinity mechanism.
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
Quoted 5 lines · Linus Torvalds
So if you have 2 users on a machine running CPU hogs, you should *first* try to be fair among users. If one user then runs 5 programs, and the other one runs just 1, then the *one* program should get 50% of the CPU time (the users fair share), and the five programs should get 10% of CPU time each. And if one of them uses two threads, each thread should get 5%.
"Fairness between users" was implemented long time ago by rik van riel
(http://surriel.com/patches/2.4/2.4.19-fairsched). Some people has been asking for a functionality like that for a long time, ie: universities that want to avoid gcc processes from one student that is trying to learn how fork() works from starving the processes of rest of the students.
But not only they want "fairness between users", they also want "priorities between users and/or groups of users", ie: "the 'students' group shouldn't starve the 'admins' group".
Quoted 28 lines · Linus Torvalds
Quoted 5 lines · Matt Mackall
Quoted 1 line · Linus Torvalds
And "fairness by euid" is probably a hell of a lot easier to do than trying to figure out the wakeup matrix.
For the record, you actually don't need to track a whole NxN matrix (or do the implied
O(n**3)matrix inversion!) to get to the same result.I'm sure you can do things differently, but the reason I think "fairness by euid" is actually worth looking at is that it's pretty much the *identical* issue that we'll have with "fairness by virtual machine" and a number of other "container" issues.
The fact is:
- "fairness" is *not* about giving everybody the same amount of CPU time (scaled by some niceness level or not). Anybody who thinks that is "fair" is just being silly and hasn't thought it through.
- "fairness" is multi-level. You want to be fair to threads within a thread group (where "process" may be one good approximation of what a "thread group" is, but not necessarily the only one).
But you *also* want to be fair in between those "thread groups", and then you want to be fair across "containers" (where "user" may be one such container).
So I claim that anything that cannot be fair by user ID is actually really REALLY unfair. I think it's absolutely humongously STUPID to call something the "Completely Fair Scheduler", and then just be fair on a thread level. That's not fair AT ALL! It's the anti-thesis of being fair!
So if you have 2 users on a machine running CPU hogs, you should *first* try to be fair among users. If one user then runs 5 programs, and the other one runs just 1, then the *one* program should get 50% of the CPU time (the users fair share), and the five programs should get 10% of CPU time each. And if one of them uses two threads, each thread should get 5%.
Quoted 7 lines
So you should see one thread get 50& CPU (single thread of one user), 4 threads get 10% CPU (their fair share of that users time), and 2 threads get 5% CPU (the fair share within that thread group!).
Any scheduling argument that just considers the above to be "7 threads total" and gives each thread 14% of CPU time "fairly" is *anything* but fair. It's a joke if that kind of scheduler then calls itself CFS!
And yes, that's largely what the current scheduler will do, but at least the current scheduler doesn't claim to be fair! So the current scheduler is a lot *better* if only in the sense that it doesn't make ridiculous claims that aren't true!
Linus
Sounds a lot like the PLFS (process level fair sharing) scheduler in Aurema's ARMTech (for whom I used to work). The "fair" in the title is a bit misleading as it's all about unfair scheduling in order to meet specific policies. But it's based on the principle that if you can allocate CPU band width "fairly" (which really means in proportion to the entitlement each process is allocated) then you can allocate CPU band width "fairly" between higher level entities such as process groups, users groups and so on by subdividing the entitlements downwards.
The tricky part of implementing this was the fact that not all entities at the various levels have sufficient demand for CPU band width to use their entitlements and this in turn means that the entities above them will have difficulty using their entitlements even if other of their subordinates have sufficient demand (because their entitlements will be too small). The trick is to have a measure of each entity's demand for CPU bandwidth and use that to modify the way entitlement is divided among subordinates.
As a first guess, an entity's CPU band width usage is an indicator of demand but doesn't take into account unmet demand due to tasks waiting on a run queue waiting for access to the CPU. On the other hand, usage plus time waiting on the queue isn't a good measure of demand either (although it's probably a good upper bound) as it's unlikely that the task would have used the same amount of CPU as the waiting time if it had gone straight to the CPU.
But my main point is that it is possible to build schedulers that can achieve higher level scheduling policies. Versions of PLFS work on Windows from user space by twiddling process priorities. Part of my more recent work at Aurema had been involved in patching Linux's scheduler so that nice worked more predictably so that we could release a user space version of PLFS for Linux. The other part was to add hard CPU band width caps for processes so that ARMTech could enforce hard CPU bandwidth caps on higher level entities (as this can't be done without the kernel being able to do it at that level.
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
Quoted 10 lines · Matt Mackall
Quoted 2 lines · Linus Torvalds
And "fairness by euid" is probably a hell of a lot easier to do than trying to figure out the wakeup matrix.
For the record, you actually don't need to track a whole NxN matrix (or do the implied
O(n**3)matrix inversion!) to get to the same result. You can converge on the same node weightings (ie dynamic priorities) by applying a damped function at each transition point (directed wakeup, preemption, fork, exit).
Quoted 4 lines
The trouble with any scheme like this is that it needs careful tuning of the damping factor to converge rapidly and not oscillate and precise numerical attention to the transition functions so that the sum of dynamic priorities is conserved.
Doing that inside the boundaries of the time constrains imposed by a scheduler, is the interesting part. Given also that the size (and members) of it (matrix) is dynamic.
Also, a "wakup matrix" (if the name correctly pictures what it is for) would help with latencies and priority inheritance, but not for global fairness.
The maniacal fairness focus we're seeing now, is due to the fact the mainline can have extremely unfair behaviour under certain conditions. IMO fairness, although important, should not be main objective of the scheduler rewrite. Simplification and predictability should be on higher priority, with interactivity achievements bound to decent fariness constraints.
- Davide
Quoted 10 lines · Matt Mackall
For the record, you actually don't need to track a whole NxN matrix (or do the implied
O(n**3)matrix inversion!) to get to the same result. You can converge on the same node weightings (ie dynamic priorities) by applying a damped function at each transition point (directed wakeup, preemption, fork, exit).The trouble with any scheme like this is that it needs careful tuning of the damping factor to converge rapidly and not oscillate and precise numerical attention to the transition functions so that the sum of dynamic priorities is conserved.
That would be the control theory approach. And yes, you have to get both the theoretical transfer function and the numerics right. It sometimes helps to use a control-systems framework like the classic Takagi-Sugeno-Kang fuzzy logic controller; get the numerics right once and for all, and treat the heuristics as data, not logic. (I haven't worked in this area in almost twenty years, but Google -- yes, I do use Google+brain for fact-checking; what do you do? -- says that people are still doing active research on TSK models, and solid fixed-point reference implementations are readily available.) That seems like an attractive strategy here because you could easily embed the control engine in the kernel and load rule sets dynamically. Done right, that could give most of the advantages of pluggable schedulers (different heuristic strokes for different folks) without diluting the tester pool for the actual engine code.
(Of course, different scheduling strategies require different input data, and you might not want the overhead of collecting data that your chosen heuristics won't use. But that's not much different from the netfilter situation, and is obviously a solvable problem, if anyone cares to put that much work in. The people who ought to be funding this kind of work are Sun and IBM, who don't have a chance on the desktop and are in big trouble in the database tier; their future as processor vendors depends on being able to service presentation-tier and business-logic-tier loads efficiently on their massively multi-core chips. MIPS should pitch in too, on behalf of licensees like Cavium who need more predictable behavior on multi-core embedded Linux.)
Note also that you might not even want to persistently prioritize particular processes or process groups. You might want a heuristic that notices that some task (say, the X server) often responds to being awakened by doing a little work and then unblocking the task that awakened it. When it is pinged from some highly interactive task, you want it to jump the scheduler queue just long enough to unblock the interactive task, which may mean letting it flush some work out of its internal queue. But otherwise you want to batch things up until there's too much "scheduler pressure" behind it, then let it work more or less until it runs out of things to do, because its working set is so large that repeatedly scheduling it in and out is hell on caches.
(Priority inheritance is the classic solution to the blocked-high-priority-task problem _in_isolation_. It is not without its pitfalls, especially when the designer of the "server" didn't expect to lose his timeslice instantly on releasing the lock. True priority inheritance is probably not something you want to inflict on a non-real-time system, but you do need some urgency heuristic. What a "fuzzy logic" framework does for you is to let you combine competing heuristics in a way that remains amenable to analysis using control theory techniques.)
What does any of this have to do with "fairness"? Nothing whatsoever! There's work that has to be done, and choosing when to do it is almost entirely a matter of staying out of the way of more urgent work while minimizing the task's negative impact on the rest of the system. Does that mean that the X server is "special", kind of the way that latency-sensitive A/V applications are "special", and belongs in a separate scheduler class? No. Nowadays, workloads where the kernel has any idea what tasks belong to what "users" are the exception, not the norm. The X server is the canary in the coal mine, and a scheduler that won't do the right thing for X without hand tweaking won't do the right thing for other eyeball-driven, multiple-tiers-on-one-box scenarios either.
If you want fairness among users to the extent that their demands _compete_, you might as well partition the whole machine, and have a separate fairness-oriented scheduler (let's call it a "hypervisor") that lives outside the kernel. (Talk about two students running gcc on the same shell server, with more important people also doing things on the same system, is so 1990's!) Not that the design of scheduler heuristics shouldn't include "fairness"-like considerations; but they're probably only interesting as a fallback for when the scheduler has no idea what it ought to schedule next.
So why is Ingo's scheduler apparently working well for desktop loads? I haven't tried it or even looked at its code, but from its marketing I would guess that it effectively penalizes tasks whose I/O requests can be serviced from (or directed to) cache long enough to actually consume a whole timeslice. This is prima facie evidence that their _current_behavior_ is non-interactive. Presumably this penalty expires quickly when the task again asks for information that is not readily at hand (or writes data that the system is not willing to cache) -- which usually implies either actual user interaction or a change of working set, both of which deserve an "urgency premium".
The mainline scheduler seems to contain various heuristics that mistake a burst of non-interactive _activity_ for a persistently non-interactive _task_. Take them away in the name of "fairness", and the system adapts more quickly to the change of working set implied by a change of user focus. There are probably fewer pathological load patterns too, since manual knob-turning uninformed by control theory is a lot less likely to get you into trouble when there are few knobs and no deliberately inserted long-time-constant feedback paths. But you can't say there are _no_ pathological load patterns, or even that the major economic drivers of the Linux ecosystem don't generate them, until you do some authentic engineering analysis.
In short (too late!) -- alternate schedulers are fun to experiment with, and the sort of people who would actually try out patches floated on LKML may find that they improve their desktop experience, hosting farm throughput, etc. But even if the mainline scheduler is a hack atop a kludge covering a crock, it's more or less what production applications have expected since the last major architectural shift (NPTL). There's just no sense in replacing it until you can either add real value (say, integral clock scaling for power efficiency, with a reasonable "spinning reserve" for peaking load) or demonstrate stability by engineering analysis instead of trial and error.
Cheers,
- Michael
Quoted 9 lines · Linus Torvalds
Quoted 5 lines · Matt Mackall
Why is X special? Because it does work on behalf of other processes? Lots of things do this. Perhaps a scheduler should focus entirely on the implicit and directed wakeup matrix and optimizing that instead[1].
Quoted 8 lines
I 100% agree - the perfect scheduler would indeed take into account where the wakeups come from, and try to "weigh" processes that help other processes make progress more. That would naturally give server processes more CPU power, because they help others
I don't believe for a second that "fairness" means "give everybody the same amount of CPU". That's a totally illogical measure of fairness. All processes are _not_ created equal.
I believe that unless the kernel is told of these inequalities, then it must schedule fairly.
And yes, by fairly, I mean fairly among all threads as a base resource class, because that's what Linux has always done (and if you aggregate into higher classes, you still need that per-thread scheduling).
So I'm not excluding extra scheduling classes like per-process, per-user, but among any class of equal schedulable entities, fair scheduling is the only option because the alternative of unfairness is just insane.
Quoted 8 lines
That said, even trying to do "fairness by effective user ID" would probably already do a lot. In a desktop environment, X would get as much CPU time as the user processes, simply because it's in a different protection domain (and that's really what "effective user ID" means: it's not about "users", it's really about "protection domains").
And "fairness by euid" is probably a hell of a lot easier to do than trying to figure out the wakeup matrix.
Well my X server has an euid of root, which would mean my X clients can cause X to do work and eat into root's resources. Or as Ingo said, X may not be running as root. Seems like just another hack to try to implicitly solve the X problem and probably create a lot of others along the way.
All fairness issues aside, in the context of keeping a very heavily loaded desktop interactive, X is special. That you are trying to think up funny rules that would implicitly give X better priority is kind of indicative of that.
Andrew Morton
maintainerQuoted 2 lines · On Thu, 19 Apr 2007 05:18:07 +0200 Nick Piggin <[email protected]> wrote:
And yes, by fairly, I mean fairly among all threads as a base resource class, because that's what Linux has always done
Yes, there are potential compatibility problems. Example: a machine with 100 busy httpd processes and suddenly a big gzip starts up from console or cron.
Under current kernels, that gzip will take ages and the httpds will take a 1% slowdown, which may well be exactly the behaviour which is desired.
If we were to schedule by UID then the gzip suddenly gets 50% of the CPU and those httpd's all take a 50% hit, which could be quite serious.
That's simple to fix via nicing, but people have to know to do that, and there will be a transition period where some disruption is possible.
Quoted 11 lines · Andrew Morton
Quoted 2 lines
And yes, by fairly, I mean fairly among all threads as a base resource class, because that's what Linux has always done
Yes, there are potential compatibility problems. Example: a machine with 100 busy httpd processes and suddenly a big gzip starts up from console or cron.
Under current kernels, that gzip will take ages and the httpds will take a 1% slowdown, which may well be exactly the behaviour which is desired.
Quoted 7 lines
If we were to schedule by UID then the gzip suddenly gets 50% of the CPU and those httpd's all take a 50% hit, which could be quite serious.
That's simple to fix via nicing, but people have to know to do that, and there will be a transition period where some disruption is possible.
hmmmm. How about the following then: default to nice -10 for all (SCHED_NORMAL) kernel threads and all root-owned tasks. Root _is_
special: root already has disk space reserved to it, root has special memory allocation allowances, etc. I dont see a reason why we couldnt by default make all root tasks have nice -10. This would be instantly loved by sysadmins i suspect ;-)
(distros that go the extra mile of making Xorg run under non-root could also go another extra one foot to renice that X server to -10.)
Ingo
Quoted 3 lines · Andrew Morton
Quoted 3 lines
Yes, there are potential compatibility problems. Example: a machine with 100 busy httpd processes and suddenly a big gzip starts up from console or cron.
[...]
Quoted 8 lines · Ingo Molnar
hmmmm. How about the following then: default to nice -10 for all (
SCHED_NORMAL) kernel threads and all root-owned tasks. Root _is_
special: root already has disk space reserved to it, root has special memory allocation allowances, etc. I dont see a reason why we couldnt by default make all root tasks have nice -10. This would be instantly loved by sysadmins i suspect ;-)
(distros that go the extra mile of making Xorg run under non-root could also go another extra one foot to renice that X server to -10.)
I'd further recommend making priority levels accessible to kernel threads that are not otherwise accessible to processes, both above and below user-available priority levels. Basically, if you can get SCHED_RR and SCHED_FIFO to coexist as "intimate scheduler classes," then a SCHED_KERN scheduler class can coexist with SCHED_OTHER in like fashion, but with availability of higher and lower priorities than any userspace process is allowed, and potentially some differing scheduling semantics. In such a manner nonessential background processing intended not to ever disturb userspace can be given priorities appropriate to it (perhaps even con's SCHED_IDLEPRIO would make sense), and other, urgent processing can be given priority over userspace altogether.
I believe root's default priority can be adjusted in userspace as things now stand somewhere in /etc/ but I'm not sure of the specifics. Word is somewhere in /etc/security/limits.conf
-- wli