[PATCH AUTOSEL 6.19-6.18] powerpc64/ftrace: fix OOL stub count with clang
Sasha Levin
sashal at kernel.org
Tue Mar 17 22:32:35 AEDT 2026
From: Hari Bathini <hbathini at linux.ibm.com>
[ Upstream commit 875612a7745013a43c67493cb0583ee3f7476344 ]
The total number of out-of-line (OOL) stubs required for function
tracing is determined using the following command:
$(OBJDUMP) -r -j __patchable_function_entries vmlinux.o
While this works correctly with GNU objdump, llvm-objdump does not
list the expected relocation records for this section. Fix this by
using the -d option and counting R_PPC64_ADDR64 relocation entries.
This works as desired with both objdump and llvm-objdump.
Signed-off-by: Hari Bathini <hbathini at linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88 at linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy at linux.ibm.com>
Link: https://patch.msgid.link/20260127084926.34497-3-hbathini@linux.ibm.com
Signed-off-by: Sasha Levin <sashal at kernel.org>
---
LLM Generated explanations, may be completely bogus:
This is a **build fix**. When building with clang/LLVM toolchain:
1. `llvm-objdump -r -j __patchable_function_entries` produces no
relocation records
2. `grep -c "$RELOCATION"` finds 0 matches, returns exit code 1
3. With `set -e` at the top of the script, the script aborts
4. The kernel build fails
This is a clear build failure for the LLVM/clang toolchain on powerpc64
with ftrace OOL stubs enabled.
## Analysis
### What the commit fixes
This commit fixes a **build failure** when compiling the Linux kernel
with the LLVM/clang toolchain on powerpc64 with
`CONFIG_PPC_FTRACE_OUT_OF_LINE` enabled. The `llvm-objdump` tool does
not list relocation records the same way as GNU objdump when using `-r
-j __patchable_function_entries`. Adding the `-d` flag makes both GNU
objdump and llvm-objdump produce the expected output.
### Stable kernel criteria assessment
1. **Obviously correct and tested**: Yes. The fix adds `-d` to objdump
invocations. It has `Tested-by:` from Venkat Rao Bagalkote. The
commit message clearly explains the problem and solution.
2. **Fixes a real bug**: Yes. Build failure with LLVM/clang toolchain.
3. **Fixes an important issue**: Yes. Build fixes are explicitly listed
as acceptable for stable trees per stable kernel rules. Users
building with LLVM toolchain cannot build a working kernel without
this fix.
4. **Small and contained**: Yes. Only 2 lines changed - adding `-d` flag
to two objdump invocations in a shell script.
5. **No new features or APIs**: Correct. No new features.
### Scope and risk
- **2 lines changed**: Minimal scope, adding a single flag to objdump
commands.
- **Only affects build tooling**: A shell script used during build, not
runtime kernel code.
- **Cross-toolchain compatible**: The fix works with both GNU objdump
and llvm-objdump.
- **Risk**: Extremely low. The `-d` (disassemble) flag is standard for
both objdump implementations and the commit message confirms testing
with both.
### Affected versions
- The file was introduced in v6.13 (commit eec37961a56aa)
- The fix is in v7.0-rc4
- Stable trees v6.13.y and v6.14.y are affected
### Dependencies
No dependencies on other commits. The fix is self-contained.
### User impact
Anyone building the powerpc64 kernel with clang/LLVM and
CONFIG_PPC_FTRACE_OUT_OF_LINE enabled hits a build failure. The
clang/LLVM toolchain is increasingly used for kernel builds
(ClangBuiltLinux project), making this a real-world issue.
## Verification
- `git log --follow -- arch/powerpc/tools/ftrace-gen-ool-stubs.sh`
confirmed the file was introduced in commit eec37961a56aa (v6.13)
- `git merge-base --is-ancestor eec37961a56aa v6.13` confirmed the file
is in v6.13 but not v6.12
- `git tag --contains 875612a774501` confirmed the fix landed in
v7.0-rc4
- Read `arch/powerpc/kernel/trace/ftrace.c:190-239` confirmed that wrong
stub count leads to WARN_ON and -EINVAL (ftrace failure)
- Read `arch/powerpc/tools/ftrace-gen-ool-stubs.sh` confirmed `set -e`
at line 5, meaning grep returning exit code 1 (zero matches) would
abort the script and fail the build
- `git tag -l 'v6.13.*'` and `git tag -l 'v6.14.*'` confirmed both
stable trees exist and need this fix
- The diff is exactly 2 lines changed (adding `-d` flag) - verified from
the commit diff
**YES**
arch/powerpc/tools/ftrace-gen-ool-stubs.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/tools/ftrace-gen-ool-stubs.sh b/arch/powerpc/tools/ftrace-gen-ool-stubs.sh
index bac186bdf64a7..9218d43aeb548 100755
--- a/arch/powerpc/tools/ftrace-gen-ool-stubs.sh
+++ b/arch/powerpc/tools/ftrace-gen-ool-stubs.sh
@@ -15,9 +15,9 @@ if [ -z "$is_64bit" ]; then
RELOCATION=R_PPC_ADDR32
fi
-num_ool_stubs_total=$($objdump -r -j __patchable_function_entries "$vmlinux_o" |
+num_ool_stubs_total=$($objdump -r -j __patchable_function_entries -d "$vmlinux_o" |
grep -c "$RELOCATION")
-num_ool_stubs_inittext=$($objdump -r -j __patchable_function_entries "$vmlinux_o" |
+num_ool_stubs_inittext=$($objdump -r -j __patchable_function_entries -d "$vmlinux_o" |
grep -e ".init.text" -e ".text.startup" | grep -c "$RELOCATION")
num_ool_stubs_text=$((num_ool_stubs_total - num_ool_stubs_inittext))
--
2.51.0
More information about the Linuxppc-dev
mailing list