public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Travis <travis@sgi.com>
To: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	mm-commits@vger.kernel.org, Yinghai Lu <yhlu.kernel@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] x86: Add check for node passed to node_to_cpumask V3
Date: Fri, 27 Jun 2008 11:03:22 -0700	[thread overview]
Message-ID: <48652B6A.7060007@sgi.com> (raw)
In-Reply-To: <19f34abd0806271024j53b383ddq33ab2b58debfbb65@mail.gmail.com>

Vegard Nossum wrote:
> On Fri, Jun 27, 2008 at 7:10 PM, Mike Travis <travis@sgi.com> wrote:
>> Subject: [PATCH 1/1] x86: Add check for node passed to node_to_cpumask V3
>>
>>  * When CONFIG_DEBUG_PER_CPU_MAPS is set, the node passed to
>>    node_to_cpumask and node_to_cpumask_ptr should be validated.
>>    If invalid, then a dump_stack is performed and a zero cpumask
>>    is returned.
>>
>> Based on "Fri Jun 27 10:06:06 PDT 2008" tip/master...  ;-)
>>
>> Signed-off-by: Mike Travis <travis@sgi.com>
>> ---
>> V2: Slightly different version to remove a compiler warning.
>> V3: Redone to reflect moving setup.c -> setup_percpu.c
>> ---
>>  arch/x86/kernel/setup_percpu.c |   26 +++++++++++++++++++++++---
>>  include/asm-x86/topology.h     |    7 ++++++-
>>  2 files changed, 29 insertions(+), 4 deletions(-)
>>
>> --- linux-2.6.tip.orig/arch/x86/kernel/setup_percpu.c
>> +++ linux-2.6.tip/arch/x86/kernel/setup_percpu.c
>> @@ -346,6 +346,10 @@ int early_cpu_to_node(int cpu)
>>        return per_cpu(x86_cpu_to_node_map, cpu);
>>  }
>>
>> +
>> +/* empty cpumask */
>> +static const cpumask_t cpu_mask_none;
>> +
>>  /*
>>  * Returns a pointer to the bitmask of CPUs on Node 'node'.
>>  */
>> @@ -358,13 +362,23 @@ cpumask_t *_node_to_cpumask_ptr(int node
>>                dump_stack();
>>                return &cpu_online_map;
>>        }
>> -       BUG_ON(node >= nr_node_ids);
>> -       return &node_to_cpumask_map[node];
>> +       if (node >= nr_node_ids) {
>> +               printk(KERN_WARNING
>> +                       "_node_to_cpumask_ptr(%d): node > nr_node_ids(%d)\n",
>> +                       node, nr_node_ids);
>> +               dump_stack();
>> +               return (cpumask_t *)&cpu_mask_none;
> 
> Hm, I am wondering about this.
> 
> There exists an option DEBUG_RODATA ("Write protect kernel read-only
> data structures"). I'm guessing this RO protections means that we'll
> get page faults (and thus BUG/panic) if this "none" mask is ever
> attempted to be changed.
> 
> So if CONFIG_DEBUG_RODATA=y, I believe we'll see first this warning,
> then a panic (after all). Would it be better to make cpu_mask_none
> non-const, in spirit of trying to continue as far as possible? I don't
> really know if it matters, though. It seems that fedora kernels at
> least ship with a default of DEBUG_RODATA=y.
> 
> What you could also do is to make it non-const and then zero it each
> time it is requested. Again, this is an error situation in either
> case, so maybe it's not worth fussing about.
> 
> 
> Vegard
> 

Ingo asked me to add the "const".  But it would be a mistake to use
node_to_cpumask_ptr to modify the map... numa_set/clear_node is the
proper way to modify the maps.  Hmm, maybe I should add "const" to
the real node_to_cpumask_ptr function, at least then the compiler
would help spot illegal usages.

Thanks,
Mike

  reply	other threads:[~2008-06-27 18:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200806090918.m599Ib0G012837@imap1.linux-foundation.org>
     [not found] ` <19f34abd0806090420r4100241cgb4b828441de3b102@mail.gmail.com>
     [not found]   ` <20080609113547.GA1534@elte.hu>
     [not found]     ` <484D54F2.4070603@sgi.com>
     [not found]       ` <20080626113229.GB29619@elte.hu>
2008-06-26 16:26         ` [PATCH 1/1] x86: Add check for node passed to node_to_cpumask Mike Travis
2008-06-27  2:39           ` [PATCH 1/1] x86: Add check for node passed to node_to_cpumask V2 Mike Travis
2008-06-27 17:10             ` [PATCH 1/1] x86: Add check for node passed to node_to_cpumask V3 Mike Travis
2008-06-27 17:24               ` Vegard Nossum
2008-06-27 18:03                 ` Mike Travis [this message]
2008-06-29 11:34                   ` Vegard Nossum
2008-06-29 12:40                     ` Mike Travis
2008-07-03  8:44               ` Ingo Molnar
2008-07-03  8:55                 ` Vegard Nossum
2008-07-03  9:01                   ` Ingo Molnar
2008-07-08 17:06                     ` [PATCH 1/1] x86: Change _node_to_cpumask_ptr to return const ptr Mike Travis
2008-07-08 17:35                       ` Vegard Nossum
2008-07-08 18:05                         ` Mike Travis
2008-07-08 18:22                           ` Vegard Nossum
2008-07-08 20:51                             ` Mike Travis
2008-07-08 21:21                               ` Vegard Nossum
2008-07-08 21:28                                 ` Mike Travis
2008-07-08 21:35                                 ` Mike Travis
2008-07-08 21:52                                   ` Vegard Nossum
2008-07-13 17:12                                     ` Ingo Molnar
2008-07-07 17:23                   ` [PATCH 1/1] x86: Add check for node passed to node_to_cpumask V3 Mike Travis

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=48652B6A.7060007@sgi.com \
    --to=travis@sgi.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mm-commits@vger.kernel.org \
    --cc=vegard.nossum@gmail.com \
    --cc=yhlu.kernel@gmail.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