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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA09ECDB483 for ; Wed, 18 Oct 2023 12:26:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BAFF8D0157; Wed, 18 Oct 2023 08:26:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 36B718D0016; Wed, 18 Oct 2023 08:26:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2329F8D0157; Wed, 18 Oct 2023 08:26:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 15EEF8D0016 for ; Wed, 18 Oct 2023 08:26:45 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E02E51A0163 for ; Wed, 18 Oct 2023 12:26:44 +0000 (UTC) X-FDA: 81358505928.18.9F1DB95 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf02.hostedemail.com (Postfix) with ESMTP id A73FA8000D for ; Wed, 18 Oct 2023 12:26:41 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=AEJkeUHJ; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf02.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697632003; h=from:from:sender:reply-to:subject:subject: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:dkim-signature; bh=aZdIDg1uk+mrpxscqst75VrD7yEmNFKRl+XP6ji4o3g=; b=hIjigGg/gUfUr/uR0s6llyfhjfJqiosSH7QikUIiy4ZaxzRhCzHcythVekFujnvAVil3Um cLaH04+qWyNPjhuRC59jg/IOrMe/hMbk/j7hQoUagfvXm5QACss7v02tdhuf7nqTDAy4tw 7jfk/Rx2soN5/vEM35A2t/a//4D2Y3I= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=AEJkeUHJ; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf02.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697632003; a=rsa-sha256; cv=none; b=Sv7fDvwR0ELPOzU165Nc4z9jqa1TvPT5NyggNIgcroiiS5n9zj9MIUMFNWnXdpVl8RlGjv Dtm82KcDShaSBm7z3DtlsrctZgUg/n/xGL9pN8KdPEYJVAcGqxMNAgZSVmo04MQeZX7BQq UEAIVtyGJc+8FV7VqeMWNNE6lyZvYVk= Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6ba8eb7e581so1029929b3a.0 for ; Wed, 18 Oct 2023 05:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1697632000; x=1698236800; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=aZdIDg1uk+mrpxscqst75VrD7yEmNFKRl+XP6ji4o3g=; b=AEJkeUHJ2fWPBYYoDwAaxLk7i2ydU0xjx9iXH7vePzBnTL8+Q02MGXceEQdMqUoOX5 vvE6s+bhSh/T7+Ker1KLe9WzZ7ndVbXz8aKtxvevXfnvDhKAZD1gy8pqGqv+olZVyfN4 V8sovHCWeLWdP5liq/vYPpcWI8ke401Lq/AQW+iAPSTMW8DEWg+ttbsqcuEyqNFpQL4H +y2sro8hGrZjEHH0cMfootIEkxWE2XRTqZPf/0lEMFO5ROe8rUrgmRcVljgbmRl9I1EW ghyTDMCjZN9OR0Zi4aebTe80PWeuojzcit3QICaLKDm+fh+sLX0iDBFxfv1yCFbK2rmx iMWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697632000; x=1698236800; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aZdIDg1uk+mrpxscqst75VrD7yEmNFKRl+XP6ji4o3g=; b=whI6Bf+8BIMXBtiDrdDNRHWgWkqN6Sju/BssbNDIzqABgHi5d1Po2ZyBmIK4gtLqIO e01WvnQyPS/p4OJpSb6bIWp75aU9C7CcPZi0OZ9XX8GrdKtoH1shDDF8YP74FM8wBULw Rq+2qxTWkCePO/ehrpk0B0Z4UOYlkNTBpyKHcZU2EAUBMSx+/SFLHUHGc2pKr52kFTYa iKzUIJr4otgHREEeX18Tk3M3Hv/pI3cSxZg+V7qEN19sPXcC9uscaemNcAelTbWDR170 0k3eQJypQRCIsPk780tKzcj8e8gXXHPKRvKrP3whg6FtT7D31ODaioKfCBvwTbrKnfe+ KtIg== X-Gm-Message-State: AOJu0YzNnA1Q+QN0fHwY2lCI1Tn6uc2ZIwU8hUPKbq+LtE5V9/+5/qtH YJkLVM5W+UvWPIaWPF3mZO311Q== X-Google-Smtp-Source: AGHT+IFbq99pKP3vQECYPULdpzMOKLMJaET5wq8NDg7QLtnUkjybSD0w+808CEgKHJtcxeLbUyLrMg== X-Received: by 2002:a05:6a20:d80d:b0:163:ab09:193e with SMTP id iv13-20020a056a20d80d00b00163ab09193emr4983608pzb.1.1697632000162; Wed, 18 Oct 2023 05:26:40 -0700 (PDT) Received: from [10.84.155.153] ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id m10-20020a654c8a000000b005acd5d7e11bsm1409852pgt.35.2023.10.18.05.26.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Oct 2023 05:26:39 -0700 (PDT) Message-ID: <605cc166-e731-e7d1-25d7-b6797a802e6f@bytedance.com> Date: Wed, 18 Oct 2023 20:26:31 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v2] x86/mm: Drop 4MB restriction on minimal NUMA node memory size To: Ingo Molnar , Mike Rapoport , David Hildenbrand , Michal Hocko , Andrew Morton Cc: x86@kernel.org, Andy Lutomirski , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20231017062215.171670-1-rppt@kernel.org> Content-Language: en-US From: Qi Zheng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A73FA8000D X-Stat-Signature: 4fz4c6o6qw6a7akfuinmatb1gc4htqcr X-Rspam-User: X-HE-Tag: 1697632001-802432 X-HE-Meta: U2FsdGVkX183ploIyfne58pDsFLMcjvt76Jfw6f1Y1Tp2R4GjsEyDE5JHbRiz+cgJ/xPslqrcbhDZfcgz9ty1bNi8KT6y4KGHi4D/zSicTZfp8at2gvq2zcgxSKhH93roriw3ltBSg9QXUZJMzK9Trm/9t7vD9WED8l7p3s/ebqAsoexqfZP5++5JS12NeHCuTVYwK4Ez2WGJcQe7WQMwK0oRSRDWU1JBTZby48ZJ5dfECH9oKTuK9Ae7anIQIwX5+yMBTJm6BpkjwwkG01eiXHOuboTu3WYdbh0PJAUzOvHlb3k5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+oOKIxZVUnHYIb5TaWPbh0B4hkfgdduAQ+SNOYMEg6rL4LZ1Y88VM5dlX8cM8GIscrqd2yvBWj63qrjcrXi3LvZFIkreqmBmvy5PMhbYkeuzfxNEnOAxhY3L3af3lVX5k44PLJFdF35SyOQw2xF/ewnd8Rgnq9bnueq8bFLaOMlLCd6gyLTDpo3fENi+lVM8 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: Hi all, On 2023/10/18 18:42, Ingo Molnar wrote: > > * Mike Rapoport wrote: > >> From: "Mike Rapoport (IBM)" >> >> Qi Zheng reports crashes in a production environment and provides a >> simplified example as a reproducer: >> >> For example, if we use qemu to start a two NUMA node kernel, >> one of the nodes has 2M memory (less than NODE_MIN_SIZE), >> and the other node has 2G, then we will encounter the >> following panic: >> >> [ 0.149844] BUG: kernel NULL pointer dereference, address: 0000000000000000 >> [ 0.150783] #PF: supervisor write access in kernel mode >> [ 0.151488] #PF: error_code(0x0002) - not-present page >> <...> >> [ 0.156056] RIP: 0010:_raw_spin_lock_irqsave+0x22/0x40 >> <...> >> [ 0.169781] Call Trace: >> [ 0.170159] >> [ 0.170448] deactivate_slab+0x187/0x3c0 >> [ 0.171031] ? bootstrap+0x1b/0x10e >> [ 0.171559] ? preempt_count_sub+0x9/0xa0 >> [ 0.172145] ? kmem_cache_alloc+0x12c/0x440 >> [ 0.172735] ? bootstrap+0x1b/0x10e >> [ 0.173236] bootstrap+0x6b/0x10e >> [ 0.173720] kmem_cache_init+0x10a/0x188 >> [ 0.174240] start_kernel+0x415/0x6ac >> [ 0.174738] secondary_startup_64_no_verify+0xe0/0xeb >> [ 0.175417] >> [ 0.175713] Modules linked in: >> [ 0.176117] CR2: 0000000000000000 >> >> The crashes happen because of inconsistency between nodemask that has >> nodes with less than 4MB as memoryless and the actual memory fed into >> core mm. > > Presumably the core MM got fixed too to not just crash, but provide some > sort of warning? > >> The commit 9391a3f9c7f1 ("[PATCH] x86_64: Clear more state when ignoring >> empty node in SRAT parsing") that introduced minimal size of a NUMA node >> does not explain why a node size cannot be less than 4MB and what boot >> failures this restriction might fix. >> >> Since then a lot has changed and core mm won't confuse badly about small >> node sizes. > > Core MM won't get confused ... other than by the above weird Qemu topology, > to which it responds with a ... NULL pointer dereference? > > Seems quite close to the literal definition of 'get confused badly' to me, > and doesn't give me the warm fuzzy feeling that giving the core MM even > *more* weird topologies is super safe ... :-/ > >> Drop the limitation for the minimal node size. > > While I agree with dropping the limitation, and I agree that 9391a3f9c7f1 > should have provided more of a justification, I believe a core MM fix is in > order as well, for it to not crash. [ If it's fixed upstream already, > please reference the relevant commit ID. ] Agree. I posted a fixed patchset[1] before, maybe we can reconsider it. :) [1]. https://lore.kernel.org/lkml/20230215152412.13368-1-zhengqi.arch@bytedance.com/ For memoryless node, this patchset skip it and fallback to other nodes when build its zonelists. Say we have node0 and node1, and node0 is memoryless, then: [ 0.102400] Fallback order for Node 0: 1 [ 0.102931] Fallback order for Node 1: 1 In this way, we will not allocate pages from memoryless node0. Then the crash problem under the weird Qemu topology will be fixed. Thanks, Qi > > Also, the changelog spelling & general presentation were quite low quality > - I've fixed it up a bit below, please carry this version going forward. > Please spell-check your patches before sending out Nth versions of it, > maybe maintainers are skipping them for a reason! > > Thanks, > > Ingo > > =================> > From: "Mike Rapoport (IBM)" > Date: Tue, 17 Oct 2023 09:22:15 +0300 > Subject: [PATCH] x86/mm: Drop 4MB restriction on minimal NUMA node memory size > > Qi Zheng reported crashes in a production environment and provided a > simplified example as a reproducer: > > | For example, if we use qemu to start a two NUMA node kernel, > | one of the nodes has 2M memory (less than NODE_MIN_SIZE), > | and the other node has 2G, then we will encounter the > | following panic: > | > | BUG: kernel NULL pointer dereference, address: 0000000000000000 > | <...> > | RIP: 0010:_raw_spin_lock_irqsave+0x22/0x40 > | <...> > | Call Trace: > | > | deactivate_slab() > | bootstrap() > | kmem_cache_init() > | start_kernel() > | secondary_startup_64_no_verify() > > The crashes happen because of inconsistency between the nodemask that > has nodes with less than 4MB as memoryless, and the actual memory fed > into the core mm. > > The commit: > > 9391a3f9c7f1 ("[PATCH] x86_64: Clear more state when ignoring empty node in SRAT parsing") > > ... that introduced minimal size of a NUMA node does not explain why > a node size cannot be less than 4MB and what boot failures this > restriction might fix. > > In the 17 years since then a lot has changed and core mm won't get > confused about small node sizes. > > Drop the limitation for the minimal node size. > > [ mingo: Improved changelog clarity. ] > > Reported-by: Qi Zheng > Signed-off-by: Mike Rapoport (IBM) > Not-Yet-Signed-off-by: Ingo Molnar > Acked-by: David Hildenbrand > Acked-by: Michal Hocko > Link: https://lore.kernel.org/all/20230212110305.93670-1-zhengqi.arch@bytedance.com/ > --- > arch/x86/include/asm/numa.h | 7 ------- > arch/x86/mm/numa.c | 7 ------- > 2 files changed, 14 deletions(-) > > diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h > index e3bae2b60a0d..ef2844d69173 100644 > --- a/arch/x86/include/asm/numa.h > +++ b/arch/x86/include/asm/numa.h > @@ -12,13 +12,6 @@ > > #define NR_NODE_MEMBLKS (MAX_NUMNODES*2) > > -/* > - * Too small node sizes may confuse the VM badly. Usually they > - * result from BIOS bugs. So dont recognize nodes as standalone > - * NUMA entities that have less than this amount of RAM listed: > - */ > -#define NODE_MIN_SIZE (4*1024*1024) > - > extern int numa_off; > > /* > diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c > index c01c5506fd4a..aa39d678fe81 100644 > --- a/arch/x86/mm/numa.c > +++ b/arch/x86/mm/numa.c > @@ -602,13 +602,6 @@ static int __init numa_register_memblks(struct numa_meminfo *mi) > if (start >= end) > continue; > > - /* > - * Don't confuse VM with a node that doesn't have the > - * minimum amount of memory: > - */ > - if (end && (end - start) < NODE_MIN_SIZE) > - continue; > - > alloc_node_data(nid); > } >