From nobody Wed Nov 27 15:43:15 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 587C4139D07 for ; Thu, 10 Oct 2024 01:21:46 +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=1728523307; cv=none; b=ASCq9q1eDG6BAQ7KsVe9LYw/C+nqZ/AJ2VRNKmzoF1hSW71+Gi3xdDOj5G0vPXgqnWY2ffoqUhFpxIdo1IgbFVyojMwerOWClObwDE/SpzSOYjQ7gqblWyRX2VDFdP4bbM5UxQ2aBGb0lacIwIsxwD9qUENIiK5UYrC8f1IOPAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728523307; c=relaxed/simple; bh=K+iLRNmPq7pFFzgCwk+WDV1uDJdmXtPtLhF5jSJiB/Q=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=rtogEZ5MhyFjVjfO1+4HpBeh0yty0fgazyWbJwLvxmVXLbqOnLo9M+yNKR3JoUQ58Nkvfuza5M22halFyggHGrnId4x0RcaGJ6w7+U8UVvBUMrKTCfozf54KUo+4FPr9DBF5TcPQcpdg+UUVLk/XXssqmQtG7ByKsucWeG6TqSc= 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=x5xIBqVF; 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="x5xIBqVF" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e28d223794so9563997b3.0 for ; Wed, 09 Oct 2024 18:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728523305; x=1729128105; 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=FJ1kKijNUBB3h6Uf74qin1j8xVsGkQayF3LcGNTjFTk=; b=x5xIBqVFeBxtBJdwdHQEq+nnoA5B3ufa8P1FP9ZvPFNTVXl+b6KcLx4l4DBH4imNYk pUcmXtztjwyByctOxmWsEPHnh2u2ArBUC6lJAeGBvHw2VIE90WxFsumojuKwHQPv81hU ALrvS8gaH3zpHvo6oqwkWs6hFTfkwn2TfQhlg7+0HmN6lvNWngadZtxr6soXUXS0qJUc KOGJneq7rQC9neCi1Qvx7ohl30emiIgNfX9Y61mCoqNMJXhYSNSQg8KnFD2MAxkeWf1C oQ5r7DEvYWk2mAFPfNHXuIrjXMgaseVyJddUUoPU2h2i0aSS2WV+4yZ+mLFFuqEHy4p+ vcPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728523305; x=1729128105; 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=FJ1kKijNUBB3h6Uf74qin1j8xVsGkQayF3LcGNTjFTk=; b=eOcwCtGD/wAfdnU7dVGoi79agkBepikOmiN5m5hVyRpoD/8e96yryHAjsxmDvHggYV pjel9cXWogI99rtGJPY1uu0nYGSDVM+aW0FAFdHu0+U0hSEaspwGm80C6hpjFaQzpmin oUi4djsjuuI4QBegV4oWbyyKt4Q2k+bdAdWxZFCeiMyoHpxMRo8ogDAzZudGP3/A1JFZ KyR9FnkoMAA0ufLYQ1HhJ0uFUCAGHZJGvq72gSUZc5x8tdlayK3ZWJXZUl/RnW7Ma4pI E79FaOJJ80cvC2idQJvxTy69XkeiiecrVR3bvnR/9o/XMCxE2otnE7VEnpPo7DyhgjFG Z2Xg== X-Forwarded-Encrypted: i=1; AJvYcCWAjOOLLvoIMNl5yv7FQz4Kd0xhcI/sEWXEBwtQIJJmJDbzHLEy72awb+wc0PS1EjNBMnqfrQ+6eJjiauw=@vger.kernel.org X-Gm-Message-State: AOJu0YxT90DcPQK6hSd1qvSjASvAba0HS2qbhbCuN45wXNDYeNBkl0UI pMg7ppp8ifBbYqyImaCax89PunnZm5aXNHdGdcR99YxVQ6mFRjCTeUUsmieUuyoMcSxH3HtyxPT ulppLXg== X-Google-Smtp-Source: AGHT+IEJypg576UbQ5VaDO0MPAIHZNmppJpIj8JxQULvGLPW7W7ttj6J21OnaqDWDcmGmHFVb5umycK+sA+N X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:6c8b:1170:a0ca:9d72]) (user=irogers job=sendgmr) by 2002:a05:6902:4ac:b0:e28:fe07:e7d8 with SMTP id 3f1490d57ef6-e28fe439b20mr61632276.10.1728523304658; Wed, 09 Oct 2024 18:21:44 -0700 (PDT) Date: Wed, 9 Oct 2024 18:21:29 -0700 In-Reply-To: <20241010012135.1272535-1-irogers@google.com> Message-Id: <20241010012135.1272535-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: <20241010012135.1272535-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Subject: [PATCH v2 3/8] 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 , Weilin Wang , Tim Chen , Thomas Richter , Sumanth Korikkar , 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 5402998881c4..e392ee5efb45 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -609,19 +609,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.rc1.288.g06298d1525-goog