[PATCH 1/8] numactl/libnuma - Possibly already fixed leaks and cleanup

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

 



[PATCH 01/08] Possibly already fixed leaks and cleanup

Against:  numactl-2.0.3-rc2

Kornilios says these [Hunks #1 and 3] are already fixed,
so I pulled them into a separate patch.

Hunk #2 that modifies numa_alloc_local() just reorganizes the code
to match the structure of numa_alloc_onnode() with, I think, no change
in behavior.  This is probably not "already fixed".

I suppose I could/should change those '(char *)-1's to MAP_FAILED, too...


 libnuma.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

Index: numactl-2.0.3-rc2/libnuma.c
===================================================================
--- numactl-2.0.3-rc2.orig/libnuma.c	2009-04-27 08:47:14.000000000 -0400
+++ numactl-2.0.3-rc2/libnuma.c	2009-04-27 09:01:33.000000000 -0400
@@ -919,8 +919,10 @@ void *numa_alloc_onnode(size_t size, int
 	mem = mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
 		   0, 0);  
 	if (mem == (char *)-1)
-		return NULL;		
-	dombind(mem, size, bind_policy, bmp);
+		mem = NULL;
+	else
+		dombind(mem, size, bind_policy, bmp);
+	numa_bitmask_free(bmp);
 	return mem; 	
 } 
 
@@ -930,8 +932,9 @@ void *numa_alloc_local(size_t size) 
 	mem = mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
 		   0, 0); 
 	if (mem == (char *)-1)
-		return NULL;
-	dombind(mem, size, MPOL_PREFERRED, NULL);
+		mem =  NULL;
+	else
+		dombind(mem, size, MPOL_PREFERRED, NULL);
 	return mem; 	
 } 
 
@@ -1496,7 +1499,7 @@ int numa_run_on_node(int node)
 
 int numa_preferred(void)
 { 
-	int policy;
+	int policy, node = 0;
 	struct bitmask *bmp;
 
 	bmp = numa_allocate_nodemask();
@@ -1505,12 +1508,15 @@ int numa_preferred(void)
 		int i;
 		int max = numa_num_possible_nodes();
 		for (i = 0; i < max ; i++) 
-			if (numa_bitmask_isbitset(bmp, i))
-				return i; 
+			if (numa_bitmask_isbitset(bmp, i)) {
+				node = i;
+				break;
+			}
 	}
 	/* could read the current CPU from /proc/self/status. Probably 
 	   not worth it. */
-	return 0; /* or random one? */
+	numa_bitmask_free(bmp);
+	return node;
 }
 
 void numa_set_preferred(int node)
--
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