Re: [PATCH v3] cpupower: Implement powercap enabled setters
From: Shuah Khan
Date: Wed May 27 2026 - 11:26:52 EST
On 5/27/26 02:12, Mateusz Jaśkiewicz wrote:
powercap_set_enabled() and powercap_zone_set_enabled() are part of the
public libcpupower API, but both currently return success without
updating sysfs.
Write the requested value to the matching enabled attribute so callers
can actually enable or disable the powercap control type or zone, and
report write failures back to the caller.
Signed-off-by: Mateusz Jaśkiewicz <jaskiewiczteo@xxxxxxxxx>
---
Changes in v3:
- Move the patch changelog below the Signed-off-by trailer so the
sign-off is kept when the patch is applied.
Changes in v2:
- Check current enabled value before writing.
- Use fd < 0 style for open() failures.
- Print sysfs open/write failures with perror().
- Drop the sizeof(path) typecast.
tools/power/cpupower/lib/powercap.c | 58 +++++++++++++++++++++++------
1 file changed, 47 insertions(+), 11 deletions(-)
Something to fix here:
lib/powercap.c: In function ‘powercap_zone_set_enabled’:
lib/powercap.c:217:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
217 | if (ret < 0 || ret >= sizeof(path))
| ^~
thanks,
-- Shuah