All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Travis <travis@sgi.com>
To: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	mm-commits@vger.kernel.org, Yinghai Lu <yhlu.kernel@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] x86: Change _node_to_cpumask_ptr to return const ptr
Date: Tue, 08 Jul 2008 14:35:21 -0700	[thread overview]
Message-ID: <4873DD99.7050001@sgi.com> (raw)
In-Reply-To: <19f34abd0807081421j67771dbclfae1fcfaa9ad4bcd@mail.gmail.com>

Subject: [PATCH 1/1] x86: Change _node_to_cpumask_ptr to return const ptr

  * Strengthen the return type for the _node_to_cpumask_ptr to be
    a const pointer.  This adds compiler checking to insure that
    node_to_cpumask_map[] is not changed inadvertently.

Applies to tip/master with the following patch applied:

	"[PATCH 1/1] x86: Add check for node passed to node_to_cpumask V3"

Signed-off-by: Mike Travis <travis@sgi.com>
---
 arch/x86/kernel/setup_percpu.c |    8 ++++----
 include/asm-generic/topology.h |    3 ++-
 include/asm-x86/topology.h     |   10 +++++-----
 3 files changed, 11 insertions(+), 10 deletions(-)

--- linux-2.6.tip.orig/arch/x86/kernel/setup_percpu.c
+++ linux-2.6.tip/arch/x86/kernel/setup_percpu.c
@@ -353,23 +353,23 @@ static const cpumask_t cpu_mask_none;
 /*
  * Returns a pointer to the bitmask of CPUs on Node 'node'.
  */
-cpumask_t *_node_to_cpumask_ptr(int node)
+const cpumask_t *_node_to_cpumask_ptr(int node)
 {
 	if (node_to_cpumask_map == NULL) {
 		printk(KERN_WARNING
 			"_node_to_cpumask_ptr(%d): no node_to_cpumask_map!\n",
 			node);
 		dump_stack();
-		return &cpu_online_map;
+		return (const cpumask_t *)&cpu_online_map;
 	}
 	if (node >= nr_node_ids) {
 		printk(KERN_WARNING
 			"_node_to_cpumask_ptr(%d): node > nr_node_ids(%d)\n",
 			node, nr_node_ids);
 		dump_stack();
-		return (cpumask_t *)&cpu_mask_none;
+		return &cpu_mask_none;
 	}
-	return (cpumask_t *)&node_to_cpumask_map[node];
+	return &node_to_cpumask_map[node];
 }
 EXPORT_SYMBOL(_node_to_cpumask_ptr);
 
--- linux-2.6.tip.orig/include/asm-generic/topology.h
+++ linux-2.6.tip/include/asm-generic/topology.h
@@ -60,7 +60,8 @@
 #ifndef node_to_cpumask_ptr
 
 #define	node_to_cpumask_ptr(v, node) 					\
-		cpumask_t _##v = node_to_cpumask(node), *v = &_##v
+		cpumask_t _##v = node_to_cpumask(node);			\
+		const cpumask_t *v = &_##v
 
 #define node_to_cpumask_ptr_next(v, node)				\
 			  _##v = node_to_cpumask(node)
--- linux-2.6.tip.orig/include/asm-x86/topology.h
+++ linux-2.6.tip/include/asm-x86/topology.h
@@ -82,7 +82,7 @@ DECLARE_EARLY_PER_CPU(int, x86_cpu_to_no
 #ifdef CONFIG_DEBUG_PER_CPU_MAPS
 extern int cpu_to_node(int cpu);
 extern int early_cpu_to_node(int cpu);
-extern cpumask_t *_node_to_cpumask_ptr(int node);
+extern const cpumask_t *_node_to_cpumask_ptr(int node);
 extern cpumask_t node_to_cpumask(int node);
 
 #else	/* !CONFIG_DEBUG_PER_CPU_MAPS */
@@ -103,7 +103,7 @@ static inline int early_cpu_to_node(int 
 }
 
 /* Returns a pointer to the cpumask of CPUs on Node 'node'. */
-static inline cpumask_t *_node_to_cpumask_ptr(int node)
+static inline const cpumask_t *_node_to_cpumask_ptr(int node)
 {
 	return &node_to_cpumask_map[node];
 }
@@ -118,7 +118,7 @@ static inline cpumask_t node_to_cpumask(
 
 /* Replace default node_to_cpumask_ptr with optimized version */
 #define node_to_cpumask_ptr(v, node)		\
-		cpumask_t *v = _node_to_cpumask_ptr(node)
+		const cpumask_t *v = _node_to_cpumask_ptr(node)
 
 #define node_to_cpumask_ptr_next(v, node)	\
 			   v = _node_to_cpumask_ptr(node)
@@ -186,7 +186,7 @@ extern int __node_distance(int, int);
 #define	cpu_to_node(cpu)	0
 #define	early_cpu_to_node(cpu)	0
 
-static inline cpumask_t *_node_to_cpumask_ptr(int node)
+static inline const cpumask_t *_node_to_cpumask_ptr(int node)
 {
 	return &cpu_online_map;
 }
@@ -201,7 +201,7 @@ static inline int node_to_first_cpu(int 
 
 /* Replace default node_to_cpumask_ptr with optimized version */
 #define node_to_cpumask_ptr(v, node)		\
-		cpumask_t *v = _node_to_cpumask_ptr(node)
+		const cpumask_t *v = _node_to_cpumask_ptr(node)
 
 #define node_to_cpumask_ptr_next(v, node)	\
 			   v = _node_to_cpumask_ptr(node)

  parent reply	other threads:[~2008-07-08 21:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-09  9:18 + fix-x86_64-splat.patch added to -mm tree akpm
     [not found] ` <19f34abd0806090420r4100241cgb4b828441de3b102@mail.gmail.com>
     [not found]   ` <20080609113547.GA1534@elte.hu>
     [not found]     ` <484D54F2.4070603@sgi.com>
     [not found]       ` <20080626113229.GB29619@elte.hu>
2008-06-26 16:26         ` [PATCH 1/1] x86: Add check for node passed to node_to_cpumask Mike Travis
2008-06-27  2:39           ` [PATCH 1/1] x86: Add check for node passed to node_to_cpumask V2 Mike Travis
2008-06-27 17:10             ` [PATCH 1/1] x86: Add check for node passed to node_to_cpumask V3 Mike Travis
2008-06-27 17:24               ` Vegard Nossum
2008-06-27 18:03                 ` Mike Travis
2008-06-29 11:34                   ` Vegard Nossum
2008-06-29 12:40                     ` Mike Travis
2008-07-03  8:44               ` Ingo Molnar
2008-07-03  8:55                 ` Vegard Nossum
2008-07-03  9:01                   ` Ingo Molnar
2008-07-08 17:06                     ` [PATCH 1/1] x86: Change _node_to_cpumask_ptr to return const ptr Mike Travis
2008-07-08 17:35                       ` Vegard Nossum
2008-07-08 18:05                         ` Mike Travis
2008-07-08 18:22                           ` Vegard Nossum
2008-07-08 20:51                             ` Mike Travis
2008-07-08 21:21                               ` Vegard Nossum
2008-07-08 21:28                                 ` Mike Travis
2008-07-08 21:35                                 ` Mike Travis [this message]
2008-07-08 21:52                                   ` Vegard Nossum
2008-07-13 17:12                                     ` Ingo Molnar
2008-07-07 17:23                   ` [PATCH 1/1] x86: Add check for node passed to node_to_cpumask V3 Mike Travis

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=4873DD99.7050001@sgi.com \
    --to=travis@sgi.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mm-commits@vger.kernel.org \
    --cc=vegard.nossum@gmail.com \
    --cc=yhlu.kernel@gmail.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.