[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250618141345.GR1613376@noisy.programming.kicks-ass.net>
Date: Wed, 18 Jun 2025 16:13:45 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
bpf@...r.kernel.org, x86@...nel.org,
Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Ingo Molnar <mingo@...nel.org>, Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Andrii Nakryiko <andrii@...nel.org>,
Indu Bhagat <indu.bhagat@...cle.com>,
"Jose E. Marchesi" <jemarch@....org>,
Beau Belgrave <beaub@...ux.microsoft.com>,
Jens Remus <jremus@...ux.ibm.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v10 05/14] unwind_user/deferred: Add unwind cache
> diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
> index f94f3fdf15fc..6e850c9d3f0c 100644
> --- a/include/linux/entry-common.h
> +++ b/include/linux/entry-common.h
> @@ -12,6 +12,7 @@
> #include <linux/resume_user_mode.h>
> #include <linux/tick.h>
> #include <linux/kmsan.h>
> +#include <linux/unwind_deferred.h>
>
> #include <asm/entry-common.h>
> #include <asm/syscall.h>
> @@ -362,6 +363,7 @@ static __always_inline void exit_to_user_mode(void)
> lockdep_hardirqs_on_prepare();
> instrumentation_end();
>
> + unwind_exit_to_user_mode();
So I was expecting this to do the actual unwind, and was about to go
yell this is the wrong place for that.
But this is not that. Perhaps find a better name like:
unwind_clear_cache() or so?
> user_enter_irqoff();
> arch_exit_to_user_mode();
> lockdep_hardirqs_on(CALLER_ADDR0);
> diff --git a/include/linux/unwind_deferred_types.h b/include/linux/unwind_deferred_types.h
> index aa32db574e43..db5b54b18828 100644
> --- a/include/linux/unwind_deferred_types.h
> +++ b/include/linux/unwind_deferred_types.h
> @@ -2,8 +2,13 @@
> #ifndef _LINUX_UNWIND_USER_DEFERRED_TYPES_H
> #define _LINUX_UNWIND_USER_DEFERRED_TYPES_H
>
> +struct unwind_cache {
> + unsigned int nr_entries;
> + unsigned long entries[];
> +};
> +
> struct unwind_task_info {
> - unsigned long *entries;
> + struct unwind_cache *cache;
> };
>
> #endif /* _LINUX_UNWIND_USER_DEFERRED_TYPES_H */
> diff --git a/kernel/unwind/deferred.c b/kernel/unwind/deferred.c
> index 0bafb95e6336..e3913781c8c6 100644
> --- a/kernel/unwind/deferred.c
> +++ b/kernel/unwind/deferred.c
> @@ -24,6 +24,7 @@
> int unwind_deferred_trace(struct unwind_stacktrace *trace)
> {
> struct unwind_task_info *info = ¤t->unwind_info;
> + struct unwind_cache *cache;
>
> /* Should always be called from faultable context */
> might_fault();
> @@ -31,17 +32,30 @@ int unwind_deferred_trace(struct unwind_stacktrace *trace)
> if (current->flags & PF_EXITING)
> return -EINVAL;
>
> - if (!info->entries) {
> - info->entries = kmalloc_array(UNWIND_MAX_ENTRIES, sizeof(long),
> - GFP_KERNEL);
> - if (!info->entries)
> + if (!info->cache) {
> + info->cache = kzalloc(struct_size(cache, entries, UNWIND_MAX_ENTRIES),
> + GFP_KERNEL);
And now you're one 'long' larger than a page. Surely that's a crap size
for an allocator?
Powered by blists - more mailing lists