From patchwork Wed Jan 31 07:21:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huacai Chen X-Patchwork-Id: 194560 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1723808dyb; Tue, 30 Jan 2024 23:27:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcCec9gGJELnQbPNDEoltu3IqCFzTf2sqWY+OZtxgQ+uHvWQpT+EKXpca1KlOuBd1R2YEt X-Received: by 2002:a17:906:4807:b0:a2e:556:f114 with SMTP id w7-20020a170906480700b00a2e0556f114mr455692ejq.25.1706686071298; Tue, 30 Jan 2024 23:27:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706686071; cv=pass; d=google.com; s=arc-20160816; b=hn5VkGQKL0sfG/6rIb8sZCuk/ml9aMDQ0nB0nWOGcjj0CQPfqURkv5d4/qlKnaE/Yb ljaDZm9LuGG3nsDFwSOAT0XeGZFPDjE1TYd1PgwzBpAxvIVLXQd7x2G/T9yhK0oAiZM/ VoBGw9T8fE4PGuG5SjoxzLhPRJaaU8SnjeSpPfrjWDsgIdn1fp89pg3eqv7Gm+tZioGX A+S8t7+ohNsiDH88TMOUIcujnHshf6LGy/EAkbmBkYWZS+uggZeYsPmx9FXMmr/X/6Kt sf6ddEtVO+0QBsNmiru+6JeZiRxYk4uVKZEu2pUUaHGl+K0UX+XOBn0/5aIzw8h7n7Zs +J6w== 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=3E85M8SdaZuSACb5kq3Wz9sWw5u0eQAIYLyKltUUKeU=; fh=cgG7R3tOEoikpww2I6EU2727IZw2xW2VS4jAMp63U60=; b=JvPjcLSFbivTdAQ7HIpeWf9tVHUNQHy0lDzWP2alX2+VjGGP9ODcaOSPiV3YqWXMie SQEdGUfE6f8nC9dbvhyrjdesfzxu6ihHsYg/1OuIKcjEpipfY/40Cf6f4o2GNvWo0+GU Gu2QqGmt3fyv2C07Pdatb2OuxaCk2IlklgBOAP1N5Tnrn5x8o2T9t/d9BvLd7D8c1z5S ARolM+wBqiJD2Zi9hJkdXxaulmxw0EaNyc3YWBq9QGReX31srydNam/VhzstErW6rtgo W9smYvWlyqPC3fy8bPqN9jLgJ2J+v4m6+N6/w8b8q6zkce+BulYDPHQACJYE+A0eI5HU iTrQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-45919-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45919-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXn36iG4smIlnH5QqIDbGDyPFwdJO0wLorHxXkmkTAEveCbwWAx77naJt5GKY9OgIiyZT9Xf6ALRoyRvoxBosr62mE+jw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dt15-20020a170906b78f00b00a3677913c3fsi304661ejb.346.2024.01.30.23.27.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 23:27:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45919-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-45919-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45919-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id E39D21F23BC3 for ; Wed, 31 Jan 2024 07:27:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D34D95645E; Wed, 31 Jan 2024 07:22:06 +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 0A03656479; Wed, 31 Jan 2024 07:22: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=1706685725; cv=none; b=AItS0LPlBLO3jOcMNXhV+3Wa1qPxBiZTBoiMM6cimyHvEQ8e+v0BUr8xBaey1vgNFXHDF0+pK1PWujGmQLbWHYyoPQasU5bTVV9wM4qw1T+o5vYoaCj4qBwhdliDXFLkje95LSH840Krd77hJxs2WkrBjOPhSmHgYijgSDwAE4o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706685725; c=relaxed/simple; bh=VSPOIQIi1SFSb7BcOqd2hNNK1gD3mDXV74OKv3NfOM4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Y4PH8T7zZZW/eVZpmaN/fu2cQE4ZO2cUvotkHqCCzDe3RVY7zOrH3/qk99Go9I1RQnmuIZaoEMBG5m0hTCqYlYuXuCwd5bnzUi1Cj7c4lnvKXpZhSpMxY6EI0dJmnhmEpp+SMbs2NY7iYnTDJ4AUGr7KZTFMucysv0JlvaiQCqE= 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 DC2FEC433F1; Wed, 31 Jan 2024 07:22:01 +0000 (UTC) From: Huacai Chen To: gregkh@linuxfoundation.org, Huacai Chen Cc: loongarch@lists.linux.dev, stable@vger.kernel.org, Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Huacai Chen Subject: [PATCH 6.1.y and 6.6.y] LoongArch/smp: Call rcutree_report_cpu_starting() at tlb_init() Date: Wed, 31 Jan 2024 15:21:51 +0800 Message-Id: <20240131072151.1023985-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789590053731415414 X-GMAIL-MSGID: 1789590053731415414 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. 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 3f3cdc7ffe7a..4b4ba3f9335d 100644 --- a/arch/loongarch/kernel/smp.c +++ b/arch/loongarch/kernel/smp.c @@ -506,7 +506,6 @@ asmlinkage void start_secondary(void) sync_counter(); cpu = raw_smp_processor_id(); set_my_cpu_offset(per_cpu_offset(cpu)); - rcu_cpu_starting(cpu); cpu_probe(); constant_clockevent_init(); diff --git a/arch/loongarch/mm/tlb.c b/arch/loongarch/mm/tlb.c index 2c51d755fbbc..e71150dd7f4b 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 */ + rcu_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)