Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp189113rdb; Mon, 15 Jan 2024 17:55:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjgIr/NywNCW62yXRt30GqA0HUNQbsyful9eQafonbobomUW1LdRhliLGK4jqZI0hWxPeG X-Received: by 2002:a05:6830:1184:b0:6dd:e4d4:bd8f with SMTP id u4-20020a056830118400b006dde4d4bd8fmr7357359otq.2.1705370148538; Mon, 15 Jan 2024 17:55:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705370148; cv=pass; d=google.com; s=arc-20160816; b=H5KW0R61D5CXp47wZctHGSKJHDEY8/v4nlpu/0VLNK3tcXfkYruVYjMOOWWYNJlmlv U+1kDRIyxLHsz9vOwSdxyvA+scZGPsTxFAteYC4OexVjEnrv9KqZrIdowTy6LXJPEm6q scL6Ap+RulRx7H12U+fIfb6p9mW7Dxp6TcyXEeoziRyGL2R+XOr9SHfbzGZ9vBdq+FM9 DpaCbxZybEjLbseUG5RGagjEuh+xCQezcDvzbhBBUbMam9OZmarMqpRpU+v/497KP/7a xB1YGqNGJ3ngHZgBUoa/S6tocCrcrD09M0eIScT+tgqnWTAU79r4nmGDVMt91c2wDdhP FDOw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:date:message-id:dkim-signature; bh=vaWPd7WEmKVVIMbAZTqR2lNCJVRIikKTszywO4roMGA=; fh=J0ptefireN6zRHj+imI9+J13RDpwNk9sGk3Pmu9SIh8=; b=sMMTTSgtqtCH0TcaWrRVMLHHvNWHuNvUXYh5ddJirKJ4hvgxBdchI6sZ7nOdNVS5Qg TaAyXRgMFNRAkCPjIKDAm2Yl23ct55MAuIJMCg1vPacjYnDvGg/+WFR2nagNSXyTYAXa wPj9UBp/TAjXtH0HHYLnNPjQv2g3RswUIjkpAjIwyGwm9KM1vSy58JjH/xS9MlJscuqS mBK/Wb2Z9mXf2rI1LowO9J6H64tk2Zg71E0w2KWMKRW2+fMxPthZmZZjEgBkWvuwglQ2 PXsOySVSK0lC6X2lgTp5RvMOkoMmoPLl9VBBokhUszjq5BqB4PnWx7Qy4nwn9CJwGpXi lqWQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=temperror (no key for signature) header.i=@amperemail.onmicrosoft.com header.s=selector1-amperemail-onmicrosoft-com header.b="/dwxtNob"; arc=pass (i=1 spf=pass spfdomain=os.amperecomputing.com dkim=pass dkdomain=amperemail.onmicrosoft.com dmarc=pass fromdomain=amperemail.onmicrosoft.com); spf=pass (google.com: domain of linux-kernel+bounces-26910-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26910-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id cr15-20020a056a000f0f00b006db81c61c29si3446007pfb.49.2024.01.15.17.55.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 17:55:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26910-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@amperemail.onmicrosoft.com header.s=selector1-amperemail-onmicrosoft-com header.b="/dwxtNob"; arc=pass (i=1 spf=pass spfdomain=os.amperecomputing.com dkim=pass dkdomain=amperemail.onmicrosoft.com dmarc=pass fromdomain=amperemail.onmicrosoft.com); spf=pass (google.com: domain of linux-kernel+bounces-26910-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26910-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 6F65C280D02 for ; Tue, 16 Jan 2024 01:55:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35C91111BA; Tue, 16 Jan 2024 01:47:39 +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="/dwxtNob" Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2099.outbound.protection.outlook.com [40.107.223.99]) (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 34C4F10A39 for ; Tue, 16 Jan 2024 01:47:35 +0000 (UTC) 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=VNjpazYO1E7qaz7aaOG7W7FIpatG+7ZqOSLBztg4TFwU8xjz7UnZfeHduqHNn1oNnTnzjMfEmGgpyjZTIiszVn0BGcgMMtJHqF1iBRDpdEMiWXM4sGb7GoGorSXVDmbt628ah4MwsVwkUlQe4xP7V2D6bHdypKLEzvpPwq6AJmcIs2jjW3r2TeHofCemIOCSLxqnk1upJvuDDq2bNB2yXIe6H/TDX0SbsugsP96pKYUYqCRfzq3PgQLT2GxiKevpW40DJlSkvjUtFLKK7AbWxIny40DOi941TEVcBkTOMdIz3f4pU4wo7Eu+JmxcN1/cACNtqHOmVFro44nRA86xTA== 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=vaWPd7WEmKVVIMbAZTqR2lNCJVRIikKTszywO4roMGA=; b=Rx2gIMu8vONnSXLrAbmU2B94TnvKsfGhBHpt4JbXCYRw5H1TWhDyjiPcmxEWWCu4soJGsG8L/o1ojWNXBhiH+Lvk0JNDU9xF0KrVbgeF7VJbng8getQTfqyzwIgTehSdRnSxMsBhB7WdeUChP0aqpmPCZrqOrH085V2WmPoZBHD7DM2zVNU1Sc1EhFgFRQi26tsZD1vydi9UKs3Koi/1uSDjT3zNudd6/Ta5NkTg6Dn/OB7n4VnQnChQciwPUPale9oHcfZ044zD1IRGL7AGrHMfPD24rjNbiKaTR/qLjdEnb2BcVvodrEWKZ2a/jTC+NKnFCoGs9dC03zvXWNbjCw== 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=vaWPd7WEmKVVIMbAZTqR2lNCJVRIikKTszywO4roMGA=; b=/dwxtNob7PBIPjzXDE3PW1iriz2Hw99L1oHoQqEl9QJTGSgxIvq5gSmuTsIsXLD58zNUERfBxxxKebriWTe6b0kJDvTsu/6fUmnSnFoDUzQDwgOF29N7aVHT67tdbQCOKo7cSKC0Ws5oVuSHTM4iOenoaQHuAvQcERblmrpxoBk= 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 CYYPR01MB8262.prod.exchangelabs.com (2603:10b6:930:c8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.18; Tue, 16 Jan 2024 01:47:32 +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.7159.020; Tue, 16 Jan 2024 01:47:32 +0000 Message-ID: <068cfd1c-8bf7-4123-8f23-49d9ec27de2e@amperemail.onmicrosoft.com> Date: Tue, 16 Jan 2024 09:47:23 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] arm64: implement arm64 specific cpu_to_node To: Mark Rutland , Huang Shijie Cc: catalin.marinas@arm.com, patches@amperecomputing.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20240115095931.53765-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: CH0PR03CA0183.namprd03.prod.outlook.com (2603:10b6:610:e4::8) 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_|CYYPR01MB8262:EE_ X-MS-Office365-Filtering-Correlation-Id: 13067c52-5e82-486d-9904-08dc16351aec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6WNePH+Xpr5wfzSAsNh/IifBt+BAF5lsDIRfXoSaL10ZVoSOQrSGS1aiqnhenZNlyAxUXXrWc4sCyU6P8mxj/hz5kXIsWexDJ/zPheeZWOyrz9MX8WYQPGGWU151kP9r6VdNY4Qo7cdrC1jUUNHa5ZP5mFoKHF1DRqvxfxIXsowJWaDXeeAV/szpEaQvAFUFfC8tAfNoVozM83lptKLRIdDbxLsHu0N0ZJlS9Pf+YrYzkGFSR4CNDvpgjvBPJ7WFEr+uNTjb0NuKeSwK2e1FtmdJsUHmaTq9TlPrC8MPJqofZuiCKq7V+zbtNGevIrtP/jmcKGaRxwKyfO3CBxRJ2YK2K27La/oS8EH9P9XGWC6gKQPGjb3SxlXeoEcEtn+vbsi8zIP6Nc2S1NajOu7IKDUXq0JDlyCtfwOhcn1wQjZoHON3NwHAeRMeR6atHO+YgYhNJJQ0/xV/V0rYmpaeCXly6JYnD4VwFH6ebpIbAKhTfts4/3oqLV6Clvy0xitlUNrM0dr0OfngU84kUewGxSwWExu+TchhGf57Ma+Mu/itwTDvPPEG7uJIQzm+uG171DiC/VCRBcN4OyhJgxUt22tc+Uf/WFDpvpvuo1QICmA= 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)(366004)(396003)(136003)(346002)(376002)(39850400004)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(31686004)(66946007)(6506007)(6666004)(2616005)(478600001)(66476007)(110136005)(83170400001)(316002)(31696002)(6486002)(66556008)(42882007)(26005)(966005)(5660300002)(8676002)(6512007)(41300700001)(38100700002)(4326008)(2906002)(8936002)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aDhtTWlmbCsyZStNTlNVWmlCUFZZc0IxVWhhY0p0R0FVNzZ4RU5RK1ZBbVlC?= =?utf-8?B?U2p4SDRKZVh0WUdRM3VFRE1PK0VQZDFVOEhjcy9vVGwwb1d2S0pIZWEyRnlH?= =?utf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CMFIyRUs4QS9VWnl4bDFxZnlJS0VXL2hieFZEYUJvNk1v?= =?utf-8?B?UzF5QURZUkJYMktsWGV3YmZZRjdxekNSdVczNHlMcENabkpDYkozc0pyRitW?= =?utf-8?B?TjZMdzZ0TjBJMkt3eUdTcU1kSldkT0xmNm92UjExd2VlTDd6N0RzeVZCb1dk?= =?utf-8?B?VjNUcnlmeFZhSXN0OGpKSWRVU3JQZW1qYnN4WVEyNGp5VTRjQmhZbWcvV05U?= =?utf-8?B?ZmNBbmh2Zy92UEJXSHM0NkkxMldsT3VYTUtlczVZcjh2Z1UvNUc1dXVSYnRo?= =?utf-8?Q?DqCFsb2tXRstefIwDopjDRg=3D?= X-OriginatorOrg: amperemail.onmicrosoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13067c52-5e82-486d-9904-08dc16351aec X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7975.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2024 01:47:32.2249 (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: Xm5fgnyYobMV+G6c+RvloReiOBYwdUUARXRfgDgSMZmywQg/UB0G9G1NdbvKv0BstL1foqJAHHkZ0jqzpQy6BMLJ2el/lj1H7lMoJtFUCGnWy4NO7cxb58Vp9LZOCxYt X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR01MB8262 Hi Mark, 在 2024/1/15 19:44, Mark Rutland 写道: > On Mon, Jan 15, 2024 at 05:59:31PM +0800, Huang Shijie wrote: >> After setting the right NUMA node for VMAP stack, >> https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/commit/?id=75b5e0bf90bf >> >> I found there are at least four places in the common code where >> the cpu_to_node() is called before it is initialized: >> 0.) early_trace_init() in kernel/trace/trace.c >> 1.) sched_init() in kernel/sched/core.c >> 2.) init_sched_fair_class() in kernel/sched/fair.c >> 3.) workqueue_init_early() in kernel/workqueue.c >> >> We cannot use early_cpu_to_node() for them, since early_cpu_to_node() >> does not work for some ARCHs, such as x86, riscv, etc. > I spot that x86 seems to have an implementation of early_cpu_to_node(); what's > wrong with it? Yes, you are right. I check the code again, x86 has its own early_cpu_to_node(). > >> So we have to implement the arm64 specific cpu_to_node(). > Surely those early uses of cpu_to_node() are equally broken on those other yes. some ARCHs also has the same issue. But I am not sure if all ARCHs support the NUMA. > architectures, so why should this be specific to arm64? I just want to fix the arm64 first. :) But if you think we should fix the common code firstly, I am okay. > >> This patch >> 0.) introduces the __cpu_to_node function pointer, >> and exports it for kernel modules. >> >> 1.) defines a macro cpu_to_node to override the >> generic percpu implementation of cpu_to_node. >> >> 2.) __cpu_to_node is initialized with early_cpu_to_node() before >> numa_node is initialized. >> >> 3.) __cpu_to_node is set to arm64_cpu_to_node() when numa_node is ready. >> arm64_cpu_to_node() is a clone of the generic cpu_to_node(). > I don't think this is the right approach. Regardlesss of anything else, we > shouldn't have a solution that only fixes arm64. > > Why can't we mandate an early_cpu_to_node(), and have the other architectures > implement that? > > Why can't we change cpu_to_node() to automatically do the right thing? ok, I will change the common code. Thanks Huang Shijie