Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2651533rwi; Tue, 11 Oct 2022 11:23:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM42tJYmmMzOganpZXFbA+OCG8HPvjqUfxqQu1LbPDwdkYpqFUs6ZyZwlDvmIak1uwjzggID X-Received: by 2002:a17:907:9491:b0:78d:337e:580f with SMTP id dm17-20020a170907949100b0078d337e580fmr20242900ejc.464.1665512627575; Tue, 11 Oct 2022 11:23:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665512627; cv=none; d=google.com; s=arc-20160816; b=Ie+Edo1cQ03LbzrIpz0khb+rrA+h4w58kR36PsLFNKAuGovtT+XlFikx2yh2As+OeS ZnQVItpbBjywKYiQtKcSASoQo16SAPrMHmE89b1MUWx90W9p9ubSQ5DZQpsaIReUrGnc lzYu4jO+rjM+w7FlPf9J58fclBcW5XdYejFh5Wl8YaCpFBJMIcy8lKqvEiAnHnsd4bkA Vq86YUICR2z8pI68qVODv4x2pCfmUVEWfDYfL7c191jiL8Ug73BAJ8Op7T7D4o82d2BF pndYtVaWzxJEzK1CMSMGkfAFZKwupvgwkFVGR2OLfwZQ1fVDkUqlOCgwSKIzAueu/P3c wUwg== 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=WO1zLatTGk7w49T3dw38/yevK8lFIMN7WGO9rdhO2q0=; b=OMZiPdr/U8UxtMw+lBSzIZOxD5s+Agrfkz1PaVPppCMhWcAyecXexbSC4u/MrupWt2 BV2e5ltrpkl9WotsJ9R38v94Ux4ctzDBzsReHfPhPWUg8jqJ1dNM7rSeobgMTu3/FszJ dv76asLuF/bv5wBAOLVWvDQ8Kin2wVtaiF5AiTRXv33BIVarGE68dPmtTisf8LBrA42Y vegCVCMmgb+4Hwly1u1z7vtZYmWeisKKH4Q4Lt3XfnZnqFCx5B862WGNPcHXa54QIJcH wmg48k2aKZLrxWOiKuTTvmb2JERw34PL7WTAH9f4M/thFff2PWUhBrD0D3Vj5o09ZgvY mKyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=hJudK9mm; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h7-20020a05640250c700b0045c129ed626si6451456edb.317.2022.10.11.11.23.21; Tue, 11 Oct 2022 11:23:47 -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=@joelfernandes.org header.s=google header.b=hJudK9mm; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230050AbiJKSCe (ORCPT + 99 others); Tue, 11 Oct 2022 14:02:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbiJKSCV (ORCPT ); Tue, 11 Oct 2022 14:02:21 -0400 Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B4106B672 for ; Tue, 11 Oct 2022 11:02:14 -0700 (PDT) Received: by mail-qk1-x732.google.com with SMTP id a18so6105008qko.0 for ; Tue, 11 Oct 2022 11:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WO1zLatTGk7w49T3dw38/yevK8lFIMN7WGO9rdhO2q0=; b=hJudK9mmd0OcgTLgDLgV1SgQdwzWbP+YDsFTSLx5pTw6kLDd9wvZUakI1Y0RBR9N4F MiCZ9FURS1a2ZlqaLiJrZAVZui1do8JjJFFDrGJZVUyP9dLAXPaLHVN4wSeUhFGYY3O7 Foo5ge8rRQxBknxNlFPED8LHL+QAt890PhS/c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WO1zLatTGk7w49T3dw38/yevK8lFIMN7WGO9rdhO2q0=; b=JO3+iWxfDLlFUo9q9Jrp8GPr7ZR13nljv0Of+aYssTqEc8mYodSVRarwP0F36YkJ8X JPuvP4zd3kZEWxovqRJ5kYTm7xgV1dC/olq6zANreufyMdtbIpFREoPWGOQVZHh7fkKl So2wza1S/Ivg2vgWW6Q057Vpchusg9l0BaZr9tYMvAmZJ/WW/8vu6NjETdp9OVE8kUZJ z9pZD5P/QKwv7bRMcFher4QQHpmAVQV/1DLhfugfHuf6t8S30IB9GcQXxiW2udKGNEvX spvot+ovpNb65mNJ8IYCmT+Ky4BMHCy4SK106V2yU3+B0w1K8H9Te24jhDGgbfONmxqK 4XaA== X-Gm-Message-State: ACrzQf09dJ3ZcY0m/Opd/a9f/AeQ0mhBwLIV2HjO10Rf/vdDn2/Gudea 4ngRKzDZROO7BitIJtgtmfEVgQ== X-Received: by 2002:a05:620a:28c1:b0:6ce:b23c:dcac with SMTP id l1-20020a05620a28c100b006ceb23cdcacmr17417950qkp.123.1665511333536; Tue, 11 Oct 2022 11:02:13 -0700 (PDT) Received: from joelboxx.c.googlers.com.com (228.221.150.34.bc.googleusercontent.com. [34.150.221.228]) by smtp.gmail.com with ESMTPSA id w22-20020a05620a425600b006cbc00db595sm13464375qko.23.2022.10.11.11.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 11:02:13 -0700 (PDT) From: "Joel Fernandes (Google)" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, rushikesh.s.kadam@intel.com, urezki@gmail.com, neeraj.iitr10@gmail.com, frederic@kernel.org, paulmck@kernel.org, rostedt@goodmis.org, youssefesmat@google.com, surenb@google.com, "Joel Fernandes (Google)" Subject: [PATCH v8 06/13] percpu-refcount: Use call_rcu_flush() for atomic switch Date: Tue, 11 Oct 2022 18:01:35 +0000 Message-Id: <20221011180142.2742289-7-joel@joelfernandes.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221011180142.2742289-1-joel@joelfernandes.org> References: <20221011180142.2742289-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 call_rcu() changes to save power will slow down the percpu refcounter's "per-CPU to atomic switch" path. The primitive uses RCU when switching to atomic mode. The enqueued async callback wakes up waiters waiting in the percpu_ref_switch_waitq. Due to this, per-CPU refcount users will slow down, such as blk_pre_runtime_suspend(). Use the call_rcu_flush() API instead which reverts to the old behavior. Signed-off-by: Joel Fernandes (Google) --- lib/percpu-refcount.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c index e5c5315da274..65c58a029297 100644 --- a/lib/percpu-refcount.c +++ b/lib/percpu-refcount.c @@ -230,7 +230,8 @@ static void __percpu_ref_switch_to_atomic(struct percpu_ref *ref, percpu_ref_noop_confirm_switch; percpu_ref_get(ref); /* put after confirmation */ - call_rcu(&ref->data->rcu, percpu_ref_switch_to_atomic_rcu); + call_rcu_flush(&ref->data->rcu, + percpu_ref_switch_to_atomic_rcu); } static void __percpu_ref_switch_to_percpu(struct percpu_ref *ref) -- 2.38.0.rc1.362.ged0d419d3c-goog