From patchwork Thu Jul 11 17:59:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730982 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 4E594C3DA4B for ; Thu, 11 Jul 2024 18:05:45 +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=mHHBS2O6oNY6SeiT+OH+p80VI/Bl4EiQ8pJoP1UpZWA=; b=Qz3WTY5NKAZF4SqIdMKYrdR9k7 w0hLUu6QmxdKwiu3oLGaz+t/VFqvaz71PaL56QX2bmATuh0teKyhER7Tad3gdb3Zbzv4TYlIbx8ac knpFzbYRpfgmvoSGTVWGH/L7lby+UDp9NZ90PelAnDQWgkTH9ZolhcnoeyeQbvmZjgp0W7eJjKLmH 43yEWAJ98LkTeJC6HSGKZNpq5bc9V6ao0RUo57isf220l0Is8apFwjIMpghIrn47LUtOHOzLLkyjv aZ9b397GprgaQAKWJRxWdudsgcPkndJu8ZnIWSnGjZFYzcspVSjK1IByGGQBnqZybJzvsAp/ouHwz Hx8amG/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyAg-0000000EyTU-3NL0; Thu, 11 Jul 2024 18:05:34 +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 1sRy69-0000000EwNc-45nx for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:55 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e0335450936so2118943276.1 for ; Thu, 11 Jul 2024 11:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720852; x=1721325652; 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=mHHBS2O6oNY6SeiT+OH+p80VI/Bl4EiQ8pJoP1UpZWA=; b=i2n8K0WPdHWGLrWciN/3mTL4pxdbtOqyygW5EkL/tjTERyYpSIJKJbjSbrTIs2KX/H ggD4TSF5H1RF/NmmXhaaknwngHNDwbVIf1fOtoq8Oj5asOdTopwZAXRMMahVibiIBX+J Gyz5DJ0GmzBS330DU2tNOT/PGLX+VRMHsLE3NiDJz4HommoJgaMnHwN7uRnGaLFcK1qs du2wD0ym1i3nUsfRmMxjmhd+5tg2sCUacarTZNZTHaBFt8c0+dw3YylXQ4S0l01eMt+C ORtuJY1MC/P7bF9Q4xOPPU8jWRGHvexJVi5KYK3+ly6Q/N0JDDZd6nDqdanbHZ2JgXyG rt6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720852; x=1721325652; 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=mHHBS2O6oNY6SeiT+OH+p80VI/Bl4EiQ8pJoP1UpZWA=; b=azy1jPB3itNxKOpBPF5gO5loBUphXcS4iZSlysUl3DGcdLLm7reqB05O4D67WCrHsG n0Q2ig8Zs3gx/euDjAxBIiknYrE8Z0feX+bpCCx9PI6WMqaWadRhSljF3j1RUveJhP1F 7sJ4UbjW98UL+w+dCLF92zroxiGu16Yqgkk2u/p4aDntVi8NrYPqigFJ1xYGouTF4qHq XZj3jqZlIeyS/qmWheYuTm+fKLMWMb5/KgVhXi2hitVby8ydndRxjhA1NsZ8X6r6zs+s HcT8EQ1Vhe3TnfHyVLOf13zdiBCBytP4ExHfsWM4ePX3PLnEYupkBj7tEs1VJGKGPLiW FjXg== X-Forwarded-Encrypted: i=1; AJvYcCXio3qpaD0RMM1y/o79o7CPyz8d3mlrS9Wr6HYCfrfdOtjzw/zyDcEcWI630Evv4XRJyI6s/qVHlcSNCcKFpw1MIAUj5w9zL3IB/Vsm9plW1UGl1M0= X-Gm-Message-State: AOJu0YyedYNuPV6Gn1exfgABss/1ooyy9GT0vG4omAmXLLA7mGyHSVdx sCgTr8AGNDraePX4kCawo37QU6G4s/kYJJhO15Gn3glooEtzmS/0p2aXF/BF2rUI3Glt6hG9nY2 luN6SSA== X-Google-Smtp-Source: AGHT+IGqpkWSNHuIk6znTjQKp37a4qhNUCcyhSSKbaeHKidGnzOJPe4kpolhyZ0aaZjRKcwzNmoatuj2V+U4 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1507:b0:e03:5b06:6db2 with SMTP id 3f1490d57ef6-e041b0347b7mr21103276.3.1720720852509; Thu, 11 Jul 2024 11:00:52 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:58 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-19-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 18/28] 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-20240711_110054_140606_AE9351FD X-CRM114-Status: GOOD ( 13.33 ) 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/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);