Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3757385rdg; Wed, 18 Oct 2023 05:27:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVp6NYqEdc9BipPral8sFO75hHOjtHEbcOElb3ICW/BxOmcy3c0wQhzhwo8UtBC5CU2GtA X-Received: by 2002:a17:903:2285:b0:1c9:dff1:6de7 with SMTP id b5-20020a170903228500b001c9dff16de7mr8029623plh.7.1697632021176; Wed, 18 Oct 2023 05:27:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697632021; cv=none; d=google.com; s=arc-20160816; b=MF3b/EqbSH9o18RH0IlNxsDDtKNy+IB+sRmQHzlRILadevGk8MlDqOzZcTRDSsHC04 baHdcLDijv4K4HS8zyssoLlZwgmSwOQUrCIubRqTSeD+HrmFapQnmZVsHNQReAhgrjP8 1pLP+qLZpjR/Zq0id/Qul8PMuwRwCQRu71ZB/dsbfulzSgDuzLQrZKMgp9qm1cubQPIV o4hrkY7ROdhjgnqRXV7uatUXSiMV0wYFPAuqPc7ptDudcZKWFTDuWdEBxRyvoPkKE38S 5+qQbdSmbvm5qTKo7BIvXyMwGohv0PhNDAgencf4iIEQZ8MrWZoi40WNluwTs06aX8Kz Llxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=aZdIDg1uk+mrpxscqst75VrD7yEmNFKRl+XP6ji4o3g=; fh=YIEY+obn3mmzNgxUoYI5ZBoaCaLJnx1dE2ApNeHBF+s=; b=u5OyAerF8e9OpWIrcQAuYm2cYvfW8x0pfzGmyUDRkZvXBkM4/YhV4djRML5cXQ6LrY Bqmn1NIlhqmYvIbb10mxkCoyiQ10ZIKFl/+TsicOWWlzX5yzPzZ84cQG4kKOj+hH3Vg4 WaKsRr2mhG02fxKbYIDF+AxI0yRiSru0Bbe2geKM6rk2dbaiMry6vH7Co84RSVK25Roo MPmZMq3mxt4GQjW1TNva1qGLHgkZMFCBZpSorQrY/bzRnhbksog7a+E3/bOvx7MalbvC Rx0JaKH97Vat0eNSQshVyUY1bWqbKOPqiSegD0t9gMgk6xY/ZJkvgh8nXwFfUy8SZTNv a7/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=JKmDg6pf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id la7-20020a170902fa0700b001c5c632aea4si3886488plb.217.2023.10.18.05.27.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 05:27:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=JKmDg6pf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 253D3802A304; Wed, 18 Oct 2023 05:26:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230145AbjJRM0n (ORCPT + 99 others); Wed, 18 Oct 2023 08:26:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjJRM0m (ORCPT ); Wed, 18 Oct 2023 08:26:42 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF201A3 for ; Wed, 18 Oct 2023 05:26:40 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6ba8eb7e581so1029930b3a.0 for ; Wed, 18 Oct 2023 05:26:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1697632000; x=1698236800; darn=vger.kernel.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=JKmDg6pfucnhXZqQj4Djuxrq4lQSMVT+aUq89Pc8vLWJ6QMevgxWSGKTpAi9LxMtU5 ZdgUx7BWPea3YvqAArgFmTQAE2C388Hg7zuFWNE3L4wkxthiJqN8TSrENwS12j7lxF9A 0TEmlHwKhC2+HeQLzslooyH9zj2Fpm1340K8P8v67znkZw40LhjGglCSdkwIUjr9JB1i aBBkzWiRg5xqYlrhylKH4DS2cCmGBhCAoiCV+WCI5jsKm/XYzRrdVN1Zfw0+nvMMIJC7 xCI/n4ukEL/zxQsnjymkuoR4eixMu13cf6Q/uq/Bir4t+C/HwZczrzmzL3AqlZSvMnfL z6mA== 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=Tk++NZlTfNjXni9Tjql7tBQlL1TkyPE55NrlsWVzmOdLqlVKPap63sUBR/ETYv1mJr j60HHgHbERFuIyZof46nNyAjT3fyZ00NbLnBSzPpEUsNes99+AQwc6Ad3AZpXHlOuznf 41IiVu9Qlvlfn3wu7SGOgsPwKijssvDUhPELjcyTB/q5V/vJ6HvL7wm9bN0/TXPQQf1n XxZgk8QPSFTwIEiT28sAJhrhzcjKLVyMpo3KKQg31yUnpsctUMgkLv1XYjDsNEWJZrdX HD3qQOq6tfdikbOEiXE6w1TUiESBny/poLTja3BJugtFb3Bd/smc+Nhuqz1X0kvTyUZD FTnA== X-Gm-Message-State: AOJu0YxZNa/LdihA94ZbsL12WI1KaDHdoe7S1ft1hcWuLDzNwibl/TGj XADfr0jkYUnxcBDq9jQQ5nYueQ== 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-Spam-Status: No, score=-4.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 18 Oct 2023 05:26:58 -0700 (PDT) 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); > } >