tracing: wprobe: Fix to use IS_ERR_PCPU() for per-cpu pointer
Masami Hiramatsu (Google)
maintainerPATCH 1/1 tracing: wprobe: Fix to use IS_ERR_PCPU() for per-cpu pointer
From: Masami Hiramatsu (Google) <[email protected]>
Since wprobe uses IS_ERR() for per-cpu pointer, it failed to build.
/tmp/next/build/kernel/trace/trace_wprobe.c: In function '__register_trace_wprobe':/tmp/next/build/kernel/trace/trace_wprobe.c:176:20: error: cast to generic address space pointer from disjoint '__seg_gs' address space pointer [-Werror]
176 | if (IS_ERR((void * __force)tw->bp_event)) {
| ^/tmp/next/build/kernel/trace/trace_wprobe.c:177:35: error: cast to generic address space pointer from disjoint '__seg_gs' address space pointer [-Werror]
177 | int ret = PTR_ERR((void * __force)tw->bp_event);
| ^
Use IS_ERR_PCPU() instead.
---
- Confirmed that make allmodconfig && make passed on x86_64 and arm64.
--- kernel/trace/trace_wprobe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_wprobe.c +1 -1
@@ -173,7 +173,7 @@ static int __register_trace_wprobe(struct trace_wprobe *tw) attr.bp_type = tw->type; tw->bp_event =register_wide_hw_breakpoint (&attr, wprobe_perf_handler, tw); -if (IS_ERR ((void *__force )tw->bp_event)) { +if (IS_ERR_PCPU ((void *__force )tw->bp_event)) {int ret =PTR_ERR ((void *__force )tw->bp_event); tw->bp_event =NULL ;
kernel/trace/trace_wprobe.c static int __register_trace_wprobe(struct trace_wprobe *tw) · line 177
Quoted 5 lines · Masami Hiramatsu (Google)
tw->bp_event = register_wide_hw_breakpoint(&attr, wprobe_perf_handler, tw);kernel/trace/trace_wprobe.c +1
-1-if (IS_ERR ((void *__force )tw->bp_event)) { +if (IS_ERR_PCPU ((void *__force )tw->bp_event)) {int ret =PTR_ERR ((void *__force )tw->bp_event);
No, this is still entirely wrong.
That casts are *WRONG*. They should not exist. And they will cause compiler errors, because you are casting fundamentally different pointer types.
They don't just point to different types, they aren't even in the same address space!
Stop adding random casts. They are a sign of type errors, and as long as they are there, the code is buggy.
And no, it's not just that IS_ERR() that was wrong. That PTR_ERR() won't work on a percpu pointer either.
No more of this randomness, please.
Linus
Masami Hiramatsu (Google)
maintainerQuoted 8 lines · On Mon, 6 Oct 2025 11:06:31 -0700 Linus Torvalds…
kernel/trace/trace_wprobe.c static int __register_trace_wprobe(struct trace_wprobe *tw) · line 177
Quoted 5 lines · Masami Hiramatsu (Google)
tw->bp_event = register_wide_hw_breakpoint(&attr, wprobe_perf_handler, tw);kernel/trace/trace_wprobe.c +1
-1-if (IS_ERR ((void *__force )tw->bp_event)) { +if (IS_ERR_PCPU ((void *__force )tw->bp_event)) {int ret =PTR_ERR ((void *__force )tw->bp_event);
Quoted 5 lines
No, this is still entirely wrong.
That casts are *WRONG*. They should not exist. And they will cause compiler errors, because you are casting fundamentally different pointer types.
Ah, got it!
Quoted 6 lines
They don't just point to different types, they aren't even in the same address space!
Stop adding random casts. They are a sign of type errors, and as long as they are there, the code is buggy.
OK.
Quoted 5 lines
And no, it's not just that
IS_ERR()that was wrong. ThatPTR_ERR()won't work on a percpu pointer either.No more of this randomness, please.
OK, let me fix that.
Thank you!
Quoted 2 lines
Linus
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>