Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp266417rwl; Thu, 30 Mar 2023 15:49:22 -0700 (PDT) X-Google-Smtp-Source: AKy350aoZliivMJrbXPcDeyWLd6VLfgwhUp5fYHGuiHZkXs7AQQGPyiQ/c0SA4XVLeOMbVNRKl6a X-Received: by 2002:a17:906:207:b0:933:23c4:820b with SMTP id 7-20020a170906020700b0093323c4820bmr3274565ejd.4.1680216561840; Thu, 30 Mar 2023 15:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680216561; cv=none; d=google.com; s=arc-20160816; b=HkGt17frX8WJPswmT10S2Y9o9dDS/HDD2IDjvO/asptJAelyDqNep4BaQoLPLElXSG mJNf9qFTMRS40TndkXZ7jHdCL+y2T4CLGrx6wW5rlQHRZpVe+JwjA5KTN2rew+NQhW3o 2x9raI7Mmf9ekxUyRkV170th7T1n2OGX0mqaoUMJHhmxoeVzINjnclvm9exnWUvmSdWM bUUhW+UTgAVDIU+VDnOepjMUbnAO3MiVp6FpYVR4VDvlwM+Ie5uKS+0uAvPOh5eQjzVG ezTVD5STaGibJVD3qDOTRapj814k0KcQEMbWyOm/bI42N1G7OpPLuRo9Td+jIhzn7wOP AOyA== 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=6OwMjonrPl+9rqmLWWxJWgR8JvI1R/aSuPUkiOn214c=; b=bKZhG1gJODXH6wjsmZ8vEubJ49wK3qHWweS09A/jGGMhfn63mtGTrhZAZPmZBlJJIt t1f1uqqJyKuNBl201Z+K4Ucp8pbUdk8U+2M6Zc4/Oh+dyBfrAq6S/22l4rDR2Xutc0W9 CtQK2hhrb6kqxlx4QJgzyoJASLRxXvYo2qYksU15piCV/s+TGomwdFNkkrQhdB6ocgfM vEAaY4B+RuDtjijBKT3Eb+CuyN/MU9ebcZOOfImIrRJFVuWP+X582/cijw7xJx6/ZrmV r7BEH8gk5nutoLAsiV+L/KTMEWATJ5arF5o/u3TFye/CueyfhojY4xScl8Q663ZH1ssv kS9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aVtFclAc; 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 e10-20020a170906c00a00b00935358c2ed6si596027ejz.398.2023.03.30.15.48.55; Thu, 30 Mar 2023 15:49:21 -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=aVtFclAc; 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 S231360AbjC3Ws2 (ORCPT + 99 others); Thu, 30 Mar 2023 18:48:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231135AbjC3Wr4 (ORCPT ); Thu, 30 Mar 2023 18:47:56 -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 ED68612852; Thu, 30 Mar 2023 15:47:35 -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 B3D4C621D9; Thu, 30 Mar 2023 22:47:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9766C433AC; 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=VVkUnY0uv7jk+b59+oVZrqwrjNkvSKi6rJLly8DwwsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aVtFclAcBAfx2ZFcDv0cCYBZoUwHDWPGOtfetvXwDp0KpsoJXb+MF/ZdPX3J1l6h9 oj7FXiVK0gc76XDa0MSRwoOiAV94xxsXhi2ftUOLP7x6ZFrMu/XutqJcT7/Yw2nWX9 GbNcVAmg20z07VWuvdDpelYQjpzFVoLgKIZJiqNp4eQmavOA54g3Y10FfxzMf/HJl3 IVuMLQ2UpMZ1xlqX9/uiN0KIFTD/KI18nOGsdhxJOaw765+D3Kosn9kMbgVnC5cFY6 sZUJa5CDJEwyFXzmxySx4os/hqxCtMkRsLvo6AEWaNw98LMg6jfFh5E8aGNCNllw49 Zuu83oM/iS1vw== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 1ED4C1540486; 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 10/20] srcu: Move ->srcu_gp_mutex from srcu_struct to srcu_usage Date: Thu, 30 Mar 2023 15:47:16 -0700 Message-Id: <20230330224726.662344-10-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_gp_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 | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/srcutree.h b/include/linux/srcutree.h index 694d87b81917..d04e3da6181c 100644 --- a/include/linux/srcutree.h +++ b/include/linux/srcutree.h @@ -67,13 +67,13 @@ struct srcu_usage { int srcu_size_state; /* Small-to-big transition state. */ 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. */ }; /* * Per-SRCU-domain structure, similar in function to rcu_state. */ struct srcu_struct { - struct mutex srcu_gp_mutex; /* Serialize GP work. */ unsigned int srcu_idx; /* Current rdr array element. */ unsigned long srcu_gp_seq; /* Grace-period seq #. */ unsigned long srcu_gp_seq_needed; /* Latest gp_seq needed. */ diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index c42248cf18f6..a36066798de7 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -245,7 +245,7 @@ static int init_srcu_struct_fields(struct srcu_struct *ssp, bool is_static) ssp->srcu_sup->srcu_size_state = SRCU_SIZE_SMALL; ssp->srcu_sup->node = NULL; mutex_init(&ssp->srcu_sup->srcu_cb_mutex); - mutex_init(&ssp->srcu_gp_mutex); + mutex_init(&ssp->srcu_sup->srcu_gp_mutex); ssp->srcu_idx = 0; ssp->srcu_gp_seq = 0; ssp->srcu_barrier_seq = 0; @@ -876,7 +876,7 @@ static void srcu_gp_end(struct srcu_struct *ssp) if (ULONG_CMP_LT(ssp->srcu_gp_seq_needed_exp, gpseq)) WRITE_ONCE(ssp->srcu_gp_seq_needed_exp, gpseq); spin_unlock_irq_rcu_node(ssp->srcu_sup); - mutex_unlock(&ssp->srcu_gp_mutex); + mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex); /* A new grace period can start at this point. But only one. */ /* Initiate callback invocation as needed. */ @@ -1585,7 +1585,7 @@ static void srcu_advance_state(struct srcu_struct *ssp) { int idx; - mutex_lock(&ssp->srcu_gp_mutex); + mutex_lock(&ssp->srcu_sup->srcu_gp_mutex); /* * Because readers might be delayed for an extended period after @@ -1603,7 +1603,7 @@ static void srcu_advance_state(struct srcu_struct *ssp) if (ULONG_CMP_GE(ssp->srcu_gp_seq, ssp->srcu_gp_seq_needed)) { WARN_ON_ONCE(rcu_seq_state(ssp->srcu_gp_seq)); spin_unlock_irq_rcu_node(ssp->srcu_sup); - mutex_unlock(&ssp->srcu_gp_mutex); + mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex); return; } idx = rcu_seq_state(READ_ONCE(ssp->srcu_gp_seq)); @@ -1611,7 +1611,7 @@ static void srcu_advance_state(struct srcu_struct *ssp) srcu_gp_start(ssp); spin_unlock_irq_rcu_node(ssp->srcu_sup); if (idx != SRCU_STATE_IDLE) { - mutex_unlock(&ssp->srcu_gp_mutex); + mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex); return; /* Someone else started the grace period. */ } } @@ -1619,7 +1619,7 @@ static void srcu_advance_state(struct srcu_struct *ssp) if (rcu_seq_state(READ_ONCE(ssp->srcu_gp_seq)) == SRCU_STATE_SCAN1) { idx = 1 ^ (ssp->srcu_idx & 1); if (!try_check_zero(ssp, idx, 1)) { - mutex_unlock(&ssp->srcu_gp_mutex); + mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex); return; /* readers present, retry later. */ } srcu_flip(ssp); @@ -1637,7 +1637,7 @@ static void srcu_advance_state(struct srcu_struct *ssp) */ idx = 1 ^ (ssp->srcu_idx & 1); if (!try_check_zero(ssp, idx, 2)) { - mutex_unlock(&ssp->srcu_gp_mutex); + mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex); return; /* readers present, retry later. */ } ssp->srcu_n_exp_nodelay = 0; -- 2.40.0.rc2