[PATCH 3/10] numactl/libnuma - cleanup local allocation behavior

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

 



PATCH 3/10 numactl - fix/cleanup libnuma local allocation behavior

Against:  numactl 1.0.3-rc1

1) In numa_alloc_local(), use MPOL_PREFERRED with NULL nodemask to
   effect local allocation.  MPOL_DEFAULT, when used with mbind()
   [i.e., vma policy], only specifies local allocation if task policy
   is also DEFAULT.  

2) For "local allocation" task policy [numa_set_preferred() and
   numa_set_localalloc()], it is more efficient to specify MPOL_DEFAULT
   and let the task fall back to system default policy.  This effectively
   removes any existing task policy.

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

 libnuma.c |   16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

Index: numactl-1.0.3-rc1/libnuma.c
===================================================================
--- numactl-1.0.3-rc1.orig/libnuma.c	2008-03-27 18:19:40.000000000 -0400
+++ numactl-1.0.3-rc1/libnuma.c	2008-03-28 09:56:55.000000000 -0400
@@ -933,7 +933,7 @@ void *numa_alloc_local(size_t size) 
 		   0, 0); 
 	if (mem == (char *)-1)
 		return NULL;
-	dombind(mem, size, MPOL_DEFAULT, NULL); 
+	dombind(mem, size, MPOL_PREFERRED, NULL);
 	return mem; 	
 } 
 
@@ -1498,21 +1498,17 @@ void numa_set_preferred(int node)
 	struct bitmask *bmp;
 
 	bmp = numa_allocate_nodemask();
-	if (node >= 0)
+	if (node >= 0) {
 		numa_bitmask_setbit(bmp, node);
-	setpol(MPOL_PREFERRED, bmp);
+		setpol(MPOL_PREFERRED, bmp);
+	} else
+		setpol(MPOL_DEFAULT, bmp);
 	numa_bitmask_free(bmp);
-	return;
 } 
 
 void numa_set_localalloc(void) 
 {	
-	struct bitmask *bmp;
-
-	bmp = numa_allocate_nodemask();
-	setpol(MPOL_PREFERRED, bmp);
-	numa_bitmask_free(bmp);
-	return;
+	setpol(MPOL_DEFAULT, numa_no_nodes_ptr);
 } 
 
 void numa_bind_v1(const nodemask_t *nodemask)
--
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