public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* 2.6.16 - sys_sched_getaffinity & hotplug
@ 2006-01-27 23:06 Jack Steiner
  2006-01-28  2:58 ` Nathan Lynch
  2006-01-28  3:14 ` Paul Jackson
  0 siblings, 2 replies; 20+ messages in thread
From: Jack Steiner @ 2006-01-27 23:06 UTC (permalink / raw)
  To: mingo; +Cc: linux-kernel


It appears if CONFIG_HOTPLUG_CPU is enabled, then all possible
cpus (0 .. NR_CPUS-1) are set in the cpu_possible_map on IA64.

	void __init
	smp_build_cpu_map (void)
	{
	...
        	for (cpu = 0; cpu < NR_CPUS; cpu++) {
                	ia64_cpu_to_sapicid[cpu] = -1;
	#ifdef CONFIG_HOTPLUG_CPU				<<<<
                	cpu_set(cpu, cpu_possible_map);		<<<<
	#endif							<<<<
        	}


sched_getaffinity() returns the cpu_possible_map and'd with the current
task p->cpus_allowed. The default cpus_allowed is all ones.

This is causing problems for apps that use sched_get_sched_affinity()
to determine which cpus that they are allowed to run on.
The call to sched_getaffinity returns:

	(from strace on a 2 cpu system with NR_CPUS = 512)
	sched_getaffinity(0, 1024,  { ffffffffffffffff, ffffff ...



The man page for sched_getaffinity() is ambiguous. It says:
	- A set bit corresponds to a legally  schedulable  CPU

But it also says:
	- Usually, all bits in the mask are set.


Should the following change be made to sched_getaffinity(). 

Index: linux/kernel/sched.c
===================================================================
--- linux.orig/kernel/sched.c	2006-01-25 08:50:21.401747695 -0600
+++ linux/kernel/sched.c	2006-01-27 16:57:24.504871895 -0600
@@ -4031,7 +4031,7 @@ long sched_getaffinity(pid_t pid, cpumas
 		goto out_unlock;
 
 	retval = 0;
-	cpus_and(*mask, p->cpus_allowed, cpu_possible_map);
+	cpus_and(*mask, p->cpus_allowed, cpu_online_map);
 
 out_unlock:
 	read_unlock(&tasklist_lock);

-- 
Thanks

Jack Steiner (steiner@sgi.com)



^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2006-01-29 17:26 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-27 23:06 2.6.16 - sys_sched_getaffinity & hotplug Jack Steiner
2006-01-28  2:58 ` Nathan Lynch
2006-01-29 13:06   ` Jack Steiner
2006-01-28  3:14 ` Paul Jackson
2006-01-28  3:42   ` Nathan Lynch
2006-01-28  4:58     ` Paul Jackson
2006-01-28  5:23       ` Nathan Lynch
2006-01-28  6:40         ` Paul Jackson
2006-01-28  7:04         ` Paul Jackson
2006-01-28 13:32   ` Ingo Molnar
2006-01-28 16:08     ` Jack Steiner
2006-01-28 19:27     ` Nathan Lynch
2006-01-28 20:06       ` Paul Jackson
2006-01-29 13:51         ` [PATCH] " Jack Steiner
2006-01-28 20:09     ` 2.6.16 " Paul Jackson
2006-01-28 20:50       ` Robert Love
2006-01-28 21:00         ` Paul Jackson
2006-01-29 13:01         ` Ingo Molnar
2006-01-29 16:09           ` Robert Love
2006-01-29 17:26             ` Paul Jackson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox