Re: For review: pthread_setaffinity_np.3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bert,

Thanks for looking the page over.

[...]

>> The argument
>> .I cpusetsize
>> is the length (in bytes) of the buffer pointed to by
>> .IR cpuset .
>> Normally this argument would be specified as
>> .IR sizeof(cpu_set_t) .
>> The constant
>> .B CPU_SETSIZE
>> specifies a value one greater than the
>> maximum CPU number that can be stored in a CPU set.
> Yeah, I like this naming confusion:
>
> http://sourceware.org/ml/libc-alpha/2008-03/msg00080.html
>
>>
>> For more details on CPU affinity masks,
>> as well as a description of a set of macros
>> that can be used to manipulate and inspect CPU sets, see
>> .BR sched_setaffinity (2)
>> for details.
>> .SH RETURN VALUE
>> On success, these functions return 0;
>> on error, they return a non-zero error number.
>> .SH ERRORS
>> .TP
>> .B EFAULT
>> A supplied memory address was invalid.
>> .TP
>> .B EINVAL
>> .RB ( pthread_setaffinity_np ())
>> The affinity bit mask
>> .I mask
>> contains no processors that are physically on the system.
>> .TP
>> .BR EINVAL
>> .RB ( pthread_setaffinity_np ())
>> .I cpuset
>> specified a CPU that was outside the range
>> permitted by the kernel data type
>> .\" cpumask_t
>> used to represent CPU sets.
>> .\" The raw sched_getaffinity() system call returns the size (in bytes)
>> .\" of the cpumask_t type.
> Maybe a more detailed hint is needed, that cpumask_t and cpu_set_t are
> the 'same', the former inside the kernel the latter in user space. But
> I think such deep kernel internals doesn't belong to a API description
> (because cpumask_t may gone, see 'struct cpumask' patches). I would
> just replace cpumask_t by cpu_set_t.

But they are not the same think (which makes things a little weird).
The kernel's cpumask_t is

typedef struct { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;

Where NR_CPUS depends on the CONFIG_NR_CPUS config option.

But in userspace, cpu_set_t is

# define __CPU_SETSIZE  1024
# define __NCPUBITS     (8 * sizeof (__cpu_mask))

/* Data structure to describe CPU mask.  */
typedef struct
{
  __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
} cpu_set_t;

That is, cpu_mask_t is always 1024 bits, but cpumask_t may be (and
typically is) smaller.

[...]

>> .SH SEE ALSO
>> .BR sched_getaffinity (2),
>> .BR sched_setaffinity (2),
>> .BR sched_getscheduler (2),
>> .BR pthread_getaffinity_np (3),
>> .BR pthread_setaffinity_np (3),
> Maybe pthread__attr_{set,get}affinity_np, too.
>
>> .BR cpuset (7),
>> .BR pthreads (7)

Good idea.  And in fact, I had already changed it to:

.SH SEE ALSO
.BR sched_getcpu (3),
.BR sched_setaffinity (2),
.BR sched_setscheduler (2),
.BR pthread_attr_setaffinity_np (3),
.BR pthread_self (3),
.BR cpuset (7),
.BR pthreads (7)

(Some "get" functions disappeared from the list since they are
documented in the corresponding "set" page.)

Cheers,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux