lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1449478184-27168-5-git-send-email-mingo@kernel.org>
Date:	Mon,  7 Dec 2015 09:49:44 +0100
From:	Ingo Molnar <mingo@...nel.org>
To:	linux-kernel@...r.kernel.org
Cc:	Rusty Russell <rusty@...tcorp.com.au>,
	Peter Zijlstra <peterz@...radead.org>,
	Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
	Xunlei Pang <xlpang@...hat.com>,
	Rik van Riel <riel@...hat.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Thomas Gleixner <tglx@...utronix.de>
Subject: [PATCH 4/4] cpumask: Rename 'alloc_cpumask_var_node()' to '__alloc_cpumask_var_node()'

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@...nel.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ