Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp547731ybh; Thu, 12 Mar 2020 06:52:25 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtiulXHXNhMZep+lptH16sEH994DPdFyd0DhPI6y31zSQQO9wSj8ye36wBsmXdQgHQlvpUZ X-Received: by 2002:aca:4991:: with SMTP id w139mr1372761oia.145.1584021145780; Thu, 12 Mar 2020 06:52:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584021145; cv=none; d=google.com; s=arc-20160816; b=jXkdq+9ThiQEIW/mltJWI4VL2iUIvCTDXLCooxSAZhN2WVVPpAiOTXWvsngmc9Zx++ NJ4YHYnXSvhax4FTb7QUQrff8ioGw6CBvG+GzqzQS/Feft9nQCzRnD9ob9Ym8iaKvB6y ymFOJGwAbLRDVJOZZ9sKTVsM7ItjvwXewbVPF1l/iJ5GZnV6c1Y+qaDR6rg7jbP7A8ab dy1+/ecFKMMKCwf9xGkdmZf61Lps6VnkDtL+c79kPqdRDRzn9TuQWe9pCtbJxUeIjuGL GNMYPhv8PT3hoT3A/j8RNoPTpLFG97sPzgsNTXewCaD5/8glcjc7vrpouX6ypUEIDsLq 11JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=yUBoDHZfKKIr5nQCfq/NJMQ/OVD/Ny8q0JJ2yZHv2Ys=; b=qMQc5T2oIrfhKX5jl2ZrGHQfThjSQRmqWbgzjUbcquYh3lxKF7RHCpMeXxmex0Jn6X i+RhSSBBooVN9NtXXxXp8Rr9UPt1K2EwLoQXjv2ha76UAyF59WzV+vMq6/vsAhjk6Ntv 07rBeZTtL8mhu2CeXb3IZJqwulPSRZ3Q3ShADK5Kn4omC0mG5CiJjVXO8a8i967eNFXF SLzmD6iLexrYEuAJt/1uDZeXOag4pDZ6gycEF+sc5dhnLxWuHGCKUr0cjceCpmVzI189 5P56T1TauU3t45jvqracih/Kx34HRNOZqCuT+Yw7kCwT/KpxONawlobHkDUMqDx+Saa3 2aPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si2732661otq.309.2020.03.12.06.52.12; Thu, 12 Mar 2020 06:52:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727553AbgCLNvs (ORCPT + 99 others); Thu, 12 Mar 2020 09:51:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:37738 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727471AbgCLNvm (ORCPT ); Thu, 12 Mar 2020 09:51:42 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 96743AC8F; Thu, 12 Mar 2020 13:51:39 +0000 (UTC) Subject: Re: [PATCH 1/3] powerpc/numa: Set numa_node for all possible cpus To: Srikar Dronamraju Cc: Sachin Sant , Michal Hocko , Linus Torvalds , LKML , linux-mm@kvack.org, Mel Gorman , "Kirill A. Shutemov" , Andrew Morton , linuxppc-dev@lists.ozlabs.org, Christopher Lameter , Joonsoo Kim References: <20200311110237.5731-1-srikar@linux.vnet.ibm.com> <20200311110237.5731-2-srikar@linux.vnet.ibm.com> <20200311115735.GM23944@dhcp22.suse.cz> <20200312052707.GA3277@linux.vnet.ibm.com> <5e5c736a-a88c-7c76-fc3d-7bc765e8dcba@suse.cz> <20200312131438.GB3277@linux.vnet.ibm.com> From: Vlastimil Babka Message-ID: <61437352-8b54-38fa-4471-044a65c9d05a@suse.cz> Date: Thu, 12 Mar 2020 14:51:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200312131438.GB3277@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/12/20 2:14 PM, Srikar Dronamraju wrote: > * Vlastimil Babka [2020-03-12 10:30:50]: > >> On 3/12/20 9:23 AM, Sachin Sant wrote: >> >> On 12-Mar-2020, at 10:57 AM, Srikar Dronamraju wrote: >> >> * Michal Hocko [2020-03-11 12:57:35]: >> >>> On Wed 11-03-20 16:32:35, Srikar Dronamraju wrote: >> >>>> To ensure a cpuless, memoryless dummy node is not online, powerpc need >> >>>> to make sure all possible but not present cpu_to_node are set to a >> >>>> proper node. >> >>> >> >>> Just curious, is this somehow related to >> >>> http://lkml.kernel.org/r/20200227182650.GG3771@dhcp22.suse.cz? >> >>> >> >> >> >> The issue I am trying to fix is a known issue in Powerpc since many years. >> >> So this surely not a problem after a75056fc1e7c (mm/memcontrol.c: allocate >> >> shrinker_map on appropriate NUMA node"). >> >> >> >> I tried v5.6-rc4 + a75056fc1e7c but didnt face any issues booting the >> >> kernel. Will work with Sachin/Abdul (reporters of the issue). > > I had used v1 and not v2. So my mistake. > >> > I applied this 3 patch series on top of March 11 next tree (commit d44a64766795 ) >> > The kernel still fails to boot with same call trace. >> > > While I am not an expert in the slub area, I looked at the patch > a75056fc1e7c and had some thoughts on why this could be causing this issue. > > On the system where the crash happens, the possible number of nodes is much > greater than the number of onlined nodes. The pdgat or the NODE_DATA is only > available for onlined nodes. > > With a75056fc1e7c memcg_alloc_shrinker_maps, we end up calling kzalloc_node > for all possible nodes and in ___slab_alloc we end up looking at the > node_present_pages which is NODE_DATA(nid)->node_present_pages. > i.e for a node whose pdgat struct is not allocated, we are trying to > dereference. From what we saw, the pgdat does exist, the problem is that slab's per-node data doesn't exist for a node that doesn't have present pages, as it would be a waste of memory. Uh actually you are probably right, the NODE_DATA doesn't exist anymore? In Sachin's first report [1] we have [ 0.000000] numa: NODE_DATA [mem 0x8bfedc900-0x8bfee3fff] [ 0.000000] numa: NODE_DATA(0) on node 1 [ 0.000000] numa: NODE_DATA [mem 0x8bfed5200-0x8bfedc8ff] But in this thread, with your patches Sachin reports: [ 0.000000] numa: NODE_DATA [mem 0x8bfedc900-0x8bfee3fff] So I assume it's just node 1. In that case, node_present_pages is really dangerous. [1] https://lore.kernel.org/linux-next/3381CD91-AB3D-4773-BA04-E7A072A63968@linux.vnet.ibm.com/ > Also for a memoryless/cpuless node or possible but not present nodes, > node_to_mem_node(node) will still end up as node (atleast on powerpc). I think that's the place where this would be best to fix. > I tried with this hunk below and it works. > > But I am not sure if we need to check at other places were > node_present_pages is being called. I think this seems to defeat the purpose of node_to_mem_node()? Shouldn't it return only nodes that are online with present memory? CCing Joonsoo who seems to have introduced this in ad2c8144418c ("topology: add support for node_to_mem_node() to determine the fallback node") I think we do need well defined and documented rules around node_to_mem_node(), cpu_to_node(), existence of NODE_DATA, various node_states bitmaps etc so everyone handles it the same, safe way. > diff --git a/mm/slub.c b/mm/slub.c > index 626cbcbd977f..bddb93bed55e 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -2571,9 +2571,13 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, > if (unlikely(!node_match(page, node))) { > int searchnode = node; > > - if (node != NUMA_NO_NODE && !node_present_pages(node)) > - searchnode = node_to_mem_node(node); > - > + if (node != NUMA_NO_NODE) { > + if (!node_online(node) || !node_present_pages(node)) { > + searchnode = node_to_mem_node(node); > + if (!node_online(searchnode)) > + searchnode = first_online_node; > + } > + } > if (unlikely(!node_match(page, searchnode))) { > stat(s, ALLOC_NODE_MISMATCH); > deactivate_slab(s, page, c->freelist, c); > >> > >> >