public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] mm: define default cpu_to_node
@ 2008-05-08 23:02 Mike Travis
  2008-05-08 23:02 ` [PATCH 1/1] " Mike Travis
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Travis @ 2008-05-08 23:02 UTC (permalink / raw)
  To: Ingo Molnar, Andrew Morton, bunk; +Cc: linux-sh, lethal, linux-kernel


The following patch is offered to resolve this problem:

| Adrian Bunk wrote:
|| Commit aa6b54461cc5c0019b9d792adf3176b444c10763
|| (asm-generic: add node_to_cpumask_ptr macro)
|| causes the following build error with migor_defconfig:
||
|| <--  snip  -->
||
|| ...
||   CC      arch/sh/kernel/asm-offsets.s
|| In file included from /home/bunk/linux/kernel-2.6/git/linux-2.6/include/linux/mm.h:8,
||                  from /home/bunk/linux/kernel-2.6/git/linux-2.6/arch/sh/kernel/asm-offsets.c:13:
|| /home/bunk/linux/kernel-2.6/git/linux-2.6/include/linux/gfp.h: In function 'alloc_pages_node':
|| /home/bunk/linux/kernel-2.6/git/linux-2.6/include/linux/gfp.h:190: 
|| error: implicit declaration of function 'cpu_to_node'
|| make[2]: *** [arch/sh/kernel/asm-offsets.s] Error 1
||


Ahh, this is what caused the error.  In include/asm-generic/topology.h
cpu_to_node is only defined now if NUMA is turned off.

#ifndef CONFIG_NUMA

/* Other architectures wishing to use this simple topology API should fill
   in the below functions as appropriate in their own <asm/topology.h> file. */
#ifndef cpu_to_node
#define cpu_to_node(cpu)        ((void)(cpu),0)
#endif
...

So before my change arch 'sh' used the default define whether NUMA was
set or not.

An alternative would be to change all the arch's that define cpu_to_node
as an inline to:

#define cpu_to_node(cpu)	_cpu_to_node(cpu)
static inline int _cpu_to_node(int cpu)
{
	...
}

Then asm-generic/topology.h could define cpu_to_node if it's not already
defined.

Andrew or Ingo - do you have any preferences?

Thanks,
Mike

Signed-off-by: Mike Travis <travis@sgi.com>

# alpha
Cc: Richard Henderson <rth@twiddle.net>

# powerpc
Cc: Paul Mackerras <paulus@samba.org>
Cc: Anton Blanchard <anton@samba.org>

# sh
Cc: Adrian Bunk <bunk@kernel.org>
Cc: lethal@linux-sh.org
Cc: linux-sh@vger.kernel.org

# sparc
Cc: David S. Miller <davem@davemloft.net>
Cc: William L. Irwin <wli@holomorphy.com>

# x86
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
---

-- 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/1] mm: define default cpu_to_node
  2008-05-08 23:02 [PATCH 0/1] mm: define default cpu_to_node Mike Travis
@ 2008-05-08 23:02 ` Mike Travis
  2008-05-09  5:20   ` Paul Mundt
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Travis @ 2008-05-08 23:02 UTC (permalink / raw)
  To: Ingo Molnar, Andrew Morton, bunk
  Cc: linux-sh, lethal, linux-kernel, Richard Henderson, Paul Mackerras,
	Anton Blanchard, David S. Miller, William L. Irwin,
	H. Peter Anvin, Thomas Gleixner

[-- Attachment #1: fix-cpu_to_node --]
[-- Type: text/plain, Size: 3693 bytes --]

  * Some architectures have CONFIG_NUMA=y but do not define a
    default cpu_to_node macro.  This provides the default in
    asm-generic/topology.h but it relies on the fact that
    cpu_to_node is a defined macro (and not an inline function).

    Which means that those architecutures that define cpu_to_node
    as a function are changed to:

    #define cpu_to_node(cpu)  _cpu_to_node(cpu)
    < ... declare the _cpu_to_node(int cpu) function. ... >
    
Based on:
    //git.kernel.org/pub/scm/linux/kernel/git/sfr/linux-next.git

Signed-off-by: Mike Travis <travis@sgi.com>

# alpha
Cc: Richard Henderson <rth@twiddle.net>

# powerpc
Cc: Paul Mackerras <paulus@samba.org>
Cc: Anton Blanchard <anton@samba.org>

# sh
Cc: Adrian Bunk <bunk@kernel.org>
Cc: lethal@linux-sh.org
Cc: linux-sh@vger.kernel.org

# sparc
Cc: David S. Miller <davem@davemloft.net>
Cc: William L. Irwin <wli@holomorphy.com>

# x86
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
 include/asm-alpha/topology.h   |    3 ++-
 include/asm-generic/topology.h |   11 ++++++++---
 include/asm-powerpc/topology.h |    3 ++-
 include/asm-sparc64/topology.h |    3 ++-
 include/asm-x86/topology.h     |    6 ++++--
 5 files changed, 18 insertions(+), 8 deletions(-)

--- linux-2.6-next.orig/include/asm-alpha/topology.h
+++ linux-2.6-next/include/asm-alpha/topology.h
@@ -6,7 +6,8 @@
 #include <asm/machvec.h>
 
 #ifdef CONFIG_NUMA
-static inline int cpu_to_node(int cpu)
+#define cpu_to_node(cpu) _cpu_to_node(cpu)
+static inline int _cpu_to_node(int cpu)
 {
 	int node;
 	
--- linux-2.6-next.orig/include/asm-generic/topology.h
+++ linux-2.6-next/include/asm-generic/topology.h
@@ -27,13 +27,18 @@
 #ifndef _ASM_GENERIC_TOPOLOGY_H
 #define _ASM_GENERIC_TOPOLOGY_H
 
+/*
+ * cpu_to_node is referenced but not defined in some arch's that
+ * have CONFIG_NUMA=y
+ */
+#ifndef cpu_to_node
+#define cpu_to_node(cpu)	((void)(cpu),0)
+#endif
+
 #ifndef	CONFIG_NUMA
 
 /* Other architectures wishing to use this simple topology API should fill
    in the below functions as appropriate in their own <asm/topology.h> file. */
-#ifndef cpu_to_node
-#define cpu_to_node(cpu)	((void)(cpu),0)
-#endif
 #ifndef parent_node
 #define parent_node(node)	((void)(node),0)
 #endif
--- linux-2.6-next.orig/include/asm-powerpc/topology.h
+++ linux-2.6-next/include/asm-powerpc/topology.h
@@ -10,7 +10,8 @@ struct device_node;
 
 #include <asm/mmzone.h>
 
-static inline int cpu_to_node(int cpu)
+#define cpu_to_node(cpu) _cpu_to_node(cpu)
+static inline int _cpu_to_node(int cpu)
 {
 	return numa_cpu_lookup_table[cpu];
 }
--- linux-2.6-next.orig/include/asm-sparc64/topology.h
+++ linux-2.6-next/include/asm-sparc64/topology.h
@@ -5,7 +5,8 @@
 
 #include <asm/mmzone.h>
 
-static inline int cpu_to_node(int cpu)
+#define cpu_to_node(cpu) _cpu_to_node(cpu)
+static inline int _cpu_to_node(int cpu)
 {
 	return numa_cpu_lookup_table[cpu];
 }
--- linux-2.6-next.orig/include/asm-x86/topology.h
+++ linux-2.6-next/include/asm-x86/topology.h
@@ -53,7 +53,8 @@ extern cpumask_t node_to_cpumask_map[];
 /* Returns the number of the node containing CPU 'cpu' */
 #ifdef CONFIG_X86_32
 #define early_cpu_to_node(cpu)	cpu_to_node(cpu)
-static inline int cpu_to_node(int cpu)
+#define cpu_to_node(cpu) _cpu_to_node(cpu)
+static inline int _cpu_to_node(int cpu)
 {
 	return cpu_to_node_map[cpu];
 }
@@ -76,7 +77,8 @@ static inline int early_cpu_to_node(int 
 #define	early_cpu_to_node(cpu)	cpu_to_node(cpu)
 #endif
 
-static inline int cpu_to_node(int cpu)
+#define cpu_to_node(cpu) _cpu_to_node(cpu)
+static inline int _cpu_to_node(int cpu)
 {
 #ifdef CONFIG_DEBUG_PER_CPU_MAPS
 	if (x86_cpu_to_node_map_early_ptr) {

-- 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] mm: define default cpu_to_node
  2008-05-08 23:02 ` [PATCH 1/1] " Mike Travis
@ 2008-05-09  5:20   ` Paul Mundt
  2008-05-09 15:01     ` Mike Travis
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Mundt @ 2008-05-09  5:20 UTC (permalink / raw)
  To: Mike Travis
  Cc: Ingo Molnar, Andrew Morton, bunk, linux-sh, linux-kernel,
	Richard Henderson, Paul Mackerras, Anton Blanchard,
	David S. Miller, William L. Irwin, H. Peter Anvin,
	Thomas Gleixner

On Thu, May 08, 2008 at 04:02:39PM -0700, Mike Travis wrote:
>   * Some architectures have CONFIG_NUMA=y but do not define a
>     default cpu_to_node macro.  This provides the default in
>     asm-generic/topology.h but it relies on the fact that
>     cpu_to_node is a defined macro (and not an inline function).
> 
NACK.. This isn't going to work anyways, cpu_to_node() is just where the
first build error occurs. If you do this, then parent_node() is the next
one to blow up, node_to_cpumask() after that, etc, etc. For now I've just
stubbed the asm-generic/topology.h definitions in to asm-sh/topology.h.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] mm: define default cpu_to_node
  2008-05-09  5:20   ` Paul Mundt
@ 2008-05-09 15:01     ` Mike Travis
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Travis @ 2008-05-09 15:01 UTC (permalink / raw)
  To: Paul Mundt, Mike Travis, Ingo Molnar, Andrew Morton, bunk,
	linux-sh, linux-kernel, Richard Henderson, Paul Mackerras,
	Anton Blanchard, David S. Miller, William L. Irwin,
	H. Peter Anvin, Thomas Gleixner

Paul Mundt wrote:
> On Thu, May 08, 2008 at 04:02:39PM -0700, Mike Travis wrote:
>>   * Some architectures have CONFIG_NUMA=y but do not define a
>>     default cpu_to_node macro.  This provides the default in
>>     asm-generic/topology.h but it relies on the fact that
>>     cpu_to_node is a defined macro (and not an inline function).
>>
> NACK.. This isn't going to work anyways, cpu_to_node() is just where the
> first build error occurs. If you do this, then parent_node() is the next
> one to blow up, node_to_cpumask() after that, etc, etc. For now I've just
> stubbed the asm-generic/topology.h definitions in to asm-sh/topology.h.


Ok, Thanks!  I was looking at that but without being able to compile it,
it was just a wild swing towards the fence... ;-)  And your rationale makes
sense, if an arch really has numa topology then it should define what that is.

Cheers,
Mike


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-05-09 15:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-08 23:02 [PATCH 0/1] mm: define default cpu_to_node Mike Travis
2008-05-08 23:02 ` [PATCH 1/1] " Mike Travis
2008-05-09  5:20   ` Paul Mundt
2008-05-09 15:01     ` Mike Travis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox