[PATCH] Fix libnuma numa_num_{task vs thread}_{cpu|node}s() naming discrepancy

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

 



libnuma in the numactl-2.0.3 package contains a mismatch the names
of the numa_num_{task|thread}_{cpu|node}s() functions.

The source code and man pages use "numa_num_thread_{cpu|node}s(),
and the numa.h header and versions.ldscript use numa_num_task_{cpu|node}().
This patch resolves this discrepancy by adopting the numa_num_task_*()
names throughout.  The rationale for this choice is as follows:

Although the term 'task' is somewhat kernel centric, it seems less
ambiguous and more correct in user space where the term 'thread' can
refer to the "1x1" or "MxN" thread model.  For 1x1 threads, 'task' and
'thread' are synonymous.  However, for MxN threads, this is not
necessarily the case.  The M user space threads may be scheduled by
the library on different tasks with different mempolicies and cpu
affinity masks.

Since the library is currently broken, no one who hasn't patched the
library can be using these functions.  Cliff and I agreed to go
with the 'task' variants.  No problem going the other way if there
is an outcry in favor of threads.

Meanwhile, this patch also changes the other occurrences of 'thread'
--all in the comments--to 'task' in the numa.h header.  And, while
we're there, let's remove any trailing white space.  Yeah, this
could be broken out into separate patches, but maybe Cliff won't
hold me to kernel patch standards.

Similarly, update numa.3 to replace 'thread' with 'task' as this is
Linux-specific man pages and the term 'task' should be understandable
by anyone using this API.

Signed-off-by: Lee Schermerhorn <lee.schermerhorn@xxxxxx>

 libnuma.c |   22 ++++++++---------
 numa.3    |   76 +++++++++++++++++++++++++++++++-------------------------------
 numa.h    |   34 +++++++++++++--------------
 3 files changed, 66 insertions(+), 66 deletions(-)

Index: numactl-2.0.4-rc2/numa.h
===================================================================
--- numactl-2.0.4-rc2.orig/numa.h	2010-03-29 13:43:16.000000000 -0400
+++ numactl-2.0.4-rc2/numa.h	2010-03-29 13:44:36.000000000 -0400
@@ -11,7 +11,7 @@
    Lesser General Public License for more details.
 
    You should find a copy of v2.1 of the GNU Lesser General Public License
-   somewhere on your Linux system; if not, write to the Free Software 
+   somewhere on your Linux system; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
 
 #ifndef _NUMA_H
@@ -72,13 +72,13 @@ static inline void nodemask_zero(nodemas
 }
 
 static inline void nodemask_zero_compat(nodemask_t *mask)
-{ 
+{
 	struct bitmask tmp;
 
 	tmp.maskp = (unsigned long *)mask;
 	tmp.size = sizeof(nodemask_t) * 8;
 	numa_bitmask_clearall(&tmp);
-} 
+}
 
 static inline void nodemask_set_compat(nodemask_t *mask, int node)
 {
@@ -116,7 +116,7 @@ static inline int nodemask_equal(const n
 }
 
 static inline int nodemask_equal_compat(const nodemask_t *a, const nodemask_t *b)
-{ 
+{
 	struct bitmask tmp_a, tmp_b;
 
 	tmp_a.maskp = (unsigned long *)a;
@@ -126,7 +126,7 @@ static inline int nodemask_equal_compat(
 	tmp_b.size = sizeof(nodemask_t) * 8;
 
 	return numa_bitmask_equal(&tmp_a, &tmp_b);
-} 
+}
 
 /* NUMA support available. If this returns a negative value all other function
    in this library are undefined. */
@@ -144,7 +144,7 @@ int numa_preferred(void);
 long long numa_node_size64(int node, long long *freep);
 long numa_node_size(int node, long *freep);
 
-int numa_pagesize(void); 
+int numa_pagesize(void);
 
 /* Set with all nodes. Only valid after numa_available. */
 extern struct bitmask *numa_all_nodes_ptr;
@@ -180,16 +180,16 @@ static inline void numa_free_nodemask(st
 	numa_bitmask_free(b);
 }
 
-/* Some node to preferably allocate memory from for thread. */
+/* Some node to preferably allocate memory from for task. */
 void numa_set_preferred(int node);
 
-/* Set local memory allocation policy for thread */
+/* Set local memory allocation policy for task */
 void numa_set_localalloc(void);
 
 /* Only allocate memory from the nodes set in mask. 0 to turn off */
 void numa_set_membind(struct bitmask *nodemask);
 
-/* Return current membind */ 
+/* Return current membind */
 struct bitmask *numa_get_membind(void);
 
 /* Return allowed memories [nodes] */
@@ -200,7 +200,7 @@ int numa_get_interleave_node(void);
 /* NUMA memory allocation. These functions always round to page size
    and are relatively slow. */
 
-/* Alloc memory page interleaved on nodes in mask */ 
+/* Alloc memory page interleaved on nodes in mask */
 void *numa_alloc_interleaved_subset(size_t size, struct bitmask *nodemask);
 /* Alloc memory page interleaved on all nodes. */
 void *numa_alloc_interleaved(size_t size);
@@ -231,15 +231,15 @@ void numa_setlocal_memory(void *start, s
 /* Allocate memory area with current memory policy */
 void numa_police_memory(void *start, size_t size);
 
-/* Run current thread only on nodes in mask */
+/* Run current task only on nodes in mask */
 int numa_run_on_node_mask(struct bitmask *mask);
-/* Run current thread only on node */
+/* Run current task only on node */
 int numa_run_on_node(int node);
-/* Return current mask of nodes the thread can run on */
+/* Return current mask of nodes the task can run on */
 struct bitmask * numa_get_run_node_mask(void);
 
 /* When strict fail allocation when memory cannot be allocated in target node(s). */
-void numa_set_bind_policy(int strict);  
+void numa_set_bind_policy(int strict);
 
 /* Fail when existing memory has incompatible policy */
 void numa_set_strict(int flag);
@@ -284,9 +284,9 @@ int numa_distance(int node1, int node2);
    program. Default is to print an error to stderr and exit if numa_exit_on_error
    is true. */
 void numa_error(char *where);
- 
-/* When true exit the program when a NUMA system call (except numa_available) 
-   fails */ 
+
+/* When true exit the program when a NUMA system call (except numa_available)
+   fails */
 extern int numa_exit_on_error;
 /* Warning function. Can also be overwritten. Default is to print on stderr
    once. */
Index: numactl-2.0.4-rc2/libnuma.c
===================================================================
--- numactl-2.0.4-rc2.orig/libnuma.c	2010-02-02 08:32:33.000000000 -0500
+++ numactl-2.0.4-rc2/libnuma.c	2010-03-29 13:46:27.000000000 -0400
@@ -431,7 +431,7 @@ read_mask(char *s, struct bitmask *bmp)
  * /proc/self/status.
  */
 static void
-set_thread_constraints(void)
+set_task_constraints(void)
 {
 	int hicpu = sysconf(_SC_NPROCESSORS_CONF)-1;
 	int i;
@@ -567,7 +567,7 @@ set_sizes(void)
 	set_nodemask_size();	/* size of kernel nodemask_t */
 	set_numa_max_cpu();	/* size of kernel cpumask_t */
 	set_configured_cpus();	/* cpus listed in /sys/devices/system/cpu */
-	set_thread_constraints(); /* cpus and nodes for current thread */
+	set_task_constraints(); /* cpus and nodes for current task */
 }
 
 int
@@ -596,13 +596,13 @@ numa_num_possible_cpus(void)
 }
 
 int
-numa_num_thread_nodes(void)
+numa_num_task_nodes(void)
 {
 	return maxprocnode+1;
 }
 
 int
-numa_num_thread_cpus(void)
+numa_num_task_cpus(void)
 {
 	return maxproccpu+1;
 }
@@ -1664,7 +1664,7 @@ numa_parse_nodestring(char *s)
 	int maxnode = numa_max_node();
 	int invert = 0, relative = 0;
 	int conf_nodes = numa_num_configured_nodes();
-	int thread_nodes = numa_num_thread_nodes();
+	int task_nodes = numa_num_task_nodes();
 	char *end;
 	struct bitmask *mask;
 
@@ -1687,7 +1687,7 @@ numa_parse_nodestring(char *s)
 		int i;
 		if (!strcmp(s,"all")) {
 			int i;
-			for (i = 0; i < thread_nodes; i++)
+			for (i = 0; i < task_nodes; i++)
 				numa_bitmask_setbit(mask, i);
 			s+=4;
 			break;
@@ -1712,7 +1712,7 @@ numa_parse_nodestring(char *s)
 				numa_warn(W_nodeparse, "missing node argument %s\n", s);
 				goto err;
 			}
-			if (arg2 >= thread_nodes) {
+			if (arg2 >= task_nodes) {
 				numa_warn(W_nodeparse, "node argument %d out of range\n", arg2);
 				goto err;
 			}
@@ -1760,7 +1760,7 @@ numa_parse_cpustring(char *s)
 {
 	int invert = 0, relative=0;
 	int conf_cpus = numa_num_configured_cpus();
-	int thread_cpus = numa_num_thread_cpus();
+	int task_cpus = numa_num_task_cpus();
 	char *end;
 	struct bitmask *mask;
 
@@ -1782,7 +1782,7 @@ numa_parse_cpustring(char *s)
 
 		if (!strcmp(s,"all")) {
 			int i;
-			for (i = 0; i < thread_cpus; i++)
+			for (i = 0; i < task_cpus; i++)
 				numa_bitmask_setbit(mask, i);
 			s+=4;
 			break;
@@ -1792,7 +1792,7 @@ numa_parse_cpustring(char *s)
 			numa_warn(W_cpuparse, "unparseable cpu description `%s'\n", s);
 			goto err;
 		}
-		if (arg >= thread_cpus) {
+		if (arg >= task_cpus) {
 			numa_warn(W_cpuparse, "cpu argument %s is out of range\n", s);
 			goto err;
 		}
@@ -1808,7 +1808,7 @@ numa_parse_cpustring(char *s)
 				numa_warn(W_cpuparse, "missing cpu argument %s\n", s);
 				goto err;
 			}
-			if (arg2 >= thread_cpus) {
+			if (arg2 >= task_cpus) {
 				numa_warn(W_cpuparse, "cpu argument %s out of range\n", s);
 				goto err;
 			}
Index: numactl-2.0.4-rc2/numa.3
===================================================================
--- numactl-2.0.4-rc2.orig/numa.3	2010-02-02 08:32:33.000000000 -0500
+++ numactl-2.0.4-rc2/numa.3	2010-03-29 13:49:06.000000000 -0400
@@ -44,9 +44,9 @@ numa \- NUMA policy library
 .br
 .BI "struct bitmask *numa_all_cpus_ptr;"
 .sp
-.BI "int numa_num_thread_cpus();"
+.BI "int numa_num_task_cpus();"
 .br
-.BI "int numa_num_thread_nodes();"
+.BI "int numa_num_task_nodes();"
 .sp
 .BI "int numa_parse_bitmap(char *" line " , struct bitmask *" mask ");
 .br
@@ -177,16 +177,16 @@ page interleaving (i.e., allocate in a r
 or a subset, of the nodes on the system),
 preferred node allocation (i.e., preferably allocate on a particular node),
 local allocation (i.e., allocate on the node on which
-the thread is currently executing),
+the task is currently executing),
 or allocation only on specific nodes (i.e., allocate on
 some subset of the available nodes).
-It is also possible to bind threads to specific nodes.
+It is also possible to bind tasks to specific nodes.
 
-Numa memory allocation policy may be specified as a per-thread attribute,
-that is inherited by children threads and processes, or as an attribute
+Numa memory allocation policy may be specified as a per-task attribute,
+that is inherited by children tasks and processes, or as an attribute
 of a range of process virtual address space.
 Numa memory policies specified for a range of virtual address space are
-shared by all threads in the process.
+shared by all tasks in the process.
 Further more, memory policies specified for a range of a shared memory
 attached using
 .I shmat(2)
@@ -195,7 +195,7 @@ or
 from shmfs/hugetlbfs are shared by all processes that attach to that region.
 Memory policies for shared disk backed file mappings are currently ignored.
 
-The default memory allocation policy for threads and all memory range
+The default memory allocation policy for tasks and all memory range
 is local allocation.
 This assumes that no ancestor has installed a non-default policy.
 
@@ -282,7 +282,7 @@ numbers in /sys/devices/system/cpu. If t
 
 .BR numa_all_nodes_ptr
 points to a bitmask that is allocated by the library with bits
-representing all nodes on which the calling thread may allocate memory.
+representing all nodes on which the calling task may allocate memory.
 This set may be up to all nodes on the system, or up to the nodes in
 the current cpuset.
 The bitmask is allocated by a call to
@@ -302,7 +302,7 @@ The user should not alter this bitmask.
 
 .BR numa_all_cpus_ptr
 points to a bitmask that is allocated by the library with bits
-representing all cpus on which the calling thread may execute.
+representing all cpus on which the calling task may execute.
 This set may be up to all cpus on the system, or up to the cpus in
 the current cpuset.
 The bitmask is allocated by a call to
@@ -312,14 +312,14 @@ using size
 The set of cpus to record is derived from /proc/self/status, field
 "Cpus_allowed".  The user should not alter this bitmask.
 
-.BR numa_num_thread_cpus()
-returns the number of cpus that the calling thread is allowed
+.BR numa_num_task_cpus()
+returns the number of cpus that the calling task is allowed
 to use.  This count is derived from the map /proc/self/status, field
 "Cpus_allowed". Also see the bitmask
 .BR numa_all_cpus_ptr.
 
-.BR numa_num_thread_nodes()
-returns the number of nodes on which the calling thread is
+.BR numa_num_task_nodes()
+returns the number of nodes on which the calling task is
 allowed to allocate memory.  This count is derived from the map
 /proc/self/status, field "Mems_allowed".
 Also see the bitmask
@@ -346,9 +346,9 @@ The bit mask is allocated by
 The string is a comma-separated list of node numbers or node ranges.
 A leading ! can be used to indicate "not" this list (in other words, all
 nodes except this list), and a leading + can be used to indicate that the
-node numbers in the list are relative to the thread's cpuset.  The string can
+node numbers in the list are relative to the task's cpuset.  The string can
 be "all" to specify all (
-.BR numa_num_thread_nodes()
+.BR numa_num_task_nodes()
 ) nodes.  Node numbers are limited by the number in the system.  See
 .BR numa_max_node()
 and
@@ -367,12 +367,12 @@ The bit mask is allocated by
 The string is a comma-separated list of cpu numbers or cpu ranges.
 A leading ! can be used to indicate "not" this list (in other words, all
 cpus except this list), and a leading + can be used to indicate that the cpu
-numbers in the list are relative to the thread's cpuset.  The string can be
+numbers in the list are relative to the task's cpuset.  The string can be
 "all" to specify all (
-.BR numa_num_thread_cpus()
+.BR numa_num_task_cpus()
 ) cpus.
 Cpu numbers are limited by the number in the system.  See
-.BR numa_num_thread_cpus()
+.BR numa_num_task_cpus()
 and
 .BR numa_num_configured_cpus().
 .br
@@ -396,7 +396,7 @@ instead of
 This is useful on 32-bit architectures with large nodes.
 
 .BR numa_preferred ()
-returns the preferred node of the current thread.
+returns the preferred node of the current task.
 This is the node on which the kernel preferably
 allocates memory, unless some other policy overrides this.
 .\" TODO:   results are misleading for MPOL_PREFERRED and may
@@ -406,7 +406,7 @@ allocates memory, unless some other poli
 .\" node.  Need to tighten this up with the syscall results.
 
 .BR numa_set_preferred ()
-sets the preferred node for the current thread to
+sets the preferred node for the current task to
 .IR node .
 The system will attempt to allocate memory from the preferred node,
 but will fall back to other nodes if no memory is available on the
@@ -418,12 +418,12 @@ calling
 .BR numa_set_localalloc ().
 
 .BR numa_get_interleave_mask ()
-returns the current interleave mask if the thread's memory allocation policy
+returns the current interleave mask if the task's memory allocation policy
 is page interleaved.
 Otherwise, this function returns an empty mask.
 
 .BR numa_set_interleave_mask ()
-sets the memory interleave mask for the current thread to
+sets the memory interleave mask for the current task to
 .IR nodemask .
 All new memory allocations
 are page interleaved over all nodes in the interleave mask. Interleaving
@@ -434,7 +434,7 @@ page into the current address space. It 
 will fall back to other nodes if no memory is available on the interleave
 target.
 .\" NOTE:  the following is not really the case.  this function sets the
-.\" thread policy for all future allocations, including stack,  bss, ...
+.\" task policy for all future allocations, including stack,  bss, ...
 .\" The functions specified in this sentence actually allocate a new memory
 .\" range [via mmap()].  This is quite a different thing.  Suggest we drop
 .\" this.
@@ -477,7 +477,7 @@ flag is true then the operation will cau
 pages in the mapping that do not follow the policy.
 
 .BR numa_bind ()
-binds the current thread and its children to the nodes
+binds the current task and its children to the nodes
 specified in
 .IR nodemask .
 They will only run on the CPUs of the specified nodes and only be able to allocate
@@ -488,7 +488,7 @@ This function is equivalent to calling
 .I numa_run_on_node_mask(nodemask)
 followed by
 .IR numa_set_membind(nodemask) .
-If threads should be bound to individual CPUs inside nodes
+If tasks should be bound to individual CPUs inside nodes
 consider using
 .I numa_node_to_cpus
 and the
@@ -496,15 +496,15 @@ and the
 syscall.
 
 .BR numa_set_localalloc ()
-sets the memory allocation policy for the calling thread to
+sets the memory allocation policy for the calling task to
 local allocation.
 In this mode, the preferred node for memory allocation is
-effectively the node where the thread is executing at the
+effectively the node where the task is executing at the
 time of a page allocation.
 
 .BR numa_set_membind ()
 sets the memory allocation mask.
-The thread will only allocate memory from the nodes set in
+The task will only allocate memory from the nodes set in
 .IR nodemask .
 Passing an empty
 .I nodemask
@@ -610,7 +610,7 @@ The
 argument will be rounded up to a multiple of the system page size.
 
 .BR numa_run_on_node ()
-runs the current thread and its children
+runs the current task and its children
 on a specific node. They will not migrate to CPUs of
 other nodes until the node affinity is reset with a new call to
 .BR numa_run_on_node_mask ().
@@ -621,7 +621,7 @@ On success, 0 is returned; on error \-1 
 is set to indicate the error.
 
 .BR numa_run_on_node_mask ()
-runs the current thread and its children only on nodes specified in
+runs the current task and its children only on nodes specified in
 .IR nodemask .
 They will not migrate to CPUs of
 other nodes until the node affinity is reset with a new call to
@@ -636,7 +636,7 @@ On success, 0 is returned; on error \-1 
 is set to indicate the error.
 
 .BR numa_get_run_node_mask ()
-returns the mask of nodes that the current thread is allowed to run on.
+returns the mask of nodes that the current task is allowed to run on.
 
 .BR numa_tonode_memory ()
 put memory on a specific node. The constraints described for
@@ -698,7 +698,7 @@ alternative to repeated calls to the get
 See getpagesize(2).
 
 .BR numa_sched_getaffinity()
-retrieves a bitmask of the cpus on which a thread may run.  The thread is
+retrieves a bitmask of the cpus on which a task may run.  The task is
 specified by
 .I pid.
 Returns the return value of the sched_getaffinity
@@ -710,9 +710,9 @@ Test the bits in the mask by calling
 .BR numa_bitmask_isbitset().
 
 .BR numa_sched_setaffinity()
-sets a thread's allowed cpu's to those cpu's specified in
+sets a task's allowed cpu's to those cpu's specified in
 .I mask.
-The thread is specified by
+The task is specified by
 .I pid.
 Returns the return value of the sched_setaffinity system call.
 See sched_setaffinity(2).  You may allocate the bitmask with
@@ -866,7 +866,7 @@ executing or current process.
 It simply uses the move_pages system call.
 .br
 .I pid
-- ID of thread.  If not valid, use the current thread.
+- ID of task.  If not valid, use the current task.
 .br
 .I count
 - Number of pages.
@@ -887,7 +887,7 @@ See move_pages(2).
 
 .BR numa_migrate_pages()
 simply uses the migrate_pages system call to cause the pages of the calling
-thread, or a specified thread, to be migated from one set of nodes to another.
+task, or a specified task, to be migated from one set of nodes to another.
 See migrate_pages(2).
 The bit masks representing the nodes should be allocated with
 .BR numa_allocate_nodemask()
@@ -897,7 +897,7 @@ using an
 .I n
 value returned from
 .BR numa_num_possible_nodes().
-A thread's current node set can be gotten by calling
+A task's current node set can be gotten by calling
 .BR numa_get_membind().
 Bits in the
 .I tonodes


--
To unsubscribe from this list: send the line "unsubscribe linux-numa" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [Devices]

  Powered by Linux