From nobody Tue Apr 7 14:51:55 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 4FFCDECAAD5 for ; Sat, 27 Aug 2022 04:04:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232408AbiH0EEI (ORCPT ); Sat, 27 Aug 2022 00:04:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240971AbiH0EEE (ORCPT ); Sat, 27 Aug 2022 00:04:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E06AE42F9 for ; Fri, 26 Aug 2022 21:03:57 -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 BE62861E0E for ; Sat, 27 Aug 2022 04:03:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02BDDC433C1; Sat, 27 Aug 2022 04:03:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661573036; bh=f9mXihupzTDK1250qHChyNfWYWBi2D+NT5drxWfjNVM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iEmwtVBod0GbmaXmMPKNucuW/S2OBHMTPsQoSnR2YoQK6xZ0HK/kbX5+qFTlLHT+i gNW0DlqV2nvg4ux8OrMj/2tHiTApgJ+rtDk44SSdaIFUrgzAG6x7CykljFQTQXx4ps C/a/f3tbG+XE0LHRwxpT2YYLXrCv3Iyohq/z8gGwpfI2w9e6gUGp94G+a6X0YlvCN5 lUFtwYHDOkQxJJDGWJPwqZ+4VncIxdMhcMyZ0mc8XvtC80j9uWLEJSF2duhulBPqh1 ZGLlYD7WJzc20+nAHnIusE4XIIylMzubBdwya1Y6d6A/8uJS/sfw4Le4T8M6/iGa75 hyWKWzbULsqew== From: "Masami Hiramatsu (Google)" To: Steven Rostedt Cc: Tom Zanussi , Ingo Molnar , linux-kernel@vger.kernel.org Subject: [PATCH v4 5/5] tracing: Show hitcount value only when specified Date: Sat, 27 Aug 2022 13:03:52 +0900 Message-Id: <166157303240.348924.7493529171143320258.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <166157298537.348924.2537162090505397377.stgit@devnote2> References: <166157298537.348924.2537162090505397377.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu (Google) Show the hitcount value only when it is specified explicitly or no value is specified. # cd /sys/kernel/debug/tracing/ # echo hist:keys=3Dpid:vals=3Druntime.percent,runtime.graph:sort=3Dpid > \ events/sched/sched_stat_runtime/trigger # sleep 10 # cat events/sched/sched_stat_runtime/hist # event histogram # # trigger info: hist:keys=3Dpid:vals=3Druntime.percent,runtime.graph:sort= =3Dpid:size=3D2048 [active] # { pid: 14 } runtime (%): 0.97 runtime: { pid: 16 } runtime (%): 1.74 runtime: { pid: 26 } runtime (%): 0.13 runtime: { pid: 57 } runtime (%): 7.06 runtime: ### { pid: 61 } runtime (%): 11.06 runtime: ##### { pid: 65 } runtime (%): 0.75 runtime: { pid: 70 } runtime (%): 0.98 runtime: { pid: 77 } runtime (%): 0.10 runtime: { pid: 125 } runtime (%): 0.56 runtime: { pid: 146 } runtime (%): 37.53 runtime: #################### { pid: 152 } runtime (%): 23.67 runtime: ############ { pid: 153 } runtime (%): 15.39 runtime: ######## Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/trace_events_hist.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_h= ist.c index fceea784fded..35feeea84a38 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -508,6 +508,7 @@ enum hist_field_flags { HIST_FIELD_FL_CONST =3D 1 << 18, HIST_FIELD_FL_PERCENT =3D 1 << 19, HIST_FIELD_FL_GRAPH =3D 1 << 20, + HIST_FIELD_FL_VAL =3D 1 << 21, }; =20 struct var_defs { @@ -4204,7 +4205,8 @@ static int create_val_field(struct hist_trigger_data = *hist_data, if (WARN_ON(val_idx >=3D TRACING_MAP_VALS_MAX)) return -EINVAL; =20 - return __create_val_field(hist_data, val_idx, file, NULL, field_str, 0); + return __create_val_field(hist_data, val_idx, file, NULL, field_str, + HIST_FIELD_FL_VAL); } =20 static const char no_comm[] =3D "(no comm)"; @@ -4355,8 +4357,11 @@ static int create_val_fields(struct hist_trigger_dat= a *hist_data, goto out; =20 fields_str =3D hist_data->attrs->vals_str; - if (!fields_str) + if (!fields_str) { + /* If there is no value, use hitcount as a value */ + hist_data->fields[HITCOUNT_IDX]->flags |=3D HIST_FIELD_FL_VAL; goto out; + } =20 for (i =3D 0, j =3D 1; i < TRACING_MAP_VALS_MAX && j < TRACING_MAP_VALS_MAX; i++) { @@ -4372,6 +4377,8 @@ static int create_val_fields(struct hist_trigger_data= *hist_data, if (strncmp(field_str + 8, ".graph", 8) =3D=3D 0) hist_data->fields[HITCOUNT_IDX]->flags |=3D HIST_FIELD_FL_GRAPH; + hist_data->fields[HITCOUNT_IDX]->flags |=3D + HIST_FIELD_FL_VAL; continue; } =20 @@ -5392,13 +5399,13 @@ static void hist_trigger_entry_print(struct seq_fil= e *m, hist_trigger_print_key(m, hist_data, key, elt); =20 flags =3D hist_data->fields[i]->flags; - hist_trigger_print_val(m, i, "hitcount", flags, stats, elt); + if (flags & HIST_FIELD_FL_VAL) + hist_trigger_print_val(m, i, "hitcount", flags, stats, elt); =20 for (i =3D 1; i < hist_data->n_vals; i++) { field_name =3D hist_field_name(hist_data->fields[i], 0); flags =3D hist_data->fields[i]->flags; - - if (flags & HIST_FIELD_FL_VAR || flags & HIST_FIELD_FL_EXPR) + if (!(flags & HIST_FIELD_FL_VAL)) continue; =20 seq_puts(m, " "); @@ -5842,6 +5849,7 @@ static int event_hist_trigger_print(struct seq_file *= m, struct hist_trigger_data *hist_data =3D data->private_data; struct hist_field *field; bool have_var =3D false; + bool show_val =3D false; unsigned int i; =20 seq_puts(m, HIST_PREFIX); @@ -5872,16 +5880,13 @@ static int event_hist_trigger_print(struct seq_file= *m, continue; } =20 - if (i =3D=3D HITCOUNT_IDX) { - seq_puts(m, "hitcount"); - if (field->flags & HIST_FIELD_FL_PERCENT) - seq_puts(m, ".percent"); - else if (field->flags & HIST_FIELD_FL_GRAPH) - seq_puts(m, ".graph"); - } else { + if (!(field->flags & HIST_FIELD_FL_VAL)) + continue; + + if (show_val) seq_puts(m, ","); - hist_field_print(m, field); - } + hist_field_print(m, field); + show_val =3D true; } =20 if (have_var) {