[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241028060029.742310369@goodmis.org>
Date: Mon, 28 Oct 2024 02:00:29 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org
Cc: Masami Hiramatsu <mhiramat@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Thomas Gleixner <tglx@...utronix.de>
Subject: [PATCH v2 0/2] fgraph: Free up function graph shadow stacks
Since the start of function graph tracing, shadow stacks were created for
every task on the system when the first instance of function graph was used.
But they were never freed due to the shadow stacks holding the return
address that was hijacked for the function graph return trampoline. The
stacks were only freed when a task exits. That means once you use function
graph tracing, your system has PAGE_SIZE stack for every task in the system
that was running when function graph was happening. That's a lot of memory
being wasted that's not being used.
This series addresses this by now freeing shadow stacks that are no longer
being used. This can be found by checking the shadow stack pointer on the
task structure.
When function graph is finished, it will free all the shadow stacks that are
no longer being used. For those still being used, the freeing of them is
delayed until the funciton graph return is called by the task and it pops
off the last return address. That will trigger a irq work which triggers a
work queue to do shadow stack clean up again. A static_branch is used so
that this check doesn't happen during normal tracing as it's in a very hot
path.
Note this patch series is based on my ftrace/urgent branch merged with my
ftrace/for-next branch (and some patches that havent been pushed yet).
Changse since v1: https://lore.kernel.org/linux-trace-kernel/20241024092723.817582319@goodmis.org/
- Had to merge ftrace/urgent to the ftrace/for-next branch and that caused
some conflicts to these patches.
Steven Rostedt (2):
fgraph: Free ret_stacks when graph tracing is done
fgraph: Free ret_stack when task is done with it
----
kernel/trace/fgraph.c | 152 ++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 136 insertions(+), 16 deletions(-)
Powered by blists - more mailing lists