From patchwork Sat Nov 18 16:02:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Shijie X-Patchwork-Id: 13460171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E46A2C5ACB3 for ; Sat, 18 Nov 2023 16:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fL28RfpB/0zqAp+vspYVVEvY3OezzeO0BASFgbnBBDY=; b=Ykd/uLZqKC7uZf HzBeyR4PO2BajHt5Yw/YW9SQk4EceAteVTcvm6uOLXtXSWNqaF/dTkuu24NKpotwcY3gpPAhRBpM+ 0A3G2yxMuQnyxrwPkTcHv1hiASB48j1n6vF7B7RURjqegETJqxhPbZY28wYYXhnUdatO5Mz8pbm5Q O/UqfCiaJyVKQqI1Yq0PQurvzzZvcK94Y76pP/BJ7HJlUudIAvjClWG6OeJdgAgsmvgYEPD/QWmsK f14yjfeqXFEj665vYOzOB5vrA5ggvLIg4eOwHR3pTEM/T/LS/H852qoOqy9y2nRlaNA6T35QAKaUt YszCaEubvVxB/lMNE1uQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r4NmM-008n56-2y; Sat, 18 Nov 2023 16:02:42 +0000 Received: from mail-bn7nam10on20720.outbound.protection.outlook.com ([2a01:111:f400:7e8a::720] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r4NmK-008n3h-1W for linux-arm-kernel@lists.infradead.org; Sat, 18 Nov 2023 16:02:41 +0000 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: 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: Y8NJEKdv7MXmP7KocyeknDxYAavKS/wWC3OR0PZoCYY5tbm6va9dDGkwBrx6bguIp1gzMm5gyMTb/icATkP48/zi9qrq1BZjR6X11rqi5cuQ8vM3O057aXvEDJMTlUeeAoLoIeh3/CcGy/32zsFB/7JHVQUXuwbeU0jElXJKDfT31bWZmemO/fxKoz5n+CG0zmFTaSBhZsmIH/XLgEAgfiGQm5u2dVaVbXiQlNnN7DPUNMW3aJsYeAzq0rwGkHIygyCsHe5lvvasar0Wd8YWHc3C24tKG9TXLzJlr2AKnFql/4tS1KF8QfP2HuHM7DFb00wdTY8SZ9Bzx/wwR9Q/zncjR2Yo5+jUM1EYGMKHWK45fGQD6HnvMEgztnLItcwIFxgJ11tnnifUTHnYU+Z/bssnZeBi67/Lv2oYGbCWD2L5KbaTnOCYUTvwqZ6FYo5SmByLuneRsyioULLwqHjAfg86jGWsOlkhu2HSuHtqH9AhJvT0v122H98qVx8i4Td0qzwjVaGKXrAOscvw8t8oQ4NIFT0OFscxhJ2NrMWIr4npo9KxrMoR6nK/bDCi9BRBM4Gd62Qb8FV/KG9q7WPaIRgq0/xdrMs6svS7xcXQ5ikxxVXeCUEP6kLjGbKJAB8jUKbqROL/6+EEHQ0UzZ9ZCA0Orbwpuze2O9glDMRRm/WJy3cdBu4O9CC00+osHW0lcpD+fOdXajZMV6uHQN+L+6zCbeq4O39QXjEDzPqpoEfDB2IEX5WvZkzc5ItspWHdmuNdfQYoS+Kt1SjWgBF6TqCxxJ2Jos6Rzr3W+jIw94vn6yWrUaqRPeOK9zPKmunshm70FYmWejUsTEhH6JviA7xaVS1WBCyqdjsQ+FzRyqIq3JK6LHcEALOY3sloIIu5d1zdIL02y8xvU/oDE5O82PX/yc3B7hjdBtPQBlI79r5OZ4sH2fMbNTOBDFVyrh9BDGE5xualowQP+i6UcGJIuLD5uDivSeFc/S77fsPfgtLhJkn8onxd3S7E+Nc9DN4sYFYDBjivFeT92TtMvXpWNLFIblxvUGdh3Eq8+2JEH10HEkLXTN8olDoksphuxRShQRy89D/5FtTataEFdVHlX3h1P1uBHMG2pFNI6b+8bz/4DaGhUjBuaGBYQTgkHHfOzY7znYIQ2kGRcGNxEK0md+tVPuKVrzn+Y82gI6vLZDeZczbPwDchh/sgnIK/mZUk/RbeVIMKcsdRuXfWPSosz/HTGmMSSYHz9J4QNcZ8HH8JAkZCaDbs0OGW5oVLv0CKZna0ElcsEEBy3StFX9EV8FLC/8L9/yMk4CToVlOPdhDACZ8sOGf9hiK1Kf7yswIGZy1x309RkkJYPZxNU0DBem6HKr4BNRO2x8uXx9F9NFS2Va55dtb2VJfF7xwLwOAiqUVfzXejEOkcAY1U3I+dYiLNZRd347MASWTlyn57sfKSLK7JeDTDbcpW9nyJ7/XsH+QKlXxGkZMijuwePi8Z+Qy07czKJlBy/2T8A/WVwZlO3L+8eX6WyjEhaRITiZKN+skKW0BQPQwWIUZGmLnWJJ6jFyl/XnSunz2gfGdjU5MJ2mAQM25aGhxYjsu8jkLmVb7ZaFVNFozWsN1ItKZQyQ== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231118_080240_516377_CCBCC153 X-CRM114-Status: GOOD ( 16.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Catalin Marinas --- 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 */