Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp482704rdb; Fri, 26 Jan 2024 01:17:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLw1tcpr63ymA4B+LknMfWH4mTHMgIcZuOZx41YLAyKnyvtTzrl7lb0TFQgG0AIeQX5v2H X-Received: by 2002:a05:6a21:150d:b0:19b:4eec:cbd9 with SMTP id nq13-20020a056a21150d00b0019b4eeccbd9mr934829pzb.42.1706260635039; Fri, 26 Jan 2024 01:17:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706260635; cv=pass; d=google.com; s=arc-20160816; b=n/ChyOZ1CkZHRbAXMFRTF9mo5i2GOHN1zq5j9k7EZrPfoBRci31T8yC/FtzO5jrTmU xVzosV9oBwwdS9RsSVs6GvRiSnzWB+QlE40roZ9jSno9oWMMmt0mqNYbKSDjImyvhGpt lrpmN2LsyAfj8GqgvZKwvejPisTAsiIcySC+6qdFRdOT0MIFUzyVgs2WwOwdwydXxbOS YjrA+pAAF62oSsCTXO88T99xuRpGFw+YYyzF7CuAGZ7LXN0R3Lg+OksUvMXaEJs2IVbB /xNy97Edel6IH/TgaIJ+rJX6xpn6dIflEInnEH5ERdBDHAbdiBTRNMpkLl2t2TSI+inH dPEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=3K/IZY7fJV81pMeYm+B/bmG6UCt5SZK8zZ+0JgtuC6c=; fh=y7VKX694VLH2eb03/y0ljujQLJGtNdYVa6lu5bfy0Mc=; b=amFLcpew7ASsE7ajPFXw6PoedoOsMLtFuPGpDWYCrmcIF6q60g4hY/omWPqsasrYnO l8TI2Yh48U+TWUxoRVjwhfOoo5DGwGfCDwXLX4prlDRqC8LSXSDnBcwHazBcVwgr3pXB o94IYZ7KB/QPmeyER7+ZxcUB6+Xo0KxuTEmGJdpcfS2WnrOGawmCQikL6T1ADYv0xWfh 9nHBEPLh4aWbtSb7Uy8uC9oS6A+FNVOtS8ikv6+rOsgm5qXrbAu+eEKEHenC++KacDYa 5aPCYjtJLMeE+PgVjOIk7xnqKUNRO44CvZCxgj7SMBcI16PPO4HlYTZqcWlgwgz1cN1D rmTg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-39756-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39756-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 ey1-20020a056a0038c100b006dd8088dd63si800573pfb.395.2024.01.26.01.17.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 01:17:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39756-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; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-39756-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39756-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 42188283476 for ; Fri, 26 Jan 2024 09:15:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1885620309; Fri, 26 Jan 2024 08:19:05 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 95A98C2FE; Fri, 26 Jan 2024 08:19:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706257144; cv=none; b=e760NwmiLXud/MMY0nbRdFaBkSs/fe7sWrCRZVb6ooiBgxacbQwJ9+bCwo1OQGYlydWx7I/YKXCuT3A7RbepnNyFfooF6XLABODOfvrxZPaRTP5AivmHVn8yTgKoZRF+onO6d4FL0Q7GG38APBxlyb7d89JFNk0L9UgfP611Ous= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706257144; c=relaxed/simple; bh=f+Gwy14SwFK7pcA8QYgiUXjBJlBmX4ONW24NcH5+dtU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=tT/AtgKI4dqjyecpLhrQWguRgxDhcyxI+BSxGgX/7ccLLx3XjZGKDxI7/0hi3ehZBg3ToJ13XQWfKcU4C/xT0CLDR42m1K/LE8gkzZQw6h4Z/183rlw9QOKAEpczifjyk1BOLT4UiwBDZQhQ3i5uLMituCBVaI1mhfdrL7jaiJE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46EB6C433F1; Fri, 26 Jan 2024 08:19:02 +0000 (UTC) From: Huacai Chen To: Huacai Chen Cc: loongarch@lists.linux.dev, Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Huacai Chen Subject: [PATCH] LoongArch/smp: Call rcutree_report_cpu_starting() at tlb_init() Date: Fri, 26 Jan 2024 16:18:43 +0800 Message-Id: <20240126081843.2749-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.39.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Machines which have more than 8 nodes fail to boot SMP after commit a2ccf46333d7b2cf96 ("LoongArch/smp: Call rcutree_report_cpu_starting() earlier"). Because such machines use tlb-based per-cpu base address rather than dmw-based per-cpu base address, resulting per-cpu variables can only be accessed after tlb_init(). But rcutree_report_cpu_starting() is now called before tlb_init() and accesses per-cpu variables indeed. Since the original patch want to avoid the lockdep warning caused by page allocation in tlb_init(), we can move rcutree_report_cpu_starting() to tlb_init() where after tlb exception configuration but before page allocation. Fixes: a2ccf46333d7b2cf96 ("LoongArch/smp: Call rcutree_report_cpu_starting() earlier") Signed-off-by: Huacai Chen --- arch/loongarch/kernel/smp.c | 1 - arch/loongarch/mm/tlb.c | 16 ++++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c index a16e3dbe9f09..2b49d30eb7c0 100644 --- a/arch/loongarch/kernel/smp.c +++ b/arch/loongarch/kernel/smp.c @@ -509,7 +509,6 @@ asmlinkage void start_secondary(void) sync_counter(); cpu = raw_smp_processor_id(); set_my_cpu_offset(per_cpu_offset(cpu)); - rcutree_report_cpu_starting(cpu); cpu_probe(); constant_clockevent_init(); diff --git a/arch/loongarch/mm/tlb.c b/arch/loongarch/mm/tlb.c index 2c0a411f23aa..0b95d32b30c9 100644 --- a/arch/loongarch/mm/tlb.c +++ b/arch/loongarch/mm/tlb.c @@ -284,12 +284,16 @@ static void setup_tlb_handler(int cpu) set_handler(EXCCODE_TLBNR * VECSIZE, handle_tlb_protect, VECSIZE); set_handler(EXCCODE_TLBNX * VECSIZE, handle_tlb_protect, VECSIZE); set_handler(EXCCODE_TLBPE * VECSIZE, handle_tlb_protect, VECSIZE); - } + } else { + int vec_sz __maybe_unused; + void *addr __maybe_unused; + struct page *page __maybe_unused; + + /* Avoid lockdep warning */ + rcutree_report_cpu_starting(cpu); + #ifdef CONFIG_NUMA - else { - void *addr; - struct page *page; - const int vec_sz = sizeof(exception_handlers); + vec_sz = sizeof(exception_handlers); if (pcpu_handlers[cpu]) return; @@ -305,8 +309,8 @@ static void setup_tlb_handler(int cpu) csr_write64(pcpu_handlers[cpu], LOONGARCH_CSR_EENTRY); csr_write64(pcpu_handlers[cpu], LOONGARCH_CSR_MERRENTRY); csr_write64(pcpu_handlers[cpu] + 80*VECSIZE, LOONGARCH_CSR_TLBRENTRY); - } #endif + } } void tlb_init(int cpu) -- 2.39.3