tracing: Updates for v6.15
Subsystems (5)
Steven Rostedt
maintainercover tracing: Updates for v6.15
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace/for-next
Head SHA1: 77feaf4a2efb078f4f8c703dce5918c0ce08b7e9
Masami Hiramatsu (Google) (2):
mm/memblock: Add reserved memory release function
tracing: Freeable reserved ring buffer
Steven Rostedt (1):
tracing: Add traceoff_after_boot option
----
Documentation/admin-guide/kernel-parameters.txt | 9 ++++ include/linux/mm.h | 1 + kernel/trace/trace.c | 24 ++++++++- kernel/trace/trace.h | 1 + mm/memblock.c | 66 ++++++++++++++++++++----- 5 files changed, 88 insertions(+), 13 deletions(-)
Steven Rostedt
maintainerPATCH 1/3 tracing: Add traceoff_after_boot option
From: Steven Rostedt <[email protected]>
Sometimes tracing is used to debug issues during the boot process. Since the trace buffer has a limited amount of storage, it may be prudent to disable tracing after the boot is finished, otherwise the critical information may be overwritten. With this option, the main tracing buffer will be turned off at the end of the boot process.
--- Documentation/admin-guide/kernel-parameters.txt | 9 +++++++++ kernel/trace/trace.c | 11 +++++++++++ 2 files changed, 20 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +9 -0
@@ -7279,6 +7279,15 @@ See also "Event triggers" in Documentation/trace/events.rst + traceoff_after_boot + [FTRACE] Sometimes tracing is used to debug issues + during the boot process. Since the trace buffer has a + limited amount of storage, it may be prudent to + disable tracing after the boot is finished, otherwise + the critical information may be overwritten. With this + option, the main tracing buffer will be turned off at + the end of the boot process. + traceoff_on_warning [FTRACE] enable this option to disable tracing when a warning is hit. This turns off "tracing_on". Tracing can
kernel/trace/trace.c +11 -0
@@ -87,6 +87,7 @@ void __init disable_tracing_selftest(const char *reason)static struct trace_iterator *tracepoint_print_iter;int tracepoint_printk;static bool tracepoint_printk_stop_on_boot__initdata ; +static bool traceoff_after_boot__initdata ;static DEFINE_STATIC_KEY_FALSE (tracepoint_printk_key);/* For tracers that don't implement custom flags */
@@ -330,6 +331,13 @@ static int __init set_tracepoint_printk_stop(char *str) }__setup ("tp_printk_stop_on_boot" , set_tracepoint_printk_stop); +static int __init set_traceoff_after_boot (char *str) +{ + traceoff_after_boot = true; +return 1 ; +} +__setup ("traceoff_after_boot" , set_traceoff_after_boot); +unsigned long long ns2usecs (u64 nsec) { nsec +=500 ;
@@ -10704,6 +10712,9 @@ __init static int late_trace_init(void) tracepoint_printk =0 ; } +if (traceoff_after_boot) +tracing_off (); +tracing_set_default_clock ();clear_boot_tracer ();return 0 ;
Signature · 1 line
2.47.2
Steven Rostedt
maintainerPATCH 2/3 mm/memblock: Add reserved memory release function
In reply to Steven RostedtFrom: "Masami Hiramatsu (Google)" <[email protected]>
Add reserve_mem_release_by_name() to release a reserved memory region with a given name. This allows us to release reserved memory which is defined by kernel cmdline, after boot.
--- include/linux/mm.h | 1 + mm/memblock.c | 66 +++++++++++++++++++++++++++++++++++++--------- 2 files changed, 55 insertions(+), 12 deletions(-)
include/linux/mm.h +1 -0
@@ -4123,6 +4123,7 @@ void vma_pgtable_walk_begin(struct vm_area_struct *vma);void vma_pgtable_walk_end (struct vm_area_struct *vma);int reserve_mem_find_by_name (const char *name,phys_addr_t *start,phys_addr_t *size); +int reserve_mem_release_by_name (const char *name);#ifdef CONFIG_64BIT int do_mseal (unsigned long start,size_t len_in,unsigned long flags);
mm/memblock.c +54 -12
94 lines not on this page · raw message
Signature · 1 line
2.47.2
Steven Rostedt
maintainerPATCH 3/3 tracing: Freeable reserved ring buffer
In reply to Steven RostedtFrom: "Masami Hiramatsu (Google)" <[email protected]>
Make the ring buffer on reserved memory to be freeable. This allows us to free the trace instance on the reserved memory without changing cmdline and rebooting. Even if we can not change the kernel cmdline for security reason, we can release the reserved memory for the ring buffer as free (available) memory.
For example, boot kernel with reserved memory; "reserve_mem=20M:2M:trace trace_instance=boot_mapped^traceoff@trace"
~ # free
total used free shared buff/cache available
Mem: 1995548 50544 1927568 14964 17436 1911480
Swap: 0 0 0
~ # rmdir /sys/kernel/tracing/instances/boot_mapped/
[ 23.704023] Freeing reserve_mem:trace memory: 20476K
~ # free
total used free shared buff/cache available
Mem: 2016024 41844 1956740 14968 17440 1940572
Swap: 0 0 0--- kernel/trace/trace.c | 13 ++++++++++++- kernel/trace/trace.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-)
kernel/trace/trace.c +12 -1
@@ -9292,6 +9292,9 @@ static void free_trace_buffers(struct trace_array *tr)#ifdef CONFIG_TRACER_MAX_TRACE free_trace_buffer (&tr->max_buffer);#endif + +if (tr->range_addr_start) +vunmap ((void *)tr->range_addr_start); }static void init_trace_flags_index (struct trace_array *tr)
@@ -9453,6 +9456,7 @@ trace_array_create_systems(const char *name, const char *systems,free_cpumask_var (tr->pipe_cpumask);free_cpumask_var (tr->tracing_cpumask);kfree_const (tr->system_names); +kfree (tr->range_name);kfree (tr->name);kfree (tr);
@@ -9579,6 +9583,11 @@ static int __remove_instance(struct trace_array *tr)free_trace_buffers (tr);clear_tracing_err_log (tr); +if (tr->range_name) { +reserve_mem_release_by_name (tr->range_name); +kfree (tr->range_name); + } +for (i =0 ; i < tr->nr_topts; i++) {kfree (tr->topts[i].topts); }
@@ -10376,6 +10385,7 @@ __init static void enable_instances(void)bool traceoff = false;char *flag_delim;char *addr_delim; + char *rname __free(kfree) = NULL; tok =strsep (&curr_str,"," );
@@ -10432,6 +10442,7 @@ __init static void enable_instances(void)pr_warn ("Failed to map boot instance %s to %s\n" , name, tok);continue ; } + rname =kstrdup (tok,GFP_KERNEL ); }if (start) {
@@ -10468,7 +10479,7 @@ __init static void enable_instances(void)*/ if (start) { tr->flags |=TRACE_ARRAY_FL_BOOT ; - tr->ref++; + tr->range_name =no_free_ptr (rname); }while ((tok =strsep (&curr_str,"," ))) {
kernel/trace/trace.h +1 -0
@@ -348,6 +348,7 @@ struct trace_array {unsigned int mapped;unsigned long range_addr_start;unsigned long range_addr_size; +char *range_name;long text_delta;long data_delta;
Signature · 1 line
2.47.2
Steven Rostedt
maintainerQuoted 3 lines · On Wed, 26 Feb 2025 19:12:35 -0500 Steven Rostedt <[email protected]> wrote:
Masami Hiramatsu (Google) (2):
mm/memblock: Add reserved memory release function
tracing: Freeable reserved ring buffer
Masami,
I'm going to revert these two patches from the trace/for-next tree and rebase them on top of the ring-buffer/for-next, as they conflict, and I rather not send Linus a pull request that has conflicts between two of my topic branches.
-- Steve