From patchwork Thu Jul 18 01:00:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735913 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 2F496C3DA60 for ; Thu, 18 Jul 2024 01:08:03 +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=UZ3Drtsbb7xK9GFR3k7+K4AhjLYb+mQoMq9GLVm8nd8=; b=I5Ao12HkctjFd/ZpLZnuWBBJxc nIarJpQZyntGJLtlACLng5eH/dgB2pUm8yEZ4lc7cZB98Q+xEBxvsxFXD5jN+hG4RzOTGvRbv1rm8 BIJjHw5xVIb442aYeayX8q+y50DAFtXlsusJJIzEfIrNCi+r78DTlHUqnko2VmzEm7MFuBQptS9fd BoZXPMqtAOE4v8WOwgOWqUsd7Lao4/7lCRIYGpNKSQm/iZrj1Wliq4LFFLKs8wwVL8sU0dsvQ1jzt lO87gePVDTUYDV+OSfpn4eJGUvuKA74IQjZO9C0k/yyK1GN7dyZNIqFEmjk66Lpmx8wa1/7wl/RLC FPyQ6BAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFce-0000000FMLZ-3c6K; Thu, 18 Jul 2024 01:07:52 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWS-0000000FJpD-4ANz for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:30 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-664916e5b40so4737067b3.1 for ; Wed, 17 Jul 2024 18:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264488; x=1721869288; 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=UZ3Drtsbb7xK9GFR3k7+K4AhjLYb+mQoMq9GLVm8nd8=; b=045BtxJ+OwnaTVSoyro7yoISfHRhrPQLxr0c+4pIaxt38NGydM+xX6iRykMXJ9Rs8n l3ClkriujGjC6uq11Mm0x7gKDv+S+58iZ/afnfnOpUNAP4lqw0CSPTuSKTQ8W2DKjkno RVzRZY68ZWiIQl84gS3bFndjcqXuktH3lGxuQ60MVBv3VYIj+pgEXoh04rIHs96inR84 3mk81aTe1IqpJTjve+5QYKWSjrGjyHq2S+tPbBQ+Tw9EXRRQuWlPMr4TtCmCTJTeYCDy 4xKRZZJdSf/6gTWfFf+4fkUejN65LKEX0zz8lkEbyWimdR+95dwzu5N1/vqxzo3+/jpX nP3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264488; x=1721869288; 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=UZ3Drtsbb7xK9GFR3k7+K4AhjLYb+mQoMq9GLVm8nd8=; b=qgKalHh/XnETfKor0qDt1mgxVYgHDQuMgTDdIaR8+4Kk4FyaXt/2CR6Oi6owNiCKrJ PVBlxmq3boPl5HEhReWLv9vncPwWJkMCCI7UNpBQGibwpf2w3PWCfILnA+ZBSCeE0gBT gZhp62EhI/ROQ8/fY5/E3V+priivbN0zBbaTeam7JeM0z5Ym+rMstZSRAEuy6a6Uu1ys 6GNx1Y6TWc496/mZv/8fpS27Ui47dAu0Rdw9I7sRs/Xcmr1QFeI73+InF/HrQzq1C22B kqWRHJN1Rnj5NR9DRg+Ra/LV0mV+xDx3lyGo2ao0duFDqL/opVdVaW6uvc+c5nAvz7E3 kaEQ== X-Forwarded-Encrypted: i=1; AJvYcCXhIYs9FNnxh6WWZbjkP0uZYO2+ofIJfCJ0czWqSMpXmTP4eUOaZ2ivMs80J1ST6XT0vR1aO1YdsRYDioU8U4+7Av4T+cr9/wJc3q0QJ3vthztQmig= X-Gm-Message-State: AOJu0YwdPH7uTHB8ohv+oh7qStpoYI0eIc9F4ytgzp9GnWzBbOpgmO1H ZjoCV2gFqIMAa+nzvl4DwvLv4Q5Dg5VcY5CIL6j7Xw3i8+EeI0aKPLgo+BaDNkbdJSJvuDrFgvM sD67RtA== X-Google-Smtp-Source: AGHT+IEMIegm6jNE4CQClsw7GOzZrobtpwCpbE8HwTGUbjxQR6jEtSbn4ARwhdR3fei25wrA9LB/QeoUjXvX X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:385:b0:620:32ea:e1d4 with SMTP id 00721157ae682-6660af16a6fmr758457b3.0.1721264487742; Wed, 17 Jul 2024 18:01:27 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:18 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-23-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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-20240717_180129_056061_6B200826 X-CRM114-Status: GOOD ( 11.67 ) 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 Reviewed-by: Adrian Hunter --- 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;