public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Dobson <colpatch@us.ibm.com>
To: Nathan Lynch <ntl@pobox.com>
Cc: lkml <linux-kernel@vger.kernel.org>, Anton Blanchard <anton@samba.org>
Subject: Re: topology api confusion
Date: Mon, 25 Jul 2005 14:41:18 -0700	[thread overview]
Message-ID: <42E55C7E.50301@us.ibm.com> (raw)
In-Reply-To: <20050722213316.GE17865@otto>

Nathan Lynch wrote:
> We need some clarity on how asm-generic/topology.h is intended to be
> used.  I suspect that it's supposed to be unconditionally included at
> the end of the architecture's topology.h so that any elements which
> are undefined by the arch have sensible default definitions.  Looking
> at 2.6.13-rc3, this is what ppc64, ia64, and x86_64 currently do,
> however i386 does not (i386 pulls in the generic version only when
> !CONFIG_NUMA).
> 
> The #ifndef guards around each element of the topology api
> cannot serve their apparent intended purpose when the architecture
> implements a given bit as a function instead of a macro
> (e.g. cpu_to_node in ppc64):

When I originally wrote this all up, I had planned it to be used the way
i386 does: offer a full implementation of topology if appropriate, else
include the generic "sane" default.  It has since changed to work more like
you described: implement some (or all) of the topology functions, then
include the generic one to define any you missed.


> Since ppc64 unconditionally includes asm-generic/topology.h, all uses
> of cpu_to_node are preprocessed to (0).  Similar damage occurs with
> every other topology function which happens to be a real function
> instead of a macro.  I'm surprised my ppc64 numa systems even boot ;)
> 
> If the intent is that the architecture is free to define only a subset
> of the api and include the generic header for fallback definitions,
> then we need to do the #ifndef __HAVE_ARCH_FOO thing, no?  That is,
> the code above would look like:

You are correct in noticing that things should (though apparently don't?)
go wonky when arches define their topology functions as *functions*, rather
than macros.  It hasn't really seemed to bite anyone yet, so I've left it
alone, though to be honest, it is as surprising to me that it works as it
is to you.  I've resisted creating #ifdef ARCH_HAVE_XXX all over the place,
though maybe it is finally time?


> Thought I'd ask for input first since this would involve a sweep of
> include/asm-*.

It would indeed...  I'd be more than happy to look at any patches you care
to generate.  As I said, it seems to work, though I'm certain it's all held
together by GCC black magic & voodoo, and probably a little duct-tape.  A
more obviously correct solution would not be a bad thing. :)

-Matt

  reply	other threads:[~2005-07-25 21:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-22 21:33 topology api confusion Nathan Lynch
2005-07-25 21:41 ` Matthew Dobson [this message]
2005-07-25 23:25   ` Nathan Lynch
2005-07-26 15:16   ` Bill Davidsen
2005-08-01  5:07 ` Anton Blanchard
2005-08-01  5:22   ` Nathan Lynch
2005-08-01  8:10   ` Paul Mackerras

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=42E55C7E.50301@us.ibm.com \
    --to=colpatch@us.ibm.com \
    --cc=anton@samba.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntl@pobox.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