From: Shinji Nomoto fj5851bi@fujitsu.com
[ Upstream commit b3eaf14f4c63fd6abc7b68c6d7a07c5680a6d8e5 ]
The set subcommand's -t option is documented as being available for boost configuration, but it was not actually functioning due to a bug in the option handling.
Link: https://lore.kernel.org/r/20250522061122.2149188-2-fj5851bi@fujitsu.com Signed-off-by: Shinji Nomoto fj5851bi@fujitsu.com Signed-off-by: Shuah Khan skhan@linuxfoundation.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
**Backport Status: YES**
This commit is a clear bug fix that should be backported to stable kernel trees. Here's my detailed analysis:
## Bug Analysis
The commit fixes a critical bug where the `-t` option for the `cpupower set` subcommand was documented and accepted as a valid option (defined in `set_opts[]` structure), but was completely non-functional due to a missing character in the `getopt_long()` call.
### Specific Code Changes
The bug is in line 58-59 of the original code: ```c while ((ret = getopt_long(argc, argv, "b:e:m:", set_opts, NULL)) != -1) { ```
The fix adds the missing `t:` to the argument string: ```c while ((ret = getopt_long(argc, argv, "b:e:m:t:", set_opts, NULL)) != -1) { ```
### Root Cause
When the turbo-boost feature was added in commit `eb426fc6bdd6` (merged in v6.6-rc1), the developer: 1. Added the option to the `set_opts[]` array correctly 2. Added the case handler for 't' in the switch statement 3. **BUT forgot to add "t:" to the getopt_long argument string**
This means that while the option was defined and had handling code, `getopt_long()` would never recognize `-t` as a valid option, making the feature completely unusable.
## Why This Should Be Backported
1. **Clear Bug Fix**: This is an obvious bug where documented functionality doesn't work at all. Users trying to use `cpupower set -t` or `--turbo-boost` would get errors.
2. **Small and Contained**: The fix is a single-line change adding 2 characters ("t:") to a string. This is as minimal as fixes get.
3. **No Side Effects**: The change only enables already-implemented functionality. It doesn't introduce new code paths or change existing behavior.
4. **User Impact**: The turbo-boost control feature is important for power management, and users on stable kernels with v6.6+ would expect this documented feature to work.
5. **Affects Stable Versions**: The bug was introduced in v6.6-rc1 and affects all kernels from v6.6 onwards that include the turbo-boost feature.
6. **Low Risk**: There's virtually no regression risk - the worst case is the option continues not working, which is the current state.
This is exactly the type of fix that stable kernel rules recommend: a clear bug fix that restores documented functionality with minimal code change and no architectural modifications.
tools/power/cpupower/utils/cpupower-set.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/power/cpupower/utils/cpupower-set.c b/tools/power/cpupower/utils/cpupower-set.c index 0677b58374ab..59ace394cf3e 100644 --- a/tools/power/cpupower/utils/cpupower-set.c +++ b/tools/power/cpupower/utils/cpupower-set.c @@ -62,8 +62,8 @@ int cmd_set(int argc, char **argv)
params.params = 0; /* parameter parsing */ - while ((ret = getopt_long(argc, argv, "b:e:m:", - set_opts, NULL)) != -1) { + while ((ret = getopt_long(argc, argv, "b:e:m:t:", + set_opts, NULL)) != -1) { switch (ret) { case 'b': if (params.perf_bias)