Naoaki MAEDA wrote:
2006/4/21, Patrick.Le-Dot <[EMAIL PROTECTED]>:
Hi,

If DEBUG_PREEMPT is on, cpu_rc_account() and cpu_rc_detect_hunger()
cause a warning message :

BUG: using smp_processor_id() in preemptible [00000001] code: bash/3278
caller is cpu_rc_account+0x11/0xa4
 <c020b40a> debug_smp_processor_id+0x8e/0xa0   <c0132b97> 
cpu_rc_account+0x11/0xa4
 <c011ac7e> do_exit+0x1c/0x3ef   <c011b0eb> sys_exit_group+0x0/0x11
 <c01027ff> sysenter_past_esp+0x54/0x75

Thank you for reporting the problem. Because I put cpu_rc_accout()
to do_exit() from this version, it might be called while preempt enable.
I will fix that.

Attached patch fixex the problem.

Thanks,
MAEDA Naoaki
 kernel/cpu_rc.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

Index: linux-2.6.17-rc2/kernel/cpu_rc.c
===================================================================
--- linux-2.6.17-rc2.orig/kernel/cpu_rc.c
+++ linux-2.6.17-rc2/kernel/cpu_rc.c
@@ -170,21 +170,21 @@ unsigned int cpu_rc_scale_timeslice(task
 void cpu_rc_account(task_t *tsk, unsigned long now)
 {
        struct cpu_rc *cr;
-       int cpu = smp_processor_id();
+       int cpu = get_cpu();
        unsigned long last;
        unsigned int cls_load, tsk_load;
        unsigned long base, update;
 
        if (tsk == idle_task(task_cpu(tsk)))
-               return;
+               goto out;
 
        cr = cpu_rc_get(tsk);
        if (!cr)
-               return;
+               goto out;
 
        base = now - tsk->ts_alloced;
        if (base == 0)
-               return;  /* duration too small. can not collect statistics. */
+               goto out;  /* duration too small. can not collect statistics. */
 
        tsk_load = CPU_RC_LOAD_SCALE * (tsk->last_slice - tsk->time_slice)
                        + (CPU_RC_LOAD_SCALE / 2);
@@ -201,6 +201,8 @@ void cpu_rc_account(task_t *tsk, unsigne
 
        cr->stat[cpu].timestamp = now;
        cr->stat[cpu].load = (cls_load + tsk_load) / CPU_RC_SPREAD_PERIOD;
+out:
+       put_cpu();
 }
 
 /*

Reply via email to