From patchwork Mon Aug 12 20:47:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761030 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 345A4C52D7C for ; Mon, 12 Aug 2024 20:55:30 +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=sjc2eLEDEoqOWEk7kdawEPHb3ceHGyCKWkqgoVjnHA8=; b=W/0PJwBCVvaBkLORj8hACWijs7 Xnv4jxcT/hZdzUBqmbGCv3+Q9mtPFJ0Y1/FfUmR2ZpffsSe+0wYzpcRIEHOdafr3lSQJnamt51z7w RvVXF9/BK63edJepskokFTK1zFFK1IGlqDCUwMORKa38TggV2+gn/CgOVU/q1LI/yQEMw4cOqoz7u aIG3BksgC0ttWyXY4e1JP6yKyGaFNRq05LN5S4S4qavxUw4jrGfAe7l5en0ORH26AWJzSzjt3YQ6y 4fCzGTMKkKYlxYOm7nXuXPPD3pVlJgF3/SHfAgrMobuv3kMHBi69UvIiXBZAotUwzikPUWdwY1Itw LWr2jhoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc4U-00000001Wzb-3G1S; Mon, 12 Aug 2024 20:55:18 +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 1sdbxM-00000001Ubs-3AE4 for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:47:58 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-664b7a67ad4so111398237b3.2 for ; Mon, 12 Aug 2024 13:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495675; x=1724100475; 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=sjc2eLEDEoqOWEk7kdawEPHb3ceHGyCKWkqgoVjnHA8=; b=J3M5JZYliZ0sKaUfNF1Gb1jiUQ8iAjwHg3FdmQrEIV13xfnfBm3oHWaK/0/v+oLT/V zEAR9Onc5Lar2mUJj+F51qaQkd/G+hXaQ6dPXzx7l608cFdHvMsqqqYixXsTiLUlbpFY UAEXJWNkJFSxMfq392tYO7DwIKR3Fd0nc7YfENs4SRhM2WLod3NQUahwUXLZ4LJ4lm+W MbYfp4NyDIuCcTLT8DD68fx1W8HZdBt/7cj4Nsekbq4aytePO5zke6C6YD/yZlDPkg/d a4y5zzzFrJh8pFPJrVuos7oA7vSLmsewKWnpliZAzwTvDjkN5COZsquyMJPZj+TPBDzR NmzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495675; x=1724100475; 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=sjc2eLEDEoqOWEk7kdawEPHb3ceHGyCKWkqgoVjnHA8=; b=L0wkrnCM7Y7txCPFcO4IHguMe24aTPOWJB9tIWCimZjH7h0Q2u4wAIRwuUzdM0fp+W wBHcoWzsyVcaUPXNkz47WwbsJ7CtXW88qGZLKQZeD2ENdlG5bCwXsPlmoCuQLNViMXnd 7nmYDqF6uv+U8s+pwYzTmie8n7hV9axBRpWnQRwSF18TSp0GnTDRNkFO6Oqwu/JlQc12 aNgXRFN/0QusnQ8KN3bQqO+60oydlQCv0oXNfmkVc91rJaBHUzQ1vUwdZGFyk3Nf+66i yi4AE2K1RCeZWHC2EdolLZVN1+0FCnCscg65A54E0ioeFx+y+m4DQV9LMIXlBlfVdypk G3gQ== X-Forwarded-Encrypted: i=1; AJvYcCXD6DB9Svc/teXQWAG70TfAPxMwWBhPbT1RgmVvNN39ObWupLRMXkiFXS2CEH7XKbhQ2Y53zPAO3BqS/5/30V/u@lists.infradead.org X-Gm-Message-State: AOJu0Yyl2fm0Oa9kaoLbT7paOaVVL6i10mGHtkqhZ+uj1znIhQ9lGeLu IJq5iiyQdUm4H+685bjkJFVPijBoMAsikIhrXVL7lSmiPT3CtAuB0Ht4LSC+m9Gnb6IXo6cEaex SwkcnmA== X-Google-Smtp-Source: AGHT+IFOd0OYmeV8Y9nqWsHm87cprbndwMQUuF1PkqYQQdBPP3ERK15XiwbbgvEjejpEJkcmP4DPnNKtl5rP X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a81:ab4d:0:b0:69b:c01:82a5 with SMTP id 00721157ae682-6a975e90bcfmr579667b3.7.1723495675061; Mon, 12 Aug 2024 13:47:55 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:05 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-14-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 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-20240812_134757_124945_E2A084BD X-CRM114-Status: GOOD ( 14.35 ) 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);