From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61897C433EF for ; Tue, 2 Nov 2021 11:44:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0FC6060F5A for ; Tue, 2 Nov 2021 11:44:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0FC6060F5A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9FB0194000A; Tue, 2 Nov 2021 07:44:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9AB56940009; Tue, 2 Nov 2021 07:44:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84C4594000A; Tue, 2 Nov 2021 07:44:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0194.hostedemail.com [216.40.44.194]) by kanga.kvack.org (Postfix) with ESMTP id 76DD0940009 for ; Tue, 2 Nov 2021 07:44:46 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3869C1828ECD3 for ; Tue, 2 Nov 2021 11:44:46 +0000 (UTC) X-FDA: 78763808172.03.DC80320 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf08.hostedemail.com (Postfix) with ESMTP id 8BE2C30000A9 for ; Tue, 2 Nov 2021 11:44:35 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 789F521763; Tue, 2 Nov 2021 11:44:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1635853484; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KEOvJnRWexgJYfY25q9WuMGbZFJrjSNfEkZHTyzLLJ4=; b=IZ7Lp6Mba/cCskET8M5IguvVMzjQ7yUO+F2026/HvGdJsEgmC8DAuRrrE8P5/SsAM+Kykf aU1Fq4XFYfSb188i1kPPeCMEHWmTmXnnaPsqryYyMx7r1K5HUY4J2JObf50T1nFapwr8M2 PrNJSZshO43h5ei2dFfXvlzbzlAbPMs= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 49D6EA3B83; Tue, 2 Nov 2021 11:44:44 +0000 (UTC) Date: Tue, 2 Nov 2021 12:44:40 +0100 From: Michal Hocko To: David Hildenbrand Cc: Alexey Makhalov , "linux-mm@kvack.org" , Andrew Morton , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , Oscar Salvador Subject: Re: [PATCH] mm: fix panic in __alloc_pages Message-ID: References: <20211101201312.11589-1-amakhalov@vmware.com> <7136c959-63ff-b866-b8e4-f311e0454492@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 8BE2C30000A9 X-Stat-Signature: dsr891ithteuhp1htmdh9uw7fegr8ba9 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=IZ7Lp6Mb; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf08.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com X-HE-Tag: 1635853475-918949 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue 02-11-21 12:00:57, David Hildenbrand wrote: > On 02.11.21 11:34, Alexey Makhalov wrote: [...] > >> The node onlining logic when onlining a CPU sounds bogus as well: Le= t's > >> take a look at try_offline_node(). It checks that: > >> 1) That no memory is *present* > >> 2) That no CPU is *present* > >> > >> We should online the node when adding the CPU ("present"), not when > >> onlining the CPU. > >=20 > > Possible. > > Assuming try_online_node was moved under add_cpu(), let=E2=80=99s > > take look on this call stack: > > add_cpu() > > try_online_node() > > __try_online_node() > > hotadd_new_pgdat() > > At line 1190 we'll have a problem: > > 1183 pgdat =3D NODE_DATA(nid); > > 1184 if (!pgdat) { > > 1185 pgdat =3D arch_alloc_nodedata(nid); > > 1186 if (!pgdat) > > 1187 return NULL; > > 1188 > > 1189 pgdat->per_cpu_nodestats =3D > > 1190 alloc_percpu(struct per_cpu_nodestat); > > 1191 arch_refresh_nodedata(nid, pgdat); > >=20 > > alloc_percpu() will go for all possible CPUs and will eventually end = up > > calling alloc_pages_node() trying to use subject nid for correspondin= g CPU > > hitting the same state #2 problem as NODE_DATA(nid) is still NULL and= nid > > is not yet online. >=20 > Right, we will end up calling pcpu_alloc_pages()->alloc_pages_node() fo= r > each possible CPU. We use cpu_to_node() to come up with the NID. Shouldn't this be numa_mem_id instead? Memory less nodes are odd little critters crafted into the MM code without wider considerations. From time to time we are struggling with some fallouts but the primary thing is that zonelists should be valid for all memory less nodes. If that is not the case then there is a problem with the initialization code. If somebody is providing a bogus node to allocate from then this should be fixed. It is still not clear to me which case are we hitting here. --=20 Michal Hocko SUSE Labs