Skip to contentSkip to conversation

CFS-devel, latest code

git Applied Ingo Molnar 12 participants 53 messages Sep 24, 2007 – Oct 10, 2007 7 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

The latest sched-devel.git tree can be pulled from:

git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched-devel.git

Lots of scheduler updates in the past few days, done by many people. Most importantly, the SMP latency problems reported and debugged by Mike Galbraith should be fixed for good now.

I've also included the latest and greatest group-fairness scheduling patch from Srivatsa Vaddagiri, which can now be used without containers as well (in a simplified, each-uid-gets-its-fair-share mode). This feature (CONFIG_FAIR_USER_SCHED) is now default-enabled.

Peter Zijlstra has been busy enhancing the math of the scheduler: we've got the new 'vslice' forked-task code that should enable snappier shell commands during load while still keeping kbuild workloads in check.

On my testsystems this codebase starts looking like something that could be merged into v2.6.24, so please give it a good workout and let us know if there's anything bad going on. (If this works out fine then i'll propagate these changes back into the CFS backport, for wider testing.)

Ingo

----------------------------------------->
the shortlog relative to 2.6.23-rc7:

Dmitry Adamushko (8):
sched: clean up struct load_stat
sched: clean up schedstat block in dequeue_entity()
sched: sched_setscheduler() fix
sched: add set_curr_task() calls
sched: do not keep current in the tree and get rid of sched_entity::fair_key
sched: optimize task_new_fair()
sched: simplify sched_class::yield_task()
sched: rework enqueue/dequeue_entity() to get rid of set_curr_task()

Ingo Molnar (41):
sched: fix new-task method
sched: resched task in task_new_fair()
sched: small sched_debug cleanup
sched: debug: track maximum 'slice'
sched: uniform tunings
sched: use constants if !CONFIG_SCHED_DEBUG
sched: remove stat_gran
sched: remove precise CPU load
sched: remove precise CPU load calculations #2
sched: track cfs_rq->curr on !group-scheduling too
sched: cleanup: simplify cfs_rq_curr() methods
sched: uninline __enqueue_entity()/__dequeue_entity()
sched: speed up update_load_add/_sub()
sched: clean up calc_weighted()
sched: introduce se->vruntime
sched: move sched_feat() definitions
sched: optimize vruntime based scheduling
sched: simplify check_preempt() methods
sched: wakeup granularity fix
sched: add se->vruntime debugging
sched: add more vruntime statistics
sched: debug: update exec_clock only when SCHED_DEBUG
sched: remove wait_runtime limit
sched: remove wait_runtime fields and features
sched: x86: allow single-depth wchan output
sched: fix delay accounting performance regression
sched: prettify /proc/sched_debug output
sched: enhance debug output
sched: kernel/sched_fair.c whitespace cleanups
sched: fair-group sched, cleanups
sched: enable CONFIG_FAIR_GROUP_SCHED=y by default sched debug: BKL usage statistics
sched: remove unneeded tunables
sched debug: print settings
sched debug: more width for parameter printouts
sched: entity_key() fix
sched: remove condition from set_task_cpu()
sched: remove last_min_vruntime effect
sched: undo some of the recent changes
sched: fix place_entity()
sched: fix sched_fork()

Matthias Kaehlcke (1):
sched: use list_for_each_entry_safe() in __wake_up_common()

Mike Galbraith (2):
sched: fix SMP migration latencies
sched: fix formatting of /proc/sched_debug

Peter Zijlstra (10):
sched: simplify SCHED_FEAT_* code
sched: new task placement for vruntime
sched: simplify adaptive latency
sched: clean up new task placement
sched: add tree based averages
sched: handle vruntime overflow
sched: better min_vruntime tracking
sched: add vslice
sched debug: check spread
sched: max_vruntime() simplification

Srivatsa Vaddagiri (7):
sched: group-scheduler core
sched: revert recent removal of set_curr_task()
sched: fix minor bug in yield
sched: print nr_running and load in /proc/sched_debug
sched: print &rq->cfs stats
sched: clean up code under CONFIG_FAIR_GROUP_SCHED
sched: add fair-user scheduler

 arch/i386/Kconfig       |   11 
 include/linux/sched.h   |   45 +--
 init/Kconfig            |   21 +
 kernel/sched.c          |  547 +++++++++++++++++++++++++------------
 kernel/sched_debug.c    |  248 +++++++++++------
 kernel/sched_fair.c     |  692 +++++++++++++++++-------------------------------
 kernel/sched_idletask.c |    5 
 kernel/sched_rt.c       |   12 
 kernel/sched_stats.h    |    4 
 kernel/sysctl.c         |   22 -
 kernel/user.c           |   43 ++
 11 files changed, 906 insertions(+), 744 deletions(-)
#1 lore raw
Quoted 4 lines · On Mon, 24 Sep 2007 23:45:37 +0200 Ingo Molnar <[email protected]> wrote:

The latest sched-devel.git tree can be pulled from:

git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched-devel.git

I'm pulling linux-2.6-sched.git, and it's oopsing all over the place on ia64, and Lee's observations about set_leftmost()'s weirdness are pertinent.

Should I instead be pulling linux-2.6-sched-devel.git?

#2 lore raw
Quoted 6 lines · Andrew Morton
Quoted 3 lines · On Mon, 24 Sep 2007 23:45:37 +0200 Ingo Molnar <[email protected]> wrote:

The latest sched-devel.git tree can be pulled from:

Quoted 7 lines
Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched-devel.git

I'm pulling linux-2.6-sched.git, and it's oopsing all over the place on ia64, and Lee's observations about set_leftmost()'s weirdness are pertinent.

Should I instead be pulling linux-2.6-sched-devel.git?

yeah, please pull that one.

linux-2.6-sched.git by mistake contained an older sched-devel tree for about a day (where your scripts picked it up). I've restored that one to -rc7 meanwhile. It's only supposed to contain strict fixes for upstream. (none at the moment)

Ingo

#3 lore raw
In reply to Ingo Molnar
Quoted 4 lines · Ingo Molnar

Lots of scheduler updates in the past few days, done by many people. Most importantly, the SMP latency problems reported and debugged by Mike
Galbraith should be fixed for good now.

Does this have anything to do with idle balancing ? I noticed some fairly large latencies in that code in 2.6.23-rc's ..

Daniel

#4 lore raw
Quoted 8 lines · Daniel Walker
Quoted 4 lines · Ingo Molnar

Lots of scheduler updates in the past few days, done by many people. Most importantly, the SMP latency problems reported and debugged by Mike
Galbraith should be fixed for good now.

Does this have anything to do with idle balancing ? I noticed some fairly large latencies in that code in 2.6.23-rc's ..

any measurements?

Ingo

#5 lore raw
Quoted 8 lines · Ingo Molnar
Quoted 6 lines · Daniel Walker
Quoted 4 lines · Ingo Molnar

Lots of scheduler updates in the past few days, done by many people. Most importantly, the SMP latency problems reported and debugged by Mike
Galbraith should be fixed for good now.

Quoted 4 lines
Quoted 2 lines

Does this have anything to do with idle balancing ? I noticed some fairly large latencies in that code in 2.6.23-rc's ..

any measurements?

Yes, I made this a while ago,

ftp://source.mvista.com/pub/dwalker/misc/long-cfs-load-balance-trace.txt

This was with PREEMPT_RT on btw, so it's not the most recent kernel. I was able to reproduce it in all the -rc's I tried.

Daniel

#6 lore raw
In reply to Ingo Molnar
Quoted 3 lines · Ingo Molnar

Mike Galbraith (2):
sched: fix SMP migration latencies
sched: fix formatting of /proc/sched_debug

Off-by-one bug in attribution, rocks and sticks (down boy!) don't count ;-) I just built, and will spend the morning beating on it... no news is good news.

-Mike

#7 lore raw
Quoted 1 line · Mike Galbraith

no news is good news.

Darn, have news: latency thing isn't dead. Two busy loops, one at nice 0 pinned to CPU0, and one at nice 19 pinned to CPU1 produced the latencies below for nice -5 Xorg. Didn't kill the box though.

se.wait_max              :            10.068169
se.wait_max              :             7.465334
se.wait_max              :           135.501816
se.wait_max              :             0.884483
se.wait_max              :           144.218955
se.wait_max              :           128.578376
se.wait_max              :            93.975768
se.wait_max              :             4.965965
se.wait_max              :           113.655533
se.wait_max              :             4.301075

sched_debug (attached) is.. strange.

-Mike

#8 lore raw
Quoted 15 lines · Mike Galbraith

Darn, have news: latency thing isn't dead. Two busy loops, one at nice 0 pinned to CPU0, and one at nice 19 pinned to CPU1 produced the latencies below for nice -5 Xorg. Didn't kill the box though.

se.wait_max              :            10.068169
se.wait_max              :             7.465334
se.wait_max              :           135.501816
se.wait_max              :             0.884483
se.wait_max              :           144.218955
se.wait_max              :           128.578376
se.wait_max              :            93.975768
se.wait_max              :             4.965965
se.wait_max              :           113.655533
se.wait_max              :             4.301075
Quoted 1 line

sched_debug (attached) is.. strange.

Disabling CONFIG_FAIR_GROUP_SCHED fixed both. Latencies of up to 336ms hit me during the recompile (make -j3), with nothing else running. Since reboot, latencies are, so far, very very nice. I'm leaving it disabled for now.

-Mike

#9 lore raw
Quoted 15 lines · Mike Galbraith
Quoted 15 lines

Darn, have news: latency thing isn't dead. Two busy loops, one at nice 0 pinned to CPU0, and one at nice 19 pinned to CPU1 produced the latencies below for nice -5 Xorg. Didn't kill the box though.

se.wait_max              :            10.068169
se.wait_max              :             7.465334
se.wait_max              :           135.501816
se.wait_max              :             0.884483
se.wait_max              :           144.218955
se.wait_max              :           128.578376
se.wait_max              :            93.975768
se.wait_max              :             4.965965
se.wait_max              :           113.655533
se.wait_max              :             4.301075
Quoted 1 line
Quoted 1 line

sched_debug (attached) is.. strange.

Mike,
Do you have FAIR_USER_SCHED turned on as well? Can you send me
your .config pls?

Also how do you check se.wait_max?

Quoted 4 lines

Disabling CONFIG_FAIR_GROUP_SCHED fixed both. Latencies of up to 336ms hit me during the recompile (make -j3), with nothing else running. Since reboot, latencies are, so far, very very nice. I'm leaving it disabled for now.

Signature · 2 lines
Regards,
vatsa
#10 lore raw
Quoted 4 lines · Srivatsa Vaddagiri
Quoted 3 lines · Mike Galbraith
Quoted 3 lines

Darn, have news: latency thing isn't dead. Two busy loops, one at nice 0 pinned to CPU0, and one at nice 19 pinned to CPU1 produced the latencies below for nice -5 Xorg. Didn't kill the box though.

These busy loops - are they spawned by the same user? Is it the root user? Also is this seen in UP mode also?

Can you also pls check if tuning root user's cpu share helps? Basically,

	# echo 4096 > /proc/root_user_share

[or any other higher value]

Quoted 1 line

Also how do you check se.wait_max?

Ok ..I see that it is in /proc/sched_debug.

Signature · 2 lines
Regards,
vatsa
#11 lore raw
Quoted 6 lines · Srivatsa Vaddagiri
Quoted 4 lines · Srivatsa Vaddagiri
Quoted 3 lines · Mike Galbraith
Quoted 3 lines

Darn, have news: latency thing isn't dead. Two busy loops, one at nice 0 pinned to CPU0, and one at nice 19 pinned to CPU1 produced the latencies below for nice -5 Xorg. Didn't kill the box though.

Quoted 8 lines

These busy loops - are they spawned by the same user? Is it the root user? Also is this seen in UP mode also?

Can you also pls check if tuning root user's cpu share helps? Basically,

	# echo 4096 > /proc/root_user_share

[or any other higher value]

I'll try these after I beat on the box some more.

-Mike

#12 lore raw
In reply to Srivatsa Vaddagiri
Quoted 3 lines · Srivatsa Vaddagiri

Mike,
Do you have FAIR_USER_SCHED turned on as well? Can you send me
your .config pls?

I did have. gzipped config attached.. this is current though, after disabling groups. I'm still beating on the basic changes (boy does it ever feel nice [awaits other shoe]).

-Mike

#13 lore raw
In reply to Mike Galbraith
Quoted 3 lines · Mike Galbraith
Quoted 1 line

sched_debug (attached) is.. strange.

Disabling CONFIG_FAIR_GROUP_SCHED fixed both. [...]

heh. Evil plan to enable the group scheduler by default worked out as planned! ;-) [guess how many container users would do ... interactivity tests like you do??]

Quoted 3 lines

[...] Latencies of up to 336ms hit me during the recompile (make -j3), with nothing else running. Since reboot, latencies are, so far, very very nice. [...]

'very very nice' == 'best ever' ? :-)

Quoted 1 line

[...] I'm leaving it disabled for now.

ok, i'm too seeing some sort of latency weirdness with CONFIG_FAIR_GROUP_SCHED enabled, _if_ there's Xorg involved which runs under root uid on my box - and hence gets 50% of all CPU time.

Srivatsa, any ideas? It could either be an accounting buglet (less likely, seems like the group scheduling bits stick to the 50% splitup nicely), or a preemption buglet. One potential preemption buglet would be for the group scheduler to not properly preempt a running task when a task from another uid is woken?

Ingo

#14 lore raw
Quoted 5 lines · Ingo Molnar
Quoted 3 lines

[...] Latencies of up to 336ms hit me during the recompile (make -j3), with nothing else running. Since reboot, latencies are, so far, very very nice. [...]

'very very nice' == 'best ever' ? :-)

Yes. Very VERY nice feel.

-Mike

#15 lore raw
Quoted 9 lines · Mike Galbraith
Quoted 5 lines · Ingo Molnar
Quoted 3 lines

[...] Latencies of up to 336ms hit me during the recompile (make -j3), with nothing else running. Since reboot, latencies are, so far, very very nice. [...]

'very very nice' == 'best ever' ? :-)

Yes. Very VERY nice feel.

cool :-)

Maybe there's more to come: if we can get CONFIG_FAIR_USER_SCHED to work properly then your Xorg will have a load-independent 50% of CPU time all to itself. (Group scheduling is quite impressive already: i can log in as root without feeling _any_ effect from a perpetual 'hackbench 100' running as uid mingo. Fork bombs no more.) Will the Amarok gforce plugin like that CPU time splitup? (or is most of the gforce overhead under your user uid?)

it could also work out negatively, _sometimes_ X does not like being too high prio. (weird as that might be.) So we'll see.

Ingo

#16 lore raw
Quoted 14 lines · Ingo Molnar
Quoted 9 lines · Mike Galbraith
Quoted 5 lines · Ingo Molnar
Quoted 3 lines

[...] Latencies of up to 336ms hit me during the recompile (make -j3), with nothing else running. Since reboot, latencies are, so far, very very nice. [...]

'very very nice' == 'best ever' ? :-)

Yes. Very VERY nice feel.

cool :-)

Quoted 7 lines

Maybe there's more to come: if we can get CONFIG_FAIR_USER_SCHED to work properly then your Xorg will have a load-independent 50% of CPU time all to itself. (Group scheduling is quite impressive already: i can log in as root without feeling _any_ effect from a perpetual 'hackbench 100' running as uid mingo. Fork bombs no more.) Will the Amarok gforce plugin like that CPU time splitup? (or is most of the gforce overhead under your user uid?)

I run everything as root (naughty me), so I'd have to change my evil ways to reap the benefits. (I'll do that to test, but it's unlikely to ever become a permanent habit here) Amarok/Gforce will definitely like the user split as long as latency is low. Visualizations are not only bandwidth hungry, they're extremely latency sensitive.

-Mike

#17 lore raw
In reply to Ingo Molnar
Quoted 10 lines · Ingo Molnar

Maybe there's more to come: if we can get CONFIG_FAIR_USER_SCHED to work properly then your Xorg will have a load-independent 50% of CPU time all to itself. (Group scheduling is quite impressive already: i can log in as root without feeling _any_ effect from a perpetual 'hackbench 100' running as uid mingo. Fork bombs no more.) Will the Amarok gforce plugin like that CPU time splitup? (or is most of the gforce overhead under your user uid?)

it could also work out negatively, _sometimes_ X does not like being too high prio. (weird as that might be.) So we'll see.

I piddled around with fair users this morning, and it worked well. With Xorg and Gforce as one user (X and Gforce are synchronous ATM), and a make -j30 as another, I could barely tell the make was running. Watching a dvd, I couldn't tell. Latencies were pretty darn good throughout three hours of testing this and that.

-Mike

#18 lore raw
In reply to Ingo Molnar
Quoted 1 line · Ingo Molnar

Maybe there's more to come: if we can get CONFIG_FAIR_USER_SCHED to work properly then your Xorg will have a load-independent 50% of CPU time all to itself.

It seems that perhaps that 50% makes more sense on a single/dual CPU system than on a more robust one, such as a four way dual core Xeon with HT or some such. With hotplug CPUs, and setups on various machines, perhaps some resource limit independent of the available resource would be useful.

Just throwing out the idea, in case it lands on fertile ground.

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
#19 lore raw
In reply to Ingo Molnar
Quoted 9 lines · Ingo Molnar

ok, i'm too seeing some sort of latency weirdness with CONFIG_FAIR_GROUP_SCHED enabled, _if_ there's Xorg involved which runs under root uid on my box - and hence gets 50% of all CPU time.

Srivatsa, any ideas? It could either be an accounting buglet (less likely, seems like the group scheduling bits stick to the 50% splitup nicely), or a preemption buglet. One potential preemption buglet would be for the group scheduler to not properly preempt a running task when a task from another uid is woken?

Yep, I noticed that too.

check_preempt_wakeup()

{
	...

	if (is_same_group(curr, p)) {
	    ^^^^^^^^^^^^^

		resched_task();
	}

}

Will try a fix to check for preemption at higher levels ..

Signature · 2 lines
Regards,
vatsa
#20 lore raw
Quoted 23 lines · Srivatsa Vaddagiri
Quoted 9 lines · Ingo Molnar

ok, i'm too seeing some sort of latency weirdness with CONFIG_FAIR_GROUP_SCHED enabled, _if_ there's Xorg involved which runs under root uid on my box - and hence gets 50% of all CPU time.

Srivatsa, any ideas? It could either be an accounting buglet (less likely, seems like the group scheduling bits stick to the 50% splitup nicely), or a preemption buglet. One potential preemption buglet would be for the group scheduler to not properly preempt a running task when a task from another uid is woken?

Yep, I noticed that too.

check_preempt_wakeup()

{
	...

	if (is_same_group(curr, p)) {
	    ^^^^^^^^^^^^^

		resched_task();
	}
Quoted 3 lines

}

Will try a fix to check for preemption at higher levels ..

i bet fixing this will increase precision of group scheduling as well. Those long latencies can be thought of as noise as well, and the fair-scheduling "engine" might not be capable to offset all sources of noise. So generally, while we allow a certain amount of lag in preemption decisions (wakeup-granularity, etc.), with which the fairness engine will cope just fine, we do not want to allow unlimited lag.

Ingo

#21 lore raw
Quoted 30 lines · Ingo Molnar
Quoted 23 lines · Srivatsa Vaddagiri
Quoted 9 lines · Ingo Molnar

ok, i'm too seeing some sort of latency weirdness with CONFIG_FAIR_GROUP_SCHED enabled, _if_ there's Xorg involved which runs under root uid on my box - and hence gets 50% of all CPU time.

Srivatsa, any ideas? It could either be an accounting buglet (less likely, seems like the group scheduling bits stick to the 50% splitup nicely), or a preemption buglet. One potential preemption buglet would be for the group scheduler to not properly preempt a running task when a task from another uid is woken?

Yep, I noticed that too.

check_preempt_wakeup()

{
	...

	if (is_same_group(curr, p)) {
	    ^^^^^^^^^^^^^

		resched_task();
	}
Quoted 3 lines

}

Will try a fix to check for preemption at higher levels ..

Quoted 7 lines

i bet fixing this will increase precision of group scheduling as well. Those long latencies can be thought of as noise as well, and the fair-scheduling "engine" might not be capable to offset all sources of noise. So generally, while we allow a certain amount of lag in preemption decisions (wakeup-granularity, etc.), with which the fairness engine will cope just fine, we do not want to allow unlimited lag.

hm, i tried the naive patch. In theory the vruntime of all scheduling entities should be 'compatible' and comparable (that's the point behind using vruntime - the fairness engine drives each vruntime forward and tries to balance them).

So the patch below just removes the is_same_group() condition. But i can still see bad (and obvious) latencies with Mike's 2-hogs test:

taskset 01 perl -e 'while (1) {}' &
nice -19 taskset 02 perl -e 'while (1) {}' &

So something's amiss.

Ingo

------------------->
Subject: sched: group scheduler wakeup latency fix
From: Ingo Molnar <[email protected]>

group scheduler wakeup latency fix.

---
 kernel/sched_fair.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
kernel/sched_fair.c +4 -5
Index: linux/kernel/sched_fair.c
===================================================================
@@ -785,6 +785,7 @@ static void check_preempt_wakeup(struct 
 {
 	struct task_struct *curr = rq->curr;
 	struct cfs_rq *cfs_rq = task_cfs_rq(curr);
+	s64 delta;
 
 	if (unlikely(rt_prio(p->prio))) {
 		update_rq_clock(rq);
@@ -792,12 +793,10 @@ static void check_preempt_wakeup(struct 
 		resched_task(curr);
 		return;
 	}
-	if (is_same_group(curr, p)) {
-		s64 delta = curr->se.vruntime - p->se.vruntime;
+	delta = curr->se.vruntime - p->se.vruntime;
 
-		if (delta > (s64)sysctl_sched_wakeup_granularity)
-			resched_task(curr);
-	}
+	if (delta > (s64)sysctl_sched_wakeup_granularity)
+		resched_task(curr);
 }
 
 static struct task_struct *pick_next_task_fair(struct rq *rq)
#22 lore raw
Quoted 7 lines · Ingo Molnar

So the patch below just removes the is_same_group() condition. But i can still see bad (and obvious) latencies with Mike's 2-hogs test:

taskset 01 perl -e 'while (1) {}' &
nice -19 taskset 02 perl -e 'while (1) {}' &

So something's amiss.

While I try recreating this myself, I wonder if this patch helps?

---
 kernel/sched_fair.c |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
kernel/sched_fair.c +14 -5
Index: current/kernel/sched_fair.c
===================================================================
@@ -794,7 +794,8 @@ static void yield_task_fair(struct rq *r
 static void check_preempt_wakeup(struct rq *rq, struct task_struct *p)
 {
 	struct task_struct *curr = rq->curr;
-	struct cfs_rq *cfs_rq = task_cfs_rq(curr);
+	struct cfs_rq *cfs_rq = task_cfs_rq(curr), *pcfs_rq;
+	struct sched_entity *se = &curr->se, *pse = &p->se;
 
 	if (unlikely(rt_prio(p->prio))) {
 		update_rq_clock(rq);
@@ -802,11 +803,19 @@ static void check_preempt_wakeup(struct 
 		resched_task(curr);
 		return;
 	}
-	if (is_same_group(curr, p)) {
-		s64 delta = curr->se.vruntime - p->se.vruntime;
 
-		if (delta > (s64)sysctl_sched_wakeup_granularity)
-			resched_task(curr);
+	for_each_sched_entity(se) {
+		cfs_rq = cfs_rq_of(se);
+		pcfs_rq = cfs_rq_of(pse);
+
+		if (cfs_rq == pcfs_rq) {
+			s64 delta = se->vruntime - pse->vruntime;
+
+			if (delta > (s64)sysctl_sched_wakeup_granularity)
+				resched_task(curr);
+			break;
+		}
+		pse = pse->parent;
 	}
 }
 
Signature · 2 lines
Regards,
vatsa
#23 lore raw
Quoted 10 lines · Srivatsa Vaddagiri
Quoted 7 lines · Ingo Molnar

So the patch below just removes the is_same_group() condition. But i can still see bad (and obvious) latencies with Mike's 2-hogs test:

taskset 01 perl -e 'while (1) {}' &
nice -19 taskset 02 perl -e 'while (1) {}' &

So something's amiss.

While I try recreating this myself, I wonder if this patch helps?

you should be able to recreate this easily by booting with maxcpus=1 and the commands above - then run a few instances of chew-max (without them being bound to any particular CPUs) and the latencies should show up.

i have tried your patch and it does not solve the problem - i think there's a more fundamental bug lurking, besides the wakeup latency problem.

Find below a /proc/sched_debug output of a really large latency. The latency is caused by the _huge_ (~450 seconds!) vruntime offset that 'loop_silent' and 'sshd' has:

            task   PID         tree-key  switches  prio     exec-runtime
     -------------------------------------------------------------------
     loop_silent  2391     55344.211189       203   120     55344.211189
            sshd  2440    513334.978030         4   120    513334.978030

R cat 2496 513672.558835 4 120 513672.558835

hm. perhaps this fixup in kernel/sched.c:set_task_cpu():

        p->se.vruntime -= old_rq->cfs.min_vruntime - new_rq->cfs.min_vruntime;

needs to become properly group-hierarchy aware?

Ingo

------------------>
Sched Debug Version: v0.05-v20, 2.6.23-rc7 #89
now at 95878.065440 msecs

  .sysctl_sched_latency                    : 20.000000
  .sysctl_sched_min_granularity            : 2.000000
  .sysctl_sched_wakeup_granularity         : 2.000000
  .sysctl_sched_batch_wakeup_granularity   : 25.000000
  .sysctl_sched_child_runs_first           : 0.000001
  .sysctl_sched_features                   : 3

cpu#0, 1828.868 MHz

  .nr_running                    : 3
  .load                          : 3072
  .nr_switches                   : 32032
  .nr_load_updates               : 95906
  .nr_uninterruptible            : 4294967238
  .jiffies                       : 4294763202
  .next_balance                  : 4294.763420
  .curr->pid                     : 2496
  .clock                         : 95893.484495
  .idle_clock                    : 55385.089335
  .prev_clock_raw                : 84753.749367
  .clock_warps                   : 0
  .clock_overflows               : 1737
  .clock_deep_idle_events        : 71815
  .clock_max_delta               : 0.999843
  .cpu_load[0]                   : 3072
  .cpu_load[1]                   : 2560
  .cpu_load[2]                   : 2304
  .cpu_load[3]                   : 2176
  .cpu_load[4]                   : 2119

cfs_rq

  .exec_clock                    : 38202.223241
  .MIN_vruntime                  : 36334.281860
  .min_vruntime                  : 36334.279140
  .max_vruntime                  : 36334.281860
  .spread                        : 0.000000
  .spread0                       : 0.000000
  .nr_running                    : 2
  .load                          : 3072
  .bkl_cnt                       : 3934
  .nr_spread_over                : 37

cfs_rq

  .exec_clock                    : 34769.316246
  .MIN_vruntime                  : 55344.211189
  .min_vruntime                  : 36334.279140
  .max_vruntime                  : 513334.978030
  .spread                        : 457990.766841
  .spread0                       : 0.000000
  .nr_running                    : 2
  .load                          : 2048
  .bkl_cnt                       : 3934
  .nr_spread_over                : 10

cfs_rq

  .exec_clock                    : 36.982394
  .MIN_vruntime                  : 0.000001
  .min_vruntime                  : 36334.279140
  .max_vruntime                  : 0.000001
  .spread                        : 0.000000
  .spread0                       : 0.000000
  .nr_running                    : 0
  .load                          : 0
  .bkl_cnt                       : 3934
  .nr_spread_over                : 1

cfs_rq

  .exec_clock                    : 20.244893
  .MIN_vruntime                  : 0.000001
  .min_vruntime                  : 36334.279140
  .max_vruntime                  : 0.000001
  .spread                        : 0.000000
  .spread0                       : 0.000000
  .nr_running                    : 0
  .load                          : 0
  .bkl_cnt                       : 3934
  .nr_spread_over                : 0

cfs_rq

  .exec_clock                    : 3305.155973
  .MIN_vruntime                  : 0.000001
  .min_vruntime                  : 36334.279140
  .max_vruntime                  : 0.000001
  .spread                        : 0.000000
  .spread0                       : 0.000000
  .nr_running                    : 1
  .load                          : 1024
  .bkl_cnt                       : 3934
  .nr_spread_over                : 13

runnable tasks:
task PID tree-key switches prio exec-runtime sum-exec sum-sleep
----------------------------------------------------------------------------------------------------------

     loop_silent  2391     55344.211189       203   120     55344.211189     34689.036169        42.855690
            sshd  2440    513334.978030         4   120    513334.978030         0.726092         0.000000
R            cat  2496    513672.558835         4   120    513672.558835         0.656690        26.294621

cpu#1, 1828.868 MHz

  .nr_running                    : 3
  .load                          : 2063
  .nr_switches                   : 22792
  .nr_load_updates               : 95625
  .nr_uninterruptible            : 58
  .jiffies                       : 4294763202
  .next_balance                  : 4294.763333
  .curr->pid                     : 2427
  .clock                         : 95643.855219
  .idle_clock                    : 54735.436719
  .prev_clock_raw                : 84754.067800
  .clock_warps                   : 0
  .clock_overflows               : 2521
  .clock_deep_idle_events        : 120633
  .clock_max_delta               : 0.999843
  .cpu_load[0]                   : 2063
  .cpu_load[1]                   : 2063
  .cpu_load[2]                   : 2063
  .cpu_load[3]                   : 2063
  .cpu_load[4]                   : 2063

cfs_rq

  .exec_clock                    : 38457.557282
  .MIN_vruntime                  : 0.000001
  .min_vruntime                  : 35360.227495
  .max_vruntime                  : 0.000001
  .spread                        : 0.000000
  .spread0                       : -974.051645
  .nr_running                    : 1
  .load                          : 1024
  .bkl_cnt                       : 456
  .nr_spread_over                : 18

cfs_rq

  .exec_clock                    : 32536.311766
  .MIN_vruntime                  : 610653.297636
  .min_vruntime                  : 35360.227495
  .max_vruntime                  : 610702.945490
  .spread                        : 49.647854
  .spread0                       : -974.051645
  .nr_running                    : 3
  .load                          : 2063
  .bkl_cnt                       : 456
  .nr_spread_over                : 202

cfs_rq

  .exec_clock                    : 17.392835
  .MIN_vruntime                  : 0.000001
  .min_vruntime                  : 35360.227495
  .max_vruntime                  : 0.000001
  .spread                        : 0.000000
  .spread0                       : -974.051645
  .nr_running                    : 0
  .load                          : 0
  .bkl_cnt                       : 456
  .nr_spread_over                : 1

cfs_rq

  .exec_clock                    : 0.428251
  .MIN_vruntime                  : 0.000001
  .min_vruntime                  : 35360.227495
  .max_vruntime                  : 0.000001
  .spread                        : 0.000000
  .spread0                       : -974.051645
  .nr_running                    : 0
  .load                          : 0
  .bkl_cnt                       : 456
  .nr_spread_over                : 1

cfs_rq

  .exec_clock                    : 5812.752391
  .MIN_vruntime                  : 0.000001
  .min_vruntime                  : 35360.227495
  .max_vruntime                  : 0.000001
  .spread                        : 0.000000
  .spread0                       : -974.051645
  .nr_running                    : 0
  .load                          : 0
  .bkl_cnt                       : 456
  .nr_spread_over                : 11

runnable tasks:
task PID tree-key switches prio exec-runtime sum-exec sum-sleep
----------------------------------------------------------------------------------------------------------

     loop_silent  2400    610702.945490       859   139    610702.945490      8622.783425        13.951214
R       chew-max  2427    610644.849769      2057   120    610644.849769     13737.197972        10.079232
        chew-max  2433    610653.297636      1969   120    610653.297636      9679.778096        10.750704
#24 lore raw
Quoted 5 lines · Ingo Molnar

hm. perhaps this fixup in kernel/sched.c:set_task_cpu():

        p->se.vruntime -= old_rq->cfs.min_vruntime - new_rq->cfs.min_vruntime;

needs to become properly group-hierarchy aware?

a quick first stab like the one below does not appear to solve the problem.

Ingo

------------------->
Subject: sched: group scheduler SMP migration fix
From: Ingo Molnar <[email protected]>

group scheduler SMP migration fix.

---
 kernel/sched.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
kernel/sched.c +7 -2
Index: linux/kernel/sched.c
===================================================================
@@ -1039,7 +1039,8 @@ void set_task_cpu(struct task_struct *p,
 {
 	int old_cpu = task_cpu(p);
 	struct rq *old_rq = cpu_rq(old_cpu), *new_rq = cpu_rq(new_cpu);
-	u64 clock_offset;
+	struct sched_entity *se;
+	u64 clock_offset, voffset;
 
 	clock_offset = old_rq->clock - new_rq->clock;
 
@@ -1051,7 +1052,11 @@ void set_task_cpu(struct task_struct *p,
 	if (p->se.block_start)
 		p->se.block_start -= clock_offset;
 #endif
-	p->se.vruntime -= old_rq->cfs.min_vruntime - new_rq->cfs.min_vruntime;
+
+	se = &p->se;
+	voffset = old_rq->cfs.min_vruntime - new_rq->cfs.min_vruntime;
+	for_each_sched_entity(se)
+		se->vruntime -= voffset;
 
 	__set_task_cpu(p, new_cpu);
 }
#25 lore raw
Quoted 5 lines · Ingo Molnar
Quoted 5 lines

hm. perhaps this fixup in kernel/sched.c:set_task_cpu():

        p->se.vruntime -= old_rq->cfs.min_vruntime - new_rq->cfs.min_vruntime;

needs to become properly group-hierarchy aware?

You seem to have hit the nerve for this problem. The two patches I sent:

	http://lkml.org/lkml/2007/9/25/117
	http://lkml.org/lkml/2007/9/25/168

partly help, but we can do better.

Quoted 14 lines

===================================================================

kernel/sched.c +2 -1
@@ -1039,7 +1039,8 @@ void set_task_cpu(struct task_struct *p,
 {
 	int old_cpu = task_cpu(p);
 	struct rq *old_rq = cpu_rq(old_cpu), *new_rq = cpu_rq(new_cpu);
-	u64 clock_offset;
+	struct sched_entity *se;
+	u64 clock_offset, voffset;
 
 	clock_offset = old_rq->clock - new_rq->clock;
 

kernel/sched.c void set_task_cpu(struct task_struct *p, · line 1057

Quoted 7 lines
kernel/sched.c +3 -1
@@ -1051,7 +1052,11 @@ void set_task_cpu(struct task_struct *p,
 	if (p->se.block_start)
 		p->se.block_start -= clock_offset;
 #endif
-	p->se.vruntime -= old_rq->cfs.min_vruntime - new_rq->cfs.min_vruntime;
+
+	se = &p->se;
+	voffset = old_rq->cfs.min_vruntime - new_rq->cfs.min_vruntime;

This one feels wrong, although I can't express my reaction correctly ..

kernel/sched.c void set_task_cpu(struct task_struct *p, · line 1059

Quoted 2 lines
kernel/sched.c +2 -0
+	for_each_sched_entity(se)
+		se->vruntime -= voffset;

Note that parent entities for a task is per-cpu. So if a task A belonging to userid guest hops from CPU0 to CPU1, then it gets a new parent entity as well, which is different from its parent entity on CPU0.

Before:

	taskA->se.parent = guest's tg->se[0]

After:

	taskA->se.parent = guest's tg->se[1]

So walking up the entity hierarchy and fixing up (parent)se->vruntime will do little good after the task has moved to a new cpu.

IMO, we need to be doing this :

- For dequeue of higher level sched entities, simulate as if they are going to "sleep"
- For enqueue of higher level entities, simulate as if they are "waking up". This will cause enqueue_entity() to reset their vruntime (to existing value for cfs_rq->min_vruntime) when they "wakeup".

If we don't do this, then lets say a group had only one task (A) and it moves from CPU0 to CPU1. Then on CPU1, when group level entity for task A is enqueued, it will have a very low vruntime (since it was never running) and this will give task A unlimited cpu time, until its group entity catches up with all the "sleep" time.

Let me try a fix for this next ..

Signature · 2 lines
Regards,
vatsa
#26 lore raw
In reply to Ingo Molnar
Quoted 3 lines · Ingo Molnar

hm. perhaps this fixup in kernel/sched.c:set_task_cpu():

        p->se.vruntime -= old_rq->cfs.min_vruntime - new_rq->cfs.min_vruntime;

This definitely does need some fixup, even though I am not sure yet if it will solve completely the latency issue.

I tried the following patch. I *think* I see some improvement, wrt latency seen when I type on the shell. Before this patch, I noticed oddities like "kill -9 chew-max-pid" wont kill chew-max (it is queued in runqueue waiting for a looong time to run before it can acknowledge signal and exit). With this patch, I don't see such oddities ..So I am hoping it fixes the latency problem you are seeing as well.

kernel/sched.c +4 -1
Index: current/kernel/sched.c
===================================================================
@@ -1039,6 +1039,8 @@ void set_task_cpu(struct task_struct *p,
 {
 	int old_cpu = task_cpu(p);
 	struct rq *old_rq = cpu_rq(old_cpu), *new_rq = cpu_rq(new_cpu);
+	struct cfs_rq *old_cfsrq = task_cfs_rq(p),
+		      *new_cfsrq = cpu_cfs_rq(old_cfsrq, new_cpu);
 	u64 clock_offset;
 
 	clock_offset = old_rq->clock - new_rq->clock;
@@ -1051,7 +1053,8 @@ void set_task_cpu(struct task_struct *p,
 	if (p->se.block_start)
 		p->se.block_start -= clock_offset;
 #endif
-	p->se.vruntime -= old_rq->cfs.min_vruntime - new_rq->cfs.min_vruntime;
+	p->se.vruntime -= old_cfsrq->min_vruntime -
+					 new_cfsrq->min_vruntime;
 
 	__set_task_cpu(p, new_cpu);
 }

--
Regards,
vatsa

#27 lore raw
Quoted 8 lines · Srivatsa Vaddagiri
Quoted 3 lines · Ingo Molnar

hm. perhaps this fixup in kernel/sched.c:set_task_cpu():

        p->se.vruntime -= old_rq->cfs.min_vruntime - new_rq->cfs.min_vruntime;

This definitely does need some fixup, even though I am not sure yet if it will solve completely the latency issue.

Quoted 6 lines

I tried the following patch. I *think* I see some improvement, wrt latency seen when I type on the shell. Before this patch, I noticed oddities like "kill -9 chew-max-pid" wont kill chew-max (it is queued in runqueue waiting for a looong time to run before it can acknowledge signal and exit). With this patch, I don't see such oddities ..So I am hoping it fixes the latency problem you are seeing as well.

http://lkml.org/lkml/2007/9/25/117 plus the below seems to be the SIlver Bullet for the latencies I was seeing.

Quoted 28 lines

Index: current/kernel/sched.c
===================================================================

kernel/sched.c +4 -2
@@ -1039,6 +1039,8 @@ void set_task_cpu(struct task_struct *p,
 {
 	int old_cpu = task_cpu(p);
 	struct rq *old_rq = cpu_rq(old_cpu), *new_rq = cpu_rq(new_cpu);
+	struct cfs_rq *old_cfsrq = task_cfs_rq(p),
+		      *new_cfsrq = cpu_cfs_rq(old_cfsrq, new_cpu);
 	u64 clock_offset;
 
 	clock_offset = old_rq->clock - new_rq->clock;
@@ -1051,7 +1053,8 @@ void set_task_cpu(struct task_struct *p,
 	if (p->se.block_start)
 		p->se.block_start -= clock_offset;
 #endif
-	p->se.vruntime -= old_rq->cfs.min_vruntime - new_rq->cfs.min_vruntime;
+	p->se.vruntime -= old_cfsrq->min_vruntime -
+					 new_cfsrq->min_vruntime;
 
 	__set_task_cpu(p, new_cpu);
 }
 
 
--

Regards,
vatsa

#28 lore raw
Quoted 9 lines · Mike Galbraith
Quoted 6 lines

I tried the following patch. I *think* I see some improvement, wrt latency seen when I type on the shell. Before this patch, I noticed oddities like "kill -9 chew-max-pid" wont kill chew-max (it is queued in runqueue waiting for a looong time to run before it can acknowledge signal and exit). With this patch, I don't see such oddities ..So I am hoping it fixes the latency problem you are seeing as well.

http://lkml.org/lkml/2007/9/25/117 plus the below seems to be the SIlver Bullet for the latencies I was seeing.

Cool ..Thanks for the quick feedback.

Ingo, do the two patches fix the latency problems you were seeing as well?

Signature · 2 lines
Regards,
vatsa
#29 lore raw
In reply to Srivatsa Vaddagiri
Quoted 1 line · Srivatsa Vaddagiri

While I try recreating this myself, I wonder if this patch helps?

It didn't here, nor did tweaking root's share. Booting with maxcpus=1, I was unable to produce large latencies, but didn't try very many things.

-Mike

#30 lore raw
Quoted 7 lines · Mike Galbraith
Quoted 1 line · Srivatsa Vaddagiri

While I try recreating this myself, I wonder if this patch helps?

It didn't here, nor did tweaking root's share. Booting with maxcpus=1, I was unable to produce large latencies, but didn't try very many things.

Easy way to make it pretty bad: pin a nice 0 loop to CPU0, pin a nice 19 loop to CPU1, then start an unpinned make.. more Xorg bouncing back and forth I suppose.

se.wait_max              :            14.105683
se.wait_max              :           316.943787
se.wait_max              :           692.884324
se.wait_max              :            38.165534
se.wait_max              :           732.883492
se.wait_max              :           127.059784
se.wait_max              :            63.403549
se.wait_max              :           372.933284

-Mike

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

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

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

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

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

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

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

#38 lore raw

[RFC/PATCH] Add sysfs control to modify a user's cpu share

Hi Ingo,

Adds tunables in sysfs to modify a user's cpu share.

A directory is created in sysfs for each new user in the system.

/sys/kernel/uids/<uid>/cpu_share

Reading this file returns the cpu shares granted for the user. Writing into this file modifies the cpu share for the user. Only an administrator is allowed to modify a user's cpu share.

Ex:

	# cd /sys/kernel/uids/
	# cat 512/cpu_share
	1024
	# echo 2048 > 512/cpu_share
	# cat 512/cpu_share
	2048
	#
---
 include/linux/sched.h |   11 +++++
 kernel/ksysfs.c       |    4 +
 kernel/sched.c        |    5 ++
 kernel/user.c         |  110 +++++++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 129 insertions(+), 1 deletion(-)
include/linux/sched.h +11 -0
Index: linux-2.6.23-rc8-sched-devel/include/linux/sched.h
===================================================================
@@ -86,6 +86,7 @@ struct sched_param {
 #include <linux/timer.h>
 #include <linux/hrtimer.h>
 #include <linux/task_io_accounting.h>
+#include <linux/kobject.h>
 
 #include <asm/processor.h>
 
@@ -598,9 +599,18 @@ struct user_struct {
 
 #ifdef CONFIG_FAIR_USER_SCHED
 	struct task_group *tg;
+ 	struct kset kset;
+ 	struct subsys_attribute user_attr;
+ 	struct work_struct work;
 #endif
 };
 
+#ifdef CONFIG_FAIR_USER_SCHED
+extern int uids_kobject_init(void);
+#else
+static inline int uids_kobject_init(void) { return 0; }
+#endif
+
 extern struct user_struct *find_user(uid_t);
 
 extern struct user_struct root_user;
@@ -1846,6 +1856,7 @@ extern struct task_group *sched_create_g
 extern void sched_destroy_group(struct task_group *tg);
 extern void sched_move_task(struct task_struct *tsk);
 extern int sched_group_set_shares(struct task_group *tg, unsigned long shares);
+extern unsigned long sched_group_shares(struct task_group *tg);
 
 #endif
 
kernel/ksysfs.c +4 -0
Index: linux-2.6.23-rc8-sched-devel/kernel/ksysfs.c
===================================================================
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kexec.h>
+#include <linux/sched.h>
 
 #define KERNEL_ATTR_RO(_name) \
 static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
@@ -116,6 +117,9 @@ static int __init ksysfs_init(void)
 					      &notes_attr);
 	}
 
+	if (!error)
+		error = uids_kobject_init();
+
 	return error;
 }
 
kernel/sched.c +5 -0
Index: linux-2.6.23-rc8-sched-devel/kernel/sched.c
===================================================================
@@ -6928,4 +6928,9 @@ int sched_group_set_shares(struct task_g
 	return 0;
 }
 
+unsigned long sched_group_shares(struct task_group *tg)
+{
+	return tg->shares;
+}
+
 #endif	/* CONFIG_FAIR_GROUP_SCHED */
kernel/user.c +109 -1

149 lines not on this page · raw message

Signature · 2 lines
regards,
Dhaval
#39 lore raw

Re: [RFC/PATCH] Add sysfs control to modify a user's cpu share

hi Dhaval,

Quoted 12 lines · Dhaval Giani

Hi Ingo,

Adds tunables in sysfs to modify a user's cpu share.

A directory is created in sysfs for each new user in the system.

/sys/kernel/uids/<uid>/cpu_share

Reading this file returns the cpu shares granted for the user. Writing into this file modifies the cpu share for the user. Only an administrator is allowed to modify a user's cpu share.

Quoted 8 lines

Ex:

	# cd /sys/kernel/uids/
	# cat 512/cpu_share
	1024
	# echo 2048 > 512/cpu_share
	# cat 512/cpu_share
	2048
	#

looks good to me! I think this API is pretty straightforward. I've put this into my tree and have updated the sched-devel git tree:

git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched-devel.git

but there seems to be a bug in it, i get this:

kobject_add failed for 500 with -EEXIST, don't try to register things with the same name in the same directory.

  [<c01e1730>] kobject_shadow_add+0x13b/0x169
  [<c01e1795>] kobject_set_name+0x28/0x91
  [<c01299d5>] user_kobject_create+0x6a/0x90
  [<c0129d3c>] alloc_uid+0x141/0x181
  [<c012d05c>] set_user+0x1c/0x91
  [<c012e4c7>] sys_setresuid+0xd9/0x17d
  [<c0103cf6>] sysenter_past_esp+0x5f/0x85
  =======================

Ingo

#40 lore raw

Re: [RFC/PATCH] Add sysfs control to modify a user's cpu share

Quoted 3 lines · Ingo Molnar

but there seems to be a bug in it, i get this:

kobject_add failed for 500 with -EEXIST, don't try to register things with the same name in the same directory.

Looks like a remove_dir/create_dir race ..

	free_user()			alloc_uid()

	   uid_hash_remove(up);

					uid_hash_insert(new, hashent);

	   schedule_work()
					user_kobject_create();
					kobject_add();	-> Boom!

	   remove_user_sysfs_dir();

/me looks up sysfs programming examples ..

Signature · 2 lines
Regards,
vatsa
#41 lore raw

Re: [RFC/PATCH] Add sysfs control to modify a user's cpu share

In reply to Ingo Molnar
Quoted 19 lines · Ingo Molnar
Quoted 10 lines

Adds tunables in sysfs to modify a user's cpu share.

A directory is created in sysfs for each new user in the system.

/sys/kernel/uids/<uid>/cpu_share

Reading this file returns the cpu shares granted for the user. Writing into this file modifies the cpu share for the user. Only an administrator is allowed to modify a user's cpu share.

Quoted 8 lines

Ex:

	# cd /sys/kernel/uids/
	# cat 512/cpu_share
	1024
	# echo 2048 > 512/cpu_share
	# cat 512/cpu_share
	2048
	#
Quoted 3 lines

looks good to me! I think this API is pretty straightforward. I've put this into my tree and have updated the sched-devel git tree:

While a sysfs interface is OK and somewhat orthogonal to the interface proposed the containers patches, I think maybe a new syscall should be considered.

Since we now have a fair share cpu scheduler, maybe an interface to specify the cpu share directly (alternatively to priority) make sense.

For processes, it may become more intuitive (and precise) to set the processing share directly than setting a priority which is converted to a share.

Maybe something similar to ioprio_set() and ioprio_get() syscalls:

- per user cpu share
- per user group cpu share
- per process cpu share
- per process group cpu share

Best regards,

- Eric

#42 lore raw

Re: [RFC/PATCH] Add sysfs control to modify a user's cpu share

Quoted 3 lines · Eric St-Laurent

While a sysfs interface is OK and somewhat orthogonal to the interface proposed the containers patches, I think maybe a new syscall should be considered.

We had discussed syscall vs filesystem based interface for resource management [1] and there was a heavy bias favoring filesystem based interface, based on which the container (now "cgroup") filesystem evolved.

Where we already have one interface defined, I would be against adding an equivalent syscall interface.

Note that this "fair-user" scheduling can in theory be accomplished using the same cgroup based interface, but requires some extra setup in userspace (either to run a daemon which moves tasks to appropriate control groups/containers upon their uid change OR to modify initrd to mount cgroup filesystem at early bootup time). I expect most distros to enable CONFIG_FAIR_CGROUP_SCHED (control group based fair group scheduler) and not CONFIG_FAIR_USER_SHCED (user id based fair group scheduler). The only reason why we are providing CONFIG_FAIR_USER_SCHED and the associated sysfs interface is to help test group scheduler w/o requiring knowledge of cgroup filesystem.

Reference:

1. http://marc.info/?l=linux-kernel&m=116231242201300&w=2

Signature · 2 lines
Regards,
vatsa
#43 lore raw

[RFC/PATCH -v2] Add sysfs control to modify a user's cpu share

In reply to Ingo Molnar

Hi Ingo,

Can you please drop commit b1add858a10cece3a68b2d8cb9e7350843700a58 (last version of this patch) and try this instead?
---
Adds tunables in sysfs to modify a user's cpu share.

A directory is created in sysfs for each new user in the system.

/sys/kernel/uids/<uid>/cpu_share

Reading this file returns the cpu shares granted for the user. Writing into this file modifies the cpu share for the user. Only an administrator is allowed to modify a user's cpu share.

Ex:

	# cd /sys/kernel/uids/
	# cat 512/cpu_share
	1024
	# echo 2048 > 512/cpu_share
	# cat 512/cpu_share
	2048
	#

Changelog since v1:
1. Added a mutex to serialize directory creation/destruction for a user in sysfs
2. Added a spinlock in the task_group structure to serialize writes to tg->shares.
3. Removed /proc/root_user_cpu_shares.
4. Added Documentation about the group scheduler.

---
 Documentation/sched-design-CFS.txt |   67 ++++++++++
 include/linux/sched.h              |   11 +
 kernel/ksysfs.c                    |    8 +
 kernel/sched.c                     |   14 +-
 kernel/sched_debug.c               |   48 -------
 kernel/user.c                      |  242 ++++++++++++++++++++++++++++++++-----
 6 files changed, 310 insertions(+), 80 deletions(-)
Documentation/sched-design-CFS.txt +67 -0
Index: linux-2.6.23-rc8-sched-devel/Documentation/sched-design-CFS.txt
===================================================================
@@ -117,3 +117,70 @@ Some implementation details:
    iterators of the scheduling modules are used. The balancing code got
    quite a bit simpler as a result.
 
+
+Group scheduler extension to CFS
+================================
+
+Normally the scheduler operates on individual tasks and strives to provide
+fair CPU time to each task. Sometimes, it may be desirable to group tasks
+and provide fair CPU time to each such task group. For example, it may
+be desirable to first provide fair CPU time to each user on the system
+and then to each task belonging to a user.
+
+CONFIG_FAIR_GROUP_SCHED strives to achieve exactly that. It lets
+SCHED_NORMAL/BATCH tasks be be grouped and divides CPU time fairly among such
+groups. At present, there are two (mutually exclusive) mechanisms to group
+tasks for CPU bandwidth control purpose:
+
+	- Based on user id (CONFIG_FAIR_USER_SCHED)
+		In this option, tasks are grouped according to their user id.
+	- Based on "cgroup" pseudo filesystem (CONFIG_FAIR_CGROUP_SCHED)
+		This options lets the administrator create arbitrary groups
+		of tasks, using the "cgroup" pseudo filesystem. See
+		Documentation/cgroups.txt for more information about this
+		filesystem.
+
+Only one of these options to group tasks can be chosen and not both.
+
+Group scheduler tunables:
+
+When CONFIG_FAIR_USER_SCHED is defined, a directory is created in sysfs for
+each new user and a "cpu_share" file is added in that directory.
+
+	# cd /sys/kernel/uids
+	# cat 512/cpu_share		# Display user 512's CPU share
+	1024
+	# echo 2048 > 512/cpu_share	# Modify user 512's CPU share
+	# cat 512/cpu_share		# Display user 512's CPU share
+	2048
+	#
+
+CPU bandwidth between two users are divided in the ratio of their CPU shares.
+For ex: if you would like user "root" to get twice the bandwidth of user
+"guest", then set the cpu_share for both the users such that "root"'s
+cpu_share is twice "guest"'s cpu_share
+
+
+When CONFIG_FAIR_CGROUP_SCHED is defined, a "cpu.shares" file is created
+for each group created using the pseudo filesystem. See example steps
+below to create task groups and modify their CPU share using the "cgroups"
+pseudo filesystem
+
+	# mkdir /dev/cpuctl
+	# mount -t cgroup -ocpu none /dev/cpuctl
+	# cd /dev/cpuctl
+
+	# mkdir multimedia	# create "multimedia" group of tasks
+	# mkdir browser		# create "browser" group of tasks
+
+	# #Configure the multimedia group to receive twice the CPU bandwidth
+	# #that of browser group
+
+	# echo 2048 > multimedia/cpu.shares
+	# echo 1024 > browser/cpu.shares
+
+	# firefox &	# Launch firefox and move it to "browser" group
+	# echo <firefox_pid> > browser/tasks
+
+	# #Launch gmplayer (or your favourite movie player)
+	# echo <movie_player_pid> > multimedia/tasks
include/linux/sched.h +11 -0
Index: linux-2.6.23-rc8-sched-devel/include/linux/sched.h
===================================================================
@@ -86,6 +86,7 @@ struct sched_param {
 #include <linux/timer.h>
 #include <linux/hrtimer.h>
 #include <linux/task_io_accounting.h>
+#include <linux/kobject.h>
 
 #include <asm/processor.h>
 
@@ -598,9 +599,18 @@ struct user_struct {
 
 #ifdef CONFIG_FAIR_USER_SCHED
 	struct task_group *tg;
+	struct kset kset;
+	struct subsys_attribute user_attr;
+	struct work_struct work;
 #endif
 };
 
+#ifdef CONFIG_FAIR_USER_SCHED
+extern int uids_kobject_init(void);
+#else
+static inline int uids_kobject_init(void) { return 0; }
+#endif
+
 extern struct user_struct *find_user(uid_t);
 
 extern struct user_struct root_user;
@@ -1846,6 +1856,7 @@ extern struct task_group *sched_create_g
 extern void sched_destroy_group(struct task_group *tg);
 extern void sched_move_task(struct task_struct *tsk);
 extern int sched_group_set_shares(struct task_group *tg, unsigned long shares);
+extern unsigned long sched_group_shares(struct task_group *tg);
 
 #endif
 
kernel/ksysfs.c +8 -0
Index: linux-2.6.23-rc8-sched-devel/kernel/ksysfs.c
===================================================================
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kexec.h>
+#include <linux/sched.h>
 
 #define KERNEL_ATTR_RO(_name) \
 static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
@@ -116,6 +117,13 @@ static int __init ksysfs_init(void)
 					      &notes_attr);
 	}
 
+	/*
+	 * Create "/sys/kernel/uids" directory and corresponding root user's
+	 * directory under it.
+	 */
+	if (!error)
+		error = uids_kobject_init();
+
 	return error;
 }
 
kernel/sched.c +13 -1
Index: linux-2.6.23-rc8-sched-devel/kernel/sched.c
===================================================================
@@ -161,6 +161,8 @@ struct task_group {
 	/* runqueue "owned" by this group on each cpu */
 	struct cfs_rq **cfs_rq;
 	unsigned long shares;
+	/* spinlock to serialize modification to shares */
+	spinlock_t lock;
 };
 
 /* Default task group's sched entity on each cpu */
@@ -6552,6 +6554,7 @@ void __init sched_init(void)
 			se->parent = NULL;
 		}
 		init_task_group.shares = init_task_group_load;
+		spin_lock_init(&init_task_group.lock);
 #endif
 
 		for (j = 0; j < CPU_LOAD_IDX_MAX; j++)
@@ -6796,6 +6799,7 @@ struct task_group *sched_create_group(vo
 	}
 
 	tg->shares = NICE_0_LOAD;
+	spin_lock_init(&tg->lock);
 
 	return tg;
 
@@ -6916,8 +6920,9 @@ int sched_group_set_shares(struct task_g
 {
 	int i;
 
+	spin_lock(&tg->lock);
 	if (tg->shares == shares)
-		return 0;
+		goto done;
 
 	/* return -EINVAL if the new value is not sane */
 
@@ -6925,7 +6930,14 @@ int sched_group_set_shares(struct task_g
 	for_each_possible_cpu(i)
 		set_se_shares(tg->se[i], shares);
 
+done:
+	spin_unlock(&tg->lock);
 	return 0;
 }
 
+unsigned long sched_group_shares(struct task_group *tg)
+{
+	return tg->shares;
+}
+
 #endif	/* CONFIG_FAIR_GROUP_SCHED */
kernel/sched_debug.c +0 -48

60 lines not on this page · raw message

kernel/user.c +211 -31

301 lines not on this page · raw message

Signature · 2 lines
regards,
Dhaval
#44 lore raw

Re: [RFC/PATCH -v2] Add sysfs control to modify a user's cpu share

Quoted 5 lines · Dhaval Giani

Hi Ingo,

Can you please drop commit b1add858a10cece3a68b2d8cb9e7350843700a58 (last version of this patch) and try this instead?

Quoted 7 lines

Changelog since v1:
1. Added a mutex to serialize directory creation/destruction for a user in sysfs
2. Added a spinlock in the task_group structure to serialize writes to tg->shares.
3. Removed /proc/root_user_cpu_shares.
4. Added Documentation about the group scheduler.

thanks - I have added this to the queue.

i'm wondering about the following: could not (yet) existing UIDs be made configurable too? I.e. if i do this in a bootup script:

echo 2048 > /sys/kernel/uids/500/cpu_share

this should just work too, regardless of there not being any UID 500 tasks yet. Likewise, once configured, the /sys/kernel/uids/* directories (with the settings in them) should probably not go away either.

Ingo

#45 lore raw

Re: [RFC/PATCH -v2] Add sysfs control to modify a user's cpu share

Quoted 10 lines
Quoted 7 lines

Changelog since v1:
1. Added a mutex to serialize directory creation/destruction for a user in sysfs
2. Added a spinlock in the task_group structure to serialize writes to tg->shares.
3. Removed /proc/root_user_cpu_shares.
4. Added Documentation about the group scheduler.

thanks - I have added this to the queue.

Quoted 8 lines

i'm wondering about the following: could not (yet) existing UIDs be made configurable too? I.e. if i do this in a bootup script:

echo 2048 > /sys/kernel/uids/500/cpu_share

this should just work too, regardless of there not being any UID 500 tasks yet. Likewise, once configured, the /sys/kernel/uids/* directories (with the settings in them) should probably not go away either.

Shouldn't that be done via uevents? E.g. UID x gets added to the sysfs tree, generates a uevent and a script then figures out the cpu_share and sets it. That way you also don't need to keep the directories. No?

#46 lore raw

Re: [RFC/PATCH -v2] Add sysfs control to modify a user's cpu share

Quoted 11 lines · Heiko Carstens
Quoted 11 lines
Quoted 7 lines

Changelog since v1:
1. Added a mutex to serialize directory creation/destruction for a user in sysfs
2. Added a spinlock in the task_group structure to serialize writes to tg->shares.
3. Removed /proc/root_user_cpu_shares.
4. Added Documentation about the group scheduler.

thanks - I have added this to the queue.

i'm wondering about the following: could not (yet) existing UIDs be made configurable too? I.e. if i do this in a bootup script:

Quoted 7 lines
Quoted 3 lines

echo 2048 > /sys/kernel/uids/500/cpu_share

this should just work too, regardless of there not being any UID 500 tasks yet. Likewise, once configured, the /sys/kernel/uids/* directories (with the settings in them) should probably not go away either.

Shouldn't that be done via uevents? E.g. UID x gets added to the sysfs tree, generates a uevent and a script then figures out the cpu_share and sets it. That way you also don't need to keep the directories. No?

That sounds complex administratively. It means that instead of setting a higher or lower than default once and having it persist until reboot I have to create a script, which *will* in some cases be left in place even after the need has gone.

I agree with Ingo, once it's done it should be persistent.

And as another administrative convenience I can look at that set of values and see what shares are being used, even when the user is not currently active.

Final question, how do setuid processes map into this implementation?

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
#47 lore raw

Re: [RFC/PATCH -v2] Add sysfs control to modify a user's cpu share

Quoted 19 lines · Bill Davidsen
Quoted 5 lines
Quoted 5 lines

i'm wondering about the following: could not (yet) existing UIDs be made configurable too? I.e. if i do this in a bootup script:

echo 2048 > /sys/kernel/uids/500/cpu_share

Quoted 8 lines
Quoted 3 lines

this should just work too, regardless of there not being any UID 500 tasks yet. Likewise, once configured, the /sys/kernel/uids/* directories (with the settings in them) should probably not go away either.

Shouldn't that be done via uevents? E.g. UID x gets added to the sysfs tree,
generates a uevent and a script then figures out the cpu_share and sets it. That way you also don't need to keep the directories. No?

That sounds complex administratively. It means that instead of setting a higher or lower than default once and having it persist until reboot I have to create a script, which *will* in some cases be left in place even after the need has gone.

Quoted 4 lines

I agree with Ingo, once it's done it should be persistent. And as another administrative convenience I can look at that set of values and see what shares are being used, even when the user is not currently active.

Although the need seems very real, I am thinking about the implementation aspect of this in the kernel i.e how will this be implementable?

1. The current patch proposes a sysfs based interface, where a new directory is created for every new user created who logs into the system. To meet the requirement Ingo suggested, it would require the ability to create directories in sysfs in advance of (user_struct) objects that aren't yet there - which is not possible to implement in sysfs afaik

2. configfs seems to allow creation of directories (i.e kernel objects) from userland. Every new directory created should translate to a user_struct object being created in the kernel (and inserted in uid_hash table). Would this be acceptable?

Also, IMHO, CONFIG_FAIR_USER_SCHED is there only as a toy, to test fair group scheduling and I expect distros to support CONFIG_FAIR_CGROUP_SCHED instead which allows "control group" (or process containers) based fair group scheduling.

Using CONFIG_FAIR_CGROUP_SCHED it is still possible to provide user-id based fair group scheduling, in two ways:

1. Have a daemon which listens for UID change events (PROC_EVENT_UID) and move the task to appropriate "control groups" and set the "control group" shares
2. Implement a "user" subsystem registered with "cgroup" core, which automatically creates new "control groups" whenever a new user is being added to the system. This is very similar to "ns" subsystem (kernel/ns_cgroup.c in -mm tree). Thus in order to provide fair user scheduling with this option, distro needs to modify initrd to:

# mkdir /dev/usercpucontrol
# mount -t cgroup -ouser,cpu none /dev/usercpucontrol

Using a combination of these two options and a /etc configuration file which specifies the cpu shares to be given to a user, it should be possible for distro to give a good fair-user based scheduler.

Quoted 1 line

Final question, how do setuid processes map into this implementation?

We seem to be going by the real uid of a task (which is what tsk->user points at) to decide its CPU bandwidth. Is that a cause of concern?

Signature · 2 lines
Regards,
vatsa
#48 lore raw

Re: [RFC/PATCH -v2] Add sysfs control to modify a user's cpu share

In reply to Heiko Carstens
Quoted 8 lines · Heiko Carstens
Quoted 5 lines

echo 2048 > /sys/kernel/uids/500/cpu_share

this should just work too, regardless of there not being any UID 500 tasks yet. Likewise, once configured, the /sys/kernel/uids/* directories (with the settings in them) should probably not go away either.

Shouldn't that be done via uevents? E.g. UID x gets added to the sysfs tree, generates a uevent and a script then figures out the cpu_share and sets it.

That would tend to be a tad racy - a site may want to set limits in the hypothetical /sys/kernel/uids/NNN before the program has a chance to fork-bomb or otherwise make it difficult to set a limitfrom within another userspace process. It's similar to why you want a process to be launched with all its ulimit's set, rather than set them after the fork/exec happens...

#49 lore raw

Re: [RFC/PATCH -v2] Add sysfs control to modify a user's cpu share

Quoted 6 lines · On Thu, Oct 04, 2007 at 05:32:17PM -0400, [email protected] wrote:
Quoted 2 lines

Shouldn't that be done via uevents? E.g. UID x gets added to the sysfs tree, generates a uevent and a script then figures out the cpu_share and sets it.

That would tend to be a tad racy - a site may want to set limits in the hypothetical /sys/kernel/uids/NNN before the program has a chance to fork-bomb or otherwise make it difficult to set a limitfrom within another userspace

Note that there is a default limit enforced on every new user (1024 value for the user's cpu share). This limit should contain any fork-bomb that the user may launch immediately.

Quoted 2 lines

process. It's similar to why you want a process to be launched with all its ulimit's set, rather than set them after the fork/exec happens...

Signature · 2 lines
Regards,
vatsa
#50 lore raw

PATCH 1/1 Generate uevents for user creation/destruction

In reply to Heiko Carstens
Quoted 5 lines · Heiko Carstens
Quoted 5 lines

i'm wondering about the following: could not (yet) existing UIDs be made configurable too? I.e. if i do this in a bootup script:

echo 2048 > /sys/kernel/uids/500/cpu_share

Quoted 7 lines
Quoted 3 lines

this should just work too, regardless of there not being any UID 500 tasks yet. Likewise, once configured, the /sys/kernel/uids/* directories (with the settings in them) should probably not go away either.

Shouldn't that be done via uevents? E.g. UID x gets added to the sysfs tree, generates a uevent and a script then figures out the cpu_share and sets it. That way you also don't need to keep the directories. No?

Heiko,
Thanks for the hint. Here's a patch to enable generation of
uevents for user creation/deletion. These uevents can be handled in userspace to configure a new user's cpu share.

Note : After bootup I could test that new user's cpu share is configured as per a configuration file (/etc/user_cpu_share.conf). However this mechanism didnt work for root user. Perhaps uevent for root user is generated way too early?

A HOWTO text file is also attached explaining how to make use of these uevents in userspace.

Ingo,
This patch applies on top of latest sched-devel tree. Pls review
and apply ..

---

Generate uevents when a user is being created/destroyed. These events could be used to configure cpu share of a new user.

---
 kernel/user.c |    4 ++++
 1 files changed, 4 insertions(+)
kernel/user.c +4 -0
Index: current/kernel/user.c
===================================================================
@@ -174,6 +174,8 @@ static int user_kobject_create(struct us
 	if (error)
 		kobject_del(kobj);
 
+	kobject_uevent(kobj, KOBJ_ADD);
+
 done:
 	return error;
 }
@@ -189,6 +191,7 @@ int __init uids_kobject_init(void)
 
 	/* create under /sys/kernel dir */
 	uids_kobject.parent = &kernel_subsys.kobj;
+	uids_kobject.kset = &kernel_subsys;
 	kobject_set_name(&uids_kobject, "uids");
 	kobject_init(&uids_kobject);
 
@@ -228,6 +231,7 @@ static void remove_user_sysfs_dir(struct
 		goto done;
 
 	sysfs_remove_file(kobj, &up->user_attr.attr);
+	kobject_uevent(kobj, KOBJ_REMOVE);
 	kobject_del(kobj);
 
 	sched_destroy_user(up);
Signature · 2 lines
Regards,
vatsa

This HOWTO explains the steps required to configure a user's cpu share automatically when he/she logs in. This has been verified to work on a Redhat distribution.

Note : This HOWTO is a *hack* to get things working quickly. In particular it doesn't follow standards like LSB.

1. Create a file /etc/user_cpu_share.conf with this format:

	[uid]	[cpu_share]

Ex:

	512	1024	#user vatsa
	514	512	#user guest

2. Create a script, named "kernel.agent" in /etc/hotplug directory as follows. Make that script executable and owned by root.

#!/bin/sh
#

# kernel hotplug agent for 2.6 kernels
#
#       ACTION=add
#       DEVPATH=/kernel/uids/[uid]
#

cd /etc/hotplug
. ./hotplug.functions

case $ACTION in

add)

	uid=${DEVPATH##*/}
	line=`grep -w $uid /etc/user_cpu_share.conf`
	if [ $? -eq 0 ]
	then
		cpu_share=`echo $line | awk '{print $2}'`
		echo $cpu_share > /sys/$DEVPATH/cpu_share
	fi
	;;

*)

	;;

esac

author Applied
#51 lore raw

Re: [PATCH sched-devel] Generate uevents for user creation/destruction

Quoted 15 lines · Srivatsa Vaddagiri
Quoted 4 lines

Shouldn't that be done via uevents? E.g. UID x gets added to the sysfs tree, generates a uevent and a script then figures out the cpu_share and sets it. That way you also don't need to keep the directories. No?

Heiko,
Thanks for the hint. Here's a patch to enable generation of
uevents for user creation/deletion. These uevents can be handled in userspace to configure a new user's cpu share.

Note : After bootup I could test that new user's cpu share is configured as per a configuration file (/etc/user_cpu_share.conf). However this mechanism didnt work for root user. Perhaps uevent for root user is generated way too early?

Quoted 6 lines

A HOWTO text file is also attached explaining how to make use of these uevents in userspace.

Ingo,
This patch applies on top of latest sched-devel tree. Pls
review and apply ..

thanks, applied. This looks reassuringly simple and straightforward!

Ingo

#52 lore raw

Re: [RFC/PATCH] Add sysfs control to modify a user's cpu share

In reply to Dhaval Giani
Quoted 12 lines · Dhaval Giani

Hi Ingo,

Adds tunables in sysfs to modify a user's cpu share.

A directory is created in sysfs for each new user in the system.

/sys/kernel/uids/<uid>/cpu_share

Reading this file returns the cpu shares granted for the user. Writing into this file modifies the cpu share for the user. Only an administrator is allowed to modify a user's cpu share.

Quoted 8 lines

Ex:

	# cd /sys/kernel/uids/
	# cat 512/cpu_share
	1024
	# echo 2048 > 512/cpu_share
	# cat 512/cpu_share
	2048
	#

Can we start adding stuff to Documentation/ for new files created in sysfs ? There's so much undocumented stuff in there now that it's unfunny.

A great start would be 'wtf is a cpu_share and why would I want to change it' ?

Dave

Signature · 1 line
http://www.codemonkey.org.uk
#53 lore raw

Re: [RFC/PATCH] Add sysfs control to modify a user's cpu share

Quoted 3 lines · Dave Jones

Can we start adding stuff to Documentation/ for new files created in sysfs ? There's so much undocumented stuff in there now that it's unfunny.

Hi Dave,
We will in the next version of the patch. At this point, the patch was
sent out to get an idea of whether sysfs is the right place for this interface or not.

Quoted 2 lines

A great start would be 'wtf is a cpu_share and why would I want to change it' ?

Quick answer before we release the next version : This has to do with the CONFIG_FAIR_USER_SCHED feature which allows dividing CPU bandwidth equally between all users of a system. Before this patch, CPU bandwidth was divided equally among all non-root users. After this patch, it will be possible to control CPU bandwidth allocation to each user separately.

For ex: by setting user "vatsa"'s cpu_share to be twice that of user "guest", it would be possible for user "vatsa" to get 2x CPU bandwidth that of user "guest"

--
Regards,
vatsa

#54 lore raw
In reply to Ingo Molnar

Hi;

25 Eyl 2007 Sal tarihinde, Ingo Molnar şunları yazmıştı:

Quoted 14 lines

The latest sched-devel.git tree can be pulled from:

git://git.kernel.org/pub/scm/linux/kernel/git/mingo/linux-2.6-sched-devel.git

Lots of scheduler updates in the past few days, done by many people. Most importantly, the SMP latency problems reported and debugged by Mike Galbraith should be fixed for good now.

I've also included the latest and greatest group-fairness scheduling patch from Srivatsa Vaddagiri, which can now be used without containers as well (in a simplified, each-uid-gets-its-fair-share mode). This feature (CONFIG_FAIR_USER_SCHED) is now default-enabled.

Quoted 8 lines

Peter Zijlstra has been busy enhancing the math of the scheduler: we've got the new 'vslice' forked-task code that should enable snappier shell commands during load while still keeping kbuild workloads in check.

On my testsystems this codebase starts looking like something that could be merged into v2.6.24, so please give it a good workout and let us know if there's anything bad going on. (If this works out fine then i'll propagate these changes back into the CFS backport, for wider testing.)

Seems like following trivial change needed to compile without CONFIG_SCHEDSTATS

caglar@zangetsu linux-2.6 $ LC_ALL=C make

  CHK     include/linux/version.h
  CHK     include/linux/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CHK     include/linux/compile.h
  CC      kernel/sched.o

In file included from kernel/sched.c:853:
kernel/sched_debug.c: In function `print_cfs_rq':
kernel/sched_debug.c:139: error: structure has no member named bkl_cnt' kernel/sched_debug.c:139: error: structure has no member named bkl_cnt' make[1]: *** [kernel/sched.o] Error 1
make: *** [kernel] Error 2

kernel/sched_debug.c +2 -0
index b68e593..4659c90 100644
@@ -136,8 +136,10 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
 			SPLIT_NS(spread0));
 	SEQ_printf(m, "  .%-30s: %ld\n", "nr_running", cfs_rq->nr_running);
 	SEQ_printf(m, "  .%-30s: %ld\n", "load", cfs_rq->load.weight);
+#ifdef CONFIG_SCHEDSTATS
 	SEQ_printf(m, "  .%-30s: %ld\n", "bkl_cnt",
 			rq->bkl_cnt);
+#endif
 	SEQ_printf(m, "  .%-30s: %ld\n", "nr_spread_over",
 			cfs_rq->nr_spread_over);
 }

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!
author Applied
#55 lore raw
Quoted 9 lines · S.Çağlar Onur

Seems like following trivial change needed to compile without CONFIG_SCHEDSTATS

caglar@zangetsu linux-2.6 $ LC_ALL=C make

  CHK     include/linux/version.h
  CHK     include/linux/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CHK     include/linux/compile.h
  CC      kernel/sched.o
Quoted 8 lines

In file included from kernel/sched.c:853:
kernel/sched_debug.c: In function `print_cfs_rq':
kernel/sched_debug.c:139: error: structure has no member named bkl_cnt' kernel/sched_debug.c:139: error: structure has no member named bkl_cnt' make[1]: *** [kernel/sched.o] Error 1
make: *** [kernel] Error 2

thanks, applied!

Ingo

#57 lore raw
Quoted 4 lines · Andrew Morton

This doornails the Vaio. After grub handover the screen remains black and the fan goes whir.

http://userweb.kernel.org/~akpm/config-sony.txt

This seems to be UP regression. Sorry abt that. I could recreate the problem very easily with CONFIG_SMP turned off.

Can you check if this patch works? Works for me here.

--

Fix UP breakage.

---
 kernel/sched.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched.c +1 -1
Index: current/kernel/sched.c
===================================================================
@@ -1029,8 +1029,8 @@ static inline void __set_task_cpu(struct
 {
 #ifdef CONFIG_SMP
 	task_thread_info(p)->cpu = cpu;
-	set_task_cfs_rq(p);
 #endif
+	set_task_cfs_rq(p);
 }
 
 #ifdef CONFIG_SMP
Signature · 2 lines
Regards,
vatsa
#58 lore raw
Quoted 27 lines · On Tue, 25 Sep 2007 14:13:27 +0530 Srivatsa Vaddagiri…
Quoted 4 lines · Andrew Morton

This doornails the Vaio. After grub handover the screen remains black and the fan goes whir.

http://userweb.kernel.org/~akpm/config-sony.txt

This seems to be UP regression. Sorry abt that. I could recreate the problem very easily with CONFIG_SMP turned off.

Can you check if this patch works? Works for me here.

--

Fix UP breakage.

---
 kernel/sched.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: current/kernel/sched.c
===================================================================

kernel/sched.c static inline void __set_task_cpu(struct · line 1036

Quoted 9 lines
kernel/sched.c +1 -1
@@ -1029,8 +1029,8 @@ static inline void __set_task_cpu(struct
 {
 #ifdef CONFIG_SMP
 	task_thread_info(p)->cpu = cpu;
-	set_task_cfs_rq(p);
 #endif
+	set_task_cfs_rq(p);
 }
 
 #ifdef CONFIG_SMP

yup, that's a fix. It was 15 minutes too late for rc8-mm1 though :(

#59 lore raw
In reply to Srivatsa Vaddagiri
Quoted 10 lines · Srivatsa Vaddagiri
Quoted 4 lines · Andrew Morton

This doornails the Vaio. After grub handover the screen remains black and the fan goes whir.

http://userweb.kernel.org/~akpm/config-sony.txt

This seems to be UP regression. Sorry abt that. I could recreate the problem very easily with CONFIG_SMP turned off.

Can you check if this patch works? Works for me here.

thanks - i've put this fix into the core group-scheduling patch.

Ingo