[patch, 2.6.9-rc4-mm1, 2.6.9-rc4] fix the prof=schedule feature

From: Ingo Molnar
Date: Fri Oct 15 2004 - 04:20:44 EST



* Andrew Morton <akpm@xxxxxxxx> wrote:

> > in the next mail i will send a patch against 2.6.9-rc4 too (which
> > luckily doesnt have the crash bug, but has the feature mismerge).
>
> OK. So it sounds like no additional patch will be needed for -mm?

the sched.c chunks below are still needed. prof=schedule must be driven
from schedule(), not from setscheduler().

The profile.c one is a cleanup. [ and you surely must be a great fan of
profiler cleanups by now B-) ]

the patch applies to 2.6.9-rc4 cleanly as well, and the sched.c bits are
necessary there too. I have tested this patch with and without
prof=schedule and it now produces the expected results:

314 work_resched 14.2727
389 log_wait_commit 1.2006
391 kjournald 0.6872
499 need_resched 9.9800
1549 worker_thread 2.5310
1649 wait_for_completion 7.4615
2551 do_exit 2.6435
2999 schedule_timeout 16.7542
3073 io_schedule 64.0208
7863 preempt_schedule 126.8226

the above is the scheduling profile of a bootup. ~40% of the reschedules
were caused by PREEMPT, ~20% by IO and the remaining ~40% by process
communication.

without this patch the output is a boring empty profile ...

Ingo

Signed-off-by: Ingo Molnar <mingo@xxxxxxx>

--- linux/kernel/sched.c.orig
+++ linux/kernel/sched.c
@@ -2646,6 +2646,7 @@ asmlinkage void __sched schedule(void)
dump_stack();
}
}
+ profile_hit(SCHED_PROFILING, __builtin_return_address(0));

need_resched:
preempt_disable();
@@ -3222,7 +3223,6 @@ static int setscheduler(pid_t pid, int p
policy != SCHED_NORMAL)
goto out_unlock;
}
- profile_hit(SCHED_PROFILING, __builtin_return_address(0));

/*
* Valid priorities for SCHED_FIFO and SCHED_RR are
--- linux/kernel/profile.c.orig
+++ linux/kernel/profile.c
@@ -22,14 +22,14 @@ static int __init profile_setup(char * s
int par;

if (!strncmp(str, "schedule", 8)) {
- prof_on = 2;
+ prof_on = SCHED_PROFILING;
printk(KERN_INFO "kernel schedule profiling enabled\n");
if (str[7] == ',')
str += 8;
}
if (get_option(&str,&par)) {
prof_shift = par;
- prof_on = 1;
+ prof_on = CPU_PROFILING;
printk(KERN_INFO "kernel profiling enabled (shift: %ld)\n",
prof_shift);
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/