From: Tiezhu Yang yangtiezhu@loongson.cn
[ Upstream commit 6a38c51a2557d4d50748818a858d507c250f3bee ]
When executing "make -C tools/tracing/rtla" on LoongArch, there exists the following error:
src/utils.c:237:24: error: '__NR_sched_setattr' undeclared
Just define __NR_sched_setattr for LoongArch if not exist.
Link: https://lore.kernel.org/20250422074917.25771-1-yangtiezhu@loongson.cn Reported-by: Haiyong Sun sunhaiyong@loongson.cn Signed-off-by: Tiezhu Yang yangtiezhu@loongson.cn Signed-off-by: Steven Rostedt (Google) rostedt@goodmis.org Signed-off-by: Sasha Levin sashal@kernel.org ---
Based on my analysis of the commit and examination of the kernel source tree, here is my assessment: **YES** This commit should be backported to stable kernel trees for the following reasons: **1. Build Fix for Supported Architecture**: This commit fixes a compilation error on LoongArch architecture where `__NR_sched_setattr` is undeclared. The error message shows: ``` src/utils.c:237:24: error: '__NR_sched_setattr' undeclared ``` **2. Minimal and Safe Change**: The change adds just two lines to define the syscall number for LoongArch: ```c # elif __loongarch__ # define __NR_sched_setattr 274 ``` **3. Follows Established Pattern**: From examining `/home/sasha/linux/include/uapi/asm-generic/unistd.h`, I confirmed that `__NR_sched_setattr` is indeed syscall number 274 in the generic syscall table. LoongArch uses the generic syscall ABI (as evidenced by `/home/sasha/linux/tools/arch/loongarch/include/uapi/asm/unistd.h` including `asm-generic/unistd.h`), so using 274 is correct and consistent. **4. Consistency with Similar Commits**: Looking at the historical commits provided: - Similar Commit #5 (Status: NO) added RISC-V support with the same syscall number 274 - Similar Commit #3 (Status: YES) was a build fix that removed unused functions - Similar Commit #2 (Status: YES) fixed compilation issues with glibc The pattern shows that build fixes for architecture support are typically backported when they're minimal and safe. **5. Essential Functionality**: The rtla tool is a real-time latency analysis tool that requires scheduler attribute syscalls to function properly. Without this fix, the tool cannot be built on LoongArch systems, making it completely unusable on that architecture. **6. No Risk of Regression**: This change only affects LoongArch builds and follows the exact same pattern used for other architectures. It defines a constant that prevents compilation failure without changing any runtime behavior. **7. Stable Tree Criteria Met**: - Fixes an important build issue affecting users - Change is minimal and contained - No architectural changes or new features - Extremely low risk of regression - Follows established patterns The commit perfectly fits the stable tree criteria for important bugfixes with minimal risk.
tools/tracing/rtla/src/utils.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/tools/tracing/rtla/src/utils.c b/tools/tracing/rtla/src/utils.c index 4995d35cf3ec6..d6ab15dcb4907 100644 --- a/tools/tracing/rtla/src/utils.c +++ b/tools/tracing/rtla/src/utils.c @@ -227,6 +227,8 @@ long parse_ns_duration(char *val) # define __NR_sched_setattr 355 # elif __s390x__ # define __NR_sched_setattr 345 +# elif __loongarch__ +# define __NR_sched_setattr 274 # endif #endif