2023-11-21 09:32:38

by Yicong Yang

[permalink] [raw]
Subject: [PATCH v4 0/4] Support SMT control on arm64

From: Yicong Yang <[email protected]>

The core CPU control framework supports runtime SMT control which
is not yet supported on arm64. Besides the general vulnerabilities
concerns we want this runtime control on our arm64 server for:

- better single CPU performance in some cases
- saving overall power consumption

This patchset implements it in the following aspects:

- implements the basic support in arch_topology driver
- support retrieve SMT thread number on OF based system
- support retrieve SMT thread number on ACPI based system
- select HOTPLUG_SMT for arm64

Tests has been done on our real ACPI based arm64 server and on
ACPI/OF based QEMU VMs.

The patchset is based on v6.7-rc1.

Change since v3:
- Fix some build and kconfig error reported by kernel test robot <[email protected]>
Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/

Change since v2:
- Detect SMT thread number at topology build from ACPI/DT, avoid looping CPUs
- Split patches into ACPI/OF/arch_topology path and enable the kconfig for arm64
Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/

Yicong Yang (4):
arch_topology: Support basic SMT control for the driver
arch_topology: Support SMT control for OF based system
arm64: topology: Support SMT control on ACPI based system
arm64: Kconfig: Enable HOTPLUG_SMT

arch/arm64/Kconfig | 1 +
arch/arm64/kernel/topology.c | 23 ++++++++++++++++++
drivers/base/arch_topology.c | 45 +++++++++++++++++++++++++++++++++++
include/linux/arch_topology.h | 14 +++++++++++
4 files changed, 83 insertions(+)

--
2.24.0


2023-11-30 06:57:15

by Yicong Yang

[permalink] [raw]
Subject: Re: [PATCH v4 0/4] Support SMT control on arm64

Hi Sudeep, Catalin, Will and ARM folks,

Any comments? Appreciate for any feedbacks.

Thanks.

On 2023/11/21 17:25, Yicong Yang wrote:
> From: Yicong Yang <[email protected]>
>
> The core CPU control framework supports runtime SMT control which
> is not yet supported on arm64. Besides the general vulnerabilities
> concerns we want this runtime control on our arm64 server for:
>
> - better single CPU performance in some cases
> - saving overall power consumption
>
> This patchset implements it in the following aspects:
>
> - implements the basic support in arch_topology driver
> - support retrieve SMT thread number on OF based system
> - support retrieve SMT thread number on ACPI based system
> - select HOTPLUG_SMT for arm64
>
> Tests has been done on our real ACPI based arm64 server and on
> ACPI/OF based QEMU VMs.
>
> The patchset is based on v6.7-rc1.
>
> Change since v3:
> - Fix some build and kconfig error reported by kernel test robot <[email protected]>
> Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/
>
> Change since v2:
> - Detect SMT thread number at topology build from ACPI/DT, avoid looping CPUs
> - Split patches into ACPI/OF/arch_topology path and enable the kconfig for arm64
> Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/
>
> Yicong Yang (4):
> arch_topology: Support basic SMT control for the driver
> arch_topology: Support SMT control for OF based system
> arm64: topology: Support SMT control on ACPI based system
> arm64: Kconfig: Enable HOTPLUG_SMT
>
> arch/arm64/Kconfig | 1 +
> arch/arm64/kernel/topology.c | 23 ++++++++++++++++++
> drivers/base/arch_topology.c | 45 +++++++++++++++++++++++++++++++++++
> include/linux/arch_topology.h | 14 +++++++++++
> 4 files changed, 83 insertions(+)
>

2023-12-11 13:16:31

by Will Deacon

[permalink] [raw]
Subject: Re: [PATCH v4 0/4] Support SMT control on arm64

On Tue, Nov 21, 2023 at 05:25:58PM +0800, Yicong Yang wrote:
> From: Yicong Yang <[email protected]>
>
> The core CPU control framework supports runtime SMT control which
> is not yet supported on arm64. Besides the general vulnerabilities
> concerns we want this runtime control on our arm64 server for:
>
> - better single CPU performance in some cases
> - saving overall power consumption
>
> This patchset implements it in the following aspects:
>
> - implements the basic support in arch_topology driver
> - support retrieve SMT thread number on OF based system
> - support retrieve SMT thread number on ACPI based system
> - select HOTPLUG_SMT for arm64
>
> Tests has been done on our real ACPI based arm64 server and on
> ACPI/OF based QEMU VMs.
>
> The patchset is based on v6.7-rc1.
>
> Change since v3:
> - Fix some build and kconfig error reported by kernel test robot <[email protected]>
> Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/
>
> Change since v2:
> - Detect SMT thread number at topology build from ACPI/DT, avoid looping CPUs
> - Split patches into ACPI/OF/arch_topology path and enable the kconfig for arm64
> Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/
>
> Yicong Yang (4):
> arch_topology: Support basic SMT control for the driver
> arch_topology: Support SMT control for OF based system

Looking at the first two patches you have here, they are incredibly trivial
and feel like they'd be better off implemented as the default behaviour in
the core code so that architectures with additional constraints (e.g. x86)
can override that.

Will

2023-12-14 11:41:40

by Yicong Yang

[permalink] [raw]
Subject: Re: [PATCH v4 0/4] Support SMT control on arm64

Hi Will,

On 2023/12/11 21:16, Will Deacon wrote:
> On Tue, Nov 21, 2023 at 05:25:58PM +0800, Yicong Yang wrote:
>> From: Yicong Yang <[email protected]>
>>
>> The core CPU control framework supports runtime SMT control which
>> is not yet supported on arm64. Besides the general vulnerabilities
>> concerns we want this runtime control on our arm64 server for:
>>
>> - better single CPU performance in some cases
>> - saving overall power consumption
>>
>> This patchset implements it in the following aspects:
>>
>> - implements the basic support in arch_topology driver
>> - support retrieve SMT thread number on OF based system
>> - support retrieve SMT thread number on ACPI based system
>> - select HOTPLUG_SMT for arm64
>>
>> Tests has been done on our real ACPI based arm64 server and on
>> ACPI/OF based QEMU VMs.
>>
>> The patchset is based on v6.7-rc1.
>>
>> Change since v3:
>> - Fix some build and kconfig error reported by kernel test robot <[email protected]>
>> Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/
>>
>> Change since v2:
>> - Detect SMT thread number at topology build from ACPI/DT, avoid looping CPUs
>> - Split patches into ACPI/OF/arch_topology path and enable the kconfig for arm64
>> Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/
>>
>> Yicong Yang (4):
>> arch_topology: Support basic SMT control for the driver
>> arch_topology: Support SMT control for OF based system
>
> Looking at the first two patches you have here, they are incredibly trivial
> and feel like they'd be better off implemented as the default behaviour in
> the core code so that architectures with additional constraints (e.g. x86)
> can override that.
>

Loop Thomas and Peter in and expect some hint on the SMT HOTPLUG implementation.

Thanks for the comments. I'm a bit uncertain of some points.

Currently the framework requires the architeture provide 2 things to enable HOTPLUG_SMT:
1. In the init stage of the arch code, use cpu_smt_set_num_threads() to tell the framework
SMT is supported or not and how many threads are within a core.
2. topology_is_primary_thread() to indicate one CPU can be offline or not, when disable SMT.

For the 2nd point, it's possible to provide a weak function in the framework if no special
requirement for the "primary" SMT thread, just make the 1st CPU in a physical core as the
primary thread like what implemented in this patchset for amr64. And let architectures like
x86/powerpc to provides override function for special purpose.

For the 1st point I'm not sure it could/should be done in the framework since we can got this
SMT information only in the init stage after we parsing the topology which is rather architecture
specific. On arm64 we may gain this after parsing the devicetree or ACPI and on x86 they gain
this by CPUID. It's hard to provide a default way for detecting this. So in this patchset the
SMT information is detected separately in the ACPI/OF topology parsing.

Thanks.