From patchwork Mon Aug 12 20:47:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761034 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 BE9D4C52D7C for ; Mon, 12 Aug 2024 20:57:52 +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=h4IuJMX0YASP6mDRB5sblKvDCNi7GxHX4wO+9+ISAHw=; b=EPkOetvrGWigrfZeb8zYJ3s4Wo OevTiv0iTgA67U7urfXJyGyi0o3ozb49CL8yYA5j+fjjQ07+qiBv8+V/sB08QiKiS1BVkeqm7rdzu CAwdDYnqSZJidxXVxGB9nRxe+7AhIn/BFbTb6fL+5iwfuRX0bspmVfhabAnyMrTQuWmgpgle+s0n6 96XmBJS31yKYPGaB8l961YhS0TtDnW21zzks5jBA0eFXTc6EL4isHFgX0whJdulFL5qjdkr34NQPd rWC+Qi9zVtWSpqe5ixaAoYfOuvVSoOe2pIwMgZj6B6lx6dmnrD6EFjEL9WVu/edU8sBAvRLiCIj33 KKriDHJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc6n-00000001XjU-49VY; Mon, 12 Aug 2024 20:57:41 +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 1sdbxV-00000001UgJ-30eH for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:07 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-66a2aee82a0so94407877b3.0 for ; Mon, 12 Aug 2024 13:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495684; x=1724100484; 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=h4IuJMX0YASP6mDRB5sblKvDCNi7GxHX4wO+9+ISAHw=; b=oA7yrdGHnf1/zttX5+qIDKw/ZMVBKKLldz6lzWdpKHcIs+byuzgGH6avFlPIzgMebs l4nPmvwdC37sZirLEujWpCbcpDGw2F0LdlGcA3lhlwjKuPZYO0e27bJNbK7/EB3DJVzX Rd7AlmoQd6IN1yqGj6CBQdDsbBVLhfxqyD1Rzy4osFLS+cVvOOnqG+OqyI00+M4Pa+FW sKoVGyCNbQ5nkujR2gVC15Wtzr96Zplnxoa8nIa5Ovn8s/SrXgwZt9LeNfFLtGbE7rmH DYe/hQloN4qDaN1OepPpmaaawNy+ScK5vB5o6naevNypUuLlo9psMDMdXOtsqT2lsMJ2 S7AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495684; x=1724100484; 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=h4IuJMX0YASP6mDRB5sblKvDCNi7GxHX4wO+9+ISAHw=; b=HbeQboIciSmeODcHA9z+exGwmzn6fSkC72JmkLMS2hiQgG2hA+W3g9iywAkd0fnK4T V61dn0Db0n8S/6QAGEXa2CJ2W+xktUpHH5TVXE+FuQ71529jX4K8rVxcvh7ePSp0lfew cukj6eYsRdTf9zXzLD3QPeuHFNFXH4vRLqe9MmGGkhU0kOe6Y0Pqf10hYX+5ypC/rLV5 6ehDTeOCCZqQiHVQI+7LOLQ8FZNaP6H+QBRJQ4C/v/2dIAamLHV0EGzd+TaXKWUR/FqH qedDT+g0PUGUCgQwrsqNxJ8SG/f7CIiVtVqBfm+8sHYXsumpFZxfzNat3Ztdn4bKHsvs k0Rg== X-Forwarded-Encrypted: i=1; AJvYcCXXNFMysTi1tp80t2pPdkLHMHEt61qAIsXebsXcCfJ1iLYvDjIcjiGO1nVqN99iWY4555i5ERtadJ4mYxYRW7TnqOt6p7X4m8mBOhf0PqAmkOfKgx8= X-Gm-Message-State: AOJu0YwEJXSiHEd5oUt22GNf27ysP+uTEPCL0hNC4AijqDfFJv+AqTXS 4LSV2LQmn3AyCepooJ1WjMCxtm4LHxRTZTqcljY3Nilu+qTZ5ba+5bD4X2vdcuiXhkpDbwGGlwR AMzrOyg== X-Google-Smtp-Source: AGHT+IENcikM/2xpbAI0+iXGHI86bo1OAG2rCZ1wxfc4b5c0Ca8mqN3x5IE3uLmAUHqZLRaOz95pxfCbyXVD X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:cec7:0:b0:e11:44fb:af26 with SMTP id 3f1490d57ef6-e1144fbbcb1mr64276.2.1723495683936; Mon, 12 Aug 2024 13:48:03 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:09 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-18-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 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-20240812_134805_807302_C585329D X-CRM114-Status: GOOD ( 13.92 ) 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 cc65e6f8f4da..d6f6ba5a569d 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -696,28 +696,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, }; @@ -876,6 +855,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);