From patchwork Tue Nov 14 09:16:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Shijie X-Patchwork-Id: 13455009 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 6C81DC4332F for ; Tue, 14 Nov 2023 09:18:35 +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: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:In-Reply-To:References: List-Owner; bh=NQJ1sKAK3xoz7RW/H+ctbEoKW/uH/0GHms355OBpYMI=; b=DR3S8TqiTG+qMr MgxcUA6Qm90ktstXfMLEc2LYZgmDqc2FGuWzqjqc2z3G/vKR9fB8CxQpys7k4ECPdl8BmH3Nk8Q9F O7FGCq5pTbPHRmFCaVsBYmP9GMr9OQq1KeBwShpLLrCHy/hznMYK5B2FyxjGPXrrpQpbjQDlvBMPA bzxKBhl4lrUAlE1t58dslERsepydDLLDE6NMip+FrO5IzY3KR8g5B0uA0kXmROxKUmpsRbIXebKIw R9QopXJFBOdmfRkcdDws0Uo/n7wiYQIBXx1X3XnAojuppHgfeOZA2+KRNMv7YVqOKjneACcNDZtON 697rpHYkrkHiU+O38wMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r2pYb-00FUP5-3B; Tue, 14 Nov 2023 09:18:05 +0000 Received: from mail-mw2nam10on20702.outbound.protection.outlook.com ([2a01:111:f400:7e89::702] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r2pYY-00FUNm-0s for linux-arm-kernel@lists.infradead.org; Tue, 14 Nov 2023 09:18:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c8XJKTiJHC8SqtnUAwwbYPZvmzdI1PQ1t3wCjo49KCGehZahiTViysGIzcD6mXYnhRkYGYMkqEAvIaNlERIDExD7s+R6VGn+DBRCJFk9fm1IutjEWe9mA3q6z4WyDeeNLIJvm2LIQxAHbvMSdcVIHCYLQgKtoD2Db8RgVfz4bKilACoHyId4U6g0kl6y0Bu9ZGQUOioHkWe9s9D7r04sl4ydpjMotwQbR8YIJoTDvpVSZbnVwZwhhWXPzqdEzv3WVDHRiE/nNIBnq40Icnmko3yYFNCPk8+LsbZrGH0WjNgSJscXbcCvjdP0FFieX1ybqcRZLyBEW/9OEzUFW/m52Q== 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=zCTfLweAjmMubihY6xBAwiJ+HbPDBA38ZcHvNO04dMc=; b=csPT7I6l0c1UhOKvzttTS716DMNpNc4vqPVfAfmG4cIRwYglfqSR2okXPfpIX0JS1JTjLGRER56xByDUGQ7IU6+ks7Dp6hD1h2WGA5Z2BsNtF6jgwe67CeSPn//PAwAuqHJLaTnzQjrI717YKUMsWbUf2Fa6CcbtS5ctgMApgGaCI/e2u3nDEGOVE8gRlVHNjPKRtF9uQ67BdAueTWxStaznvIuaQMuPP5aTHFAWE0jWCqkNRbw606HTiOFvd/IV9Nvq0bD9pyk2uwa2q82vRDyx7g9F5Kuq8k+BIx5XJ/n7PnsCGRi1WVaosJPAjYMPzDrN8B4swkq4+A1jm1cdfQ== 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=zCTfLweAjmMubihY6xBAwiJ+HbPDBA38ZcHvNO04dMc=; b=j4I9ExqK8onfDsmEVZwfw4DV+FIWEBdWwuOuEk4SY5Uft0SLSNfHEwsCpD4KC0l43UiTodYkagn7/3CdxCybdyZeswoRbBobRuKxuOlLhi9X0wd5/UkO2f8CGWykttr8SKWaK8tILajwv/71ahn1MbQdjirlcvgJtPTRAd2A3s8= 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 BL3PR01MB7196.prod.exchangelabs.com (2603:10b6:208:347::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.31; Tue, 14 Nov 2023 09:17:50 +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; Tue, 14 Nov 2023 09:17:49 +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] arm64: irq: set the correct node for VMAP stack Date: Tue, 14 Nov 2023 17:16:43 +0800 Message-Id: <20231114091643.59530-1-shijie@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 X-ClientProxiedBy: CH0PR03CA0264.namprd03.prod.outlook.com (2603:10b6:610:e5::29) To PH0PR01MB7975.prod.exchangelabs.com (2603:10b6:510:26d::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR01MB7975:EE_|BL3PR01MB7196:EE_ X-MS-Office365-Filtering-Correlation-Id: fb359013-e710-4a3d-205f-08dbe4f2923a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ifcpzH0LgExv3zxsy24q+LnIwsGZbxY1snmOSABxosOZuMJBbW6WVOGt34nKd8wag8UXDXLPyZf06LJW1ll75Lb9mjMzZZ/9hOW1hFdo7KJ4rtew1D3JeuHXlUL1AZwm1eWdj/IntG90u53vCnoylggLWhbCo1RJFWkGFDeAU1ExfBWPjn8OAvcThNGKEcJOqPvYXiey97p+r/W3RP5d/qbay1xeteec3rZLHtf/nOK8BriPe3VM9HVSOT1NHUrBztQLUs/CwIvV7+utYEzffidql6ybOnoxSbwIsVonu+Zn8noeSPioZWTkODldXzpG98jKM4RtwQIisdYLE2O5Wfh+hNJIq98YNl96W7MClB4X2RRb322EYfQZiHeJXRD4grwMb/57tMEZwnd2dbIP8RYBQnj0HEUoNw/m//s8FZhtPygXMqRJ4qyDodJNddugc+ZJE7s4mnHbm3MBHEhxrPIz0HOIAHalBWqt216EkL5te6dtHrNVBktrfPqMY7OzXG/WeeWdSHa6UQeAeEYxS2HMeSU394YokmOyqQBxw26mVAs8infuzNX7liRO4zehCSdEuNOrnE6djVJ2Rjr0IiLwQwAfmS46bIHtgZJxBl4/qVlor1fV0aCLctEw2qsF 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)(396003)(366004)(376002)(346002)(39850400004)(136003)(230922051799003)(451199024)(186009)(64100799003)(1800799009)(38350700005)(86362001)(83380400001)(26005)(6666004)(6486002)(478600001)(1076003)(6512007)(2616005)(107886003)(38100700002)(52116002)(6506007)(41300700001)(2906002)(6916009)(5660300002)(7416002)(66556008)(8936002)(4326008)(66476007)(8676002)(316002)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jzpe3EHoDwXf8k8btOens2RUmCiX7k5iH+w+JG0Lsh3KxqgWysuOls13vkQ26kMjCUK0olLQ0VYdixsN1kG10P/q83q5WKKpokkTYFQ+hrgIZ5mljRYMydpT8eU98M6CYXWNhSScmEALVBtdP+YnaIzOnZPjz6WDUHvgWayj4PDlB9PG+n+7psoEq+6pIsork7TTjqSuUNRNkV53EuMAYeerJmTHeAQVbewOQx/xGjVwRCgmSJR0tCr6xHUHzN8UExgOAizLKFtc8uaHgrc51LV0pXW9L4v1dbxXJOJEDUnEwnwbMRRxQUdeIxo+eON9q2SnlcK2MQZe0kMQyjbMNG5n0W6isEOsz8Vylx43ylxcYxuo+yckwl1EDZ+XpYUsq1pnD8ZSOSD0NJhYySOQvZhq19KRJ8pBM1YQ/rtN4mIf2PeO2YCPxlwQaHTcues77U0HyHNxBWSRKQCu9e7ua8aUsr1H1qqpFqq6H3CE7vhK8hVYqArhhpwB9z/xmOKa6ufix0nQhLfioawKBHsSTebosZ9FFDzsLTBIJGKV+SDX4HqNvabUpZpuK1IKXZOffaV5tS5942kL8C5LhHTufibW0eEMp1F7idYnUOAigorxBgXUvZ8DfYhZXJxrJjkroC3eKuv9Yfx0qMClDpajmLLAi4l7Lt/tRJBwY6GziQgsVzE1Ekzv45SED/Y0gt9/zKdEa49uVDPSumCMBHPK/NIK7yXVlYq4Fxgley3UpShpAY275WuyFIM4Ekps38+JNUBcIseG9CDc2DyGRkxnlHDSdy+DmNeNqVx/B9rx1NEIORIOk0v5LuaqBsrfYe7Iijc2mBRMy9S1BXYxads5ExCY8ceSGmHmd4PLTpA0wbi7hsa7IbJtq2IMrKf116Q29dGbR4b5FeTzwiEtwcJ6Sl13dGnOIzHOvMBW6VQrjj/WE9o64Hb4awBBSvDZxAD3uN8f3jShxVXttOwI3cDS8VCA7ZUVEmCxJPzvmIVEqAprnln+fj4TXa2jJTzhuagrvpXptqPWNsim+Ggq7XcY0JBxeQYD09hU1Z2qeftPM0gC6QNit5eQVma0i8TD9LrQOZzmf+UjXk8WD2avnxQBWCC44FUfHolE5RBdIf4gQqAvAwFrBjYPU23d3aymWhi0twl9/SZyFiqrgPznOdvfoPlCuaIutomer2X2tlnJe7Gi0Ehu1vErF6fmpR/pWz6ypp65znT5lKA2lRMTNVw8Ck+YaRlfyvgcyZlUJxnd8kJYwEViE09OHSJgTpem7VBHFYDTzRtQr8K1Ys0JmT0NTaJpdbtfl/EBHbBFuPF110XTm0n8KKePuG6FpXZXnS7cOWEOnZIhvbjsFalF5YAxF9wJPco39myk7MAHgPalu+UEFxn/wU4k6+vDRKChtFCW9y5eQ1M24Vt9s9I6lJXUtyUpUoxh25t2DXMSkZxKwWz1KzTuuzme1mQh/jrehU6JbAkFoqx04B3SLej4flsPN1p4a3L3nCDvt+4wT7RvH/H+E1aebHjxyImwD1ihN4kd9mtyQyYkKGsICrsJj8rfb0UYD7uDta31qGNYhgXhpq7Z3jG00h2Df8P+YmsoCnI6QbzXTWv5CjMi3zqIWrcOkg== X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb359013-e710-4a3d-205f-08dbe4f2923a X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7975.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2023 09:17:49.3210 (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: YmiaUWSXIDcmMrhKJNuPWahtSFT/vHVKhrJ9y471Y2oj0hQL88sUcLJn1dgy0KAvsNMnH08gEqciA+qI3MUnpdeYfLFbwK+QmrOmKMqQPBK3fiZmMgI+e6AobPE2upIK X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR01MB7196 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231114_011802_477448_A7DE52B5 X-CRM114-Status: GOOD ( 15.18 ) 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 --- arch/arm64/kernel/irq.c | 2 +- drivers/base/arch_numa.c | 2 +- include/asm-generic/numa.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c index 6ad5c6ef5329..e62d3cb3f74c 100644 --- a/arch/arm64/kernel/irq.c +++ b/arch/arm64/kernel/irq.c @@ -57,7 +57,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..fc8a9bd6a444 100644 --- a/include/asm-generic/numa.h +++ b/include/asm-generic/numa.h @@ -38,6 +38,7 @@ void __init early_map_cpu_to_node(unsigned int cpu, int nid); void numa_store_cpu_info(unsigned int cpu); void numa_add_cpu(unsigned int cpu); void numa_remove_cpu(unsigned int cpu); +int early_cpu_to_node(int cpu); #else /* CONFIG_NUMA */