From owner-freebsd-arch@FreeBSD.ORG Wed Jun 5 15:13:46 2013 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 80171496 for ; Wed, 5 Jun 2013 15:13:46 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) by mx1.freebsd.org (Postfix) with ESMTP id 5EB161E90 for ; Wed, 5 Jun 2013 15:13:46 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id AA374B984 for ; Wed, 5 Jun 2013 11:13:45 -0400 (EDT) From: John Baldwin To: freebsd-arch@freebsd.org Subject: Re: [PATCH] Allow atomic sets of non-overlapping CPU sets for a global cpuset Date: Wed, 5 Jun 2013 11:13:33 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p25; KDE/4.5.5; amd64; ; ) References: <201305311216.56558.jhb@freebsd.org> In-Reply-To: <201305311216.56558.jhb@freebsd.org> MIME-Version: 1.0 Message-Id: <201306051113.33907.jhb@freebsd.org> Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 05 Jun 2013 11:13:45 -0400 (EDT) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 15:13:46 -0000 On Friday, May 31, 2013 12:16:56 pm 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 Also note that non-overlapping masks work fine if you change the "local" mask of a process: % cpuset -l 1 /bin/sh $ cpuset -g pid -1 mask: 1 $ cpuset -l 2 -p $$ $ cpuset -g pid -1 mask: 2 -- John Baldwin