From nobody Thu Apr 2 17:13:13 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 99B402D0C8B for ; Wed, 11 Feb 2026 01:52:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770774774; cv=none; b=tVVbKee4NGlJHtcIykiYoQGwbsDmpeJs9zkocPq2rebwc6hozqzd2sqVZxPDo202ygwOL3jp9UD0LcI2fZbWspbKyy18kQTfwSF2Ri87sClzGnK2s2Axq/QQ9kSVK6tt+jFGtGaX2862RUPjWSCoF9cSPacoZRNs1/A3+kG4eNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770774774; c=relaxed/simple; bh=GtzZQe4Cyczg2thV7yGZJSLtC9TeQUSKesXkt8zVUEA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=jAzbSaNfvmrcpOjfaGA+iWncScaz7mRrtOmiGTFoKKraJ5ruhrxAWisBsu6vigSSVPeZv1AlbvWArHx93WnoLUZrZUhAn+K7XqieNNdfa/Qg+cyhUUKhNEWuEOH/mLcct0ZLrQDwkoaCnGXhE8eyb7FiINwGCUFtrIq84cXAIyA= 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=btr48qNI; arc=none smtp.client-ip=74.125.82.74 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="btr48qNI" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-124aa710af7so28038804c88.1 for ; Tue, 10 Feb 2026 17:52:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770774773; x=1771379573; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=3/qLzlsqfHs+dLny8bu5w2UvyZ2sO7c+56V79RBEKH0=; b=btr48qNIUCx57yBoIEB8H5cRgXMvr/pGAh4IzBphPReW2/wgAahkcw6mcelaCDN4Pk Wf/Td8dS6A6VJDXvxUdmNtGuBUfwR+pBHyP6FHy31HtYiiQIM6bm3z61olD49RY48w8e bFCDwnACKwfyMp4TpQ5BysAqKROjBidhUIR6QC2p0azUJ3UHsqlbTdLqpJImXngwsmBe aTHyQQ9VH2ANa05Bht2XiZTRgUU5MnU8fA2FUz8l7LsfpJx6MMSwDKCfkkB515oJf50L smQ2h5u/pgfaLboBSu1hebpqPF9of0F9G1LL4hj3QQ8TStOfiGFpwUllyw+McTWN5AXF oGNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770774773; x=1771379573; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3/qLzlsqfHs+dLny8bu5w2UvyZ2sO7c+56V79RBEKH0=; b=cUUlDEsvA/mAapq9VZVHfFYvzWDYG+ZiidxvzA3RDo2/c+i4inDGqJhyxow52wVuWQ 5tx31z7pRdOJjVF89TLjMOQmwDgs4XWje1AVVAsZ6ANM0aQa70sKJXjukzLg5FYkWs0c HpkmcRvlhp/i3DtGyjH9dlMY1BJlGkTcwj+c6Fv2EjVzB9Sh4veXvZ1e7gpyI61vUfbf ptosI5g9lErC80kYOyggx5HNzcBdwXQhZTfG8qWZS+m10i16O3+olsmoyg6vrahqHlGR NBb/LmyplMh3KzKlzWIZyXoIKizmfL02TGgDcDs7nCZ5CMfB86GqJwFwNkhTkqSLDM5P 8l5g== X-Forwarded-Encrypted: i=1; AJvYcCWp/TWNU9LA4TTGU8ihPMmCwfF1QeRFVxYbqpvLubvinFK/QRvy76rtKl9F7k1yNZTNMfRlbh/wrqiHL/g=@vger.kernel.org X-Gm-Message-State: AOJu0YwYPBtj/KHGPHxI2/p9jn9ppU5pPzBkfcnzXUN4gc4ffZY3aHIm Q4FAC3kiGR59YgxiyEfejxrPeGNxpO8ATUW8pIP7RmEesDecRClfEnPW/zZeOdQaJywC1cG0Fq5 g37m+CFZUlw== X-Received: from dlbdd17.prod.google.com ([2002:a05:7022:a91:b0:127:cec:12cd]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:102:b0:123:34e8:ae96 with SMTP id a92af1059eb24-1272437e6fdmr2166858c88.37.1770774772750; Tue, 10 Feb 2026 17:52:52 -0800 (PST) Date: Tue, 10 Feb 2026 17:52:39 -0800 In-Reply-To: <20260211015242.2700218-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260211015242.2700218-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.239.g8d8fc8a987-goog Message-ID: <20260211015242.2700218-3-irogers@google.com> Subject: [PATCH v1 2/5] perf json: Pipe mode --to-json support From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Derek Foreman , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In pipe mode the environment may not be fully initialized so be robust to fields being NULL. Add default handling of feature and attr events. Signed-off-by: Ian Rogers --- tools/perf/util/data-convert-json.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-con= vert-json.c index eefa3a94c813..6a626322476a 100644 --- a/tools/perf/util/data-convert-json.c +++ b/tools/perf/util/data-convert-json.c @@ -48,6 +48,9 @@ struct convert_json { static void output_json_string(FILE *out, const char *s) { fputc('"', out); + if (!s) + goto out; + while (*s) { switch (*s) { =20 @@ -71,6 +74,7 @@ static void output_json_string(FILE *out, const char *s) =20 ++s; } +out: fputc('"', out); } =20 @@ -322,6 +326,16 @@ static void output_headers(struct perf_session *sessio= n, struct convert_json *c) output_json_format(out, false, 2, "]"); } =20 +static int process_feature_event(const struct perf_tool *tool __maybe_unus= ed, + struct perf_session *session, + union perf_event *event) +{ + if (event->feat.feat_id < HEADER_LAST_FEATURE) + return perf_event__process_feature(session, event); + + return 0; +} + int bt_convert__perf2json(const char *input_name, const char *output_name, struct perf_data_convert_opts *opts __maybe_unused) { @@ -360,6 +374,8 @@ int bt_convert__perf2json(const char *input_name, const= char *output_name, c.tool.auxtrace_info =3D perf_event__process_auxtrace_info; c.tool.auxtrace =3D perf_event__process_auxtrace; c.tool.event_update =3D perf_event__process_event_update; + c.tool.attr =3D perf_event__process_attr; + c.tool.feature =3D process_feature_event; c.tool.ordering_requires_timestamps =3D true; =20 if (opts->all) { --=20 2.53.0.239.g8d8fc8a987-goog