From owner-svn-src-head@FreeBSD.ORG Sat Jan 9 12:31:11 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2A52106566B; Sat, 9 Jan 2010 12:31:11 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BF8BB8FC13; Sat, 9 Jan 2010 12:31:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o09CVBrp000792; Sat, 9 Jan 2010 12:31:11 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o09CVBKa000784; Sat, 9 Jan 2010 12:31:11 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201001091231.o09CVBKa000784@svn.freebsd.org> From: Xin LI Date: Sat, 9 Jan 2010 12:31:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r201892 - in head: lib/libc/sys share/man/man3 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jan 2010 12:31:11 -0000 Author: delphij Date: Sat Jan 9 12:31:11 2010 New Revision: 201892 URL: http://svn.freebsd.org/changeset/base/201892 Log: Add a set of manual pages for pthread[_attr]_[sg]etaffinity(3). Reviewed by: davidxu MFC after: 2 weeks Added: head/share/man/man3/pthread_affinity_np.3 (contents, props changed) head/share/man/man3/pthread_attr_affinity_np.3 (contents, props changed) Modified: head/lib/libc/sys/cpuset.2 head/lib/libc/sys/cpuset_getaffinity.2 head/share/man/man3/Makefile head/share/man/man3/pthread.3 head/share/man/man3/pthread_attr.3 Modified: head/lib/libc/sys/cpuset.2 ============================================================================== --- head/lib/libc/sys/cpuset.2 Sat Jan 9 12:28:42 2010 (r201891) +++ head/lib/libc/sys/cpuset.2 Sat Jan 9 12:31:11 2010 (r201892) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 29, 2008 +.Dd January 8, 2010 .Dt CPUSET 2 .Os .Sh NAME @@ -216,7 +216,9 @@ for allocation. .Xr cpuset 1 , .Xr cpuset_getaffinity 2 , .Xr cpuset_setaffinity 2 , -.Xr CPU_SET 3 +.Xr CPU_SET 3 , +.Xr pthread_affinity_np 3 , +.Xr pthread_attr_affinity_np 3 .Sh HISTORY The .Nm Modified: head/lib/libc/sys/cpuset_getaffinity.2 ============================================================================== --- head/lib/libc/sys/cpuset_getaffinity.2 Sat Jan 9 12:28:42 2010 (r201891) +++ head/lib/libc/sys/cpuset_getaffinity.2 Sat Jan 9 12:31:11 2010 (r201892) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 29, 2008 +.Dd January 8, 2010 .Dt CPUSET 2 .Os .Sh NAME @@ -147,7 +147,9 @@ operation. .Xr cpuset 2 , .Xr cpuset_getid 2 , .Xr cpuset_setid 2 , -.Xr CPU_SET 3 +.Xr CPU_SET 3 , +.Xr pthread_affinity_np 3 , +.Xr pthread_attr_affinity_np 3 .Sh HISTORY The .Nm Modified: head/share/man/man3/Makefile ============================================================================== --- head/share/man/man3/Makefile Sat Jan 9 12:28:42 2010 (r201891) +++ head/share/man/man3/Makefile Sat Jan 9 12:31:11 2010 (r201892) @@ -155,8 +155,10 @@ MLINKS+= tree.3 RB_EMPTY.3 \ .if ${MK_LIBTHR} != "no" PTHREAD_MAN= pthread.3 \ + pthread_affinity_np.3 \ pthread_atfork.3 \ pthread_attr.3 \ + pthread_attr_affinity_np.3 \ pthread_attr_get_np.3 \ pthread_attr_setcreatesuspend_np.3 \ pthread_barrierattr.3 \ @@ -218,7 +220,9 @@ PTHREAD_MAN= pthread.3 \ pthread_testcancel.3 \ pthread_yield.3 -PTHREAD_MLINKS= pthread_attr.3 pthread_attr_destroy.3 \ +PTHREAD_MLINKS= pthread_affinity_np.3 pthread_getaffinity_np.3 \ + pthread_affinity_np.3 pthread_setaffinity_np.3 +PTHREAD_MLINKS+=pthread_attr.3 pthread_attr_destroy.3 \ pthread_attr.3 pthread_attr_getdetachstate.3 \ pthread_attr.3 pthread_attr_getguardsize.3 \ pthread_attr.3 pthread_attr_getinheritsched.3 \ @@ -238,6 +242,8 @@ PTHREAD_MLINKS= pthread_attr.3 pthread_a pthread_attr.3 pthread_attr_setstack.3 \ pthread_attr.3 pthread_attr_setstackaddr.3 \ pthread_attr.3 pthread_attr_setstacksize.3 +PTHREAD_MLINKS+=pthread_attr_affinity_np.3 pthread_attr_getaffinity_np.3 \ + pthread_attr_affinity_np.3 pthread_attr_setaffinity_np.3 PTHREAD_MLINKS+=pthread_barrierattr.3 pthread_barrierattr_destroy.3 \ pthread_barrierattr.3 pthread_barrierattr_getpshared.3 \ pthread_barrierattr.3 pthread_barrierattr_init.3 \ Modified: head/share/man/man3/pthread.3 ============================================================================== --- head/share/man/man3/pthread.3 Sat Jan 9 12:28:42 2010 (r201891) +++ head/share/man/man3/pthread.3 Sat Jan 9 12:31:11 2010 (r201892) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 1, 2009 +.Dd January 8, 2010 .Dt PTHREAD 3 .Os .Sh NAME @@ -478,7 +478,9 @@ functions and the thread functions. Threaded applications are linked with this library. .Sh SEE ALSO .Xr libthr 3 , +.Xr pthread_affinity_np 3 , .Xr pthread_atfork 3 , +.Xr pthread_attr 3 , .Xr pthread_cancel 3 , .Xr pthread_cleanup_pop 3 , .Xr pthread_cleanup_push 3 , Added: head/share/man/man3/pthread_affinity_np.3 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man3/pthread_affinity_np.3 Sat Jan 9 12:31:11 2010 (r201892) @@ -0,0 +1,157 @@ +.\"- +.\" Copyright (c) 2010 Xin LI +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd January 8, 2010 +.Dt PTHREAD_AFFINITY_NP 3 +.Os +.Sh NAME +.Nm pthread_getaffinity_np , +.Nm pthread_setaffinity_np +.Nd manage CPU affinity +.Sh LIBRARY +.Lb libpthread +.Sh SYNOPSIS +.In pthread_np.h +.Ft int +.Fn pthread_getaffinity_np "pthread_t td" "size_t cpusetsize" "cpuset_t *cpusetp" +.Ft int +.Fn pthread_setaffinity_np "pthread_t td" "size_t cpusetsize" "const cpuset_t *cpusetp" +.Sh DESCRIPTION +.Fn pthread_getaffinity_np +and +.Fn pthread_setaffinity_np +allow the manipulation of sets of CPUs available to specified thread. +.Pp +Masks of type +.Ft cpuset_t +are composed using the +.Xr CPU_SET 2 +macros. +The kernel tolerates large sets as long as all CPUs specified +in the set exist. +Sets smaller than the kernel uses generate an error on calls to +.Fn pthread_getaffinity_np +even if the result set would fit within the user supplied set. +Calls to +.Fn pthread_setaffinity_np +tolerate small sets with no restrictions. +.Pp +The supplied mask should have a size of +.Fa cpusetsize +bytes. +This size is usually provided by calling +.Li sizeof(cpuset_t) +which is ultimately determined by the value of +.Dv CPU_SETSIZE +as defined in +.In sys/cpuset.h . +.Pp +.Fn pthread_getaffinity_np +retrieves the +mask from the thread specified by +.Fa td , +and stores it in the space provided by +.Fa cpumaskp . +.Pp +.Fn pthread_setaffinity_np +attempts to set the mask for the thread specified by +.Fa td +to the value in +.Fa cpumaskp . +.Pp +.Sh RETURN VALUES +If successful, the +.Fn pthread_getaffinity_np +and +.Fn pthread_setaffinity_np +functions will return zero. +Otherwise an error number will be returned +to indicate the error. +.Sh ERRORS +The +.Fn pthread_getaffinity_np +and +.Fn pthread_setaffinity_np +functions may fail if: +.Bl -tag -width Er +.It Bq Er EDEADLK +The +.Fn pthread_setaffinity_np +call would leave a thread without a valid CPU to run on because the set +does not overlap with the thread's anonymous mask. +.It Bq Er EFAULT +The +.Fa cpumaskp +pointer passed was invalid. +.It Bq Er ESRCH +The thread specified by the +.Fa td +argument could not be found. +.It Bq Er ERANGE +The +.Fa cpusetsize +was either preposterously large or smaller than the kernel set size. +.It Bq Er EPERM +The calling thread did not have the credentials required to complete the +operation. +.El +.Sh SEE ALSO +.Xr cpuset 1 , +.Xr cpuset 2 , +.Xr cpuset_getid 2 , +.Xr cpuset_setid 2 , +.Xr CPU_SET 3 , +.Xr pthread 3 , +.Xr pthread_attr_get_affinity_np 3 , +.Xr pthread_attr_set_affinity_np 3 . +.Sh STANDARDS +The +.Nm pthread_getaffinity_np +and +.Nm pthread_setaffinity_np +functions are non-standard +.Fx +extensions and may be not available on other operating systems. +.Sh HISTORY +The +.Nm pthread_getaffinity_np +and +.Nm pthread_setaffinity_np +function first appeared in +.Fx 7.2 . +.Sh AUTHORS +.An -nosplit +The +.Nm pthread_getaffinity_np +and +.Nm pthread_setaffinity_np +functions were written by +.An David Xu +.Aq davidxu@FreeBSD.org , +and this manpage was written by +.An Xin LI +.Aq delphij@FreeBSD.org . Modified: head/share/man/man3/pthread_attr.3 ============================================================================== --- head/share/man/man3/pthread_attr.3 Sat Jan 9 12:28:42 2010 (r201891) +++ head/share/man/man3/pthread_attr.3 Sat Jan 9 12:31:11 2010 (r201892) @@ -26,7 +26,7 @@ .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd April 28, 2000 +.Dd January 8, 2010 .Dt PTHREAD_ATTR 3 .Os .Sh NAME @@ -209,9 +209,9 @@ Invalid or unsupported value for .El .Sh SEE ALSO .Xr pthread_attr_get_np 3 , +.Xr pthread_attr_affinity_np 3 , .Xr pthread_create 3 .Sh STANDARDS -The .Fn pthread_attr_init , .Fn pthread_attr_destroy , .Fn pthread_attr_setstacksize , Added: head/share/man/man3/pthread_attr_affinity_np.3 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man3/pthread_attr_affinity_np.3 Sat Jan 9 12:31:11 2010 (r201892) @@ -0,0 +1,150 @@ +.\"- +.\" Copyright (c) 2010 Xin LI +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd January 8, 2010 +.Dt PTHREAD_ATTR_AFFINITY_NP 3 +.Os +.Sh NAME +.Nm pthread_attr_getaffinity_np , +.Nm pthread_attr_setaffinity_np +.Nd manage CPU affinity in thread attribute object +.Sh LIBRARY +.Lb libpthread +.Sh SYNOPSIS +.In pthread_np.h +.Ft int +.Fn pthread_attr_getaffinity_np "const pthread_attr_t *pattr" "size_t cpusetsize" "cpuset_t *cpusetp" +.Ft int +.Fn pthread_attr_setaffinity_np "pthread_attr_t *pattr" "size_t cpusetsize" "const cpuset_t *cpusetp" +.Sh DESCRIPTION +.Fn pthread_attr_getaffinity_np +and +.Fn pthread_attr_setaffinity_np +allow the manipulation of sets of CPUs available to specified thread attribute object. +.Pp +Masks of type +.Ft cpuset_t +are composed using the +.Xr CPU_SET 2 +macros. +The kernel tolerates large sets as long as all CPUs specified +in the set exist. +Sets smaller than the kernel uses generate an error on calls to +.Fn pthread_attr_getaffinity_np +even if the result set would fit within the user supplied set. +Calls to +.Fn pthread_attr_setaffinity_np +tolerate small sets with no restrictions. +.Pp +The supplied mask should have a size of +.Fa cpusetsize +bytes. +This size is usually provided by calling +.Li sizeof(cpuset_t) +which is ultimately determined by the value of +.Dv CPU_SETSIZE +as defined in +.In sys/cpuset.h . +.Pp +.Fn pthread_attr_getaffinity_np +retrieves the +mask from the thread attribute object specified by +.Fa pattr , +and stores it in the space provided by +.Fa cpumaskp . +.Pp +.Fn pthread_attr_setaffinity_np +set the mask for the thread attribute object specified by +.Fa pattr +to the value in +.Fa cpumaskp . +.Pp +.Sh RETURN VALUES +If successful, the +.Fn pthread_attr_getaffinity_np +and +.Fn pthread_attr_setaffinity_np +functions will return zero. +Otherwise an error number will be returned +to indicate the error. +.Sh ERRORS +The +.Fn pthread_attr_getaffinity_np +and +.Fn pthread_attr_setaffinity_np +functions will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa pattr +or the attribute specified by it is NULL. +.El +.Pp +The +.Fn pthread_attr_setaffinity_np +function will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa pattr +or the attribute specified by it is NULL. +.It Bq Er ENOMEM +Insufficient memory exists to store the cpuset mask. +.El +.Sh SEE ALSO +.Xr cpuset 1 , +.Xr cpuset 2 , +.Xr cpuset_getid 2 , +.Xr cpuset_setid 2 , +.Xr CPU_SET 3 , +.Xr pthread_get_affinity_np 3 , +.Xr pthread_set_affinity_np 3 . +.Sh STANDARDS +The +.Nm pthread_attr_getaffinity_np +and +.Nm pthread_attr_setaffinity_np +functions are non-standard +.Fx +extensions and may be not available on other operating systems. +.Sh HISTORY +The +.Nm pthread_attr_getaffinity_np +and +.Nm pthread_attr_setaffinity_np +functions first appeared in +.Fx 7.2 . +.Sh AUTHORS +.An -nosplit +The +.Nm pthread_attr_getaffinity_np +and +.Nm pthread_attr_setaffinity_np +functions were written by +.An David Xu Aq davidxu@FreeBSD.org , +and this manpage was written by +.An Xin LI Aq delphij@FreeBSD.org .