From nobody Wed Dec 17 10:46:23 2025 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E2B9171658 for ; Thu, 11 Jul 2024 18:00:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720846; cv=none; b=cMDqM7ZvD/1o0UAMxs4e476mm54e75JdVsjQwPPWy5YYpuIbiOzC3VJkK6klLfEJVR2YAjLhNJhV7UY42IEBSDkQUkrW4ipxVVZtbKNWTHraARSQEoSAW04yh9gwhsxkQhjZZhQkiVBxl+kVLwsM94dVkDje84TZRGwIo+8tE8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720846; c=relaxed/simple; bh=gdWytOna78avdV8ta1mlF796MEMlXufN3RbPM1j+MUo=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=avNSqge3bsUKYQ1zNsSR4zu5K0bXU+FGBuJ0BUHqVgAayz4KfijlOpRD++2AIJU6sPOalyLaY6PEf8CoZzlXiGKllRiNt0SVmtko3BqtTxT8/fCUFvVSm6sCnObAeaLCCvGRqQmYRT+MbG4EPZaDRXkWEHyc6griLYqx5qrmw74= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=XcXE+d54; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XcXE+d54" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e035949cc4eso2128147276.1 for ; Thu, 11 Jul 2024 11:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720843; x=1721325643; darn=vger.kernel.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=XcXE+d54E/nI0W6uHdDcD7cyNaaCflJCceyJ/vJLLYDG9IDo/S3QYH5sMk8aUI6nHJ AX4MiYmGLhvBsuUNHiBjEVPRnd7NoMHqdtYbMQjO3/yrow7VEeNCkJW70xDx3Ux5DA4w Pw3RstYTx6rFs5p/7wSfp6TJiuT9JlCXYTFaUB8kqWMs6m8HitI3650rOreEdbNIHNKB BxK6DHj+e4gBM+v0OEDiLu/cNB+9Pk5QQ3dfMooE7YXfjoREzVi+WHDf02pi8sMcAevu xWuiPExgkVZ7LV15w2ANhH26e7UgmXK/gPiM4bXhl1DKpEgp0X1/B0mF/854pBNmxnM6 cLeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720843; x=1721325643; 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=eMrgorFANtzJNTZ21PREeU5ltHBg/N6nUaPe6yy9HUdmv72abhkLLPy5GDQSzuXDMe eiZDclv//GxkCMoU3QW4UBj4G0DWLAcoUYCcBWxNpUN7aNqunaH78bDj1l/zaZdSqGwr RSkbn4eX8BtKOJsbaroGg1KcVFBfOC+/k8NaJFDq8Ce8t/Bk0uyGlGVnB6HR7qFsy53L 1KgbQu+P3Ta+dis7dFjQAk/H6TRYAyulRWq6GcDhNtocZyP3G43+NrqUFgkROFg/BqAV alrGWcc0h3JVnzhZ64MIdjhwW+9xRPFIAv/taLmnyuJ7mt58wzxXJkbQaO0TSES+9sE9 WI3Q== X-Forwarded-Encrypted: i=1; AJvYcCVGQI6OLO8ztsMi1aQB1K81/9j+qyXJ8UZVlV4lqo9CaMu6eiz0x/abAezcsrr4Dsz+jMtAn5kvatSlyGIhaAZnwxN8kP35ekZPuWfJ X-Gm-Message-State: AOJu0YwZtQ5aJdG9q3iikd4o+l9MJaesX1GZLZgt+pPzFewZtE5kFYnz Mbak795ghFCujrCGuiQl/7GfFUoZX6BzY6oBlb28zAXeYh1TzRFhBx4dHmUCNaOWV4Cg45bO8Ap R5tWEYQ== X-Google-Smtp-Source: AGHT+IGUZPma1/UNbVlFLgQNB3aw1ju3QFq7+jgs3bRCoCKdY1pYTS0J6J1QQ1ukZSK8z62+IBuYguGU+ptP X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:2386:b0:e03:9d57:57ee with SMTP id 3f1490d57ef6-e041b0545c2mr460225276.4.1720720843539; Thu, 11 Jul 2024 11:00:43 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:54 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-15-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 14/28] 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D NULL; const char **__argv; int i, j, err =3D 0; - struct perf_script script =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .namespaces =3D perf_event__process_namespaces, - .cgroup =3D perf_event__process_cgroup, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .attr =3D process_attr, - .event_update =3D perf_event__process_event_update, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data =3D perf_event__process_tracing_data, -#endif - .feature =3D process_feature_event, - .build_id =3D perf_event__process_build_id, - .id_index =3D perf_event__process_id_index, - .auxtrace_info =3D perf_script__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .auxtrace_error =3D perf_event__process_auxtrace_error, - .stat =3D perf_event__process_stat_event, - .stat_round =3D process_stat_round_event, - .stat_config =3D process_stat_config_event, - .thread_map =3D process_thread_map_event, - .cpu_map =3D process_cpu_map_event, - .throttle =3D process_throttle_event, - .unthrottle =3D process_throttle_event, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, - }; + struct perf_script script =3D {}; struct perf_data data =3D { .mode =3D PERF_DATA_MODE_READ, }; @@ -4102,10 +4071,8 @@ int cmd_script(int argc, const char **argv) data.path =3D input_name; data.force =3D symbol_conf.force; =20 - if (unsorted_dump) { + if (unsorted_dump) dump_trace =3D true; - script.tool.ordered_events =3D false; - } =20 if (symbol__validate_sym_arguments()) return -1; @@ -4296,6 +4263,34 @@ int cmd_script(int argc, const char **argv) use_browser =3D 0; } =20 + perf_tool__init(&script.tool, !unsorted_dump); + script.tool.sample =3D process_sample_event; + script.tool.mmap =3D perf_event__process_mmap; + script.tool.mmap2 =3D perf_event__process_mmap2; + script.tool.comm =3D perf_event__process_comm; + script.tool.namespaces =3D perf_event__process_namespaces; + script.tool.cgroup =3D perf_event__process_cgroup; + script.tool.exit =3D perf_event__process_exit; + script.tool.fork =3D perf_event__process_fork; + script.tool.attr =3D process_attr; + script.tool.event_update =3D perf_event__process_event_update; +#ifdef HAVE_LIBTRACEEVENT + script.tool.tracing_data =3D perf_event__process_tracing_data; +#endif + script.tool.feature =3D process_feature_event; + script.tool.build_id =3D perf_event__process_build_id; + script.tool.id_index =3D perf_event__process_id_index; + script.tool.auxtrace_info =3D perf_script__process_auxtrace_info; + script.tool.auxtrace =3D perf_event__process_auxtrace; + script.tool.auxtrace_error =3D perf_event__process_auxtrace_error; + script.tool.stat =3D perf_event__process_stat_event; + script.tool.stat_round =3D process_stat_round_event; + script.tool.stat_config =3D process_stat_config_event; + script.tool.thread_map =3D process_thread_map_event; + script.tool.cpu_map =3D process_cpu_map_event; + script.tool.throttle =3D process_throttle_event; + script.tool.unthrottle =3D process_throttle_event; + script.tool.ordering_requires_timestamps =3D true; session =3D perf_session__new(&data, &script.tool); if (IS_ERR(session)) return PTR_ERR(session); --=20 2.45.2.993.g49e7a77208-goog