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: <aKbspRcrEWBiox8c@lx-t490>
Date: Thu, 21 Aug 2025 11:53:41 +0200
From: "Ahmed S. Darwish" <darwi@...utronix.de>
To: K Prateek Nayak <kprateek.nayak@....com>
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
	Borislav Petkov <bp@...en8.de>,
	Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
	linux-kernel@...r.kernel.org, "H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH 0/2] x86/cpu/cacheinfo: Simplify llc_id calculation on
 AMD platforms

Hi,

On Thu, 21 Aug 2025, K Prateek Nayak wrote:
>
> Reuse the available cacheinfo helpers instead of open-coding masks and
> shifts in cacheinfo_amd_init_llc_id().
>
> This series has been tested on top of tip:x86/cpu at commit 6a42c31ef324
> ("x86/cpu: Rename and move CPU model entry for Diamond Rapids") with no
> changes being observed in "/sys/kernel/debug/x86/topo/" on a 3rd
> Generation EPYC platform.
>

I had to merge the diff of the two patches to get what was going on.

My only comment would be:

> --- a/arch/x86/kernel/cpu/cacheinfo.c
> +++ b/arch/x86/kernel/cpu/cacheinfo.c
> ...
> +/*
> + * The max shared threads number comes from CPUID(0x4) EAX[25-14] with input
> + * ECX as cache index. Then right shift apicid by the number's order to get
> + * cache id for this cache node.
> + */
> +static unsigned int get_cache_id(u32 apicid, struct _cpuid4_info *id4)
> +{
> +	unsigned long num_threads_sharing;
> +	int index_msb;
> +
> +	num_threads_sharing = 1 + id4->eax.split.num_threads_sharing;
> +	index_msb = get_count_order(num_threads_sharing);
> +	return apicid >> index_msb;
> +}
> +
...
> -/*
> - * The max shared threads number comes from CPUID(0x4) EAX[25-14] with input
> - * ECX as cache index. Then right shift apicid by the number's order to get
> - * cache id for this cache node.
> - */
> -static void get_cache_id(int cpu, struct _cpuid4_info *id4)
> -{
> -	struct cpuinfo_x86 *c = &cpu_data(cpu);
> -	unsigned long num_threads_sharing;
> -	int index_msb;
> -
> -	num_threads_sharing = 1 + id4->eax.split.num_threads_sharing;
> -	index_msb = get_count_order(num_threads_sharing);
> -	id4->id = c->topo.apicid >> index_msb;
> -}
> -
...

Since you don't write to 'id4' anymore, please make the pointer constant.
It helps with code comprehension: from a quick glance, one knows that the
function does not write to the passed structure.

Other than that, and possibly merging the two patches (if you want to):

Acked-by: Ahmed S. Darwish <darwi@...utronix.de>

Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ