[PATCH] Allow atomic sets of non-overlapping CPU sets for a global cpuset

David Xu davidxu at freebsd.org
Wed Jun 5 09:52:01 UTC 2013


On 2013/06/01 00:16, John Baldwin wrote:
> So there's an oddity with cpuset I've run into recently at work.  Suppose I
> have created a new cpuset and want to change the set of CPUs for that set (say
> from a mask of just CPU 1 to a mask of just CPU 2).  I can't do that
> atomically.  I have to first set the mask to contain both the old set (CPU 1)
> and the new set (CPU 2) and then change it a second time to only contain the
> new set (CPU 2).  The reason is that cpuset_modify() runs cpuset_testupdate()
> on the set it is about to modify, so when I try to change it in a single
> operation the new mask doesn't overlap with the old mask and it fails with
> EDEADLK.
>
> % cpuset -c -l 1 /bin/sh
> $ cpuset -gi
> pid -1 cpuset id: 2
> $ cpuset -g
> pid -1 mask: 1
> $ cpuset -l 2 -s 2
> cpuset: setaffinity: Resource deadlock avoided
>
> I think that the correct logic here is that we should only check descendants
> of the set we are changing, but not the set we are about to change.  The patch
> does this and allows my test case above to work:

The patch looks fine to me.




More information about the freebsd-arch mailing list