kernel/trace/trace_wprobe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
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.
Reported-by: Mark Brown <broonie@kernel.org>
Closes: https://lore.kernel.org/all/aN6fTmAjD7-SJsw2@sirena.org.uk/
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
- Confirmed that `make allmodconfig && make` passed on x86_64 and arm64.
---
kernel/trace/trace_wprobe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/trace_wprobe.c b/kernel/trace/trace_wprobe.c
index 4b00a8e917c1..aa8ef173528b 100644
--- a/kernel/trace/trace_wprobe.c
+++ b/kernel/trace/trace_wprobe.c
@@ -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;
On Mon, 6 Oct 2025 at 02:47, Masami Hiramatsu (Google)
<mhiramat@kernel.org> wrote:
>
> 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);
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
On Mon, 6 Oct 2025 11:06:31 -0700
Linus Torvalds <torvalds@linux-foundation.org> wrote:
> On Mon, 6 Oct 2025 at 02:47, Masami Hiramatsu (Google)
> <mhiramat@kernel.org> wrote:
> >
> > 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);
>
> 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!
>
> 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.
>
> 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.
OK, let me fix that.
Thank you!
>
> Linus
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
© 2016 - 2026 Red Hat, Inc.