Re: getaffinity/setaffinity and cpu sets.



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
_______________________________________________
freebsd-arch@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • [PATCH 2/3] x86: modify send_IPI_mask interface to accept cpumask_t pointers
    ... static void lapic_timer_broadcast ... Some cpus do not strictly honor the set of cpus ... int hotplug = 1; ... struct irq_cfg *cfg; ...
    (Linux-Kernel)
  • [PATCH 02/31] cpumask: modify send_IPI_mask interface to accept cpumask_t pointers
    ... static void lapic_timer_broadcast ... Some cpus do not strictly honor the set of cpus ... int hotplug = 1; ... struct irq_cfg *cfg; ...
    (Linux-Kernel)
  • Re: Delay Routine: Fully-portable C89 if possible
    ... difference between a 33-Bit int and a 32-Bit int is that the former ... The speed difference will, of course, vary depending on the code in question, and the cpus in question - but some 32-bit cpus work twice as fast on 32-bit data as they do on smaller data, and 8-bit cpus clearly work much faster on the smaller data. ... it avoids multiplies on lookups - multiplies can be costly on small cpus. ... The compiler should pad the struct to ensure that accesses are possible, but not necessarily optimal - if you know the exact sizes, you can add padding yourself to choose a balance between space and speed. ...
    (comp.arch.embedded)
  • Re: [patch 1/7] Immediate Values - Architecture Independent Code
    ... static unsigned int stopmachine_num_threads; ... * help our sisters onto their CPUs. ... all the other CPUs will execute the callback concurrently. ...
    (Linux-Kernel)
  • [patch 1/5] s390: atomic primitives.
    ... /* Wait for all other cpus to enter stopped state */ ... int cpu; ... Copyright 2002 IBM Deutschland Entwicklung GmbH, ... int ret; ...
    (Linux-Kernel)