public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Jack Steiner <steiner@sgi.com>
To: Andreas Schwab <schwab@suse.de>
Cc: Takayoshi Kochi <t-kochi@bq.jp.nec.com>,
	ak@suse.de, linux-ia64@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: Externalize SLIT table
Date: Fri, 05 Nov 2004 16:44:49 +0000	[thread overview]
Message-ID: <20041105164449.GC26719@sgi.com> (raw)
In-Reply-To: <jevfcknty5.fsf@sykes.suse.de>

On Fri, Nov 05, 2004 at 05:26:10PM +0100, Andreas Schwab wrote:
> Jack Steiner <steiner@sgi.com> writes:
> 
> > @@ -111,6 +111,21 @@ static ssize_t node_read_numastat(struct
> >  }
> >  static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
> >  
> > +static ssize_t node_read_distance(struct sys_device * dev, char * buf)
> > +{
> > +	int nid = dev->id;
> > +	int len = 0;
> > +	int i;
> > +
> > +	for (i = 0; i < numnodes; i++)
> > +		len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i));
> 
> Can this overflow the space allocated for buf?


Good point. I think we are ok for now. AFAIK, the largest cpu count
currently supported is 512. That gives a max string of 2k (max of 3 
digits + space per cpu).

However, I should probably add a BUILD_BUG_ON to check for overflow.

	BUILD_BUG_ON(NR_NODES*4 > PAGE_SIZE/2);
	BUILD_BUG_ON(NR_CPUS*4 > PAGE_SIZE/2);



> 
> > @@ -58,6 +59,31 @@ static inline void register_cpu_control(
> >  }
> >  #endif /* CONFIG_HOTPLUG_CPU */
> >  
> > +#ifdef CONFIG_NUMA
> > +static ssize_t cpu_read_distance(struct sys_device * dev, char * buf)
> > +{
> > +	int nid = cpu_to_node(dev->id);
> > +	int len = 0;
> > +	int i;
> > +
> > +	for (i = 0; i < num_possible_cpus(); i++)
> > +		len += sprintf(buf + len, "%s%d", i ? " " : "", 
> > +			node_distance(nid, cpu_to_node(i)));
> 
> Or this?
> 
> Andreas.
> 
> -- 
> Andreas Schwab, SuSE Labs, schwab@suse.de
> SuSE Linux AG, Maxfeldstra_e 5, 90409 N|rnberg, Germany
> Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."

-- 
Thanks

Jack Steiner (steiner@sgi.com)          651-683-5302
Principal Engineer                      SGI - Silicon Graphics, Inc.



  reply	other threads:[~2004-11-05 16:44 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-03 20:56 Externalize SLIT table Jack Steiner
2004-11-04  1:59 ` Takayoshi Kochi
2004-11-04  4:07   ` Andi Kleen
2004-11-04  4:57     ` Takayoshi Kochi
2004-11-04  6:37       ` Andi Kleen
2004-11-05 16:08       ` Jack Steiner
2004-11-05 16:26         ` Andreas Schwab
2004-11-05 16:44           ` Jack Steiner [this message]
2004-11-06 11:50             ` Christoph Hellwig
2004-11-06 12:48               ` Andi Kleen
2004-11-06 13:07                 ` Christoph Hellwig
2004-11-05 17:13         ` Erich Focht
2004-11-05 19:13           ` Jack Steiner
2004-11-09 19:23     ` Matthew Dobson
2004-11-04 14:13   ` Jack Steiner
2004-11-04 14:29     ` Andi Kleen
2004-11-04 15:31     ` Erich Focht
2004-11-04 17:04       ` Andi Kleen
2004-11-04 19:36         ` Jack Steiner
2004-11-09 19:45         ` Matthew Dobson
2004-11-09 19:43       ` Matthew Dobson
2004-11-09 20:34         ` Mark Goodwin
2004-11-09 22:00           ` Jesse Barnes
2004-11-09 23:58           ` Matthew Dobson
2004-11-10  5:05             ` Mark Goodwin
2004-11-10 18:45               ` Erich Focht
2004-11-10 22:09                 ` Matthew Dobson
2004-11-18 16:39 ` Jack Steiner

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=20041105164449.GC26719@sgi.com \
    --to=steiner@sgi.com \
    --cc=ak@suse.de \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwab@suse.de \
    --cc=t-kochi@bq.jp.nec.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