From patchwork Mon Aug 12 20:47:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761039 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B333C52D7C for ; Mon, 12 Aug 2024 21:00:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GbSuls1koziHCu+Zgk0ioXEnPdjQxeNgIBorrGo8zG0=; b=SLQ4nmRiv3rTIMQuSIjA7eMnLp EzmJ+WBatVDQy5MBhEqqg/IH+ose5bf/jd4ScmDkuxyYQjfAW5Q+MfwIHFscwZcc67q/oTow33slT +QICfaWfaPRN9hQbjEsKuG1yX9/NrJdSMRXNNG9YpIczczkuE8c6sfEH+Hj9ik3Goq83DgSvkJAKy y0dVkEmgQ25LGmpwA+omprFTNwcvYxXpol8PR6Z2Jw6UkO91/S4G9uDaxIFbO60isLXY1lvgiumX3 Pyo4VThTXEaKfTqFMY5yg4Hma7JVKK16XK1WkzJoGB32DSJUIdsbpINN9faNI7rtmTeSARH1dN6ir PU0VqEWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc9d-00000001YXZ-2UiR; Mon, 12 Aug 2024 21:00:37 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdbxg-00000001Umy-3Gn3 for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:18 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e0be1808a36so7073387276.1 for ; Mon, 12 Aug 2024 13:48:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495695; x=1724100495; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=GbSuls1koziHCu+Zgk0ioXEnPdjQxeNgIBorrGo8zG0=; b=IDuk5/ABo+j8sYRyoaAy1IcUEsdl2X+zaor0kLVwhbm4HRZPbgolyLxr3jEyaOPEdE nFDHaiCzQo7Zs+hfpAyuD4SFtV3Rx8bBpRDMZn6VWUJoZUD2tXlvHRITFG3I5EiTIP2K 98zdGFCTfIqpd4saK372kCUMG5gWJyRdGpCOmI175Zl4DCcbWWsCvGxkaW4ZHf6sySIl 53/M0Yzvcn/tbYsFa+tscVFLLEXIYAsLL7XowbuXHQxYNWUzJbctIHle/wVAh7xwPXAk ikasz5+Dq23jaSTwib3KS+/rSHE7OXIO36zRzXenmba0WLgqjpPSV02Gfy9zZRQkCl1u k+qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495695; x=1724100495; 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=GbSuls1koziHCu+Zgk0ioXEnPdjQxeNgIBorrGo8zG0=; b=uZbJWRJ2m1ktn8agmVRCe/v3QpTat47SLYzxP99JSjTkN7hoHBn56MkS6YUxOk/hNQ XV7/Xs1T9urZRsPW9YF7e2IY1U6b3RyO3/7B9NtHq9+irQnsNjTuUGi5QgTZ+txpFJOZ b28ntH6S5i0WOZqXqvFlr6vSPQnvSzABoT5yuWVXbjinfiMx1m5n+hJoGpgG1T96pLcq I3sogIPHObc8/TzH19aIHv7emBBx1698vLa+Nvu96WxcmyrrG7vGKrrVjx7pz3TDsYda qiHZ0xDKS0eoDGak1KPVpYK4v5pwJ/7vGMfWjf3ZbIf1PR27YyFDmBGoIyN3CKwRGHUz 9Rhw== X-Forwarded-Encrypted: i=1; AJvYcCXctXzwkf6nNM4abZb/QS6oakSZLF9wU+6QHxMMBCYXQ4zy+hxMEZL37CGAzR1TWwsdv6gatiOZgOfrj6f9k3lB@lists.infradead.org X-Gm-Message-State: AOJu0YwiQEpxxgG2QCX/z+9tD2+ox/qKI3zAZI/SaLNtux+/c1Jd/txX 62F0Go5cIj145QRcN/E+dPAhgDsB2Z9RBPjWpG07F7ZIeOes/Z2YgqjHxmLnXf1S24+iMR8EMDR 3ILOorQ== X-Google-Smtp-Source: AGHT+IGKJ+9oWMNqxHbfR8xASqbD92WuYLWcfVYrMvX7Qri5bDa2vpoBKzYqnCKUn0C5AVvaDA3aVfY+pTnG X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:eb09:0:b0:e0e:3f14:c29d with SMTP id 3f1490d57ef6-e113ce83143mr78677276.4.1723495695218; Mon, 12 Aug 2024 13:48:15 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:14 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-23-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 22/27] perf data convert json: Use perf_tool__init 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 , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134816_848607_DA1267E5 X-CRM114-Status: GOOD ( 13.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/util/data-convert-json.c | 43 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-convert-json.c index 905ea9823f9d..20bfb0884e9e 100644 --- a/tools/perf/util/data-convert-json.c +++ b/tools/perf/util/data-convert-json.c @@ -316,39 +316,36 @@ int bt_convert__perf2json(const char *input_name, const char *output_name, struct perf_session *session; int fd; int ret = -1; - struct convert_json c = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .cgroup = perf_event__process_cgroup, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .build_id = perf_event__process_build_id, - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .event_update = perf_event__process_event_update, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, .first = true, .events_count = 0, }; - struct perf_data data = { .mode = PERF_DATA_MODE_READ, .path = input_name, .force = opts->force, }; + perf_tool__init(&c.tool, /*ordered_events=*/true); + c.tool.sample = process_sample_event; + c.tool.mmap = perf_event__process_mmap; + c.tool.mmap2 = perf_event__process_mmap2; + c.tool.comm = perf_event__process_comm; + c.tool.namespaces = perf_event__process_namespaces; + c.tool.cgroup = perf_event__process_cgroup; + c.tool.exit = perf_event__process_exit; + c.tool.fork = perf_event__process_fork; + c.tool.lost = perf_event__process_lost; +#ifdef HAVE_LIBTRACEEVENT + c.tool.tracing_data = perf_event__process_tracing_data; +#endif + c.tool.build_id = perf_event__process_build_id; + c.tool.id_index = perf_event__process_id_index; + c.tool.auxtrace_info = perf_event__process_auxtrace_info; + c.tool.auxtrace = perf_event__process_auxtrace; + c.tool.event_update = perf_event__process_event_update; + c.tool.ordering_requires_timestamps = true; + if (opts->all) { pr_err("--all is currently unsupported for JSON output.\n"); goto err;