Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp224626rdb; Mon, 22 Jan 2024 18:46:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IExyESoOmXLoTSHF/VCQ2ddlUJQzmdqf2xx5O3qLWivjXlUsHUUyxdtocC5D+yqiWfwQmlc X-Received: by 2002:a05:6214:19ea:b0:683:a93c:7888 with SMTP id q10-20020a05621419ea00b00683a93c7888mr278533qvc.92.1705977979956; Mon, 22 Jan 2024 18:46:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705977979; cv=pass; d=google.com; s=arc-20160816; b=OTqIEjmxOG+mK4EqdVZ5LVfy7X+rtGJ/yh6wcTTEMVAeSoLD8wH1VsKqHMy4c6TiGU RRDcFsIQIbR/QsauiOnsFrBABH5T8TpnLIncE+temDzlN1BPXoiuJdfhJdJDA5mul/Ir D+QOSGxYRabJIRIVgUoOFXevGMdeA6Vmq9EZovGKysV4lYvCrSreHK0KyNrYi0wgO/9+ shW3mooGhwVyPlHhU+2sFh9bgOs0U/zML8kRmv2Bm+NsQC2uEiGexFVP4nD1OnB/tJyo Px8qvMpVOl3RuuRhiiC/VdohxsW5PSuA8feW5Njdi9MdIIN755XFXeQc61jiViZpW+5h T5kg== 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=tN77219oTfySqORIhqXKs2Ov6rmZC/yms3OuHT4dgnc=; fh=XZ9/U7K4a4bjbp4WomVuJL1gikPVxlDd2VmG8zX4/BU=; b=aQlMs3ehN9neNX6Yy//GmyVqVqjTQKreLvJOOiioIH5iKMoxcYFFlQZFbyh6xqVpvl e2t5EUNC8fhtIysWF6VZSqiYAI5xurPrlLbGktyaa6wWibIjdMNJHL5zlTdA+//AsUIT uAm0RvlvLtA40WTuhsV7vRMt9vTbO6debUvh36ALroQlVPYvzgEZkGZ4VXNNxlIpXhoK asvXKMmG84qFeQ49kINoraAovESM5iXdBh50L84uz2wdSys5mikQZEBW9saPE2qT2al6 VJxf/Q7kcei19xKiViHzjZfrd39aLFgSj33dwO0PkF7yTHSQczT8Z1Lh7wTIPQN2lT1b 10Ow== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-34647-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34647-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z14-20020a0cf00e000000b00683696e7e41si6928368qvk.299.2024.01.22.18.46.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 18:46:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34647-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-34647-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34647-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B55D11C26F19 for ; Tue, 23 Jan 2024 02:46:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A0D013205; Tue, 23 Jan 2024 02:42:18 +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 170ED2570; Tue, 23 Jan 2024 02:42:17 +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=1705977738; cv=none; b=nfCJN3C/yefW8eL7eP9Y7uOSbDQ88dDOydpSGwzH/VXRCpeynIBgnDVjRdCmmePoOEt1cNGQN9Tw+WnaHyA0ELegGqAJOfCWmTvLbhgVQFQFTxrt8rjB0SHrgC3A8MqRB6iHYtyZl02oz9TxXHldtcQ3g0p0chVtXsCMNNlBNHM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705977738; c=relaxed/simple; bh=2KAfxXRILTyRg7HhJoRIjIBq03f0zaVqF8HojyrwGec=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=JiXXS8V2XqaYSuPE+tnpvBhUDg5plg76XYU9+e/vwzsjL0YdFqeG0LCIlfKlWHTwmlOBLfsb4Wh18S7KyWOmucbyPMjfugTVdKdSufFFUPN50v5cxfp83fdHL+D+SYxLZOvwLluppOPgEiC4eQ2umFKubpDH0uCDtgSMQbRaYM4= 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 D314CC433C7; Tue, 23 Jan 2024 02:42:14 +0000 (UTC) From: Huacai Chen To: Arnd Bergmann , Huacai Chen Cc: loongarch@lists.linux.dev, linux-arch@vger.kernel.org, stable@vger.kernel.org, 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() earlier Date: Tue, 23 Jan 2024 10:41:51 +0800 Message-Id: <20240123024151.1365379-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 rcutree_report_cpu_starting() must be called before cpu_probe() to avoid the following lockdep splat that triggered by calling __alloc_pages() when CONFIG_PROVE_RCU_LIST=y: ============================= WARNING: suspicious RCU usage 6.6.0+ #980 Not tainted ----------------------------- kernel/locking/lockdep.c:3761 RCU-list traversed in non-reader section!! other info that might help us debug this: RCU used illegally from offline CPU! rcu_scheduler_active = 1, debug_locks = 1 1 lock held by swapper/1/0: #0: 900000000c82ef98 (&pcp->lock){+.+.}-{2:2}, at: get_page_from_freelist+0x894/0x1790 CPU: 1 PID: 0 Comm: swapper/1 Not tainted 6.6.0+ #980 Stack : 0000000000000001 9000000004f79508 9000000004893670 9000000100310000 90000001003137d0 0000000000000000 90000001003137d8 9000000004f79508 0000000000000000 0000000000000001 0000000000000000 90000000048a3384 203a656d616e2065 ca43677b3687e616 90000001002c3480 0000000000000008 000000000000009d 0000000000000000 0000000000000001 80000000ffffe0b8 000000000000000d 0000000000000033 0000000007ec0000 13bbf50562dad831 9000000005140748 0000000000000000 9000000004f79508 0000000000000004 0000000000000000 9000000005140748 90000001002bad40 0000000000000000 90000001002ba400 0000000000000000 9000000003573ec8 0000000000000000 00000000000000b0 0000000000000004 0000000000000000 0000000000070000 ... Call Trace: [<9000000003573ec8>] show_stack+0x38/0x150 [<9000000004893670>] dump_stack_lvl+0x74/0xa8 [<900000000360d2bc>] lockdep_rcu_suspicious+0x14c/0x190 [<900000000361235c>] __lock_acquire+0xd0c/0x2740 [<90000000036146f4>] lock_acquire+0x104/0x2c0 [<90000000048a955c>] _raw_spin_lock_irqsave+0x5c/0x90 [<900000000381cd5c>] rmqueue_bulk+0x6c/0x950 [<900000000381fc0c>] get_page_from_freelist+0xd4c/0x1790 [<9000000003821c6c>] __alloc_pages+0x1bc/0x3e0 [<9000000003583b40>] tlb_init+0x150/0x2a0 [<90000000035742a0>] per_cpu_trap_init+0xf0/0x110 [<90000000035712fc>] cpu_probe+0x3dc/0x7a0 [<900000000357ed20>] start_secondary+0x40/0xb0 [<9000000004897138>] smpboot_entry+0x54/0x58 raw_smp_processor_id() is required in order to avoid calling into lockdep before RCU has declared the CPU to be watched for readers. See also commit 29368e093921 ("x86/smpboot: Move rcu_cpu_starting() earlier"), commit de5d9dae150c ("s390/smp: move rcu_cpu_starting() earlier") and commit 99f070b62322 ("powerpc/smp: Call rcu_cpu_starting() earlier"). Signed-off-by: Huacai Chen --- arch/loongarch/kernel/smp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c index d19c2ebdf47b..1b5f266813a2 100644 --- a/arch/loongarch/kernel/smp.c +++ b/arch/loongarch/kernel/smp.c @@ -504,8 +504,9 @@ asmlinkage void start_secondary(void) unsigned int cpu; sync_counter(); - cpu = smp_processor_id(); + cpu = raw_smp_processor_id(); set_my_cpu_offset(per_cpu_offset(cpu)); + rcu_cpu_starting(cpu); cpu_probe(); constant_clockevent_init(); -- 2.39.3