Re: [PATCH] explicitly bind idle tasks
Nathan Lynch wrote: With hotplug cpu and preempt, we tend to see smp_processor_id warnings from idle loop code because it's always checking whether its cpu has gone offline. Replacing every use of smp_processor_id with _smp_processor_id in all idle loop code is one solution; another way is explicitly binding idle threads to their cpus (the smp_processor_id warning does not fire if the caller is bound only to the calling cpu). This has the (admittedly slight) advantage of letting us know if an idle thread ever runs on the wrong cpu. I also prefer explicitly binding idle threads to their cpus instead of replacing use of smp_processor_id with _smp_processor_id. Signed-off-by: Nathan Lynch <[EMAIL PROTECTED]> Acked-by: Joel Schopp <[EMAIL PROTECTED]> Index: linux-2.6.11-rc5-mm1/init/main.c === --- linux-2.6.11-rc5-mm1.orig/init/main.c 2005-03-02 00:12:07.0 + +++ linux-2.6.11-rc5-mm1/init/main.c 2005-03-02 00:53:04.0 + @@ -638,6 +638,10 @@ { lock_kernel(); /* + * init can run on any cpu. + */ + set_cpus_allowed(current, CPU_MASK_ALL); + /* * Tell the world that we're going to be the grim * reaper of innocent orphaned children. * Index: linux-2.6.11-rc5-mm1/kernel/sched.c === --- linux-2.6.11-rc5-mm1.orig/kernel/sched.c 2005-03-02 00:12:07.0 + +++ linux-2.6.11-rc5-mm1/kernel/sched.c 2005-03-02 00:47:14.0 + @@ -4092,6 +4092,7 @@ idle->array = NULL; idle->prio = MAX_PRIO; idle->state = TASK_RUNNING; + idle->cpus_allowed = cpumask_of_cpu(cpu); set_task_cpu(idle, cpu); spin_lock_irqsave(>lock, flags); - 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/ - 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/
Re: [PATCH] explicitly bind idle tasks
Nathan Lynch wrote: With hotplug cpu and preempt, we tend to see smp_processor_id warnings from idle loop code because it's always checking whether its cpu has gone offline. Replacing every use of smp_processor_id with _smp_processor_id in all idle loop code is one solution; another way is explicitly binding idle threads to their cpus (the smp_processor_id warning does not fire if the caller is bound only to the calling cpu). This has the (admittedly slight) advantage of letting us know if an idle thread ever runs on the wrong cpu. I also prefer explicitly binding idle threads to their cpus instead of replacing use of smp_processor_id with _smp_processor_id. Signed-off-by: Nathan Lynch [EMAIL PROTECTED] Acked-by: Joel Schopp [EMAIL PROTECTED] Index: linux-2.6.11-rc5-mm1/init/main.c === --- linux-2.6.11-rc5-mm1.orig/init/main.c 2005-03-02 00:12:07.0 + +++ linux-2.6.11-rc5-mm1/init/main.c 2005-03-02 00:53:04.0 + @@ -638,6 +638,10 @@ { lock_kernel(); /* + * init can run on any cpu. + */ + set_cpus_allowed(current, CPU_MASK_ALL); + /* * Tell the world that we're going to be the grim * reaper of innocent orphaned children. * Index: linux-2.6.11-rc5-mm1/kernel/sched.c === --- linux-2.6.11-rc5-mm1.orig/kernel/sched.c 2005-03-02 00:12:07.0 + +++ linux-2.6.11-rc5-mm1/kernel/sched.c 2005-03-02 00:47:14.0 + @@ -4092,6 +4092,7 @@ idle-array = NULL; idle-prio = MAX_PRIO; idle-state = TASK_RUNNING; + idle-cpus_allowed = cpumask_of_cpu(cpu); set_task_cpu(idle, cpu); spin_lock_irqsave(rq-lock, flags); - 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/ - 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/
Re: [PATCH] explicitly bind idle tasks
On Tue, 1 Mar 2005, Nathan Lynch wrote: > On Sun, Feb 27, 2005 at 02:49:28PM -0800, Andrew Morton wrote: > > Benjamin Herrenschmidt <[EMAIL PROTECTED]> wrote: > > > > > > > - if (cpu_is_offline(smp_processor_id()) && > > > > + if (cpu_is_offline(_smp_processor_id()) && > > > >system_state == SYSTEM_RUNNING) > > > >cpu_die(); > > > >} > > > > _ > > > > > > This is the idle loop. Is that ever supposed to be preempted ? > > > > Nope, it's a false positive. We had to do the same in x86's idle loop and > > probably others will hit it. > > Perhaps I'm missing something, but is there any reason we can't do > the following? I've tested it on ppc64, doesn't seem to break anything. > > With hotplug cpu and preempt, we tend to see smp_processor_id warnings > from idle loop code because it's always checking whether its cpu has > gone offline. Replacing every use of smp_processor_id with > _smp_processor_id in all idle loop code is one solution; another way > is explicitly binding idle threads to their cpus (the smp_processor_id > warning does not fire if the caller is bound only to the calling cpu). > This has the (admittedly slight) advantage of letting us know if an > idle thread ever runs on the wrong cpu. Makes sense to me, for some reason i thought the smp_processor_id() function did a cpu_rq->idle check of some sort. Thanks, Zwane - 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/
[PATCH] explicitly bind idle tasks
On Sun, Feb 27, 2005 at 02:49:28PM -0800, Andrew Morton wrote: > Benjamin Herrenschmidt <[EMAIL PROTECTED]> wrote: > > > > > - if (cpu_is_offline(smp_processor_id()) && > > > +if (cpu_is_offline(_smp_processor_id()) && > > > system_state == SYSTEM_RUNNING) > > > cpu_die(); > > > } > > > _ > > > > This is the idle loop. Is that ever supposed to be preempted ? > > Nope, it's a false positive. We had to do the same in x86's idle loop and > probably others will hit it. Perhaps I'm missing something, but is there any reason we can't do the following? I've tested it on ppc64, doesn't seem to break anything. With hotplug cpu and preempt, we tend to see smp_processor_id warnings from idle loop code because it's always checking whether its cpu has gone offline. Replacing every use of smp_processor_id with _smp_processor_id in all idle loop code is one solution; another way is explicitly binding idle threads to their cpus (the smp_processor_id warning does not fire if the caller is bound only to the calling cpu). This has the (admittedly slight) advantage of letting us know if an idle thread ever runs on the wrong cpu. Signed-off-by: Nathan Lynch <[EMAIL PROTECTED]> Index: linux-2.6.11-rc5-mm1/init/main.c === --- linux-2.6.11-rc5-mm1.orig/init/main.c 2005-03-02 00:12:07.0 + +++ linux-2.6.11-rc5-mm1/init/main.c2005-03-02 00:53:04.0 + @@ -638,6 +638,10 @@ { lock_kernel(); /* +* init can run on any cpu. +*/ + set_cpus_allowed(current, CPU_MASK_ALL); + /* * Tell the world that we're going to be the grim * reaper of innocent orphaned children. * Index: linux-2.6.11-rc5-mm1/kernel/sched.c === --- linux-2.6.11-rc5-mm1.orig/kernel/sched.c2005-03-02 00:12:07.0 + +++ linux-2.6.11-rc5-mm1/kernel/sched.c 2005-03-02 00:47:14.0 + @@ -4092,6 +4092,7 @@ idle->array = NULL; idle->prio = MAX_PRIO; idle->state = TASK_RUNNING; + idle->cpus_allowed = cpumask_of_cpu(cpu); set_task_cpu(idle, cpu); spin_lock_irqsave(>lock, flags); - 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/
[PATCH] explicitly bind idle tasks
On Sun, Feb 27, 2005 at 02:49:28PM -0800, Andrew Morton wrote: Benjamin Herrenschmidt [EMAIL PROTECTED] wrote: - if (cpu_is_offline(smp_processor_id()) +if (cpu_is_offline(_smp_processor_id()) system_state == SYSTEM_RUNNING) cpu_die(); } _ This is the idle loop. Is that ever supposed to be preempted ? Nope, it's a false positive. We had to do the same in x86's idle loop and probably others will hit it. Perhaps I'm missing something, but is there any reason we can't do the following? I've tested it on ppc64, doesn't seem to break anything. With hotplug cpu and preempt, we tend to see smp_processor_id warnings from idle loop code because it's always checking whether its cpu has gone offline. Replacing every use of smp_processor_id with _smp_processor_id in all idle loop code is one solution; another way is explicitly binding idle threads to their cpus (the smp_processor_id warning does not fire if the caller is bound only to the calling cpu). This has the (admittedly slight) advantage of letting us know if an idle thread ever runs on the wrong cpu. Signed-off-by: Nathan Lynch [EMAIL PROTECTED] Index: linux-2.6.11-rc5-mm1/init/main.c === --- linux-2.6.11-rc5-mm1.orig/init/main.c 2005-03-02 00:12:07.0 + +++ linux-2.6.11-rc5-mm1/init/main.c2005-03-02 00:53:04.0 + @@ -638,6 +638,10 @@ { lock_kernel(); /* +* init can run on any cpu. +*/ + set_cpus_allowed(current, CPU_MASK_ALL); + /* * Tell the world that we're going to be the grim * reaper of innocent orphaned children. * Index: linux-2.6.11-rc5-mm1/kernel/sched.c === --- linux-2.6.11-rc5-mm1.orig/kernel/sched.c2005-03-02 00:12:07.0 + +++ linux-2.6.11-rc5-mm1/kernel/sched.c 2005-03-02 00:47:14.0 + @@ -4092,6 +4092,7 @@ idle-array = NULL; idle-prio = MAX_PRIO; idle-state = TASK_RUNNING; + idle-cpus_allowed = cpumask_of_cpu(cpu); set_task_cpu(idle, cpu); spin_lock_irqsave(rq-lock, flags); - 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/
Re: [PATCH] explicitly bind idle tasks
On Tue, 1 Mar 2005, Nathan Lynch wrote: On Sun, Feb 27, 2005 at 02:49:28PM -0800, Andrew Morton wrote: Benjamin Herrenschmidt [EMAIL PROTECTED] wrote: - if (cpu_is_offline(smp_processor_id()) + if (cpu_is_offline(_smp_processor_id()) system_state == SYSTEM_RUNNING) cpu_die(); } _ This is the idle loop. Is that ever supposed to be preempted ? Nope, it's a false positive. We had to do the same in x86's idle loop and probably others will hit it. Perhaps I'm missing something, but is there any reason we can't do the following? I've tested it on ppc64, doesn't seem to break anything. With hotplug cpu and preempt, we tend to see smp_processor_id warnings from idle loop code because it's always checking whether its cpu has gone offline. Replacing every use of smp_processor_id with _smp_processor_id in all idle loop code is one solution; another way is explicitly binding idle threads to their cpus (the smp_processor_id warning does not fire if the caller is bound only to the calling cpu). This has the (admittedly slight) advantage of letting us know if an idle thread ever runs on the wrong cpu. Makes sense to me, for some reason i thought the smp_processor_id() function did a cpu_rq-idle check of some sort. Thanks, Zwane - 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/