Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2235105imn; Mon, 1 Aug 2022 16:43:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR6pQX7eTjV45T150D1dj1NwIUO5ELcuagmLxk+BP7Uhp1PvDaeGrfKOr2uk6ViFd6mozguj X-Received: by 2002:a17:90b:4a86:b0:1f3:b701:87d6 with SMTP id lp6-20020a17090b4a8600b001f3b70187d6mr17911143pjb.213.1659397400602; Mon, 01 Aug 2022 16:43:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659397400; cv=none; d=google.com; s=arc-20160816; b=CYcFY1h93zg0WTwGFDjwsDhFnofh7/qmldVZW+Eu+Ik3pj/onZ+7tv3Bhf2QPcECj5 Ln2KLGOIhzF5oDgC0YyYXYD6O4oSdt4oczCqjNz4VjPwcpcv+cB+Ombm1L6JEqOeQD8S DxNSvMy4HofoNAAFtSoj4D9EwPNocWXzj4XqYfopamh8e/4fk4PhQi5MmDPb8Dftxjaq lPyyeQw2QYzn3IsZKvRwQ2emc4090ETn4O+53OTolMWOJquJDVbqREDdQSJ00gjzp9bI XddgZO5SmvQsl5Eje81wXVp8Ka1dv5A48HvpuN3E55dyoiADcPOSJFE30TvDee/4AVgu 5TTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=PtUC9hnW6ElppZjUEjJnZtttwz6S7w3zQfxn0VU/FNE=; b=iPqF50z7PbEfRDf46TUjGBArDE8zKFk1i4wUji98dk1302IRaF3uHuD7VK2ue87FSr 5Cf3wkNNowsHlcYVjBpFtDiJqKh/Zdpl5B6GqaC6+xT+s/fixsDSc3/l+/JYLdXCErV5 pY9zfA11ssnU/EtYc7fml1Q9Ccy07BvxMChIH+b7LzvHZFgGaJWcz3bmwViCcds+Qf8o bj9Wa469d5vs8eABK8yCIyjRGSE5PwegIYaC0cdIVGHOnLTZSAkqQBDkILiiSaahDFt8 D+DAcKfOirATqfvD6GLlueJcSnAXFWnC9yhC2qTsCJWWIguWz0eB1+wDALNvnlEwecJB tdZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y+i7h8rH; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h21-20020a635315000000b0041b2b6c8eb6si13213470pgb.287.2022.08.01.16.43.06; Mon, 01 Aug 2022 16:43:20 -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=Y+i7h8rH; 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 S235020AbiHAXKe (ORCPT + 99 others); Mon, 1 Aug 2022 19:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231215AbiHAXKd (ORCPT ); Mon, 1 Aug 2022 19:10:33 -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 E014E19029; Mon, 1 Aug 2022 16:10:31 -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 AE00760DE0; Mon, 1 Aug 2022 23:10:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B5A9C433C1; Mon, 1 Aug 2022 23:10:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659395430; bh=c68rvvKS7OQgl7DSiVXP6nOIRR0u1tOQMrT4+jA51fE=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=Y+i7h8rHt7TGpHAWfVjqvgbK+2WMmD82Hc7mAxOb0aI49VvxXJ/OHEqKkz5251s9d Qks06Ig1tubt+kmUzInNt9UInoy9zGAM+fDDRZ5dFgn3lhFXQ90VsKf96o8MjuaFXr SuLWtOh1NoJRw+S9jZYLDGyBTnL5JYZC2q3CkC8j0psP63MYikDjgXumwt7XA7VXNN YF618/qertaCAdhOtxSVbba7X7TcEjG7xN2/Gpz1aZNoZRJ6aIh0GFvVnJ1+T26udB A+uxXIu7tba7WAPZd7gCzSxgq6vFUuENDVsv7GmBoXTfALO4/fwvAMuRvXEPUIz3+n qgUgIcPqLSwbA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id A403B5C0D2B; Mon, 1 Aug 2022 16:10:29 -0700 (PDT) Date: Mon, 1 Aug 2022 16:10:29 -0700 From: "Paul E. McKenney" To: Zqiang Cc: frederic@kernel.org, quic_neeraju@quicinc.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rcutorture: Use the barrier operation corresponding to rcutorture.torture_type Message-ID: <20220801231029.GB2860372@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20220731105356.1741086-1-qiang1.zhang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220731105356.1741086-1-qiang1.zhang@intel.com> X-Spam-Status: No, score=-7.7 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 On Sun, Jul 31, 2022 at 06:53:56PM +0800, Zqiang wrote: > when the rcutorture.torture_type value is 'rcu', this is correct for > invoke rcu_barrier() to wait all in-flight call_rcu() callbacks > (rcu_torture_fwd_cb_cr()) complete in rcutorture_oom_notify(). but when > the rcutorture.torture_type value is 'tasks-tracing', invoke rcu_barrier() > won't wait all in-flight call_rcu_tasks_trace() callbacks complete, the > rcu_barrier_tasks_trace() should be invoked. > > This commit fix it by using barrier operation corresponding to > rcutorture.torture_type to wait all in-flight rcu_torture_fwd_cb_cr() > complete. > > Signed-off-by: Zqiang Good catch, thank you! I have done my usual wordsmithing as shown below. Could you please double-check it? Thanx, Paul ------------------------------------------------------------------------ commit f8c9027f9c81be92344996a51babaa5a23bd88db Author: Zqiang Date: Sun Jul 31 18:53:56 2022 +0800 rcutorture: Use the barrier operation specified by cur_ops The rcutorture_oom_notify() function unconditionally invokes rcu_barrier(), which is OK when the rcutorture.torture_type value is "rcu", but unhelpful otherwise. The purpose of these barrier calls is to wait for all outstanding callback-flooding callbacks to be invoked before cleaning up their data. Using the wrong barrier function therefore risks arbitrary memory corruption. Thus, this commit changes these rcu_barrier() calls into cur_ops->cb_barrier() to make things work when torturing non-vanilla flavors of RCU. Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 7f13f2e5ed62f..7e7d54841613c 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2638,12 +2638,12 @@ static int rcutorture_oom_notify(struct notifier_block *self, for (i = 0; i < fwd_progress; i++) ncbs += rcu_torture_fwd_prog_cbfree(&rfp[i]); pr_info("%s: Freed %lu RCU callbacks.\n", __func__, ncbs); - rcu_barrier(); + cur_ops->cb_barrier(); ncbs = 0; for (i = 0; i < fwd_progress; i++) ncbs += rcu_torture_fwd_prog_cbfree(&rfp[i]); pr_info("%s: Freed %lu RCU callbacks.\n", __func__, ncbs); - rcu_barrier(); + cur_ops->cb_barrier(); ncbs = 0; for (i = 0; i < fwd_progress; i++) ncbs += rcu_torture_fwd_prog_cbfree(&rfp[i]);