Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2183466rwl; Thu, 13 Apr 2023 02:53:44 -0700 (PDT) X-Google-Smtp-Source: AKy350ZgVXhuJfpzsYV08oQ07+7zDwI8togNciMhUGIu4fOQX21f6PS59JI8Cv5UzT31TNKxi2EI X-Received: by 2002:a05:6a00:139e:b0:632:6f:493e with SMTP id t30-20020a056a00139e00b00632006f493emr3147484pfg.10.1681379624341; Thu, 13 Apr 2023 02:53:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681379624; cv=none; d=google.com; s=arc-20160816; b=hDOfRvg8ndIiQ2qIdvw+1UWmmgELXZeCvcrVFVSVjF8Y5n7aUgeduKAAyTGm7/l0JV 6a3FlR7rWb9X8wMCUYk2BfQsQdauSd3d67Yz4ToMt1PvF0+j9nwSZf1fHf5eUeN7oOU7 F3cwvKF61UW66fswfmdw0DvhZKDQFsUB2yPBX/mog/PLyDTOPpnHguNzwt+XaUOdNKjf XMfxn6SeaWTUY7eIBPdLjewmPP4eu7WMMbv5PfwSz5knPzM9cszXN5oLo79IfWjOUHjn OkM8nk6UfKgQNIyWrTt277rzYM7KNINdAHD5lBdk9Tf6VAnOsezXFhKWkEfc+G4wiuw9 GZ6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=jkfx9TFAa3glGDYFoDghgabR+5q0/ptAJA1TQbofi5M=; b=bccPArf7xKOiIT262IoSv3ZObGqnyDtxvTgnhoRKMH3RgsFNtX5fBtetczGsMT5q38 pGn2f5vbBMDwbypFDYf8ADWkDVKmtJl37/sL+fDwl4HwMW88EZNhTwSIsm+QpJ2A7LuZ hcc7xgyD6KMoA9a6rKQyk6JOIaHzpBlXD4aKVsFwHAwapQfNR2bZ6tSt5350YZI7zAZm 2tbuleuSYFfGBMNlFgqtuXUpED2nCGCAZpbhDhBaVSsZ/ZkKCb+irFk4dni9tH+m5keX t9x9uC+At33rp8M/dNqMte0YP0DQZr/yWhVFl8j/yd8u2QJ84GQ0NxyBQalWwmK9ryGM h76Q== 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 r6-20020a63e506000000b0050126b5d089si1714301pgh.386.2023.04.13.02.53.32; Thu, 13 Apr 2023 02:53:44 -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 S229736AbjDMJuB (ORCPT + 99 others); Thu, 13 Apr 2023 05:50:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbjDMJt6 (ORCPT ); Thu, 13 Apr 2023 05:49:58 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B8ABE7AB3 for ; Thu, 13 Apr 2023 02:49:56 -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 DE4E8D75; Thu, 13 Apr 2023 02:50:40 -0700 (PDT) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F39E03F6C4; Thu, 13 Apr 2023 02:49:54 -0700 (PDT) Date: Thu, 13 Apr 2023 10:49:52 +0100 From: Sudeep Holla To: Pierre Gondois Cc: linux-kernel@vger.kernel.org, Radu Rendec , Alexandre Ghiti , Sudeep Holla , Conor Dooley , Will Deacon , Greg Kroah-Hartman , "Rafael J. Wysocki" , Palmer Dabbelt , Gavin Shan Subject: Re: [PATCH v3 4/4] cacheinfo: Add use_arch[|_cache]_info field/function Message-ID: <20230413094952.ncdldvv2ysjqwbsv@bogus> References: <20230413091436.230134-1-pierre.gondois@arm.com> <20230413091436.230134-5-pierre.gondois@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230413091436.230134-5-pierre.gondois@arm.com> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 On Thu, Apr 13, 2023 at 11:14:34AM +0200, Pierre Gondois wrote: > The cache information can be extracted from either a Device > Tree (DT), the PPTT ACPI table, or arch registers (clidr_el1 > for arm64). > > The clidr_el1 register is used only if DT/ACPI information is not > available. It does not states how caches are shared among CPUs. > > Add a use_arch_cache_info field/function to identify when the > DT/ACPI doesn't provide cache information. Use this information > to assume L1 caches are privates and L2 and higher are shared among > all CPUs. > I have tentatively merged first 3 patches along with Radu's series(waiting for build tests still before confirming). I am not yet sure on this. > Signed-off-by: Pierre Gondois > --- > drivers/base/cacheinfo.c | 13 ++++++++++++- > include/linux/cacheinfo.h | 10 ++++++++++ > 2 files changed, 22 insertions(+), 1 deletion(-) > > diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c > index 06de9a468958..49dbb4357911 100644 > --- a/drivers/base/cacheinfo.c > +++ b/drivers/base/cacheinfo.c > @@ -40,7 +40,8 @@ static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf, > * For non DT/ACPI systems, assume unique level 1 caches, > * system-wide shared caches for all other levels. > */ > - if (!(IS_ENABLED(CONFIG_OF) || IS_ENABLED(CONFIG_ACPI))) > + if (!(IS_ENABLED(CONFIG_OF) || IS_ENABLED(CONFIG_ACPI)) || > + this_leaf->use_arch_info) Can't we just use use_arch_cache_info() here ? > return (this_leaf->level != 1) && (sib_leaf->level != 1); > > if ((sib_leaf->attributes & CACHE_ID) && > @@ -349,6 +350,7 @@ static int cache_shared_cpu_map_setup(unsigned int cpu) > struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); > struct cacheinfo *this_leaf, *sib_leaf; > unsigned int index, sib_index; > + bool use_arch_info = false; > int ret = 0; > > if (this_cpu_ci->cpu_map_populated) > @@ -361,6 +363,12 @@ static int cache_shared_cpu_map_setup(unsigned int cpu) > */ > if (!last_level_cache_is_valid(cpu)) { > ret = cache_setup_properties(cpu); > + if (ret && use_arch_cache_info()) { > + // Possibility to rely on arch specific information. > + use_arch_info = true; > + ret = 0; > + } > + > if (ret) > return ret; > } > @@ -370,6 +378,9 @@ static int cache_shared_cpu_map_setup(unsigned int cpu) > > this_leaf = per_cpu_cacheinfo_idx(cpu, index); > > + if (use_arch_info) > + this_leaf->use_arch_info = true; > + > cpumask_set_cpu(cpu, &this_leaf->shared_cpu_map); > for_each_online_cpu(i) { > struct cpu_cacheinfo *sib_cpu_ci = get_cpu_cacheinfo(i); > diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h > index 908e19d17f49..fed675b251a2 100644 > --- a/include/linux/cacheinfo.h > +++ b/include/linux/cacheinfo.h > @@ -66,6 +66,7 @@ struct cacheinfo { > #define CACHE_ALLOCATE_POLICY_MASK \ > (CACHE_READ_ALLOCATE | CACHE_WRITE_ALLOCATE) > #define CACHE_ID BIT(4) > + bool use_arch_info; Do you see the need to stash this value as it is either globally true or false based on the arch ? > void *fw_token; > bool disable_sysfs; > void *priv; > @@ -129,4 +130,13 @@ static inline int get_cpu_cacheinfo_id(int cpu, int level) > return -1; > } > > +static inline bool use_arch_cache_info(void) > +{ > +#if defined(CONFIG_ARM64) > + return true; > +#else > + return false; > +#endif > +} > + Can we just have it as: #ifdef CONFIG_ARM64 #define use_arch_cache_info() (true) #else #define use_arch_cache_info() (false) #endif > #endif /* _LINUX_CACHEINFO_H */ > -- > 2.25.1 > -- Regards, Sudeep