public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Dobson <colpatch@us.ibm.com>
To: Nick Piggin <piggin@cyberone.com.au>
Cc: linux-kernel@vger.kernel.org, mbligh@aracnet.com,
	Andrew Morton <akpm@osdl.org>,
	Trivial Patch Monkey <trivial@rustcorp.com.au>
Subject: Re: [TRIVIAL PATCH] Use valid node number when unmapping CPUs
Date: Mon, 05 Jan 2004 14:52:47 -0800	[thread overview]
Message-ID: <3FF9EABF.7050906@us.ibm.com> (raw)
In-Reply-To: 3FE78F53.9090302@cyberone.com.au

Nick Piggin wrote:
> 
> 
> Matthew Dobson wrote:
> 
>> The cpu_2_node array for i386 is initialized to 0 for each CPU, 
>> effectively mapping all CPUs to node 0 unless changed.  When we unmap 
>> CPUs, however, we stick a -1 in the array, mapping the CPU to an 
>> invalid node.  This really isn't helpful.  We should map the CPU to 
>> node 0, to make sure that callers of cpu_to_node() and friends aren't 
>> returned a bogus node number.  This trivial patch changes the 
>> unmapping code to place a 0 in the node mapping for removed CPUs.
>>
>> Cheers!
> 
> 
> 
> I'd prefer it got initialised to -1 for each cpu, and either set to -1
> or not touched during unmap.
 >
> 
> 0 is more bogus than the alternatives, isn't it? At least for the subset
> of CPUs not on node 0. Callers should be fixed.

Not really...  These macros are usually used for things like scheduling, 
memory placement and other decisions.  Right now the value doesn't have 
to be error-checked, because it is assumed to always return a valid 
node.  For these types of uses, it's far better to schedule/allocate 
something on the wrong node (ie: node 0) than on an invalid node (ie: 
node -1).  Having a possible negative value for this will break things 
when used as an array index (as it often is), and will force us to put 
tests to ensure it is a valid value before using it, and introduce 
possible races in the future (ie: imagine testing if CPU 17's node 
mapping is non-negative, simultaneously unmapping the CPU, then using 
the macro again to make a node decision.  You may get a negative value 
back, thus causing you to index way off the end of your array... BOOM). 
  If we stick with the convention that we always have a valid (even if 
not *correct*) value in these arrays, the worst we should get is poor 
performance, not breakage.

Cheers!

-Matt


  reply	other threads:[~2004-01-05 23:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-22 19:37 [TRIVIAL PATCH] Use valid node number when unmapping CPUs Matthew Dobson
2003-12-23  0:41 ` Nick Piggin
2004-01-05 22:52   ` Matthew Dobson [this message]
2004-01-06  0:39     ` Nick Piggin
2004-03-29 15:46     ` Nick Piggin
2004-03-29 15:45   ` Matthew Dobson

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=3FF9EABF.7050906@us.ibm.com \
    --to=colpatch@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbligh@aracnet.com \
    --cc=piggin@cyberone.com.au \
    --cc=trivial@rustcorp.com.au \
    /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