Patchwork [1/1] sparc: task_cpu() for stopper thread on sparc32 returns 0

login
register
mail settings
Submitter Konrad Eisele
Date April 19, 2012, 9:22 a.m.
Message ID <1334827362-3434-1-git-send-email-konrad@gaisler.com>
Download mbox | patch
Permalink /patch/153710/
State RFC
Delegated to: David Miller
Headers show

Comments

Konrad Eisele - April 19, 2012, 9:22 a.m.
The stopper thread for CPU > 0 (at least in sparc32)
has on initialization task_cpu() set to zero even
for CPUs > 0. The patch explicitly checks weather the
CPU is allowed to run on the cpu that task_cpu()
return or changes the return cpu.

Signed-off-by: Konrad Eisele <konrad@gaisler.com>
---
 kernel/sched/stop_task.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
Sam Ravnborg - April 19, 2012, 3:34 p.m.
Added a few more people - as this patch touches a core file.

I expect we have an issue on sparc32 - that manifest
in this bug. But I do not know this code at all.

	Sam

On Thu, Apr 19, 2012 at 11:22:42AM +0200, Konrad Eisele wrote:
> The stopper thread for CPU > 0 (at least in sparc32)
> has on initialization task_cpu() set to zero even
> for CPUs > 0. The patch explicitly checks weather the
> CPU is allowed to run on the cpu that task_cpu()
> return or changes the return cpu.
> 
> Signed-off-by: Konrad Eisele <konrad@gaisler.com>
> ---
>  kernel/sched/stop_task.c |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/kernel/sched/stop_task.c b/kernel/sched/stop_task.c
> index 7b386e8..9201866 100644
> --- a/kernel/sched/stop_task.c
> +++ b/kernel/sched/stop_task.c
> @@ -13,7 +13,14 @@
>  static int
>  select_task_rq_stop(struct task_struct *p, int sd_flag, int flags)
>  {
> -	return task_cpu(p); /* stop tasks as never migrate */
> +	int ccpu, cpu , dcpu;
> +	ccpu = cpu = task_cpu(p);
> +	if (unlikely(!cpumask_test_cpu(cpu, tsk_cpus_allowed(p)))) {
> +		cpu = cpumask_first(tsk_cpus_allowed(p));
> +		if (cpu >= nr_cpu_ids)
> +			cpu = ccpu;
> +	}
> +	return cpu;
>  }
>  #endif /* CONFIG_SMP */
>  
> -- 
> 1.6.1.3
> 
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - April 19, 2012, 5:35 p.m.
From: Konrad Eisele <konrad@gaisler.com>
Date: Thu, 19 Apr 2012 11:22:42 +0200

> The stopper thread for CPU > 0 (at least in sparc32)
> has on initialization task_cpu() set to zero even
> for CPUs > 0. The patch explicitly checks weather the
> CPU is allowed to run on the cpu that task_cpu()
> return or changes the return cpu.
> 
> Signed-off-by: Konrad Eisele <konrad@gaisler.com>

Posting a patch to generic code like this only to the Sparc
list isn't going to drive us forward to a solution and will
not involve the people who need to help you look into this
problem.

Therefore you need to post this with at least linux-kernel
and the scheduler maintainer's CC:'d.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/kernel/sched/stop_task.c b/kernel/sched/stop_task.c
index 7b386e8..9201866 100644
--- a/kernel/sched/stop_task.c
+++ b/kernel/sched/stop_task.c
@@ -13,7 +13,14 @@ 
 static int
 select_task_rq_stop(struct task_struct *p, int sd_flag, int flags)
 {
-	return task_cpu(p); /* stop tasks as never migrate */
+	int ccpu, cpu , dcpu;
+	ccpu = cpu = task_cpu(p);
+	if (unlikely(!cpumask_test_cpu(cpu, tsk_cpus_allowed(p)))) {
+		cpu = cpumask_first(tsk_cpus_allowed(p));
+		if (cpu >= nr_cpu_ids)
+			cpu = ccpu;
+	}
+	return cpu;
 }
 #endif /* CONFIG_SMP */