tracing: Make percpu stack trace buffer invariant to PAGE_SIZE
PATCH v2 1/1 tracing: Make percpu stack trace buffer invariant to PAGE_SIZE
Previously the size of "struct ftrace_stacks" depended upon PAGE_SIZE. For the common 4K page size, on a 64-bit system, sizeof(struct ftrace_stacks) was 32K. But for a 64K page size, sizeof(struct ftrace_stacks) was 512K.
But ftrace stack usage requirements should be invariant to page size. So let's redefine FTRACE_KSTACK_ENTRIES so that "struct ftrace_stacks" is always sized at 32K for 64-bit and 16K for 32-bit.
As a side effect, it removes the PAGE_SIZE compile-time constant assumption from this code, which is required to reach the goal of boot-time page size selection.
--- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +1 -1
@@ -2914,7 +2914,7 @@ trace_function(struct trace_array *tr, unsigned long ip, unsigned long/* Allow 4 levels of nesting: normal, softirq, irq, NMI */ #define FTRACE_KSTACK_NESTING 4 -#define FTRACE_KSTACK_ENTRIES (PAGE_SIZE / FTRACE_KSTACK_NESTING) +#define FTRACE_KSTACK_ENTRIES (SZ_4K / FTRACE_KSTACK_NESTING)struct ftrace_stack {unsigned long calls[FTRACE_KSTACK_ENTRIES ];
--
2.43.0
Quoted 5 lines · Ryan Roberts
Previously the size of "struct
ftrace_stacks" depended uponPAGE_SIZE. For the common 4K page size, on a 64-bit system,sizeof(struct ftrace_stacks)was 32K. But for a 64K page size,sizeof(struct ftrace_stacks)was 512K.
Quoted 7 lines
But ftrace stack usage requirements should be invariant to page size. So let's redefine
FTRACE_KSTACK_ENTRIESso that "structftrace_stacks" is always sized at 32K for 64-bit and 16K for 32-bit.As a side effect, it removes the
PAGE_SIZEcompile-time constant assumption from this code, which is required to reach the goal of boot-time page size selection.
Just a polite bump on this... Does anyone have any comments?
Thanks,
Ryan
Quoted 22 lines
Signed-off-by Ryan Roberts <[email protected]>--- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/trace/trace.c +1
-2@@ -2914,7 +2914,7 @@ trace_function(struct trace_array *tr, unsigned long ip, unsigned long/* Allow 4 levels of nesting: normal, softirq, irq, NMI */ #define FTRACE_KSTACK_NESTING 4 -#define FTRACE_KSTACK_ENTRIES (PAGE_SIZE / FTRACE_KSTACK_NESTING) +#define FTRACE_KSTACK_ENTRIES (SZ_4K / FTRACE_KSTACK_NESTING)struct ftrace_stack {unsigned long calls[FTRACE_KSTACK_ENTRIES ]; --2.43.0
Steven Rostedt
maintainerQuoted 10 lines · On Wed, 30 Oct 2024 08:50:16 +0000 Ryan Roberts <[email protected]> wrote:
Quoted 9 lines · Ryan Roberts
Previously the size of "struct
ftrace_stacks" depended uponPAGE_SIZE. For the common 4K page size, on a 64-bit system,sizeof(struct ftrace_stacks)was 32K. But for a 64K page size,sizeof(struct ftrace_stacks)was 512K.But ftrace stack usage requirements should be invariant to page size. So let's redefine
FTRACE_KSTACK_ENTRIESso that "structftrace_stacks" is always sized at 32K for 64-bit and 16K for 32-bit.
Quoted 5 lines
Quoted 3 lines
As a side effect, it removes the
PAGE_SIZEcompile-time constant assumption from this code, which is required to reach the goal of boot-time page size selection.Just a polite bump on this... Does anyone have any comments?
No, it's in my queue. I've just been traveling.
-- Steve