From patchwork Thu Jul 18 01:00:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735908 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 1C37BC3DA60 for ; Thu, 18 Jul 2024 01:06:32 +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=D4D79+IUkfPytCkqQCFYniN8I4X54SHHR0HOTbDEr6c=; b=iw/t2ooMct8W6ppwBJdLSBQ47T tYWzSmGfpBDG8TMgDaojw46lmbXWnXIpbJZt7EYNLAUEoCEB50Go2F7uNI9NdfhDjjuvwbQlqf6mY IwlL8R9hkbJnyJz2TzVGuuPE3f0VPMMD9KL3CZW7dekRklQCU3ipQIKz6BTOtKb06Umbu/IVvwok9 bR8Vgk5dEr1IMV6B/ccL3OLojj+YDYVQQvJBHNI1ys/8lAvmTUhSpcxd22hIQ9HrHaL9IcfPFI3d7 d+rNWZgOmOOfL3t5bYzuCJjCdD5NYxTBwtgLaMgGYBJF1iejqzNpPPs1oSfXfws8X9Ykf3xIlzy27 VVx/lYxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFb8-0000000FLjf-0P5J; Thu, 18 Jul 2024 01:06:18 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWH-0000000FJk4-28lA for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:18 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e036150efc6so659954276.2 for ; Wed, 17 Jul 2024 18:01:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264476; x=1721869276; 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=D4D79+IUkfPytCkqQCFYniN8I4X54SHHR0HOTbDEr6c=; b=kY8JTfsHedRHCzvRNRaMt+DI99Jpmk6Je17gw9G2vuUvEoWaPUmvTb8A4b7A4JPthE jGIXdtT3VvLX8Dtb3xkUBeloBA6XwFVZL6tNuxcHLfqc1bp2Sz3cd4VeXH7sT9ZwL7zl BxiTAf3xbb0ovqyPAYZJxpzwPWaFT8L2KUXAv16VK8pwoH/RqUUFKZTHGMwopOf9j7ca xERkOh9y44Tfp/iS6L6l4EWdpMVOSO08af7WGPeHogYjmlKAIi+wrog7IyyqAWa7MMVQ zjsO+9oElmiwmPp6+GpIKzyN5fygnpCWNHO2EGIKIIrj1exZ8Oas6bmwrAIMhszStWmA RbTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264476; x=1721869276; 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=D4D79+IUkfPytCkqQCFYniN8I4X54SHHR0HOTbDEr6c=; b=Hea8+lsqyP1eLUogUIxJ8j8QWeiv0yW1jIE5lb0Uw5Wfzk5K4bYA97pZWak5yiVLI/ KKHh8YnSsCAOaZYE0PSwnTjZUgZQzxQRkOOvrJTy0vo0H4brVdAGw1HCermgXadPc0TZ zFV19BjlFizYL2OTucxx56wqdIJ7cDEbAEJyuwIM/mgzS3T6icpBMhd/Ezb4/RTvz+47 xIuTISEMAbnYIzyGCEZ7RlWLya5A72ZpNTZDSRLZzLdDZBXpScApcaxWfmCXvVixfcwL PAXmGEVN6jIADTUPzPIIqCS3LjYEnReJUfv6wap0u8MaAjWVN1YFZdTkfOlM1aHgnMY8 PWkA== X-Forwarded-Encrypted: i=1; AJvYcCVFeCCTyB5JqNZz9TmbHSGIrT5COaISe3GpN2+tMtcX4iejA06E7zLDC3MtOSHHaC8DKtMg+flMQLHUlvdw9McAbkl5nB405n/RRgTA7aTMCTQ9pHM= X-Gm-Message-State: AOJu0Yz6H3Do+SDLylUbLwkw6/AsIz9ymPBeCeUwshwMScvztp1Ezlzu 9E4fgi9iTH3eoSEW5RdK9aL13VoFktB6E0oIHcgFx3m75mM6ajnGxuasphvp7kO4ioL40y8FhBl auAEAdQ== X-Google-Smtp-Source: AGHT+IFdcXueyp+PMAvktitAsznwCgBObp3v+ssLmbsVDVTn4IUrAVOTsIsjGyiwtSBsWfywOqLvQluTAWWt X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:2b8e:b0:e03:62f0:a297 with SMTP id 3f1490d57ef6-e05fea28f01mr2107276.2.1721264476138; Wed, 17 Jul 2024 18:01:16 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:13 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-18-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 17/27] perf annotate: 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_180117_574527_FFA8DF0F X-CRM114-Status: GOOD ( 12.84 ) 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/builtin-annotate.c | 42 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index c0685d2c8de1..598ab854b9f3 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -686,28 +686,7 @@ static const char * const annotate_usage[] = { int cmd_annotate(int argc, const char **argv) { - struct perf_annotate annotate = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .namespaces = perf_event__process_namespaces, - .attr = perf_event__process_attr, - .build_id = perf_event__process_build_id, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .feature = process_feature_event, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, - }; + struct perf_annotate annotate = {}; struct perf_data data = { .mode = PERF_DATA_MODE_READ, }; @@ -864,6 +843,25 @@ int cmd_annotate(int argc, const char **argv) data.path = input_name; + perf_tool__init(&annotate.tool, /*ordered_events=*/true); + annotate.tool.sample = process_sample_event; + annotate.tool.mmap = perf_event__process_mmap; + annotate.tool.mmap2 = perf_event__process_mmap2; + annotate.tool.comm = perf_event__process_comm; + annotate.tool.exit = perf_event__process_exit; + annotate.tool.fork = perf_event__process_fork; + annotate.tool.namespaces = perf_event__process_namespaces; + annotate.tool.attr = perf_event__process_attr; + annotate.tool.build_id = perf_event__process_build_id; +#ifdef HAVE_LIBTRACEEVENT + annotate.tool.tracing_data = perf_event__process_tracing_data; +#endif + annotate.tool.id_index = perf_event__process_id_index; + annotate.tool.auxtrace_info = perf_event__process_auxtrace_info; + annotate.tool.auxtrace = perf_event__process_auxtrace; + annotate.tool.feature = process_feature_event; + annotate.tool.ordering_requires_timestamps = true; + annotate.session = perf_session__new(&data, &annotate.tool); if (IS_ERR(annotate.session)) return PTR_ERR(annotate.session);