From: "Bert Wesarg" <bert.wesarg-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
To: Loic Domaigne <tech-Z4JMKDdsf89Wk0Htik3J/w@public.gmane.org>
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
josv-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
"brian m. carlson"
<sandals-spVehEqlxw627WubY2PhZQivdfXVPZ6z@public.gmane.org>,
Stefan Puiu
<stefanpuiuro-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>,
Karsten Weiss
<K.Weiss-Pt+Xe7GJXK+P2YhJcF5u+nqWYbMAw+HU@public.gmane.org>
Subject: Re: For review: pthread_setaffinity_np.3
Date: Mon, 10 Nov 2008 19:38:16 +0100 [thread overview]
Message-ID: <36ca99e90811101038v62348fc0mbb366219168bf2ff@mail.gmail.com> (raw)
In-Reply-To: <4916133A.8060209-Z4JMKDdsf89Wk0Htik3J/w@public.gmane.org>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 3669 bytes --]
On Sat, Nov 8, 2008 at 23:31, Loic Domaigne <tech@domaigne.com> wrote:
> Hi Michael,
>
> this one is not 'straightforward' for me as I needed to look into the glibc
> and kernel source...
>
> I am not very knowledgeable in that area, so my review comments are in
> consequence...
>
> Cheers,
> Loïc
> --
>
>> .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
>> .\" <mtk.manpages@gmail.com>
>> .\"
>> .\" Permission is granted to make and distribute verbatim copies of this
>> .\" manual provided the copyright notice and this permission notice are
>> .\" preserved on all copies.
>> .\"
>> .\" Permission is granted to copy and distribute modified versions of this
>> .\" manual under the conditions for verbatim copying, provided that the
>> .\" entire resulting derived work is distributed under the terms of a
>> .\" permission notice identical to this one.
>> .\"
>> .\" Since the Linux kernel and libraries are constantly changing, this
>> .\" manual page may be incorrect or out-of-date. The author(s) assume no
>> .\" responsibility for errors or omissions, or for damages resulting from
>> .\" the use of the information contained herein. The author(s) may not
>> .\" have taken the same level of care in the production of this manual,
>> .\" which is licensed free of charge, as they might when working
>> .\" professionally.
>> .\"
>> .\" Formatted or processed versions of this manual, if unaccompanied by
>> .\" the source, must acknowledge the copyright and authors of this work.
>> .\"
>> .TH PTHREAD_SETAFFINITY_NP 3 2008-11-04 "Linux" "Linux Programmer's
>> Manual"
>> .SH NAME
>> pthread_setaffinity_np, pthread_getaffinity_np \- set/get
>> CPU affinity of a thread
>> .SH SYNOPSIS
>> .nf
>> .B #define _GNU_SOURCE
>> .B #include <pthread.h>
>>
>> .BI "int pthread_setaffinity_np(pthread_t " thread ", size_t " cpusetsize
>> ,
>> .BI " const cpu_set_t *" cpuset );
>> .BI "int pthread_getaffinity_np(pthread_t " thread ", size_t " cpusetsize
>> ,
>> .BI " cpu_set_t *" cpuset );
>> .sp
>> Compile and link with \fI\-pthread\fP.
>> .SH DESCRIPTION
>> The
>> .BR pthread_setaffinity_np ()
>> sets the CPU affinity mask of the thread
>> .I thread
>> to the CPU set pointed to by
>> .IR cpuset .
>> If the call is successful,
>> and the thread is not currently running on one of the CPUs in
>> .IR cpuset ,
>> then it is migrated to one of those CPUs.
>>
>> The
>> .BR pthread_getaffinity_np ()
>> function returns the CPU affinity mask of the thread
>> .I thread
>> in the buffer pointed to by
>> .IR cpuset .
>>
>> 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.
>
> I came independently to the same conclusion than you. AFAICS,glibc defines
> the cpu_set_t to be a 1024 bits long structure. But the kernel defines the
> corresponding structure to be a bit field of appropriate length to store
> NR_CPUS.
>
> Interesting enough, the exact size of the kernel structure is determined by
> the glibc on the 1st call to pthread_setaffinity_np().
>
> We'll run into troubles if run this on a server with more than 1K core ;-)
Thats why glibc provides a new set of function to handle cpu_set_t
with more than 1K bits.
Look for the definitions of macros with a _S suffix in <sched.h>.
Bert
N§²æìr¸yúèØb²X¬¶Ç§vØ^)Þº{.nÇ+·¥{±©âØ^nr¡ö¦zË\x1aëh¨èÚ&¢îý»\x05ËÛÔØï¦v¬Îf\x1dp)¹¹br ê+Ê+zf£¢·h§~Ûiÿûàz¹\x1e®w¥¢¸?¨èÚ&¢)ߢ^[f
next prev parent reply other threads:[~2008-11-10 18:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-04 22:47 For review: pthread_setaffinity_np.3 Michael Kerrisk
[not found] ` <cfd18e0f0811041447w57dd5de4he68ca780ed963074-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-05 18:00 ` Bert Wesarg
[not found] ` <36ca99e90811051000j619ff316u8c836352627fe4a0-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-06 19:32 ` Michael Kerrisk
2008-11-08 22:31 ` Loic Domaigne
[not found] ` <4916133A.8060209-Z4JMKDdsf89Wk0Htik3J/w@public.gmane.org>
2008-11-10 18:38 ` Bert Wesarg [this message]
[not found] ` <36ca99e90811101038v62348fc0mbb366219168bf2ff-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-13 2:30 ` Michael Kerrisk
[not found] ` <cfd18e0f0811121830u3dc6ea30va0298bdbedf1f2fb-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-13 7:32 ` Bert Wesarg
2008-11-14 15:04 ` Michael Kerrisk
[not found] ` <cfd18e0f0811140704l18e5741fgdbb5a6c52fb8cbe7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-14 15:38 ` Michael Kerrisk
[not found] ` <001636c5b6831e5a44045ba80779@googlemail.com>
[not found] ` <001636c5b6831e5a44045ba80779-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2008-11-14 15:45 ` Delivery Status Notification (Failure) Michael Kerrisk
[not found] ` <cfd18e0f0811140745k69075aend9686e463c9c1a4d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-14 15:56 ` Bert Wesarg
[not found] ` <36ca99e90811140756q7c445d5ei7c31c5b59df7c7a7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-14 16:02 ` Michael Kerrisk
[not found] ` <cfd18e0f0811140802i2c06e0am164648735fa7dda3-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-14 16:26 ` Christoph Lameter
[not found] ` <Pine.LNX.4.64.0811141026080.24886-dRBSpnHQED8AvxtiuMwx3w@public.gmane.org>
2008-11-14 16:39 ` Christoph Lameter
[not found] ` <Pine.LNX.4.64.0811141038510.25195-dRBSpnHQED8AvxtiuMwx3w@public.gmane.org>
2008-11-14 16:43 ` Michael Kerrisk
[not found] ` <cfd18e0f0811140843q42971316wfade996b67aa2a6-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-14 20:45 ` David Rientjes
[not found] ` <cfd18e0f0811140738i33f2c671kc99bbb7750f2fa44-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-14 15:52 ` For review: pthread_setaffinity_np.3 Bert Wesarg
[not found] ` <36ca99e90811140752t1c04f87do88926777d2be614a-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-14 16:04 ` Michael Kerrisk
2008-11-14 15:50 ` Michael Kerrisk
[not found] ` <cfd18e0f0811140750r5a22255bx7bd53c580b42cc6-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-11-15 19:41 ` Loic Domaigne
[not found] ` <491F25D1.8020007-Z4JMKDdsf89Wk0Htik3J/w@public.gmane.org>
2008-11-17 17:15 ` Michael Kerrisk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=36ca99e90811101038v62348fc0mbb366219168bf2ff@mail.gmail.com \
--to=bert.wesarg-gm/ye1e23mwn+bqq9rbeug@public.gmane.org \
--cc=K.Weiss-Pt+Xe7GJXK+P2YhJcF5u+nqWYbMAw+HU@public.gmane.org \
--cc=josv-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=sandals-spVehEqlxw627WubY2PhZQivdfXVPZ6z@public.gmane.org \
--cc=stefanpuiuro-/E1597aS9LQAvxtiuMwx3w@public.gmane.org \
--cc=tech-Z4JMKDdsf89Wk0Htik3J/w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox