public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiang Liu <jiang.liu@linux.intel.com>
To: David Rientjes <rientjes@google.com>,
	Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	Tony Luck <tony.luck@intel.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [Bugfix] sched: fix possible invalid memory access caused by CPU hot-addition
Date: Wed, 23 Apr 2014 12:53:41 +0800	[thread overview]
Message-ID: <53574755.3080809@linux.intel.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1404221849330.4008@chino.kir.corp.google.com>



On 2014/4/23 9:59, David Rientjes wrote:
> On Tue, 22 Apr 2014, Peter Zijlstra wrote:
> 
>> On Tue, Apr 22, 2014 at 01:01:51PM -0700, Andrew Morton wrote:
>>> On Tue, 22 Apr 2014 10:15:15 +0200 Peter Zijlstra <peterz@infradead.org> wrote:
>>>
>>>> On Tue, Apr 22, 2014 at 01:27:15PM +0800, Jiang Liu wrote:
>>>>> When calling kzalloc_node(size, flags, node), we should first check
>>>>> whether node is onlined, otherwise it may cause invalid memory access
>>>>> as below.
>>>>
>>>> But this is only for memory less node crap, right? 
>>>
>>> um, why are memoryless nodes crap?
>>
>> Why wouldn't they be? Having CPUs with no local memory seems decidedly
>> suboptimal.
> 
> The quick fix for memoryless node issues is usually just do cpu_to_mem() 
> rather than cpu_to_node() in the caller.  This assumes that the arch is 
> setup correctly to handle memoryless nodes with 
> CONFIG_HAVE_MEMORYLESS_NODES (and we've had problems recently with 
> memoryless nodes not being configured correctly on powerpc).
> 
> That type of a fix would probably be better handled in the slab allocator, 
> though, since kmalloc_node(nid) shouldn't crash just because nid is 
> memoryless, we should be doing local_memory_node(node) when allocating the 
> slab pages.
> 
> However, I don't think memoryless nodes are the problem here since Jiang 
> is testing for !node_online(nid) in his patch, so it's a problem with 
> cpu_to_node() pointing to an offline node.  It makes sense for the page 
> allocator to crash in such a case, the node id is erroneous.
> 
> So either the cpu-to-node mapping is invalid or alloc_fair_sched_group() 
> is allocating memory for a cpu on an offline node.  The 
> for_each_possible_cpu() looks suspicious.  There's no guarantee that 
> local_memory_node(node) for an offline node will return anything with 
> affinity, so falling back to NUMA_NO_NODE looks appropriate in Jiang's 
> patch.
Hi David,
	That's the case, alloc_fair_sched_group() is trying to allocate
memory for CPU in offline node, which then access non-exist NODE_DATA.
Thanks!
Gerry

> 

  reply	other threads:[~2014-04-23  4:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-22  5:27 [Bugfix] sched: fix possible invalid memory access caused by CPU hot-addition Jiang Liu
2014-04-22  8:15 ` Peter Zijlstra
2014-04-22 20:01   ` Andrew Morton
2014-04-22 20:04     ` Peter Zijlstra
2014-04-23  1:59       ` David Rientjes
2014-04-23  4:53         ` Jiang Liu [this message]
2014-04-23  2:05       ` Mike Galbraith
2014-04-23  2:45   ` Jiang Liu
2014-04-23  5:32     ` Peter Zijlstra
2014-04-23  5:45       ` Jiang Liu
2014-04-23  5:51       ` Peter Zijlstra
2014-04-23 17:46         ` Luck, Tony
2014-04-24  2:59           ` Jiang Liu
2014-04-24  7:47             ` Peter Zijlstra
2014-04-24 17:41               ` Luck, Tony
2014-04-24 19:09                 ` Peter Zijlstra

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=53574755.3080809@linux.intel.com \
    --to=jiang.liu@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rientjes@google.com \
    --cc=tony.luck@intel.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