Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1235408rdb; Sat, 18 Nov 2023 08:03:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzw/y8tqGCw4sVFKErzMR4ydc8biUnTNk5LiIm/qd4ZI+gl9BsaHriILyaDiGdCSL4AXSj X-Received: by 2002:a05:6870:b692:b0:1e9:f1af:e33d with SMTP id cy18-20020a056870b69200b001e9f1afe33dmr2967264oab.36.1700323389835; Sat, 18 Nov 2023 08:03:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700323389; cv=pass; d=google.com; s=arc-20160816; b=FspBP3tVA4c/k3U9nAeOPiRLI/oLsVfuYCliCdX7J9fiTsl7hM3W1ASH6+Frcglaly 7Q8nAmWTUxamcFMncWJmOFDLyCxPIVF66Nk/PhIcK44xqruF+kk0Q7UWDEF6X6rdcCz+ OrvPfEqyyuTDCOB5ylslukYDEGdakBnzR0b3IiQXImACikEenootgGegXBRYGUNYLxXG t8PzUVg9dL91A8MzFRLlZ4+ofL38RdxyvPtpjXOjFxRtZzxNr4qz3+8N2D3biV69wAHu 8nGZIGuDozk6a8xca+hPQp7yL8eJ47pdfQghHhatZHoHGO2HbSNj3UEOdeTkMg9/RS0i pzlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wv2MhPhz8vX5EVXTcetWaN6ncrvpW3Me+2LRl1lemRQ=; fh=FpWUK1Dqq9usdIlHjzlZ1b0bmIVNDsz6Rd1cKPgoizk=; b=FVD2YumyzSLgDN+j6qu0s3kvVGaq+XwI1ymUjpWOnVDVlyxX4evuxZ8bOwI3bPkmbp eVupyBN8lSJhiLsh5lat0mynRVIW5SficGKhPc9XpZ2S+C9ogFbWoDYAL/ITmshO4DSh 33D5z4ps1OIlpFO5R4XCUtKUfwqhYsylZgaqgoPJVACXJxyrfjVMnjOuZNsBKUmtmRFp zuYZ9jMTmWzulfM3jS5qjPK57oNgeUcWqNdUN31psfeIvS/2j129zkAz8PE2px6xuka1 tpOnrwXaLf83xxbTTaj8m7LYrdKp56gBfR3pBMsdIVNyDCmuDgkdugmonEKBRnIqeqKA UdrQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=IUezXz9I; arc=pass (i=1 spf=pass spfdomain=os.amperecomputing.com dkim=pass dkdomain=os.amperecomputing.com dmarc=pass fromdomain=os.amperecomputing.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id wx10-20020a0568707e0a00b001dd6429e3c5si448865oab.214.2023.11.18.08.03.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 08:03:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=IUezXz9I; arc=pass (i=1 spf=pass spfdomain=os.amperecomputing.com dkim=pass dkdomain=os.amperecomputing.com dmarc=pass fromdomain=os.amperecomputing.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1D5E480486A6; Sat, 18 Nov 2023 08:02:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229478AbjKRQCl (ORCPT + 99 others); Sat, 18 Nov 2023 11:02:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbjKRQCj (ORCPT ); Sat, 18 Nov 2023 11:02:39 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2109.outbound.protection.outlook.com [40.107.92.109]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE77D182; Sat, 18 Nov 2023 08:02:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QVYE/WkwsmMmJVugsf6lCgeB62pMNDivyRnrFTl8+aT34O41rFiCTPOMVQc+elHTOt23OqIg87GPRV7QTI0ket5S4+XbuN2bctlaM2jeWULyfxgXK0ridkzNbrU2x48Xe2kCaLAiI2ixpD1XnQOcVvBa3nrYGOA6tpXaBdnRz16VV3Uo4Wl0vChaIMdecZ0C/kZ6vzZd8hqi8RLhCPWUtC90rRabH7CYZhUCYftpT5mM7SHX+t67hVPyncKJLhKxJPUiFWdsMZWo0zyIFRTuEixIO8Vw9tgirRS58RgK2km5U6dMxSqGdd1mIKUUcsSfGiiktKHzUC8l+212LFBntQ== 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=wv2MhPhz8vX5EVXTcetWaN6ncrvpW3Me+2LRl1lemRQ=; b=h1PBNTMcB9nn5Kor+BZk4/4VL1BkF48jpi/oJvVoCXoAi6xKNnasaMuKQPfifii62+o8zMhrCmC/U/43KAr6xK0DyRzxSkWCrjRAImNVCM5AZDREsUoY7kt6vrI5NtveUiGlyhQIWu8g5ganMifVNdq8TbagpJT6YAH1v40dfVMh+2FZDgBunNiFphD2a7Qrp12ETEsI2uE9BSJ3g6Nm2NhbMIgsVuoizbaayb4+Sm1BKqdismj2GkgKVT3hlMmiJgthko5hXcpmEJGX3MYpk7dfhRjRZM4djAv3S1wQBNlzMuihoozuoYwAXJsK7jvL5YXHveo/Fr+EsppgGJ+eIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wv2MhPhz8vX5EVXTcetWaN6ncrvpW3Me+2LRl1lemRQ=; b=IUezXz9IBNiQFOeyUY2OP0YRRmdUWbm/Ml6gB+MFFQduRZAiePtreHAewtgmkMqXxYXtbz91Fnv7S/PuWcks5RmrJIuyffc+q7aLUy4BNSm7ItTY6nk8Qb8ggbt41pyP91U3ENfQsdytJgQFcM9dkjmkvz0fFFjMbZAZ+4h1Eh0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from PH0PR01MB7975.prod.exchangelabs.com (2603:10b6:510:26d::15) by IA0PR01MB8306.prod.exchangelabs.com (2603:10b6:208:480::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.25; Sat, 18 Nov 2023 16:02:32 +0000 Received: from PH0PR01MB7975.prod.exchangelabs.com ([fe80::3f45:6905:e017:3b77]) by PH0PR01MB7975.prod.exchangelabs.com ([fe80::3f45:6905:e017:3b77%7]) with mapi id 15.20.6977.028; Sat, 18 Nov 2023 16:02:32 +0000 From: Huang Shijie To: catalin.marinas@arm.com Cc: will@kernel.org, gregkh@linuxfoundation.org, rafael@kernel.org, arnd@arndb.de, mark.rutland@arm.com, broonie@kernel.org, keescook@chromium.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, patches@amperecomputing.com, Huang Shijie Subject: [PATCH v3] arm64: irq: set the correct node for VMAP stack Date: Sun, 19 Nov 2023 00:02:05 +0800 Message-Id: <20231118160205.3923-1-shijie@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: CH5P222CA0013.NAMP222.PROD.OUTLOOK.COM (2603:10b6:610:1ee::14) To PH0PR01MB7975.prod.exchangelabs.com (2603:10b6:510:26d::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR01MB7975:EE_|IA0PR01MB8306:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d36c0ee-4d1a-44ad-704d-08dbe84fc578 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nC8TVmGGqpY7I48bdngWs164A5sdGUTuITlZWfudmdiobWnuxrTMKGZiGDWxfxv1+HO5rX1b0qiVZkf9Qw7kq58ZElIxDbmsHxehdJ1ORnui+KWJwQvyPt6Y1xZ4bbwDiNTPQcNakHeQspp3+K4QIVeBhrqedqgTKhJCLTsoHV0HoAnq+hQ/i8BayE5TYUa2zaD53rnQxAe8F4JOYKLWvwvNn7uEpOpEQ5l8xNl66J0HmRcHDoJOI8g+3KZKA+FqjAqbILaO3UMC6nSn/h+UfqkZKSO/tWbv2IOGAU6F+MWX7W0SXL922szIOgCZw1QbGHNl6kYgGxcg37+Guua7ZbZpe5NxA89hZ25H7F6+g2UC9daQfJJ5rfoONQV9YVKwNINk/HPBhZDuwpDbPfCbz4ilpEzlmtVaXqhyY1GGWtMjwOU2CABuONYROilpyABnJJSpz5KDezcVMIff4rTiOMEje/LUGoXOTSCdSdqMfgTJtZYHxJxnNNPGi8uZLjU6v0Lybj4US438k3H/VIYIjJCain9RNb7CDyCrJcxmGy7/MEgl9+vOpRZpz50wfJPzl7SPWSYhsx6Vh8vwV6faw3F5E4Z5RLRCEkb/rCGbBRlnkLF2PudUnr5F9Fsuvava 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)(39850400004)(396003)(346002)(376002)(366004)(136003)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(66556008)(66476007)(66946007)(6916009)(316002)(52116002)(6512007)(6666004)(6506007)(2616005)(26005)(1076003)(107886003)(478600001)(6486002)(38350700005)(38100700002)(83380400001)(86362001)(2906002)(5660300002)(7416002)(4326008)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Y8NJEKdv7MXmP7KocyeknDxYAavKS/wWC3OR0PZoCYY5tbm6va9dDGkwBrx6?= =?us-ascii?Q?bguIp1gzMm5gyMTb/icATkP48/zi9qrq1BZjR6X11rqi5cuQ8vM3O057aXvE?= =?us-ascii?Q?DJMTlUeeAoLoIeh3/CcGy/32zsFB/7JHVQUXuwbeU0jElXJKDfT31bWZmemO?= =?us-ascii?Q?/fxKoz5n+CG0zmFTaSBhZsmIH/XLgEAgfiGQm5u2dVaVbXiQlNnN7DPUNMW3?= =?us-ascii?Q?aJsYeAzq0rwGkHIygyCsHe5lvvasar0Wd8YWHc3C24tKG9TXLzJlr2AKnFql?= =?us-ascii?Q?/4tS1KF8QfP2HuHM7DFb00wdTY8SZ9Bzx/wwR9Q/zncjR2Yo5+jUM1EYGMKH?= =?us-ascii?Q?WK45fGQD6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4QNcZ8HH8J?= =?us-ascii?Q?AkZCaDbs0OGW5oVLv0CKZna0ElcsEEBy3StFX9EV8FLC/8L9/yMk4CToVlOP?= =?us-ascii?Q?dhDACZ8sOGf9hiK1Kf7yswIGZy1x309RkkJYPZxNU0DBem6HKr4BNRO2x8uX?= =?us-ascii?Q?x9F9NFS2Va55dtb2VJfF7xwLwOAiqUVfzXejEOkcAY1U3I+dYiLNZRd347MA?= =?us-ascii?Q?SWTlyn57sfKSLK7JeDTDbcpW9nyJ7/XsH+QKlXxGkZMijuwePi8Z+Qy07czK?= =?us-ascii?Q?JlBy/2T8A/WVwZlO3L+8eX6WyjEhaRITiZKN+skKW0BQPQwWIUZGmLnWJJ6j?= =?us-ascii?Q?Fyl/XnSunz2gfGdjU5MJ2mAQM25aGhxYjsu8jkLmVb7ZaFVNFozWsN1ItKZQ?= =?us-ascii?Q?yQ=3D=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d36c0ee-4d1a-44ad-704d-08dbe84fc578 X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7975.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2023 16:02:31.9315 (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: wlRs/yK7rDRQIWa8tsCRGI5iApSbE90Hdo9ajnOm8+l8i/i3Bo3iIMM1MK6sCjnn3SePn5PDMdOX80TeFHZIy8FGg9vHvyof77bKx8I5XNXucHFnaTV23XnJyWQSYQtm X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR01MB8306 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Sat, 18 Nov 2023 08:02:48 -0800 (PST) In current code, init_irq_stacks() will call cpu_to_node(). The cpu_to_node() depends on percpu "numa_node" which is initialized in: arch_call_rest_init() --> rest_init() -- kernel_init() --> kernel_init_freeable() --> smp_prepare_cpus() But init_irq_stacks() is called in init_IRQ() which is before arch_call_rest_init(). So in init_irq_stacks(), the cpu_to_node() does not work, it always return 0. In NUMA, it makes the node 1 cpu accesses the IRQ stack which is in the node 0. This patch fixes it by exporting the early_cpu_to_node(), and use it in the init_irq_stacks(). Signed-off-by: Huang Shijie --- v2 --> v3: move the "numa.h" to the right position. --- arch/arm64/kernel/irq.c | 3 ++- drivers/base/arch_numa.c | 2 +- include/asm-generic/numa.h | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c index 6ad5c6ef5329..d9ee14723478 100644 --- a/arch/arm64/kernel/irq.c +++ b/arch/arm64/kernel/irq.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -57,7 +58,7 @@ static void init_irq_stacks(void) unsigned long *p; for_each_possible_cpu(cpu) { - p = arch_alloc_vmap_stack(IRQ_STACK_SIZE, cpu_to_node(cpu)); + p = arch_alloc_vmap_stack(IRQ_STACK_SIZE, early_cpu_to_node(cpu)); per_cpu(irq_stack_ptr, cpu) = p; } } diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c index eaa31e567d1e..90519d981471 100644 --- a/drivers/base/arch_numa.c +++ b/drivers/base/arch_numa.c @@ -144,7 +144,7 @@ void __init early_map_cpu_to_node(unsigned int cpu, int nid) unsigned long __per_cpu_offset[NR_CPUS] __read_mostly; EXPORT_SYMBOL(__per_cpu_offset); -static int __init early_cpu_to_node(int cpu) +int early_cpu_to_node(int cpu) { return cpu_to_node_map[cpu]; } diff --git a/include/asm-generic/numa.h b/include/asm-generic/numa.h index 1a3ad6d29833..16073111bffc 100644 --- a/include/asm-generic/numa.h +++ b/include/asm-generic/numa.h @@ -35,6 +35,7 @@ int __init numa_add_memblk(int nodeid, u64 start, u64 end); void __init numa_set_distance(int from, int to, int distance); void __init numa_free_distance(void); void __init early_map_cpu_to_node(unsigned int cpu, int nid); +int early_cpu_to_node(int cpu); void numa_store_cpu_info(unsigned int cpu); void numa_add_cpu(unsigned int cpu); void numa_remove_cpu(unsigned int cpu); @@ -46,6 +47,7 @@ static inline void numa_add_cpu(unsigned int cpu) { } static inline void numa_remove_cpu(unsigned int cpu) { } static inline void arch_numa_init(void) { } static inline void early_map_cpu_to_node(unsigned int cpu, int nid) { } +static inline int early_cpu_to_node(int cpu) { return 0; } #endif /* CONFIG_NUMA */ -- 2.40.1