From patchwork Fri Jul 12 18:10:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732147 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 261BBC3DA45 for ; Fri, 12 Jul 2024 18:16:08 +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=BgJSCF9yLnG02WKUg8SfX7odmyVBKa2lGRMN+iopItY=; b=lqPqAyzA0qOkXz4teHeNl0xLrR X0E+E2axaVzK37+aj+JNcPtXQde09KXC46EmpRfJrPtsZSoc4U5VgUZ4hnwSRR6kzxhwRv7xELB5F 4ZwMCigAlrQgXXdwbfJgwtXP+k3rN5UZqw253+7mSw8w1W7iuCo6nJBpIFdJpTHNMRr0R+pXhzxGt Imz4Datj4LGIQeXOHs8qXpwWn4WVqwz/HFUPSOjnHHBhDDtiG0rnCC3vqKkK27A1XgUgbL7oH+0Sp kEoPnXEEZEhU/3JIqwhJlZaJsbkJ2DbCDpmsF7O/WUpEMvO9ydoRufRZIzTWIOthA9rP/LuBrbdfU A1FmzPIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKoI-00000000wqQ-1KOq; Fri, 12 Jul 2024 18:15:58 +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 1sSKl6-00000000vOD-2iXP for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:42 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-65194ea3d4dso36987447b3.0 for ; Fri, 12 Jul 2024 11:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807959; x=1721412759; 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=BgJSCF9yLnG02WKUg8SfX7odmyVBKa2lGRMN+iopItY=; b=MACPEUz6QVI/VSAXmhTyg9U3H98c71KEKXw+9I7Ia3VwIjsKr73IPsX6kxfJpWp0pY xRIIg1r4p2kp4FqCoConVyCf4eLXr06Gqjk9uM/rQARzhr5ys0gZrtiz9dfH1LuaqqpG w2T7Df3coDZXC4aWBPtgU1464lhhAA1NVUxRMZz2kDqTmntlIn3D1V52Nzm18Nm41T77 +gzGquoBg+PKcH445BPoOF3QLJYLKgj55Q3rm3k6kHhWjPFLJlx/1leucbDTOWIOLyp0 b/gP2C2sDSLTpGrz0wq2qSwmbSoWhzNlAVBEv/2hdUZRCIlfnJvaAjQExNYCzrJ9RLd8 j0xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807959; x=1721412759; 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=BgJSCF9yLnG02WKUg8SfX7odmyVBKa2lGRMN+iopItY=; b=RHkjIWAT+ltZQIuSHDmf5Od9AP/zGcpi0BCnBIGL2IQ6IHRzRq7sg1sUoVR9P94P3A mEWAFVosHDtAL3HwhImtjDwAKfCZSRvkk5apVhM3m5CivpWudjTCCrBUHuDST140EUOr jQ8uiUiMmWO04FUU9ewGA9M+1SMxuNAgVfGgaHxHaojBppfpqphNc34bqXNsPnMvixvi +w5ulRu9LerDEtuFlnw8yzMVE5x8MAtH+0LzDNiyEIkGwyD2iKxKFi1a3qPPsgHlOuXv 6pHAu/TK2IkDWeqyf8h9CrJER0+o60iYlGsyT+BcT0hh+ZJD3KtecyDvNj9VseQAYIKO P4TQ== X-Forwarded-Encrypted: i=1; AJvYcCUQJSjuBr5UxdBddXnPNoGUpGSAnR45jt8UYFkFl5RW6DwsJ4Go38jcMGJYanaNh1vTpF+J4izxoBwrKVvNMdnt+dQms+4XQ0/hhI4QH50IJkZA5xc= X-Gm-Message-State: AOJu0Yyamt++bbVgB7syB0jJtuU4mGwE2bKzMAbgr1NGOmtmK9Vnv7Zj PlNqsJIaHfO0g487VjYR0KzJpaywT3ugDX0ITQVokBu8cpjKsXkAlDrghN0DGZPWvLuQ0sw4Vio G/YaFnQ== X-Google-Smtp-Source: AGHT+IGSRo1j+8MrlxjlP2j0amUvFCZ7I7KDAWRqN8yitAfuMgeL0LfUscnbxCScl9n5gTfoA9hXSuXoBhys X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:1002:b0:de4:654f:9ad0 with SMTP id 3f1490d57ef6-e041b058ccbmr26281276.6.1720807959082; Fri, 12 Jul 2024 11:12:39 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:54 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-14-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 13/27] perf script: 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-20240712_111240_771793_9B2C13F5 X-CRM114-Status: GOOD ( 13.83 ) 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-script.c | 65 +++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 394bce9f5338..b4fc2971335b 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -3899,38 +3899,7 @@ int cmd_script(int argc, const char **argv) const char *dlfilter_file = NULL; const char **__argv; int i, j, err = 0; - struct perf_script script = { - .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, - .attr = process_attr, - .event_update = perf_event__process_event_update, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .feature = process_feature_event, - .build_id = perf_event__process_build_id, - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_script__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .auxtrace_error = perf_event__process_auxtrace_error, - .stat = perf_event__process_stat_event, - .stat_round = process_stat_round_event, - .stat_config = process_stat_config_event, - .thread_map = process_thread_map_event, - .cpu_map = process_cpu_map_event, - .throttle = process_throttle_event, - .unthrottle = process_throttle_event, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, - }; + struct perf_script script = {}; struct perf_data data = { .mode = PERF_DATA_MODE_READ, }; @@ -4102,10 +4071,8 @@ int cmd_script(int argc, const char **argv) data.path = input_name; data.force = symbol_conf.force; - if (unsorted_dump) { + if (unsorted_dump) dump_trace = true; - script.tool.ordered_events = false; - } if (symbol__validate_sym_arguments()) return -1; @@ -4296,6 +4263,34 @@ int cmd_script(int argc, const char **argv) use_browser = 0; } + perf_tool__init(&script.tool, !unsorted_dump); + script.tool.sample = process_sample_event; + script.tool.mmap = perf_event__process_mmap; + script.tool.mmap2 = perf_event__process_mmap2; + script.tool.comm = perf_event__process_comm; + script.tool.namespaces = perf_event__process_namespaces; + script.tool.cgroup = perf_event__process_cgroup; + script.tool.exit = perf_event__process_exit; + script.tool.fork = perf_event__process_fork; + script.tool.attr = process_attr; + script.tool.event_update = perf_event__process_event_update; +#ifdef HAVE_LIBTRACEEVENT + script.tool.tracing_data = perf_event__process_tracing_data; +#endif + script.tool.feature = process_feature_event; + script.tool.build_id = perf_event__process_build_id; + script.tool.id_index = perf_event__process_id_index; + script.tool.auxtrace_info = perf_script__process_auxtrace_info; + script.tool.auxtrace = perf_event__process_auxtrace; + script.tool.auxtrace_error = perf_event__process_auxtrace_error; + script.tool.stat = perf_event__process_stat_event; + script.tool.stat_round = process_stat_round_event; + script.tool.stat_config = process_stat_config_event; + script.tool.thread_map = process_thread_map_event; + script.tool.cpu_map = process_cpu_map_event; + script.tool.throttle = process_throttle_event; + script.tool.unthrottle = process_throttle_event; + script.tool.ordering_requires_timestamps = true; session = perf_session__new(&data, &script.tool); if (IS_ERR(session)) return PTR_ERR(session);