* [PATCH] tracing: wprobe: Fix to use IS_ERR_PCPU() for per-cpu pointer
@ 2025-10-06 9:47 Masami Hiramatsu (Google)
2025-10-06 18:06 ` Linus Torvalds
0 siblings, 1 reply; 3+ messages in thread
From: Masami Hiramatsu (Google) @ 2025-10-06 9:47 UTC (permalink / raw)
To: Steven Rostedt
Cc: Mark Brown, Linus Torvalds, Menglong Dong, Thorsten Blum,
Masami Hiramatsu, linux-kernel, linux-trace-kernel
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;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tracing: wprobe: Fix to use IS_ERR_PCPU() for per-cpu pointer
2025-10-06 9:47 [PATCH] tracing: wprobe: Fix to use IS_ERR_PCPU() for per-cpu pointer Masami Hiramatsu (Google)
@ 2025-10-06 18:06 ` Linus Torvalds
2025-10-07 0:35 ` Masami Hiramatsu
0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2025-10-06 18:06 UTC (permalink / raw)
To: Masami Hiramatsu (Google)
Cc: Steven Rostedt, Mark Brown, Menglong Dong, Thorsten Blum,
linux-kernel, linux-trace-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tracing: wprobe: Fix to use IS_ERR_PCPU() for per-cpu pointer
2025-10-06 18:06 ` Linus Torvalds
@ 2025-10-07 0:35 ` Masami Hiramatsu
0 siblings, 0 replies; 3+ messages in thread
From: Masami Hiramatsu @ 2025-10-07 0:35 UTC (permalink / raw)
To: Linus Torvalds
Cc: Steven Rostedt, Mark Brown, Menglong Dong, Thorsten Blum,
linux-kernel, linux-trace-kernel
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-07 0:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-06 9:47 [PATCH] tracing: wprobe: Fix to use IS_ERR_PCPU() for per-cpu pointer Masami Hiramatsu (Google)
2025-10-06 18:06 ` Linus Torvalds
2025-10-07 0:35 ` Masami Hiramatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox