Skip to contentSkip to conversation

intel_powerclamp: New module parameter

PATCH Superseded Srinivas Pandruvada 3 participants 10 messages Feb 5, 2023 – Feb 7, 2023

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover intel_powerclamp: New module parameter

Split from the series for powerclamp user of powercap idle-inject.

v2
- Build warnings reported by Rui
- Moved the powerclamp documentation to admin guide folder
- Commit log updated as suggested by Rafael and other code suggestion

Srinivas Pandruvada (2):
Documentation:admin-guide: Move intel_powerclamp documentation thermal/drivers/intel_powerclamp: Add two module parameters

 Documentation/admin-guide/index.rst           |   1 +
 .../thermal/intel_powerclamp.rst              |  22 +++
 Documentation/driver-api/thermal/index.rst    |   1 -
 MAINTAINERS                                   |   1 +
 drivers/thermal/intel/intel_powerclamp.c      | 177 +++++++++++++++---
 5 files changed, 180 insertions(+), 22 deletions(-)
 rename Documentation/{driver-api => admin-guide}/thermal/intel_powerclamp.rst (93%)
Signature · 1 line
2.39.1
#1 lore raw

PATCH v2 1/2 Documentation:admin-guide: Move intel_powerclamp documentation

Create a folder "thermal" under Documentation/admin-guide and move intel_powerclamp documentation to this folder.

---
 Documentation/admin-guide/index.rst                              | 1 +
 .../{driver-api => admin-guide}/thermal/intel_powerclamp.rst     | 0
 Documentation/driver-api/thermal/index.rst                       | 1 -
 MAINTAINERS                                                      | 1 +
 4 files changed, 2 insertions(+), 1 deletion(-)
 rename Documentation/{driver-api => admin-guide}/thermal/intel_powerclamp.rst (100%)
Documentation/admin-guide/index.rst +1 -0
index 5bfafcbb9562..c872a8a1ddfa 100644
@@ -116,6 +116,7 @@ configure specific aspects of kernel behavior to your liking.
    svga
    syscall-user-dispatch
    sysrq
+   thermal
    thunderbolt
    ufs
    unicode
Documentation/admin-guide/thermal/intel_powerclamp.rst renamed from Documentation/driver-api/thermal/intel_powerclamp.rst +0 -0
similarity index 100%
rename from Documentation/driver-api/thermal/intel_powerclamp.rst
rename to Documentation/admin-guide/thermal/intel_powerclamp.rst
Documentation/driver-api/thermal/index.rst +0 -1
index 030306ffa408..a886028014ab 100644
@@ -14,7 +14,6 @@ Thermal
 
    exynos_thermal
    exynos_thermal_emulation
-   intel_powerclamp
    nouveau_thermal
    x86_pkg_temperature_thermal
    intel_dptf
MAINTAINERS +1 -0
index b4043f72dfac..28fd62eacaf3 100644
@@ -20714,6 +20714,7 @@ S:	Supported
 Q:	https://patchwork.kernel.org/project/linux-pm/list/
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal
 F:	Documentation/ABI/testing/sysfs-class-thermal
+F:	Documentation/admin-guide/thermal/
 F:	Documentation/devicetree/bindings/thermal/
 F:	Documentation/driver-api/thermal/
 F:	drivers/thermal/
Signature · 1 line
2.39.1
#2 lore raw

PATCH v2 2/2 thermal/drivers/intel_powerclamp: Add two module parameters

In reply to Srinivas Pandruvada

In some use cases, it is desirable to only inject idle on certain set of CPUs. For example on Alder Lake systems, it is possible that we force idle only on P-Cores for thermal reasons. Also the idle percent can be more than 50% if we only choose partial set of CPUs in the system.

Introduce 2 new module parameters for this purpose. They can be only changed when the cooling device is inactive.

cpumask (Read/Write): A bit mask of CPUs to inject idle. The format of this bitmask is same as used in other subsystems like in /proc/irq/*/smp_affinity. The mask is comma separated 32 bit groups. Each CPU is one bit. For example for 256 CPU system the full mask is:
ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff The leftmost mask is for CPU 0-32.

max_idle (Read/Write): Maximum injected idle time to the total CPU time ratio in percent range from 1 to 100. Even if the cooling device max_state is always 100 (100%), this parameter allows to add a max idle percent limit. The default is 50, to match the current implementation of powerclamp driver. Also doesn't allow value more than 75, if the cpumask includes every CPU present in the system.

Also when the cpumask doesn't include every CPU, there is no use of compensation using package C-state idle counters. Hence don't start package C-state polling thread even for a single package or a single die system in this case.

---
 .../admin-guide/thermal/intel_powerclamp.rst  |  22 +++
 drivers/thermal/intel/intel_powerclamp.c      | 177 +++++++++++++++---
 2 files changed, 178 insertions(+), 21 deletions(-)
Documentation/admin-guide/thermal/intel_powerclamp.rst +22 -0
index 3f6dfb0b3ea6..da83b5eefbff 100644
@@ -26,6 +26,8 @@ By:
 	    - Generic Thermal Layer (sysfs)
 	    - Kernel APIs (TBD)
 
+	(*) Module Parameters
+
 INTRODUCTION
 ============
 
@@ -318,3 +320,23 @@ device, a PID based userspace thermal controller can manage to
 control CPU temperature effectively, when no other thermal influence
 is added. For example, a UltraBook user can compile the kernel under
 certain temperature (below most active trip points).
+
+Module Parameters
+=================
+
+``cpumask`` (RW)
+	A bit mask of CPUs to inject idle. The format of the bitmask is same as
+	used in other subsystems like in /proc/irq/*/smp_affinity. The mask is
+	comma separated 32 bit groups. Each CPU is one bit. For example for a 256
+	CPU system the full mask is:
+	ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff
+
+	The leftmost mask is for CPU 0-32.
+
+``max_idle`` (RW)
+	Maximum injected idle time to the total CPU time ratio in percent range
+	from 1 to 100. Even if the cooling device max_state is always 100 (100%),
+	this parameter allows to add a max idle percent limit. The default is 50,
+	to match the current implementation of powerclamp driver. Also doesn't
+	allow value more than 75, if the cpumask includes every CPU present in
+	the system.
drivers/thermal/intel/intel_powerclamp.c +156 -21

222 lines not on this page · raw message

Signature · 1 line
2.39.1
reviewer
#3 lore raw
In reply to Srinivas Pandruvada

Hi, Srinivas,

First of all, the previous build error is gone.

Second, I found something strange, which may be related with the scheduler asym-packing, so CC Ricardo.

The test is done with pm linux-intel branch + this patch series on an ADL system. cpu0~cpu7 are Pcore cpus, cpu8-cpu15 are Ecore cpus, and intel_powerclamp is register as cooling_device21.

1. run stress -c 16
2. update /sys/module/intel_powerclamp/parameters/cpumask echo 90 > /sys/module/intel_powerclamp/parameters/max_idle
3. echo 90 > /sys/class/thermal/cooling_device21/cur_state
4. echo 0 > /sys/class/thermal/cooling_device21/cur_state I use turbostat to monitor the CPU Busy% in all 4 steps.

If 'cpumask' does not include all the Ecore CPUs, all CPUs becomes 100% busy after idle injection removed in step 4.

If 'cpumask' includes all the Ecore CPUs, i.e. cpumask = FFxy, in some cases, the Ecore CPUs will drop to an Busy% much lower than 10%, and then they don't come back to busy after idle injection removed in step 4, although we have 16 stress threads. And this also relates with how long we stay in idle injection.

Say, when cpumask=fff3, the problem can be triggered occasionally if there is a 10 second timeout between step 3 and step4, but it is much easier to reproducible if I increase the timeout to 20 seconds.

It seems that Pcore can always pull tasks from Ecores, but Ecore can not pull tasks from Pcore HT siblings.

thanks,
rui

Quoted 21 lines · Srinivas Pandruvada

Split from the series for powerclamp user of powercap idle-inject.

v2
- Build warnings reported by Rui
- Moved the powerclamp documentation to admin guide folder
- Commit log updated as suggested by Rafael and other code suggestion

Srinivas Pandruvada (2):
Documentation:admin-guide: Move intel_powerclamp documentation thermal/drivers/intel_powerclamp: Add two module parameters

 Documentation/admin-guide/index.rst           |   1 +
 .../thermal/intel_powerclamp.rst              |  22 +++
 Documentation/driver-api/thermal/index.rst    |   1 -
 MAINTAINERS                                   |   1 +
 drivers/thermal/intel/intel_powerclamp.c      | 177 +++++++++++++++-
--
 5 files changed, 180 insertions(+), 22 deletions(-)
 rename Documentation/{driver-api => admin-

guide}/thermal/intel_powerclamp.rst (93%)

#4 lore raw

Hi Rui,

Quoted 7 lines · Rui

Hi, Srinivas,

First of all, the previous build error is gone.

Second, I found something strange, which may be related with the scheduler asym-packing, so CC Ricardo.

I thought you disable ITMT before idle injection and reenebale after removal.

Quoted 2 lines

The test is done with pm linux-intel branch + this patch series on an ADL system.

Can you do test on bleeding edge branch of Linux-pm?

Quoted 10 lines

cpu0~cpu7 are Pcore cpus, cpu8-cpu15 are Ecore cpus, and
intel_powerclamp is register as cooling_device21.

1. run stress -c 16
2. update /sys/module/intel_powerclamp/parameters/cpumask echo 90 > /sys/module/intel_powerclamp/parameters/max_idle
3. echo 90 > /sys/class/thermal/cooling_device21/cur_state
4. echo 0 > /sys/class/thermal/cooling_device21/cur_state I use turbostat to monitor the CPU Busy% in all 4 steps.

Quoted 4 lines

If 'cpumask' does not include all the Ecore CPUs, all CPUs becomes 100%
busy after idle injection removed in step 4.

that should be the case.

Quoted 5 lines

If 'cpumask' includes all the Ecore CPUs, i.e. cpumask = FFxy, in some
cases, the Ecore CPUs will drop to an Busy% much lower than 10%, and then they don't come back to busy after idle injection removed in step

Do you see that idle injection is removed message in dmesg?
We can also check powercap idle-inejct, if some CPUs still not wake from play_idle.

Quoted 10 lines

4, although we have 16 stress threads. And this also relates with how long we stay in idle injection.

Say, when cpumask=fff3, the problem can be triggered occasionally if there is a 10 second timeout between step 3 and step4, but it is much easier to reproducible if I increase the timeout to 20 seconds.

It seems that Pcore can always pull tasks from Ecores, but Ecore can not pull tasks from Pcore HT siblings.

That will be regular load balance threads should do. Better to try upsteam kernel first.

Thanks,
Srinivas

Quoted 27 lines

thanks,
rui

Quoted 23 lines · Srinivas Pandruvada

Split from the series for powerclamp user of powercap idle-inject.

v2
- Build warnings reported by Rui
- Moved the powerclamp documentation to admin guide folder
- Commit log updated as suggested by Rafael and other code suggestion

Srinivas Pandruvada (2):
  Documentation:admin-guide: Move intel_powerclamp documentation thermal/drivers/intel_powerclamp: Add two module parameters

 Documentation/admin-guide/index.rst           |   1 + .../thermal/intel_powerclamp.rst              |  22 +++ Documentation/driver-api/thermal/index.rst    |   1 - MAINTAINERS                                   |   1 + drivers/thermal/intel/intel_powerclamp.c      | 177
+++++++++++++++-
--

 5 files changed, 180 insertions(+), 22 deletions(-)

 rename Documentation/{driver-api => admin-
guide}/thermal/intel_powerclamp.rst (93%)

reviewer
#5 lore raw
Quoted 5 lines · srinivas pandruvada

Hi Rui,

Quoted 2 lines · Rui

Hi, Srinivas,

Quoted 7 lines
Quoted 5 lines

First of all, the previous build error is gone.

Second, I found something strange, which may be related with the scheduler asym-packing, so CC Ricardo.

I thought you disable ITMT before idle injection and reenebale after removal.

No.

I can reproduce this by playing with raw intel_powerclamp sysfs knobs and ITMT enabled.

Quoted 4 lines
Quoted 4 lines

The test is done with pm linux-intel branch

sorry, I mean linux-next branch.

Quoted 20 lines
Quoted 2 lines

+ this patch series on an
ADL system.

Can you do test on bleeding edge branch of Linux-pm?

Quoted 10 lines

cpu0~cpu7 are Pcore cpus, cpu8-cpu15 are Ecore cpus, and
intel_powerclamp is register as cooling_device21.

1. run stress -c 16
2. update /sys/module/intel_powerclamp/parameters/cpumask echo 90 > /sys/module/intel_powerclamp/parameters/max_idle
3. echo 90 > /sys/class/thermal/cooling_device21/cur_state
4. echo 0 > /sys/class/thermal/cooling_device21/cur_state I use turbostat to monitor the CPU Busy% in all 4 steps.

Quoted 4 lines

If 'cpumask' does not include all the Ecore CPUs, all CPUs becomes 100%
busy after idle injection removed in step 4.

that should be the case.

Quoted 7 lines
Quoted 6 lines

If 'cpumask' includes all the Ecore CPUs, i.e. cpumask = FFxy, in some
cases, the Ecore CPUs will drop to an Busy% much lower than 10%, and
then they don't come back to busy after idle injection removed in step

Do you see that idle injection is removed message in dmesg?

yes.

Quoted 2 lines

We can also check powercap idle-inejct, if some CPUs still not wake from play_idle.

"ps" command shows the the idle_injection threads time is not increasing any more.

Quoted 12 lines
Quoted 12 lines

4, although we have 16 stress threads. And this also relates with how
long we stay in idle injection.

Say, when cpumask=fff3, the problem can be triggered occasionally if
there is a 10 second timeout between step 3 and step4, but it is much
easier to reproducible if I increase the timeout to 20 seconds.

Quoted 6 lines
Quoted 4 lines

It seems that Pcore can always pull tasks from Ecores, but Ecore can
not pull tasks from Pcore HT siblings.

That will be regular load balance threads should do. Better to try upsteam kernel first.

I'm already running with linux-pm tree linux-next branch + this patch series.

thanks,
rui

Quoted 33 lines

Thanks,
Srinivas

Quoted 28 lines

thanks,
rui

Quoted 24 lines · Srinivas Pandruvada

Split from the series for powerclamp user of powercap idle- inject.

v2
- Build warnings reported by Rui
- Moved the powerclamp documentation to admin guide folder
- Commit log updated as suggested by Rafael and other code suggestion

Srinivas Pandruvada (2):
Documentation:admin-guide: Move intel_powerclamp documentation thermal/drivers/intel_powerclamp: Add two module parameters

 Documentation/admin-guide/index.rst           |   1 +
 .../thermal/intel_powerclamp.rst              |  22 +++
 Documentation/driver-api/thermal/index.rst    |   1 -
 MAINTAINERS                                   |   1 +
 drivers/thermal/intel/intel_powerclamp.c      | 177
+++++++++++++++-
--
 5 files changed, 180 insertions(+), 22 deletions(-)
 rename Documentation/{driver-api => admin-

guide}/thermal/intel_powerclamp.rst (93%)

#6 lore raw
Quoted 11 lines · Rui
Quoted 10 lines · srinivas pandruvada

Hi Rui,

Quoted 7 lines · Rui

Hi, Srinivas,

First of all, the previous build error is gone.

Second, I found something strange, which may be related with the scheduler asym-packing, so CC Ricardo.

Quoted 9 lines
Quoted 3 lines

I thought you disable ITMT before idle injection and reenebale after
removal.

No.

I can reproduce this by playing with raw intel_powerclamp sysfs knobs and ITMT enabled.

This issue is happening even if ITMT disabled. If the module mask is composed of P-cores it works or even on servers as expected. Also if you offline all P-cores then select mask among E-cores, it is working. Somehow P-core influences E-cores.

Since this patch is module mask related, that is functioning correctly. We have to debug this interaction with P and E cores separately.

Thanks,
Srinivas

Quoted 103 lines
Quoted 4 lines
Quoted 4 lines

The test is done with pm linux-intel branch

sorry, I mean linux-next branch.

Quoted 21 lines
Quoted 2 lines

 + this patch series on an
ADL system.

Can you do test on bleeding edge branch of Linux-pm?

Quoted 10 lines

 cpu0~cpu7 are Pcore cpus, cpu8-cpu15 are Ecore cpus, and intel_powerclamp is register as cooling_device21.

1. run stress -c 16
2. update /sys/module/intel_powerclamp/parameters/cpumask echo 90 > /sys/module/intel_powerclamp/parameters/max_idle
3. echo 90 > /sys/class/thermal/cooling_device21/cur_state
4. echo 0 > /sys/class/thermal/cooling_device21/cur_state I use turbostat to monitor the CPU Busy% in all 4 steps.

Quoted 5 lines

If 'cpumask' does not include all the Ecore CPUs, all CPUs becomes
100%
busy after idle injection removed in step 4.

that should be the case.

Quoted 7 lines
Quoted 6 lines

If 'cpumask' includes all the Ecore CPUs, i.e. cpumask = FFxy, in some
cases, the Ecore CPUs will drop to an Busy% much lower than 10%, and
then they don't come back to busy after idle injection removed in step

 Do you see that idle injection is removed message in dmesg?

yes.

Quoted 2 lines

We can also check powercap idle-inejct, if some CPUs still not wake from play_idle.

"ps" command shows the the idle_injection threads time is not increasing any more.

Quoted 12 lines
Quoted 12 lines

4, although we have 16 stress threads. And this also relates with how
long we stay in idle injection.

Say, when cpumask=fff3, the problem can be triggered occasionally if
there is a 10 second timeout between step 3 and step4, but it is much
easier to reproducible if I increase the timeout to 20 seconds.

Quoted 6 lines
Quoted 4 lines

It seems that Pcore can always pull tasks from Ecores, but Ecore can
not pull tasks from Pcore HT siblings.

That will be regular load balance threads should do. Better to try upsteam kernel first.

I'm already running with linux-pm tree linux-next branch + this patch series.

thanks,
rui

Quoted 34 lines

Thanks,
Srinivas

Quoted 29 lines

thanks,
rui

Quoted 25 lines · Srinivas Pandruvada

Split from the series for powerclamp user of powercap idle- inject.

v2
- Build warnings reported by Rui
- Moved the powerclamp documentation to admin guide folder
- Commit log updated as suggested by Rafael and other code suggestion

Srinivas Pandruvada (2):
  Documentation:admin-guide: Move intel_powerclamp documentation
  thermal/drivers/intel_powerclamp: Add two module parameters

 Documentation/admin-guide/index.rst           |   1 + .../thermal/intel_powerclamp.rst              |  22 +++ Documentation/driver-api/thermal/index.rst    |   1 - MAINTAINERS                                   |   1 + drivers/thermal/intel/intel_powerclamp.c      | 177
+++++++++++++++-
--

 5 files changed, 180 insertions(+), 22 deletions(-)

 rename Documentation/{driver-api => admin-
guide}/thermal/intel_powerclamp.rst (93%)

#7 lore raw
Quoted 22 lines · srinivas pandruvada
Quoted 11 lines · Rui
Quoted 10 lines · srinivas pandruvada

Hi Rui,

Quoted 7 lines · Rui

Hi, Srinivas,

First of all, the previous build error is gone.

Second, I found something strange, which may be related with the scheduler asym-packing, so CC Ricardo.

Quoted 9 lines
Quoted 3 lines

I thought you disable ITMT before idle injection and reenebale after
removal.

No.

I can reproduce this by playing with raw intel_powerclamp sysfs knobs and ITMT enabled.

Quoted 7 lines

This issue is happening even if ITMT disabled. If the module mask is composed of P-cores it works or even on servers as expected. Also if you offline all P-cores then select mask among E-cores, it is working. Somehow P-core influences E-cores.

Since this patch is module mask related, that is functioning correctly. We have to debug this interaction with P and E cores separately.

Currently, when doing asym_packing, ECores will only pull tasks from a PCore only if both SMT siblings are busy. It will only pull from the lower-priority sibling. These patches [1] let ECores pull from either sibling, if both are busy.

I presume that by injecting idle, the scheduler thinks that the CPU is idle (i.e., idle_cpu() returns true) and it will not do asym_packing from lower-priority CPUs.

However, in your experiment you have 16 threads. If a Pcore is overloaded, an ECore should be able to help.

[1]. https://lore.kernel.org/lkml/[email protected]/

#8 lore raw
Quoted 48 lines · Ricardo Neri
Quoted 31 lines · srinivas pandruvada
Quoted 16 lines · Rui
Quoted 7 lines · srinivas pandruvada

Hi Rui,

Quoted 4 lines · Rui

Hi, Srinivas,

First of all, the previous build error is gone.

Quoted 7 lines
Quoted 4 lines

Second, I found something strange, which may be related with the
scheduler asym-packing, so CC Ricardo.

I thought you disable ITMT before idle injection and reenebale after
removal.

Quoted 6 lines

No.

I can reproduce this by playing with raw intel_powerclamp sysfs knobs
and ITMT enabled.

This issue is happening even if ITMT disabled. If the module mask is
composed of P-cores it works or even on servers as expected. Also if you offline all P-cores then select mask among E-cores, it is
working. Somehow P-core influences E-cores.

Quoted 3 lines

Since this patch is module mask related, that is functioning correctly.
We have to debug this interaction with P and E cores separately.

Currently, when doing asym_packing, ECores will only pull tasks from a
PCore only if both SMT siblings are busy. It will only pull from the lower-priority sibling. These patches [1] let ECores pull from either sibling, if both are busy.

I presume that by injecting idle, the scheduler thinks that the CPU is
idle (i.e., idle_cpu() returns true) and it will not do asym_packing from
lower-priority CPUs.

Quoted 3 lines

However, in your experiment you have 16 threads. If a Pcore is overloaded,
an ECore should be able to help.

This issue happens with or without ITMT and also without any idle injection active.

Thanks,
Srinivas

Quoted 4 lines

[1].
https://lore.kernel.org/lkml/[email protected]/

#9 lore raw
Quoted 49 lines · srinivas pandruvada
Quoted 48 lines · Ricardo Neri
Quoted 31 lines · srinivas pandruvada
Quoted 16 lines · Rui
Quoted 7 lines · srinivas pandruvada

Hi Rui,

Quoted 4 lines · Rui

Hi, Srinivas,

First of all, the previous build error is gone.

Quoted 7 lines
Quoted 4 lines

Second, I found something strange, which may be related with the
scheduler asym-packing, so CC Ricardo.

I thought you disable ITMT before idle injection and reenebale after
removal.

Quoted 6 lines

No.

I can reproduce this by playing with raw intel_powerclamp sysfs knobs
and ITMT enabled.

This issue is happening even if ITMT disabled. If the module mask is
composed of P-cores it works or even on servers as expected. Also if you offline all P-cores then select mask among E-cores, it is
working. Somehow P-core influences E-cores.

Quoted 3 lines

Since this patch is module mask related, that is functioning correctly.
We have to debug this interaction with P and E cores separately.

Currently, when doing asym_packing, ECores will only pull tasks from a
PCore only if both SMT siblings are busy. It will only pull from the lower-priority sibling. These patches [1] let ECores pull from either sibling, if both are busy.

I presume that by injecting idle, the scheduler thinks that the CPU is
idle (i.e., idle_cpu() returns true) and it will not do asym_packing from
lower-priority CPUs.

Quoted 5 lines
Quoted 3 lines

However, in your experiment you have 16 threads. If a Pcore is overloaded,
an ECore should be able to help.

This issue happens with or without ITMT and also without any idle injection active.

I was not able to reproduce this issue on my ADL-S system with ITMT. The described bug is exactly what and old patchset of mine was supposed to fix [2]. Maybe the CPU priorities in the failing system are such that it prevents asym_packing from kicking in.

I was able to reproduce the issue without ITMT.

I had found that the scheduler cannot handle load balance between SMT and non-SMT cores correctly. My patchset [1] includes fixes for this case. I applied it on top of Rafael's linux-next branch and it fixed the issue for me in the non-ITMT case. Perhaps patches 5 and 6 are sufficient, but I applied the whole series.

Thanks and BR,
Ricardo

[1]. https://lore.kernel.org/lkml/[email protected]/
[2]. https://lore.kernel.org/all/[email protected]/