From nobody Tue Nov 26 12:44:55 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7B971DFDAD for ; Thu, 17 Oct 2024 17:54:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729187647; cv=none; b=sGwl03D1xhsAGR5e/M7gqGLLmJhncSV/ixpOJtEgywwayZdG+LueN5C/rnr6kUeUzub1QBsPBYUVxwUBop/1gcxNRhxQ5UZKOYw+9kjQOItC2ORRi0DuWr62W1JNYJ5yE8RfV1CPtptBwOlqOBdLvesMX8jSSW1mwXpqiB9rWOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729187647; c=relaxed/simple; bh=JHZeSmkWIrj8EFARpnwwv3ZxZXRwxkO0vkOgH6dtkac=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=fYF0Jpk8nRSKGi2NCYXt00SX+/kSlq5lOowArCid8uTPH1b7NG7oDZUNdQUU27xuiyPm7x55lpjerP3Kh3ydmdeN6AH+4Pd2JTpzL7jCLyZ6RXESJtzi85fEiFrvpfpdzpWoUVDDmt16RTfjotar6Jlz+naaRW8myJYq3gybJKA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QoIlyL0t; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QoIlyL0t" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e315a5b199so21355247b3.2 for ; Thu, 17 Oct 2024 10:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729187644; x=1729792444; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=j2gIFyt42nntsnGaIcEwttdqpxaZNfusYx2zy+lIpHc=; b=QoIlyL0tBLLfEwdePreiKV/41rOpxPdkWGVW3dbfC40Oont4rjxMm6zeu5bDMmvrdp W+ADQknoDgpRzKdzbtu7F3OBOSB9JOg9oQnpoR4B5vxOL8t0g6rTbd8v9UOj1aRvPNfk 2ZqGNe9hjVS9ADnv30Yz+cJeQRdyDhKh4by/pc25eQyP9cAM7shPohV74mSpCcSRPqZG hQ5Z2dvIIfumsqw1n+2uOi7ya3XSNdpTyZkO5y4dRvhc6Ia3sFDYqhD5sO/Qp8vIYdto 99+7/NBERu8IZTvCCq6VGYwHWh+XTqGwCPHuMN0SkCQBJJ3vver4KSXQqlYOE4yw1WuN AhEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729187644; x=1729792444; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=j2gIFyt42nntsnGaIcEwttdqpxaZNfusYx2zy+lIpHc=; b=QfExfqezS7LplVig83N4+BIeP+VrxT6OvqICAOqVAQa9n145Oj9tJTpU2d8KF6+efJ QPFm14AqzstfuPwDcVw8XbczNTEsm4EtMLNZ2nS/sA/r6THHaas/mR6mm2h4jVPGUsmk Pk4LME3qUaDlZlKNYtwkzu3IF2Ihc0QkGNmEJ6nSgpOUZA7RS9cwxkyn8zdV99j2RQjm xk9atejADYciQp6iBa1ri+0wJYs6w3OcxD4c33oraxv2LiinewcvwW9C08pqmNmMxqj/ vm/ZhVXANGXWufSD+jFuAvGtmIHiTy7JtABIRd3bo+8r9t/+YcA7sn1ClKdUeNqQR5Wc 34uA== X-Forwarded-Encrypted: i=1; AJvYcCUCuUdS6/19Qo/dzL6s47JpeSRkIhuaXiBl4cGLOZ5B2W8L/mBKhHKnkFGKSHH4QNjtU070PHz6y8vPM8A=@vger.kernel.org X-Gm-Message-State: AOJu0YzKlubfh2CkOnD+1PCqV3sBRz+FF6IBvQ6S8CgIcJ1fuCaqCC6y ExQ8Plhe62pCrsP1pzsMqb+YMDYFhW1FR9tp/srTzbAPYc1QKFRlN+Qm5OPTMb7iXspzb/zanGd U/T31FA== X-Google-Smtp-Source: AGHT+IFOb7Ly95ignRrZpM2eJffAbLiYBD5BXqW5NZZKWGFTAymVVA4fkRvwEwltD1JaiD5Sx3sRyDuUmgkk X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:98a5:142e:8c2e:e9e5]) (user=irogers job=sendgmr) by 2002:a05:690c:d8b:b0:69b:c01:82a5 with SMTP id 00721157ae682-6e3d41e6b49mr1223917b3.7.1729187643820; Thu, 17 Oct 2024 10:54:03 -0700 (PDT) Date: Thu, 17 Oct 2024 10:53:50 -0700 In-Reply-To: <20241017175356.783793-1-irogers@google.com> Message-Id: <20241017175356.783793-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241017175356.783793-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v5 1/7] perf color: Add printf format checking and resolve issues From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Yicong Yang , Tim Chen , Thomas Richter , Sumanth Korikkar , Weilin Wang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add printf format checking to vararg printf routines in color.h. Resolve build errors/bugs that are found through this checking. Signed-off-by: Ian Rogers --- tools/perf/builtin-sched.c | 2 +- tools/perf/builtin-trace.c | 2 +- tools/perf/util/arm-spe.c | 2 +- tools/perf/util/color.h | 9 +++++---- tools/perf/util/intel-bts.c | 2 +- tools/perf/util/intel-pt.c | 2 +- tools/perf/util/s390-cpumsf.c | 2 +- tools/perf/util/s390-sample-raw.c | 8 ++++---- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index fdf979aaf275..99bfc3ad71e2 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1739,7 +1739,7 @@ static int map_switch_event(struct perf_sched *sched,= struct evsel *evsel, } =20 if (sched->map.comp && new_cpu) - color_fprintf(stdout, color, " (CPU %d)", this_cpu); + color_fprintf(stdout, color, " (CPU %d)", this_cpu.cpu); =20 if (proceed !=3D 1) { color_fprintf(stdout, color, "\n"); diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 0b30297b4ecb..748b061f8678 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1873,7 +1873,7 @@ static int trace__process_event(struct trace *trace, = struct machine *machine, switch (event->header.type) { case PERF_RECORD_LOST: color_fprintf(trace->output, PERF_COLOR_RED, - "LOST %" PRIu64 " events!\n", event->lost.lost); + "LOST %" PRIu64 " events!\n", (u64)event->lost.lost); ret =3D machine__process_lost_event(machine, event, sample); break; default: diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 13fd2c8afebd..fd0d793ecad8 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -122,7 +122,7 @@ static void arm_spe_dump(struct arm_spe *spe __maybe_un= used, else pkt_len =3D 1; printf("."); - color_fprintf(stdout, color, " %08x: ", pos); + color_fprintf(stdout, color, " %08zx: ", pos); for (i =3D 0; i < pkt_len; i++) color_fprintf(stdout, color, " %02x", buf[i]); for (; i < 16; i++) diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h index aecf56dae73f..b2f37de305f6 100644 --- a/tools/perf/util/color.h +++ b/tools/perf/util/color.h @@ -2,6 +2,7 @@ #ifndef __PERF_COLOR_H #define __PERF_COLOR_H =20 +#include #include #include =20 @@ -37,11 +38,11 @@ int perf_config_colorbool(const char *var, const char *= value, int stdout_is_tty) int color_vsnprintf(char *bf, size_t size, const char *color, const char *fmt, va_list args); int color_vfprintf(FILE *fp, const char *color, const char *fmt, va_list a= rgs); -int color_fprintf(FILE *fp, const char *color, const char *fmt, ...); -int color_snprintf(char *bf, size_t size, const char *color, const char *f= mt, ...); +int color_fprintf(FILE *fp, const char *color, const char *fmt, ...) __pri= ntf(3, 4); +int color_snprintf(char *bf, size_t size, const char *color, const char *f= mt, ...) __printf(4, 5); int value_color_snprintf(char *bf, size_t size, const char *fmt, double va= lue); -int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...); -int percent_color_len_snprintf(char *bf, size_t size, const char *fmt, ...= ); +int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...) __= printf(3, 4); +int percent_color_len_snprintf(char *bf, size_t size, const char *fmt, ...= ) __printf(3, 4); int percent_color_fprintf(FILE *fp, const char *fmt, double percent); const char *get_percent_color(double percent); =20 diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index 27d9b5c9fec8..3ea82d5e8d2e 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -100,7 +100,7 @@ static void intel_bts_dump(struct intel_bts *bts __mayb= e_unused, else sz =3D len; printf("."); - color_fprintf(stdout, color, " %08x: ", pos); + color_fprintf(stdout, color, " %08zx: ", pos); for (i =3D 0; i < sz; i++) color_fprintf(stdout, color, " %02x", buf[i]); for (; i < br_sz; i++) diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index fd2597613f3d..3fe67bf652b6 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -249,7 +249,7 @@ static void intel_pt_dump(struct intel_pt *pt __maybe_u= nused, else pkt_len =3D 1; printf("."); - color_fprintf(stdout, color, " %08x: ", pos); + color_fprintf(stdout, color, " %08zx: ", pos); for (i =3D 0; i < pkt_len; i++) color_fprintf(stdout, color, " %02x", buf[i]); for (; i < 16; i++) diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index 73846b73d0cf..30638653ad2d 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -345,7 +345,7 @@ static bool s390_cpumsf_trailer_show(const char *color,= size_t pos, } color_fprintf(stdout, color, " [%#08zx] Trailer %c%c%c bsdes:%d" " dsdes:%d Overflow:%lld Time:%#llx\n" - "\t\tC:%d TOD:%#lx\n", + "\t\tC:%d TOD:%#llx\n", pos, te->f ? 'F' : ' ', te->a ? 'A' : ' ', diff --git a/tools/perf/util/s390-sample-raw.c b/tools/perf/util/s390-sampl= e-raw.c index 53383e97ec9d..335217bb532b 100644 --- a/tools/perf/util/s390-sample-raw.c +++ b/tools/perf/util/s390-sample-raw.c @@ -98,12 +98,12 @@ static void s390_cpumcfdg_dumptrail(const char *color, = size_t offset, te.res2 =3D be32_to_cpu(tep->res2); =20 color_fprintf(stdout, color, " [%#08zx] Trailer:%c%c%c%c%c" - " Cfvn:%d Csvn:%d Speed:%d TOD:%#llx\n", + " Cfvn:%d Csvn:%d Speed:%d TOD:%#lx\n", offset, te.clock_base ? 'T' : ' ', te.speed ? 'S' : ' ', te.mtda ? 'M' : ' ', te.caca ? 'C' : ' ', te.lcda ? 'L' : ' ', te.cfvn, te.csvn, te.cpu_speed, te.timestamp); - color_fprintf(stdout, color, "\t\t1:%lx 2:%lx 3:%lx TOD-Base:%#llx" + color_fprintf(stdout, color, "\t\t1:%lx 2:%lx 3:%lx TOD-Base:%#lx" " Type:%x\n\n", te.progusage1, te.progusage2, te.progusage3, te.tod_base, te.mach_type); @@ -205,7 +205,7 @@ static void s390_cpumcfdg_dump(struct perf_pmu *pmu, st= ruct perf_sample *sample) char *ev_name =3D get_counter_name(ce.set, i, pmu); =20 color_fprintf(stdout, color, - "\tCounter:%03d %s Value:%#018lx\n", i, + "\tCounter:%03zd %s Value:%#018"PRIx64"\n", i, ev_name ?: "", be64_to_cpu(*p)); free(ev_name); } @@ -260,7 +260,7 @@ static void s390_pai_all_dump(struct evsel *evsel, stru= ct perf_sample *sample) =20 ev_name =3D get_counter_name(evsel->core.attr.config, pai_data.event_nr, evsel->pmu); - color_fprintf(stdout, color, "\tCounter:%03d %s Value:%#018lx\n", + color_fprintf(stdout, color, "\tCounter:%03d %s Value:%#018"PRIx64"\n", pai_data.event_nr, ev_name ?: "", pai_data.event_val); free(ev_name); --=20 2.47.0.105.g07ac214952-goog From nobody Tue Nov 26 12:44:55 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B3681DFD8D for ; Thu, 17 Oct 2024 17:54:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729187648; cv=none; b=TXSgK0LCze2LiKHuLs8zB+3DbSbgcpb00ASIVIvggzIeafpLsRm83tGWk1vyFx2ONhy0NJDY+dvFFXAemS5qAVKWI0yquKWwIDbXKM88HNfCngjHDnor2emUuZFy9ycwb3GaqvL4Mwv3TvoOKmm6AaoKWrcv76aIIaFlqXEl6OU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729187648; c=relaxed/simple; bh=WUodcAb4TVW2yeFy1LDOu4j2dnFFiTlcHPQcWZN06qw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=X9jF+gbiiI/gH/rOUJ0JfhLUHAPoKAQHE3tBORCWGw4rURlrRDFsoZU898ETXa3KibfM/y7ULjG9YuRxkVK8Pn+cr+q0uhcQkn9fSqlx9ksEp019n/vYHY9MzcvQPm/Nj7lzMu9O3iPWaAmqBrTqc3dqoLLDMX0aO7NLGqs+A8Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Pth671ox; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Pth671ox" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e59dc7df64so15110047b3.1 for ; Thu, 17 Oct 2024 10:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729187646; x=1729792446; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=SvCFzl8c1PGWsh4EV+hkwTVYrXNfM9i5AC+z8XoTGw0=; b=Pth671oxxtcIlNon0+FEUMyhymRyo2nEh/6RaSJa28IIb2FECju+8tcV8kH5Ygpbj+ 0fOLF+zX7ulmy/safBqzNN5c6llSesiNpsb0ezURFyrtIjNOwARHIjITkYokAByQixhi VF5SbRiFcp+lLNBAQOxKqZbK6Y1M7G1salw/u8192C6NYYKMespaC7rHHwgPbp666QQV +8yS67Kw6vmmBbLhaMrAaB/QFZ4yfWK9K/QlpJ/0ig8A/g2InLpDgXzBXsGoeNxLkDHA iwwgZUqExdoPMkcDPceqKcT0UxhLlP7bmd5uNZezQ5SfYPbpSPeEI2LW2JsAyZXVwgqT Uwag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729187646; x=1729792446; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SvCFzl8c1PGWsh4EV+hkwTVYrXNfM9i5AC+z8XoTGw0=; b=T2twUbw0dfOJzt5PltJgaVgGErmR8psiRyEeFwFm2/ATUitcfG1rU9oYsdp1R/vBFp ubOp2rhQN2GBgK6SX9j+rLeKYuKHmof0xlYfftlr/DXfBMD1wR4q6g86Dl/fkiwZAtfi DKHk2G+gLQLMBDCiloCXEgMi1gJoGRE4dDjeNJtfzYOcrv7N/ZFF801mNs9dZkYeUoqX CcBM0iboDC4bX8uQoFcaPpEKw4B6jD8f1AMgizkiuJMKNgCZIOIs23TnFhGKYcfmTWRV Oww777x3Fif11wWwdazGfcUWSWwCmHnhRleTdpyAeinGMiuhqOsk0ZZoxoaolWOT9PSc buzA== X-Forwarded-Encrypted: i=1; AJvYcCU55AbEBFG36nJz0L0It9eHs/mDOaC7kO5jiLrZfcXbLXV22lA//fANE9/W/EAlKBnQj19uBVhVN9vSxPk=@vger.kernel.org X-Gm-Message-State: AOJu0YwzaiDC+/eGs8/+JLJb52HAjtn6NNyvlShYYsWA/8Wf/SwLSHs3 TVddItg+oROC4HWzjEP0rf6HiwDeNlJEDuesD/fyN+JT7U41XSfV/cZ3BXOjlJ+aMBVLhsjRfy9 X2JY0NQ== X-Google-Smtp-Source: AGHT+IFlmA1tf2B1a5er6bTub7GvcxLouK/2eBonblCcnbTWMLGRQp2J49vwfdT3KnR075GkZWCQGOMeiBp8 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:98a5:142e:8c2e:e9e5]) (user=irogers job=sendgmr) by 2002:a05:690c:670a:b0:6db:e464:addc with SMTP id 00721157ae682-6e5a3d922c2mr1475937b3.4.1729187646038; Thu, 17 Oct 2024 10:54:06 -0700 (PDT) Date: Thu, 17 Oct 2024 10:53:51 -0700 In-Reply-To: <20241017175356.783793-1-irogers@google.com> Message-Id: <20241017175356.783793-3-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241017175356.783793-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v5 2/7] perf stat: Fix/add parameter names for print_metric From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Yicong Yang , Tim Chen , Thomas Richter , Sumanth Korikkar , Weilin Wang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The print_metric parameter names were rearranged, fix and add comments in the stat-shadow callers to ensure they are correct. Signed-off-by: Ian Rogers --- tools/perf/util/stat-shadow.c | 55 ++++++++++++++++++++--------------- tools/perf/util/stat.h | 6 ++-- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 6227de848083..512890d50b69 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -196,17 +196,21 @@ static void print_ratio(struct perf_stat_config *conf= ig, const struct evsel *evsel, int aggr_idx, double numerator, struct perf_stat_output_ctx *out, enum stat_type denominator_type, - const double color_ratios[3], const char *unit) + const double color_ratios[3], const char *_unit) { double denominator =3D find_stat(evsel, aggr_idx, denominator_type); + double ratio =3D 0; + const char *color =3D NULL; + const char *fmt =3D NULL; + const char *unit =3D NULL; =20 if (numerator && denominator) { - double ratio =3D numerator / denominator * 100.0; - const char *color =3D get_ratio_color(color_ratios, ratio); - - out->print_metric(config, out->ctx, color, "%7.2f%%", unit, ratio); - } else - out->print_metric(config, out->ctx, NULL, NULL, unit, 0); + ratio =3D numerator / denominator * 100.0; + color =3D get_ratio_color(color_ratios, ratio); + fmt =3D "%7.2f%%"; + unit =3D _unit; + } + out->print_metric(config, out->ctx, color, fmt, unit, ratio); } =20 static void print_stalled_cycles_front(struct perf_stat_config *config, @@ -320,14 +324,15 @@ static void print_instructions(struct perf_stat_confi= g *config, find_stat(evsel, aggr_idx, STAT_STALLED_CYCLES_BACK)); =20 if (cycles) { - print_metric(config, ctxp, NULL, "%7.2f ", "insn per cycle", - instructions / cycles); - } else - print_metric(config, ctxp, NULL, NULL, "insn per cycle", 0); + print_metric(config, ctxp, /*color=3D*/NULL, "%7.2f ", "insn per cycle", + instructions / cycles); + } else { + print_metric(config, ctxp, /*color=3D*/NULL, /*fmt=3D*/NULL, "insn per c= ycle", 0); + } =20 if (max_stalled && instructions) { out->new_line(config, ctxp); - print_metric(config, ctxp, NULL, "%7.2f ", "stalled cycles per insn", + print_metric(config, ctxp, /*color=3D*/NULL, "%7.2f ", "stalled cycles p= er insn", max_stalled / instructions); } } @@ -342,9 +347,10 @@ static void print_cycles(struct perf_stat_config *conf= ig, if (cycles && nsecs) { double ratio =3D cycles / nsecs; =20 - out->print_metric(config, out->ctx, NULL, "%8.3f", "GHz", ratio); - } else - out->print_metric(config, out->ctx, NULL, NULL, "GHz", 0); + out->print_metric(config, out->ctx, /*color=3D*/NULL, "%8.3f", "GHz", ra= tio); + } else { + out->print_metric(config, out->ctx, /*color=3D*/NULL, /*fmt=3D*/NULL, "G= Hz", 0); + } } =20 static void print_nsecs(struct perf_stat_config *config, @@ -357,10 +363,11 @@ static void print_nsecs(struct perf_stat_config *conf= ig, double wall_time =3D avg_stats(&walltime_nsecs_stats); =20 if (wall_time) { - print_metric(config, ctxp, NULL, "%8.3f", "CPUs utilized", + print_metric(config, ctxp, /*color=3D*/NULL, "%8.3f", "CPUs utilized", nsecs / (wall_time * evsel->scale)); - } else - print_metric(config, ctxp, NULL, NULL, "CPUs utilized", 0); + } else { + print_metric(config, ctxp, /*color=3D*/NULL, /*fmt=3D*/NULL, "CPUs utili= zed", 0); + } } =20 static int prepare_metric(const struct metric_expr *mexp, @@ -542,12 +549,12 @@ static void generic_metric(struct perf_stat_config *c= onfig, ratio); } } else { - print_metric(config, ctxp, color, /*unit=3D*/NULL, + print_metric(config, ctxp, color, /*fmt=3D*/NULL, out->force_header ? (metric_name ?: evsel->name) : "", 0); } } else { - print_metric(config, ctxp, color, /*unit=3D*/NULL, + print_metric(config, ctxp, color, /*fmt=3D*/NULL, out->force_header ? (metric_name ?: evsel->name) : "", 0); } @@ -718,9 +725,11 @@ void perf_stat__print_shadow_stats(struct perf_stat_co= nfig *config, =20 if (unit !=3D ' ') snprintf(unit_buf, sizeof(unit_buf), "%c/sec", unit); - print_metric(config, ctxp, NULL, "%8.3f", unit_buf, ratio); - } else + print_metric(config, ctxp, /*color=3D*/NULL, "%8.3f", + unit_buf, ratio); + } else { num =3D 0; + } } } =20 @@ -728,7 +737,7 @@ void perf_stat__print_shadow_stats(struct perf_stat_con= fig *config, &num, NULL, out, metric_events); =20 if (num =3D=3D 0) - print_metric(config, ctxp, NULL, NULL, NULL, 0); + print_metric(config, ctxp, /*color=3D*/NULL, /*fmt=3D*/NULL, /*unit=3D*/= NULL, 0); } =20 /** diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index fd7a187551bd..a5f3d7d00101 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -155,8 +155,10 @@ extern struct stats walltime_nsecs_stats; extern struct rusage_stats ru_stats; =20 typedef void (*print_metric_t)(struct perf_stat_config *config, - void *ctx, const char *color, const char *unit, - const char *fmt, double val); + void *ctx, const char *color, + const char *fmt, + const char *unit, + double val); typedef void (*new_line_t)(struct perf_stat_config *config, void *ctx); =20 /* Used to print the display name of the Default metricgroup for now. */ --=20 2.47.0.105.g07ac214952-goog From nobody Tue Nov 26 12:44:55 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24D061E008D for ; Thu, 17 Oct 2024 17:54:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729187650; cv=none; b=aeZl0PpeFsfKXCDyUgfnvHl33O+AoYOPTjMPErirR7xupSYcBRe94j79wr9yxO4gMatn4YlzdilCJwmIXJtFDxqNgWY1yf+uNclFNn2s+8tLjz6rXQYzjG2TWMIlc4jXlHc/NyyNimtCIUjCa2BC5ZLtg/wg+gsACfN3qCBFde8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729187650; c=relaxed/simple; bh=d4p2SSC+jRmzGX9QPS6kNxF3hzHXI6/kfpx81KrMoUw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=KC0R3iOVttbeIiqATHz21qt/cGf3rXN3TCloPqZw3l/+v6ZtSXwiM0Ds3E4eEO16+GqwK0/c7gi2Aq3JrKbu3JO31ng6F49CBrbFqcqGpMMsloNZb3ho3KQMhnB/d/Iar5emzs9P+I9fJlTpUyNpiQ9S7ikdjiR8g+pWr6gH+po= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=UtXbRUDC; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UtXbRUDC" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e31e5d1739so21682827b3.1 for ; Thu, 17 Oct 2024 10:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729187648; x=1729792448; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=82hKZR8Ty5xgYC+xyYfKClAaNBzZJMlhS4+fNhwIq44=; b=UtXbRUDC+PD/2L1h69b6UO3C7Arl5kBYSbI6DP5EQb2f4Hf7Hn9aAVUOJp0mcxU2n7 FELYmGdDFyxea8EyxdXslbt/ZLS6qBIOIyUoiqGjpUrat8Yr8gJWQsjMjkN7uvptiA3M ze/uXusPm+Xr7FC8Nx91ek/R6X8v3fH5lNzJtPjLQ3t4kSnLQJW5T13e9DVyVKSPMHIW 4mUJqYXHcHfc9gmuq5wozX7AxFZyOcm2bgkB4/1kHuZWRTEc2/kqE+T6nh7XC92mGdPD m0AU+JSOuNbUZ1Q4Et4bbLO4DZFXbnZhWgSdUZ289ME9dI5DNGNe+k5L2DXOMQjU4dWE 6Z/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729187648; x=1729792448; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=82hKZR8Ty5xgYC+xyYfKClAaNBzZJMlhS4+fNhwIq44=; b=a+h0kwlThloY/3VsyzIpdihuB+MF9YfTAziGEVDaHrbaCO0ozJmzfjhqbbaA7fGewg OLop3T2g+fdRS0PzJ+PKEZ5OVoLtT2ieCKPch431S9ELFM4CCZpDmboWlrKpTJl3Wg2g Gm3T9Dgz5n7o3ehuGopvEJlvbFUVXGpyXqNzw9utkAV0MQV8dEX9XksU8y+UOmGMPmxz DB/g8qn1RE6J2/sP5H5BdPwqtPZgNVEfGF47FZLkhkUM4nR/cbYIQsyEiq8CJ7bQ1vzX W8R5senPgxg8fNMFvPOkYElRZs8BIvGwYHUrjawFl03xis6syqqPt8geOWAoVCRN+uv8 1yVg== X-Forwarded-Encrypted: i=1; AJvYcCXcwAGfo9PauKGRISBVTFm6IDcM8ago//zcNhj1eE8kcPoW7XlUmKVQvcINe2ppnqDkVCqjvbvY/fVpDQg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1pv8Qdhgbh/y7yeKloqw5E83EJzjC3wLeuqaXBdmOnl662zxj Bjw5t3oGb21DNRFCdRbxtmCdiw1Jbb+A8ZCH/4Sh3V2gsEWiAHB7Xb+2lGjiOYTxDH43GtK9Ehb pI20giQ== X-Google-Smtp-Source: AGHT+IFWI153JAZftkTDRK4H3G+AWk03BVP1rqIrqsWHYCRDtPZDe81i5SeYYAG+nYoX4BSvPym+jcuhv3xr X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:98a5:142e:8c2e:e9e5]) (user=irogers job=sendgmr) by 2002:a05:690c:4d04:b0:6db:c34f:9e4f with SMTP id 00721157ae682-6e3d4213b28mr1776457b3.8.1729187648222; Thu, 17 Oct 2024 10:54:08 -0700 (PDT) Date: Thu, 17 Oct 2024 10:53:52 -0700 In-Reply-To: <20241017175356.783793-1-irogers@google.com> Message-Id: <20241017175356.783793-4-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241017175356.783793-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v5 3/7] perf stat: Display "none" for NaN with metric only json From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Yicong Yang , Tim Chen , Thomas Richter , Sumanth Korikkar , Weilin Wang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Return earlier for an empty unit case. If snprintf of the fmt doesn't produce digits between vals and ends, as happens with NaN, make the value "none" as happens in print_metric_end. Signed-off-by: Ian Rogers --- tools/perf/util/stat-display.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index ef0ca8cd802d..a137b377efa4 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -610,19 +610,22 @@ static void print_metric_only_json(struct perf_stat_c= onfig *config __maybe_unuse { struct outstate *os =3D ctx; FILE *out =3D os->fh; - char buf[64], *vals, *ends; + char buf[64], *ends; char tbuf[1024]; + const char *vals; =20 if (!valid_only_metric(unit)) return; unit =3D fixunit(tbuf, os->evsel, unit); + if (!unit[0]) + return; snprintf(buf, sizeof(buf), fmt ?: "", val); - ends =3D vals =3D skip_spaces(buf); + vals =3D ends =3D skip_spaces(buf); while (isdigit(*ends) || *ends =3D=3D '.') ends++; *ends =3D 0; - if (!unit[0] || !vals[0]) - return; + if (!vals[0]) + vals =3D "none"; fprintf(out, "%s\"%s\" : \"%s\"", os->first ? "" : ", ", unit, vals); os->first =3D false; } --=20 2.47.0.105.g07ac214952-goog From nobody Tue Nov 26 12:44:55 2024 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A86641E04B8 for ; Thu, 17 Oct 2024 17:54:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729187657; cv=none; b=haz7Zmy8QxKCoNDKxhR/YxfTMZq1G/xe0Dm9jJ/Qc0GTg/BSwQ+Xnnd/7f/YDGEAW/p83U2lmVbzAA817nHLOw/8UB0vWW08nh8bwww96Sx2r42WQ8NY0bDI2onUzb5HQeR7ALYUDD4JNfwawkckn7KVyDssKOv0R9P6q6ZDpS4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729187657; c=relaxed/simple; bh=tWKJqnfBwSOmrMspZ2sdkDVmtmOQkJadh5Otwb2PTrM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=iATtY5olF31GDjlpGCjBr81t2vSGvGh/YiKEFls8s/AEyzBV0j98Q0B5iRiz741VAVBq56skIc+2yRcLa4IsRG68H9pNXOupcXs5Quw7UQRzJLIT9YxcVfaPUoIrsiHOFUEXLJL7hmMsxj5lwYNGuj1x/Gze7HBoE8SwARTU31c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lh/iWkIw; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lh/iWkIw" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e28ef71f0d8so2397675276.0 for ; Thu, 17 Oct 2024 10:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729187651; x=1729792451; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=e2/oyoGU6HrX/Xxl9SMoDXlcRLOo1IYbCdJ0T7Dlej0=; b=lh/iWkIwsTys6DiiIOyHXtaFeDynTgub0bnsHrqqCCm2YL77fTWcX0qChsa481eJ2U Mdm6mv8R77gkzimulNOmt0b3RmxYQZVf/aPx3ag7ykvjxHk/DakcyrWA3XbHsAdacnhC u/UuTkoltwnjubpZkSQYW3dYNA8BSIwq29r4RJIkWW3GQkF5OARXDG0XKtrc80kL9YCd 8mYFivJFGo0jDPikMvUp/2J0C3JyCyDFz8Lwj7puXSRbAgLBq+rMktMGpJ9XI6o78+U2 agDT2Acsk247kcg6SLo9E8ie07fsrYKQnI/2qkFriUcreDLZM7c+StlG22GGjatX0b16 V14w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729187651; x=1729792451; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=e2/oyoGU6HrX/Xxl9SMoDXlcRLOo1IYbCdJ0T7Dlej0=; b=o9/bafXWmwnLYTK0lb8uh3OEAU7IbMU8bQ7QXrJrc4oFKB49vjyaEBP2f1puxseM60 TbzuwKOOrHwcnhi8knsl9pNemQrOA6SE1ZDJxFXi8NkJ9bGB2CtmfJaB/r1cCC9Z14Yd Shc8SJKWK6wDf+BAjpUiZpfraSN/c8ANRyPOF2935neWPTRhtdSJ0jfQFtJz7nGCVnLT +xWFfA12Wu2Iv8h1JKjwNFoXzuSTdfNjeBevLfdzyyDIMwFfpyorKY4mwWZBxIGWEKzN 9RsvXYFRFa5sH9z+aOaADQYfBM/vfGxb8gft9tPvECACQFTYB6dSa2ZRyt5uvtgZRpBk ZOMw== X-Forwarded-Encrypted: i=1; AJvYcCW77/r4scwlwWWV4vd8chwwkWFC8VyqkOPy81kfv1KC2qxWPA/ZWNKGhtni+RxZyXLzyzmYaDOEed5rii4=@vger.kernel.org X-Gm-Message-State: AOJu0YxNXAzt/l9UUKttTo3Rf6/oH6RYyrSONIvJ2Wv+5nxMPaYUx/iw 5ozuSR3s1Xs8JMPE0mIiIukZm3fvTHryXrDJY/FNMtu3DcmWWL+yOlhIPmWGBfjWqGRTXXYAXVL 1TVe5jQ== X-Google-Smtp-Source: AGHT+IF8ZgJiYZC6Y4MdQnp0pzNBftyhUw/O0yoGc816lrCGCTote0tRmMfBMHmL7XgCp8i4ttUMCJ5vA92g X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:98a5:142e:8c2e:e9e5]) (user=irogers job=sendgmr) by 2002:a25:b204:0:b0:e25:cea9:b0e with SMTP id 3f1490d57ef6-e2978594b05mr4017276.9.1729187650384; Thu, 17 Oct 2024 10:54:10 -0700 (PDT) Date: Thu, 17 Oct 2024 10:53:53 -0700 In-Reply-To: <20241017175356.783793-1-irogers@google.com> Message-Id: <20241017175356.783793-5-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241017175356.783793-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v5 4/7] perf stat: Drop metric-unit if unit is NULL From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Yicong Yang , Tim Chen , Thomas Richter , Sumanth Korikkar , Weilin Wang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Avoid cases like: ``` $ perf stat -a -M topdownl1 -j -I 1000 ... {"interval" : 11.127757275, "counter-value" : "85715898.000000", "unit" : "= ", "event" : "IDQ.MITE_UOPS", "event-runtime" : 988376123, "pcnt-running" := 100.00, "metric-value" : "0.000000", "metric-unit" : "(null)"} ... ``` If there is no unit then drop the metric-value too as: Suggested-by: Tim Chen Signed-off-by: Ian Rogers --- tools/perf/util/stat-display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index a137b377efa4..c6d33010ed22 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -471,8 +471,8 @@ static void print_metric_json(struct perf_stat_config *= config __maybe_unused, struct outstate *os =3D ctx; FILE *out =3D os->fh; =20 - fprintf(out, "\"metric-value\" : \"%f\", ", val); - fprintf(out, "\"metric-unit\" : \"%s\"", unit); + if (unit) + fprintf(out, "\"metric-value\" : \"%f\", \"metric-unit\" : \"%s\"", val,= unit); if (!config->metric_only) fprintf(out, "}"); } --=20 2.47.0.105.g07ac214952-goog From nobody Tue Nov 26 12:44:55 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA6411E0B86 for ; Thu, 17 Oct 2024 17:54:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729187655; cv=none; b=hdUKIZTrtX5PCHXjO+uyJqrwt8c2ddCelzUoN2YTmUrFWgTYf8y+D7TAOB+V6pIMBxbBzMpClmwWtYAFqE9gTukeBCSkweMdEM/MpMb7pGBz/P589mbORcGXlbxwRD6be1wCw0+0Q0uDnSYqa4NplDv/dkbrCi/+p85A6GEyBM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729187655; c=relaxed/simple; bh=RVW6wkDVKjRG51bYEhA4x0xQ+lNpEYTqs22+cLMthkA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Qk8Hotc9oSgigXj0fePxXYHAOXoyewh/7SiiQu/GoiCd7MgbOVkh1gHMdMth9FGC7s+QWmr1nBlpvHTbBkzp24gO4S8KOHZ1xnvmd8YpiV/pSiKOM3KUKTTi4yYaSSoG8FkdL1JQPX99zjjq9//AbKWmQfvdexea0lEXL5JH9HU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hYCaWgqL; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hYCaWgqL" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e35a643200so30809267b3.0 for ; Thu, 17 Oct 2024 10:54:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729187652; x=1729792452; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=YGfOVTovWxk2hP7JLrRDPs7H1ZDJlZRA8sfvnLLeCQY=; b=hYCaWgqLBNNgkxjhE3UaTwn/yLYo7u8yI/qKDITjTNiYTahc6tpSDtwNgLcLm4MO9H RaR4iPAnWfv7PWK8qYofJTIqkbenvsu6u84sPvDeQnVpBw1GhhGXAgX9NUJSExo4E7b/ DFRtDcDwylAoc9oPovQ9/F5niySeY5TmKafsDo4pbCdMKbiz2m+RUnb7XKXKkGAU5VhD J6xpIYulr8SISFRiL5x9WSjX7TiWnGjhuGOmC3sdgRAByub/43R6dWe1ktfeUK4t8Fgh z9j7lOzismmBnQm1a9ibAXhopswqhAuWPfYtXF0f2Vp6fElhsRWGKWQIGGyQOK6Oqx7g PAzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729187652; x=1729792452; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YGfOVTovWxk2hP7JLrRDPs7H1ZDJlZRA8sfvnLLeCQY=; b=fB6mXMa8nSwqN8e8HMH1zoy2fCYffgZ/TY4YzpbFEJYjBPRCuM8ZW5ZR3UxruM4U6l Sak3KF2cf/kOnv05IGi30Z8S3b6BgG7z11dp7FYKKvocPY6l7rBdcR5u0SQ+LZMdbCba 2kVQIV03n7fstOSzA9Tr5L2g0xCtpXOQmebVyzR91CMuUOPmq7Mu56N5lYK6gvcPS6OO dQfG+f8OBT7yFi4O5lkEv+xAOT+csRU45EaTLhEfVqONzLMUE4WDyE5oMOp1LVr4iYkM 636Z3lfb9/dqk/4Rwm9HWbLW+Rzoj7N+v782MCvSHxRqq/uRp0Wg2lz6tnz2/3SvqFfk OArQ== X-Forwarded-Encrypted: i=1; AJvYcCX3GITxdm2ihRy6hrRK5TJPpIiTj6V9v0mZ87LnNTPbwzEpvELKawIQwHDKBxFurCFUWAbICC+/71MCEsw=@vger.kernel.org X-Gm-Message-State: AOJu0Ywrhy2Y6c2jNwSsXC1NTuhB1vo4+g/32yd7NqwgMNKogaNL49I8 uOVYaYhdBKWXyx3kXru9hpU2dizOtbvxlm3c9dGLmeGGLIVg50nV5NEFSoO98qp+wTa6w4u7Ji2 hg7H4kw== X-Google-Smtp-Source: AGHT+IFoZMHDMn6AMV5fhVkttYOF6CVW6VkH2HB6bY2Y7c+Qq9+Ya9kmJR9Hjd6uiVVH8rNeDRyRgKUFqoba X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:98a5:142e:8c2e:e9e5]) (user=irogers job=sendgmr) by 2002:a05:690c:9a92:b0:6e2:120b:be57 with SMTP id 00721157ae682-6e3d41ca705mr1411897b3.5.1729187652710; Thu, 17 Oct 2024 10:54:12 -0700 (PDT) Date: Thu, 17 Oct 2024 10:53:54 -0700 In-Reply-To: <20241017175356.783793-1-irogers@google.com> Message-Id: <20241017175356.783793-6-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241017175356.783793-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v5 5/7] perf stat: Change color to threshold in print_metric From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Yicong Yang , Tim Chen , Thomas Richter , Sumanth Korikkar , Weilin Wang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Colors don't mean things in CSV and JSON output, switch to a threshold enum value that the standard output can convert to a color. Updating the CSV and JSON output will be later changes. Signed-off-by: Ian Rogers --- tools/perf/arch/x86/util/iostat.c | 2 +- tools/perf/builtin-script.c | 6 +- tools/perf/util/stat-display.c | 40 ++++++++---- tools/perf/util/stat-shadow.c | 105 +++++++++++++++--------------- tools/perf/util/stat.h | 12 +++- 5 files changed, 97 insertions(+), 68 deletions(-) diff --git a/tools/perf/arch/x86/util/iostat.c b/tools/perf/arch/x86/util/i= ostat.c index df7b5dfcc26a..366b44d0bb7e 100644 --- a/tools/perf/arch/x86/util/iostat.c +++ b/tools/perf/arch/x86/util/iostat.c @@ -444,7 +444,7 @@ void iostat_print_metric(struct perf_stat_config *confi= g, struct evsel *evsel, iostat_value =3D (count->val - prev_count_val) / ((double) count->run / count->ena); } - out->print_metric(config, out->ctx, NULL, "%8.0f", iostat_metric, + out->print_metric(config, out->ctx, METRIC_THRESHOLD_UNKNOWN, "%8.0f", io= stat_metric, iostat_value / (256 * 1024)); } =20 diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index a644787fa9e1..8c5d5cecfba4 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2136,11 +2136,11 @@ struct metric_ctx { }; =20 static void script_print_metric(struct perf_stat_config *config __maybe_un= used, - void *ctx, const char *color, - const char *fmt, - const char *unit, double val) + void *ctx, enum metric_threshold_classify thresh, + const char *fmt, const char *unit, double val) { struct metric_ctx *mctx =3D ctx; + const char *color =3D metric_threshold_classify__color(thresh); =20 if (!fmt) return; diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index c6d33010ed22..5974aaead95f 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -73,6 +73,19 @@ static const char *aggr_header_std[] =3D { [AGGR_GLOBAL] =3D "" }; =20 +const char *metric_threshold_classify__color(enum metric_threshold_classif= y thresh) +{ + const char * const colors[] =3D { + "", /* unknown */ + PERF_COLOR_RED, /* bad */ + PERF_COLOR_MAGENTA, /* nearly bad */ + PERF_COLOR_YELLOW, /* less good */ + PERF_COLOR_GREEN, /* good */ + }; + static_assert(ARRAY_SIZE(colors) - 1 =3D=3D METRIC_THRESHOLD_GOOD, "miss= ing enum value"); + return colors[thresh]; +} + static void print_running_std(struct perf_stat_config *config, u64 run, u6= 4 ena) { if (run !=3D ena) @@ -405,13 +418,14 @@ static void do_new_line_std(struct perf_stat_config *= config, } =20 static void print_metric_std(struct perf_stat_config *config, - void *ctx, const char *color, const char *fmt, - const char *unit, double val) + void *ctx, enum metric_threshold_classify thresh, + const char *fmt, const char *unit, double val) { struct outstate *os =3D ctx; FILE *out =3D os->fh; int n; bool newline =3D os->newline; + const char *color =3D metric_threshold_classify__color(thresh); =20 os->newline =3D false; =20 @@ -443,7 +457,7 @@ static void new_line_csv(struct perf_stat_config *confi= g, void *ctx) =20 static void print_metric_csv(struct perf_stat_config *config __maybe_unuse= d, void *ctx, - const char *color __maybe_unused, + enum metric_threshold_classify thresh __maybe_unused, const char *fmt, const char *unit, double val) { struct outstate *os =3D ctx; @@ -464,7 +478,7 @@ static void print_metric_csv(struct perf_stat_config *c= onfig __maybe_unused, =20 static void print_metric_json(struct perf_stat_config *config __maybe_unus= ed, void *ctx, - const char *color __maybe_unused, + enum metric_threshold_classify thresh __maybe_unused, const char *fmt __maybe_unused, const char *unit, double val) { @@ -559,13 +573,14 @@ static const char *fixunit(char *buf, struct evsel *e= vsel, } =20 static void print_metric_only(struct perf_stat_config *config, - void *ctx, const char *color, const char *fmt, - const char *unit, double val) + void *ctx, enum metric_threshold_classify thresh, + const char *fmt, const char *unit, double val) { struct outstate *os =3D ctx; FILE *out =3D os->fh; char buf[1024], str[1024]; unsigned mlen =3D config->metric_only_len; + const char *color =3D metric_threshold_classify__color(thresh); =20 if (!valid_only_metric(unit)) return; @@ -582,7 +597,8 @@ static void print_metric_only(struct perf_stat_config *= config, } =20 static void print_metric_only_csv(struct perf_stat_config *config __maybe_= unused, - void *ctx, const char *color __maybe_unused, + void *ctx, + enum metric_threshold_classify thresh __maybe_unused, const char *fmt, const char *unit, double val) { @@ -604,7 +620,8 @@ static void print_metric_only_csv(struct perf_stat_conf= ig *config __maybe_unused } =20 static void print_metric_only_json(struct perf_stat_config *config __maybe= _unused, - void *ctx, const char *color __maybe_unused, + void *ctx, + enum metric_threshold_classify thresh __maybe_unused, const char *fmt, const char *unit, double val) { @@ -636,7 +653,8 @@ static void new_line_metric(struct perf_stat_config *co= nfig __maybe_unused, } =20 static void print_metric_header(struct perf_stat_config *config, - void *ctx, const char *color __maybe_unused, + void *ctx, + enum metric_threshold_classify thresh __maybe_unused, const char *fmt __maybe_unused, const char *unit, double val __maybe_unused) { @@ -810,7 +828,7 @@ static void printout(struct perf_stat_config *config, s= truct outstate *os, =20 if (run =3D=3D 0 || ena =3D=3D 0 || counter->counts->scaled =3D=3D -1) { if (config->metric_only) { - pm(config, os, NULL, "", "", 0); + pm(config, os, METRIC_THRESHOLD_UNKNOWN, "", "", 0); return; } =20 @@ -865,7 +883,7 @@ static void printout(struct perf_stat_config *config, s= truct outstate *os, perf_stat__print_shadow_stats(config, counter, uval, aggr_idx, &out, &config->metric_events); } else { - pm(config, os, /*color=3D*/NULL, /*format=3D*/NULL, /*unit=3D*/"", /*val= =3D*/0); + pm(config, os, METRIC_THRESHOLD_UNKNOWN, /*format=3D*/NULL, /*unit=3D*/"= ", /*val=3D*/0); } =20 if (!config->metric_only) { diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 512890d50b69..ada787947e16 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -137,18 +137,14 @@ static enum stat_type evsel__stat_type(struct evsel *= evsel) return STAT_NONE; } =20 -static const char *get_ratio_color(const double ratios[3], double val) +static enum metric_threshold_classify get_ratio_thresh(const double ratios= [3], double val) { - const char *color =3D PERF_COLOR_NORMAL; + assert(ratios[0] > ratios[1]); + assert(ratios[1] > ratios[2]); =20 - if (val > ratios[0]) - color =3D PERF_COLOR_RED; - else if (val > ratios[1]) - color =3D PERF_COLOR_MAGENTA; - else if (val > ratios[2]) - color =3D PERF_COLOR_YELLOW; - - return color; + return val > ratios[1] + ? (val > ratios[0] ? METRIC_THRESHOLD_BAD : METRIC_THRESHOLD_NEARLY_BAD) + : (val > ratios[2] ? METRIC_THRESHOLD_LESS_GOOD : METRIC_THRESHOLD_GOOD); } =20 static double find_stat(const struct evsel *evsel, int aggr_idx, enum stat= _type type) @@ -196,21 +192,21 @@ static void print_ratio(struct perf_stat_config *conf= ig, const struct evsel *evsel, int aggr_idx, double numerator, struct perf_stat_output_ctx *out, enum stat_type denominator_type, - const double color_ratios[3], const char *_unit) + const double thresh_ratios[3], const char *_unit) { double denominator =3D find_stat(evsel, aggr_idx, denominator_type); double ratio =3D 0; - const char *color =3D NULL; + enum metric_threshold_classify thresh =3D METRIC_THRESHOLD_UNKNOWN; const char *fmt =3D NULL; const char *unit =3D NULL; =20 if (numerator && denominator) { ratio =3D numerator / denominator * 100.0; - color =3D get_ratio_color(color_ratios, ratio); + thresh =3D get_ratio_thresh(thresh_ratios, ratio); fmt =3D "%7.2f%%"; unit =3D _unit; } - out->print_metric(config, out->ctx, color, fmt, unit, ratio); + out->print_metric(config, out->ctx, thresh, fmt, unit, ratio); } =20 static void print_stalled_cycles_front(struct perf_stat_config *config, @@ -218,9 +214,9 @@ static void print_stalled_cycles_front(struct perf_stat= _config *config, int aggr_idx, double stalled, struct perf_stat_output_ctx *out) { - static const double color_ratios[3] =3D {50.0, 30.0, 10.0}; + const double thresh_ratios[3] =3D {50.0, 30.0, 10.0}; =20 - print_ratio(config, evsel, aggr_idx, stalled, out, STAT_CYCLES, color_rat= ios, + print_ratio(config, evsel, aggr_idx, stalled, out, STAT_CYCLES, thresh_ra= tios, "frontend cycles idle"); } =20 @@ -229,9 +225,9 @@ static void print_stalled_cycles_back(struct perf_stat_= config *config, int aggr_idx, double stalled, struct perf_stat_output_ctx *out) { - static const double color_ratios[3] =3D {75.0, 50.0, 20.0}; + const double thresh_ratios[3] =3D {75.0, 50.0, 20.0}; =20 - print_ratio(config, evsel, aggr_idx, stalled, out, STAT_CYCLES, color_rat= ios, + print_ratio(config, evsel, aggr_idx, stalled, out, STAT_CYCLES, thresh_ra= tios, "backend cycles idle"); } =20 @@ -240,9 +236,9 @@ static void print_branch_miss(struct perf_stat_config *= config, int aggr_idx, double misses, struct perf_stat_output_ctx *out) { - static const double color_ratios[3] =3D {20.0, 10.0, 5.0}; + const double thresh_ratios[3] =3D {20.0, 10.0, 5.0}; =20 - print_ratio(config, evsel, aggr_idx, misses, out, STAT_BRANCHES, color_ra= tios, + print_ratio(config, evsel, aggr_idx, misses, out, STAT_BRANCHES, thresh_r= atios, "of all branches"); } =20 @@ -251,9 +247,9 @@ static void print_l1d_miss(struct perf_stat_config *con= fig, int aggr_idx, double misses, struct perf_stat_output_ctx *out) { - static const double color_ratios[3] =3D {20.0, 10.0, 5.0}; + const double thresh_ratios[3] =3D {20.0, 10.0, 5.0}; =20 - print_ratio(config, evsel, aggr_idx, misses, out, STAT_L1_DCACHE, color_r= atios, + print_ratio(config, evsel, aggr_idx, misses, out, STAT_L1_DCACHE, thresh_= ratios, "of all L1-dcache accesses"); } =20 @@ -262,9 +258,9 @@ static void print_l1i_miss(struct perf_stat_config *con= fig, int aggr_idx, double misses, struct perf_stat_output_ctx *out) { - static const double color_ratios[3] =3D {20.0, 10.0, 5.0}; + const double thresh_ratios[3] =3D {20.0, 10.0, 5.0}; =20 - print_ratio(config, evsel, aggr_idx, misses, out, STAT_L1_ICACHE, color_r= atios, + print_ratio(config, evsel, aggr_idx, misses, out, STAT_L1_ICACHE, thresh_= ratios, "of all L1-icache accesses"); } =20 @@ -273,9 +269,9 @@ static void print_ll_miss(struct perf_stat_config *conf= ig, int aggr_idx, double misses, struct perf_stat_output_ctx *out) { - static const double color_ratios[3] =3D {20.0, 10.0, 5.0}; + const double thresh_ratios[3] =3D {20.0, 10.0, 5.0}; =20 - print_ratio(config, evsel, aggr_idx, misses, out, STAT_LL_CACHE, color_ra= tios, + print_ratio(config, evsel, aggr_idx, misses, out, STAT_LL_CACHE, thresh_r= atios, "of all LL-cache accesses"); } =20 @@ -284,9 +280,9 @@ static void print_dtlb_miss(struct perf_stat_config *co= nfig, int aggr_idx, double misses, struct perf_stat_output_ctx *out) { - static const double color_ratios[3] =3D {20.0, 10.0, 5.0}; + const double thresh_ratios[3] =3D {20.0, 10.0, 5.0}; =20 - print_ratio(config, evsel, aggr_idx, misses, out, STAT_DTLB_CACHE, color_= ratios, + print_ratio(config, evsel, aggr_idx, misses, out, STAT_DTLB_CACHE, thresh= _ratios, "of all dTLB cache accesses"); } =20 @@ -295,9 +291,9 @@ static void print_itlb_miss(struct perf_stat_config *co= nfig, int aggr_idx, double misses, struct perf_stat_output_ctx *out) { - static const double color_ratios[3] =3D {20.0, 10.0, 5.0}; + const double thresh_ratios[3] =3D {20.0, 10.0, 5.0}; =20 - print_ratio(config, evsel, aggr_idx, misses, out, STAT_ITLB_CACHE, color_= ratios, + print_ratio(config, evsel, aggr_idx, misses, out, STAT_ITLB_CACHE, thresh= _ratios, "of all iTLB cache accesses"); } =20 @@ -306,9 +302,9 @@ static void print_cache_miss(struct perf_stat_config *c= onfig, int aggr_idx, double misses, struct perf_stat_output_ctx *out) { - static const double color_ratios[3] =3D {20.0, 10.0, 5.0}; + const double thresh_ratios[3] =3D {20.0, 10.0, 5.0}; =20 - print_ratio(config, evsel, aggr_idx, misses, out, STAT_CACHE_REFS, color_= ratios, + print_ratio(config, evsel, aggr_idx, misses, out, STAT_CACHE_REFS, thresh= _ratios, "of all cache refs"); } =20 @@ -324,16 +320,16 @@ static void print_instructions(struct perf_stat_confi= g *config, find_stat(evsel, aggr_idx, STAT_STALLED_CYCLES_BACK)); =20 if (cycles) { - print_metric(config, ctxp, /*color=3D*/NULL, "%7.2f ", "insn per cycle", - instructions / cycles); + print_metric(config, ctxp, METRIC_THRESHOLD_UNKNOWN, "%7.2f ", + "insn per cycle", instructions / cycles); } else { - print_metric(config, ctxp, /*color=3D*/NULL, /*fmt=3D*/NULL, "insn per c= ycle", 0); + print_metric(config, ctxp, METRIC_THRESHOLD_UNKNOWN, /*fmt=3D*/NULL, + "insn per cycle", 0); } - if (max_stalled && instructions) { out->new_line(config, ctxp); - print_metric(config, ctxp, /*color=3D*/NULL, "%7.2f ", "stalled cycles p= er insn", - max_stalled / instructions); + print_metric(config, ctxp, METRIC_THRESHOLD_UNKNOWN, "%7.2f ", + "stalled cycles per insn", max_stalled / instructions); } } =20 @@ -347,9 +343,11 @@ static void print_cycles(struct perf_stat_config *conf= ig, if (cycles && nsecs) { double ratio =3D cycles / nsecs; =20 - out->print_metric(config, out->ctx, /*color=3D*/NULL, "%8.3f", "GHz", ra= tio); + out->print_metric(config, out->ctx, METRIC_THRESHOLD_UNKNOWN, "%8.3f", + "GHz", ratio); } else { - out->print_metric(config, out->ctx, /*color=3D*/NULL, /*fmt=3D*/NULL, "G= Hz", 0); + out->print_metric(config, out->ctx, METRIC_THRESHOLD_UNKNOWN, /*fmt=3D*/= NULL, + "GHz", 0); } } =20 @@ -363,10 +361,11 @@ static void print_nsecs(struct perf_stat_config *conf= ig, double wall_time =3D avg_stats(&walltime_nsecs_stats); =20 if (wall_time) { - print_metric(config, ctxp, /*color=3D*/NULL, "%8.3f", "CPUs utilized", + print_metric(config, ctxp, METRIC_THRESHOLD_UNKNOWN, "%8.3f", "CPUs util= ized", nsecs / (wall_time * evsel->scale)); } else { - print_metric(config, ctxp, /*color=3D*/NULL, /*fmt=3D*/NULL, "CPUs utili= zed", 0); + print_metric(config, ctxp, METRIC_THRESHOLD_UNKNOWN, /*fmt=3D*/NULL, + "CPUs utilized", 0); } } =20 @@ -500,7 +499,7 @@ static void generic_metric(struct perf_stat_config *con= fig, double ratio, scale, threshold; int i; void *ctxp =3D out->ctx; - const char *color =3D NULL; + enum metric_threshold_classify thresh =3D METRIC_THRESHOLD_UNKNOWN; =20 pctx =3D expr__ctx_new(); if (!pctx) @@ -523,8 +522,8 @@ static void generic_metric(struct perf_stat_config *con= fig, if (metric_threshold && expr__parse(&threshold, pctx, metric_threshold) =3D=3D 0 && !isnan(threshold)) { - color =3D fpclassify(threshold) =3D=3D FP_ZERO - ? PERF_COLOR_GREEN : PERF_COLOR_RED; + thresh =3D fpclassify(threshold) =3D=3D FP_ZERO + ? METRIC_THRESHOLD_GOOD : METRIC_THRESHOLD_BAD; } =20 if (metric_unit && metric_name) { @@ -539,22 +538,22 @@ static void generic_metric(struct perf_stat_config *c= onfig, scnprintf(metric_bf, sizeof(metric_bf), "%s %s", unit, metric_name); =20 - print_metric(config, ctxp, color, "%8.1f", + print_metric(config, ctxp, thresh, "%8.1f", metric_bf, ratio); } else { - print_metric(config, ctxp, color, "%8.2f", + print_metric(config, ctxp, thresh, "%8.2f", metric_name ? metric_name : out->force_header ? evsel->name : "", ratio); } } else { - print_metric(config, ctxp, color, /*fmt=3D*/NULL, + print_metric(config, ctxp, thresh, /*fmt=3D*/NULL, out->force_header ? (metric_name ?: evsel->name) : "", 0); } } else { - print_metric(config, ctxp, color, /*fmt=3D*/NULL, + print_metric(config, ctxp, thresh, /*fmt=3D*/NULL, out->force_header ? (metric_name ?: evsel->name) : "", 0); } @@ -725,7 +724,7 @@ void perf_stat__print_shadow_stats(struct perf_stat_con= fig *config, =20 if (unit !=3D ' ') snprintf(unit_buf, sizeof(unit_buf), "%c/sec", unit); - print_metric(config, ctxp, /*color=3D*/NULL, "%8.3f", + print_metric(config, ctxp, METRIC_THRESHOLD_UNKNOWN, "%8.3f", unit_buf, ratio); } else { num =3D 0; @@ -736,8 +735,10 @@ void perf_stat__print_shadow_stats(struct perf_stat_co= nfig *config, perf_stat__print_shadow_stats_metricgroup(config, evsel, aggr_idx, &num, NULL, out, metric_events); =20 - if (num =3D=3D 0) - print_metric(config, ctxp, /*color=3D*/NULL, /*fmt=3D*/NULL, /*unit=3D*/= NULL, 0); + if (num =3D=3D 0) { + print_metric(config, ctxp, METRIC_THRESHOLD_UNKNOWN, + /*fmt=3D*/NULL, /*unit=3D*/NULL, 0); + } } =20 /** diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index a5f3d7d00101..6f8cff3cd39a 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -154,8 +154,18 @@ struct evlist; extern struct stats walltime_nsecs_stats; extern struct rusage_stats ru_stats; =20 +enum metric_threshold_classify { + METRIC_THRESHOLD_UNKNOWN, + METRIC_THRESHOLD_BAD, + METRIC_THRESHOLD_NEARLY_BAD, + METRIC_THRESHOLD_LESS_GOOD, + METRIC_THRESHOLD_GOOD, +}; +const char *metric_threshold_classify__color(enum metric_threshold_classif= y thresh); + typedef void (*print_metric_t)(struct perf_stat_config *config, - void *ctx, const char *color, + void *ctx, + enum metric_threshold_classify thresh, const char *fmt, const char *unit, double val); --=20 2.47.0.105.g07ac214952-goog From nobody Tue Nov 26 12:44:55 2024 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBEFF1E008D for ; Thu, 17 Oct 2024 17:54:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729187662; cv=none; b=CZ5mMms6BIJ+L2OH0UIy2UZOatxyUC8V0+rNdc8tlWSvOETHe+FVsHxqmg0kNwRU4Znk7O3tno/0rBeG+BN35MbUxmtjSAihHzOG0PrjQRdFQcLj1BgURrFtiovcmHywe2jN5sY7t4JiPEWVBLa4MNhOOcWjCO6DqJS1aMfuk1E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729187662; c=relaxed/simple; bh=nR/8QLcBCh+39nvfzpZZaCLHNApxIUJpcbhdwvA+Oxk=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=AklfPx9/AfmUGbyCAikC0GuHnO45tyzlSzwieLuzmuHbq0vj8+6QSkM3XmxJpevG9s0sSV+ix00AuttcMpoTGV3F1CJ6LLAWQYxYH6DkoggiP+lX51GrBaUqRC+x62UI3sAIsCMBgVxT8ZpH5h93K/ApC1mkczSywRsyHOhTELo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=FS99niwa; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FS99niwa" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e2974759f5fso1443657276.0 for ; Thu, 17 Oct 2024 10:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729187655; x=1729792455; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Y/n/isiF2Sq7ntpurAmJIm0kx07dBkasA8rH7Du+HlQ=; b=FS99niwa82SQSFyWaEOeE3xIN9+mVy6jXkTOgpfUmraIkOe897q9HcFPcFhpttcRqt 7qAfuGd8IQCqoytpc0/j8EnpNhHrqbJyDOoyAhr3NJ2okjWTf4L47oWZIwtobnpZJ5CU J+nmdmro7nX9RtzjqZbt9vsL7PZagsC4OKG//gGSZ9ToTcl/lXl3dpRtjwV+3heIvimx JlQzugw4+OrHqBVRGahQrGOl9z+sUG1XbvAmh0QHJtoBdEjxD0VR2GhK4o4y4HWcFaDb W+j/pcl8YrldxkV7TlY4Obwhw9Sg77HtTUSK7bD9oP8m+X42xMAxlGlJAXHqfQe17DWx Jxeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729187655; x=1729792455; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Y/n/isiF2Sq7ntpurAmJIm0kx07dBkasA8rH7Du+HlQ=; b=hXULU+add89QvpKcwQAbNVNXtCkftlolpFAzxGnK7RhFoIIvebqmAYZInUdnRTssyH rNJL5ctK+23zICRzhu1hYkXSk4IrrrlIp1FAouOIBexq0X9S2Jg1VkH67xA657WCXnwq 7a+Y24L+ZfWqC7tAqUQ3LvdQsKz77QVZgcDFLg+t4tno6lWBPdL42ARybKS91HPipVyP nuzFOu6+rtWFMkCAMNYKAXYo0Y7THlmoECgwzZrgaUHM+LLSgWmeAdwzJgkNfG9+3dSu h1KDAMUKD+AhhpxDn5lpjirwbcZBucPuOSL8vEUkp88IUagfkFyQLCCAq2S+iV9Qc+jL KpoA== X-Forwarded-Encrypted: i=1; AJvYcCVIUHma7X2C/YWWvIfI/zMio4I5YrFnVLmB4aUkIFRF/JdfnHnaMsJcOgZi4ZILXu7oDPY8XfUXCqs3z0w=@vger.kernel.org X-Gm-Message-State: AOJu0YxA8AytjKcMCxcO8EoFtSdFlwUVe8ncWVtjnIBAtwK6Hr1ofKpA hmqF9UKwMmvSiPP495Gq742jmXRryhy53oi6xAFbue1+JrnHIkOFUocp21pltvo3gUUHWCxaF7Z nHO7h8A== X-Google-Smtp-Source: AGHT+IFkq//YcMLCTfQVRn0x0a7UIOUag/SxD792fuWu3fhbg1GW7c20XG4ZYGJl76OK+axyzL3R3Opp2pnU X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:98a5:142e:8c2e:e9e5]) (user=irogers job=sendgmr) by 2002:a25:aa0c:0:b0:e1c:ffab:a801 with SMTP id 3f1490d57ef6-e2b9ce000a9mr7046276.2.1729187654825; Thu, 17 Oct 2024 10:54:14 -0700 (PDT) Date: Thu, 17 Oct 2024 10:53:55 -0700 In-Reply-To: <20241017175356.783793-1-irogers@google.com> Message-Id: <20241017175356.783793-7-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241017175356.783793-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v5 6/7] perf stat: Add metric-threshold to json output From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Yicong Yang , Tim Chen , Thomas Richter , Sumanth Korikkar , Weilin Wang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the threshold isn't unknown add a value to the json like: "metric-threshold" : "good" A more complete example: ``` $ perf stat -a -j -I 1000 {"interval" : 1.001089747, "counter-value" : "16045.281449", "unit" : "msec= ", "event" : "cpu-clock", "event-runtime" : 16045355135, "pcnt-running" : 1= 00.00, "metric-value" : "16.045281", "metric-unit" : "CPUs utilized"} {"interval" : 1.001089747, "counter-value" : "10003.000000", "unit" : "", "= event" : "context-switches", "event-runtime" : 16045314844, "pcnt-running" = : 100.00, "metric-value" : "623.423156", "metric-unit" : "/sec"} {"interval" : 1.001089747, "counter-value" : "328.000000", "unit" : "", "ev= ent" : "cpu-migrations", "event-runtime" : 16045321403, "pcnt-running" : 10= 0.00, "metric-value" : "20.442147", "metric-unit" : "/sec"} {"interval" : 1.001089747, "counter-value" : "20114.000000", "unit" : "", "= event" : "page-faults", "event-runtime" : 16045355927, "pcnt-running" : 100= .00, "metric-value" : "1.253577", "metric-unit" : "K/sec"} {"interval" : 1.001089747, "counter-value" : "4066679471.000000", "unit" : = "", "event" : "instructions", "event-runtime" : 16045369123, "pcnt-running"= : 100.00, "metric-value" : "1.628330", "metric-unit" : "insn per cycle"} {"interval" : 1.001089747, "counter-value" : "2497454658.000000", "unit" : = "", "event" : "cycles", "event-runtime" : 16045374810, "pcnt-running" : 100= .00, "metric-value" : "0.155650", "metric-unit" : "GHz"} {"interval" : 1.001089747, "counter-value" : "914974294.000000", "unit" : "= ", "event" : "branches", "event-runtime" : 16045379877, "pcnt-running" : 10= 0.00, "metric-value" : "57.024509", "metric-unit" : "M/sec"} {"interval" : 1.001089747, "counter-value" : "9237201.000000", "unit" : "",= "event" : "branch-misses", "event-runtime" : 16045375017, "pcnt-running" := 100.00, "metric-value" : "1.009559", "metric-unit" : "of all branches", "m= etric-threshold" : "good"} {"interval" : 1.001089747, "event-runtime" : 16045397172, "pcnt-running" : = 100.00, "metricgroup" : "TopdownL1"} {"interval" : 1.001089747, "metric-value" : "22.036686", "metric-unit" : "%= tma_backend_bound", "metric-threshold" : "bad"} {"interval" : 1.001089747, "metric-value" : "7.610161", "metric-unit" : "% = tma_bad_speculation", "metric-threshold" : "good"} {"interval" : 1.001089747, "metric-value" : "36.729687", "metric-unit" : "%= tma_frontend_bound", "metric-threshold" : "bad"} {"interval" : 1.001089747, "metric-value" : "33.623465", "metric-unit" : "%= tma_retiring"} ... ``` Signed-off-by: Ian Rogers --- .../tests/shell/lib/perf_json_output_lint.py | 5 ++++- tools/perf/util/stat-display.c | 22 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/tools/perf/tests/shell/lib/perf_json_output_lint.py b/tools/pe= rf/tests/shell/lib/perf_json_output_lint.py index abc1fd737782..8ddb85586131 100644 --- a/tools/perf/tests/shell/lib/perf_json_output_lint.py +++ b/tools/perf/tests/shell/lib/perf_json_output_lint.py @@ -57,6 +57,7 @@ def check_json_output(expected_items): 'interval': lambda x: isfloat(x), 'metric-unit': lambda x: True, 'metric-value': lambda x: isfloat(x), + 'metric-threshold': lambda x: x in ['unknown', 'good', 'less good', = 'nearly bad', 'bad'], 'metricgroup': lambda x: True, 'node': lambda x: True, 'pcnt-running': lambda x: isfloat(x), @@ -68,13 +69,15 @@ def check_json_output(expected_items): for item in json.loads(input): if expected_items !=3D -1: count =3D len(item) - if count !=3D expected_items and count >=3D 1 and count <=3D 6 and '= metric-value' in item: + if count !=3D expected_items and count >=3D 1 and count <=3D 7 and '= metric-value' in item: # Events that generate >1 metric may have isolated metric # values and possibly other prefixes like interval, core, # aggregate-number, or event-runtime/pcnt-running from multiplexin= g. pass elif count !=3D expected_items and count >=3D 1 and count <=3D 5 and= 'metricgroup' in item: pass + elif count =3D=3D expected_items + 1 and 'metric-threshold' in item: + pass elif count !=3D expected_items: raise RuntimeError(f'wrong number of fields. counted {count} expec= ted {expected_items}' f' in \'{item}\'') diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 5974aaead95f..53dcdf07f5a2 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -86,6 +86,19 @@ const char *metric_threshold_classify__color(enum metric= _threshold_classify thre return colors[thresh]; } =20 +static const char *metric_threshold_classify__str(enum metric_threshold_cl= assify thresh) +{ + const char * const strs[] =3D { + "unknown", + "bad", + "nearly bad", + "less good", + "good", + }; + static_assert(ARRAY_SIZE(strs) - 1 =3D=3D METRIC_THRESHOLD_GOOD, "missin= g enum value"); + return strs[thresh]; +} + static void print_running_std(struct perf_stat_config *config, u64 run, u6= 4 ena) { if (run !=3D ena) @@ -478,15 +491,20 @@ static void print_metric_csv(struct perf_stat_config = *config __maybe_unused, =20 static void print_metric_json(struct perf_stat_config *config __maybe_unus= ed, void *ctx, - enum metric_threshold_classify thresh __maybe_unused, + enum metric_threshold_classify thresh, const char *fmt __maybe_unused, const char *unit, double val) { struct outstate *os =3D ctx; FILE *out =3D os->fh; =20 - if (unit) + if (unit) { fprintf(out, "\"metric-value\" : \"%f\", \"metric-unit\" : \"%s\"", val,= unit); + if (thresh !=3D METRIC_THRESHOLD_UNKNOWN) { + fprintf(out, ", \"metric-threshold\" : \"%s\"", + metric_threshold_classify__str(thresh)); + } + } if (!config->metric_only) fprintf(out, "}"); } --=20 2.47.0.105.g07ac214952-goog From nobody Tue Nov 26 12:44:55 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D44A1E0DAC for ; Thu, 17 Oct 2024 17:54:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729187659; cv=none; b=NwivK51TBXf1YxixMrnTBz7SMnaj3wKluaNjT2iqRmOdZv3A3nYbzbS9H3s3PXYqlwTWi60mWTn7XO0QeM/euaQo+IDoqL2MhTWUYnE8BfjkkPngT5AD+iuBQISUwIBtP500CUKDani/DbBKqM6YBwDlisdiyWSbdf9AOVHjr9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729187659; c=relaxed/simple; bh=xxNoLSb6kFTUL1OnMX+2sTQ86EFI5XTgz4LWu0BFnc8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=b7dx0MJxD6tfOdNnz0DmCHZGdE1O4LD+eY6HvCnwtIxU+g7/onfl+dFrNUT2VkInHXgl/UZcFKx5rGbPgLlZSKYSDygGNSS98Soa/X+HVm1AfBfCD1/aptmI2hml209KcQpD+vUq6OIGjFJybfoFnf9cp4vUGg6IzNoMR+y/5DM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VUS5cl+y; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VUS5cl+y" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e376aa4586so28308747b3.1 for ; Thu, 17 Oct 2024 10:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729187657; x=1729792457; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=PO/jFnTS1VOsCUFZImr0igUuGTgy/DTrx5IiSFpgwUc=; b=VUS5cl+yUoP2TpeznihAmka3Wrb70iK4SYQwvlep4VLO2fkAJAkysaeNAVRh7ECgQ5 1fHjPYk1AWAGp14sSQaBx7fGI+n3U0Mo91OeUO8bBJCZTnVKAW1KFUIle4nH8mWHgP9t XacJt31xqJMI9sN4ALhf1MCUlPcqLHZ1QqaOb6OfQACkBzGL+aWlCXLUsYtiG844iXJa pAigQCou+j4q4mPO2soq82OD7hc79m8dWcYQNDYMI9z1Qsx2in9vahdxYY7Sds4qkM6r gcxeLgeXjpeZqKzWIeEqzerECPB0S0w1SAun1+6VBDjfydxSWLFtkO2XesgE49aqKXqF JwxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729187657; x=1729792457; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PO/jFnTS1VOsCUFZImr0igUuGTgy/DTrx5IiSFpgwUc=; b=jbQo58azmZfEBjhb3jgSHPMzvJBrZKmGcQhsW9WozAn0XgSvirPcegNs38GBTQDqkm ZsqTuBYAc9hxQ/9zLA9hSG/HLR5HTGuQpe9fjD0Kmk3NugT6JSTJWTpSl54LTzNhCVTI Y+9aWfyESs5Y/M9r2n+ab3AnWnlu/Qhet8svCflzCkE9NgNCwnVIM2iAzKHYIE86VXtO EwH3/Mul8cLzKc8V0TzMKUN+kr26GZpLsXf+ou0NNzkMEQlVYuvhABpng5PJrGbFgnpt 5hZbynirgMsnBNkP/CfvstZg6TgqZSn/cEXUkrdsntc7g0MMlawJQkTqm2vVvUDoA3yz zqYw== X-Forwarded-Encrypted: i=1; AJvYcCXLloaN9yRkbNhpeLb9DiR1cUvQNKVW2kc5URONPAN5Xl4PT9iO7A70kz8oRyVPiX4zDmZmt9PYK/rHZ5o=@vger.kernel.org X-Gm-Message-State: AOJu0Yz1WL+qLdT+3HiIOEE+77SisOu3CmPKLyOiC1Q+TvaZeTrxw2Dd nNqp4LrrzArOvQQvCucC5TXgMywJxlsLLYBkuIJwqrv+PYbaxWKbVH40sewhF9/wzC1kKWxFmoZ hz+f+tQ== X-Google-Smtp-Source: AGHT+IGQyAokEHLg7BxgQeLFlntRMpKEp9jucxTE9lGEQ6PxGbHfEPxS4ADwCWI7ULTb1Y0UDNtXj8bqnFar X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:98a5:142e:8c2e:e9e5]) (user=irogers job=sendgmr) by 2002:a05:6902:1c3:b0:e28:ee84:e4d8 with SMTP id 3f1490d57ef6-e29783006b4mr4728276.3.1729187656920; Thu, 17 Oct 2024 10:54:16 -0700 (PDT) Date: Thu, 17 Oct 2024 10:53:56 -0700 In-Reply-To: <20241017175356.783793-1-irogers@google.com> Message-Id: <20241017175356.783793-8-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241017175356.783793-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v5 7/7] perf stat: Disable metric thresholds for CSV and JSON metric-only mode From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Yicong Yang , Tim Chen , Thomas Richter , Sumanth Korikkar , Weilin Wang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" These modes don't use the threshold, so don't compute it saving time and potentially reducing events. Signed-off-by: Ian Rogers --- tools/perf/builtin-stat.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index b5e18853982c..7639ecda6c05 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2561,6 +2561,14 @@ int cmd_stat(int argc, const char **argv) goto out; } =20 + if (stat_config.csv_output || (stat_config.metric_only && stat_config.jso= n_output)) { + /* + * Current CSV and metric-only JSON output doesn't display the + * metric threshold so don't compute it. + */ + stat_config.metric_no_threshold =3D true; + } + if (stat_config.walltime_run_table && stat_config.run_count <=3D 1) { fprintf(stderr, "--table is only supported with -r\n"); parse_options_usage(stat_usage, stat_options, "r", 1); --=20 2.47.0.105.g07ac214952-goog