On Fri, May 13, 2005 at 07:58:51PM -0700, Paul Jackson wrote:
>
> So how would you, or Srivatsa or Nathan, respond to my more substantive
> point, to repeat:
>
> Srivatsa, replying to Dinakar:
> > This in fact was the reason that we added lock_cpu_hotplug
> > in sched_setaffinity.
>
> Why just in sched_setaffinity()?
I suspect that the lock_cpu_hotplug is no longer necessary in
sched_setaffinity. I found the original changeset which introduced
it, and it's short enough that I'll just duplicate it here:
diff -Naru a/kernel/sched.c b/kernel/sched.c
--- a/kernel/sched.c 2005-05-14 07:21:39 -07:00
+++ b/kernel/sched.c 2005-05-14 07:21:39 -07:00
@@ -1012,6 +1012,7 @@
unsigned long flags;
cpumask_t old_mask, new_mask = cpumask_of_cpu(dest_cpu);
+ lock_cpu_hotplug();
rq = task_rq_lock(p, &flags);
old_mask = p->cpus_allowed;
if (!cpu_isset(dest_cpu, old_mask) || !cpu_online(dest_cpu))
@@ -1035,6 +1036,7 @@
}
out:
task_rq_unlock(rq, &flags);
+ unlock_cpu_hotplug();
}
/*
@@ -2309,11 +2311,13 @@
if (copy_from_user(&new_mask, user_mask_ptr, sizeof(new_mask)))
return -EFAULT;
+ lock_cpu_hotplug();
read_lock(&tasklist_lock);
p = find_process_by_pid(pid);
if (!p) {
read_unlock(&tasklist_lock);
+ unlock_cpu_hotplug();
return -ESRCH;
}
@@ -2334,6 +2338,7 @@
out_unlock:
put_task_struct(p);
+ unlock_cpu_hotplug();
return retval;
}
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/03/19 08:02:56-08:00 [email protected]
# [PATCH] Hotplug CPUs: Take cpu Lock Around Migration
#
# Grab cpu lock around sched_migrate_task() and
#sys_sched_setaffinity().
# This is a noop without CONFIG_HOTPLUG_CPU.
#
# The sched_migrate_task may have a performance penalty on NUMA if
#lots
# of exec rebalancing is happening, however this only applies to
# CONFIG_NUMA and CONFIG_HOTPLUG_CPU, which noone does at the moment
# anyway.
#
# Also, the scheduler in -mm solves the race another way, so this
#will
# vanish then.
#
# kernel/sched.c
# 2004/03/16 18:10:10-08:00 [email protected] +5 -0
# Hotplug CPUs: Take cpu Lock Around Migration
#
The lock/unlock_cpu_hotplug is no longer there in sched_migrate_task.
The changelog leads me to believe that it was intended that the same
change should have been made to sched_setaffinity by now. I think
it's safe to remove it; I can't see why it would be necessary any
more.
Nathan
-
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/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]