Skip to contentSkip to conversation

sched_[set|get]_affinity() syscall, 2.4.15-pre9

PATCH Andi Kleen 2 participants 2 messages Nov 27, 2001 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Andi Kleen

author
#1 lore raw
Quoted 6 lines · Joe Korty

I have not yet seen the patch, but one nice feature that a system call interface
could provide is the ability to *atomically* change the cpu affinities of sets of
processes

Could you quickly explain an use case where it makes a difference if CPU affinity settings for multiple processes are done atomically or not ?

The only way to make CPU affinity settings of processes really atomically without a "consolidation window" is to
do them before the process starts up. This is easy when they're inherited -- just set them for the parent before starting the other processes. This works with any interface; proc based or not as long as it inherits.

-Andi

#2 lore raw
Quoted 8 lines · Andi Kleen

Could you quickly explain an use case where it makes a difference if CPU affinity settings for multiple processes are done atomically or not ?

The only way to make CPU affinity settings of processes really atomically without a "consolidation window" is to
do them before the process starts up. This is easy when they're inherited -- just set them for the parent before starting the other processes. This works with any interface; proc based or not as long as it inherits.

I assume he meant to prevent the case of setting affinity _after_ a process forks. In other words, "atomically" in the sense that it occurs prior to some action, in order to affect properly all children.

This could be done in program with by writing to the proc entry before forking, or can be done in a wrapper script (set affinity of self, exec new task).

cpus_allowed is inherited by all children so this works fine.

Robert Love