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: <875xglntx1.ffs@tglx>
Date: Tue, 24 Jun 2025 15:36:10 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: Li Chen <me@...ux.beauty>, Ingo Molnar <mingo@...hat.com>, Borislav
 Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
 x86@...nel.org, "H . Peter Anvin" <hpa@...or.com>, "Rafael J . Wysocki"
 <rafael.j.wysocki@...el.com>, Peter Zijlstra <peterz@...radead.org>, K
 Prateek Nayak <kprateek.nayak@....com>, Sohil Mehta
 <sohil.mehta@...el.com>, Brian Gerst <brgerst@...il.com>, Patryk Wlazlyn
 <patryk.wlazlyn@...ux.intel.com>, linux-kernel@...r.kernel.org, "Gautham
 R. Shenoy" <gautham.shenoy@....com>, Li Chen <chenl311@...natelecom.cn>
Subject: Re: [PATCH 2/2] x86/smpboot: avoid SMT domain attach/destroy if SMT
 is not enabled

On Tue, Jun 24 2025 at 16:08, Li Chen wrote:
> From: Li Chen <chenl311@...natelecom.cn>
>
> Currently, the SMT domain is added into sched_domain_topology
> by default if CONFIG_SCHED_SMT is enabled.
>
> If cpu_attach_domain finds that the CPU SMT domain’s cpumask_weight

If cpu_attach_domain()

IIRC, I told you that before.

> is just 1, it will destroy_sched_domain it.
>
> On a large machine, such as one with 512 cores, this results in
> 512 redundant domain attach/destroy operations.
>
> We can avoid these unnecessary operations by simply checking

s/We can avoid/Avoid/

Care to read my reviews? If you disagree, then discuss it with me, but
silently ignoring it them is not an option.

> cpu_smt_num_threads and not inserting SMT domain into x86_topology if SMT

not inserting? That's not what this new version does.

> +static void __init maybe_remove_smt_level(void)
> +{
> +	if (cpu_smt_num_threads <= 1) {
> +		/*
> +		 * SMT level is x86_topology[0].  Shift the array left by one,
> +		 * keep the sentinel { NULL } at the end.
> +		 */
> +		memmove(&x86_topology[0], &x86_topology[1],
> +			sizeof(x86_topology) - sizeof(x86_topology[0]));
> +		memset(&x86_topology[ARRAY_SIZE(x86_topology) - 1], 0,
> +		       sizeof(x86_topology[0]));

So this sets the last entry in the array, aka the original sentinel in
the last array entry, to zero...

This is completely pointless. The above memmove() copies

	topo[1 .. (N - 1)] 
to
	topo[0 .. (N - 2)]

Where N = ARRAY_SIZE(topo).

Therefore
        topo[N - 1] == NULL
and
        topo[N - 2] == NULL

No?

But then what's worse is that you fail to take that removal into account
for the x86_has_numa_in_package case, which still unconditionally sets
topo[N - 2] to zero even if the SMT level had been removed...

Please take your time and do not rush out half baked stuff.

Thanks,

        tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ