From nobody Sat Apr 18 15:44:26 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2000C433EF for ; Tue, 12 Jul 2022 23:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231354AbiGLXJy (ORCPT ); Tue, 12 Jul 2022 19:09:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbiGLXJv (ORCPT ); Tue, 12 Jul 2022 19:09:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A58EB9B1A9 for ; Tue, 12 Jul 2022 16:09:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4270C61740 for ; Tue, 12 Jul 2022 23:09:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A38BEC3411E; Tue, 12 Jul 2022 23:09:48 +0000 (UTC) Date: Tue, 12 Jul 2022 19:09:47 -0400 From: Steven Rostedt To: Linus Torvalds Cc: LKML , Ingo Molnar , Andrew Morton , Douglas Anderson , Li kunyu , Tiezhu Yang , Zheng Yejian , sunliming Subject: [GIT PULL] tracing: Fixes and minor cleanups for 5.19 Message-ID: <20220712190947.055042b4@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Linus, Fixes and minor clean ups for tracing: - Fix memory leak by reverting what was thought to be a double free. A static tool had gave a false positive that a double free was possible in the error path, but it was actually a different location that confused the static analyzer (and those of us that reviewed it). - Move use of static buffers by ftrace_dump() to a location that can be used by kgdb's ftdump(), as it needs it for the same reasons. - Clarify in the Kconfig description that function tracing has negligible impact on x86, but may have a bit bigger impact on other architectures. - Remove unnecessary extra semicolon in trace event. - Make a local variable static that is used in the fprobes sample - Use KSYM_NAME_LEN for length of function in kprobe sample and get rid of unneeded macro for the same purpose. Please pull the latest trace-v5.19-rc5 tree, which can be found at: git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git trace-v5.19-rc5 Tag SHA1: f64990a1b4d1e153bcb18e40634f008ce23cfbfd Head SHA1: 1e1fb420fe68d9d938db360fec700dfd230cc22a Douglas Anderson (1): tracing: Fix sleeping while atomic in kdb ftdump Li kunyu (1): blk-iocost: tracing: atomic64_read(&ioc->vtime_rate) is assigned an e= xtra semicolon Steven Rostedt (Google) (1): ftrace: Be more specific about arch impact when function tracer is en= abled Tiezhu Yang (1): samples: Use KSYM_NAME_LEN for kprobes Zheng Yejian (1): tracing/histograms: Fix memory leak problem sunliming (1): fprobe/samples: Make sample_probe static ---- include/trace/events/iocost.h | 2 +- kernel/trace/Kconfig | 3 ++- kernel/trace/trace.c | 11 ++++++----- kernel/trace/trace_events_hist.c | 2 ++ samples/fprobe/fprobe_example.c | 2 +- samples/kprobes/kprobe_example.c | 5 ++--- samples/kprobes/kretprobe_example.c | 5 ++--- 7 files changed, 16 insertions(+), 14 deletions(-) --------------------------- diff --git a/include/trace/events/iocost.h b/include/trace/events/iocost.h index e282ce02fa2d..6d1626e7a4ce 100644 --- a/include/trace/events/iocost.h +++ b/include/trace/events/iocost.h @@ -160,7 +160,7 @@ TRACE_EVENT(iocost_ioc_vrate_adj, =20 TP_fast_assign( __assign_str(devname, ioc_name(ioc)); - __entry->old_vrate =3D atomic64_read(&ioc->vtime_rate);; + __entry->old_vrate =3D atomic64_read(&ioc->vtime_rate); __entry->new_vrate =3D new_vrate; __entry->busy_level =3D ioc->busy_level; __entry->read_missed_ppm =3D missed_ppm[READ]; diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index debbbb083286..ccd6a5ade3e9 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -194,7 +194,8 @@ config FUNCTION_TRACER sequence is then dynamically patched into a tracer call when tracing is enabled by the administrator. If it's runtime disabled (the bootup default), then the overhead of the instructions is very - small and not measurable even in micro-benchmarks. + small and not measurable even in micro-benchmarks (at least on + x86, but may have impact on other architectures). =20 config FUNCTION_GRAPH_TRACER bool "Kernel Function Graph Tracer" diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index a8cfac0611bc..b8dd54627075 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -9864,6 +9864,12 @@ void trace_init_global_iter(struct trace_iterator *i= ter) /* Output in nanoseconds only if we are using a clock in nanoseconds. */ if (trace_clocks[iter->tr->clock_id].in_ns) iter->iter_flags |=3D TRACE_FILE_TIME_IN_NS; + + /* Can not use kmalloc for iter.temp and iter.fmt */ + iter->temp =3D static_temp_buf; + iter->temp_size =3D STATIC_TEMP_BUF_SIZE; + iter->fmt =3D static_fmt_buf; + iter->fmt_size =3D STATIC_FMT_BUF_SIZE; } =20 void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) @@ -9896,11 +9902,6 @@ void ftrace_dump(enum ftrace_dump_mode oops_dump_mod= e) =20 /* Simulate the iterator */ trace_init_global_iter(&iter); - /* Can not use kmalloc for iter.temp and iter.fmt */ - iter.temp =3D static_temp_buf; - iter.temp_size =3D STATIC_TEMP_BUF_SIZE; - iter.fmt =3D static_fmt_buf; - iter.fmt_size =3D STATIC_FMT_BUF_SIZE; =20 for_each_tracing_cpu(cpu) { atomic_inc(&per_cpu_ptr(iter.array_buffer->data, cpu)->disabled); diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_h= ist.c index 48e82e141d54..e87a46794079 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -4430,6 +4430,8 @@ static int parse_var_defs(struct hist_trigger_data *h= ist_data) =20 s =3D kstrdup(field_str, GFP_KERNEL); if (!s) { + kfree(hist_data->attrs->var_defs.name[n_vars]); + hist_data->attrs->var_defs.name[n_vars] =3D NULL; ret =3D -ENOMEM; goto free; } diff --git a/samples/fprobe/fprobe_example.c b/samples/fprobe/fprobe_exampl= e.c index 01ee6c8c8382..58f6e8358e97 100644 --- a/samples/fprobe/fprobe_example.c +++ b/samples/fprobe/fprobe_example.c @@ -20,7 +20,7 @@ =20 #define BACKTRACE_DEPTH 16 #define MAX_SYMBOL_LEN 4096 -struct fprobe sample_probe; +static struct fprobe sample_probe; static unsigned long nhit; =20 static char symbol[MAX_SYMBOL_LEN] =3D "kernel_clone"; diff --git a/samples/kprobes/kprobe_example.c b/samples/kprobes/kprobe_exam= ple.c index f991a66b5b02..fd346f58ddba 100644 --- a/samples/kprobes/kprobe_example.c +++ b/samples/kprobes/kprobe_example.c @@ -16,9 +16,8 @@ #include #include =20 -#define MAX_SYMBOL_LEN 64 -static char symbol[MAX_SYMBOL_LEN] =3D "kernel_clone"; -module_param_string(symbol, symbol, sizeof(symbol), 0644); +static char symbol[KSYM_NAME_LEN] =3D "kernel_clone"; +module_param_string(symbol, symbol, KSYM_NAME_LEN, 0644); =20 /* For each probe you need to allocate a kprobe structure */ static struct kprobe kp =3D { diff --git a/samples/kprobes/kretprobe_example.c b/samples/kprobes/kretprob= e_example.c index 228321ecb161..cbf16542d84e 100644 --- a/samples/kprobes/kretprobe_example.c +++ b/samples/kprobes/kretprobe_example.c @@ -23,11 +23,10 @@ #include #include #include -#include #include =20 -static char func_name[NAME_MAX] =3D "kernel_clone"; -module_param_string(func, func_name, NAME_MAX, S_IRUGO); +static char func_name[KSYM_NAME_LEN] =3D "kernel_clone"; +module_param_string(func, func_name, KSYM_NAME_LEN, 0644); MODULE_PARM_DESC(func, "Function to kretprobe; this module will report the" " function's execution time");