linux-kernel.vger.kernel.org archive mirror
 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 2/4] cpumask: Remove 'alloc_cpumask_var()'
Date: Mon,  7 Dec 2015 09:49:42 +0100	[thread overview]
Message-ID: <1449478184-27168-3-git-send-email-mingo@kernel.org> (raw)
In-Reply-To: <1449478184-27168-1-git-send-email-mingo@kernel.org>

This API is unused and slightly unrobust: on non-CPUMASK_OFFSTACK
kernels it will result in initialized cpumasks - while on
CPUMASK_OFFSTACK kernels it results in initialized cpumasks,
enabling hard to find initialization bugs.

Be conservative and default to zeroing. Users of this facility that
really want to allocate their cpumasks without initializing them can
still use alloc_cpumask_var_node() to do so.

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

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 608beca04fc6..0d24286fe8f8 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -654,7 +654,6 @@ 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(cpumask_var_t *mask, gfp_t flags);
 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 alloc_bootmem_cpumask_var(cpumask_var_t *mask);
@@ -666,11 +665,6 @@ typedef struct cpumask cpumask_var_t[1];
 
 #define this_cpu_cpumask_var_ptr(x) this_cpu_ptr(x)
 
-static inline bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
-{
-	return true;
-}
-
 static inline bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags,
 					  int node)
 {
diff --git a/lib/cpumask.c b/lib/cpumask.c
index 7f93df07bce7..415041e9cda6 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -80,24 +80,19 @@ bool zalloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node)
 EXPORT_SYMBOL(zalloc_cpumask_var_node);
 
 /**
- * alloc_cpumask_var - allocate a struct cpumask
+ * zalloc_cpumask_var - allocate a struct cpumask
  * @mask: pointer to cpumask_var_t where the cpumask is returned
  * @flags: GFP_ flags
  *
  * Only defined when CONFIG_CPUMASK_OFFSTACK=y, otherwise is
  * 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 alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
-{
-	return alloc_cpumask_var_node(mask, flags, NUMA_NO_NODE);
-}
-EXPORT_SYMBOL(alloc_cpumask_var);
-
 bool zalloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
 {
-	return alloc_cpumask_var(mask, flags | __GFP_ZERO);
+	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 ` Ingo Molnar [this message]
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 ` [PATCH 4/4] cpumask: Rename 'alloc_cpumask_var_node()' to '__alloc_cpumask_var_node()' Ingo Molnar

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-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).