public inbox for linux-numa@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Schermerhorn <lee.schermerhorn@hp.com>
To: Cliff Wickman <cpi@sgi.com>
Cc: Kornilios Kourtis <kkourt@cslab.ece.ntua.gr>,
	Brice Goglin <Brice.Goglin@inria.fr>,
	linux-numa@vger.kernel.org, eric.whitney@hp.com
Subject: [PATCH 1/8] numactl/libnuma - Possibly already fixed leaks and cleanup
Date: Tue, 28 Apr 2009 12:36:27 -0400	[thread overview]
Message-ID: <20090428163627.24945.23606.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20090428163621.24945.95516.sendpatchset@localhost.localdomain>

[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)

  reply	other threads:[~2009-04-28 16:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-28 16:36 [PATCH 0/8] numactl/libnuma - Fixes and Cleanup Lee Schermerhorn
2009-04-28 16:36 ` Lee Schermerhorn [this message]
2009-04-28 16:36 ` [PATCH 2/8] numactl/libnuma - Simple bitmask leak fixes Lee Schermerhorn
2009-04-28 16:36 ` [PATCH 3/8] numactl/libnuma - more " Lee Schermerhorn
2009-04-28 16:36 ` [PATCH 4/8] numactl/libnuma - return freeable bitmasks Lee Schermerhorn
2009-04-28 16:36 ` [PATCH 5/8] numactl/libnuma - fix parsing of cpu, node mask Lee Schermerhorn
2009-04-28 16:36 ` [PATCH 6/8] numactl/numademo - eliminate page allocation overhead from memtest measurements Lee Schermerhorn
2009-04-28 16:37 ` [PATCH 7/8] numactl/Makefile - Generalize Makefile .so Version Lee Schermerhorn
2009-04-28 16:46   ` Andi Kleen
2009-04-28 17:01     ` Lee Schermerhorn
2009-04-28 17:10       ` Andi Kleen
2009-04-28 16:37 ` [PATCH 8/8] numactl/test - Make checkaffinity more robust Lee Schermerhorn
2009-04-28 19:38 ` [PATCH 0/8] numactl/libnuma - Fixes and Cleanup Cliff Wickman
2009-04-28 20:08   ` Lee Schermerhorn

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=20090428163627.24945.23606.sendpatchset@localhost.localdomain \
    --to=lee.schermerhorn@hp.com \
    --cc=Brice.Goglin@inria.fr \
    --cc=cpi@sgi.com \
    --cc=eric.whitney@hp.com \
    --cc=kkourt@cslab.ece.ntua.gr \
    --cc=linux-numa@vger.kernel.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