On Fri, 5 Sep 2008, Mark Hounschell wrote: > Steven Rostedt wrote: > > On Sun, 31 Aug 2008, Karthik Singaram Lakshmanan wrote: > > > > > Hi, > > > I am a noob to SMP real-time scheduling in linux, I have a question of > > > sched_setaffinity(). If I restrict an application to a single CPU > > > using the appropriate cpumask for sched_setaffinity(), Is it > > > guaranteed that the kernel will never schedule it on any other CPU? I > > > am asking this because looking at kernel/sched.c seems to use > > > cpu_clear during load balancing. I am interested in knowing whether the > > > cache will be invalidated when my task is assigned to a single CPU. > > > Are there exceptions where the cpu-mask will be overridden? > > > Thanks for taking the time to answer my query. > > > > A task should never be scheduled on a CPU that is not in its affinity. > > (although I hear a rumor that if a task is bound to a single CPU, and that > > CPU is taken offline, it will be migrated. But I doubt this is true, since > > there are tasks that would crash the system if this were true). > > > > -- Steve > > > > It seems to be true. It's affinity mask gets changed to the CPUs left online. > At least according to sched_getaffinity. Hmm, it is true: [root@bxrhel51 bin]# ps ax |grep yes 6560 pts/1 R+ 0:31 yes 6566 pts/0 S+ 0:00 grep yes [root@bxrhel51 bin]# taskset -p 8 6560 pid 6560's current affinity mask: f pid 6560's new affinity mask: 8 [root@bxrhel51 bin]# taskset -p 6560 pid 6560's current affinity mask: 8 [root@bxrhel51 bin]# echo 0 > /sys/devices/system/cpu/cpu3/online [root@bxrhel51 bin]# taskset -p 6560 pid 6560's current affinity mask: 7 I ran "yes" and made the affinity set to CPU3. Then I took CPU3 offline and this just made the task move to _all_ other online CPUS. -- Steve -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html