All of lore.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 4/8] numactl/libnuma - return freeable bitmasks
Date: Tue, 28 Apr 2009 12:36:44 -0400	[thread overview]
Message-ID: <20090428163644.24945.43171.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20090428163621.24945.95516.sendpatchset@localhost.localdomain>

[PATCH 04/08] - Return freeable masks

Against:  numactl-2.0.3-rc2

The V2+ libnuma API provides functions to free masks [bit, cpu, node]
returned by some functions.  [It should probably be more specific
about it being the caller's responsibility to free such masks.]
However, in some cases, the library returns pointers to libnuma
internal masks, such as numa_no_nodes.

Instead, return pointer to freshly allocated mask that the caller can
free without affecting the library's internal operation.

Kornilious replaced my bogus structure assignments with calls to
copy_bitmask_to_bitmask()   --lts


 libnuma.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

Index: numactl-2.0.3-rc2/libnuma.c
===================================================================
--- numactl-2.0.3-rc2.orig/libnuma.c	2009-04-27 16:49:39.000000000 -0400
+++ numactl-2.0.3-rc2/libnuma.c	2009-04-27 16:50:00.000000000 -0400
@@ -896,9 +896,9 @@ numa_get_interleave_mask_v2(void)
 
 	bmp = numa_allocate_nodemask();
 	getpol(&oldpolicy, bmp);
-	if (oldpolicy == MPOL_INTERLEAVE)
-		return bmp;
-	return numa_no_nodes_ptr;
+	if (oldpolicy != MPOL_INTERLEAVE)
+		copy_bitmask_to_bitmask(numa_no_nodes_ptr, bmp);
+	return bmp;
 } 
 __asm__(".symver numa_get_interleave_mask_v2,numa_get_interleave_mask@@libnuma_1.2");
 
@@ -1055,9 +1055,9 @@ numa_get_membind_v2(void)
 
 	bmp = numa_allocate_nodemask();
 	getpol(&oldpolicy, bmp);
-	if (oldpolicy == MPOL_BIND)
-		return bmp;
-	return numa_all_nodes_ptr;
+	if (oldpolicy != MPOL_BIND)
+		copy_bitmask_to_bitmask(numa_all_nodes_ptr, bmp);
+	return bmp;
 } 
 __asm__(".symver numa_get_membind_v2,numa_get_membind@@libnuma_1.2");
 
@@ -1629,8 +1629,10 @@ numa_parse_nodestring(char *s)
 
 	mask = numa_allocate_nodemask();
 
-	if (s[0] == 0)
-		return numa_no_nodes_ptr;
+	if (s[0] == 0){
+		copy_bitmask_to_bitmask(numa_no_nodes_ptr, mask);
+		return mask; /* return freeable mask */
+	}
 	if (*s == '!') {
 		invert = 1;
 		s++;

  parent 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 ` [PATCH 1/8] numactl/libnuma - Possibly already fixed leaks and cleanup Lee Schermerhorn
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 ` Lee Schermerhorn [this message]
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=20090428163644.24945.43171.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.