Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 05 Jun 2013 17:52:34 +0800
From:      David Xu <davidxu@freebsd.org>
To:        John Baldwin <jhb@freebsd.org>
Cc:        arch@freebsd.org
Subject:   Re: [PATCH] Allow atomic sets of non-overlapping CPU sets for a global cpuset
Message-ID:  <51AF0A62.4040206@freebsd.org>
In-Reply-To: <201305311216.56558.jhb@freebsd.org>
References:  <201305311216.56558.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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.





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51AF0A62.4040206>