Messages in this thread | | | Date | Fri, 3 Oct 2008 13:54:49 -0400 (EDT) | From | Steven Rostedt <> | Subject | Re: [PATCH] x86 Topology cpu_to_node parameter check |
| |
On Fri, 3 Oct 2008, Mathieu Desnoyers wrote:
> * Steven Rostedt (rostedt@goodmis.org) wrote: > > > > On Fri, 3 Oct 2008, Mathieu Desnoyers wrote: > > > > > > That's how I did it first, but then I looked at asm-generic/topology.h > > > and have seen it uses #defines. Should we change them too ? > > > > > > > The old way of doing this is with defines. But all new code should be > > static inline functions when feasible. This way we can get typechecking > > on the parameters even when the configuration is disabled. > > > > Even if the rest of the file uses defines, the new code should be > > static inlines. Eventually, even the old defines will be converted. > > > > -- Steve > > > > Argh, I think topology.h is utterly broken :-( > > Have you noticed the subtile interaction between the > > include/asm-x86/topology.h : > > #define numa_node_id() 0 > #define cpu_to_node(cpu) 0 > #define early_cpu_to_node(cpu) 0 > ... > #include <asm-generic/topology.h> > > > and > include/asm-generic/topology.h : > #ifndef cpu_to_node > #define cpu_to_node(cpu) ((void)(cpu),0) > #endif > > If any architecture decide for some reason to use a static inline rather > than a define, as currently done with node_to_first_cpu : > > include/asm-x86/topology.h : > static inline int node_to_first_cpu(int node) > { > return first_cpu(cpu_online_map); > } > ... > #include <asm-generic/topology.h> > > include/asm-generic/topology.h : > #ifndef node_to_first_cpu > #define node_to_first_cpu(node) ((void)(node),0) > #endif > > (which will override the static inline !) > > It results in an override of the arch-specific version. Nice eh ?
Seems that they expect cpu_to_node to be a macro if NUMA is not configured.
Actually, since the asm-generic/topology.h does have the cpu shown (although not in inline format), the solution here is to simply remove the
#define cpu_to_node() 0
And we can still make the early_cpu_to_node a static inline since it is not referenced in the generic code.
-- Steve
| |