Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp266039rwl; Thu, 30 Mar 2023 15:48:48 -0700 (PDT) X-Google-Smtp-Source: AKy350ZSOqHJIVShveLJS64ZyACo1ETT04xOBVALooN52SZg7POs9aw93oiwBL85wmhyLkn07ZBS X-Received: by 2002:a17:906:15c:b0:8f5:14ab:94bc with SMTP id 28-20020a170906015c00b008f514ab94bcmr21573037ejh.6.1680216527939; Thu, 30 Mar 2023 15:48:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680216527; cv=none; d=google.com; s=arc-20160816; b=l4XLWQfDxTwto0QUzRBlM8kOXzlvXW6OJZcX6gRsl4/PpaGZ3YFOdpzqmhkRe1G99U wlduQBH4pYnTJ2YXqh5Lpj6bISKOydyHdUONcxLr+p5WuktAYESqjcWSORk25zFjrbI3 ZBn8HdGb5pxRpbonFPAi/j3PGSIF5xcxX5cx5m8CQDdGupX8Q9kX127Dhn/1xyqJXQ2n RL5dKey0tqtt1qE2mUOvAHz1e6qtpmLdVcQpwaKfRj/t8XSz3n/cPFUO0W4odmw72mjL I0OYsxWChLtINSZGhm3DTNo+4065dBQSwovTKjdkaEI2AjKg/3Q8MtRuyxHRtigHycI+ 0i0g== 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=RbUt4Mat5K+qCfdImjqS9eh6Gi7PhmuBt4u9LyF4NX4=; b=dSVeQuG8JFo/A2y1by55PVgUjt3K/cnUUpXKtpXuZ1Xm/oo0siHkMTeDdai6uamDH0 rfnhOP8i+I3aQ4hpfh2S5G8LVJtMgStm703KxddOxfLFZAlQgk0hbakxjW7j3MC75P7k IUVqYmQ0AM9wfernCxUi3qTJS5qPUfS9h6PFhNni+rGJclZCtc69nb7w/J9TzMxNOoYh MNGdAZz6Dg0H9Md02HnD4BLSf5502TpmYWCeX+2Jdhq1lWwCvxp+GyMAbNU2YeGUeGt5 2ksehGQIkyEOnmo9nhZz0vgd+U25ga1mxbFdCT4m/XaLaGNv6itbP8L2PgUxiJvPx0g/ 2xjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S8YyvD9L; 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 h1-20020a170906590100b00931fdd18ee2si595946ejq.266.2023.03.30.15.48.23; Thu, 30 Mar 2023 15:48: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=@kernel.org header.s=k20201202 header.b=S8YyvD9L; 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 S231286AbjC3WsG (ORCPT + 99 others); Thu, 30 Mar 2023 18:48:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231197AbjC3Wrw (ORCPT ); Thu, 30 Mar 2023 18:47:52 -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 0DEA812054; Thu, 30 Mar 2023 15:47: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 8405B621D7; Thu, 30 Mar 2023 22:47:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEDA7C433A0; Thu, 30 Mar 2023 22:47:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680216448; bh=cul4jXhNAUP7VLyJNUzboJAx7iCgCVh7yP8irDHosoE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S8YyvD9Lhp4043m6tOQEkTkh9yt2ForFJhH8L1PmqPljd8VvZznlk4So7iB1JAm0M rGt1XdiGj4t0+UScvwHWifSzmgNzUR2WPAhZ1ghGQOU+5GYO4z1HcoHKncdvfKeavX onzMAAI9Jv6gOr7T8msVuWqfZy9dxgqYw/WCaNoB/x/sycWv2QJr9MOrmj1CP2FjXY RdQTXTIG2i4MYHDNknIDlcOMaRB+K9Q+j5gReRykbi7uSEcCq3kQ+57olWtHn8w8X/ ktpMUW3rY7JFfnV7aPqp/THrXv0oIvixK8DcVrGa6PQUjEzBqfc/6mmwGb6Za2Tdo6 exxyU/uqvNlOQ== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 14C701540483; Thu, 30 Mar 2023 15:47:28 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, hch@lst.de, "Paul E. McKenney" , Sachin Sant , "Zhang, Qiang1" Subject: [PATCH rcu 07/20] srcu: Move ->srcu_cb_mutex from srcu_struct to srcu_usage Date: Thu, 30 Mar 2023 15:47:13 -0700 Message-Id: <20230330224726.662344-7-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 This commit moves the ->srcu_cb_mutex field from the srcu_struct structure to the srcu_usage structure to reduce the size of the former in order to improve cache locality. Suggested-by: Christoph Hellwig Tested-by: Sachin Sant Tested-by: "Zhang, Qiang1" Signed-off-by: Paul E. McKenney --- include/linux/srcutree.h | 2 +- kernel/rcu/srcutree.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/srcutree.h b/include/linux/srcutree.h index 443d27a214ef..231de66ceb15 100644 --- a/include/linux/srcutree.h +++ b/include/linux/srcutree.h @@ -65,13 +65,13 @@ struct srcu_usage { struct srcu_node *level[RCU_NUM_LVLS + 1]; /* First node at each level. */ int srcu_size_state; /* Small-to-big transition state. */ + struct mutex srcu_cb_mutex; /* Serialize CB preparation. */ }; /* * Per-SRCU-domain structure, similar in function to rcu_state. */ struct srcu_struct { - struct mutex srcu_cb_mutex; /* Serialize CB preparation. */ spinlock_t __private lock; /* Protect counters and size state. */ struct mutex srcu_gp_mutex; /* Serialize GP work. */ unsigned int srcu_idx; /* Current rdr array element. */ diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index 8428a184d506..1814f3bfc219 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -242,7 +242,7 @@ static int init_srcu_struct_fields(struct srcu_struct *ssp, bool is_static) return -ENOMEM; ssp->srcu_sup->srcu_size_state = SRCU_SIZE_SMALL; ssp->srcu_sup->node = NULL; - mutex_init(&ssp->srcu_cb_mutex); + mutex_init(&ssp->srcu_sup->srcu_cb_mutex); mutex_init(&ssp->srcu_gp_mutex); ssp->srcu_idx = 0; ssp->srcu_gp_seq = 0; @@ -861,7 +861,7 @@ static void srcu_gp_end(struct srcu_struct *ssp) int ss_state; /* Prevent more than one additional grace period. */ - mutex_lock(&ssp->srcu_cb_mutex); + mutex_lock(&ssp->srcu_sup->srcu_cb_mutex); /* End the current grace period. */ spin_lock_irq_rcu_node(ssp); @@ -921,7 +921,7 @@ static void srcu_gp_end(struct srcu_struct *ssp) } /* Callback initiation done, allow grace periods after next. */ - mutex_unlock(&ssp->srcu_cb_mutex); + mutex_unlock(&ssp->srcu_sup->srcu_cb_mutex); /* Start a new grace period if needed. */ spin_lock_irq_rcu_node(ssp); -- 2.40.0.rc2