From: Calvin Owens calvin@wbinvd.org
[ Upstream commit 6ea0ec1b958a84aff9f03fb0ae4613a4d5bed3ea ]
turbostat.c: In function 'parse_int_file': turbostat.c:5567:19: error: 'PATH_MAX' undeclared (first use in this function) 5567 | char path[PATH_MAX]; | ^~~~~~~~
turbostat.c: In function 'probe_graphics': turbostat.c:6787:19: error: 'PATH_MAX' undeclared (first use in this function) 6787 | char path[PATH_MAX]; | ^~~~~~~~
Signed-off-by: Calvin Owens calvin@wbinvd.org Reviewed-by: Artem Bityutskiy artem.bityutskiy@linux.intel.com Signed-off-by: Len Brown len.brown@intel.com Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
**Backport Status: YES**
This commit should be backported to stable kernel trees for the following reasons:
1. **Clear Build Fix**: This is a straightforward build fix that addresses compilation failures when building turbostat with musl libc. The error messages in the commit clearly show `PATH_MAX` is undeclared, which prevents the tool from compiling.
2. **Minimal and Safe Change**: The fix is extremely minimal - it only adds a single include directive (`#include <limits.h>`) at line 70 of turbostat.c. This is a standard POSIX header that defines `PATH_MAX` and other system limits.
3. **No Functional Changes**: The commit doesn't change any logic or behavior - it simply ensures the code compiles correctly by including the necessary header file that defines `PATH_MAX`.
4. **Affects User Tools**: While turbostat is a userspace tool (not kernel code), it's an important power monitoring utility that's part of the kernel source tree. Users building kernel tools with musl libc (common in embedded systems, Alpine Linux, etc.) would be unable to build this tool without this fix.
5. **Cross-Platform Compatibility**: The issue affects systems using musl libc instead of glibc. With glibc, `PATH_MAX` might be defined through indirect includes, but musl requires explicit inclusion of `<limits.h>`. This fix improves portability.
6. **No Risk of Regression**: Adding the `<limits.h>` include has zero risk of breaking existing functionality. The header is standard and the constant `PATH_MAX` is used in at least 4 places in the code (lines 5641, 6870, 7481, 7537) where character arrays are declared.
7. **Follows Stable Rules**: This perfectly fits the stable kernel criteria: - Fixes a real bug (build failure) - Obviously correct (standard header inclusion) - Already tested (has sign-offs and review) - Small change (1 line) - No new features or architectural changes
The commit is an ideal candidate for stable backporting as it fixes a concrete build issue with minimal risk and maximum benefit for users of alternative libc implementations.
tools/power/x86/turbostat/turbostat.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index bf011c2847f2..46ee85216373 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -67,6 +67,7 @@ #include <stdbool.h> #include <assert.h> #include <linux/kernel.h> +#include <limits.h>
#define UNUSED(x) (void)(x)