From patchwork Wed Oct 19 22:46:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 5884 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp570484wrs; Wed, 19 Oct 2022 15:47:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7GSpCBy9pXuhPZkPXLfAIQYdDgpSzjR/z5GJSqkc+9YZKmMut+p66lrWkoVrhIXqDfDv0g X-Received: by 2002:a17:90b:4b89:b0:20a:c168:6865 with SMTP id lr9-20020a17090b4b8900b0020ac1686865mr12312845pjb.130.1666219677451; Wed, 19 Oct 2022 15:47:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666219677; cv=none; d=google.com; s=arc-20160816; b=mLUhyi6JDZtCtRUqLRDslvudUf65VVRb6fJynNO4vh+m46OBAZTRBEqqjCdyOcJVIq BAA25tNaWMeGYNHyqsvmTgQGAtxY9hVqvAiTa3eoAuO3JlnVE23GXGk+Y9HMT3wiEohN jxaXXdIKVBwI1iEBFvpDkDS+jjpfhNE3ht22lTmxp4hrdCnedofZoE94JA4pWFQr0kje N7EZxhjV25Kg0+nojRbuY4jlFvUOyPkKmSfTj1/2q472A6ASsHUq85Wp49owCJqvGlA1 eM0PWY/93uBlNZRp/Dcu5k5wrBuOJOF8kpoU2G1J4d0szv1Bgf2mcRSwuAwz2SmoMtX9 nFmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SLt14/p6S8YXw7EwYPmmgLnzbzUwKbWEJ5hkMWhd9VM=; b=KK0a8oYOiQYIaLB2r0mhhWaTNSdMwTy7fR59pcvnb0cecmshNZNUJ2glEcZYnywrXA PFJsq8JnDjNWDgMYzNGIiYHMHGhnToPgldeetGJjv5QfyZIXllRDXy3wmgN7Gsbz+LIk vVDVa5ZWdX92a58GO7dUF98eRAoCe7mQl/+vj9euw8iZvXf7Dt6W1RsJwtduR0EZJMyv d+oyb2IO73NktBI22cd3ZWkgmQJ3gMphloCMoaqrEuMXZINFIP9mWjiwrFJXqsvD009j XthFObmltqOiD0azkIfFtBaClCPwq//0/5HttGsHMfYH7QU+svsOwf/THaY3TNHWrnkj Oe8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MDQYW34t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v16-20020a631510000000b004386a1ebe70si19150388pgl.43.2022.10.19.15.47.45; Wed, 19 Oct 2022 15:47:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MDQYW34t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230192AbiJSWrN (ORCPT + 99 others); Wed, 19 Oct 2022 18:47:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230235AbiJSWrD (ORCPT ); Wed, 19 Oct 2022 18:47:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CE62188107; Wed, 19 Oct 2022 15:47:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 88595619E5; Wed, 19 Oct 2022 22:47:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E601EC433C1; Wed, 19 Oct 2022 22:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666219621; bh=Ygtgs0PHtrfe91imqGDUAOtSTrIZREFcGSd4BCKgdo0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MDQYW34tUukSZiX8K55GD3wJ5gibLdND5HFZUo8qjQ3KQ7iMdSFIbxKJopZ6jw13B Fe9D657uTPDoZEbvaEEiK1aNR2w5t4ORXEOpjyPcautM9bICAH7PVP7nr9GZy3zmQV SpbqN56G5zFTHsB/mAaZUZAbadveQ+Q9TPMlpH1AVliutFzGqxAhvMHOLNnh32uruG 0tcL1XtCEojAV5R3jWM6dGfk5Ucjbcb+gOlsf+31yVcECbcc2wlyzpgodfvNR2FDmD yHt8Ru3lc593r6juGUX71bZt4y2Wo53LyHCqSOmaeslA266I7PWMG2RNeCnxC9MhCl CfK73ddbVu4tw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id A393B5C06B4; Wed, 19 Oct 2022 15:47:00 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, Zqiang , "Paul E . McKenney" Subject: [PATCH rcu 1/8] rcu: Remove duplicate RCU exp QS report from rcu_report_dead() Date: Wed, 19 Oct 2022 15:46:52 -0700 Message-Id: <20221019224659.2499511-1-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> References: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747157964332451684?= X-GMAIL-MSGID: =?utf-8?q?1747157964332451684?= From: Zqiang The rcu_report_dead() function invokes rcu_report_exp_rdp() in order to force an immediate expedited quiescent state on the outgoing CPU, and then it invokes rcu_preempt_deferred_qs() to provide any required deferred quiescent state of either sort. Because the call to rcu_preempt_deferred_qs() provides the expedited RCU quiescent state if requested, the call to rcu_report_exp_rdp() is potentially redundant. One possible issue is a concurrent start of a new expedited RCU grace period, but this situation is already handled correctly by __sync_rcu_exp_select_node_cpus(). This function will detect that the CPU is going offline via the error return from its call to smp_call_function_single(). In that case, it will retry, and eventually stop retrying due to rcu_report_exp_rdp() clearing the ->qsmaskinitnext bit corresponding to the target CPU. As a result, __sync_rcu_exp_select_node_cpus() will report the necessary quiescent state after dealing with any remaining CPU. This change assumes that control does not enter rcu_report_dead() within an RCU read-side critical section, but then again, the surviving call to rcu_preempt_deferred_qs() has always made this assumption. This commit therefore removes the call to rcu_report_exp_rdp(), thus relying on rcu_preempt_deferred_qs() to handle both normal and expedited quiescent states. Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 6bb8e72bc8151..0ca21ac0f0648 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4276,8 +4276,6 @@ void rcu_report_dead(unsigned int cpu) // Do any dangling deferred wakeups. do_nocb_deferred_wakeup(rdp); - /* QS for any half-done expedited grace period. */ - rcu_report_exp_rdp(rdp); rcu_preempt_deferred_qs(current); /* Remove outgoing CPU from mask in the leaf rcu_node structure. */ From patchwork Wed Oct 19 22:46:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 5891 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp571870wrs; Wed, 19 Oct 2022 15:53:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5UexZLWWCGDz6w4cHw/X2cYBWmx1eyyKRjFn8pg9SQ+r9NwoErgYIOoeK633uL1/deu3hv X-Received: by 2002:a05:6402:249f:b0:453:eb1b:1f8b with SMTP id q31-20020a056402249f00b00453eb1b1f8bmr9332758eda.235.1666220004971; Wed, 19 Oct 2022 15:53:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666220004; cv=none; d=google.com; s=arc-20160816; b=XYI2YLr4DGw2bTDR5RF6OGzRP2irObTh8jps0I80BpH1oTogBSnMsmgykWNDOchf2m 0KrG8uuRyEbjGtpE5Yq80x8WVftaKCm6l1rpCZV2YUfR31XBgUpmiDR9NYJ8JOIZPXVN veHKaUJ7VSGTmL8+pz5NJ2X3KV8lniNRCyL/xPUtoUK48hPYzrenVZtAYMKuMXLeZoVC 7148Fbb45qenf2V3P2Cg+xZbE1RKO227X0yshQTHSVFErQ11KLDMDFt9o4pNC94QAj3O irIu85nohvJjcmpBJJHi21CwlqosMiMpYcW+m4e21bEU1OCDTtU8KAJ9fdk2/qeOKn5n e0qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TfBysiIA3J8WErhoZhN37NtnpqfyjE4cOsB3a7gKvmI=; b=GLSbq1yzmDts/YguX0ewnh1X4Rp9HIekj0x1cEzHnNPhcTH6P28hLdFI8JrUhROHSj e877NNAlQstLj6X/ZjlTiAhbUDi7VeAJ+MwuDvSQwlqkUwOX3rhB7kWilJ7hZnLanyj4 So7rDmvM6UwxAyeJjXEW7NTEla2RuZnugatVWv+BkQnjn+JOypvuGlr6GPxtYWyijYd6 7NjSavg5CIoLWa3nYYqaplbHY3+Xe065PQpDnZiphU6UZrpqo/L24K76Xep/jZwd21TM 45456Aoi/UoCEi0t0mIHyY7Mfdq7d6j1rg8qm0f7Od7TlFlnUcH8JIBskbZY7+N5gX3G SwcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ie/0CtZv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sz15-20020a1709078b0f00b007313312730esi11754402ejc.85.2022.10.19.15.52.59; Wed, 19 Oct 2022 15:53:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ie/0CtZv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231279AbiJSWrW (ORCPT + 99 others); Wed, 19 Oct 2022 18:47:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230285AbiJSWrE (ORCPT ); Wed, 19 Oct 2022 18:47:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 966D01849BE; Wed, 19 Oct 2022 15:47:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4CD7BB82613; Wed, 19 Oct 2022 22:47:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4999C433D6; Wed, 19 Oct 2022 22:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666219621; bh=zhI+nSG0LEQR2PAAAvwCyyYQdtfxOPlUmkdh0E4iu6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ie/0CtZv4oEdoViQqjdmdwAOkuUbEniXSDznUSiM+fM8btdjJ+wZZM2Nh2vOHGJBK kuQUWupa2Mqkf1yLJFOutIuIHllryTzfrPxQyLNBM4qdYDtaHkftNSP3NVz68HSGB0 IIUB+ijLG9OUCiSW8lCz5etbYQY3MHEHNmg0wwb/8d5S9ximif6nNJQpgMmBPNNZZP tS8EnPBF1QFqoIJD96pTmSVl2edtkzBI6abWSzoYOroWhUZhPPIYAcKUWvpNyH43vD 9iuN2l8GfB7H79el4Pi63Mw0C+d6nAORSLbaPu0MJXOakr8ZDhujDXh/SPrsKFgKBH YlnijjYTyPRSw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id A6FAF5C0879; Wed, 19 Oct 2022 15:47:00 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, Pingfan Liu , David Woodhouse , Frederic Weisbecker , Neeraj Upadhyay , Josh Triplett , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , "Jason A. Donenfeld" , "Paul E . McKenney" Subject: [PATCH rcu 2/8] rcu: Synchronize ->qsmaskinitnext in rcu_boost_kthread_setaffinity() Date: Wed, 19 Oct 2022 15:46:53 -0700 Message-Id: <20221019224659.2499511-2-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> References: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747158307922952698?= X-GMAIL-MSGID: =?utf-8?q?1747158307922952698?= From: Pingfan Liu Once either rcutree_online_cpu() or rcutree_dead_cpu() is invoked concurrently, the following rcu_boost_kthread_setaffinity() race can occur: CPU 1 CPU2 mask = rcu_rnp_online_cpus(rnp); ... mask = rcu_rnp_online_cpus(rnp); ... set_cpus_allowed_ptr(t, cm); set_cpus_allowed_ptr(t, cm); This results in CPU2's update being overwritten by that of CPU1, and thus the possibility of ->boost_kthread_task continuing to run on a to-be-offlined CPU. This commit therefore eliminates this race by relying on the pre-existing acquisition of ->boost_kthread_mutex to serialize the full process of changing the affinity of ->boost_kthread_task. Signed-off-by: Pingfan Liu Cc: David Woodhouse Cc: Frederic Weisbecker Cc: Neeraj Upadhyay Cc: Josh Triplett Cc: Steven Rostedt Cc: Mathieu Desnoyers Cc: Lai Jiangshan Cc: Joel Fernandes Cc: "Jason A. Donenfeld" Signed-off-by: Paul E. McKenney --- kernel/rcu/tree_plugin.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index e3142ee35fc6a..7b0fe741a0886 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -1221,11 +1221,13 @@ static void rcu_spawn_one_boost_kthread(struct rcu_node *rnp) * We don't include outgoingcpu in the affinity set, use -1 if there is * no outgoing CPU. If there are no CPUs left in the affinity set, * this function allows the kthread to execute on any CPU. + * + * Any future concurrent calls are serialized via ->boost_kthread_mutex. */ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu) { struct task_struct *t = rnp->boost_kthread_task; - unsigned long mask = rcu_rnp_online_cpus(rnp); + unsigned long mask; cpumask_var_t cm; int cpu; @@ -1234,6 +1236,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu) if (!zalloc_cpumask_var(&cm, GFP_KERNEL)) return; mutex_lock(&rnp->boost_kthread_mutex); + mask = rcu_rnp_online_cpus(rnp); for_each_leaf_node_possible_cpu(rnp, cpu) if ((mask & leaf_node_cpu_bit(rnp, cpu)) && cpu != outgoingcpu) From patchwork Wed Oct 19 22:46:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 5886 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp570614wrs; Wed, 19 Oct 2022 15:48:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4+B7toHE2am+dtzMCefq13nA28gdd7nMj3OmY2bG49mssP5NWTFH/t1WyhtCwGKe6KGbun X-Received: by 2002:a05:6a00:1ace:b0:565:f52a:d998 with SMTP id f14-20020a056a001ace00b00565f52ad998mr10840844pfv.25.1666219705481; Wed, 19 Oct 2022 15:48:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666219705; cv=none; d=google.com; s=arc-20160816; b=rTrnxJsLKHBo7Rx42DlMH90hOsYPfSi41CcP4PdWSRqYEQoM2cgbS30s67kdx9WhUr MHMt880YZbLsOQY8eOoZp+MCIC8oyfWJYQ0Ii5ZtFJtF1rCBVXsa0dp0OaBiGGBQQR6F +8LklhEX9tdamsbLN+EGZzXEbNq8AD/phalkqb3s7ifW4Oy4SfSVbmZ98om4ba6NgTbD Y8F7HP6OBNlYqPQz7qNKWLqfG3fhCcDLALi5GEAPakWLgWo1aHH3Ks2r1P5YFRy6V9/q 965dXvE8ON+VVP2MRES1u37tOUpj+cOF5CUDHoAE1xs+cYWD4aaWOmuwEDfbi8EMqgAG P+xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5f4RqyVJYIpaFfo+EpLDXcWlO0wdx/BfqGpkLlar3y8=; b=DR3lmv9J5nfpTW2nYQdvjjGCeX7RWx3xLzsDEzmyapjwtdJnO+9hm8p7rFHQpifOr3 aa5aExspdqs5yChbvoL3DW9HLTGQzsXkmrMVo+/S7P9FVZ5ILo75YiqSQnHQyCwRv4vW LA+AdbRZ85CucMRM1CKb/mYuq7YzvTi8eVFAn3RDrI+VD6ghaqCP1z0NPIMGLy92Q4lV f9XnjuqN4I/yr9sXm3WZiEogJVFOmlb863WwrX5vyAEN7JXJefq0GFQCnvGK7adMj8HC xegX2ChpV2/EDRkhiY4rmEBph/f2/0ItB8q7nk2PZZZmk6v1NZOsD01QE1fJjQ6uxFq0 e+OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CATtEuYG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jl3-20020a170903134300b0017f77d19d92si18186081plb.127.2022.10.19.15.48.13; Wed, 19 Oct 2022 15:48:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CATtEuYG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231147AbiJSWrU (ORCPT + 99 others); Wed, 19 Oct 2022 18:47:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230282AbiJSWrE (ORCPT ); Wed, 19 Oct 2022 18:47:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91E0317C167; Wed, 19 Oct 2022 15:47:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 514B7B8261A; Wed, 19 Oct 2022 22:47:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB837C433B5; Wed, 19 Oct 2022 22:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666219621; bh=XdRd/D7YtnjF/VbtVQdPblQxfOL6jWA9yUi4elYsgMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CATtEuYG11NQ97X+dUT5iqaZitwvMN1GjLxxebL7NPDD4dxFA0yPhlkM/csd1ceU0 5YpYWBZTlDcIDBhwd6d0OdN3MkPVI2tLW93lrNsg8w9aKtopPk/i42xNiXpnSQrikF 9opL8UGvgpS2dC64Wl4SQKHNG9djEdMGQzGo5+nqC2ZAE0qEe7BEwQ9bVoEDpM1P1I zqxyAoxz6PzHlS9NsFx7aMOnhGD5niqY5M1NnljreFhSr0HeZEDtpzzYi5U1llCaEK 2fsg1/4UBIGvOSBX7KbTKIxuiO9jPari1IRNCcENz39AozIrPniJi6mGm6EzuGUpMZ pDSXKJwdKXczw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id A93345C0890; Wed, 19 Oct 2022 15:47:00 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, Zeng Heng , Mukesh Ojha , "Paul E . McKenney" Subject: [PATCH rcu 3/8] rcu: Remove unused 'cpu' in rcu_virt_note_context_switch() Date: Wed, 19 Oct 2022 15:46:54 -0700 Message-Id: <20221019224659.2499511-3-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> References: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747157994045787874?= X-GMAIL-MSGID: =?utf-8?q?1747157994045787874?= From: Zeng Heng This commit removes the unused function argument 'cpu'. This does not change functionality, but might save a cycle or two. Signed-off-by: Zeng Heng Acked-by: Mukesh Ojha Signed-off-by: Paul E. McKenney --- include/linux/kvm_host.h | 2 +- include/linux/rcutiny.h | 2 +- include/linux/rcutree.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 32f259fa58013..381b92d146c71 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -416,7 +416,7 @@ static __always_inline void guest_context_enter_irqoff(void) */ if (!context_tracking_guest_enter()) { instrumentation_begin(); - rcu_virt_note_context_switch(smp_processor_id()); + rcu_virt_note_context_switch(); instrumentation_end(); } } diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h index 768196a5f39d6..9bc025aa79a30 100644 --- a/include/linux/rcutiny.h +++ b/include/linux/rcutiny.h @@ -142,7 +142,7 @@ static inline int rcu_needs_cpu(void) * Take advantage of the fact that there is only one CPU, which * allows us to ignore virtualization-based context switches. */ -static inline void rcu_virt_note_context_switch(int cpu) { } +static inline void rcu_virt_note_context_switch(void) { } static inline void rcu_cpu_stall_reset(void) { } static inline int rcu_jiffies_till_stall_check(void) { return 21 * HZ; } static inline void rcu_irq_exit_check_preempt(void) { } diff --git a/include/linux/rcutree.h b/include/linux/rcutree.h index 5efb51486e8af..70795386b9ffa 100644 --- a/include/linux/rcutree.h +++ b/include/linux/rcutree.h @@ -27,7 +27,7 @@ void rcu_cpu_stall_reset(void); * wrapper around rcu_note_context_switch(), which allows TINY_RCU * to save a few bytes. The caller must have disabled interrupts. */ -static inline void rcu_virt_note_context_switch(int cpu) +static inline void rcu_virt_note_context_switch(void) { rcu_note_context_switch(false); } From patchwork Wed Oct 19 22:46:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 5882 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp570416wrs; Wed, 19 Oct 2022 15:47:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7A//7FEyh+OZ8vTaf0JANZKA6ZZHzLra7pMyFBEin9+YfKOULbfc7xD5/hXiHEjHXlkgUf X-Received: by 2002:a17:90b:392:b0:20b:2c3b:547f with SMTP id ga18-20020a17090b039200b0020b2c3b547fmr12596020pjb.116.1666219663477; Wed, 19 Oct 2022 15:47:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666219663; cv=none; d=google.com; s=arc-20160816; b=C1XJEyBOsleiwd1aE/flqggTRyOiwUF0HbH6QVSlW7evTzORPqw0xOvX6iGen4jDwO fKJPSnb96orBx0KfENcLZhNBHXKj+G5kqGXnBLqluhQjRuP236zcSd4HcgBhoSt+rR5J o4CQ1+uuBK1u3lUXwfwn9RqOjQEjij8MhjohhakQ980HoAj4vxwWqupbHvsUmTmMpjGB dNybsnJ4szdvqGwy9NMSPERb0wBxY2sExTJA3LNv/Fxd81AY6aqIkNUFnf4vJBa1I5sz qBW++oIeRWr5BjJS3aby3sxGf/O6T56PF2DdoQ/6OCVDpQ3Ft/MxK9Cwq32XEBfhteQC suuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=INgB8dOwM5zpVWkaTj9Y0qKFbRzIN6v21XP7PWkGnyI=; b=drSFEXT+Dk80QoFp6nddkVwdV6hyyFwRKjG2U9WnlUXu144TCzvS+4P6eV4KQ7z05x 0dV5WeVFsbb3rujBFem88Po6pBQ6tMJ8WDZdIK0WKlPIQxld0n5y/ikEDAj8l+rR5vDb +Cf7OsyjlC3qf+qYkBB7CMoCS8+yhpfMrgRz2qxbO0Vf+4Gm43a3fYupXWmtnGNVt9aO 1Fqausv2T1d7HpdhMZfkaxrjcKoWWlRAyJb2fiD9tkXTGFIIJbMVnHrfHgjagNguE3wi wOFRZWdt1qnohNbSeDNTCEAkMwoHr3PKMoNQc3BOYn/pX3B9ClXogIyr4OekskR3wR47 Br+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jZ9Z0O4b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a655547000000b0044189a7cf37si21761423pgr.323.2022.10.19.15.47.31; Wed, 19 Oct 2022 15:47:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jZ9Z0O4b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230407AbiJSWrJ (ORCPT + 99 others); Wed, 19 Oct 2022 18:47:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230192AbiJSWrC (ORCPT ); Wed, 19 Oct 2022 18:47:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CBEE17C167; Wed, 19 Oct 2022 15:47:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 928ED619E9; Wed, 19 Oct 2022 22:47:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC272C43470; Wed, 19 Oct 2022 22:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666219621; bh=+mIw1jy8wj3gxm+o9ZlbmvXenuiwqx+JElmYZGbXaeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jZ9Z0O4bxNI1YlzPyEqaNEYwOgorClEeEvpkHvp2pmO6GzXevqCV3HxCsEQqCysOu bmpwnxQkAHY3unTeNRtyIKVQfx5peSYFKdS3cri2lzyajtFdxKd1Sy8izG2XH0tEfT DxQ/ZPj+Q0TRLxJCPp2RHrMk//Q8/2JZTfYObUG4EhM1yL+w0aGD5BMW07/pLaSWu+ ihoL++h+iI9JvfAYPU4ifHt13KidQ6HWdyj0+w9H4FrRSepBvE3fDIUCa9EHYZ5pbj sTOvJlTYpyQeR8xJSK16uUQV3qWt6w3SVDmE3Pz2U3wMDeiYgBraK7p+EGRFse76Ab PHR0j5Jf0qN5A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id AB23C5C0920; Wed, 19 Oct 2022 15:47:00 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, "Joel Fernandes (Google)" , Frederic Weisbecker , "Paul E . McKenney" Subject: [PATCH rcu 4/8] rcu: Use READ_ONCE() for lockless read of rnp->qsmask Date: Wed, 19 Oct 2022 15:46:55 -0700 Message-Id: <20221019224659.2499511-4-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> References: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747157950118054344?= X-GMAIL-MSGID: =?utf-8?q?1747157950118054344?= From: "Joel Fernandes (Google)" The rnp->qsmask is locklessly accessed from rcutree_dying_cpu(). This may help avoid load tearing due to concurrent access, KCSAN issues, and preserve sanity of people reading the mask in tracing. Reviewed-by: Frederic Weisbecker Signed-off-by: Joel Fernandes (Google) Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 0ca21ac0f0648..5ec97e3f7468f 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2106,7 +2106,7 @@ int rcutree_dying_cpu(unsigned int cpu) if (!IS_ENABLED(CONFIG_HOTPLUG_CPU)) return 0; - blkd = !!(rnp->qsmask & rdp->grpmask); + blkd = !!(READ_ONCE(rnp->qsmask) & rdp->grpmask); trace_rcu_grace_period(rcu_state.name, READ_ONCE(rnp->gp_seq), blkd ? TPS("cpuofl-bgp") : TPS("cpuofl")); return 0; From patchwork Wed Oct 19 22:46:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 5888 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp571633wrs; Wed, 19 Oct 2022 15:52:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4CVwA+xroJfirQy0QLv5EUv6ces+xtpa+Fq8eWxRWZ41s4R4AlafH4wVTaglI+FZtxA5MP X-Received: by 2002:a17:907:7b8b:b0:78d:cee5:3145 with SMTP id ne11-20020a1709077b8b00b0078dcee53145mr8258807ejc.537.1666219955981; Wed, 19 Oct 2022 15:52:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666219955; cv=none; d=google.com; s=arc-20160816; b=kHW2g0EeHpN1J/AxOqmaocy803n/vjzCowQSbAUpXC9/FW9+YdOfDd+KIfcd9goVcS ftSg7ZlZn4+AiLPKL2g3ftJcWfZdKRWJoAUo7nZZ+4Fu1O/MstzM+4wJZdUU3BVYRPLp aCNhAGORCre8Ae+PArMPJbanTDM/l3DVj6DF5VbY1EOrX2YJAurwX7vKK7G0Daj2Hfnx yZLVGj8u86rdGYhag8Rcp7qOeNfkb/R06bFwwTxOR5WrfjSk4a8+TkgzfG1aApNHGApR wjZMb63zFhrdWwqbMbS7fiCvEv/1+QUsLVxPcMvkPzv7X8QpGLml1n9wl0o9aXr2mF02 xypA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vaBNEjQiN5imowm/0xL8cBoXu3aflqCt38ox8eogPH0=; b=AP0b8kKAZ4MfoGkLcLKlTuFWZgWpBP4U74gPS/LZ9gnwSGQv2v+8497VKKje2MtI3F Q6UrrL3WFq1ROQPG2JAjvDlZ0/JdmovTKqXd3Ujcd+ZrUePiNP6V4sDYNLCuOQ3+hB6M iAvEuojG+B7Ah+Whqr1vP5pUh2k9MWjNObeXTLxKICCX+afgal66TWG8AgydGM39H110 tHLbpwtmKCURarWW9SuDEkYPpx03P9eNnnpmMvJ9MpgeYBpltLUfGN4CYuvoXnxj+uPX 7b/wQ56x6E0o7k3cid1Du9oeOB8pUA/J2KZWm7EvW7xoeZ2G2/T2s7LbL6oujan+r95i DAbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XMSKFGEu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs13-20020a170906dc8d00b0077b4248b138si15114342ejc.127.2022.10.19.15.52.10; Wed, 19 Oct 2022 15:52:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XMSKFGEu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231287AbiJSWr0 (ORCPT + 99 others); Wed, 19 Oct 2022 18:47:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbiJSWrE (ORCPT ); Wed, 19 Oct 2022 18:47:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B463E186D70; Wed, 19 Oct 2022 15:47:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 64496B825E1; Wed, 19 Oct 2022 22:47:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0562DC4347C; Wed, 19 Oct 2022 22:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666219621; bh=U+1luf3mbgyTSKOMl8vtX4dFmH8rl+GKNY2TDjN1IyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XMSKFGEu/uzR3N52gimUSRvlUY77ksX6bwSP5MEEbrhoYubbKoJVO455NMN69R4xj x9GRwiRrinWyIWvqcLaI+JhV5ZHw0Ow+vjol3spPlLV+EDFsRspfhySJYB1hNYEyDD aSGLKC8qpWBT4nbxwHNQOo7RmG1Z0Y+5PDZjmaBTcnkG3j3YRGb2Ycr+/iXr0GVAM8 f3R8P+eO4JCLRSgp7mHQtfS9keccHmF/hGloP0UzUPKujvCNZbkgV3dyp0o5SzcWdJ GLdFjAAokYxUviKsgseded/9rmE6dJI2yUYwAvyjELLvaU6fXnXMYEQiD9ItgNieST uSvkQeYinB1kw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id AD5D05C0A04; Wed, 19 Oct 2022 15:47:00 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, "Paul E. McKenney" , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org Subject: [PATCH rcu 5/8] slab: Explain why SLAB_DESTROY_BY_RCU reference before locking Date: Wed, 19 Oct 2022 15:46:56 -0700 Message-Id: <20221019224659.2499511-5-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> References: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747158256615942836?= X-GMAIL-MSGID: =?utf-8?q?1747158256615942836?= It is not obvious to the casual user why it is absolutely necessary to acquire a reference to a SLAB_DESTROY_BY_RCU structure before acquiring a lock in that structure. Therefore, add a comment explaining this point. Signed-off-by: Paul E. McKenney Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton Cc: Vlastimil Babka Cc: Roman Gushchin Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Acked-by: Vlastimil Babka --- include/linux/slab.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/slab.h b/include/linux/slab.h index 90877fcde70bd..446303e385265 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -76,6 +76,12 @@ * rcu_read_lock before reading the address, then rcu_read_unlock after * taking the spinlock within the structure expected at that address. * + * Note that it is not possible to acquire a lock within a structure + * allocated with SLAB_DESTROY_BY_RCU without first acquiring a reference + * as described above. The reason is that SLAB_DESTROY_BY_RCU pages are + * not zeroed before being given to the slab, which means that any locks + * must be initialized after each and every kmem_struct_alloc(). + * * Note that SLAB_TYPESAFE_BY_RCU was originally named SLAB_DESTROY_BY_RCU. */ /* Defer freeing slabs to RCU */ From patchwork Wed Oct 19 22:46:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 5889 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp571634wrs; Wed, 19 Oct 2022 15:52:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7wRYgLKxBkj2IQw1/J71+pyw3X72ZOsLkmWQnrkC4hEh8PtwqSLivFnWKrF19X5NzmFxDF X-Received: by 2002:a05:6402:1d86:b0:457:e84:f0e with SMTP id dk6-20020a0564021d8600b004570e840f0emr9472836edb.241.1666219956011; Wed, 19 Oct 2022 15:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666219956; cv=none; d=google.com; s=arc-20160816; b=Z5E97ZpFJPORcAKulHxrqnwGKgUXA3ZWkM+giwHl9D7qXRr92wMm4ZZTLNyRVoqMFf Ar3uuYqJ74VA8Dk3+VQwyn90/3rsdD6JB4AEgCh42bg33KYTt1/Tm3zwr6hpSrVaQuWB 9DaKFBEEBwwL+KXC2BZJy5n6+fVwb1peJuC6OKYHFb1k3/K943tGoIRzUnHMSGE9RNHs CEyVZ1o8DSow0oNA5MSHhYUO4KK9h4CSOWWYz+kWQTySA6TGqQnn7AWwQWTgN2q2z71a q/b9dGe3jU4Rh3WEPP/oTpSKbiv27Dmb0oiENAq026KtiWPQ6BWSLipA7G1Raj7dWi8k PRsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4r6Bd0HHdUi/pH3EW3rpD8aXMlJrUCz9wyI1ctfKHek=; b=FpbEW6wu0D3hKQMvqoQwbhPE9hdaiyjTbzBa9D2zRFqZLKC0kxRTF/HIEoKATW5lYo 99pzREtXBmpEhOU+80f524IgHv4zX/ks3ITciek25ZER4hmrvT81xbvWkKqZm8jqY7F1 yXGXJEyNmvjtCoNxw4ivF/9vGOp61xKfhR3Ln0VqgpxbRGqCyOrgxm6HYk6c3KHuGf9L 81fPY3TPtf02jO80q7sDSneeXFOTW46eFI/LjmtoxcLsp/E5wHLPMUGBlaWDzfSNMUBq G0SzXQPF4VggGMA8NnsnmJ4f9GSmCv4WlrKtt4ydFgIeoxByacryETKLVX9kGBZVKwHu a10w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Oy/1fcvM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg15-20020a170907970f00b0078d426c2844si16598583ejc.213.2022.10.19.15.52.11; Wed, 19 Oct 2022 15:52:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Oy/1fcvM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231223AbiJSWre (ORCPT + 99 others); Wed, 19 Oct 2022 18:47:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbiJSWrF (ORCPT ); Wed, 19 Oct 2022 18:47:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B056188AAD; Wed, 19 Oct 2022 15:47:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DA989B8260A; Wed, 19 Oct 2022 22:47:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 506FBC4314A; Wed, 19 Oct 2022 22:47:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666219621; bh=fFc3hA0ZPr//nb0oSgszXsNmNDNbjld6HNvW7I07HJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oy/1fcvMSiFHp/xKwJ9CqwfRJHoqRkZcrv5jCD4aB/NXbeEvG+CAwUn+1laykl7t5 MMmXgTMbAhBmVfvWRKyYlC5jUxmRPZ6dEJEz0m9ZwTUj4tfcDKHGlv9zWZk+A+WIg0 EqUOn0Qr+yCnEZl+/MBE/objul/fDbsW25LyJ9tkZ7Pq6SRXK/2/7uPjOk/JmrDBtJ mVGDhL9L+jbomtlachTuFWKndhB7zvpLpYgWGxho7hvOURaDR6/s/GPVo+BLtxO4uV B56yRqi+MUbeTK0SrMpyjd1/6lJenX52g0gLYrHty/L61W6B5paQBeYXfdxCgTivgS 7jlhUKv59foUw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id AF2425C0A40; Wed, 19 Oct 2022 15:47:00 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, Yipeng Zou , Frederic Weisbecker , "Paul E . McKenney" Subject: [PATCH rcu 6/8] rcu: Remove rcu_is_idle_cpu() Date: Wed, 19 Oct 2022 15:46:57 -0700 Message-Id: <20221019224659.2499511-6-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> References: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747158256752734875?= X-GMAIL-MSGID: =?utf-8?q?1747158256752734875?= From: Yipeng Zou The commit 3fcd6a230fa7 ("x86/cpu: Avoid cpuinfo-induced IPIing of idle CPUs") introduced rcu_is_idle_cpu() in order to identify the current CPU idle state. But commit f3eca381bd49 ("x86/aperfmperf: Replace arch_freq_get_on_cpu()") switched to using MAX_SAMPLE_AGE, so rcu_is_idle_cpu() is no longer used. This commit therefore removes it. Fixes: f3eca381bd49 ("x86/aperfmperf: Replace arch_freq_get_on_cpu()") Signed-off-by: Yipeng Zou Reviewed-by: Frederic Weisbecker Signed-off-by: Paul E. McKenney --- include/linux/rcutiny.h | 2 -- include/linux/rcutree.h | 2 -- kernel/rcu/tree.c | 6 ------ 3 files changed, 10 deletions(-) diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h index 9bc025aa79a30..5c271bf3a1e7e 100644 --- a/include/linux/rcutiny.h +++ b/include/linux/rcutiny.h @@ -146,8 +146,6 @@ static inline void rcu_virt_note_context_switch(void) { } static inline void rcu_cpu_stall_reset(void) { } static inline int rcu_jiffies_till_stall_check(void) { return 21 * HZ; } static inline void rcu_irq_exit_check_preempt(void) { } -#define rcu_is_idle_cpu(cpu) \ - (is_idle_task(current) && !in_nmi() && !in_hardirq() && !in_serving_softirq()) static inline void exit_rcu(void) { } static inline bool rcu_preempt_need_deferred_qs(struct task_struct *t) { diff --git a/include/linux/rcutree.h b/include/linux/rcutree.h index 70795386b9ffa..4003bf6cfa1c2 100644 --- a/include/linux/rcutree.h +++ b/include/linux/rcutree.h @@ -87,8 +87,6 @@ bool poll_state_synchronize_rcu_full(struct rcu_gp_oldstate *rgosp); void cond_synchronize_rcu(unsigned long oldstate); void cond_synchronize_rcu_full(struct rcu_gp_oldstate *rgosp); -bool rcu_is_idle_cpu(int cpu); - #ifdef CONFIG_PROVE_RCU void rcu_irq_exit_check_preempt(void); #else diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 5ec97e3f7468f..f6561aa401c04 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -301,12 +301,6 @@ static bool rcu_dynticks_in_eqs(int snap) return !(snap & RCU_DYNTICKS_IDX); } -/* Return true if the specified CPU is currently idle from an RCU viewpoint. */ -bool rcu_is_idle_cpu(int cpu) -{ - return rcu_dynticks_in_eqs(rcu_dynticks_snap(cpu)); -} - /* * Return true if the CPU corresponding to the specified rcu_data * structure has spent some time in an extended quiescent state since From patchwork Wed Oct 19 22:46:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 5887 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp571245wrs; Wed, 19 Oct 2022 15:50:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM66mokzeknaXcL0n7QBhR275DDhn4vT1WM2KuPkTpZuGbBPiRR0ncFZs/EZhhpA1+i7LlOj X-Received: by 2002:a05:6a00:15ce:b0:562:cafb:2844 with SMTP id o14-20020a056a0015ce00b00562cafb2844mr10928819pfu.75.1666219848965; Wed, 19 Oct 2022 15:50:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666219848; cv=none; d=google.com; s=arc-20160816; b=dqiSFE5Kl+NDtyAZuivM6uH0OYiGfccfP5psvFtCFaZkhmLxmtyi0D+yDzmFKt5qlJ 2IrLlMl4wQrsWPebn7pwthI3E6TUfIUoIUNOPgGhIkROgNUnCNYu0Tay6NBTk6tdYSFD m0ZrXaoq8SlKZMRvL7y29fjB+XPPxn3+Isl8OeMgbuY1ZPLuqnRJUWr0KYD5Du6NtI3l y2n2f6LeBh18Vjag/yU7bo5aAs3UvlruTAOr3NXGIIjEUEfc8SZKhQHvZxTGzFq9bo3H OBtGKmgQoovCALzBZ/hiUPWepAXAFSPvKcNCm87uemF3PjcY7IUB2HC3J9cMh2K8pKlP 9rWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0RcWTi8ZpNpsvppY4AX9YU8rMx5fGb2/Z3KkaRriHmo=; b=zabFI1V03/nYo2gAoQ6fogyZm18D6wzHLbV9SlcnzbLs39j5TFUif1GPdQCbbY1XRt wYXwecIc6Spd531r3UWEOxsaW3Yqy3VHB+F2RKiLv/AjcMg+vZsn+lhEno1ifkCzqUhN iXwFsnmcHAmD/hIMnyFam03XxnQHwAWZMYHsYtuL98mVEgGo8czqAmMAYfx4a89jQOwR zeTwASFQq/XUUoudLhH7iCPOJlC2yFy6dwqFLbw38bmhhJdXDA/3huc+bOLimuzQCaOt TA1OWdTkjE/k0ac1wivEORDH2QaHMm0G8/5xmCU1c3z90h+8vxeAYKMS8dcFH/uwZ7In fjqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s2eRhzIv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v190-20020a6389c7000000b0046b30704f88si17479352pgd.5.2022.10.19.15.50.35; Wed, 19 Oct 2022 15:50:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s2eRhzIv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231304AbiJSWrb (ORCPT + 99 others); Wed, 19 Oct 2022 18:47:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbiJSWrF (ORCPT ); Wed, 19 Oct 2022 18:47:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B1E6188107; Wed, 19 Oct 2022 15:47:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B8D70B8261B; Wed, 19 Oct 2022 22:47:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 505A7C43148; Wed, 19 Oct 2022 22:47:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666219621; bh=IeaAKnXCrTJxEtb/hM2Q5kn1ssJ75eQ9FsOhFMTira4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s2eRhzIvlTeDSe1B8OI9k7XhSR+HrCnEujCmMR1fA0ltBZ3oeJzvsdkc2x8DaEYo6 vip4yyk3uBScrCJ2kpln3iH9pg39A/8gA4spvtnSP5RsmBB6WdCboK04Lo+doYVmeF sfAVQs7GcyBG7/mXI324vwx0aN7ztx59oUdwFoYECI7und9aTWpjb+OvBu6aLg3jsE kbe+8LCQ6WxrFfgnMEdnfL4tH3furhSuBLAWGjrb50IEm/wOYENRcCYoJkwr+qaFYl 0VWesc45R5xRXk47xsq/OWFN/sqiKo2xtO0cwWgpzeW77txeSnyUIr0DJZexx8qx4z jss+1AKGZ7jvg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B11CC5C0AC5; Wed, 19 Oct 2022 15:47:00 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, "Paul E. McKenney" , Alexei Starovoitov Subject: [PATCH rcu 7/8] rcu-tasks: Make grace-period-age message human-readable Date: Wed, 19 Oct 2022 15:46:58 -0700 Message-Id: <20221019224659.2499511-7-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> References: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747158144128734095?= X-GMAIL-MSGID: =?utf-8?q?1747158144128734095?= This commit adds a few words to the informative message that appears every ten seconds in RCU Tasks and RCU Tasks Trace grace periods. This message currently reads as follows: rcu_tasks_wait_gp: rcu_tasks grace period 1046 is 10088 jiffies old. After this change, it provides additional context, instead reading as follows: rcu_tasks_wait_gp: rcu_tasks grace period number 1046 (since boot) is 10088 jiffies old. Reported-by: Alexei Starovoitov Signed-off-by: Paul E. McKenney --- kernel/rcu/tasks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index f5bf6fb430dab..b0b885e071fa8 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -728,7 +728,7 @@ static void rcu_tasks_wait_gp(struct rcu_tasks *rtp) if (rtsi > 0 && !reported && time_after(j, lastinfo + rtsi)) { lastinfo = j; rtsi = rtsi * rcu_task_stall_info_mult; - pr_info("%s: %s grace period %lu is %lu jiffies old.\n", + pr_info("%s: %s grace period number %lu (since boot) is %lu jiffies old.\n", __func__, rtp->kname, rtp->tasks_gp_seq, j - rtp->gp_start); } } From patchwork Wed Oct 19 22:46:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 5883 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp570435wrs; Wed, 19 Oct 2022 15:47:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7z16BDxoBgkNUw62W09VStbQma0Rh6+b+erF37Zf4sEDbCRHd+6m9W5/eo5gtS2L8AA3Xe X-Received: by 2002:a63:b5d:0:b0:45f:d7d0:5808 with SMTP id a29-20020a630b5d000000b0045fd7d05808mr8990784pgl.330.1666219668326; Wed, 19 Oct 2022 15:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666219668; cv=none; d=google.com; s=arc-20160816; b=owpaX8cuvh6UAJcQRWO2PddnRp0ObvIt+5owvY+I5qg+TKzWmcoMEZ1JPgheXofdpN Qde0Ux190X7P2cW+Agu+1muD6MCVwJ+StYLwJ6HGkx95BzcZpGP7jn2hCikLe3glsAgc uhE6nJ03qOveI2ixxop11aekzimPRx80+8ZAMwKupRBW7B5/vhRV8vd/37tIUm/QkQNQ u3BKcNnyfN3uXSRiENBNxLgC50Vjq9jvYh2ZEOC7Y9UhdZ1kNcDM5bHFxlYkrkwJCFvk a3FtrzpAGlWKc4u2WhfMvNERuyCrcNBbsFRDCMD6HwxFrK7qiI+TSBGD8MYAS1m3WWUY x7cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X9GDItMct8iZ7efwyNK/aqam1NNqBX2R2C3hmrI+Wps=; b=TJ4UTUmxZVsysaVGzjk9azMErIN5ktrO/kEMvuetniHitVBaHhNYooepVz/7yEdlx5 MEMSsm1pOBvHauc7YvZcv9BmNAwHJGIM73pssTDM/GmQXI/Y9FW3vIK/wXpeUQ5htuJL H1itvWQfG69GuMoVqA0KzReYkP30LbDxkYCTrVKxSd07VxZ6YjPRTTNOfx+ZBzhiUP4L b8Dg0geF3vF6AuX8FeRc2YPcxsBdTK7r2PcNQnfkmbTLscjuAR2Dg5ZL39Vzh50u+9+W IhOsGvuXw2QLhKye5YOvTtHbSWP/JEHEzoqZlk66x1EQTVD1LmHllwU/Heeg3AdBMf6H fCFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tuC9VoJU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id om9-20020a17090b3a8900b0020305fa091csi1423642pjb.140.2022.10.19.15.47.36; Wed, 19 Oct 2022 15:47:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tuC9VoJU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231136AbiJSWrQ (ORCPT + 99 others); Wed, 19 Oct 2022 18:47:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbiJSWrD (ORCPT ); Wed, 19 Oct 2022 18:47:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8820717FD5C; Wed, 19 Oct 2022 15:47:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 22755619D6; Wed, 19 Oct 2022 22:47:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5060CC43149; Wed, 19 Oct 2022 22:47:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666219621; bh=CDl8H2MGOjWvC458fdEn7dT11YxGntP9ARrgviEeMhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tuC9VoJUsxYY/4c+0Pc8LrQ1NGvAKs1dMjfH9r+iKyPsUll5AXr+M8mzGLDsSgWsc wNZkFN8/urxwPLqOoviVRke4/rJGfytC7VoI/4ExKL6ikIH8zSDpmSs7VGFH1rf/bT AE9DZl2rrmOoaHRLKi9uSR2a6dK851gFDFHp3a04uSuhov9GeK36VtvC5mCmne1dpU PAn+ouBxcTUFL9Civ4mINIPu8vnvSSs6P5heivUd6ApQ9BEkJmoKY9dvA6huIWeH/+ Ew+TTrGXjp4GD/qunPYACNRTIUTSMSBEAwcN98aCDMgs1y03E41YnNyklrkA2rCEXJ dZAatlp2GWijA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B2E8E5C0B8F; Wed, 19 Oct 2022 15:47:00 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, Zqiang , Joel Fernandes , "Paul E . McKenney" Subject: [PATCH rcu 8/8] rcu: Fix __this_cpu_read() lockdep warning in rcu_force_quiescent_state() Date: Wed, 19 Oct 2022 15:46:59 -0700 Message-Id: <20221019224659.2499511-8-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> References: <20221019224652.GA2499358@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747157954672383322?= X-GMAIL-MSGID: =?utf-8?q?1747157954672383322?= From: Zqiang Running rcutorture with non-zero fqs_duration module parameter in a kernel built with CONFIG_PREEMPTION=y results in the following splat: BUG: using __this_cpu_read() in preemptible [00000000] code: rcu_torture_fqs/398 caller is __this_cpu_preempt_check+0x13/0x20 CPU: 3 PID: 398 Comm: rcu_torture_fqs Not tainted 6.0.0-rc1-yoctodev-standard+ Call Trace: dump_stack_lvl+0x5b/0x86 dump_stack+0x10/0x16 check_preemption_disabled+0xe5/0xf0 __this_cpu_preempt_check+0x13/0x20 rcu_force_quiescent_state.part.0+0x1c/0x170 rcu_force_quiescent_state+0x1e/0x30 rcu_torture_fqs+0xca/0x160 ? rcu_torture_boost+0x430/0x430 kthread+0x192/0x1d0 ? kthread_complete_and_exit+0x30/0x30 ret_from_fork+0x22/0x30 The problem is that rcu_force_quiescent_state() uses __this_cpu_read() in preemptible code instead of the proper raw_cpu_read(). This commit therefore changes __this_cpu_read() to raw_cpu_read(). Signed-off-by: Zqiang Reviewed-by: Joel Fernandes (Google) Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index f6561aa401c04..1e1d333d07ffe 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2410,7 +2410,7 @@ void rcu_force_quiescent_state(void) struct rcu_node *rnp_old = NULL; /* Funnel through hierarchy to reduce memory contention. */ - rnp = __this_cpu_read(rcu_data.mynode); + rnp = raw_cpu_read(rcu_data.mynode); for (; rnp != NULL; rnp = rnp->parent) { ret = (READ_ONCE(rcu_state.gp_flags) & RCU_GP_FLAG_FQS) || !raw_spin_trylock(&rnp->fqslock);