lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bf63ca22-944d-b709-242f-fd09c66ff519@redhat.com>
Date:   Wed, 1 Jun 2022 11:20:12 +0800
From:   Gavin Shan <gshan@...hat.com>
To:     Sudeep Holla <sudeep.holla@....com>, linux-kernel@...r.kernel.org
Cc:     Atish Patra <atishp@...shpatra.org>,
        Atish Patra <atishp@...osinc.com>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        Morten Rasmussen <morten.rasmussen@....com>,
        Dietmar Eggemann <dietmar.eggemann@....com>,
        Qing Wang <wangqing@...o.com>,
        linux-arm-kernel@...ts.infradead.org,
        linux-riscv@...ts.infradead.org, Rob Herring <robh+dt@...nel.org>
Subject: Re: [PATCH v3 04/16] cacheinfo: Add support to check if last level
 cache(LLC) is valid or shared

Hi Sudeep,

On 5/25/22 4:14 PM, Sudeep Holla wrote:
> It is useful to have helper to check if the given two CPUs share last level
> cache. We can do that check by comparing fw_token or by comparing the cache
> ID. Currently we check just for fw_token as the cache ID is optional.
> 
> This helper can be used to build the llc_sibling during arch specific
> topology parsing and feeding information to the sched_domains. This also
> helps to get rid of llc_id in the CPU topology as it is sort of duplicate
> information.
> 
> Also add helper to check if the llc information in cacheinfo is valid or not.
> 
> Signed-off-by: Sudeep Holla <sudeep.holla@....com>
> ---
>   drivers/base/cacheinfo.c  | 26 ++++++++++++++++++++++++++
>   include/linux/cacheinfo.h |  2 ++
>   2 files changed, 28 insertions(+)
> 

With below nits fixed:

Reviewed-by: Gavin Shan <gshan@...hat.com>

> diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
> index 417e1ebf5525..ed74db18468f 100644
> --- a/drivers/base/cacheinfo.c
> +++ b/drivers/base/cacheinfo.c
> @@ -47,6 +47,32 @@ static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf,
>   	return sib_leaf->fw_token == this_leaf->fw_token;
>   }
>   
> +bool last_level_cache_is_valid(unsigned int cpu)
> +{
> +	struct cacheinfo *llc;
> +
> +	if (!cache_leaves(cpu))
> +		return false;
> +
> +	llc = per_cpu_cacheinfo_idx(cpu, cache_leaves(cpu) - 1);
> +
> +	return llc->fw_token;
> +}
> +

	return !!llc->fw_token;

> +bool last_level_cache_is_shared(unsigned int cpu_x, unsigned int cpu_y)
> +{
> +	struct cacheinfo *llc_x, *llc_y;
> +
> +	if (!last_level_cache_is_valid(cpu_x) ||
> +	    !last_level_cache_is_valid(cpu_y))
> +		return false;
> +
> +	llc_x = per_cpu_cacheinfo_idx(cpu_x, cache_leaves(cpu_x) - 1);
> +	llc_y = per_cpu_cacheinfo_idx(cpu_y, cache_leaves(cpu_y) - 1);
> +
> +	return cache_leaves_are_shared(llc_x, llc_y);
> +}
> +
>   #ifdef CONFIG_OF
>   /* OF properties to query for a given cache type */
>   struct cache_type_info {
> diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h
> index 4ff37cb763ae..7e429bc5c1a4 100644
> --- a/include/linux/cacheinfo.h
> +++ b/include/linux/cacheinfo.h
> @@ -82,6 +82,8 @@ struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu);
>   int init_cache_level(unsigned int cpu);
>   int populate_cache_leaves(unsigned int cpu);
>   int cache_setup_acpi(unsigned int cpu);
> +bool last_level_cache_is_valid(unsigned int cpu);
> +bool last_level_cache_is_shared(unsigned int cpu_x, unsigned int cpu_y);
>   #ifndef CONFIG_ACPI_PPTT
>   /*
>    * acpi_find_last_cache_level is only called on ACPI enabled
> 

Thanks,
Gavin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ