From patchwork Thu Jul 11 18:00:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730987 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 B7F6FC3DA45 for ; Thu, 11 Jul 2024 18:07:09 +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=QqtdDMsD55pEoQfMNz6zeYZQAoeVSzSneBvTBBwc7VY=; b=GT85KjIKjpZ7cm4/eoXGHvgATU wrUW/bjRRycuOLXene5/mruZgUtZ4WG0rlN0U39gCT7iZ56cs/20y1NbaoJUAWuaXRsVEH3HM3gGk /UoHpMYYqzTxibFssTc8vQ0JtQ2HDX971rO9jWNv3bvv76lkS84fnQnmZUHNmlXgJErWGOm0j58TK w70ri5uZsxXn0QrkEhL8s9TYNWTFkh47IvxFx7yhypoD6kZV3UxDaBOWs9T4ymsZaJRY4PA7ZwZys l4pBYv07CVJzuUanNWC3i+EnfyDkRZXikc6bY0xI47q2vgKFKg7f3wVjJ3SGG/7XFyWKSUPUjO2Pl FqeDIdKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyC1-0000000EzB1-2Lpr; Thu, 11 Jul 2024 18:06:57 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy6M-0000000EwVW-0GBY for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:01:08 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-64a5503e253so19855137b3.0 for ; Thu, 11 Jul 2024 11:01:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720864; x=1721325664; 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=QqtdDMsD55pEoQfMNz6zeYZQAoeVSzSneBvTBBwc7VY=; b=h3kabjbCzCaLPfXXTrlsNLdut2C6bbv8bneysr7IfKL9cnUrmnflBGAmX3UNGwvTHh wIpJ7FGtqJe7yIbgGta+Hbc+vc76NGZ7dxvs9R7tdq4rzleWugZppFgJ4HryO+NQT/SJ C55z+tb61M1mCkFGCFBgaQWyuq6VnHwOpjt22KmYnhJz0pHite0KKZTy5Dxw4s7xBj6x 7st/fGy6URbwJ5KW1VmEawi0eN1g1kpI0sJKy3nCIR+f8RTA3tSrmQJfYRauX1Xqf+GN O9RrG0akNQ9z+KEUqXaxEYKnr43yI8dVOWBWAXNbn7MYgH8ZjAs/1Ve5brGDDFbVZscv ggkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720864; x=1721325664; 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=QqtdDMsD55pEoQfMNz6zeYZQAoeVSzSneBvTBBwc7VY=; b=nG4u9Nc4vt6VbDpqLbiqfygcOmi4aawzS98s8AlYAjgjrF6aKWaH3QyuvTpc6q7+5/ a5uMWMDEOlGZ+JYGJoBl4ovIjlbRUjgffD+9pbmkqNi6BSrC87HA1UfiNKmVegonVWE4 WCtGPAH5JV6Pe1SkITVtpNfAJNBT/QhkhLAVjN+eoh55naRoJFKrMJqy+bGlLifWB6zq iwFCPYBd7Zw5k9MoJi99ruDHsR61TnN/ojBUoCcdRE4S8HGPRwlYTngOoxxrIQV3FZuM 1KwU/CNZFRnDu37XDai/7vzVlpRrptoz9sRyziMnOsl9AbOPFAMWMyHFcAResk5hGUA5 VgPg== X-Forwarded-Encrypted: i=1; AJvYcCWM3Hb17n7pCOoG6xuaGPsl5sf5aODkFN9VvG/Qhc2QyxL9slag91HKmHlX8ZT41CTa17Nl9KKXqSnqVMGVDtBrMz+mkz9L9PyTI53Ba+hfwXdpUf0= X-Gm-Message-State: AOJu0YzpWdOvoFZPCyVYqZK/M4hR55g+4Tfq78Tnt+LnnorqAn+SNY58 nnbBa3rsDwDpnKaaGsa8PkeqeR226XGF0lggsFzqx8zVct4C8curCMUPwChK8bdtJ+y+eCrwhSb 0Mfb/+Q== X-Google-Smtp-Source: AGHT+IFm7iteUqTnpFU/9RIErlfRTtg3oqwxjOCKfDaCl4dOg8omYu/CwVrqY1dpL402Zc1R9QmK5RmuQget X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:6b0c:b0:648:afcb:a7d0 with SMTP id 00721157ae682-658f06d9ecdmr530397b3.8.1720720863879; Thu, 11 Jul 2024 11:01:03 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:03 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-24-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 23/28] 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-20240711_110106_159963_9D05FCA1 X-CRM114-Status: GOOD ( 12.14 ) 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;