Re: [PATCH] tracing: wprobe: Fix to use IS_ERR_PCPU() for per-cpu pointer
From: Google
Date: Mon Oct 06 2025 - 20:35:15 EST
On Mon, 6 Oct 2025 11:06:31 -0700
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Mon, 6 Oct 2025 at 02:47, Masami Hiramatsu (Google)
> <mhiramat@xxxxxxxxxx> 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@xxxxxxxxxx>