Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp230547lqo; Wed, 27 Mar 2024 11:18:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXZRAhYuOjb4RR0Q/51OOHbIrCtXOek2ff9zO56SdYwbNgb4861+IemFYO2NUqFHLF72IAUT4yqWPlQeCkthaI5wBwFTNJptXkjBTMJ8A== X-Google-Smtp-Source: AGHT+IGvBBWMkL/dNSXgY6RaBSKEGj0XmZ82XlWkBvypv7dwDWCaernTWQjFVVN6LnTr/mpcug/G X-Received: by 2002:a05:6a20:9f96:b0:1a3:bcd0:3bda with SMTP id mm22-20020a056a209f9600b001a3bcd03bdamr848409pzb.15.1711563528371; Wed, 27 Mar 2024 11:18:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711563528; cv=pass; d=google.com; s=arc-20160816; b=AJhZZHl02XjHxcgysNG8c+XsLeNR5py+uiM/XmofytKMAwzlnG81RD1TihajIX1k6Z 4gZZEt0SfodloArSDcb7JoTsCFXKT8Vz8rM/ocWe8C65xUFuFjE3PgTAaG8nEVLHx05f gUDKutjJcxGr2x4Ar00nwvfYcTXOnk4PRSkCnEDvEGlLONWCkIUvzofVip4g1svz91xa weEzvdRn2Z/A7PmFswi9d/yaKArjshHtv898A9YvTecnuXYONIWBIVUkC7h3B1Rhy3IN w7dHIBY1C+1nCeewb67DL/JKoCoaH0f/mInjbPP/AF2hi8qbMhNAxtRIrXZpQYTx0KON 3u1A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=byGL53qiGBbXiBapByeeI0s5PD32Z9zHMJCgL9CiBbk=; fh=T9OnXifD/0qQYnEFKK6l3OFqNepyaZCBoOgtXT5BvMg=; b=N/mJ3HJxeu44CSmXy901+ypTv+0rgjPIKovWDsS55n1TXpZnD1kqqMTXRuuVPkWjli nustY4TU87hOAGtB+1aWl17ApqWqN6PCTM0DlkzjuS4lOSci3deo87bZNelZ9HO+jiKx hzMrG7GkQ0TWnlCR/wRPFFfanOUrfOEHOGplBKBdxORNrW2sc6fVtVxELpyDw1Hd13c/ 9ilR07ad2fdK6neYpFN8wXPn2s6zj1FKlu8i3lnYZQdguN2x3wffws4t0kq3Pa2H/ek7 8ewfU561+0xuCZmW1g/WX0ZHHuygeFCP5gI0rBVEcFtySsJB8yl/nQ9t3IkA3w19iRwz bVdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=RkxWd7fx; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-121815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121815-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i35-20020a632223000000b005ce06ca3538si11990063pgi.873.2024.03.27.11.18.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 11:18:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=RkxWd7fx; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-121815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121815-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A48A1294621 for ; Wed, 27 Mar 2024 18:18:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C56FB14F124; Wed, 27 Mar 2024 18:17:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="RkxWd7fx" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1B6C130A63; Wed, 27 Mar 2024 18:17:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711563463; cv=none; b=KNSdfrj3qdm3WB4VO4w7otPFDA6KbIkv2YwYM98Vc3zXBBS/nf33YzENmouuAA4bvH8GPmRaYoe6cKGXBQhX2Es9CkE4qZXtl5yldu4Iq3Z7Mwldd43EOrwW/KSFpKsRjlfDHQ/ukPFuOsx/ujv6wPqkHdx4+wf6P+hYlDIy9Wo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711563463; c=relaxed/simple; bh=cuOPfgYarGsg6xpTgF2yo+uJ/Cd9/PbvYrZtfzWIAWA=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=pz5VT01FaeJh7nPWl99os+j8lz9tJh7uTJr1Fa5+RpgcjCm6qf6NK3DO0jnu5Usnh35hV7vthK/MKOXCYwsOsysHKAkJDkd7MneDS3WzGCna9L4CV+bZZz3OFCVXxOXVy2OYX05yqENksSFJLASWGku/olzB9Aj6s2XC1/Vx24E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=RkxWd7fx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 680A4C43390; Wed, 27 Mar 2024 18:17:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1711563462; bh=cuOPfgYarGsg6xpTgF2yo+uJ/Cd9/PbvYrZtfzWIAWA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RkxWd7fxszjbkBAhnxMMmGIe1h9FKHAVl8O+/y4E+OyVKiv7IRTOoVWnBexJe9Qi9 +TAsEnYgru/VQSeepmbuUfEprBv2RQg5xWifJm48Tf7YU36SeMA36iZubYcx/pS1In 9D8kpe1b6ypL+O0tgl7HcF34HzDsZeDajYeDtxlE= Date: Wed, 27 Mar 2024 11:17:40 -0700 From: Andrew Morton To: Huang Shijie Cc: gregkh@linuxfoundation.org, patches@amperecomputing.com, rafael@kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, yury.norov@gmail.com, kuba@kernel.org, vschneid@redhat.com, mingo@kernel.org, vbabka@suse.cz, rppt@kernel.org, tglx@linutronix.de, jpoimboe@kernel.org, ndesaulniers@google.com, mikelley@microsoft.com, mhiramat@kernel.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, chenhuacai@kernel.org, jiaxun.yang@flygoat.com, linux-mips@vger.kernel.org, cl@os.amperecomputing.com Subject: Re: [PATCH v3] NUMA: Early use of cpu_to_node() returns 0 instead of the correct node id Message-Id: <20240327111740.f8d3802b0eae15bcb8727e04@linux-foundation.org> In-Reply-To: <20240126064451.5465-1-shijie@os.amperecomputing.com> References: <20240126064451.5465-1-shijie@os.amperecomputing.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 26 Jan 2024 14:44:51 +0800 Huang Shijie wrote: > During the kernel booting, the generic cpu_to_node() is called too early in > arm64, powerpc and riscv when CONFIG_NUMA is enabled. > > There are at least four places in the common code where > the generic cpu_to_node() is called before it is initialized: > 1.) early_trace_init() in kernel/trace/trace.c > 2.) sched_init() in kernel/sched/core.c > 3.) init_sched_fair_class() in kernel/sched/fair.c > 4.) workqueue_init_early() in kernel/workqueue.c > > In order to fix the bug, the patch introduces early_numa_node_init() > which is called after smp_prepare_boot_cpu() in start_kernel. > early_numa_node_init will initialize the "numa_node" as soon as > the early_cpu_to_node() is ready, before the cpu_to_node() is called > at the first time. What are the userspace-visible runtime effects of this bug?