Re: [PATCH] cputopology: Add default CPU topology information [3rd try]

From: Ben Hutchings
Date: Sat May 31 2008 - 19:45:07 EST


Vegard Nossum wrote:
> On Sat, May 31, 2008 at 11:44 PM, Ben Hutchings
> <bhutchings@xxxxxxxxxxxxxx> wrote:
> > Define the macros topology_{physical_package,core}_id() and
> > topology_{thread,core}_siblings() in <asm-generic/topology.h> if they are not
> > already defined.
> >
> > Move inclusion of <asm-generic/topology.h> after definitions of these
> > macros in <asm-powerpc/topology.h> and <asm-x86/topology.h>.
>
> Hi again :)
>
> As I said in my previous e-mail, having #includes in the middle of
> headers is nasty. This kind of dependency is really subtle and makes
> later modification much harder. (Actually, it hurts readability as
> well.)

It is a bit nasty, but it seems to be reasonably common to include
<asm-generic/foo.h> toward the end of <asm-bar/foo.h>. So I think
anyone working with an asm header should expect that.

> The standard way to do this seems to be:
>
> asm/topology.h should define ARCH_HAS_* macros if it wishes to
> override the defaults
> linux/topology.h should #include asm/topology.h at the top of the file
> linux/topology.h should define the generic functions/macros only if
> the ARCH_HAS_* macros are undefined
>
> Other files wishing to use these definitions should then include
> linux/topology.h.
>
> Or is that unfeasible in this case?

It seem feasible, though there is no need for ARCH_HAS_* macros given that
the features being described are themselves macros. I would be happy to
move the defaults to <linux/topology.h>. Actually, everything in
<asm-generic/topology.h> could probably be moved to <linux/topology.h>.

Ben.

--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/