Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp341039rwl; Thu, 23 Mar 2023 17:21:08 -0700 (PDT) X-Google-Smtp-Source: AK7set+5+ugXopP8w3SXNcrMPTq01dA8SOHF5rm2ugRSLZpM9j4HhXkOIEtsv78D22x0Bo8ALn7v X-Received: by 2002:a17:907:6e17:b0:902:874:9c31 with SMTP id sd23-20020a1709076e1700b0090208749c31mr8634320ejc.35.1679617268034; Thu, 23 Mar 2023 17:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679617268; cv=none; d=google.com; s=arc-20160816; b=fJlXXd2wf3V/bHJ+Fz9hMJXbxTTKLguDZUZ55ya6E3r0/JEHqbrn8NeCpHkwJvM1dG mvuwN+dlCQuHAzeqtOX59alhnScNT37Y6I/YC5OfGgHiwM0D+bQisfiYWmyaRRWYavcT L8fsHIR4k5HCcNANz9zU0j8BR831QwOF9Ncq1dmfFqzdNwrLCl8vChebhwxl8xSfyq5/ O3VLpDiYzjjHbeb1+j2BOxnoOezOoFvsV2sX7T9u9C212D9dITbnz4M50n0KZ/qZHh0G MV0hva5JYnQ5JI94ZerLdm1Fosb75lk4/7PSfoIawFhJUDE/L+ca8pfCYViseHMJaPqN JlpQ== 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=Be339qI3Bq3vB8OsLaeGPTLF5B/nrT83vuWY6kGPi+g=; b=s/Obx/I2bBDXlCaWJJ/Um1GSyqvIheBu5q47QueDNxpJiG/9lJhsmpeZpFjWQ9HtLt qRxBGzTxn2rjgD4PyFcAPiZS2RMjb82F9F5+7YEUggM1R3bSbn50UZkAHRY/CohLW6/F sa01x/mWDK1j1XbCwhxAMFzAmcHrfqmrL9Y7mJufoHEakMeBRjKSgxM0ajg8oGyAScEH 2Q5QNi9s/veyBCHB8b6ruE2g6+UGKWVwujBQxgXoNp5O3xE1ECF6f3lJaaEYilOPRAcR VtVNUgSmqG+2qsX9jcGAYWdXi0LyjJ75wGd6Z9TUdrt2yz2II5lWhzR9eFEWbqpgWYh3 ajgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r0K3ytQW; 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 ue6-20020a170907c68600b009321def4b92si10705292ejc.333.2023.03.23.17.20.43; Thu, 23 Mar 2023 17:21:08 -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=r0K3ytQW; 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 S231535AbjCXAUK (ORCPT + 99 others); Thu, 23 Mar 2023 20:20:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231241AbjCXATu (ORCPT ); Thu, 23 Mar 2023 20:19:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDECA2C66C; Thu, 23 Mar 2023 17:19:43 -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 ams.source.kernel.org (Postfix) with ESMTPS id 66EAAB82245; Fri, 24 Mar 2023 00:19:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FBF4C4339C; Fri, 24 Mar 2023 00:19:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679617181; bh=l31ZVxzvsf5Mo/krVC1TzBNoZigl26axBa/w/xOsuuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r0K3ytQWk89vnjC3zZ2d7/NNM+0eQFQpeAuvXn1ohJlVwm75gD9staupAQosnD0cD BtCRxT1fsTXKJYttuZUS9by6VyUSXd2lDUDZkiG8eeXgCPDftTzjxPDNMtt/+O2bVr 14iki5/0ubn/M67CJIFC8VMafg5XIqX6MRBJcSMRYE6Epjlg25w0ZHhPljSVpNA+te bL2coV5i0P2WO3jJcb9/3lJyO5EIJXT74zeXKOBbB8VtlwT/BOZo4x9bGN/RnoQyub KtwyxYywUx7LRaRCebxaGP1iGYW+52qmpN9QrSgBB4txO+UfAGVZ5Ojet139G+fUqJ 9QFHLrS1ET53g== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 95153154039D; Thu, 23 Mar 2023 17:19:40 -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" Subject: [PATCH RFC rcu 04/19] srcu: Move ->level from srcu_struct to srcu_usage Date: Thu, 23 Mar 2023 17:19:23 -0700 Message-Id: <20230324001938.3443499-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <3db82572-f156-4a5d-b711-841aa28bd996@paulmck-laptop> References: <3db82572-f156-4a5d-b711-841aa28bd996@paulmck-laptop> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,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 ->level[] array 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 Signed-off-by: Paul E. McKenney --- include/linux/srcutree.h | 4 ++-- kernel/rcu/srcutree.c | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/srcutree.h b/include/linux/srcutree.h index 2689e64024bb..362c8f39c53d 100644 --- a/include/linux/srcutree.h +++ b/include/linux/srcutree.h @@ -62,14 +62,14 @@ struct srcu_node { */ struct srcu_usage { struct srcu_node *node; /* Combining tree. */ + struct srcu_node *level[RCU_NUM_LVLS + 1]; + /* First node at each level. */ }; /* * Per-SRCU-domain structure, similar in function to rcu_state. */ struct srcu_struct { - 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. */ spinlock_t __private lock; /* Protect counters and size state. */ diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index ad1d5ca42a99..90d753e10e33 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -178,9 +178,9 @@ static bool init_srcu_struct_nodes(struct srcu_struct *ssp, gfp_t gfp_flags) return false; /* Work out the overall tree geometry. */ - ssp->level[0] = &ssp->srcu_sup->node[0]; + ssp->srcu_sup->level[0] = &ssp->srcu_sup->node[0]; for (i = 1; i < rcu_num_lvls; i++) - ssp->level[i] = ssp->level[i - 1] + num_rcu_lvl[i - 1]; + ssp->srcu_sup->level[i] = ssp->srcu_sup->level[i - 1] + num_rcu_lvl[i - 1]; rcu_init_levelspread(levelspread, num_rcu_lvl); /* Each pass through this loop initializes one srcu_node structure. */ @@ -202,10 +202,10 @@ static bool init_srcu_struct_nodes(struct srcu_struct *ssp, gfp_t gfp_flags) } /* Non-root node. */ - if (snp == ssp->level[level + 1]) + if (snp == ssp->srcu_sup->level[level + 1]) level++; - snp->srcu_parent = ssp->level[level - 1] + - (snp - ssp->level[level]) / + snp->srcu_parent = ssp->srcu_sup->level[level - 1] + + (snp - ssp->srcu_sup->level[level]) / levelspread[level - 1]; } @@ -214,7 +214,7 @@ static bool init_srcu_struct_nodes(struct srcu_struct *ssp, gfp_t gfp_flags) * leaves of the srcu_node tree. */ level = rcu_num_lvls - 1; - snp_first = ssp->level[level]; + snp_first = ssp->srcu_sup->level[level]; for_each_possible_cpu(cpu) { sdp = per_cpu_ptr(ssp->sda, cpu); sdp->mynode = &snp_first[cpu / levelspread[level]]; @@ -889,7 +889,7 @@ static void srcu_gp_end(struct srcu_struct *ssp) srcu_for_each_node_breadth_first(ssp, snp) { spin_lock_irq_rcu_node(snp); cbs = false; - last_lvl = snp >= ssp->level[rcu_num_lvls - 1]; + last_lvl = snp >= ssp->srcu_sup->level[rcu_num_lvls - 1]; if (last_lvl) cbs = ss_state < SRCU_SIZE_BIG || snp->srcu_have_cbs[idx] == gpseq; snp->srcu_have_cbs[idx] = gpseq; -- 2.40.0.rc2