From owner-freebsd-arch@FreeBSD.ORG Thu Feb 21 16:34:21 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E88116A400; Thu, 21 Feb 2008 16:34:21 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 05E7413C458; Thu, 21 Feb 2008 16:34:20 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.2/8.14.2/NETPLEX) with ESMTP id m1LGY95t000213; Thu, 21 Feb 2008 11:34:09 -0500 (EST) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.0 (mail.netplex.net [204.213.176.10]); Thu, 21 Feb 2008 11:34:09 -0500 (EST) Date: Thu, 21 Feb 2008 11:34:09 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Jeff Roberson In-Reply-To: <20080220213253.A920@desktop> Message-ID: References: <20071219211025.T899@desktop> <18311.49715.457070.397815@grasshopper.cs.duke.edu> <20080112182948.F36731@fledge.watson.org> <20080112170831.A957@desktop> <20080112194521.I957@desktop> <20080219234101.D920@desktop> <20080220101348.D44565@fledge.watson.org> <20080220005030.Y920@desktop> <20080220105333.G44565@fledge.watson.org> <47BCEFDB.5040207@freebsd.org> <20080220175532.Q920@desktop> <20080220213253.A920@desktop> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: arch@freebsd.org, Robert Watson , David Xu , Andrew Gallatin Subject: Re: getaffinity/setaffinity and cpu sets. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Feb 2008 16:34:21 -0000 On Wed, 20 Feb 2008, Jeff Roberson wrote: > I have the following api working: > > /* > * Parameters for the level argument to getaffinity. > */ > #define CPU_LEVEL_SYS 1 /* All system cpus. */ > #define CPU_LEVEL_AVAIL 2 /* Available cpus for which. */ > #define CPU_LEVEL_WHICH 3 /* Actual mask for which. */ > > /* > * Parameters for the which argument to {get,set}affinity. > */ > #define CPU_WHICH_TID 1 /* Specifies a thread id. */ > #define CPU_WHICH_PID 2 /* Specifies a process id. */ > #define CPU_WHICH_SET 3 /* Specifies a set id. */ > > > Along with a CPU_CLR, CPU_COPY, CPU_ISSET, CPU_SET, CPU_ZERO for manipulating > the sets. > > int getaffinity(int level, int which, int id, int cpusetsize, long *mask); > int setaffinity(int which, int id, int cpusetsize, long *mask); > > The get call has a notion of 'level' which allows us to fetch different > masks. The system set is all processors in the system. The available set is > the set of cpus available to the tid/pid in the 'which' argument. An > application would fetch the avail set and then potentially reduce it. > > The setaffinity call doesn't have a level because the avail/sys sets are > immutable. You can only set things which can be specified by the which > argument. Everything looks pretty good to me, but if you add the 'level' to setaffinity(), you might be able to say "run on any ONE of the CPUs in the cpuset - I don't care which one". -- DE