Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp862333rdb; Fri, 19 Jan 2024 00:42:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IF4PC+4sUfUt2gepidxFFn0EZMA2AIA4rIuxyuKq5piJIoDDJTt790COR/XmnrO2L2xo8e4 X-Received: by 2002:aa7:d04a:0:b0:559:ef77:c379 with SMTP id n10-20020aa7d04a000000b00559ef77c379mr841973edo.109.1705653763844; Fri, 19 Jan 2024 00:42:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705653763; cv=pass; d=google.com; s=arc-20160816; b=BS/uqigSoKZ5njDxFWrVyEdw+EQRT8yCW1mJVd37U1n3G3/Cc/rCWQAuLBe4fyrfX6 o3k8eYrK/Y14cHskgew9S2oRBPutX8Ju/bSRHS825fymrGrL2OVkaqBm8/c4CYyYYKI9 mF7HHhOEt6Ko8SADn1NRRlGj/cwgCmNdI8Sy0/ozArwUS5GgrjGISKK00pinRTmJUr+1 E3z/Koz7/E/ugrKpJIYjLfjd5ECEvQPabzDEbTq8Yfnt5IQuXUkZta6wLfHTrVOLx3yj qu2Bb3iM347mVVF5nwj5xxBgoi5avUnv21SQAPNSfacqjzFFcA7myRif+JKQmFGYT7Dk jKbw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wwgebwdqYNMKTiafLlmwxhHj1sEL7JB/1xq3KtOsZ+k=; fh=wrI0x4h8Zmupv13w/8NqwHAK0fpUi9R3eXxefJuA5AI=; b=TvhmvLfPOX38ywH4THchxqX/gEcnrhLspwfV4PA4vb0heuI6TKA9OZp7hZebKDh8iR s6zh3w5g1vLLI2P/gI+m2jCMHZxVjxhMxzNvUWRdbXnBBaBDLMAYhInluNUN7813Xmve K6cDnywEl9KbDVLRmjt1WTChhyp1nxTlkQu6jWgC6isJ0X0MzDbBqK1nK6CTucI72uWf WwUIWN7+Ab5obgLzD6JXPBinM5P7whoWyE6yXa8f1BF9VVl+AMF2jvINg/j5Dc1KVUfY 3rjtUHUSeZLfIUREhUBlSZY9a9J42rUaNJSqySa13ABfXYUNdllub4APdMHvstRyzyGZ /iww== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RUoTSPkL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-30916-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30916-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n12-20020a056402434c00b005591f7b4441si5563187edc.35.2024.01.19.00.42.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 00:42:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30916-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RUoTSPkL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-30916-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30916-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9A7FA1F2378F for ; Fri, 19 Jan 2024 08:42:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5CF8E2376A; Fri, 19 Jan 2024 08:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RUoTSPkL" 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 7915D20300; Fri, 19 Jan 2024 08:42:25 +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=1705653746; cv=none; b=TFPaIAp0+NGp65Qjbzd9TmnwWqWabo9xSSSuBrNqYIXzWxSNbwbamtjfs6ZNIt0ZvtvWIPO7QeHhLiFdMZjnSSqZBvt3KoG/HFb0x0sovRGt8zHHzYpWoxKgHUqN9tUuhOOvInhDnVmxxF0LWrpad83cgUYIIXsUiYmS4PsEAQA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705653746; c=relaxed/simple; bh=g5BoGuy/aNMWgkh7HES0ckmxP53aa40fqWFfKkEi5ao=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QB1K6SUMUM1l5STdyUXAz59oEKP9hl94rIv8memLXTxKbfzK/wy+/VOAy9gKtB05iCwzWAHF101DN5WsBb6IYxVQlpNv3y9/L22wfRH0qxzxXnHpIp4XwDCnv2jX2g63uNkSC6mCw7KP4Y71166nx/ocBCV0dXdoTz+xqcaQsUw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RUoTSPkL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D732C433F1; Fri, 19 Jan 2024 08:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705653745; bh=g5BoGuy/aNMWgkh7HES0ckmxP53aa40fqWFfKkEi5ao=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RUoTSPkLvPmGnMVOMJ1HuVQU6XfFhUmlMpbTrKyG6U8fqip+jV7+oHYufClRc2Byz I3fuHmD32xA9G5aC/qgCk0gYD2vI2MQEFi09W0zbpuY8l7bMAjiVnFVTxzbC5teWMK 2ts22XzYj3hQvM/l0YmrlVjXLWu1vB29XDBEUj8NHEI4CKzhcPgj4wkLqJgR+twtIi 1e1W7S0aNeD7srev8SEKpVES97FlgnMqaSwICysppCZPOJOdR/q6MZgPu4DkdBn1e1 eGJEwySey3GhtxwqiPhQicHsJSJpxONbZ8rdyTC8j8SjIWuLoAXc0bc1dmrqTx86DO cHge1k3R0OABQ== Date: Fri, 19 Jan 2024 10:42:04 +0200 From: Mike Rapoport To: Shijie Huang Cc: Yury Norov , Huang Shijie , gregkh@linuxfoundation.org, patches@amperecomputing.com, rafael@kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, kuba@kernel.org, vschneid@redhat.com, mingo@kernel.org, akpm@linux-foundation.org, vbabka@suse.cz, 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] NUMA: Early use of cpu_to_node() returns 0 instead of the correct node id Message-ID: References: <20240119033227.14113-1-shijie@os.amperecomputing.com> <1cd078fd-c345-4d85-a92f-04c806c20efa@amperemail.onmicrosoft.com> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1cd078fd-c345-4d85-a92f-04c806c20efa@amperemail.onmicrosoft.com> On Fri, Jan 19, 2024 at 02:46:16PM +0800, Shijie Huang wrote: > > 在 2024/1/19 12:42, Yury Norov 写道: > > This adds another level of indirection, I think. Currently cpu_to_node > > is a simple inliner. After the patch it would be a real function with > > all the associate overhead. Can you share a bloat-o-meter output here? > #./scripts/bloat-o-meter vmlinux vmlinux.new > add/remove: 6/1 grow/shrink: 61/51 up/down: 1168/-588 (580) > Function                                     old     new   delta > numa_update_cpu                              148     244     +96 > >  ...................................................................................................................................(to many to skip) > > Total: Before=32990130, After=32990710, chg +0.00% It's not only about text size, the indirect call also hurts performance > > > > Regardless, I don't think that the approach is correct. As per your > > description, some initialization functions erroneously call > > cpu_to_node() instead of early_cpu_to_node() which exists specifically > > for that case. > > > > If the above correct, it's clearly a caller problem, and the fix is to > > simply switch all those callers to use early version. > > It is easy to change to early_cpu_to_node() for sched_init(), > init_sched_fair_class() > > and workqueue_init_early(). These three places call the cpu_to_node() in the > __init function. > > > But it is a little hard to change the early_trace_init(), since it calls > cpu_to_node in the deep > > function stack: > >   early_trace_init() --> ring_buffer_alloc() -->rb_allocate_cpu_buffer() > > > For early_trace_init(), we need to change more code. > > > Anyway, If we think it is not a good idea to change the common code, I am > oaky too. Is there a fundamental reason to have early_cpu_to_node() at all? It seems that all the mappings are known by the end of setup_arch() and the initialization of numa_node can be moved earlier. > > I would also initialize the numa_node with NUMA_NO_NODE at declaration, > > so that if someone calls cpu_to_node() before the variable is properly > > initialized at runtime, he'll get NO_NODE, which is obviously an error. > > Even we set the numa_node with NUMA_NO_NODE, it does not always produce > error. > > Please see the alloc_pages_node(). > > > Thanks > > Huang Shijie > -- Sincerely yours, Mike.