61 lines
1.9 KiB
Diff
61 lines
1.9 KiB
Diff
From 4c6df3d78817c20a147c0291f6600d002c0910d3 Mon Sep 17 00:00:00 2001
|
|
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
Date: Fri, 14 Jun 2013 17:16:35 +0200
|
|
Subject: [PATCH] kernel/hotplug: restore original cpu mask oncpu/down
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.0/patches-4.0.5-rt3.tar.xz
|
|
|
|
If a task which is allowed to run only on CPU X puts CPU Y down then it
|
|
will be allowed on all CPUs but the on CPU Y after it comes back from
|
|
kernel. This patch ensures that we don't lose the initial setting unless
|
|
the CPU the task is running is going down.
|
|
|
|
Cc: stable-rt@vger.kernel.org
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
---
|
|
kernel/cpu.c | 13 ++++++++++++-
|
|
1 file changed, 12 insertions(+), 1 deletion(-)
|
|
|
|
--- a/kernel/cpu.c
|
|
+++ b/kernel/cpu.c
|
|
@@ -637,6 +637,7 @@ static int __ref _cpu_down(unsigned int
|
|
.hcpu = hcpu,
|
|
};
|
|
cpumask_var_t cpumask;
|
|
+ cpumask_var_t cpumask_org;
|
|
|
|
if (num_online_cpus() == 1)
|
|
return -EBUSY;
|
|
@@ -647,6 +648,12 @@ static int __ref _cpu_down(unsigned int
|
|
/* Move the downtaker off the unplug cpu */
|
|
if (!alloc_cpumask_var(&cpumask, GFP_KERNEL))
|
|
return -ENOMEM;
|
|
+ if (!alloc_cpumask_var(&cpumask_org, GFP_KERNEL)) {
|
|
+ free_cpumask_var(cpumask);
|
|
+ return -ENOMEM;
|
|
+ }
|
|
+
|
|
+ cpumask_copy(cpumask_org, tsk_cpus_allowed(current));
|
|
cpumask_andnot(cpumask, cpu_online_mask, cpumask_of(cpu));
|
|
set_cpus_allowed_ptr(current, cpumask);
|
|
free_cpumask_var(cpumask);
|
|
@@ -655,7 +662,8 @@ static int __ref _cpu_down(unsigned int
|
|
if (mycpu == cpu) {
|
|
printk(KERN_ERR "Yuck! Still on unplug CPU\n!");
|
|
migrate_enable();
|
|
- return -EBUSY;
|
|
+ err = -EBUSY;
|
|
+ goto restore_cpus;
|
|
}
|
|
|
|
cpu_hotplug_begin();
|
|
@@ -733,6 +741,9 @@ static int __ref _cpu_down(unsigned int
|
|
cpu_hotplug_done();
|
|
if (!err)
|
|
cpu_notify_nofail(CPU_POST_DEAD | mod, hcpu);
|
|
+restore_cpus:
|
|
+ set_cpus_allowed_ptr(current, cpumask_org);
|
|
+ free_cpumask_var(cpumask_org);
|
|
return err;
|
|
}
|
|
|