* [PATCH RT] drop migrate_disabled section in _cpu_down
@ 2014-03-24 12:20 Nicholas Mc Guire
2014-03-24 14:20 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Mc Guire @ 2014-03-24 12:20 UTC (permalink / raw)
To: linux-rt-users
Cc: linux-kernel, rostedt, tglx, Sebastian Andrzej Siewior, Peter Zijlstra
HI !
Minor cleanup: drop unnecessary migrate_disable in _cpu_down
in kernel/cpu.c:_cpu_down
...
cpumask_andnot(cpumask, cpu_online_mask, cpumask_of(cpu));
set_cpus_allowed_ptr(current, cpumask);
...
migrate_disable();
mycpu = smp_processor_id();
if (mycpu == cpu) {
printk(KERN_ERR "Yuck! Still on unplug CPU\n!");
migrate_enable();
err = -EBUSY;
goto restore_cpus;
}
migrate_enable();
If we got migrated off "cpu" then we can not get migrate
back as the cpus_allowed was updated. so if smp_processor_id(); returns
anything != cpu we are fine even if migrated off to a third cpu between
the mycpu = smp_processor_id() and the if (mycpu == cpu). No need for
migration protection here.
Further the migrate disable is effectively only needed for the condition
check in the if statement - so I think it could be replaced by:
if (cpu==smp_processor_id()) {
pr_err("Yuck! Still on unplug CPU\n!");
err = -EBUSY;
goto restore_cpus;
}
even in the case that the cpus_allowed had not been updated.
Patch is against 3.12.13-rt21
Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
---
kernel/cpu.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index ba7416b..fc5566a 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -565,7 +565,7 @@ static int __ref take_cpu_down(void *_param)
/* Requires cpu_add_remove_lock to be held */
static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
{
- int mycpu, err, nr_calls = 0;
+ int err, nr_calls = 0;
void *hcpu = (void *)(long)cpu;
unsigned long mod = tasks_frozen ? CPU_TASKS_FROZEN : 0;
struct take_cpu_down_param tcd_param = {
@@ -593,15 +593,11 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
cpumask_andnot(cpumask, cpu_online_mask, cpumask_of(cpu));
set_cpus_allowed_ptr(current, cpumask);
free_cpumask_var(cpumask);
- migrate_disable();
- mycpu = smp_processor_id();
- if (mycpu == cpu) {
+ if (cpu == smp_processor_id()) {
printk(KERN_ERR "Yuck! Still on unplug CPU\n!");
- migrate_enable();
err = -EBUSY;
goto restore_cpus;
}
- migrate_enable();
cpu_hotplug_begin();
err = cpu_unplug_begin(cpu);
--
1.7.10.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH RT] drop migrate_disabled section in _cpu_down
2014-03-24 12:20 [PATCH RT] drop migrate_disabled section in _cpu_down Nicholas Mc Guire
@ 2014-03-24 14:20 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2014-03-24 14:20 UTC (permalink / raw)
To: Nicholas Mc Guire
Cc: linux-rt-users, linux-kernel, tglx, Sebastian Andrzej Siewior,
Peter Zijlstra
On Mon, 24 Mar 2014 13:20:25 +0100
Nicholas Mc Guire <der.herr@hofr.at> wrote:
> HI !
>
>
> Minor cleanup: drop unnecessary migrate_disable in _cpu_down
>
> in kernel/cpu.c:_cpu_down
> ...
> cpumask_andnot(cpumask, cpu_online_mask, cpumask_of(cpu));
> set_cpus_allowed_ptr(current, cpumask);
> ...
> migrate_disable();
> mycpu = smp_processor_id();
> if (mycpu == cpu) {
> printk(KERN_ERR "Yuck! Still on unplug CPU\n!");
> migrate_enable();
> err = -EBUSY;
> goto restore_cpus;
> }
> migrate_enable();
>
> If we got migrated off "cpu" then we can not get migrate
> back as the cpus_allowed was updated. so if smp_processor_id(); returns
> anything != cpu we are fine even if migrated off to a third cpu between
> the mycpu = smp_processor_id() and the if (mycpu == cpu). No need for
> migration protection here.
>
> Further the migrate disable is effectively only needed for the condition
> check in the if statement - so I think it could be replaced by:
>
> if (cpu==smp_processor_id()) {
> pr_err("Yuck! Still on unplug CPU\n!");
> err = -EBUSY;
> goto restore_cpus;
> }
>
> even in the case that the cpus_allowed had not been updated.
>
> Patch is against 3.12.13-rt21
This is checking for an anomaly, and it's in a very slow path. I feel
more comfortable with keeping the code as is, than to change it for a
micro optimization.
-- Steve
>
> Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-03-24 14:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-24 12:20 [PATCH RT] drop migrate_disabled section in _cpu_down Nicholas Mc Guire
2014-03-24 14:20 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®