Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] cpupower: Propagate errors from child powercap zones
@ 2026-11-20  6:21 Zhu Jun
  2026-11-20 19:45 ` Shuah Khan
  0 siblings, 1 reply; 2+ messages in thread
From: Zhu Jun @ 2026-11-20  6:21 UTC (permalink / raw)
  To: trenn; +Cc: shuah, jwyatt, jkacur, linux-pm, Zhu Jun

powercap_walk_zones() returns a callback error for the current zone but
discards errors from recursive calls. A callback that fails on a child
zone therefore does not stop the walk and the caller receives success.

Propagate the recursive return value so callback errors have the same
meaning at every level of the hierarchy.

Fixes: c2294c1496b7 ("cpupower: Introduce powercap intel-rapl library and powercap-info command")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 tools/power/cpupower/lib/powercap.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/power/cpupower/lib/powercap.c b/tools/power/cpupower/lib/powercap.c
index 94a0c69e55ef..76ca392161e6 100644
--- a/tools/power/cpupower/lib/powercap.c
+++ b/tools/power/cpupower/lib/powercap.c
@@ -300,8 +300,11 @@ int powercap_walk_zones(struct powercap_zone *zone,
 		return ret;
 
 	for (i = 0; i < POWERCAP_MAX_CHILD_ZONES; i++) {
-		if (zone->children[i] != NULL)
-			powercap_walk_zones(zone->children[i], f);
+		if (zone->children[i]) {
+			ret = powercap_walk_zones(zone->children[i], f);
+			if (ret)
+				return ret;
+		}
 	}
 	return 0;
 }



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-20 19:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20  6:21 [PATCH] cpupower: Propagate errors from child powercap zones Zhu Jun
2026-11-20 19:45 ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox