Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp661889rdb; Tue, 31 Oct 2023 20:35:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGnF/jhionngi1cuo/9YnOqknGbRN7MaOZO1mXB+P1lZq+PvuiU+yzDOe7qPg+jU0UtiPbh X-Received: by 2002:a05:6a21:33a1:b0:181:2526:93b5 with SMTP id yy33-20020a056a2133a100b00181252693b5mr1943626pzb.13.1698809730992; Tue, 31 Oct 2023 20:35:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698809730; cv=none; d=google.com; s=arc-20160816; b=iTcqo9J1ZKnh3bYoxSWj0+PM6bRCgCJRSlTDz8WBmXUazQRviWzQoEqAM1KQfj05v8 89u86IMCYNaw3vCre+a+JxdkmT2U9cJB5CzEzhxVcNxryZ9jEeSSVKf+w5jdG+l+w29N cfC+g/ZkJYcLi0uQU2Q0zLEGVGQLAvzT+oRz6wy+DO/CgxuTf8dvyQRK/+f2LRQquVb/ nE7zQiZv+CwlZExMVX/CXiJL6cw/MuDfZXpO6Yu8h8cCtYJDruXUMTruN8fV+LL5BhVp KA3fjuYqE2JBKtcp8thPQWUdFnbqEuPfPOZaqUqbuw4pjh8NbkSvHSQ6Kyu+e4iPrWyW NHhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=4AYaAfrBQMEF3rm9agZrtQ/weHtjQJC7TH+07CV4Lio=; fh=gwiqvfVgKJz0dErjXj6/k92xBhYgRbUDUBlJIm9YqFs=; b=H0hQTiisqFYPC1nbZyW7De94ht3lhgZV68SQ5jWjuwL9XBqinziUq2MIU82zFHpOGc MfOh28El+efewSID27YtzirTnWHNAbQbQfDhCL2j18q/OklZQqQiQYnhGtgnQXL2m7fM cJpXeiGR6nrY4KplTPK1D/kUVTyvRTaLK1RBIhwAjN/pCPoqQk94es2J8CjUnPIZLMo3 xr625CvNFkU2gJEW8IQDWQgTLPWByQFYvV4k5scCBcvmYmc90gVx4eJmbWAaxo9j3FBe 8M7YWLFMNWlM6/JgFmFsyatmpZHscN7JhiytU0tou2EXv1CdxkgkDIhEdE3d86kcMmg8 tsgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hNiJFe2h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id k11-20020a636f0b000000b005b958401e4fsi2222758pgc.418.2023.10.31.20.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 20:35:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hNiJFe2h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 7AFA28087E3B; Tue, 31 Oct 2023 20:35:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232569AbjKADfX (ORCPT + 99 others); Tue, 31 Oct 2023 23:35:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231924AbjKADfV (ORCPT ); Tue, 31 Oct 2023 23:35:21 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B63E7A4; Tue, 31 Oct 2023 20:35:19 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6b77ab73c6fso369224b3a.1; Tue, 31 Oct 2023 20:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698809719; x=1699414519; darn=vger.kernel.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4AYaAfrBQMEF3rm9agZrtQ/weHtjQJC7TH+07CV4Lio=; b=hNiJFe2hWRWqcT8E4Pfk7GdFEFHdYU9ZVQqN5thpreM9DQsxXGBilzSmRdaTaFtnnp MHCTyw0fptKGNQVvDeq0PbLyMldSduERS2vOgptZ2GitMcle0rFisJOnhP2pdlXDgnPt 74OpzzvWEi5akJyJd4uuXixsGiChIsdQI/IuLanuZ8f+OByL1068QwH6iiJD5qAxJ1fR pIqbCa9F7yUk1SZ3mYgxOmYCavPEn5pOOCDZnE7Er+325fsHXobORPekHooW/MUK5mZq E4nIl3w9HxNWylXZT82DYc8nbw5SI4jffYKzmFJWJsvwoy0NGO+PUhFdK2l7N2RgXWWG LCwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698809719; x=1699414519; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4AYaAfrBQMEF3rm9agZrtQ/weHtjQJC7TH+07CV4Lio=; b=Piy4V/ZkZ1TlVkDW0SrEXunr/nJM226/wBalUgkPhHWF8UaXLjcY6GSeEMHnU1o+eU nhwVyWyl9kiBCvyaShGJRKcXfn3GxEwPVJlB0URwyQSncBXlKZEC9QU5m9NwBJpa0Q+M EzrYFYbgSNdw2tObT8XTq27MaQ0Rmv0QQW9D5pYa7cD6HSoTVEAD8yK8V503IJMKN/8S Ggp3avSnacxgI5nlvGuBstct0477HYJ2fYwbETXkEx3F1oa+PbpBSSQaZ402auiuyhYN Io0iY446j3q2n90744x4payvPqyg3Qcuwpr7ZTmkSMVyTGwM+kIND55JOGCzgn4IonZL IwVA== X-Gm-Message-State: AOJu0YysQ9FF2aNMbMWvnJB0FPck91kcGRNcW6IVx7Mf2SZLkHECtkj6 M6pQUmVDzM1FVHQSh15bdaM= X-Received: by 2002:a05:6a00:6ca1:b0:6c2:e263:5c3d with SMTP id jc33-20020a056a006ca100b006c2e2635c3dmr1528475pfb.0.1698809719082; Tue, 31 Oct 2023 20:35:19 -0700 (PDT) Received: from MSCND1355B05.fareast.nevint.com ([183.242.39.186]) by smtp.gmail.com with ESMTPSA id z3-20020aa785c3000000b0069ea08a2a99sm318749pfn.211.2023.10.31.20.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 20:35:18 -0700 (PDT) From: Zqiang To: paulmck@kernel.org, frederic@kernel.org, joel@joelfernandes.org, boqun.feng@gmail.com Cc: qiang.zhang1211@gmail.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rcu: Force quiescent states only for ongoing grace period Date: Wed, 1 Nov 2023 11:35:07 +0800 Message-Id: <20231101033507.21651-1-qiang.zhang1211@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 31 Oct 2023 20:35:28 -0700 (PDT) Currently, when running the rcutorture testing, if the fqs_task kthread was created, the periodic fqs operations will be performed, regardless of whether the grace-period is ongoing. however, if there is no ongoing grace-period, invoke the rcu_force_quiescent_state() has no effect, because when the new grace-period starting, will clear all flags int rcu_state.gp_flags in rcu_gp_init(). this commit therefore add rcu_gp_in_progress() check in rcu_force_quiescent_state(), if there is no ongoing grace-period, return directly. Signed-off-by: Zqiang --- kernel/rcu/tree.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index aa4c808978b8..5b4279ef66da 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2338,6 +2338,8 @@ void rcu_force_quiescent_state(void) struct rcu_node *rnp; struct rcu_node *rnp_old = NULL; + if (!rcu_gp_in_progress()) + return; /* Funnel through hierarchy to reduce memory contention. */ rnp = raw_cpu_read(rcu_data.mynode); for (; rnp != NULL; rnp = rnp->parent) { -- 2.17.1