mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 14:12:06 +00:00
fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long
Instead of using "ALIGN()", use BUILD_BUG_ON() as the structures should always be divisible by sizeof(long). Co-developed with Masami Hiramatsu: Link: https://lore.kernel.org/linux-trace-kernel/171509093949.162236.14518699447151894536.stgit@devnote2 Link: http://lkml.kernel.org/r/20190524111144.GI2589@hirez.programming.kicks-ass.net Link: https://lore.kernel.org/linux-trace-kernel/20240603190821.232168933@goodmis.org Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com> Cc: Florent Revest <revest@chromium.org> Cc: Martin KaFai Lau <martin.lau@linux.dev> Cc: bpf <bpf@vger.kernel.org> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Alan Maguire <alan.maguire@oracle.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Guo Ren <guoren@kernel.org> Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
parent
42675b723b
commit
59e5f04e41
@ -33,7 +33,7 @@
|
||||
* SHADOW_STACK_MAX_OFFSET: The max offset of the stack for a new frame to be added
|
||||
*/
|
||||
#define FGRAPH_FRAME_SIZE sizeof(struct ftrace_ret_stack)
|
||||
#define FGRAPH_FRAME_OFFSET (ALIGN(FGRAPH_FRAME_SIZE, sizeof(long)) / sizeof(long))
|
||||
#define FGRAPH_FRAME_OFFSET DIV_ROUND_UP(FGRAPH_FRAME_SIZE, sizeof(long))
|
||||
#define SHADOW_STACK_SIZE (PAGE_SIZE)
|
||||
#define SHADOW_STACK_OFFSET \
|
||||
(ALIGN(SHADOW_STACK_SIZE, sizeof(long)) / sizeof(long))
|
||||
@ -103,6 +103,8 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func,
|
||||
if (!current->ret_stack)
|
||||
return -EBUSY;
|
||||
|
||||
BUILD_BUG_ON(SHADOW_STACK_SIZE % sizeof(long));
|
||||
|
||||
/*
|
||||
* We must make sure the ret_stack is tested before we read
|
||||
* anything else.
|
||||
@ -326,6 +328,8 @@ ftrace_graph_get_ret_stack(struct task_struct *task, int idx)
|
||||
{
|
||||
int index = task->curr_ret_stack;
|
||||
|
||||
BUILD_BUG_ON(FGRAPH_FRAME_SIZE % sizeof(long));
|
||||
|
||||
index -= FGRAPH_FRAME_OFFSET * (idx + 1);
|
||||
if (index < 0)
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user