Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp818481rdb; Thu, 18 Jan 2024 22:46:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqsb4byzgpVOBY8gOXzP8Wbqi99tiLxb8obVLzhSfnA3Atp916+cpzGOqLAKDMavGbawDy X-Received: by 2002:a05:6870:46ac:b0:206:7fc0:4d57 with SMTP id a44-20020a05687046ac00b002067fc04d57mr1984397oap.22.1705646805615; Thu, 18 Jan 2024 22:46:45 -0800 (PST) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n5-20020a634005000000b005c6183ccab2si2765271pga.630.2024.01.18.22.46.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 22:46:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30828-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=temperror (no key for signature) header.i=@amperemail.onmicrosoft.com header.s=selector1-amperemail-onmicrosoft-com header.b=EDhQMB5P; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-30828-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30828-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 343EA282593 for ; Fri, 19 Jan 2024 06:46:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 867498F61; Fri, 19 Jan 2024 06:46:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=amperemail.onmicrosoft.com header.i=@amperemail.onmicrosoft.com header.b="EDhQMB5P" Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2119.outbound.protection.outlook.com [40.107.237.119]) (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 D7F8B6FAF; Fri, 19 Jan 2024 06:46:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.119 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705646797; cv=fail; b=AOkmdcXdbu8AnkugIoB1BL5IeezrEA1WRYtX92bhPjJcGeKvVVf2mPCmxQXbVa1srBZ73/dymAWqOYPKGi5HRjHjSqbo3kz/DcuqTkIPT3W/VwdwL0KEMhWO37tMy9d0sENo9+3yRMlPgLiP/bl9FIHz9SihPBOHo7kSXZAZXEs= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705646797; c=relaxed/simple; bh=WSfo5lJs6BSrKOfsVlF20X3acurqj2SB9yQTU+FUemk=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=HQ9rT97hGnNIJO2IDvlo2CcRdr0Y4FjHs1sn7vHAZbEY7hR9EaAfVmaX8agqpmqhjdSyjVE5ApmX25GmENgjBSmSMFkKdRcde47CYToIsxodg+TwHgGE2m26K/fXqt0e2YP2F8mXzW+Au3MDimj8FGG9QTTAr/NeclQzRXg+v+c= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=amperemail.onmicrosoft.com; spf=pass smtp.mailfrom=os.amperecomputing.com; dkim=fail (0-bit key) header.d=amperemail.onmicrosoft.com header.i=@amperemail.onmicrosoft.com header.b=EDhQMB5P reason="key not found in DNS"; arc=fail smtp.client-ip=40.107.237.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=amperemail.onmicrosoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=os.amperecomputing.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ToxSrkd73ZGalQ3rTv0/E5aCuSPiZaP7el12HgdzvDghy06BxQTD+Dk+JQ6sT2LvUQ+y6zsce3gmhMFKzShdLDqzfCezyBDBlQx9rObKh9RzDCGEpi6ys2jtDX+0Px95s2kFTxpDfjfctlG4PzXtQ8gnMBkezHCoANQ2hpe0vvOv+ld8470iHdcRt6pSs6ljiaFZWZx4uarOgbAFbyzv5F+c3A6/sSeK7xtgy/TOQzHh673LqEzFbBSexqi9ZBm2d9WLxY5mJEkytUN0ZDaGLg7G8fECr5lqeN2lM0ymwINFh+yioJBcvYx/kbyAtGKuIFMYzySaoY6AqUPj/hwp8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KuvYuY28tX/CjPLdBJzvpF9TuCjSNkmWkt/BUdLf5zE=; b=fs9WqPxOULVVU5dXj5MOlUIwiuaZsT0i26C932y1cSa3hgdm2wWUzFQTIU0yok7y3sDSczhDC4AqrsApwS8uyigzbqmgs84gldfxP1qY/95dJw+Mp7SeiqA+GEONgeRiwieeqi55/UJXBl/iYM5J59G4nkVcb4oK4buP5vrSZzBGnZmrJ2ulLR0zVFux5xqlpb7k5d1jGjF3KJouwqJRRQgbJEBznXuL9dCoAENkQxoK2e9fKBJzvdIe+Iu1WsIIsN4qt/chMLns/2hbxrNdBeAiETyk3e9UZBPx5/wjpQiFcrukikS5Dfa+MwXiB2H3px+Q4pY9EXCMyN2sIP4ikw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=amperemail.onmicrosoft.com; dkim=pass header.d=amperemail.onmicrosoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amperemail.onmicrosoft.com; s=selector1-amperemail-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KuvYuY28tX/CjPLdBJzvpF9TuCjSNkmWkt/BUdLf5zE=; b=EDhQMB5PpxrJXQjZx6L+fAyha2CqtyIlxwvTSbuYGg7ae1MiHuye/H1DcEgaFgHkaRPkZ/y4FrDt6/Kv0vnOSM7Q6pYI5/uc4szG78aLPoI65CS1KSBVy9PC9FnzuURNSZHzA3JdXxcbZCNag82i8WYjvhSMj6yKR8ovtjAWh48= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amperemail.onmicrosoft.com; Received: from PH0PR01MB7975.prod.exchangelabs.com (2603:10b6:510:26d::15) by CO1PR01MB7291.prod.exchangelabs.com (2603:10b6:303:156::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.26; Fri, 19 Jan 2024 06:46:31 +0000 Received: from PH0PR01MB7975.prod.exchangelabs.com ([fe80::91c:92f:45a5:e68a]) by PH0PR01MB7975.prod.exchangelabs.com ([fe80::91c:92f:45a5:e68a%6]) with mapi id 15.20.7202.026; Fri, 19 Jan 2024 06:46:31 +0000 Message-ID: <1cd078fd-c345-4d85-a92f-04c806c20efa@amperemail.onmicrosoft.com> Date: Fri, 19 Jan 2024 14:46:16 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] NUMA: Early use of cpu_to_node() returns 0 instead of the correct node id To: Yury Norov , Huang Shijie Cc: 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, 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 References: <20240119033227.14113-1-shijie@os.amperecomputing.com> From: Shijie Huang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: CH0PR07CA0017.namprd07.prod.outlook.com (2603:10b6:610:32::22) To PH0PR01MB7975.prod.exchangelabs.com (2603:10b6:510:26d::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR01MB7975:EE_|CO1PR01MB7291:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a71be4b-4d28-4475-f9fb-08dc18ba5e97 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XkTx/JxRN3LuU7scTj9pZMjdworz1bZPy5bNUWL1hw3KMe9IzHtySEg2FHKKrcMbZp3UwdOqqolDgk87L4uKwGYTAypPcS5i64OcecxaqJK1iu84R2vBzPO5JIemsxt355eLW3zcq++G983X0VaQaLoleirsLt+UiDHTo1jA1IDSXgD8YBSKvZ1yrAF1zLVosD+uawYKkF1SWDtb380DWmYFZ1dPh3gp9hCHUTvOe9K5SqFsKSEMILbofWUnO0PCfzJck7p7tAZOyvjYiEOcXVgzPuD3qIbw50ouDi36YTx8wkU4VnbegUVgeXuOKOsOeMBHniqrpJjH4PSeRYIfPlMvhqpYXNTck8ORHkBMBD9KVylb5sbMJCeXyVqOKCokdaDMkwQer0/CufMCGzsGJ2z/ZW/Tz3zH7aiZszMMlnKYzSM61HMuO9/UjkYWuMDp8/XdcHVyiqoroZeg0y8NB3boRnLYTsLr1FVEmdMFMXdG/my9D3F3zd3Z4TVpBk00R7H3kmg1mWrlClP9T8SCNnGPLpVxrXP5VyY8pUfIqvDXSd4qtdVUVoqn6rMV9cNwrfLmQ7eOZzNDzCdZ1IDAVfHQTwOgfeop3dPkISHa4LTK0OhUMfgXt3gSCBtvWx+u X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR01MB7975.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(346002)(376002)(366004)(396003)(39850400004)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(26005)(107886003)(2616005)(42882007)(6666004)(6506007)(6512007)(83380400001)(7416002)(5660300002)(2906002)(41300700001)(478600001)(6486002)(110136005)(4326008)(8676002)(8936002)(66476007)(66556008)(66946007)(316002)(31696002)(38100700002)(83170400001)(31686004)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Wk1OR1hhSFA1L2tFZS8yN012Ykx5Q0ZpbE96N3pEVHg3ZEhPSTl6blFkSmFy?= =?utf-8?B?WGJlYngzQm1wL0NzRVFJQjN5R2hZckpJOEM3dXJTR2ZUV0tBcHlGREtyajc0?= =?utf-8?B?NkR3dEVuRU9lZHZxRVd2YkFSaFJIK0w1RnpOTTZhbVdLaHRLanRVd1RUemQz?= =?utf-8?B?VXIwMnlBcEk3QlIreHkxQnNVeDZ3dkJNZzlIVG84REM4Ni9EWkRCNy96V2t4?= =?utf-8?B?dE5KZ1Z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3YUR1cVlacUNsM2RneVBUeHJhQTh2VHdO?= =?utf-8?B?aXRuLzRtYUFqM2Y3YTc3bXNoZzhwcGZnS3BQMzhqaGZvK0JRc1NRN3p6RDFl?= =?utf-8?B?aXh1eDMvRjI3b2ZGYWVKaTI1Q1hmQjB2OTl4ZDlSN0dNaTkrM1Fub01laUNo?= =?utf-8?Q?B20T2V3cGUZIlLJgRJacLEQ=3D?= X-OriginatorOrg: amperemail.onmicrosoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6a71be4b-4d28-4475-f9fb-08dc18ba5e97 X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7975.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2024 06:46:31.2149 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aL3NMB/llKCtTPp63balqZ42Tl4RRBeAJeirXOZ7LmljgdrDW1oFiM1OcbTxQDQK51s68scd4lSctql53pA6PiB5e9R2H2Nsh+LtUUKfylp/AJ3mCRjqaIT1Or84w08p X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR01MB7291 在 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% > > 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. > > 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