Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7990769imu; Tue, 4 Dec 2018 00:41:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/VSRLrueww3r9aZhojkqa+/BJW6NRLMvE7huSK1rcY+Rwq0cnXKDtGWq2/INjuJDIozAn2n X-Received: by 2002:a17:902:7791:: with SMTP id o17mr18846564pll.60.1543912918527; Tue, 04 Dec 2018 00:41:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543912918; cv=none; d=google.com; s=arc-20160816; b=R0VkNfu74RbmWH0yElQ/lx5X4RlJs8yrwg37Q0u2M5PGS8tR64Z3V5BdfwDWnii6Jt RK6QlrLwfZ+Os7yL7l3Cl3jugzFGHRDQNJ9AvsIglcYvzmqijgI22votjU5bd8St+4aO /KURMsjHI9WeIGHiVMgQQhGWCzbICS689knN+IEJ9xrh8oRFR2ybBBfg3V4HIN0LsdP4 PF5pwlH4ySLxj9w1kEQja9p4Dwo2WJxuOIHrC3/0AOeOZHrEK/7YPHCH7pRzssgYdVE+ QHG2m+c7OSNRppPjEaCw0hTLBwGe6eOVBdpAnnkG0Mpxr34v9RR1I8BXeFaPcAnQvzQm m9fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=taMYfSr3Z1OLGbDUYyrbc/6grk+5DrFU2CpFJTK6Rj8=; b=KCW9Kz7hkULliB8OBrtciRgNteRy8lAnjMao3/14Ar/dXFUhBh6PpVHrcj67RP8L2Z 5Br+x/DxJR/jaLu/Zx+iVWlKxccIeK2wxYgN9UgFpbFfLPD1rKdDKcdelG/xDgifuW4C 50ExQRSvUxa07TQhwsFjEhpDJg1iER+YWTYz6S6TeWjWkcsSyETFjck7XIypYx5E0MWB YE3OU1Ev/YAs4gq3Crw3qxcG/BHOKGVhMpw4sM5irQgpHQodUqJmwgYJKVhI6t0g9FiX tH8q2wkUcdk8gt3oIUIUxfY4RgUGGO5LwComUDbD0N3mMyiJoAY4w3ayrfn0/SlB9+z9 vGsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S14t0tlC; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z5si14661015pgj.177.2018.12.04.00.41.43; Tue, 04 Dec 2018 00:41:58 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S14t0tlC; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725865AbeLDIk4 (ORCPT + 99 others); Tue, 4 Dec 2018 03:40:56 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:33744 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbeLDIkz (ORCPT ); Tue, 4 Dec 2018 03:40:55 -0500 Received: by mail-ed1-f66.google.com with SMTP id p6so4905183eds.0 for ; Tue, 04 Dec 2018 00:40:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=taMYfSr3Z1OLGbDUYyrbc/6grk+5DrFU2CpFJTK6Rj8=; b=S14t0tlCuMSkLpXGTZOM5uHrLh7bfZ9ZBGSfyzaOsc0eX5UIqAMiXW/h/LKjo7k6im T9WCeNShPge5mlB8HBfwf8w+YCD2RcfV9bjsXDHlURHVBJbhw/e6ilbi05uw1YN+DSka GDDQasK75MrCQpMvxdD40vWC2sC+BlI8wG8Dci0TAjicMOj25KjiBxn9ntNfz1aJRnzS WHx8wwAOjpcxeD2A5f0beAa1ITX8mlf0niH9oMu/fOHLk1rBsyacAVZ5ubZQB3TWUEGw GRkEz/IxJRzVmplBqmvkGRnPfe86lvCNe7HAwZaLnVr8BQmqROij5+dZ03GRw/qIAff7 eLxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=taMYfSr3Z1OLGbDUYyrbc/6grk+5DrFU2CpFJTK6Rj8=; b=N8+6wXf866lwX9s8T7uHoL0DMrHi0ZOGwo/+OaZCTRoAwzM9EP+DYQiDip7snAfg36 xb5xArp/tNo5JEyG2lRAtLksgxKZxQx6htJdTQgei/zs5yqVGqXjzZMZQi/HM6yAU7os jaCPXU+BfJWdEVEv6N4vn6NEFsGKcb76U09Xxs3lOuytGpVXLb/HwN4RRUpOIBRgXejU tniXHncTHKxrBar1i04PR1+RPe/K6OEOAd+7u9rJgrVoH5JeoVd1NgXm85AM/s2sW44V x88QdiI1mXA1rcvnad23X4/BDSS1yv0TKL08e9z3ze3z4Hly2za1FkBqpGdCYqhp08p0 87Lg== X-Gm-Message-State: AA+aEWZUGReS+GLFz0DZUF8RtCJ96cRwLoAPUcNdmdEqGVFk3ofkEMvI /TjHNYEs3/nylYD5tJOG7mg= X-Received: by 2002:a50:fe15:: with SMTP id f21mr16388693edt.116.1543912853531; Tue, 04 Dec 2018 00:40:53 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id h47sm4667544eda.8.2018.12.04.00.40.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 00:40:53 -0800 (PST) Date: Tue, 4 Dec 2018 08:40:52 +0000 From: Wei Yang To: Pingfan Liu Cc: mhocko@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Vlastimil Babka , Mike Rapoport , Bjorn Helgaas , Jonathan Cameron Subject: Re: [PATCH] mm/alloc: fallback to first node if the wanted node offline Message-ID: <20181204084052.gpwwlnp6n2zehjy5@master> Reply-To: Wei Yang References: <1543892757-4323-1-git-send-email-kernelfans@gmail.com> <20181204072251.GT31738@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 04, 2018 at 04:20:32PM +0800, Pingfan Liu wrote: >On Tue, Dec 4, 2018 at 3:22 PM Michal Hocko wrote: >> >> On Tue 04-12-18 11:05:57, Pingfan Liu wrote: >> > During my test on some AMD machine, with kexec -l nr_cpus=x option, the >> > kernel failed to bootup, because some node's data struct can not be allocated, >> > e.g, on x86, initialized by init_cpu_to_node()->init_memory_less_node(). But >> > device->numa_node info is used as preferred_nid param for >> > __alloc_pages_nodemask(), which causes NULL reference >> > ac->zonelist = node_zonelist(preferred_nid, gfp_mask); >> > This patch tries to fix the issue by falling back to the first online node, >> > when encountering such corner case. >> >> We have seen similar issues already and the bug was usually that the >> zonelists were not initialized yet or the node is completely bogus. >> Zonelists should be initialized by build_all_zonelists quite early so I >> am wondering whether the later is the case. What is the actual node >> number the device is associated with? >> >The device's node num is 2. And in my case, I used nr_cpus param. Due >to init_cpu_to_node() initialize all the possible node. It is hard >for me to figure out without this param, how zonelists is accessed >before page allocator works. If my understanding is correct, we can't do page alloc before zonelist is initialized. I guess Michal's point is to figure out this reason. > >> Your patch is not correct btw, because we want to fallback into the node in >> the distance order rather into the first online node. >> -- >What about this: >+extern int find_next_best_node(int node, nodemask_t *used_node_mask); >+ > /* > * We get the zone list from the current node and the gfp_mask. > * This zone list contains a maximum of MAXNODES*MAX_NR_ZONES zones. >@@ -453,6 +455,11 @@ static inline int gfp_zonelist(gfp_t flags) > */ > static inline struct zonelist *node_zonelist(int nid, gfp_t flags) > { >+ if (unlikely(!node_online(nid))) { >+ nodemask_t used_mask; >+ nodes_complement(used_mask, node_online_map); >+ nid = find_next_best_node(nid, &used_mask); >+ } > return NODE_DATA(nid)->node_zonelists + gfp_zonelist(flags); > } > >I just finished the compiling, not test it yet, since the machine is >not on hand yet. It needs some time to get it again. > >Thanks, >Pingfan -- Wei Yang Help you, Help me