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: <20251110160440.000054c6@huawei.com>
Date: Mon, 10 Nov 2025 16:04:40 +0000
From: Jonathan Cameron <jonathan.cameron@...wei.com>
To: Ben Horgan <ben.horgan@....com>
CC: <james.morse@....com>, <amitsinght@...vell.com>,
	<baisheng.gao@...soc.com>, <baolin.wang@...ux.alibaba.com>,
	<bobo.shaobowang@...wei.com>, <carl@...amperecomputing.com>,
	<catalin.marinas@....com>, <dakr@...nel.org>, <dave.martin@....com>,
	<david@...hat.com>, <dfustini@...libre.com>, <fenghuay@...dia.com>,
	<gregkh@...uxfoundation.org>, <gshan@...hat.com>, <guohanjun@...wei.com>,
	<jeremy.linton@....com>, <kobak@...dia.com>, <lcherian@...vell.com>,
	<lenb@...nel.org>, <linux-acpi@...r.kernel.org>,
	<linux-arm-kernel@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
	<lpieralisi@...nel.org>, <peternewman@...gle.com>, <quic_jiles@...cinc.com>,
	<rafael@...nel.org>, <robh@...nel.org>, <rohit.mathew@....com>,
	<scott@...amperecomputing.com>, <sdonthineni@...dia.com>,
	<sudeep.holla@....com>, <tan.shaopeng@...itsu.com>, <will@...nel.org>,
	<xhao@...ux.alibaba.com>
Subject: Re: [PATCH 05/33] ACPI / PPTT: Add a helper to fill a cpumask from
 a cache_id

On Fri, 7 Nov 2025 12:34:22 +0000
Ben Horgan <ben.horgan@....com> wrote:

> From: James Morse <james.morse@....com>
> 
> MPAM identifies CPUs by the cache_id in the PPTT cache structure.
> 
> The driver needs to know which CPUs are associated with the cache.
> The CPUs may not all be online, so cacheinfo does not have the
> information.
> 
> Add a helper to pull this information out of the PPTT.
> 
> CC: Rohit Mathew <Rohit.Mathew@....com>
> Signed-off-by: James Morse <james.morse@....com>
> Signed-off-by: Ben Horgan <ben.horgan@....com>

Very similar comments to on previous.

> ---
> Changes since v3:
> Equivalent changes to the previous patch:
>  Tags dropped due to rework
>  Fallout/simplification from adding acpi_pptt_cache_v1_full
>  Look for each cache type before incrementing level
> ---
>  drivers/acpi/pptt.c  | 62 ++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/acpi.h |  6 +++++
>  2 files changed, 68 insertions(+)
> 
> diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
> index 71841c106020..7b4cb17c12c0 100644
> --- a/drivers/acpi/pptt.c
> +++ b/drivers/acpi/pptt.c
> @@ -981,3 +981,65 @@ int find_acpi_cache_level_from_id(u32 cache_id)
>  
>  	return -ENOENT;
>  }
> +
> +/**
> + * acpi_pptt_get_cpumask_from_cache_id() - Get the cpus associated with the
> + *					   specified cache
> + * @cache_id: The id field of the cache
> + * @cpus: Where to build the cpumask
> + *
> + * Determine which CPUs are below this cache in the PPTT. This allows the property
> + * to be found even if the CPUs are offline.
> + *
> + * The PPTT table must be rev 3 or later,
> + *
> + * Return: -ENOENT if the PPTT doesn't exist, or the cache cannot be found.
> + * Otherwise returns 0 and sets the cpus in the provided cpumask.
> + */
> +int acpi_pptt_get_cpumask_from_cache_id(u32 cache_id, cpumask_t *cpus)
> +{
> +	int cpu;
> +	struct acpi_table_header *table;
> +
> +	cpumask_clear(cpus);
> +
> +	table = acpi_get_pptt();
> +	if (!table)
> +		return -ENOENT;
> +
> +	if (table->revision < 3)
> +		return -ENOENT;
> +
> +	for_each_possible_cpu(cpu) {
> +		bool not_empty = true;

Basically same comments.  This dance of setting it not_empty to
get into the loop is a bit nasty as it means that variable is
briefly has an alternative meaning the name doesn't convey.

A do/while() doesn't have that problem as we always do one iteration.


> +		u32 acpi_cpu_id;
> +		struct acpi_pptt_cache_v1_full *cache;
> +		struct acpi_pptt_processor *cpu_node;
> +
> +		acpi_cpu_id = get_acpi_id_for_cpu(cpu);
> +		cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
> +		if (!cpu_node)
> +			continue;
> +
> +		for (int level = 1; not_empty; level++) {
> +			int cache_type[] = {CACHE_TYPE_INST, CACHE_TYPE_DATA, CACHE_TYPE_UNIFIED};
> +
> +			not_empty = false;
> +			for (int i = 0; i < ARRAY_SIZE(cache_type); i++) {
> +				cache = acpi_find_cache_node(table, acpi_cpu_id, cache_type[i],
> +							     level, &cpu_node);
> +
> +				if (!cache)
> +					continue;
> +
> +				not_empty = true;
> +
> +				if (acpi_pptt_cache_id_is_valid(cache) &&
> +				    cache->extra.cache_id == cache_id)
> +					cpumask_set_cpu(cpu, cpus);
> +			}
> +		}
> +	}
> +
> +	return 0;
> +}



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ