From patchwork Thu Jul 18 01:00: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: 13735904 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 D03F4C3DA60 for ; Thu, 18 Jul 2024 01:05:14 +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=pNFK3i3CL2hY169owdLoin8oWSW6A2yJIcLVmlGvbqE=; b=B3rNRwUO9BQquq9uNHgQ2EP9xA cvh1eG5rQLLK3gUXAlN9eWkemQ0DnSHiOYFbdjpEBMcFwkpT8xOkXthO/P3JJWYBTBiWN8+B27iBJ Kh/xJoJKow14oA3Qt4nNnep57GUbrFRn6hu1EEsSUXPKC799vDWXQkWmp9IrZ/Yyzvu+wjJ8VUVIx 4pRj1xhqG5ELVbhADckRT3ZRGKm5aOOlHaHDS4dukIxOYFNtbDsE1hq/xZ9X8l8Fmh1BEgWxfpPAY l3FJlPTZdDimtNgxTzzToeHzTnk3LohjSdmM5fNOawyKtHs0xL8yFR7MW2D96nwSMRsoauvKpxMom t/GJFbQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFZt-0000000FLGH-38nY; Thu, 18 Jul 2024 01:05:01 +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 1sUFW8-0000000FJe3-1YQT for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:10 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e05faf3fdc4so650951276.2 for ; Wed, 17 Jul 2024 18:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264467; x=1721869267; 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=pNFK3i3CL2hY169owdLoin8oWSW6A2yJIcLVmlGvbqE=; b=nOLAqD46QZ2jSguJZEUVTox4wGvU8r3Ej1JSpL2i73Kh5fD84s1J00r3sbnJ4WmZtU lOLGg/+74a6HKwrDq/7aOToP4ZU2fKlogKB8Q6VM4vA7GuN1cqNXIBUnTyHKbVt1U9J6 kv8a3sTGJIO1YhMUfE/OTq/KkS/LkoN/vebdJ5rlizj98hTQeXAO3xyOfx/lbvLN1mJq EeppUkXgTh6cdtWeJ1W5AHMXNiYkwxXO4ELPbH0V16IDHITLex8kD8uuNBLa9u+Scajf 1HlhykMW34K9Rh9ocQjJBg4cbwn/DQ6huZVylEX8d3dUXkfktyEdWIUJuQPpo6hN7YyX 8R2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264467; x=1721869267; 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=pNFK3i3CL2hY169owdLoin8oWSW6A2yJIcLVmlGvbqE=; b=o78/vVT6re7H9fB2hYIek4c+K+jf3iwGTrlDCWNHncdm19wqqAwjWYLOkjH38YC+qb /duLkE0luE1cbvZfsoKKpUQPzFNOQRNioAHpjS1AP+Amtd7ZwWMafma+AuS98MNtrsmh F+3o05eva4PO/UnmYA8IIkoIhNHnisTbYDA8++zAIkN7T+ctQUiZrR8UPyFcsuLusVfr +udrwLfbZoXDWp6C7fo9DKDB+dy+gqCE1IQMOqbCQ9lJwfglJphlyxpS5JVwrX4qiafI 18dN49RyaUxBcIV/OPqmmdIg8DK13yHfnYrMUfBXSXC58NIcXxItGUZBw289LxXtqIET iIOg== X-Forwarded-Encrypted: i=1; AJvYcCV2xuvKXrXGspgkTqDzBicpQMT5/X9ckxpuenknnA+RaqcGkOak3LYlpAR0soR2hMWss5Ib56sJ5336ZDaZ33f8j5dUcxns5AvdxrPyeg94lPdlQXw= X-Gm-Message-State: AOJu0Yy0Ef238pZuOuZ9+dBbmK7hwsPAIfShaxglJTMpHhT7ag9sr5eS LiGfALh/DPQTX6h6I62nd4HKY97lS5QFQ18Ud6WY9507mve6ZXSk7Qwn4EBgF6II9K7xu287339 Eh47p2A== X-Google-Smtp-Source: AGHT+IFHPEUR6SHxDxIGONs3PPAyxDcCJ98okKUpCTVwExnLyEiQ71Kvctfkm9eZdP+bwodMy6NLwOHXvMHK X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:1003:b0:e05:a345:259a with SMTP id 3f1490d57ef6-e05febdcb0bmr22837276.9.1721264467108; Wed, 17 Jul 2024 18:01:07 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:09 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-14-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 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-20240717_180108_522869_A28A6B6B X-CRM114-Status: GOOD ( 13.09 ) 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-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);