Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3641805ioo; Wed, 25 May 2022 05:14:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJtwQngLDhRcIYFQjCjoaqiDE3r7fuHh+TDzYfFWPE/aqslC6XfFNZ3oefoOOJvCT6uCN4 X-Received: by 2002:a17:90b:4c4a:b0:1df:9cbf:879f with SMTP id np10-20020a17090b4c4a00b001df9cbf879fmr10010141pjb.84.1653480858774; Wed, 25 May 2022 05:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653480858; cv=none; d=google.com; s=arc-20160816; b=0707ngUpipNuMW+o/qEUFy6HY779nOoFxL2CEx0cYj3bk8j6zZa/LB2Rcbxl0lRRC3 Bx1aUvXtHuRIjRiJMfBcixhBJVQAj4pKtfRDKQREDsA5nOtFRXv3BqNyhqwhKk8rEVzu QX53IP9OKEVQZGxY0AL4lsw0hFIzZNRSIN9zGqD2Pk/5dNNmnLzXzSYDS8QpyG4Fq62o CK4JYvR+iSLI7+y7idudjD4OE6+xJ0a24tIeuHV/0baufwJ5mZ8CIBgNS3HUnY8FkJge YyqnIQXtnabmkPNShyfamoQ0mMHoMrGZSPUMx3wi5QJ6+mcP7wDFp4E87ckheD/WQdWq MZ+A== 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; bh=GvEyaSecIunHwviRmB0x6VK4CTTvFk0fNKDAuyceZ4k=; b=hUWXci/AH0TaN7btQDvJJQ1VQI5dt1+4GSSp3Xr5DyQ+TmVZ5S5LJ3kHAZGmysC8eN peaHK6XNHetUn7mB5UggkHDV90x0BhD7Ydw/Gim4EltlOHup2EL+iVa2fFnpTdxvgWQg 9b7xqMHUwf33S/fqwlbIqFCmwqBQw7ULQqeH2zqr/IAk3rmlvpKH1JAQn+9K3NLPaxSF rLhQ8SHRwzE7cMyKwBjNVBFnCD0AnxeAm4+KuzaC8YNlV6Lk/3pRT44xKIhnmZcuNLKN GcwDVvNmSXKM/ZOZD64Ab3EHyTNNsL+rBFqufPJC+jrX3rfz7zenPsB2DIn3A/UDHndk 0uAw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r204-20020a632bd5000000b003c1d56c081bsi16050117pgr.212.2022.05.25.05.14.05; Wed, 25 May 2022 05:14:18 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236781AbiEYIOs (ORCPT + 99 others); Wed, 25 May 2022 04:14:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236258AbiEYIOh (ORCPT ); Wed, 25 May 2022 04:14:37 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 420697CDD3 for ; Wed, 25 May 2022 01:14:36 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E3E361042; Wed, 25 May 2022 01:14:35 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 427F33F73D; Wed, 25 May 2022 01:14:34 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , Atish Patra , Atish Patra , Vincent Guittot , Morten Rasmussen , Dietmar Eggemann , Qing Wang , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, Rob Herring Subject: [PATCH v3 02/16] cacheinfo: Add helper to access any cache index for a given CPU Date: Wed, 25 May 2022 09:14:02 +0100 Message-Id: <20220525081416.3306043-3-sudeep.holla@arm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220525081416.3306043-2-sudeep.holla@arm.com> References: <20220525081416.3306043-1-sudeep.holla@arm.com> <20220525081416.3306043-2-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 The cacheinfo for a given CPU at a given index is used at quite a few places by fetching the base point for index 0 using the helper per_cpu_cacheinfo(cpu) and offseting it by the required index. Instead, add another helper to fetch the required pointer directly and use it to simplify and improve readability. Signed-off-by: Sudeep Holla --- drivers/base/cacheinfo.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index b0bde272e2ae..c4547d8ac6f3 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -25,6 +25,8 @@ static DEFINE_PER_CPU(struct cpu_cacheinfo, ci_cpu_cacheinfo); #define ci_cacheinfo(cpu) (&per_cpu(ci_cpu_cacheinfo, cpu)) #define cache_leaves(cpu) (ci_cacheinfo(cpu)->num_leaves) #define per_cpu_cacheinfo(cpu) (ci_cacheinfo(cpu)->info_list) +#define per_cpu_cacheinfo_idx(cpu, idx) \ + (per_cpu_cacheinfo(cpu) + (idx)) struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu) { @@ -172,7 +174,7 @@ static int cache_setup_of_node(unsigned int cpu) } while (index < cache_leaves(cpu)) { - this_leaf = this_cpu_ci->info_list + index; + this_leaf = per_cpu_cacheinfo_idx(cpu, index); if (this_leaf->level != 1) np = of_find_next_cache_node(np); else @@ -231,7 +233,7 @@ static int cache_shared_cpu_map_setup(unsigned int cpu) for (index = 0; index < cache_leaves(cpu); index++) { unsigned int i; - this_leaf = this_cpu_ci->info_list + index; + this_leaf = per_cpu_cacheinfo_idx(cpu, index); /* skip if shared_cpu_map is already populated */ if (!cpumask_empty(&this_leaf->shared_cpu_map)) continue; @@ -242,7 +244,7 @@ static int cache_shared_cpu_map_setup(unsigned int cpu) if (i == cpu || !sib_cpu_ci->info_list) continue;/* skip if itself or no cacheinfo */ - sib_leaf = sib_cpu_ci->info_list + index; + sib_leaf = per_cpu_cacheinfo_idx(i, index); if (cache_leaves_are_shared(this_leaf, sib_leaf)) { cpumask_set_cpu(cpu, &sib_leaf->shared_cpu_map); cpumask_set_cpu(i, &this_leaf->shared_cpu_map); @@ -258,12 +260,11 @@ static int cache_shared_cpu_map_setup(unsigned int cpu) static void cache_shared_cpu_map_remove(unsigned int cpu) { - struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); struct cacheinfo *this_leaf, *sib_leaf; unsigned int sibling, index; for (index = 0; index < cache_leaves(cpu); index++) { - this_leaf = this_cpu_ci->info_list + index; + this_leaf = per_cpu_cacheinfo_idx(cpu, index); for_each_cpu(sibling, &this_leaf->shared_cpu_map) { struct cpu_cacheinfo *sib_cpu_ci; @@ -609,7 +610,6 @@ static int cache_add_dev(unsigned int cpu) int rc; struct device *ci_dev, *parent; struct cacheinfo *this_leaf; - struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); const struct attribute_group **cache_groups; rc = cpu_cache_sysfs_init(cpu); @@ -618,7 +618,7 @@ static int cache_add_dev(unsigned int cpu) parent = per_cpu_cache_dev(cpu); for (i = 0; i < cache_leaves(cpu); i++) { - this_leaf = this_cpu_ci->info_list + i; + this_leaf = per_cpu_cacheinfo_idx(cpu, i); if (this_leaf->disable_sysfs) continue; if (this_leaf->type == CACHE_TYPE_NOCACHE) -- 2.36.1