All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Rusty Russell <rusty@rustcorp.com.au>,
	Peter Zijlstra <peterz@infradead.org>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Xunlei Pang <xlpang@redhat.com>, Rik van Riel <riel@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 4/4] cpumask: Rename 'alloc_cpumask_var_node()' to '__alloc_cpumask_var_node()'
Date: Mon,  7 Dec 2015 09:49:44 +0100	[thread overview]
Message-ID: <1449478184-27168-5-git-send-email-mingo@kernel.org> (raw)
In-Reply-To: <1449478184-27168-1-git-send-email-mingo@kernel.org>

Add a double underscore to this API, to make it very clear that this is an
internal API with unusual semantics: for example on !CPUMASK_OFFSTACK
kernels it will result in initialized cpumasks, while on CPUMASK_OFFSTACK
kernels it will allocate a var-cpumask that is not initialized. The
caller has to make sure this initialization happens.

Also add this information to the documentation of the API.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/cpumask.h |  4 ++--
 lib/cpumask.c           | 16 ++++++++++------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 719fecaa64e4..7ed1e1f8e806 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -653,7 +653,7 @@ typedef struct cpumask *cpumask_var_t;
 
 #define this_cpu_cpumask_var_ptr(x) this_cpu_read(x)
 
-bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node);
+bool __alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node);
 bool zalloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node);
 bool zalloc_cpumask_var(cpumask_var_t *mask, gfp_t flags);
 void zalloc_bootmem_cpumask_var(cpumask_var_t *mask);
@@ -665,7 +665,7 @@ typedef struct cpumask cpumask_var_t[1];
 
 #define this_cpu_cpumask_var_ptr(x) this_cpu_ptr(x)
 
-static inline bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags,
+static inline bool __alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags,
 					  int node)
 {
 	return true;
diff --git a/lib/cpumask.c b/lib/cpumask.c
index cb9b80284274..c291d993fb9c 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -45,7 +45,7 @@ int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
 /* These are not inline because of header tangles. */
 #ifdef CONFIG_CPUMASK_OFFSTACK
 /**
- * alloc_cpumask_var_node - allocate a struct cpumask on a given node
+ * __alloc_cpumask_var_node - allocate a struct cpumask on a given node
  * @mask: pointer to cpumask_var_t where the cpumask is returned
  * @flags: GFP_ flags
  *
@@ -57,8 +57,12 @@ int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
  * usually smart enough to know that mask can never be NULL if
  * CONFIG_CPUMASK_OFFSTACK=n, so does code elimination in that case
  * too.
+ *
+ * ( Also note that the freshly allocated mask will not be zero
+ *   initialized - in contrast to !CONFIG_CPUMASK_OFFSTACK kernels
+ *   which typically pass in masks that are already initialized. )
  */
-bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node)
+bool __alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node)
 {
 	*mask = kmalloc_node(cpumask_size(), flags, node);
 
@@ -71,11 +75,11 @@ bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node)
 
 	return *mask != NULL;
 }
-EXPORT_SYMBOL(alloc_cpumask_var_node);
+EXPORT_SYMBOL(__alloc_cpumask_var_node);
 
 bool zalloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node)
 {
-	return alloc_cpumask_var_node(mask, flags | __GFP_ZERO, node);
+	return __alloc_cpumask_var_node(mask, flags | __GFP_ZERO, node);
 }
 EXPORT_SYMBOL(zalloc_cpumask_var_node);
 
@@ -88,11 +92,11 @@ EXPORT_SYMBOL(zalloc_cpumask_var_node);
  * a nop returning a constant 1 (in <linux/cpumask.h>).
  * The cpumask is initialized to all zeroes.
  *
- * See alloc_cpumask_var_node().
+ * See __alloc_cpumask_var_node().
  */
 bool zalloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
 {
-	return alloc_cpumask_var_node(mask, flags | __GFP_ZERO, NUMA_NO_NODE);
+	return __alloc_cpumask_var_node(mask, flags | __GFP_ZERO, NUMA_NO_NODE);
 }
 EXPORT_SYMBOL(zalloc_cpumask_var);
 
-- 
2.5.0


      parent reply	other threads:[~2015-12-07  8:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-07  8:49 [PATCH 0/4] [RFC] cpumask: Robustify the var-cpumask allocation APIs Ingo Molnar
2015-12-07  8:49 ` [PATCH 1/4] cpumask: Migrate 'alloc_cpumask_var()' users to 'zalloc_cpumask_var()' Ingo Molnar
2015-12-08  1:28   ` Linus Torvalds
2015-12-08  4:09     ` Ingo Molnar
2015-12-08  4:13       ` Ingo Molnar
     [not found]         ` <CA+55aFyOXsv6uY3Dyc=i3SmwFD8XQYZeqzPXz36qzvdOD=gZSg@mail.gmail.com>
2015-12-16  0:26           ` Rusty Russell
2015-12-07  8:49 ` [PATCH 2/4] cpumask: Remove 'alloc_cpumask_var()' Ingo Molnar
2015-12-07  8:49 ` [PATCH 3/4] cpumask: Rename 'alloc_bootmem_cpumask_var()' to 'zalloc_bootmem_cpumask_var()' Ingo Molnar
2015-12-07  8:49 ` Ingo Molnar [this message]

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=1449478184-27168-5-git-send-email-mingo@kernel.org \
    --to=mingo@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=xlpang@redhat.com \
    /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.