From nobody Wed Dec 17 08:56:07 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 06DC8177982 for ; Fri, 12 Jul 2024 18:12:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807935; cv=none; b=ath6ZdeFmRrTc5bgxUPEHknaNhUcrJKBCri4cqyUmPG2tZZumxKKM0I0+vQYIJmjD8RqU6fsxS1mMTwrki1dE9w8Kzq4QbBOMBh1uOGKGWPBeOnKcBBZY76rO293SABtJNucLPq6qf8aJg0DnoUgYBwhqj5qV4HRJVbumMu52Bk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807935; c=relaxed/simple; bh=4cp6uLBgGkWjDELO/N1tG5QGFJMICWk677rX66y9+NY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=AsmeAuT9PAiyVD3Ys40MKCTEoogBjDIo7//AQDEUV7Yeg9qq+vEPmL3Ab0jTWGrFGY41b24dWtBsWy4IbE4uk3PEwnzz3kiEjsUxtRv4vVKmfhgo63S+9HJpTCeY2rZcwZSetdb9OChfwSw3OJ5UTnhUYG+6YroHYeH+f7Q+edU= 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=0wQnmsVy; arc=none smtp.client-ip=209.85.128.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="0wQnmsVy" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6525230ceeaso42245407b3.2 for ; Fri, 12 Jul 2024 11:12:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807933; x=1721412733; 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=i9KTqj1XTO1kSrFui3ztj2R2oaLi4f9rlK2QpY6IF3o=; b=0wQnmsVyCWpVwrZmm/soPpCBsIaePY6T2nhQ0VObHDmz/fWNOMcFWuDpp6ua41FH0i HLOZ0nHcTFTQJM2qRLbOGSDPVQc2wOQRrYTBFvyfqZvKf83GHbNCrpQJTEp4r/Rn0ouN QdOMX3UeTAfc9tpgCO4O+g3AbMxWhlrD/MH+az3vW920o+twF0cSl++8lurcy3bTrdHH 1MC2b8p/YH1ac0Yn09cLZMUVUho2thQR2GM3w9QXsDgcFhUGkEVGVtPpyKgm4La032kk QY8rEWtO5X0lXbBY9WtrVUSUUP1xkDcG23pYyxbKzC/9x8d4/PRTFSFWSCtuNRRQrMEZ RGog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807933; x=1721412733; 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=i9KTqj1XTO1kSrFui3ztj2R2oaLi4f9rlK2QpY6IF3o=; b=Fu/GAz+n28Ykg0it45hLduBok2xWYWUM32DK0gzKSaeLjmg0+XcsBqdrR02nRXgTgk sZmfnOoWSplhZknEDj35ba2j55zle/ZyOsYfbawVIOo3znoUEri2xHvrF+RCwXaB7qCd ZQT/F0Tl8bNZegdy0VTNGsoUa7uy9tPGb8WU4DHqDSvN5iM3q3euqCYKYbIAuxG+D4Uv cKykAtHs8vpwcCw7q3+Q2y/jBiWeQdvxmZNbthbQmap4oi2Ue8WqKOutqxjG+SeyYYgZ gUion3J8Ug+6nt14sYW402Jvywi6Rl9yVhDUwICS6fFBBZP3vY+RIg4awAVnPtX5Hn7l cRiQ== X-Forwarded-Encrypted: i=1; AJvYcCURXiWWzyoL4ozLKKfgxmSFMicQTLXN0Yz4clt79BWjNr+DbVO3r8iZfoaqkrQr8Voaxtlsa95XkUUL5/1gxLyQiZ3ocTk8sFRr32RZ X-Gm-Message-State: AOJu0Yz14cOEWO5JPM64Tt6EEbWZdsLeBLm8sAnI+Up+JxWFJKe1p1rz UlNu+jVt5bAdnqjoaW+liNPFei99+0A5EQ3coHE+LejMfSo4WqoloBwf4jqWihLfKGmdtofFcc9 9RNOFhA== X-Google-Smtp-Source: AGHT+IGvfJh6Fcob436fAIUAkFPWwgKJ1V+h3C/YNeu+8Ob8fyB7BX4Gx99i+s9g+7X7JG4NXDcKx7uNt6JD X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:6910:b0:650:92da:a97f with SMTP id 00721157ae682-658f0fb318fmr1326627b3.10.1720807932980; Fri, 12 Jul 2024 11:12:12 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:42 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 01/27] perf auxtrace: Remove dummy tools 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" Add perf_session__deliver_synth_attr_event that synthesizes a perf_record_header_attr event with one id. Remove use of perf_event__synthesize_attr that necessitates the use of the dummy tool in order to pass the session. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter Tested-by: Adrian Hunter Tested-by: Leo Yan --- tools/perf/util/arm-spe.c | 49 ++++++++----------------------------- tools/perf/util/cs-etm.c | 33 ++----------------------- tools/perf/util/intel-bts.c | 31 +---------------------- tools/perf/util/intel-pt.c | 24 +----------------- tools/perf/util/session.c | 24 ++++++++++++++++++ tools/perf/util/session.h | 3 +++ 6 files changed, 41 insertions(+), 123 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index afbd5869f6bf..fa40f3cb6266 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -1073,35 +1073,6 @@ static void arm_spe_print_info(__u64 *arr) fprintf(stdout, arm_spe_info_fmts[ARM_SPE_PMU_TYPE], arr[ARM_SPE_PMU_TYPE= ]); } =20 -struct arm_spe_synth { - struct perf_tool dummy_tool; - struct perf_session *session; -}; - -static int arm_spe_event_synth(struct perf_tool *tool, - union perf_event *event, - struct perf_sample *sample __maybe_unused, - struct machine *machine __maybe_unused) -{ - struct arm_spe_synth *arm_spe_synth =3D - container_of(tool, struct arm_spe_synth, dummy_tool); - - return perf_session__deliver_synth_event(arm_spe_synth->session, - event, NULL); -} - -static int arm_spe_synth_event(struct perf_session *session, - struct perf_event_attr *attr, u64 id) -{ - struct arm_spe_synth arm_spe_synth; - - memset(&arm_spe_synth, 0, sizeof(struct arm_spe_synth)); - arm_spe_synth.session =3D session; - - return perf_event__synthesize_attr(&arm_spe_synth.dummy_tool, attr, 1, - &id, arm_spe_event_synth); -} - static void arm_spe_set_event_name(struct evlist *evlist, u64 id, const char *name) { @@ -1172,7 +1143,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf= _session *session) spe->sample_flc =3D true; =20 /* Level 1 data cache miss */ - err =3D arm_spe_synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->l1d_miss_id =3D id; @@ -1180,7 +1151,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf= _session *session) id +=3D 1; =20 /* Level 1 data cache access */ - err =3D arm_spe_synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->l1d_access_id =3D id; @@ -1192,7 +1163,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf= _session *session) spe->sample_llc =3D true; =20 /* Last level cache miss */ - err =3D arm_spe_synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->llc_miss_id =3D id; @@ -1200,7 +1171,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf= _session *session) id +=3D 1; =20 /* Last level cache access */ - err =3D arm_spe_synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->llc_access_id =3D id; @@ -1212,7 +1183,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf= _session *session) spe->sample_tlb =3D true; =20 /* TLB miss */ - err =3D arm_spe_synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->tlb_miss_id =3D id; @@ -1220,7 +1191,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf= _session *session) id +=3D 1; =20 /* TLB access */ - err =3D arm_spe_synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->tlb_access_id =3D id; @@ -1232,7 +1203,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf= _session *session) spe->sample_branch =3D true; =20 /* Branch miss */ - err =3D arm_spe_synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->branch_miss_id =3D id; @@ -1244,7 +1215,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf= _session *session) spe->sample_remote_access =3D true; =20 /* Remote access */ - err =3D arm_spe_synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->remote_access_id =3D id; @@ -1255,7 +1226,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf= _session *session) if (spe->synth_opts.mem) { spe->sample_memory =3D true; =20 - err =3D arm_spe_synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->memory_id =3D id; @@ -1276,7 +1247,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf= _session *session) attr.config =3D PERF_COUNT_HW_INSTRUCTIONS; attr.sample_period =3D spe->synth_opts.period; spe->instructions_sample_period =3D attr.sample_period; - err =3D arm_spe_synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->instructions_id =3D id; diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 5e9fbcfad7d4..7fd976ea954b 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1595,35 +1595,6 @@ static int cs_etm__synth_branch_sample(struct cs_etm= _queue *etmq, return ret; } =20 -struct cs_etm_synth { - struct perf_tool dummy_tool; - struct perf_session *session; -}; - -static int cs_etm__event_synth(struct perf_tool *tool, - union perf_event *event, - struct perf_sample *sample __maybe_unused, - struct machine *machine __maybe_unused) -{ - struct cs_etm_synth *cs_etm_synth =3D - container_of(tool, struct cs_etm_synth, dummy_tool); - - return perf_session__deliver_synth_event(cs_etm_synth->session, - event, NULL); -} - -static int cs_etm__synth_event(struct perf_session *session, - struct perf_event_attr *attr, u64 id) -{ - struct cs_etm_synth cs_etm_synth; - - memset(&cs_etm_synth, 0, sizeof(struct cs_etm_synth)); - cs_etm_synth.session =3D session; - - return perf_event__synthesize_attr(&cs_etm_synth.dummy_tool, attr, 1, - &id, cs_etm__event_synth); -} - static int cs_etm__synth_events(struct cs_etm_auxtrace *etm, struct perf_session *session) { @@ -1675,7 +1646,7 @@ static int cs_etm__synth_events(struct cs_etm_auxtrac= e *etm, attr.config =3D PERF_COUNT_HW_BRANCH_INSTRUCTIONS; attr.sample_period =3D 1; attr.sample_type |=3D PERF_SAMPLE_ADDR; - err =3D cs_etm__synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; etm->branches_sample_type =3D attr.sample_type; @@ -1698,7 +1669,7 @@ static int cs_etm__synth_events(struct cs_etm_auxtrac= e *etm, attr.config =3D PERF_COUNT_HW_INSTRUCTIONS; attr.sample_period =3D etm->synth_opts.period; etm->instructions_sample_period =3D attr.sample_period; - err =3D cs_etm__synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; etm->instructions_sample_type =3D attr.sample_type; diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index ec1b3bd9f530..160d346cb450 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -737,35 +737,6 @@ static bool intel_bts_evsel_is_auxtrace(struct perf_se= ssion *session, return evsel->core.attr.type =3D=3D bts->pmu_type; } =20 -struct intel_bts_synth { - struct perf_tool dummy_tool; - struct perf_session *session; -}; - -static int intel_bts_event_synth(struct perf_tool *tool, - union perf_event *event, - struct perf_sample *sample __maybe_unused, - struct machine *machine __maybe_unused) -{ - struct intel_bts_synth *intel_bts_synth =3D - container_of(tool, struct intel_bts_synth, dummy_tool); - - return perf_session__deliver_synth_event(intel_bts_synth->session, - event, NULL); -} - -static int intel_bts_synth_event(struct perf_session *session, - struct perf_event_attr *attr, u64 id) -{ - struct intel_bts_synth intel_bts_synth; - - memset(&intel_bts_synth, 0, sizeof(struct intel_bts_synth)); - intel_bts_synth.session =3D session; - - return perf_event__synthesize_attr(&intel_bts_synth.dummy_tool, attr, 1, - &id, intel_bts_event_synth); -} - static int intel_bts_synth_events(struct intel_bts *bts, struct perf_session *session) { @@ -814,7 +785,7 @@ static int intel_bts_synth_events(struct intel_bts *bts, attr.sample_type |=3D PERF_SAMPLE_ADDR; pr_debug("Synthesizing 'branches' event with id %" PRIu64 " sample type = %#" PRIx64 "\n", id, (u64)attr.sample_type); - err =3D intel_bts_synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) { pr_err("%s: failed to synthesize 'branches' event type\n", __func__); diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index d6d7b7512505..1fc03bfd14c3 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -3659,37 +3659,15 @@ static int intel_pt_queue_data(struct perf_session = *session, data_offset, timestamp); } =20 -struct intel_pt_synth { - struct perf_tool dummy_tool; - struct perf_session *session; -}; - -static int intel_pt_event_synth(struct perf_tool *tool, - union perf_event *event, - struct perf_sample *sample __maybe_unused, - struct machine *machine __maybe_unused) -{ - struct intel_pt_synth *intel_pt_synth =3D - container_of(tool, struct intel_pt_synth, dummy_tool); - - return perf_session__deliver_synth_event(intel_pt_synth->session, event, - NULL); -} - static int intel_pt_synth_event(struct perf_session *session, const char *= name, struct perf_event_attr *attr, u64 id) { - struct intel_pt_synth intel_pt_synth; int err; =20 pr_debug("Synthesizing '%s' event with id %" PRIu64 " sample type %#" PRI= x64 "\n", name, id, (u64)attr->sample_type); =20 - memset(&intel_pt_synth, 0, sizeof(struct intel_pt_synth)); - intel_pt_synth.session =3D session; - - err =3D perf_event__synthesize_attr(&intel_pt_synth.dummy_tool, attr, 1, - &id, intel_pt_event_synth); + err =3D perf_session__deliver_synth_attr_event(session, attr, id); if (err) pr_err("%s: failed to synthesize '%s' event type\n", __func__, name); diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 5596bed1b8c8..18a8f4a84045 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1764,6 +1764,30 @@ int perf_session__deliver_synth_event(struct perf_se= ssion *session, return machines__deliver_event(&session->machines, evlist, event, sample,= tool, 0, NULL); } =20 +int perf_session__deliver_synth_attr_event(struct perf_session *session, + const struct perf_event_attr *attr, + u64 id) +{ + union { + struct { + struct perf_record_header_attr attr; + u64 ids[1]; + } attr_id; + union perf_event ev; + } ev =3D { + .attr_id.attr.header.type =3D PERF_RECORD_HEADER_ATTR, + .attr_id.attr.header.size =3D sizeof(ev.attr_id), + .attr_id.ids[0] =3D id, + }; + + if (attr->size !=3D sizeof(ev.attr_id.attr.attr)) { + pr_debug("Unexpected perf_event_attr size\n"); + return -EINVAL; + } + ev.attr_id.attr.attr =3D *attr; + return perf_session__deliver_synth_event(session, &ev.ev, NULL); +} + static void event_swap(union perf_event *event, bool sample_id_all) { perf_event__swap_op swap; diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 4c29dc86956f..cc28976bb00e 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -154,6 +154,9 @@ extern volatile int session_done; int perf_session__deliver_synth_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample); +int perf_session__deliver_synth_attr_event(struct perf_session *session, + const struct perf_event_attr *attr, + u64 id); =20 int perf_session__dsos_hit_all(struct perf_session *session); =20 --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:07 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 ED212178361 for ; Fri, 12 Jul 2024 18:12:15 +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=1720807937; cv=none; b=VkwD/IP+7lsscdOO37MNl1nWjO2X2GgQAlmSQi0otIVduCqpwxEezq1JRkJRgjMlTCqnoi3gUAJlWA6aDhX1JjtmHF23CZEDzpnp9cDhp/XXp79zQFTrkJtIhuDZ90oFy2rfJt9COoC4dM9eFjpzPiPAfBZVBOM4Lp/ohEucp+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807937; c=relaxed/simple; bh=LctEg2Je3fRQdJP1aZySQP64dlbQCviuGkAlqwvn5oA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=nWgDg79SzaR/E+FB5/3HxSpOIgqXGE/xvWqBdWzz2HGQDcruuNgwaKXnpTgC7Fh/2uV1mJpT3UofEPLvuTYvFoB5RhoYBvQ2MaaD0k6jzmXCH+U3zG2AUiQyjujoEnzPwXt2451mPVtOxkWYd4Qrh6pQUViTPvuF8iTNpK/2RQA= 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=3wlSGdx+; 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="3wlSGdx+" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e03a694ba5aso3598907276.3 for ; Fri, 12 Jul 2024 11:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807935; x=1721412735; 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=AbSFIAjgELn8En/ODTzECP6YTzi/bZUaiF8JxVDqD4U=; b=3wlSGdx+VpQbcv2sqOTDUzio+fUQVprQZ7TFarkZI8oyJrTnBW2b3cLbbJJe2QL9ET l3oayrKkNPvqQauUIXETTJAKBpq3JrcVpQRJKwzvdJ9m+5YHK8C3Zix+9sNaod7IYqqO hF3TscKDO4FAXS+HIb4qLDF5LhMmSTPqgK6x35Lru9mDyl+b/iLWIhQtVvcU2fCy34w4 S4ykt9PhwkIWu8FAMO/8j3e521uNSKOyKoSgM/deVnchXW3+MEJzHfw6dRdgjNFTA1Lf aO6IQoP+tXBhKIkzgBK5EeXEQu5LUXnU/6OrxRDmpfSM/O01UoMxjIPZ8g21RmMB1I9N xmXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807935; x=1721412735; 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=AbSFIAjgELn8En/ODTzECP6YTzi/bZUaiF8JxVDqD4U=; b=J+FT1dQFk9OxKsvnczzU6ISqMsLJiVkyioaquo7ovFd/OD9sySf5ijEuPocr5rYGM8 TWKjMjfjW3ZnBbfLA5XGg+bgVJG5Wc8VwPVlciJ/p7NUjtODC/dCPwVL+rqLkoSX8fSc G/gNZBmgJEtYl/oKti5gemBL9yTexFgPpfGa7ud/kVIavtLgB92yqAQDagmh7Gtrs6iv OEbevLXvCd1NOhzVHYmplEFDPx5Xzd4Gm2nAsp2CTJITG/1p0gIcf0BxMOufRlPloSge 9cMms4qWGwxMDdHa7fgNx7PaaJC28lwW3q0JbrnUBilBkyhz9DbesBeIMe15t2ujrRVD wPpw== X-Forwarded-Encrypted: i=1; AJvYcCUCwcheReD1zQFXYdQiayJ/rtZSrq6EbI1Ca8LExohxc6Mp5dRVuNdiMHJmQ4pq/2Ryxohlq0EfJzS4Oe3R8bnMOv+Q1SHQpymJFZNz X-Gm-Message-State: AOJu0Yw2inr/mhCXxsWsJakTP4EmhE4W5QvcIUF3H4diIasYgDV4b27K TINWDgjqeHenGq8r9mHNkfAQr9GoQLGU6gAQzsrdbrTj673f0QFGkVKADSQzQocyBiYOavk0tfQ YPnFAkQ== X-Google-Smtp-Source: AGHT+IFiaKeWftjlYDypGwGYdX+YIN1A5uSwmAuQjC00TFYkgW3S+YBZZ4Y/Pr7DJjydk0jmQ0Rw6pq2PkQl X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:274a:b0:e03:2f8e:9d81 with SMTP id 3f1490d57ef6-e041af3b67amr54130276.0.1720807934990; Fri, 12 Jul 2024 11:12:14 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:43 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-3-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 02/27] perf s390-cpumsf: Remove unused struct 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" struct s390_cpumsf_synth was likely cargo culted from other auxtrace examples. It has no users, so remove. Signed-off-by: Ian Rogers --- tools/perf/util/s390-cpumsf.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index 6fe478b0b61b..4ec583e511af 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -952,11 +952,6 @@ s390_cpumsf_process_event(struct perf_session *session, return err; } =20 -struct s390_cpumsf_synth { - struct perf_tool cpumsf_tool; - struct perf_session *session; -}; - static int s390_cpumsf_process_auxtrace_event(struct perf_session *session, union perf_event *event __maybe_unused, --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:07 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 46D28178398 for ; Fri, 12 Jul 2024 18:12:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807943; cv=none; b=BsQbP3vWi9bb9Icarvuw8+GsnNwY9xa3A/XpOvmKgpAQ47I7oU6xnBcm3Jncwo3QazL8JEx36ZVh0eZ2Y0ziiSpAedU3USFePRDBXL2XrXWHJR+4JYoyx70JGVPIwv0HpHI5AZwFGr9Aa58r88dpJVvhLneqQkNcL3Zlgt0IkoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807943; c=relaxed/simple; bh=3+jemqp+N2P27Sk42oFvJxS+mgFZvwI1zGTCPAgP5V8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Ulj2beJw6QrZa9PgGLgg0icLv1ubVQTa7dqqqQTClegItLRUKqwQjck6O+xz2vUOGS4Od0thm5aX2dlbzc09tXt5jeXIroxUKYLYGytRVm7ojlXvC5wpRdKp2pEwH9BO8ZpesE3IIEMhoDAaLpxQzs2/kpEPmhu11S8rM6WF0d8= 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=lq3hTBN3; arc=none smtp.client-ip=209.85.128.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="lq3hTBN3" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-64c3f08ca52so34512927b3.3 for ; Fri, 12 Jul 2024 11:12:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807937; x=1721412737; 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=HIWQmor+Scc7M4YcVrFBx0ZUYFreSj97vY86NrMsF4g=; b=lq3hTBN3uF2lDBThUL6XyNns8mD99P97OOUGpDRdHfgBLaSEoCcnXMKeifE2Sm/scu gssl3j4Kh+n0U0sljyfdH9wlaptXvSGxsz/Wn3B2AACkQgpQsh+tEs12QRPiucNEiHIC /Jmhh8vp5hpPQ00gz4dwwNRxzgDpwm42n39bvvHtPmoOTmo8hdX651m5biLJbYtdvuTf 44WjsJxTXWNzop8EEDlg5XugkaRpNYLMn2cwE5jsmvXiu8N8VJ9c/+PqVGIkD5bw2QIG HnW54NhhdCD0TVyqmtFhA66B0d/3z5HcMv8bNbdBhTOliF+GxftvTdrfyUKp4Q4UCF7h s4Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807937; x=1721412737; 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=HIWQmor+Scc7M4YcVrFBx0ZUYFreSj97vY86NrMsF4g=; b=VAqBQwJazA52K7tUKEJ8OJmYrL7dehv3sd8d+fa3SKDGTqdM5K5p0x2n/q5F8te1II tMZsc5+A9DWcmOW2XKuYzq6kodvHT+pb/p5D5U8qwzSxFPTTbtdBStXFhK1hmIHSTKSW Qphgb8lcXLDJebHD4QF223OJYi/RdXA9wKTzc1moWisNDDGKZML3msz5BXQTH9qE7lKh R/2J6ya2O1tl2hmyQTvniPmDIA0fuoClkJt3xj5+XQOfQ1C6+F6dlY+nfhsiMbMsw4fQ 8q778j1dDssaVBF94FYsZIcmuHQ0ERg9pr+DH75iADWgj7BLI3GOs88Dsc39XmzcRVeo iwMA== X-Forwarded-Encrypted: i=1; AJvYcCXYa7VheW07+aBzCG6S2UdK9C4mrQoj0NKnGlXsr5vzvfFi8HrVmTb3Hd4jo+4hDL3f/1J4CbPHSePqLPfZ7BBN5vysaZzbEjLAc2ow X-Gm-Message-State: AOJu0YzFqhLhpgAZ5YItqvsthb42yKE2qEO43xKbl39Mlk2nfD/FX6Wa UIf35At9WpFGG/4DfZ7/u5A1LkocEWp5jYEf6YYIpFsI8MPGCpWD4TJTIPE+2BuIRxNmRHPek7s RzJQgTg== X-Google-Smtp-Source: AGHT+IHYPTXXmKLWqrt3itHMlToWeCci3onqs4yNbG96uPz1SboBng8Qtoz/+vKU0BY0uMpCh892WFK+D451 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:724a:b0:646:3ef4:6ad2 with SMTP id 00721157ae682-658f0accfedmr2475237b3.9.1720807937299; Fri, 12 Jul 2024 11:12:17 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:44 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-4-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 03/27] perf tool: Constify tool pointers 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" The tool pointer (to a struct largely of function pointers) is passed around but is unchanged except at initialization. Change parameter and variable types to be const to lower the possibilities of what could happen with a tool. Signed-off-by: Ian Rogers --- tools/perf/arch/x86/util/event.c | 4 +- tools/perf/bench/synthesize.c | 2 +- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-c2c.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-inject.c | 70 ++++++++++++------------- tools/perf/builtin-kmem.c | 3 +- tools/perf/builtin-kvm.c | 4 +- tools/perf/builtin-kwork.c | 22 ++++---- tools/perf/builtin-lock.c | 4 +- tools/perf/builtin-mem.c | 4 +- tools/perf/builtin-record.c | 14 ++--- tools/perf/builtin-report.c | 12 ++--- tools/perf/builtin-sched.c | 34 ++++++------ tools/perf/builtin-script.c | 41 ++++++++------- tools/perf/builtin-stat.c | 8 +-- tools/perf/builtin-timechart.c | 8 +-- tools/perf/builtin-top.c | 2 +- tools/perf/builtin-trace.c | 4 +- tools/perf/tests/cpumap.c | 6 +-- tools/perf/tests/dlfilter-test.c | 2 +- tools/perf/tests/dwarf-unwind.c | 2 +- tools/perf/tests/event_update.c | 8 +-- tools/perf/tests/stat.c | 6 +-- tools/perf/tests/thread-map.c | 2 +- tools/perf/util/arm-spe.c | 6 +-- tools/perf/util/auxtrace.c | 12 ++--- tools/perf/util/auxtrace.h | 20 ++++---- tools/perf/util/bpf-event.c | 4 +- tools/perf/util/build-id.c | 4 +- tools/perf/util/build-id.h | 4 +- tools/perf/util/cs-etm.c | 6 +-- tools/perf/util/data-convert-bt.c | 4 +- tools/perf/util/data-convert-json.c | 4 +- tools/perf/util/event.c | 34 ++++++------ tools/perf/util/event.h | 34 ++++++------ tools/perf/util/header.c | 6 +-- tools/perf/util/header.h | 4 +- tools/perf/util/hisi-ptt.c | 6 +-- tools/perf/util/intel-bts.c | 6 +-- tools/perf/util/intel-pt.c | 6 +-- tools/perf/util/jitdump.c | 4 +- tools/perf/util/s390-cpumsf.c | 6 +-- tools/perf/util/session.c | 30 +++++------ tools/perf/util/session.h | 2 +- tools/perf/util/synthetic-events.c | 80 ++++++++++++++--------------- tools/perf/util/synthetic-events.h | 70 ++++++++++++------------- tools/perf/util/tool.h | 8 +-- tools/perf/util/tsc.c | 2 +- 49 files changed, 314 insertions(+), 316 deletions(-) diff --git a/tools/perf/arch/x86/util/event.c b/tools/perf/arch/x86/util/ev= ent.c index e65b7dbe27fb..a0400707180c 100644 --- a/tools/perf/arch/x86/util/event.c +++ b/tools/perf/arch/x86/util/event.c @@ -15,7 +15,7 @@ #if defined(__x86_64__) =20 struct perf_event__synthesize_extra_kmaps_cb_args { - struct perf_tool *tool; + const struct perf_tool *tool; perf_event__handler_t process; struct machine *machine; union perf_event *event; @@ -65,7 +65,7 @@ static int perf_event__synthesize_extra_kmaps_cb(struct m= ap *map, void *data) return 0; } =20 -int perf_event__synthesize_extra_kmaps(struct perf_tool *tool, +int perf_event__synthesize_extra_kmaps(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine) { diff --git a/tools/perf/bench/synthesize.c b/tools/perf/bench/synthesize.c index 7401ebbac100..9b333276cbdb 100644 --- a/tools/perf/bench/synthesize.c +++ b/tools/perf/bench/synthesize.c @@ -49,7 +49,7 @@ static const char *const bench_usage[] =3D { =20 static atomic_t event_count; =20 -static int process_synthesized_event(struct perf_tool *tool __maybe_unused, +static int process_synthesized_event(const struct perf_tool *tool __maybe_= unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index b10b7f005658..c0685d2c8de1 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -279,7 +279,7 @@ static int evsel__add_sample(struct evsel *evsel, struc= t perf_sample *sample, return ret; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index c157bd31f2e5..88c131d05186 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -273,7 +273,7 @@ static void compute_stats(struct c2c_hist_entry *c2c_he, update_stats(&cstats->load, weight); } =20 -static int process_sample_event(struct perf_tool *tool __maybe_unused, +static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 57d300d8e570..4c0567882a7a 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -388,7 +388,7 @@ struct hist_entry_ops block_hist_ops =3D { .free =3D block_hist_free, }; =20 -static int diff__process_sample_event(struct perf_tool *tool, +static int diff__process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index a212678d47be..be74e2bf1f00 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -134,7 +134,7 @@ struct event_entry { union perf_event event[]; }; =20 -static int dso__inject_build_id(struct dso *dso, struct perf_tool *tool, +static int dso__inject_build_id(struct dso *dso, const struct perf_tool *t= ool, struct machine *machine, u8 cpumode, u32 flags); =20 static int output_bytes(struct perf_inject *inject, void *buf, size_t sz) @@ -149,7 +149,7 @@ static int output_bytes(struct perf_inject *inject, voi= d *buf, size_t sz) return 0; } =20 -static int perf_event__repipe_synth(struct perf_tool *tool, +static int perf_event__repipe_synth(const struct perf_tool *tool, union perf_event *event) { struct perf_inject *inject =3D container_of(tool, struct perf_inject, @@ -158,7 +158,7 @@ static int perf_event__repipe_synth(struct perf_tool *t= ool, return output_bytes(inject, event, event->header.size); } =20 -static int perf_event__repipe_oe_synth(struct perf_tool *tool, +static int perf_event__repipe_oe_synth(const struct perf_tool *tool, union perf_event *event, struct ordered_events *oe __maybe_unused) { @@ -166,7 +166,7 @@ static int perf_event__repipe_oe_synth(struct perf_tool= *tool, } =20 #ifdef HAVE_JITDUMP -static int perf_event__drop_oe(struct perf_tool *tool __maybe_unused, +static int perf_event__drop_oe(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct ordered_events *oe __maybe_unused) { @@ -188,7 +188,7 @@ static int perf_event__repipe_op4_synth(struct perf_ses= sion *session, return perf_event__repipe_synth(session->tool, event); } =20 -static int perf_event__repipe_attr(struct perf_tool *tool, +static int perf_event__repipe_attr(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist) { @@ -206,7 +206,7 @@ static int perf_event__repipe_attr(struct perf_tool *to= ol, return perf_event__repipe_synth(tool, event); } =20 -static int perf_event__repipe_event_update(struct perf_tool *tool, +static int perf_event__repipe_event_update(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist __maybe_unused) { @@ -237,7 +237,7 @@ static int copy_bytes(struct perf_inject *inject, struc= t perf_data *data, off_t static s64 perf_event__repipe_auxtrace(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_inject *inject =3D container_of(tool, struct perf_inject, tool); int ret; @@ -284,7 +284,7 @@ perf_event__repipe_auxtrace(struct perf_session *sessio= n __maybe_unused, =20 #endif =20 -static int perf_event__repipe(struct perf_tool *tool, +static int perf_event__repipe(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -292,7 +292,7 @@ static int perf_event__repipe(struct perf_tool *tool, return perf_event__repipe_synth(tool, event); } =20 -static int perf_event__drop(struct perf_tool *tool __maybe_unused, +static int perf_event__drop(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -300,7 +300,7 @@ static int perf_event__drop(struct perf_tool *tool __ma= ybe_unused, return 0; } =20 -static int perf_event__drop_aux(struct perf_tool *tool, +static int perf_event__drop_aux(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct machine *machine __maybe_unused) @@ -341,13 +341,13 @@ perf_inject__cut_auxtrace_sample(struct perf_inject *= inject, return ev; } =20 -typedef int (*inject_handler)(struct perf_tool *tool, +typedef int (*inject_handler)(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine); =20 -static int perf_event__repipe_sample(struct perf_tool *tool, +static int perf_event__repipe_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -372,7 +372,7 @@ static int perf_event__repipe_sample(struct perf_tool *= tool, return perf_event__repipe_synth(tool, event); } =20 -static int perf_event__repipe_mmap(struct perf_tool *tool, +static int perf_event__repipe_mmap(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -386,7 +386,7 @@ static int perf_event__repipe_mmap(struct perf_tool *to= ol, } =20 #ifdef HAVE_JITDUMP -static int perf_event__jit_repipe_mmap(struct perf_tool *tool, +static int perf_event__jit_repipe_mmap(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -455,7 +455,7 @@ static struct dso *findnew_dso(int pid, int tid, const = char *filename, return dso; } =20 -static int perf_event__repipe_buildid_mmap(struct perf_tool *tool, +static int perf_event__repipe_buildid_mmap(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -474,7 +474,7 @@ static int perf_event__repipe_buildid_mmap(struct perf_= tool *tool, return perf_event__repipe(tool, event, sample, machine); } =20 -static int perf_event__repipe_mmap2(struct perf_tool *tool, +static int perf_event__repipe_mmap2(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -500,7 +500,7 @@ static int perf_event__repipe_mmap2(struct perf_tool *t= ool, } =20 #ifdef HAVE_JITDUMP -static int perf_event__jit_repipe_mmap2(struct perf_tool *tool, +static int perf_event__jit_repipe_mmap2(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -524,7 +524,7 @@ static int perf_event__jit_repipe_mmap2(struct perf_too= l *tool, } #endif =20 -static int perf_event__repipe_buildid_mmap2(struct perf_tool *tool, +static int perf_event__repipe_buildid_mmap2(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -565,7 +565,7 @@ static int perf_event__repipe_buildid_mmap2(struct perf= _tool *tool, return 0; } =20 -static int perf_event__repipe_fork(struct perf_tool *tool, +static int perf_event__repipe_fork(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -578,7 +578,7 @@ static int perf_event__repipe_fork(struct perf_tool *to= ol, return err; } =20 -static int perf_event__repipe_comm(struct perf_tool *tool, +static int perf_event__repipe_comm(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -591,7 +591,7 @@ static int perf_event__repipe_comm(struct perf_tool *to= ol, return err; } =20 -static int perf_event__repipe_namespaces(struct perf_tool *tool, +static int perf_event__repipe_namespaces(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -603,7 +603,7 @@ static int perf_event__repipe_namespaces(struct perf_to= ol *tool, return err; } =20 -static int perf_event__repipe_exit(struct perf_tool *tool, +static int perf_event__repipe_exit(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -712,7 +712,7 @@ static bool perf_inject__lookup_known_build_id(struct p= erf_inject *inject, return false; } =20 -static int dso__inject_build_id(struct dso *dso, struct perf_tool *tool, +static int dso__inject_build_id(struct dso *dso, const struct perf_tool *t= ool, struct machine *machine, u8 cpumode, u32 flags) { struct perf_inject *inject =3D container_of(tool, struct perf_inject, @@ -743,7 +743,7 @@ static int dso__inject_build_id(struct dso *dso, struct= perf_tool *tool, return 0; } =20 -int perf_event__inject_buildid(struct perf_tool *tool, union perf_event *e= vent, +int perf_event__inject_buildid(const struct perf_tool *tool, union perf_ev= ent *event, struct perf_sample *sample, struct evsel *evsel __maybe_unused, struct machine *machine) @@ -776,7 +776,7 @@ int perf_event__inject_buildid(struct perf_tool *tool, = union perf_event *event, return 0; } =20 -static int perf_inject__sched_process_exit(struct perf_tool *tool, +static int perf_inject__sched_process_exit(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel __maybe_unused, @@ -796,7 +796,7 @@ static int perf_inject__sched_process_exit(struct perf_= tool *tool, return 0; } =20 -static int perf_inject__sched_switch(struct perf_tool *tool, +static int perf_inject__sched_switch(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -821,7 +821,7 @@ static int perf_inject__sched_switch(struct perf_tool *= tool, } =20 #ifdef HAVE_LIBTRACEEVENT -static int perf_inject__sched_stat(struct perf_tool *tool, +static int perf_inject__sched_stat(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel, @@ -866,7 +866,7 @@ static int guest_session__output_bytes(struct guest_ses= sion *gs, void *buf, size return ret < 0 ? ret : 0; } =20 -static int guest_session__repipe(struct perf_tool *tool, +static int guest_session__repipe(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -1032,7 +1032,7 @@ static struct guest_id *guest_session__lookup_id(stru= ct guest_session *gs, u64 i return NULL; } =20 -static int process_attr(struct perf_tool *tool, union perf_event *event, +static int process_attr(const struct perf_tool *tool, union perf_event *ev= ent, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) { @@ -1160,7 +1160,7 @@ static u64 evlist__first_id(struct evlist *evlist) return 0; } =20 -static int process_build_id(struct perf_tool *tool, +static int process_build_id(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -1210,7 +1210,7 @@ static int guest_session__add_build_ids(struct guest_= session *gs) gs); } =20 -static int guest_session__ksymbol_event(struct perf_tool *tool, +static int guest_session__ksymbol_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -1574,7 +1574,7 @@ static int guest_session__flush_events(struct guest_s= ession *gs) return guest_session__inject_events(gs, -1); } =20 -static int host__repipe(struct perf_tool *tool, +static int host__repipe(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -1647,7 +1647,7 @@ static int host__finished_init(struct perf_session *s= ession, union perf_event *e * guest events up to the same time. Finally write out the FINISHED_ROUND = event * itself. */ -static int host__finished_round(struct perf_tool *tool, +static int host__finished_round(const struct perf_tool *tool, union perf_event *event, struct ordered_events *oe) { @@ -1665,7 +1665,7 @@ static int host__finished_round(struct perf_tool *too= l, return perf_event__repipe_oe_synth(tool, event, oe); } =20 -static int host__context_switch(struct perf_tool *tool, +static int host__context_switch(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -1719,7 +1719,7 @@ static int evsel__check_stype(struct evsel *evsel, u6= 4 sample_type, const char * return 0; } =20 -static int drop_sample(struct perf_tool *tool __maybe_unused, +static int drop_sample(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct evsel *evsel __maybe_unused, diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 6fd95be5032b..859ff018eace 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -955,7 +955,7 @@ static bool perf_kmem__skip_sample(struct perf_sample *= sample) typedef int (*tracepoint_handler)(struct evsel *evsel, struct perf_sample *sample); =20 -static int process_sample_event(struct perf_tool *tool __maybe_unused, +static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -2061,4 +2061,3 @@ int cmd_kmem(int argc, const char **argv) =20 return ret; } - diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 71165036e4ca..a3b903cf4311 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1166,7 +1166,7 @@ static void print_result(struct perf_kvm_stat *kvm) } =20 #if defined(HAVE_TIMERFD_SUPPORT) && defined(HAVE_LIBTRACEEVENT) -static int process_lost_event(struct perf_tool *tool, +static int process_lost_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -1187,7 +1187,7 @@ static bool skip_sample(struct perf_kvm_stat *kvm, return false; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 56e3f3a5e03a..8ffaa80a2d1d 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -958,7 +958,7 @@ static int top_sched_switch_event(struct perf_kwork *kw= ork, } =20 static struct kwork_class kwork_irq; -static int process_irq_handler_entry_event(struct perf_tool *tool, +static int process_irq_handler_entry_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -971,7 +971,7 @@ static int process_irq_handler_entry_event(struct perf_= tool *tool, return 0; } =20 -static int process_irq_handler_exit_event(struct perf_tool *tool, +static int process_irq_handler_exit_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1037,7 +1037,7 @@ static struct kwork_class kwork_irq =3D { }; =20 static struct kwork_class kwork_softirq; -static int process_softirq_raise_event(struct perf_tool *tool, +static int process_softirq_raise_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1051,7 +1051,7 @@ static int process_softirq_raise_event(struct perf_to= ol *tool, return 0; } =20 -static int process_softirq_entry_event(struct perf_tool *tool, +static int process_softirq_entry_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1065,7 +1065,7 @@ static int process_softirq_entry_event(struct perf_to= ol *tool, return 0; } =20 -static int process_softirq_exit_event(struct perf_tool *tool, +static int process_softirq_exit_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1167,7 +1167,7 @@ static struct kwork_class kwork_softirq =3D { }; =20 static struct kwork_class kwork_workqueue; -static int process_workqueue_activate_work_event(struct perf_tool *tool, +static int process_workqueue_activate_work_event(const struct perf_tool *t= ool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1181,7 +1181,7 @@ static int process_workqueue_activate_work_event(stru= ct perf_tool *tool, return 0; } =20 -static int process_workqueue_execute_start_event(struct perf_tool *tool, +static int process_workqueue_execute_start_event(const struct perf_tool *t= ool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1195,7 +1195,7 @@ static int process_workqueue_execute_start_event(stru= ct perf_tool *tool, return 0; } =20 -static int process_workqueue_execute_end_event(struct perf_tool *tool, +static int process_workqueue_execute_end_event(const struct perf_tool *too= l, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1266,7 +1266,7 @@ static struct kwork_class kwork_workqueue =3D { }; =20 static struct kwork_class kwork_sched; -static int process_sched_switch_event(struct perf_tool *tool, +static int process_sched_switch_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1945,12 +1945,12 @@ static int perf_kwork__report(struct perf_kwork *kw= ork) return 0; } =20 -typedef int (*tracepoint_handler)(struct perf_tool *tool, +typedef int (*tracepoint_handler)(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 -static int perf_kwork__process_tracepoint_sample(struct perf_tool *tool, +static int perf_kwork__process_tracepoint_sample(const struct perf_tool *t= ool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 0253184b3b58..6efa9d646637 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1501,7 +1501,7 @@ static const struct evsel_str_handler contention_trac= epoints[] =3D { { "lock:contention_end", evsel__process_contention_end, }, }; =20 -static int process_event_update(struct perf_tool *tool, +static int process_event_update(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist) { @@ -1520,7 +1520,7 @@ static int process_event_update(struct perf_tool *too= l, typedef int (*tracepoint_handler)(struct evsel *evsel, struct perf_sample *sample); =20 -static int process_sample_event(struct perf_tool *tool __maybe_unused, +static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index 863fcd735dae..c2038a32543c 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -188,7 +188,7 @@ static int __cmd_record(int argc, const char **argv, st= ruct perf_mem *mem) } =20 static int -dump_raw_samples(struct perf_tool *tool, +dump_raw_samples(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -262,7 +262,7 @@ dump_raw_samples(struct perf_tool *tool, return 0; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel __maybe_unused, diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index a94516e8c522..f27f725913d7 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -608,7 +608,7 @@ static int record__comp_enabled(struct record *rec) return rec->opts.comp_level > 0; } =20 -static int process_synthesized_event(struct perf_tool *tool, +static int process_synthesized_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -619,7 +619,7 @@ static int process_synthesized_event(struct perf_tool *= tool, =20 static struct mutex synth_lock; =20 -static int process_locked_synthesized_event(struct perf_tool *tool, +static int process_locked_synthesized_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -704,7 +704,7 @@ static void record__sig_exit(void) =20 #ifdef HAVE_AUXTRACE_SUPPORT =20 -static int record__process_auxtrace(struct perf_tool *tool, +static int record__process_auxtrace(const struct perf_tool *tool, struct mmap *map, union perf_event *event, void *data1, size_t len1, void *data2, size_t len2) @@ -1416,7 +1416,7 @@ static void set_timestamp_boundary(struct record *rec= , u64 sample_time) rec->evlist->last_sample_time =3D sample_time; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -3243,7 +3243,7 @@ static const char * const __record_usage[] =3D { }; const char * const *record_usage =3D __record_usage; =20 -static int build_id__process_mmap(struct perf_tool *tool, union perf_event= *event, +static int build_id__process_mmap(const struct perf_tool *tool, union perf= _event *event, struct perf_sample *sample, struct machine *machine) { /* @@ -3255,7 +3255,7 @@ static int build_id__process_mmap(struct perf_tool *t= ool, union perf_event *even return perf_event__process_mmap(tool, event, sample, machine); } =20 -static int build_id__process_mmap2(struct perf_tool *tool, union perf_even= t *event, +static int build_id__process_mmap2(const struct perf_tool *tool, union per= f_event *event, struct perf_sample *sample, struct machine *machine) { /* @@ -3268,7 +3268,7 @@ static int build_id__process_mmap2(struct perf_tool *= tool, union perf_event *eve return perf_event__process_mmap2(tool, event, sample, machine); } =20 -static int process_timestamp_boundary(struct perf_tool *tool, +static int process_timestamp_boundary(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct machine *machine __maybe_unused) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 6edc0d4ce6fb..c402d9b3dca6 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -263,7 +263,7 @@ static int process_feature_event(struct perf_session *s= ession, return 0; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -339,7 +339,7 @@ static int process_sample_event(struct perf_tool *tool, return ret; } =20 -static int process_read_event(struct perf_tool *tool, +static int process_read_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct evsel *evsel, @@ -765,7 +765,7 @@ static void report__output_resort(struct report *rep) ui_progress__finish(); } =20 -static int count_sample_event(struct perf_tool *tool __maybe_unused, +static int count_sample_event(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct evsel *evsel, @@ -777,7 +777,7 @@ static int count_sample_event(struct perf_tool *tool __= maybe_unused, return 0; } =20 -static int count_lost_samples_event(struct perf_tool *tool, +static int count_lost_samples_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine __maybe_unused) @@ -793,7 +793,7 @@ static int count_lost_samples_event(struct perf_tool *t= ool, return 0; } =20 -static int process_attr(struct perf_tool *tool __maybe_unused, +static int process_attr(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct evlist **pevlist); =20 @@ -1233,7 +1233,7 @@ parse_percent_limit(const struct option *opt, const c= har *str, return 0; } =20 -static int process_attr(struct perf_tool *tool __maybe_unused, +static int process_attr(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct evlist **pevlist) { diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 8750b5f2d49b..2c60bd3a8149 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1489,7 +1489,7 @@ static void perf_sched__sort_lat(struct perf_sched *s= ched) } } =20 -static int process_sched_wakeup_event(struct perf_tool *tool, +static int process_sched_wakeup_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1502,7 +1502,7 @@ static int process_sched_wakeup_event(struct perf_too= l *tool, return 0; } =20 -static int process_sched_wakeup_ignore(struct perf_tool *tool __maybe_unus= ed, +static int process_sched_wakeup_ignore(const struct perf_tool *tool __mayb= e_unused, struct evsel *evsel __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -1770,7 +1770,7 @@ static int map_switch_event(struct perf_sched *sched,= struct evsel *evsel, return 0; } =20 -static int process_sched_switch_event(struct perf_tool *tool, +static int process_sched_switch_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1796,7 +1796,7 @@ static int process_sched_switch_event(struct perf_too= l *tool, return err; } =20 -static int process_sched_runtime_event(struct perf_tool *tool, +static int process_sched_runtime_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1809,7 +1809,7 @@ static int process_sched_runtime_event(struct perf_to= ol *tool, return 0; } =20 -static int perf_sched__process_fork_event(struct perf_tool *tool, +static int perf_sched__process_fork_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -1826,7 +1826,7 @@ static int perf_sched__process_fork_event(struct perf= _tool *tool, return 0; } =20 -static int process_sched_migrate_task_event(struct perf_tool *tool, +static int process_sched_migrate_task_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1839,12 +1839,12 @@ static int process_sched_migrate_task_event(struct = perf_tool *tool, return 0; } =20 -typedef int (*tracepoint_handler)(struct perf_tool *tool, +typedef int (*tracepoint_handler)(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 -static int perf_sched__process_tracepoint_sample(struct perf_tool *tool __= maybe_unused, +static int perf_sched__process_tracepoint_sample(const struct perf_tool *t= ool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel, @@ -1860,7 +1860,7 @@ static int perf_sched__process_tracepoint_sample(stru= ct perf_tool *tool __maybe_ return err; } =20 -static int perf_sched__process_comm(struct perf_tool *tool __maybe_unused, +static int perf_sched__process_comm(const struct perf_tool *tool __maybe_u= nused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2506,7 +2506,7 @@ static void timehist_print_wakeup_event(struct perf_s= ched *sched, printf("\n"); } =20 -static int timehist_sched_wakeup_ignore(struct perf_tool *tool __maybe_unu= sed, +static int timehist_sched_wakeup_ignore(const struct perf_tool *tool __may= be_unused, union perf_event *event __maybe_unused, struct evsel *evsel __maybe_unused, struct perf_sample *sample __maybe_unused, @@ -2515,7 +2515,7 @@ static int timehist_sched_wakeup_ignore(struct perf_t= ool *tool __maybe_unused, return 0; } =20 -static int timehist_sched_wakeup_event(struct perf_tool *tool, +static int timehist_sched_wakeup_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct evsel *evsel, struct perf_sample *sample, @@ -2599,7 +2599,7 @@ static void timehist_print_migration_event(struct per= f_sched *sched, printf("\n"); } =20 -static int timehist_migrate_task_event(struct perf_tool *tool, +static int timehist_migrate_task_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct evsel *evsel, struct perf_sample *sample, @@ -2627,7 +2627,7 @@ static int timehist_migrate_task_event(struct perf_to= ol *tool, return 0; } =20 -static int timehist_sched_change_event(struct perf_tool *tool, +static int timehist_sched_change_event(const struct perf_tool *tool, union perf_event *event, struct evsel *evsel, struct perf_sample *sample, @@ -2758,7 +2758,7 @@ static int timehist_sched_change_event(struct perf_to= ol *tool, return rc; } =20 -static int timehist_sched_switch_event(struct perf_tool *tool, +static int timehist_sched_switch_event(const struct perf_tool *tool, union perf_event *event, struct evsel *evsel, struct perf_sample *sample, @@ -2767,7 +2767,7 @@ static int timehist_sched_switch_event(struct perf_to= ol *tool, return timehist_sched_change_event(tool, event, evsel, sample, machine); } =20 -static int process_lost(struct perf_tool *tool __maybe_unused, +static int process_lost(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine __maybe_unused) @@ -3010,13 +3010,13 @@ static void timehist_print_summary(struct perf_sche= d *sched, printf(" (x %d)\n", sched->max_cpu.cpu); } =20 -typedef int (*sched_handler)(struct perf_tool *tool, +typedef int (*sched_handler)(const struct perf_tool *tool, union perf_event *event, struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 -static int perf_timehist__process_sample(struct perf_tool *tool, +static int perf_timehist__process_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index c16224b1fef3..394bce9f5338 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2399,7 +2399,7 @@ static bool filter_cpu(struct perf_sample *sample) return false; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -2486,7 +2486,7 @@ static int process_sample_event(struct perf_tool *too= l, // Used when scr->per_event_dump is not set static struct evsel_script es_stdout; =20 -static int process_attr(struct perf_tool *tool, union perf_event *event, +static int process_attr(const struct perf_tool *tool, union perf_event *ev= ent, struct evlist **pevlist) { struct perf_script *scr =3D container_of(tool, struct perf_script, tool); @@ -2552,7 +2552,7 @@ static int process_attr(struct perf_tool *tool, union= perf_event *event, return 0; } =20 -static int print_event_with_time(struct perf_tool *tool, +static int print_event_with_time(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine, @@ -2588,14 +2588,14 @@ static int print_event_with_time(struct perf_tool *= tool, return 0; } =20 -static int print_event(struct perf_tool *tool, union perf_event *event, +static int print_event(const struct perf_tool *tool, union perf_event *eve= nt, struct perf_sample *sample, struct machine *machine, pid_t pid, pid_t tid) { return print_event_with_time(tool, event, sample, machine, pid, tid, 0); } =20 -static int process_comm_event(struct perf_tool *tool, +static int process_comm_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2607,7 +2607,7 @@ static int process_comm_event(struct perf_tool *tool, event->comm.tid); } =20 -static int process_namespaces_event(struct perf_tool *tool, +static int process_namespaces_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2619,7 +2619,7 @@ static int process_namespaces_event(struct perf_tool = *tool, event->namespaces.tid); } =20 -static int process_cgroup_event(struct perf_tool *tool, +static int process_cgroup_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2631,7 +2631,7 @@ static int process_cgroup_event(struct perf_tool *too= l, sample->tid); } =20 -static int process_fork_event(struct perf_tool *tool, +static int process_fork_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2643,7 +2643,7 @@ static int process_fork_event(struct perf_tool *tool, event->fork.pid, event->fork.tid, event->fork.time); } -static int process_exit_event(struct perf_tool *tool, +static int process_exit_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2656,7 +2656,7 @@ static int process_exit_event(struct perf_tool *tool, return perf_event__process_exit(tool, event, sample, machine); } =20 -static int process_mmap_event(struct perf_tool *tool, +static int process_mmap_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2668,7 +2668,7 @@ static int process_mmap_event(struct perf_tool *tool, event->mmap.tid); } =20 -static int process_mmap2_event(struct perf_tool *tool, +static int process_mmap2_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2680,7 +2680,7 @@ static int process_mmap2_event(struct perf_tool *tool, event->mmap2.tid); } =20 -static int process_switch_event(struct perf_tool *tool, +static int process_switch_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2712,7 +2712,7 @@ static int process_auxtrace_error(struct perf_session= *session, } =20 static int -process_lost_event(struct perf_tool *tool, +process_lost_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2722,7 +2722,7 @@ process_lost_event(struct perf_tool *tool, } =20 static int -process_throttle_event(struct perf_tool *tool __maybe_unused, +process_throttle_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2733,7 +2733,7 @@ process_throttle_event(struct perf_tool *tool __maybe= _unused, } =20 static int -process_finished_round_event(struct perf_tool *tool __maybe_unused, +process_finished_round_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct ordered_events *oe __maybe_unused) =20 @@ -2743,7 +2743,7 @@ process_finished_round_event(struct perf_tool *tool _= _maybe_unused, } =20 static int -process_bpf_events(struct perf_tool *tool __maybe_unused, +process_bpf_events(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2755,7 +2755,7 @@ process_bpf_events(struct perf_tool *tool __maybe_unu= sed, sample->tid); } =20 -static int process_text_poke_events(struct perf_tool *tool, +static int process_text_poke_events(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -3757,7 +3757,7 @@ static int process_thread_map_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_script *script =3D container_of(tool, struct perf_script, too= l); =20 if (dump_trace) @@ -3779,7 +3779,7 @@ static int process_cpu_map_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_script *script =3D container_of(tool, struct perf_script, too= l); =20 if (dump_trace) @@ -3809,11 +3809,10 @@ static int process_feature_event(struct perf_sessio= n *session, static int perf_script__process_auxtrace_info(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; - int ret =3D perf_event__process_auxtrace_info(session, event); =20 if (ret =3D=3D 0) { + const struct perf_tool *tool =3D session->tool; struct perf_script *script =3D container_of(tool, struct perf_script, to= ol); =20 ret =3D perf_script__setup_per_event_dump(script); diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 661832756a24..d460c46f15fd 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -248,7 +248,7 @@ static void perf_stat__reset_stats(void) perf_stat__reset_shadow_stats(); } =20 -static int process_synthesized_event(struct perf_tool *tool __maybe_unused, +static int process_synthesized_event(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -2180,7 +2180,7 @@ static int process_stat_config_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_stat *st =3D container_of(tool, struct perf_stat, tool); =20 perf_event__read_stat_config(&stat_config, &event->stat_config); @@ -2229,7 +2229,7 @@ static int process_thread_map_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_stat *st =3D container_of(tool, struct perf_stat, tool); =20 if (st->threads) { @@ -2248,7 +2248,7 @@ static int process_cpu_map_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_stat *st =3D container_of(tool, struct perf_stat, tool); struct perf_cpu_map *cpus; =20 diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 19d4542ea18a..5bf818baa662 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -320,7 +320,7 @@ static int *cpus_cstate_state; static u64 *cpus_pstate_start_times; static u64 *cpus_pstate_state; =20 -static int process_comm_event(struct perf_tool *tool, +static int process_comm_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -330,7 +330,7 @@ static int process_comm_event(struct perf_tool *tool, return 0; } =20 -static int process_fork_event(struct perf_tool *tool, +static int process_fork_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -340,7 +340,7 @@ static int process_fork_event(struct perf_tool *tool, return 0; } =20 -static int process_exit_event(struct perf_tool *tool, +static int process_exit_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -571,7 +571,7 @@ typedef int (*tracepoint_handler)(struct timechart *tch= art, struct perf_sample *sample, const char *backtrace); =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index e8cbbf10d361..d6fcc6c122da 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -740,7 +740,7 @@ static int hist_iter__top_callback(struct hist_entry_it= er *iter, return 0; } =20 -static void perf_event__process_sample(struct perf_tool *tool, +static void perf_event__process_sample(const struct perf_tool *tool, const union perf_event *event, struct evsel *evsel, struct perf_sample *sample, diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index a547ccfa92c9..e39469808ef5 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1637,7 +1637,7 @@ static int trace__process_event(struct trace *trace, = struct machine *machine, return ret; } =20 -static int trace__tool_process(struct perf_tool *tool, +static int trace__tool_process(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -3009,7 +3009,7 @@ static void trace__set_base_time(struct trace *trace, trace->base_time =3D sample->time; } =20 -static int trace__process_sample(struct perf_tool *tool, +static int trace__process_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c index bd8e396f3e57..2f0168b2a5a9 100644 --- a/tools/perf/tests/cpumap.c +++ b/tools/perf/tests/cpumap.c @@ -11,7 +11,7 @@ =20 struct machine; =20 -static int process_event_mask(struct perf_tool *tool __maybe_unused, +static int process_event_mask(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -47,7 +47,7 @@ static int process_event_mask(struct perf_tool *tool __ma= ybe_unused, return 0; } =20 -static int process_event_cpus(struct perf_tool *tool __maybe_unused, +static int process_event_cpus(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -73,7 +73,7 @@ static int process_event_cpus(struct perf_tool *tool __ma= ybe_unused, return 0; } =20 -static int process_event_range_cpus(struct perf_tool *tool __maybe_unused, +static int process_event_range_cpus(const struct perf_tool *tool __maybe_u= nused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/tests/dlfilter-test.c b/tools/perf/tests/dlfilter-t= est.c index da3a9b50b1b1..54f59d1246bc 100644 --- a/tools/perf/tests/dlfilter-test.c +++ b/tools/perf/tests/dlfilter-test.c @@ -62,7 +62,7 @@ static int test_result(const char *msg, int ret) return ret; } =20 -static int process(struct perf_tool *tool, union perf_event *event, +static int process(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) { diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwin= d.c index d01aa931fe81..f85d391ced98 100644 --- a/tools/perf/tests/dwarf-unwind.c +++ b/tools/perf/tests/dwarf-unwind.c @@ -37,7 +37,7 @@ #define NO_TAIL_CALL_BARRIER __asm__ __volatile__("" : : : "memory"); #endif =20 -static int mmap_handler(struct perf_tool *tool __maybe_unused, +static int mmap_handler(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_updat= e.c index d093a9b878d1..fdecad920f59 100644 --- a/tools/perf/tests/event_update.c +++ b/tools/perf/tests/event_update.c @@ -12,7 +12,7 @@ #include "tests.h" #include "debug.h" =20 -static int process_event_unit(struct perf_tool *tool __maybe_unused, +static int process_event_unit(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -25,7 +25,7 @@ static int process_event_unit(struct perf_tool *tool __ma= ybe_unused, return 0; } =20 -static int process_event_scale(struct perf_tool *tool __maybe_unused, +static int process_event_scale(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -43,7 +43,7 @@ struct event_name { const char *name; }; =20 -static int process_event_name(struct perf_tool *tool, +static int process_event_name(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -57,7 +57,7 @@ static int process_event_name(struct perf_tool *tool, return 0; } =20 -static int process_event_cpus(struct perf_tool *tool __maybe_unused, +static int process_event_cpus(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/tests/stat.c b/tools/perf/tests/stat.c index 706780fb5695..6468cc0d0204 100644 --- a/tools/perf/tests/stat.c +++ b/tools/perf/tests/stat.c @@ -21,7 +21,7 @@ static bool has_term(struct perf_record_stat_config *conf= ig, return false; } =20 -static int process_stat_config_event(struct perf_tool *tool __maybe_unused, +static int process_stat_config_event(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -62,7 +62,7 @@ static int test__synthesize_stat_config(struct test_suite= *test __maybe_unused, return 0; } =20 -static int process_stat_event(struct perf_tool *tool __maybe_unused, +static int process_stat_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -93,7 +93,7 @@ static int test__synthesize_stat(struct test_suite *test = __maybe_unused, int sub return 0; } =20 -static int process_stat_round_event(struct perf_tool *tool __maybe_unused, +static int process_stat_round_event(const struct perf_tool *tool __maybe_u= nused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c index 74308c1368fe..1fe521466bf4 100644 --- a/tools/perf/tests/thread-map.c +++ b/tools/perf/tests/thread-map.c @@ -60,7 +60,7 @@ static int test__thread_map(struct test_suite *test __may= be_unused, int subtest return 0; } =20 -static int process_event(struct perf_tool *tool __maybe_unused, +static int process_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index fa40f3cb6266..138ffc71b32d 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -899,7 +899,7 @@ static int arm_spe_context_switch(struct arm_spe *spe, = union perf_event *event, static int arm_spe_process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { int err =3D 0; u64 timestamp; @@ -947,7 +947,7 @@ static int arm_spe_process_event(struct perf_session *s= ession, =20 static int arm_spe_process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct arm_spe *spe =3D container_of(session->auxtrace, struct arm_spe, auxtrace); @@ -985,7 +985,7 @@ static int arm_spe_process_auxtrace_event(struct perf_s= ession *session, } =20 static int arm_spe_flush(struct perf_session *session __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct arm_spe *spe =3D container_of(session->auxtrace, struct arm_spe, auxtrace); diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index e2f317063eec..cbb773ed6f1a 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -1240,7 +1240,7 @@ void auxtrace_synth_error(struct perf_record_auxtrace= _error *auxtrace_error, int } =20 int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, - struct perf_tool *tool, + const struct perf_tool *tool, struct perf_session *session, perf_event__handler_t process) { @@ -1831,7 +1831,7 @@ int __weak compat_auxtrace_mmap__write_tail(struct au= xtrace_mmap *mm, u64 tail) =20 static int __auxtrace_mmap__read(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn, + const struct perf_tool *tool, process_auxtrace_t fn, bool snapshot, size_t snapshot_size) { struct auxtrace_mmap *mm =3D &map->auxtrace_mmap; @@ -1942,14 +1942,14 @@ static int __auxtrace_mmap__read(struct mmap *map, } =20 int auxtrace_mmap__read(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn) + const struct perf_tool *tool, process_auxtrace_t fn) { return __auxtrace_mmap__read(map, itr, tool, fn, false, 0); } =20 int auxtrace_mmap__read_snapshot(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn, + const struct perf_tool *tool, process_auxtrace_t fn, size_t snapshot_size) { return __auxtrace_mmap__read(map, itr, tool, fn, true, snapshot_size); @@ -2829,7 +2829,7 @@ int auxtrace_parse_filters(struct evlist *evlist) } =20 int auxtrace__process_event(struct perf_session *session, union perf_event= *event, - struct perf_sample *sample, struct perf_tool *tool) + struct perf_sample *sample, const struct perf_tool *tool) { if (!session->auxtrace) return 0; @@ -2847,7 +2847,7 @@ void auxtrace__dump_auxtrace_sample(struct perf_sessi= on *session, session->auxtrace->dump_auxtrace_sample(session, sample); } =20 -int auxtrace__flush_events(struct perf_session *session, struct perf_tool = *tool) +int auxtrace__flush_events(struct perf_session *session, const struct perf= _tool *tool) { if (!session->auxtrace) return 0; diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 8a6ec9565835..d405efcd8708 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -208,17 +208,17 @@ struct auxtrace { int (*process_event)(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool); + const struct perf_tool *tool); int (*process_auxtrace_event)(struct perf_session *session, union perf_event *event, - struct perf_tool *tool); + const struct perf_tool *tool); int (*queue_data)(struct perf_session *session, struct perf_sample *sample, union perf_event *event, u64 data_offset); void (*dump_auxtrace_sample)(struct perf_session *session, struct perf_sample *sample); int (*flush_events)(struct perf_session *session, - struct perf_tool *tool); + const struct perf_tool *tool); void (*free_events)(struct perf_session *session); void (*free)(struct perf_session *session); bool (*evsel_is_auxtrace)(struct perf_session *session, @@ -508,17 +508,17 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mm= ap_params *mp, struct evlist *evlist, struct evsel *evsel, int idx); =20 -typedef int (*process_auxtrace_t)(struct perf_tool *tool, +typedef int (*process_auxtrace_t)(const struct perf_tool *tool, struct mmap *map, union perf_event *event, void *data1, size_t len1, void *data2, size_t len2); =20 int auxtrace_mmap__read(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn); + const struct perf_tool *tool, process_auxtrace_t fn); =20 int auxtrace_mmap__read_snapshot(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn, + const struct perf_tool *tool, process_auxtrace_t fn, size_t snapshot_size); =20 int auxtrace_queues__init_nr(struct auxtrace_queues *queues, int nr_queues= ); @@ -639,10 +639,10 @@ int addr_filters__parse_bare_filter(struct addr_filte= rs *filts, int auxtrace_parse_filters(struct evlist *evlist); =20 int auxtrace__process_event(struct perf_session *session, union perf_event= *event, - struct perf_sample *sample, struct perf_tool *tool); + struct perf_sample *sample, const struct perf_tool *tool); void auxtrace__dump_auxtrace_sample(struct perf_session *session, struct perf_sample *sample); -int auxtrace__flush_events(struct perf_session *session, struct perf_tool = *tool); +int auxtrace__flush_events(struct perf_session *session, const struct perf= _tool *tool); void auxtrace__free_events(struct perf_session *session); void auxtrace__free(struct perf_session *session); bool auxtrace__evsel_is_auxtrace(struct perf_session *session, @@ -809,7 +809,7 @@ static inline int auxtrace__process_event(struct perf_session *session __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } @@ -822,7 +822,7 @@ void auxtrace__dump_auxtrace_sample(struct perf_session= *session __maybe_unused, =20 static inline int auxtrace__flush_events(struct perf_session *session __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c index 827695cd0408..13608237c50e 100644 --- a/tools/perf/util/bpf-event.c +++ b/tools/perf/util/bpf-event.c @@ -170,7 +170,7 @@ static int perf_event__synthesize_one_bpf_prog(struct p= erf_session *session, { struct perf_record_ksymbol *ksymbol_event =3D &event->ksymbol; struct perf_record_bpf_event *bpf_event =3D &event->bpf; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct bpf_prog_info_node *info_node; struct perf_bpil *info_linear; struct bpf_prog_info *info; @@ -310,7 +310,7 @@ struct kallsyms_parse { union perf_event *event; perf_event__handler_t process; struct machine *machine; - struct perf_tool *tool; + const struct perf_tool *tool; }; =20 static int diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 83a1581e8cf1..098fcc625d91 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -42,7 +42,7 @@ =20 static bool no_buildid_cache; =20 -int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused, +int build_id__mark_dso_hit(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct evsel *evsel __maybe_unused, @@ -67,7 +67,7 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe= _unused, return 0; } =20 -static int perf_event__exit_del_thread(struct perf_tool *tool __maybe_unus= ed, +static int perf_event__exit_del_thread(const struct perf_tool *tool __mayb= e_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index 3fa8bffb07ca..ae87c4c58d5b 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -35,11 +35,11 @@ char *dso__build_id_filename(const struct dso *dso, cha= r *bf, size_t size, char *__dso__build_id_filename(const struct dso *dso, char *bf, size_t siz= e, bool is_debug, bool is_kallsyms); =20 -int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, +int build_id__mark_dso_hit(const struct perf_tool *tool, union perf_event = *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine); =20 -int perf_event__inject_buildid(struct perf_tool *tool, union perf_event *e= vent, +int perf_event__inject_buildid(const struct perf_tool *tool, union perf_ev= ent *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine); =20 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 7fd976ea954b..21023d2a58ee 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -788,7 +788,7 @@ static void cs_etm__dump_event(struct cs_etm_queue *etm= q, } =20 static int cs_etm__flush_events(struct perf_session *session, - struct perf_tool *tool) + const struct perf_tool *tool) { struct cs_etm_auxtrace *etm =3D container_of(session->auxtrace, struct cs_etm_auxtrace, @@ -2711,7 +2711,7 @@ static int cs_etm__process_switch_cpu_wide(struct cs_= etm_auxtrace *etm, static int cs_etm__process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { struct cs_etm_auxtrace *etm =3D container_of(session->auxtrace, struct cs_etm_auxtrace, @@ -2781,7 +2781,7 @@ static void dump_queued_data(struct cs_etm_auxtrace *= etm, =20 static int cs_etm__process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct cs_etm_auxtrace *etm =3D container_of(session->auxtrace, struct cs_etm_auxtrace, diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-conve= rt-bt.c index 2b732bccabad..9e2170604b66 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -792,7 +792,7 @@ static bool is_flush_needed(struct ctf_stream *cs) return cs->count >=3D STREAM_FLUSH_COUNT; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *_event, struct perf_sample *sample, struct evsel *evsel, @@ -871,7 +871,7 @@ do { \ } while(0) =20 #define __FUNC_PROCESS_NON_SAMPLE(_name, body) \ -static int process_##_name##_event(struct perf_tool *tool, \ +static int process_##_name##_event(const struct perf_tool *tool, \ union perf_event *_event, \ struct perf_sample *sample, \ struct machine *machine) \ diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-con= vert-json.c index 3cf64f5b23ee..905ea9823f9d 100644 --- a/tools/perf/util/data-convert-json.c +++ b/tools/perf/util/data-convert-json.c @@ -118,7 +118,7 @@ static void output_json_key_format(FILE *out, bool comm= a, int depth, va_end(args); } =20 -static void output_sample_callchain_entry(struct perf_tool *tool, +static void output_sample_callchain_entry(const struct perf_tool *tool, u64 ip, struct addr_location *al) { struct convert_json *c =3D container_of(tool, struct convert_json, tool); @@ -146,7 +146,7 @@ static void output_sample_callchain_entry(struct perf_t= ool *tool, output_json_format(out, false, 4, "}"); } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel __maybe_unused, diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index f32f9abf6344..c2f0e7f40ad5 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -216,7 +216,7 @@ size_t perf_event__fprintf_cgroup(union perf_event *eve= nt, FILE *fp) event->cgroup.id, event->cgroup.path); } =20 -int perf_event__process_comm(struct perf_tool *tool __maybe_unused, +int perf_event__process_comm(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -224,7 +224,7 @@ int perf_event__process_comm(struct perf_tool *tool __m= aybe_unused, return machine__process_comm_event(machine, event, sample); } =20 -int perf_event__process_namespaces(struct perf_tool *tool __maybe_unused, +int perf_event__process_namespaces(const struct perf_tool *tool __maybe_un= used, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -232,7 +232,7 @@ int perf_event__process_namespaces(struct perf_tool *to= ol __maybe_unused, return machine__process_namespaces_event(machine, event, sample); } =20 -int perf_event__process_cgroup(struct perf_tool *tool __maybe_unused, +int perf_event__process_cgroup(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -240,7 +240,7 @@ int perf_event__process_cgroup(struct perf_tool *tool _= _maybe_unused, return machine__process_cgroup_event(machine, event, sample); } =20 -int perf_event__process_lost(struct perf_tool *tool __maybe_unused, +int perf_event__process_lost(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -248,7 +248,7 @@ int perf_event__process_lost(struct perf_tool *tool __m= aybe_unused, return machine__process_lost_event(machine, event, sample); } =20 -int perf_event__process_aux(struct perf_tool *tool __maybe_unused, +int perf_event__process_aux(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -256,7 +256,7 @@ int perf_event__process_aux(struct perf_tool *tool __ma= ybe_unused, return machine__process_aux_event(machine, event); } =20 -int perf_event__process_itrace_start(struct perf_tool *tool __maybe_unused, +int perf_event__process_itrace_start(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -264,7 +264,7 @@ int perf_event__process_itrace_start(struct perf_tool *= tool __maybe_unused, return machine__process_itrace_start_event(machine, event); } =20 -int perf_event__process_aux_output_hw_id(struct perf_tool *tool __maybe_un= used, +int perf_event__process_aux_output_hw_id(const struct perf_tool *tool __ma= ybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -272,7 +272,7 @@ int perf_event__process_aux_output_hw_id(struct perf_to= ol *tool __maybe_unused, return machine__process_aux_output_hw_id_event(machine, event); } =20 -int perf_event__process_lost_samples(struct perf_tool *tool __maybe_unused, +int perf_event__process_lost_samples(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -280,7 +280,7 @@ int perf_event__process_lost_samples(struct perf_tool *= tool __maybe_unused, return machine__process_lost_samples_event(machine, event, sample); } =20 -int perf_event__process_switch(struct perf_tool *tool __maybe_unused, +int perf_event__process_switch(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -288,7 +288,7 @@ int perf_event__process_switch(struct perf_tool *tool _= _maybe_unused, return machine__process_switch_event(machine, event); } =20 -int perf_event__process_ksymbol(struct perf_tool *tool __maybe_unused, +int perf_event__process_ksymbol(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -296,7 +296,7 @@ int perf_event__process_ksymbol(struct perf_tool *tool = __maybe_unused, return machine__process_ksymbol(machine, event, sample); } =20 -int perf_event__process_bpf(struct perf_tool *tool __maybe_unused, +int perf_event__process_bpf(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -304,7 +304,7 @@ int perf_event__process_bpf(struct perf_tool *tool __ma= ybe_unused, return machine__process_bpf(machine, event, sample); } =20 -int perf_event__process_text_poke(struct perf_tool *tool __maybe_unused, +int perf_event__process_text_poke(const struct perf_tool *tool __maybe_unu= sed, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -387,7 +387,7 @@ size_t perf_event__fprintf_cpu_map(union perf_event *ev= ent, FILE *fp) return ret; } =20 -int perf_event__process_mmap(struct perf_tool *tool __maybe_unused, +int perf_event__process_mmap(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -395,7 +395,7 @@ int perf_event__process_mmap(struct perf_tool *tool __m= aybe_unused, return machine__process_mmap_event(machine, event, sample); } =20 -int perf_event__process_mmap2(struct perf_tool *tool __maybe_unused, +int perf_event__process_mmap2(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -410,7 +410,7 @@ size_t perf_event__fprintf_task(union perf_event *event= , FILE *fp) event->fork.ppid, event->fork.ptid); } =20 -int perf_event__process_fork(struct perf_tool *tool __maybe_unused, +int perf_event__process_fork(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -418,7 +418,7 @@ int perf_event__process_fork(struct perf_tool *tool __m= aybe_unused, return machine__process_fork_event(machine, event, sample); } =20 -int perf_event__process_exit(struct perf_tool *tool __maybe_unused, +int perf_event__process_exit(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -587,7 +587,7 @@ size_t perf_event__fprintf(union perf_event *event, str= uct machine *machine, FIL return ret; } =20 -int perf_event__process(struct perf_tool *tool __maybe_unused, +int perf_event__process(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index d8bcee2e9b93..4b24f1c580fd 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -267,71 +267,71 @@ struct perf_tool; void perf_event__read_stat_config(struct perf_stat_config *config, struct perf_record_stat_config *event); =20 -int perf_event__process_comm(struct perf_tool *tool, +int perf_event__process_comm(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_lost(struct perf_tool *tool, +int perf_event__process_lost(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_lost_samples(struct perf_tool *tool, +int perf_event__process_lost_samples(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_aux(struct perf_tool *tool, +int perf_event__process_aux(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_itrace_start(struct perf_tool *tool, +int perf_event__process_itrace_start(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_aux_output_hw_id(struct perf_tool *tool, +int perf_event__process_aux_output_hw_id(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_switch(struct perf_tool *tool, +int perf_event__process_switch(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_namespaces(struct perf_tool *tool, +int perf_event__process_namespaces(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_cgroup(struct perf_tool *tool, +int perf_event__process_cgroup(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_mmap(struct perf_tool *tool, +int perf_event__process_mmap(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_mmap2(struct perf_tool *tool, +int perf_event__process_mmap2(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_fork(struct perf_tool *tool, +int perf_event__process_fork(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_exit(struct perf_tool *tool, +int perf_event__process_exit(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_ksymbol(struct perf_tool *tool, +int perf_event__process_ksymbol(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_bpf(struct perf_tool *tool, +int perf_event__process_bpf(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_text_poke(struct perf_tool *tool, +int perf_event__process_text_poke(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process(struct perf_tool *tool, +int perf_event__process(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 55e9553861d0..3309fe7f1d12 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -4326,7 +4326,7 @@ int perf_session__read_header(struct perf_session *se= ssion, int repipe_fd) int perf_event__process_feature(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct feat_fd ff =3D { .fd =3D 0 }; struct perf_record_header_feature *fe =3D (struct perf_record_header_feat= ure *)event; int type =3D fe->header.type; @@ -4405,7 +4405,7 @@ size_t perf_event__fprintf_event_update(union perf_ev= ent *event, FILE *fp) return ret; } =20 -int perf_event__process_attr(struct perf_tool *tool __maybe_unused, +int perf_event__process_attr(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct evlist **pevlist) { @@ -4444,7 +4444,7 @@ int perf_event__process_attr(struct perf_tool *tool _= _maybe_unused, return 0; } =20 -int perf_event__process_event_update(struct perf_tool *tool __maybe_unused, +int perf_event__process_event_update(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct evlist **pevlist) { diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index 7c16a250e738..07ff647197ff 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h @@ -156,9 +156,9 @@ int perf_header__fprintf_info(struct perf_session *s, F= ILE *fp, bool full); =20 int perf_event__process_feature(struct perf_session *session, union perf_event *event); -int perf_event__process_attr(struct perf_tool *tool, union perf_event *eve= nt, +int perf_event__process_attr(const struct perf_tool *tool, union perf_even= t *event, struct evlist **pevlist); -int perf_event__process_event_update(struct perf_tool *tool, +int perf_event__process_event_update(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist); size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp); diff --git a/tools/perf/util/hisi-ptt.c b/tools/perf/util/hisi-ptt.c index 37ea987017f6..e4cc4785f744 100644 --- a/tools/perf/util/hisi-ptt.c +++ b/tools/perf/util/hisi-ptt.c @@ -79,14 +79,14 @@ static void hisi_ptt_dump_event(struct hisi_ptt *ptt, u= nsigned char *buf, static int hisi_ptt_process_event(struct perf_session *session __maybe_unu= sed, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } =20 static int hisi_ptt_process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct hisi_ptt *ptt =3D container_of(session->auxtrace, struct hisi_ptt, auxtrace); @@ -123,7 +123,7 @@ static int hisi_ptt_process_auxtrace_event(struct perf_= session *session, } =20 static int hisi_ptt_flush(struct perf_session *session __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index 160d346cb450..27d9b5c9fec8 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -591,7 +591,7 @@ static int intel_bts_process_queues(struct intel_bts *b= ts, u64 timestamp) static int intel_bts_process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { struct intel_bts *bts =3D container_of(session->auxtrace, struct intel_bt= s, auxtrace); @@ -634,7 +634,7 @@ static int intel_bts_process_event(struct perf_session = *session, =20 static int intel_bts_process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct intel_bts *bts =3D container_of(session->auxtrace, struct intel_bt= s, auxtrace); @@ -675,7 +675,7 @@ static int intel_bts_process_auxtrace_event(struct perf= _session *session, } =20 static int intel_bts_flush(struct perf_session *session, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct intel_bts *bts =3D container_of(session->auxtrace, struct intel_bt= s, auxtrace); diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index 1fc03bfd14c3..fd2597613f3d 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -3449,7 +3449,7 @@ static int intel_pt_text_poke(struct intel_pt *pt, un= ion perf_event *event) static int intel_pt_process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { struct intel_pt *pt =3D container_of(session->auxtrace, struct intel_pt, auxtrace); @@ -3533,7 +3533,7 @@ static int intel_pt_process_event(struct perf_session= *session, return err; } =20 -static int intel_pt_flush(struct perf_session *session, struct perf_tool *= tool) +static int intel_pt_flush(struct perf_session *session, const struct perf_= tool *tool) { struct intel_pt *pt =3D container_of(session->auxtrace, struct intel_pt, auxtrace); @@ -3600,7 +3600,7 @@ static bool intel_pt_evsel_is_auxtrace(struct perf_se= ssion *session, =20 static int intel_pt_process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct intel_pt *pt =3D container_of(session->auxtrace, struct intel_pt, auxtrace); diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index 1f657ef8975f..5ce13653512b 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c @@ -424,7 +424,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd= , union jr_entry *jr) { struct perf_sample sample; union perf_event *event; - struct perf_tool *tool =3D jd->session->tool; + const struct perf_tool *tool =3D jd->session->tool; uint64_t code, addr; uintptr_t uaddr; char *filename; @@ -543,7 +543,7 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd= , union jr_entry *jr) { struct perf_sample sample; union perf_event *event; - struct perf_tool *tool =3D jd->session->tool; + const struct perf_tool *tool =3D jd->session->tool; char *filename; size_t size; struct stat st; diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index 4ec583e511af..73846b73d0cf 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -912,7 +912,7 @@ static int s390_cpumsf_process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { struct s390_cpumsf *sf =3D container_of(session->auxtrace, struct s390_cpumsf, @@ -955,7 +955,7 @@ s390_cpumsf_process_event(struct perf_session *session, static int s390_cpumsf_process_auxtrace_event(struct perf_session *session, union perf_event *event __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct s390_cpumsf *sf =3D container_of(session->auxtrace, struct s390_cpumsf, @@ -998,7 +998,7 @@ static void s390_cpumsf_free_events(struct perf_session= *session __maybe_unused) } =20 static int s390_cpumsf_flush(struct perf_session *session __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 18a8f4a84045..7e9827e61d1b 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -102,7 +102,7 @@ static int perf_session__process_compressed_event(struc= t perf_session *session, =20 static int perf_session__deliver_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool, + const struct perf_tool *tool, u64 file_offset, const char *file_path); =20 @@ -328,7 +328,7 @@ static int process_event_synth_tracing_data_stub(struct= perf_session *session return 0; } =20 -static int process_event_synth_attr_stub(struct perf_tool *tool __maybe_un= used, +static int process_event_synth_attr_stub(const struct perf_tool *tool __ma= ybe_unused, union perf_event *event __maybe_unused, struct evlist **pevlist __maybe_unused) @@ -337,7 +337,7 @@ static int process_event_synth_attr_stub(struct perf_to= ol *tool __maybe_unused, return 0; } =20 -static int process_event_synth_event_update_stub(struct perf_tool *tool __= maybe_unused, +static int process_event_synth_event_update_stub(const struct perf_tool *t= ool __maybe_unused, union perf_event *event __maybe_unused, struct evlist **pevlist __maybe_unused) @@ -349,7 +349,7 @@ static int process_event_synth_event_update_stub(struct= perf_tool *tool __maybe_ return 0; } =20 -static int process_event_sample_stub(struct perf_tool *tool __maybe_unused, +static int process_event_sample_stub(const struct perf_tool *tool __maybe_= unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct evsel *evsel __maybe_unused, @@ -359,7 +359,7 @@ static int process_event_sample_stub(struct perf_tool *= tool __maybe_unused, return 0; } =20 -static int process_event_stub(struct perf_tool *tool __maybe_unused, +static int process_event_stub(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -368,7 +368,7 @@ static int process_event_stub(struct perf_tool *tool __= maybe_unused, return 0; } =20 -static int process_finished_round_stub(struct perf_tool *tool __maybe_unus= ed, +static int process_finished_round_stub(const struct perf_tool *tool __mayb= e_unused, union perf_event *event __maybe_unused, struct ordered_events *oe __maybe_unused) { @@ -1076,7 +1076,7 @@ static perf_event__swap_op perf_event__swap_ops[] =3D= { * Flush every events below timestamp 7 * etc... */ -int perf_event__process_finished_round(struct perf_tool *tool __maybe_unus= ed, +int perf_event__process_finished_round(const struct perf_tool *tool __mayb= e_unused, union perf_event *event __maybe_unused, struct ordered_events *oe) { @@ -1470,7 +1470,7 @@ static struct machine *machines__find_for_cpumode(str= uct machines *machines, } =20 static int deliver_sample_value(struct evlist *evlist, - struct perf_tool *tool, + const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct sample_read_value *v, @@ -1502,7 +1502,7 @@ static int deliver_sample_value(struct evlist *evlist, } =20 static int deliver_sample_group(struct evlist *evlist, - struct perf_tool *tool, + const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine, @@ -1521,7 +1521,7 @@ static int deliver_sample_group(struct evlist *evlist, return ret; } =20 -static int evlist__deliver_sample(struct evlist *evlist, struct perf_tool = *tool, +static int evlist__deliver_sample(struct evlist *evlist, const struct perf= _tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine) { @@ -1546,7 +1546,7 @@ static int machines__deliver_event(struct machines *m= achines, struct evlist *evlist, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool, u64 file_offset, + const struct perf_tool *tool, u64 file_offset, const char *file_path) { struct evsel *evsel; @@ -1634,7 +1634,7 @@ static int machines__deliver_event(struct machines *m= achines, =20 static int perf_session__deliver_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool, + const struct perf_tool *tool, u64 file_offset, const char *file_path) { @@ -1667,7 +1667,7 @@ static s64 perf_session__process_user_event(struct pe= rf_session *session, const char *file_path) { struct ordered_events *oe =3D &session->ordered_events; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_sample sample =3D { .time =3D 0, }; int fd =3D perf_data__fd(session->data); int err; @@ -1754,7 +1754,7 @@ int perf_session__deliver_synth_event(struct perf_ses= sion *session, struct perf_sample *sample) { struct evlist *evlist =3D session->evlist; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; =20 events_stats__inc(&evlist->stats, event->header.type); =20 @@ -1886,7 +1886,7 @@ static s64 perf_session__process_event(struct perf_se= ssion *session, const char *file_path) { struct evlist *evlist =3D session->evlist; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; int ret; =20 if (session->header.needs_swap) diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index cc28976bb00e..6886cc85600f 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -163,7 +163,7 @@ int perf_session__dsos_hit_all(struct perf_session *ses= sion); int perf_event__process_id_index(struct perf_session *session, union perf_event *event); =20 -int perf_event__process_finished_round(struct perf_tool *tool, +int perf_event__process_finished_round(const struct perf_tool *tool, union perf_event *event, struct ordered_events *oe); =20 diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic= -events.c index 5498048f56ea..7f884d70de81 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0-only=20 +// SPDX-License-Identifier: GPL-2.0-only =20 #include "util/cgroup.h" #include "util/data.h" @@ -47,7 +47,7 @@ =20 unsigned int proc_map_timeout =3D DEFAULT_PROC_MAP_PARSE_TIMEOUT; =20 -int perf_tool__process_synth_event(struct perf_tool *tool, +int perf_tool__process_synth_event(const struct perf_tool *tool, union perf_event *event, struct machine *machine, perf_event__handler_t process) @@ -187,7 +187,7 @@ static int perf_event__prepare_comm(union perf_event *e= vent, pid_t pid, pid_t ti return 0; } =20 -pid_t perf_event__synthesize_comm(struct perf_tool *tool, +pid_t perf_event__synthesize_comm(const struct perf_tool *tool, union perf_event *event, pid_t pid, perf_event__handler_t process, struct machine *machine) @@ -218,7 +218,7 @@ static void perf_event__get_ns_link_info(pid_t pid, con= st char *ns, } } =20 -int perf_event__synthesize_namespaces(struct perf_tool *tool, +int perf_event__synthesize_namespaces(const struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, @@ -257,7 +257,7 @@ int perf_event__synthesize_namespaces(struct perf_tool = *tool, return 0; } =20 -static int perf_event__synthesize_fork(struct perf_tool *tool, +static int perf_event__synthesize_fork(const struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, pid_t ppid, perf_event__handler_t process, @@ -418,7 +418,7 @@ static void perf_record_mmap2__read_build_id(struct per= f_record_mmap2 *event, dso__put(dso); } =20 -int perf_event__synthesize_mmap_events(struct perf_tool *tool, +int perf_event__synthesize_mmap_events(const struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, @@ -542,7 +542,7 @@ int perf_event__synthesize_mmap_events(struct perf_tool= *tool, } =20 #ifdef HAVE_FILE_HANDLE -static int perf_event__synthesize_cgroup(struct perf_tool *tool, +static int perf_event__synthesize_cgroup(const struct perf_tool *tool, union perf_event *event, char *path, size_t mount_len, perf_event__handler_t process, @@ -582,7 +582,7 @@ static int perf_event__synthesize_cgroup(struct perf_to= ol *tool, return 0; } =20 -static int perf_event__walk_cgroup_tree(struct perf_tool *tool, +static int perf_event__walk_cgroup_tree(const struct perf_tool *tool, union perf_event *event, char *path, size_t mount_len, perf_event__handler_t process, @@ -630,7 +630,7 @@ static int perf_event__walk_cgroup_tree(struct perf_too= l *tool, return ret; } =20 -int perf_event__synthesize_cgroups(struct perf_tool *tool, +int perf_event__synthesize_cgroups(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine) { @@ -657,7 +657,7 @@ int perf_event__synthesize_cgroups(struct perf_tool *to= ol, return 0; } #else -int perf_event__synthesize_cgroups(struct perf_tool *tool __maybe_unused, +int perf_event__synthesize_cgroups(const struct perf_tool *tool __maybe_un= used, perf_event__handler_t process __maybe_unused, struct machine *machine __maybe_unused) { @@ -666,7 +666,7 @@ int perf_event__synthesize_cgroups(struct perf_tool *to= ol __maybe_unused, #endif =20 struct perf_event__synthesize_modules_maps_cb_args { - struct perf_tool *tool; + const struct perf_tool *tool; perf_event__handler_t process; struct machine *machine; union perf_event *event; @@ -717,7 +717,7 @@ static int perf_event__synthesize_modules_maps_cb(struc= t map *map, void *data) return 0; } =20 -int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__han= dler_t process, +int perf_event__synthesize_modules(const struct perf_tool *tool, perf_even= t__handler_t process, struct machine *machine) { int rc; @@ -763,7 +763,7 @@ static int __event__synthesize_thread(union perf_event = *comm_event, union perf_event *fork_event, union perf_event *namespaces_event, pid_t pid, int full, perf_event__handler_t process, - struct perf_tool *tool, struct machine *machine, + const struct perf_tool *tool, struct machine *machine, bool needs_mmap, bool mmap_data) { char filename[PATH_MAX]; @@ -852,7 +852,7 @@ static int __event__synthesize_thread(union perf_event = *comm_event, return rc; } =20 -int perf_event__synthesize_thread_map(struct perf_tool *tool, +int perf_event__synthesize_thread_map(const struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine, @@ -929,7 +929,7 @@ int perf_event__synthesize_thread_map(struct perf_tool = *tool, return err; } =20 -static int __perf_event__synthesize_threads(struct perf_tool *tool, +static int __perf_event__synthesize_threads(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine, bool needs_mmap, @@ -993,7 +993,7 @@ static int __perf_event__synthesize_threads(struct perf= _tool *tool, } =20 struct synthesize_threads_arg { - struct perf_tool *tool; + const struct perf_tool *tool; perf_event__handler_t process; struct machine *machine; bool needs_mmap; @@ -1015,7 +1015,7 @@ static void *synthesize_threads_worker(void *arg) return NULL; } =20 -int perf_event__synthesize_threads(struct perf_tool *tool, +int perf_event__synthesize_threads(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine, bool needs_mmap, bool mmap_data, @@ -1104,14 +1104,14 @@ int perf_event__synthesize_threads(struct perf_tool= *tool, return err; } =20 -int __weak perf_event__synthesize_extra_kmaps(struct perf_tool *tool __may= be_unused, +int __weak perf_event__synthesize_extra_kmaps(const struct perf_tool *tool= __maybe_unused, perf_event__handler_t process __maybe_unused, struct machine *machine __maybe_unused) { return 0; } =20 -static int __perf_event__synthesize_kernel_mmap(struct perf_tool *tool, +static int __perf_event__synthesize_kernel_mmap(const struct perf_tool *to= ol, perf_event__handler_t process, struct machine *machine) { @@ -1183,7 +1183,7 @@ static int __perf_event__synthesize_kernel_mmap(struc= t perf_tool *tool, return err; } =20 -int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, +int perf_event__synthesize_kernel_mmap(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine) { @@ -1196,7 +1196,7 @@ int perf_event__synthesize_kernel_mmap(struct perf_to= ol *tool, return perf_event__synthesize_extra_kmaps(tool, process, machine); } =20 -int perf_event__synthesize_thread_map2(struct perf_tool *tool, +int perf_event__synthesize_thread_map2(const struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine) @@ -1346,7 +1346,7 @@ static struct perf_record_cpu_map *cpu_map_event__new= (const struct perf_cpu_map } =20 =20 -int perf_event__synthesize_cpu_map(struct perf_tool *tool, +int perf_event__synthesize_cpu_map(const struct perf_tool *tool, const struct perf_cpu_map *map, perf_event__handler_t process, struct machine *machine) @@ -1364,7 +1364,7 @@ int perf_event__synthesize_cpu_map(struct perf_tool *= tool, return err; } =20 -int perf_event__synthesize_stat_config(struct perf_tool *tool, +int perf_event__synthesize_stat_config(const struct perf_tool *tool, struct perf_stat_config *config, perf_event__handler_t process, struct machine *machine) @@ -1403,7 +1403,7 @@ int perf_event__synthesize_stat_config(struct perf_to= ol *tool, return err; } =20 -int perf_event__synthesize_stat(struct perf_tool *tool, +int perf_event__synthesize_stat(const struct perf_tool *tool, struct perf_cpu cpu, u32 thread, u64 id, struct perf_counts_values *count, perf_event__handler_t process, @@ -1425,7 +1425,7 @@ int perf_event__synthesize_stat(struct perf_tool *too= l, return process(tool, (union perf_event *) &event, NULL, machine); } =20 -int perf_event__synthesize_stat_round(struct perf_tool *tool, +int perf_event__synthesize_stat_round(const struct perf_tool *tool, u64 evtime, u64 type, perf_event__handler_t process, struct machine *machine) @@ -1826,7 +1826,7 @@ int perf_event__synthesize_id_sample(__u64 *array, u6= 4 type, const struct perf_s return (void *)array - (void *)start; } =20 -int __perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__= handler_t process, +int __perf_event__synthesize_id_index(const struct perf_tool *tool, perf_e= vent__handler_t process, struct evlist *evlist, struct machine *machine, size_t from) { union perf_event *ev; @@ -1918,13 +1918,13 @@ int __perf_event__synthesize_id_index(struct perf_t= ool *tool, perf_event__handle return err; } =20 -int perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__ha= ndler_t process, +int perf_event__synthesize_id_index(const struct perf_tool *tool, perf_eve= nt__handler_t process, struct evlist *evlist, struct machine *machine) { return __perf_event__synthesize_id_index(tool, process, evlist, machine, = 0); } =20 -int __machine__synthesize_threads(struct machine *machine, struct perf_too= l *tool, +int __machine__synthesize_threads(struct machine *machine, const struct pe= rf_tool *tool, struct target *target, struct perf_thread_map *threads, perf_event__handler_t process, bool needs_mmap, bool data_mmap, unsigned int nr_threads_synthesize) @@ -1985,7 +1985,7 @@ static struct perf_record_event_update *event_update_= event__new(size_t size, u64 return ev; } =20 -int perf_event__synthesize_event_update_unit(struct perf_tool *tool, struc= t evsel *evsel, +int perf_event__synthesize_event_update_unit(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process) { size_t size =3D strlen(evsel->unit); @@ -2002,7 +2002,7 @@ int perf_event__synthesize_event_update_unit(struct p= erf_tool *tool, struct evse return err; } =20 -int perf_event__synthesize_event_update_scale(struct perf_tool *tool, stru= ct evsel *evsel, +int perf_event__synthesize_event_update_scale(const struct perf_tool *tool= , struct evsel *evsel, perf_event__handler_t process) { struct perf_record_event_update *ev; @@ -2019,7 +2019,7 @@ int perf_event__synthesize_event_update_scale(struct = perf_tool *tool, struct evs return err; } =20 -int perf_event__synthesize_event_update_name(struct perf_tool *tool, struc= t evsel *evsel, +int perf_event__synthesize_event_update_name(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process) { struct perf_record_event_update *ev; @@ -2036,7 +2036,7 @@ int perf_event__synthesize_event_update_name(struct p= erf_tool *tool, struct evse return err; } =20 -int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, struc= t evsel *evsel, +int perf_event__synthesize_event_update_cpus(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process) { struct synthesize_cpu_map_data syn_data =3D { .map =3D evsel->core.own_cp= us }; @@ -2059,7 +2059,7 @@ int perf_event__synthesize_event_update_cpus(struct p= erf_tool *tool, struct evse return err; } =20 -int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *ev= list, +int perf_event__synthesize_attrs(const struct perf_tool *tool, struct evli= st *evlist, perf_event__handler_t process) { struct evsel *evsel; @@ -2087,7 +2087,7 @@ static bool has_scale(struct evsel *evsel) return evsel->scale !=3D 1; } =20 -int perf_event__synthesize_extra_attr(struct perf_tool *tool, struct evlis= t *evsel_list, +int perf_event__synthesize_extra_attr(const struct perf_tool *tool, struct= evlist *evsel_list, perf_event__handler_t process, bool is_pipe) { struct evsel *evsel; @@ -2143,7 +2143,7 @@ int perf_event__synthesize_extra_attr(struct perf_too= l *tool, struct evlist *evs return 0; } =20 -int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_= attr *attr, +int perf_event__synthesize_attr(const struct perf_tool *tool, struct perf_= event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process) { union perf_event *ev; @@ -2177,7 +2177,7 @@ int perf_event__synthesize_attr(struct perf_tool *too= l, struct perf_event_attr * } =20 #ifdef HAVE_LIBTRACEEVENT -int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, st= ruct evlist *evlist, +int perf_event__synthesize_tracing_data(const struct perf_tool *tool, int = fd, struct evlist *evlist, perf_event__handler_t process) { union perf_event ev; @@ -2225,7 +2225,7 @@ int perf_event__synthesize_tracing_data(struct perf_t= ool *tool, int fd, struct e } #endif =20 -int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *po= s, u16 misc, +int perf_event__synthesize_build_id(const struct perf_tool *tool, struct d= so *pos, u16 misc, perf_event__handler_t process, struct machine *machine) { union perf_event ev; @@ -2249,7 +2249,7 @@ int perf_event__synthesize_build_id(struct perf_tool = *tool, struct dso *pos, u16 return process(tool, &ev, NULL, machine); } =20 -int perf_event__synthesize_stat_events(struct perf_stat_config *config, st= ruct perf_tool *tool, +int perf_event__synthesize_stat_events(struct perf_stat_config *config, co= nst struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process, bool attr= s) { int err; @@ -2286,7 +2286,7 @@ int perf_event__synthesize_stat_events(struct perf_st= at_config *config, struct p =20 extern const struct perf_header_feature_ops feat_ops[HEADER_LAST_FEATURE]; =20 -int perf_event__synthesize_features(struct perf_tool *tool, struct perf_se= ssion *session, +int perf_event__synthesize_features(const struct perf_tool *tool, struct p= erf_session *session, struct evlist *evlist, perf_event__handler_t process) { struct perf_header *header =3D &session->header; @@ -2349,7 +2349,7 @@ int perf_event__synthesize_features(struct perf_tool = *tool, struct perf_session return ret; } =20 -int perf_event__synthesize_for_pipe(struct perf_tool *tool, +int perf_event__synthesize_for_pipe(const struct perf_tool *tool, struct perf_session *session, struct perf_data *data, perf_event__handler_t process) diff --git a/tools/perf/util/synthetic-events.h b/tools/perf/util/synthetic= -events.h index 53737d1619a4..31df7653677f 100644 --- a/tools/perf/util/synthetic-events.h +++ b/tools/perf/util/synthetic-events.h @@ -40,45 +40,45 @@ enum perf_record_synth { =20 int parse_synth_opt(char *str); =20 -typedef int (*perf_event__handler_t)(struct perf_tool *tool, union perf_ev= ent *event, +typedef int (*perf_event__handler_t)(const struct perf_tool *tool, union p= erf_event *event, struct perf_sample *sample, struct machine *machine); =20 -int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *ev= list, perf_event__handler_t process); -int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_= attr *attr, u32 ids, u64 *id, perf_event__handler_t process); -int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *po= s, u16 misc, perf_event__handler_t process, struct machine *machine); -int perf_event__synthesize_cpu_map(struct perf_tool *tool, const struct pe= rf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine); -int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, struc= t evsel *evsel, perf_event__handler_t process); -int perf_event__synthesize_event_update_name(struct perf_tool *tool, struc= t evsel *evsel, perf_event__handler_t process); -int perf_event__synthesize_event_update_scale(struct perf_tool *tool, stru= ct evsel *evsel, perf_event__handler_t process); -int perf_event__synthesize_event_update_unit(struct perf_tool *tool, struc= t evsel *evsel, perf_event__handler_t process); -int perf_event__synthesize_extra_attr(struct perf_tool *tool, struct evlis= t *evsel_list, perf_event__handler_t process, bool is_pipe); -int perf_event__synthesize_extra_kmaps(struct perf_tool *tool, perf_event_= _handler_t process, struct machine *machine); -int perf_event__synthesize_features(struct perf_tool *tool, struct perf_se= ssion *session, struct evlist *evlist, perf_event__handler_t process); -int perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__ha= ndler_t process, struct evlist *evlist, struct machine *machine); -int __perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__= handler_t process, struct evlist *evlist, struct machine *machine, size_t f= rom); +int perf_event__synthesize_attrs(const struct perf_tool *tool, struct evli= st *evlist, perf_event__handler_t process); +int perf_event__synthesize_attr(const struct perf_tool *tool, struct perf_= event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process); +int perf_event__synthesize_build_id(const struct perf_tool *tool, struct d= so *pos, u16 misc, perf_event__handler_t process, struct machine *machine); +int perf_event__synthesize_cpu_map(const struct perf_tool *tool, const str= uct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *mach= ine); +int perf_event__synthesize_event_update_cpus(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process); +int perf_event__synthesize_event_update_name(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process); +int perf_event__synthesize_event_update_scale(const struct perf_tool *tool= , struct evsel *evsel, perf_event__handler_t process); +int perf_event__synthesize_event_update_unit(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process); +int perf_event__synthesize_extra_attr(const struct perf_tool *tool, struct= evlist *evsel_list, perf_event__handler_t process, bool is_pipe); +int perf_event__synthesize_extra_kmaps(const struct perf_tool *tool, perf_= event__handler_t process, struct machine *machine); +int perf_event__synthesize_features(const struct perf_tool *tool, struct p= erf_session *session, struct evlist *evlist, perf_event__handler_t process); +int perf_event__synthesize_id_index(const struct perf_tool *tool, perf_eve= nt__handler_t process, struct evlist *evlist, struct machine *machine); +int __perf_event__synthesize_id_index(const struct perf_tool *tool, perf_e= vent__handler_t process, struct evlist *evlist, struct machine *machine, si= ze_t from); int perf_event__synthesize_id_sample(__u64 *array, u64 type, const struct = perf_sample *sample); -int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, perf_event_= _handler_t process, struct machine *machine); -int perf_event__synthesize_mmap_events(struct perf_tool *tool, union perf_= event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, struct = machine *machine, bool mmap_data); -int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__han= dler_t process, struct machine *machine); -int perf_event__synthesize_namespaces(struct perf_tool *tool, union perf_e= vent *event, pid_t pid, pid_t tgid, perf_event__handler_t process, struct m= achine *machine); -int perf_event__synthesize_cgroups(struct perf_tool *tool, perf_event__han= dler_t process, struct machine *machine); +int perf_event__synthesize_kernel_mmap(const struct perf_tool *tool, perf_= event__handler_t process, struct machine *machine); +int perf_event__synthesize_mmap_events(const struct perf_tool *tool, union= perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, s= truct machine *machine, bool mmap_data); +int perf_event__synthesize_modules(const struct perf_tool *tool, perf_even= t__handler_t process, struct machine *machine); +int perf_event__synthesize_namespaces(const struct perf_tool *tool, union = perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, st= ruct machine *machine); +int perf_event__synthesize_cgroups(const struct perf_tool *tool, perf_even= t__handler_t process, struct machine *machine); int perf_event__synthesize_sample(union perf_event *event, u64 type, u64 r= ead_format, const struct perf_sample *sample); -int perf_event__synthesize_stat_config(struct perf_tool *tool, struct perf= _stat_config *config, perf_event__handler_t process, struct machine *machin= e); -int perf_event__synthesize_stat_events(struct perf_stat_config *config, st= ruct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process,= bool attrs); -int perf_event__synthesize_stat_round(struct perf_tool *tool, u64 time, u6= 4 type, perf_event__handler_t process, struct machine *machine); -int perf_event__synthesize_stat(struct perf_tool *tool, struct perf_cpu cp= u, u32 thread, u64 id, struct perf_counts_values *count, perf_event__handle= r_t process, struct machine *machine); -int perf_event__synthesize_thread_map2(struct perf_tool *tool, struct perf= _thread_map *threads, perf_event__handler_t process, struct machine *machin= e); -int perf_event__synthesize_thread_map(struct perf_tool *tool, struct perf_= thread_map *threads, perf_event__handler_t process, struct machine *machine= , bool needs_mmap, bool mmap_data); -int perf_event__synthesize_threads(struct perf_tool *tool, perf_event__han= dler_t process, struct machine *machine, bool needs_mmap, bool mmap_data, u= nsigned int nr_threads_synthesize); -int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, st= ruct evlist *evlist, perf_event__handler_t process); -int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, str= uct perf_tool *tool, perf_event__handler_t process, struct machine *machine= ); -pid_t perf_event__synthesize_comm(struct perf_tool *tool, union perf_event= *event, pid_t pid, perf_event__handler_t process, struct machine *machine); - -int perf_tool__process_synth_event(struct perf_tool *tool, union perf_even= t *event, struct machine *machine, perf_event__handler_t process); +int perf_event__synthesize_stat_config(const struct perf_tool *tool, struc= t perf_stat_config *config, perf_event__handler_t process, struct machine *= machine); +int perf_event__synthesize_stat_events(struct perf_stat_config *config, co= nst struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t pr= ocess, bool attrs); +int perf_event__synthesize_stat_round(const struct perf_tool *tool, u64 ti= me, u64 type, perf_event__handler_t process, struct machine *machine); +int perf_event__synthesize_stat(const struct perf_tool *tool, struct perf_= cpu cpu, u32 thread, u64 id, struct perf_counts_values *count, perf_event__= handler_t process, struct machine *machine); +int perf_event__synthesize_thread_map2(const struct perf_tool *tool, struc= t perf_thread_map *threads, perf_event__handler_t process, struct machine *= machine); +int perf_event__synthesize_thread_map(const struct perf_tool *tool, struct= perf_thread_map *threads, perf_event__handler_t process, struct machine *m= achine, bool needs_mmap, bool mmap_data); +int perf_event__synthesize_threads(const struct perf_tool *tool, perf_even= t__handler_t process, struct machine *machine, bool needs_mmap, bool mmap_d= ata, unsigned int nr_threads_synthesize); +int perf_event__synthesize_tracing_data(const struct perf_tool *tool, int = fd, struct evlist *evlist, perf_event__handler_t process); +int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, con= st struct perf_tool *tool, perf_event__handler_t process, struct machine *m= achine); +pid_t perf_event__synthesize_comm(const struct perf_tool *tool, union perf= _event *event, pid_t pid, perf_event__handler_t process, struct machine *ma= chine); + +int perf_tool__process_synth_event(const struct perf_tool *tool, union per= f_event *event, struct machine *machine, perf_event__handler_t process); =20 size_t perf_event__sample_event_size(const struct perf_sample *sample, u64= type, u64 read_format); =20 -int __machine__synthesize_threads(struct machine *machine, struct perf_too= l *tool, +int __machine__synthesize_threads(struct machine *machine, const struct pe= rf_tool *tool, struct target *target, struct perf_thread_map *threads, perf_event__handler_t process, bool needs_mmap, bool data_mmap, unsigned int nr_threads_synthesize); @@ -87,7 +87,7 @@ int machine__synthesize_threads(struct machine *machine, = struct target *target, unsigned int nr_threads_synthesize); =20 #ifdef HAVE_AUXTRACE_SUPPORT -int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, stru= ct perf_tool *tool, +int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, cons= t struct perf_tool *tool, struct perf_session *session, perf_event__handler_t process); =20 #else // HAVE_AUXTRACE_SUPPORT @@ -96,7 +96,7 @@ int perf_event__synthesize_auxtrace_info(struct auxtrace_= record *itr, struct per =20 static inline int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr __maybe_u= nused, - struct perf_tool *tool __maybe_unused, + const struct perf_tool *tool __maybe_unused, struct perf_session *session __maybe_unused, perf_event__handler_t process __maybe_unused) { @@ -117,7 +117,7 @@ static inline int perf_event__synthesize_bpf_events(str= uct perf_session *session } #endif // HAVE_LIBBPF_SUPPORT =20 -int perf_event__synthesize_for_pipe(struct perf_tool *tool, +int perf_event__synthesize_for_pipe(const struct perf_tool *tool, struct perf_session *session, struct perf_data *data, perf_event__handler_t process); diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index c957fb849ac6..b192d44fe91f 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -15,14 +15,14 @@ struct perf_tool; struct machine; struct ordered_events; =20 -typedef int (*event_sample)(struct perf_tool *tool, union perf_event *even= t, +typedef int (*event_sample)(const struct perf_tool *tool, union perf_event= *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine); =20 -typedef int (*event_op)(struct perf_tool *tool, union perf_event *event, +typedef int (*event_op)(const struct perf_tool *tool, union perf_event *ev= ent, struct perf_sample *sample, struct machine *machine); =20 -typedef int (*event_attr_op)(struct perf_tool *tool, +typedef int (*event_attr_op)(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist); =20 @@ -31,7 +31,7 @@ typedef s64 (*event_op3)(struct perf_session *session, un= ion perf_event *event); typedef int (*event_op4)(struct perf_session *session, union perf_event *e= vent, u64 data, const char *str); =20 -typedef int (*event_oe)(struct perf_tool *tool, union perf_event *event, +typedef int (*event_oe)(const struct perf_tool *tool, union perf_event *ev= ent, struct ordered_events *oe); =20 enum show_feature_header { diff --git a/tools/perf/util/tsc.c b/tools/perf/util/tsc.c index f19791d46e99..2e33a20e1e1b 100644 --- a/tools/perf/util/tsc.c +++ b/tools/perf/util/tsc.c @@ -72,7 +72,7 @@ int perf_read_tsc_conversion(const struct perf_event_mmap= _page *pc, } =20 int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, - struct perf_tool *tool, + const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine) { --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:07 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 CDC36178361 for ; Fri, 12 Jul 2024 18:12:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807942; cv=none; b=gvyuYmI0URWZsg/i4HKVlXbhQA40rDDkUyj8YwLRv9LtwsKNxeRwXY8HymG/pX8WHrsWGQo5hSEyOG/allxI4QeH36WDvsZWf2byD4D3bQgTGqU1wYBsYtFvpyDgULTVMwU+wia95Ukz6lQX68oamxdzxhj4pbHt4gduU7/Xn/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807942; c=relaxed/simple; bh=PtBRXc0c+0allU3O64DiNYmraKLIDmcwEXLGEG6EUWQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=NIuY+soJNIXF/N6QOl41zzFgX6HlGkYb1QR+ZBzeSIIhhtswUCikxPRbNY5BToXQSEZ2gwMLfuAFu8mHYD1T0oJBGCS0tdzRF3pi8mQJNU8xL7mq2VSafLGLzJrDdbY0Ka5K0CK4yURZun3VREAZjMyhU01VNPAqyTRhvJhE9HM= 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=YMMcEBWX; arc=none smtp.client-ip=209.85.128.202 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="YMMcEBWX" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6501bac2d6aso25813497b3.0 for ; Fri, 12 Jul 2024 11:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807940; x=1721412740; 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=7irtahaUgZZ2kadtdQTAIVJwXhey7Hso05gQMGn03JQ=; b=YMMcEBWXhNgL/HOMt2c5sEg9kfE3lnliaU+OhZh/g/EVYxlYOqA+4xDSMlRXzEivhT d6Gf+aBSaIL+0dYvSlr8D2n3eBbfYy804BOsSuta8S2m8T4t7xly4pTSaYkaIgikp5gJ LrTQY1qepXq0tWpbEweRL7tAnRfQjQmQ0x4lLMerQLuCpH5IZI7OL0K8I3mtgG6jgu5o FTwDqQxbqHgAUqc+qTECE6aFy/kR0iho6Bg7Z9RMD/7vOo1xqnvmQoW/Y+dnWynXThev cMUReXdJi5uWpI2VZnDVgjVXIznQ05d/51sQmWe2vnfg2XavJ7osxVXEpGKNJMbvenfq IecA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807940; x=1721412740; 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=7irtahaUgZZ2kadtdQTAIVJwXhey7Hso05gQMGn03JQ=; b=CTjmLghSyO1VErQ6jQJ6xvo+QnwQakv2IJEqCyWG+nZ+jGP+H+Q9282ChGvDiWzk+k op5IbFD+VAyTG0cauLlaWEW73bG7zTOB0P9vxCn74YsQFpqbUg+EpnNXSxABLl66Iu1I wz5M4A/LNtRBa/g/VY4pv+9G/Gpxe8JFBXlGT7ukI4T7aLgy9ovLLNbMFhgjSiPZ4R+D YttjWAWb7dg3hL3qhkjqQbv4hCCF35hAQ0e6U1+YNN804Rek65U0KK7F0Ef4vLXx7lma aQYjMEDKP3cV3wOjg06oJPk76ageIgIt+ylRncNoGxjwQN2X0D3c26PG9wU+6owa/bMN CM0w== X-Forwarded-Encrypted: i=1; AJvYcCVnrzkdrv2z1hPjK8WE6bNb6g7eYLk9IZ3SY56Zv3qIpuXGkHJfjD56jAgW7ZBLiFy03UkgCLb+CBqYRUXIkdanLecy9HR0WM/2AJWk X-Gm-Message-State: AOJu0YxYK9bnHYmzr5FvgeiBHE4Q8myNmcHJcpld4PCaSYvXdxRySO9R LvxegbLD+c9EO1P9A93FqX7yNLM2PeTkuFNfUs5kIi+8fWOb/RnJrqfCmIST6qhwwXiMZSHaz+J TCyVc3g== X-Google-Smtp-Source: AGHT+IEy+F9KU38JefBPwZOtKdQLbKALuCGzUqHQUM3gdJAAlu2RdV1w0fDalFLhNImrlG4cgHl3Dhp9FWi9 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a81:d80a:0:b0:651:2eea:4dfe with SMTP id 00721157ae682-65deffe9b93mr146937b3.0.1720807939878; Fri, 12 Jul 2024 11:12:19 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:45 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-5-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 04/27] perf tool: Move fill defaults into tool.c 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" The aim here is to eventually make perf_tool__fill_defaults an init function so that the tools struct is more const. Create a tool.c to go along with tool.h. Move perf_tool__fill_defaults out of session.c into tool.c along with the default stub values. Add perf_tool__compressed_is_stub for a test in perf_session__process_user_event. perf_session__process_compressed_event is only used from being default initialized so migrate into tool.c. Signed-off-by: Ian Rogers --- tools/perf/util/Build | 1 + tools/perf/util/session.c | 310 +----------------------------------- tools/perf/util/session.h | 2 - tools/perf/util/tool.c | 325 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/tool.h | 4 + 5 files changed, 331 insertions(+), 311 deletions(-) create mode 100644 tools/perf/util/tool.c diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 0f18fe81ef0b..f3633342374a 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -65,6 +65,7 @@ perf-util-y +=3D map.o perf-util-y +=3D maps.o perf-util-y +=3D pstack.o perf-util-y +=3D session.o +perf-util-y +=3D tool.o perf-util-y +=3D sample-raw.o perf-util-y +=3D s390-sample-raw.o perf-util-y +=3D amd-sample-raw.o diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 7e9827e61d1b..5359ee055c85 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -38,68 +38,6 @@ #include "units.h" #include =20 -#ifdef HAVE_ZSTD_SUPPORT -static int perf_session__process_compressed_event(struct perf_session *ses= sion, - union perf_event *event, u64 file_offset, - const char *file_path) -{ - void *src; - size_t decomp_size, src_size; - u64 decomp_last_rem =3D 0; - size_t mmap_len, decomp_len =3D session->header.env.comp_mmap_len; - struct decomp *decomp, *decomp_last =3D session->active_decomp->decomp_la= st; - - if (decomp_last) { - decomp_last_rem =3D decomp_last->size - decomp_last->head; - decomp_len +=3D decomp_last_rem; - } - - mmap_len =3D sizeof(struct decomp) + decomp_len; - decomp =3D mmap(NULL, mmap_len, PROT_READ|PROT_WRITE, - MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); - if (decomp =3D=3D MAP_FAILED) { - pr_err("Couldn't allocate memory for decompression\n"); - return -1; - } - - decomp->file_pos =3D file_offset; - decomp->file_path =3D file_path; - decomp->mmap_len =3D mmap_len; - decomp->head =3D 0; - - if (decomp_last_rem) { - memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_las= t_rem); - decomp->size =3D decomp_last_rem; - } - - src =3D (void *)event + sizeof(struct perf_record_compressed); - src_size =3D event->pack.header.size - sizeof(struct perf_record_compress= ed); - - decomp_size =3D zstd_decompress_stream(session->active_decomp->zstd_decom= p, src, src_size, - &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem); - if (!decomp_size) { - munmap(decomp, mmap_len); - pr_err("Couldn't decompress data\n"); - return -1; - } - - decomp->size +=3D decomp_size; - - if (session->active_decomp->decomp =3D=3D NULL) - session->active_decomp->decomp =3D decomp; - else - session->active_decomp->decomp_last->next =3D decomp; - - session->active_decomp->decomp_last =3D decomp; - - pr_debug("decomp (B): %zd to %zd\n", src_size, decomp_size); - - return 0; -} -#else /* !HAVE_ZSTD_SUPPORT */ -#define perf_session__process_compressed_event perf_session__process_compr= essed_event_stub -#endif - static int perf_session__deliver_event(struct perf_session *session, union perf_event *event, const struct perf_tool *tool, @@ -319,251 +257,6 @@ void perf_session__delete(struct perf_session *sessio= n) free(session); } =20 -static int process_event_synth_tracing_data_stub(struct perf_session *sess= ion - __maybe_unused, - union perf_event *event - __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_synth_attr_stub(const struct perf_tool *tool __ma= ybe_unused, - union perf_event *event __maybe_unused, - struct evlist **pevlist - __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_synth_event_update_stub(const struct perf_tool *t= ool __maybe_unused, - union perf_event *event __maybe_unused, - struct evlist **pevlist - __maybe_unused) -{ - if (dump_trace) - perf_event__fprintf_event_update(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_sample_stub(const struct perf_tool *tool __maybe_= unused, - union perf_event *event __maybe_unused, - struct perf_sample *sample __maybe_unused, - struct evsel *evsel __maybe_unused, - struct machine *machine __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_stub(const struct perf_tool *tool __maybe_unused, - union perf_event *event __maybe_unused, - struct perf_sample *sample __maybe_unused, - struct machine *machine __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_finished_round_stub(const struct perf_tool *tool __mayb= e_unused, - union perf_event *event __maybe_unused, - struct ordered_events *oe __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int skipn(int fd, off_t n) -{ - char buf[4096]; - ssize_t ret; - - while (n > 0) { - ret =3D read(fd, buf, min(n, (off_t)sizeof(buf))); - if (ret <=3D 0) - return ret; - n -=3D ret; - } - - return 0; -} - -static s64 process_event_auxtrace_stub(struct perf_session *session __mayb= e_unused, - union perf_event *event) -{ - dump_printf(": unhandled!\n"); - if (perf_data__is_pipe(session->data)) - skipn(perf_data__fd(session->data), event->auxtrace.size); - return event->auxtrace.size; -} - -static int process_event_op2_stub(struct perf_session *session __maybe_unu= sed, - union perf_event *event __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - - -static -int process_event_thread_map_stub(struct perf_session *session __maybe_unu= sed, - union perf_event *event __maybe_unused) -{ - if (dump_trace) - perf_event__fprintf_thread_map(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static -int process_event_cpu_map_stub(struct perf_session *session __maybe_unused, - union perf_event *event __maybe_unused) -{ - if (dump_trace) - perf_event__fprintf_cpu_map(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static -int process_event_stat_config_stub(struct perf_session *session __maybe_un= used, - union perf_event *event __maybe_unused) -{ - if (dump_trace) - perf_event__fprintf_stat_config(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_stat_stub(struct perf_session *perf_session __maybe_unu= sed, - union perf_event *event) -{ - if (dump_trace) - perf_event__fprintf_stat(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_stat_round_stub(struct perf_session *perf_session __may= be_unused, - union perf_event *event) -{ - if (dump_trace) - perf_event__fprintf_stat_round(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_time_conv_stub(struct perf_session *perf_session = __maybe_unused, - union perf_event *event) -{ - if (dump_trace) - perf_event__fprintf_time_conv(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int perf_session__process_compressed_event_stub(struct perf_session= *session __maybe_unused, - union perf_event *event __maybe_unused, - u64 file_offset __maybe_unused, - const char *file_path __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -void perf_tool__fill_defaults(struct perf_tool *tool) -{ - if (tool->sample =3D=3D NULL) - tool->sample =3D process_event_sample_stub; - if (tool->mmap =3D=3D NULL) - tool->mmap =3D process_event_stub; - if (tool->mmap2 =3D=3D NULL) - tool->mmap2 =3D process_event_stub; - if (tool->comm =3D=3D NULL) - tool->comm =3D process_event_stub; - if (tool->namespaces =3D=3D NULL) - tool->namespaces =3D process_event_stub; - if (tool->cgroup =3D=3D NULL) - tool->cgroup =3D process_event_stub; - if (tool->fork =3D=3D NULL) - tool->fork =3D process_event_stub; - if (tool->exit =3D=3D NULL) - tool->exit =3D process_event_stub; - if (tool->lost =3D=3D NULL) - tool->lost =3D perf_event__process_lost; - if (tool->lost_samples =3D=3D NULL) - tool->lost_samples =3D perf_event__process_lost_samples; - if (tool->aux =3D=3D NULL) - tool->aux =3D perf_event__process_aux; - if (tool->itrace_start =3D=3D NULL) - tool->itrace_start =3D perf_event__process_itrace_start; - if (tool->context_switch =3D=3D NULL) - tool->context_switch =3D perf_event__process_switch; - if (tool->ksymbol =3D=3D NULL) - tool->ksymbol =3D perf_event__process_ksymbol; - if (tool->bpf =3D=3D NULL) - tool->bpf =3D perf_event__process_bpf; - if (tool->text_poke =3D=3D NULL) - tool->text_poke =3D perf_event__process_text_poke; - if (tool->aux_output_hw_id =3D=3D NULL) - tool->aux_output_hw_id =3D perf_event__process_aux_output_hw_id; - if (tool->read =3D=3D NULL) - tool->read =3D process_event_sample_stub; - if (tool->throttle =3D=3D NULL) - tool->throttle =3D process_event_stub; - if (tool->unthrottle =3D=3D NULL) - tool->unthrottle =3D process_event_stub; - if (tool->attr =3D=3D NULL) - tool->attr =3D process_event_synth_attr_stub; - if (tool->event_update =3D=3D NULL) - tool->event_update =3D process_event_synth_event_update_stub; - if (tool->tracing_data =3D=3D NULL) - tool->tracing_data =3D process_event_synth_tracing_data_stub; - if (tool->build_id =3D=3D NULL) - tool->build_id =3D process_event_op2_stub; - if (tool->finished_round =3D=3D NULL) { - if (tool->ordered_events) - tool->finished_round =3D perf_event__process_finished_round; - else - tool->finished_round =3D process_finished_round_stub; - } - if (tool->id_index =3D=3D NULL) - tool->id_index =3D process_event_op2_stub; - if (tool->auxtrace_info =3D=3D NULL) - tool->auxtrace_info =3D process_event_op2_stub; - if (tool->auxtrace =3D=3D NULL) - tool->auxtrace =3D process_event_auxtrace_stub; - if (tool->auxtrace_error =3D=3D NULL) - tool->auxtrace_error =3D process_event_op2_stub; - if (tool->thread_map =3D=3D NULL) - tool->thread_map =3D process_event_thread_map_stub; - if (tool->cpu_map =3D=3D NULL) - tool->cpu_map =3D process_event_cpu_map_stub; - if (tool->stat_config =3D=3D NULL) - tool->stat_config =3D process_event_stat_config_stub; - if (tool->stat =3D=3D NULL) - tool->stat =3D process_stat_stub; - if (tool->stat_round =3D=3D NULL) - tool->stat_round =3D process_stat_round_stub; - if (tool->time_conv =3D=3D NULL) - tool->time_conv =3D process_event_time_conv_stub; - if (tool->feature =3D=3D NULL) - tool->feature =3D process_event_op2_stub; - if (tool->compressed =3D=3D NULL) - tool->compressed =3D perf_session__process_compressed_event; - if (tool->finished_init =3D=3D NULL) - tool->finished_init =3D process_event_op2_stub; -} - static void swap_sample_id_all(union perf_event *event, void *data) { void *end =3D (void *) event + event->header.size; @@ -1672,8 +1365,7 @@ static s64 perf_session__process_user_event(struct pe= rf_session *session, int fd =3D perf_data__fd(session->data); int err; =20 - if (event->header.type !=3D PERF_RECORD_COMPRESSED || - tool->compressed =3D=3D perf_session__process_compressed_event_stub) + if (event->header.type !=3D PERF_RECORD_COMPRESSED || perf_tool__compress= ed_is_stub(tool)) dump_event(session->evlist, event, file_offset, &sample, file_path); =20 /* These events are processed right away */ diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 6886cc85600f..7f69baeae7fb 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -92,8 +92,6 @@ int perf_session__process_events(struct perf_session *ses= sion); int perf_session__queue_event(struct perf_session *s, union perf_event *ev= ent, u64 timestamp, u64 file_offset, const char *file_path); =20 -void perf_tool__fill_defaults(struct perf_tool *tool); - int perf_session__resolve_callchain(struct perf_session *session, struct evsel *evsel, struct thread *thread, diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c new file mode 100644 index 000000000000..17219ecb8fa6 --- /dev/null +++ b/tools/perf/util/tool.c @@ -0,0 +1,325 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "data.h" +#include "debug.h" +#include "header.h" +#include "session.h" +#include "stat.h" +#include "tool.h" +#include "tsc.h" +#include +#include + +#ifdef HAVE_ZSTD_SUPPORT +static int perf_session__process_compressed_event(struct perf_session *ses= sion, + union perf_event *event, u64 file_offset, + const char *file_path) +{ + void *src; + size_t decomp_size, src_size; + u64 decomp_last_rem =3D 0; + size_t mmap_len, decomp_len =3D session->header.env.comp_mmap_len; + struct decomp *decomp, *decomp_last =3D session->active_decomp->decomp_la= st; + + if (decomp_last) { + decomp_last_rem =3D decomp_last->size - decomp_last->head; + decomp_len +=3D decomp_last_rem; + } + + mmap_len =3D sizeof(struct decomp) + decomp_len; + decomp =3D mmap(NULL, mmap_len, PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); + if (decomp =3D=3D MAP_FAILED) { + pr_err("Couldn't allocate memory for decompression\n"); + return -1; + } + + decomp->file_pos =3D file_offset; + decomp->file_path =3D file_path; + decomp->mmap_len =3D mmap_len; + decomp->head =3D 0; + + if (decomp_last_rem) { + memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_las= t_rem); + decomp->size =3D decomp_last_rem; + } + + src =3D (void *)event + sizeof(struct perf_record_compressed); + src_size =3D event->pack.header.size - sizeof(struct perf_record_compress= ed); + + decomp_size =3D zstd_decompress_stream(session->active_decomp->zstd_decom= p, src, src_size, + &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem); + if (!decomp_size) { + munmap(decomp, mmap_len); + pr_err("Couldn't decompress data\n"); + return -1; + } + + decomp->size +=3D decomp_size; + + if (session->active_decomp->decomp =3D=3D NULL) + session->active_decomp->decomp =3D decomp; + else + session->active_decomp->decomp_last->next =3D decomp; + + session->active_decomp->decomp_last =3D decomp; + + pr_debug("decomp (B): %zd to %zd\n", src_size, decomp_size); + + return 0; +} +#endif + +static int process_event_synth_tracing_data_stub(struct perf_session *sess= ion + __maybe_unused, + union perf_event *event + __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_synth_attr_stub(const struct perf_tool *tool __ma= ybe_unused, + union perf_event *event __maybe_unused, + struct evlist **pevlist + __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_synth_event_update_stub(const struct perf_tool *t= ool __maybe_unused, + union perf_event *event __maybe_unused, + struct evlist **pevlist + __maybe_unused) +{ + if (dump_trace) + perf_event__fprintf_event_update(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_sample_stub(const struct perf_tool *tool __maybe_= unused, + union perf_event *event __maybe_unused, + struct perf_sample *sample __maybe_unused, + struct evsel *evsel __maybe_unused, + struct machine *machine __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_stub(const struct perf_tool *tool __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_sample *sample __maybe_unused, + struct machine *machine __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_finished_round_stub(const struct perf_tool *tool __mayb= e_unused, + union perf_event *event __maybe_unused, + struct ordered_events *oe __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int skipn(int fd, off_t n) +{ + char buf[4096]; + ssize_t ret; + + while (n > 0) { + ret =3D read(fd, buf, min(n, (off_t)sizeof(buf))); + if (ret <=3D 0) + return ret; + n -=3D ret; + } + + return 0; +} + +static s64 process_event_auxtrace_stub(struct perf_session *session __mayb= e_unused, + union perf_event *event) +{ + dump_printf(": unhandled!\n"); + if (perf_data__is_pipe(session->data)) + skipn(perf_data__fd(session->data), event->auxtrace.size); + return event->auxtrace.size; +} + +static int process_event_op2_stub(struct perf_session *session __maybe_unu= sed, + union perf_event *event __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + + +static +int process_event_thread_map_stub(struct perf_session *session __maybe_unu= sed, + union perf_event *event __maybe_unused) +{ + if (dump_trace) + perf_event__fprintf_thread_map(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static +int process_event_cpu_map_stub(struct perf_session *session __maybe_unused, + union perf_event *event __maybe_unused) +{ + if (dump_trace) + perf_event__fprintf_cpu_map(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static +int process_event_stat_config_stub(struct perf_session *session __maybe_un= used, + union perf_event *event __maybe_unused) +{ + if (dump_trace) + perf_event__fprintf_stat_config(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_stat_stub(struct perf_session *perf_session __maybe_unu= sed, + union perf_event *event) +{ + if (dump_trace) + perf_event__fprintf_stat(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_stat_round_stub(struct perf_session *perf_session __may= be_unused, + union perf_event *event) +{ + if (dump_trace) + perf_event__fprintf_stat_round(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_time_conv_stub(struct perf_session *perf_session = __maybe_unused, + union perf_event *event) +{ + if (dump_trace) + perf_event__fprintf_time_conv(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int perf_session__process_compressed_event_stub(struct perf_session= *session __maybe_unused, + union perf_event *event __maybe_unused, + u64 file_offset __maybe_unused, + const char *file_path __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +void perf_tool__fill_defaults(struct perf_tool *tool) +{ + if (tool->sample =3D=3D NULL) + tool->sample =3D process_event_sample_stub; + if (tool->mmap =3D=3D NULL) + tool->mmap =3D process_event_stub; + if (tool->mmap2 =3D=3D NULL) + tool->mmap2 =3D process_event_stub; + if (tool->comm =3D=3D NULL) + tool->comm =3D process_event_stub; + if (tool->namespaces =3D=3D NULL) + tool->namespaces =3D process_event_stub; + if (tool->cgroup =3D=3D NULL) + tool->cgroup =3D process_event_stub; + if (tool->fork =3D=3D NULL) + tool->fork =3D process_event_stub; + if (tool->exit =3D=3D NULL) + tool->exit =3D process_event_stub; + if (tool->lost =3D=3D NULL) + tool->lost =3D perf_event__process_lost; + if (tool->lost_samples =3D=3D NULL) + tool->lost_samples =3D perf_event__process_lost_samples; + if (tool->aux =3D=3D NULL) + tool->aux =3D perf_event__process_aux; + if (tool->itrace_start =3D=3D NULL) + tool->itrace_start =3D perf_event__process_itrace_start; + if (tool->context_switch =3D=3D NULL) + tool->context_switch =3D perf_event__process_switch; + if (tool->ksymbol =3D=3D NULL) + tool->ksymbol =3D perf_event__process_ksymbol; + if (tool->bpf =3D=3D NULL) + tool->bpf =3D perf_event__process_bpf; + if (tool->text_poke =3D=3D NULL) + tool->text_poke =3D perf_event__process_text_poke; + if (tool->aux_output_hw_id =3D=3D NULL) + tool->aux_output_hw_id =3D perf_event__process_aux_output_hw_id; + if (tool->read =3D=3D NULL) + tool->read =3D process_event_sample_stub; + if (tool->throttle =3D=3D NULL) + tool->throttle =3D process_event_stub; + if (tool->unthrottle =3D=3D NULL) + tool->unthrottle =3D process_event_stub; + if (tool->attr =3D=3D NULL) + tool->attr =3D process_event_synth_attr_stub; + if (tool->event_update =3D=3D NULL) + tool->event_update =3D process_event_synth_event_update_stub; + if (tool->tracing_data =3D=3D NULL) + tool->tracing_data =3D process_event_synth_tracing_data_stub; + if (tool->build_id =3D=3D NULL) + tool->build_id =3D process_event_op2_stub; + if (tool->finished_round =3D=3D NULL) { + if (tool->ordered_events) + tool->finished_round =3D perf_event__process_finished_round; + else + tool->finished_round =3D process_finished_round_stub; + } + if (tool->id_index =3D=3D NULL) + tool->id_index =3D process_event_op2_stub; + if (tool->auxtrace_info =3D=3D NULL) + tool->auxtrace_info =3D process_event_op2_stub; + if (tool->auxtrace =3D=3D NULL) + tool->auxtrace =3D process_event_auxtrace_stub; + if (tool->auxtrace_error =3D=3D NULL) + tool->auxtrace_error =3D process_event_op2_stub; + if (tool->thread_map =3D=3D NULL) + tool->thread_map =3D process_event_thread_map_stub; + if (tool->cpu_map =3D=3D NULL) + tool->cpu_map =3D process_event_cpu_map_stub; + if (tool->stat_config =3D=3D NULL) + tool->stat_config =3D process_event_stat_config_stub; + if (tool->stat =3D=3D NULL) + tool->stat =3D process_stat_stub; + if (tool->stat_round =3D=3D NULL) + tool->stat_round =3D process_stat_round_stub; + if (tool->time_conv =3D=3D NULL) + tool->time_conv =3D process_event_time_conv_stub; + if (tool->feature =3D=3D NULL) + tool->feature =3D process_event_op2_stub; + if (tool->compressed =3D=3D NULL) { +#ifdef HAVE_ZSTD_SUPPORT + tool->compressed =3D perf_session__process_compressed_event; +#else + tool->compressed =3D perf_session__process_compressed_event_stub; +#endif + } + if (tool->finished_init =3D=3D NULL) + tool->finished_init =3D process_event_op2_stub; +} + +bool perf_tool__compressed_is_stub(const struct perf_tool *tool) +{ + return tool->compressed =3D=3D perf_session__process_compressed_event_stu= b; +} diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index b192d44fe91f..7913b698033a 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -88,4 +88,8 @@ struct perf_tool { enum show_feature_header show_feat_hdr; }; =20 +void perf_tool__fill_defaults(struct perf_tool *tool); + +bool perf_tool__compressed_is_stub(const struct perf_tool *tool); + #endif /* __PERF_TOOL_H */ --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:07 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 2D00A177991 for ; Fri, 12 Jul 2024 18:12:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807944; cv=none; b=r5KZ9CWMFsp7IY7vbTwJZ5jin+nVp04eMeEQTqj232HMdYXwcodLc2xAWXmfJqPXcK2lDKYQ81IHHoAF6+XMTMcp1latYIlPqsl4gymjNKOYBmy9V2+COyZiizvE/fcFGVLGStJtsLh9oudf7h/1tcMHmsPvuxR/cDgF8pATx1g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807944; c=relaxed/simple; bh=0sUGypKycMkQkspjkBVoBrgTbEB/yfeNI4tZZobPQAE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=WFKUjPd+dScuDpPZrmNpAVngF0SJO94yBTD+p1ok8MfX53fcqL6l7yvib3sa2kT0RiwMR45aN0vYdooLHW2PGCB8vcDwwo3z7p2t785fTwUuS46NKanaHLJC0uSoZ7IRJe8AYZh5WB482FTvYlBnlgRtqYhLUWe7o66xDhNyVTY= 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=i/Eaol+u; arc=none smtp.client-ip=209.85.128.202 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="i/Eaol+u" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-650fccfd373so36214907b3.3 for ; Fri, 12 Jul 2024 11:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807942; x=1721412742; 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=PUbNGHbJusTOA2CgJOpkojrr3Ag9eG/HXr7a91E5F44=; b=i/Eaol+uUPG7jEAK9rbPgRQZshpunNSczO2Z9pknNOUtl/cCWCD3d9716KSQpGOjr8 0KFwwnFuCbNah0RxXADz45nfJ/VzQR+HtPtTKrCmeuimMMuW4pry1rGPZjYCz+wVA7uX G8Htuh5wG8CeysUOoHAlZE7VfykkGIS9q6o0nDRun9QLAvHKyvSSUe3BVotvuETc6fch ogKBzT+/pUAdsco56UKusshdRO364e8BGJVvb2PN8nl1ZEVG5Kchk+GT/WAIH5EIrw37 TmufXV2MfA51Ezu/iK1dQcGSlV0t6pjz8OWEtdFrl8WEWTgwCvZ8e9KTza9gJxun8P+S j0SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807942; x=1721412742; 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=PUbNGHbJusTOA2CgJOpkojrr3Ag9eG/HXr7a91E5F44=; b=f0aj1B+JGFsyHde/czT/G5AEzm6bMhohXHK5L21CihG42lrCEr0OEed+2mnna3m993 wyUQPwc4g5YN3/MULr8jDBJeOrqDjo9hdOl3+SKnJyRSu+LeXwLom/LidcuQlzRUP2zd k+pdxcHn33Jiblp7YlK6tuYHsYUQowSJF7StquYUowo3fpU9pb2SNnvdBsHzNhVPS5aQ HWpE511c1vrbcBsBtbMi/k6K5Vc14FR6UbwGv2hG42rfh7rWPbT2rs3n9Gf78gmuolj4 eLTLw0awGiWQgnKI+MDmnBxZzg79ChJeoF24EppqtsvtclMjdtNmFHgqUJx4JwhcV8RL T5PQ== X-Forwarded-Encrypted: i=1; AJvYcCX9Jqy4/8rpuFE1+TjB9Se9qNE1Ri7yOvCP025eabBTt00iY0oeUirmiZ3YbDAmV8Cb7c+bnDdcNETW2CLGxqq3/rUdif78CL+LczG9 X-Gm-Message-State: AOJu0Yxjiiivk8mBellMLcoB8OpebVaxPpa6IfW/7WiJmhy70wu/zrJQ pMQklgv5dv9kWYFa4dz8JTEyla6TIR+OEjFCDYFhNC7SowknoUITYOkC3eTZCLLYhWhL9qnhREw SmTxKog== X-Google-Smtp-Source: AGHT+IEn4aL7gAe/A8RlgnAdU+tNwlNq+Sm/494mGsbEklzNlhOPqAJr26SyTCQFnLjLoMPuNqG7qpfWvCca X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:2b0d:b0:dda:d7cf:5c2c with SMTP id 3f1490d57ef6-e041b17798cmr23897276.13.1720807942024; Fri, 12 Jul 2024 11:12:22 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:46 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-6-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 05/27] perf tool: Add 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" Add init function that behaves like perf_tool__fill_defaults but assumes all values haven't been initialized. Signed-off-by: Ian Rogers --- tools/perf/util/tool.c | 58 ++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/tool.h | 1 + 2 files changed, 59 insertions(+) diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c index 17219ecb8fa6..cbd9b888bd73 100644 --- a/tools/perf/util/tool.c +++ b/tools/perf/util/tool.c @@ -230,6 +230,64 @@ static int perf_session__process_compressed_event_stub= (struct perf_session *sess return 0; } =20 +void perf_tool__init(struct perf_tool *tool, bool ordered_events) +{ + tool->ordered_events =3D ordered_events; + tool->ordering_requires_timestamps =3D false; + tool->namespace_events =3D false; + tool->cgroup_events =3D false; + tool->no_warn =3D false; + tool->show_feat_hdr =3D SHOW_FEAT_NO_HEADER; + + tool->sample =3D process_event_sample_stub; + tool->mmap =3D process_event_stub; + tool->mmap2 =3D process_event_stub; + tool->comm =3D process_event_stub; + tool->namespaces =3D process_event_stub; + tool->cgroup =3D process_event_stub; + tool->fork =3D process_event_stub; + tool->exit =3D process_event_stub; + tool->lost =3D perf_event__process_lost; + tool->lost_samples =3D perf_event__process_lost_samples; + tool->aux =3D perf_event__process_aux; + tool->itrace_start =3D perf_event__process_itrace_start; + tool->context_switch =3D perf_event__process_switch; + tool->ksymbol =3D perf_event__process_ksymbol; + tool->bpf =3D perf_event__process_bpf; + tool->text_poke =3D perf_event__process_text_poke; + tool->aux_output_hw_id =3D perf_event__process_aux_output_hw_id; + tool->read =3D process_event_sample_stub; + tool->throttle =3D process_event_stub; + tool->unthrottle =3D process_event_stub; + tool->attr =3D process_event_synth_attr_stub; + tool->event_update =3D process_event_synth_event_update_stub; + tool->tracing_data =3D process_event_synth_tracing_data_stub; + tool->build_id =3D process_event_op2_stub; + + if (ordered_events) + tool->finished_round =3D perf_event__process_finished_round; + else + tool->finished_round =3D process_finished_round_stub; + + tool->id_index =3D process_event_op2_stub; + tool->auxtrace_info =3D process_event_op2_stub; + tool->auxtrace =3D process_event_auxtrace_stub; + tool->auxtrace_error =3D process_event_op2_stub; + tool->thread_map =3D process_event_thread_map_stub; + tool->cpu_map =3D process_event_cpu_map_stub; + tool->stat_config =3D process_event_stat_config_stub; + tool->stat =3D process_stat_stub; + tool->stat_round =3D process_stat_round_stub; + tool->time_conv =3D process_event_time_conv_stub; + tool->feature =3D process_event_op2_stub; +#ifdef HAVE_ZSTD_SUPPORT + tool->compressed =3D perf_session__process_compressed_event; +#else + tool->compressed =3D perf_session__process_compressed_event_stub; +#endif + tool->finished_init =3D process_event_op2_stub; +} + void perf_tool__fill_defaults(struct perf_tool *tool) { if (tool->sample =3D=3D NULL) diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index 7913b698033a..897c6c44b6b2 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -88,6 +88,7 @@ struct perf_tool { enum show_feature_header show_feat_hdr; }; =20 +void perf_tool__init(struct perf_tool *tool, bool ordered_events); void perf_tool__fill_defaults(struct perf_tool *tool); =20 bool perf_tool__compressed_is_stub(const struct perf_tool *tool); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 4805317966C for ; Fri, 12 Jul 2024 18:12:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807947; cv=none; b=Lu39gbsqKVIdDIwyep/w3cgKHIBLs6fPxfmtmjGV+CfqOiLy9MNI7955TnKTDFJHpRPPwdq7cnlcQghAz99L6bQKL3+4h3g0yDaYBN5C0SDbN2IAS/UY/mLTr8ghOKDWLtTs5+cZust6/xyDSJ7t3ovtWi164sMh4/n16CGeOwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807947; c=relaxed/simple; bh=z5wXs6v0oTEwyKPVEdDTOwtt2S/GFG3uzWXLUE9bRVQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=E79n5eNnMWHcbY+o3KSP9gOY3usUx0OO5S/OhQ0haAKyjfixtxnNWB7lA21t05TvUDxGPgtRWiq4r8lagqiTSYjUTvdstD+qOmAWKw9/vBGJL88GfTrXA1GhzxozruE5NwIbl+SOsV2FwBeHBmHcH3mKBVMGaZOIPFyR6CeFfcA= 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=XPt0Sz3b; arc=none smtp.client-ip=209.85.219.202 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="XPt0Sz3b" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e056166e0a6so3815853276.2 for ; Fri, 12 Jul 2024 11:12:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807944; x=1721412744; 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=yTWyT8gKTKays8rE64DnYrzhErijM5o6wos0PD63SLQ=; b=XPt0Sz3bc5GB3E1NZRuWYy8zR6ciwmI9Q7Qt3WY4w9jK9SOFVaiW5f+6Zwxtvg9L0O HwxiwKVfN/9tijFPK6sr48/5bjSxGLbQXCN1x2t7gXm0MvWpGkSRPn/j0X7O42awHIxu PPINkLzJYNTIogySjof6Fauw+Bk3t9+60BmVQ1ukI1YcYJ746nSytCxqDeL4CaC8g9H4 nAGXzyU7kZbh0YwzKAarY90DO5W6GtWA00xiL2zynRhswoLe4ZRBwElwOwmVlUpWknCY QrntscG1bZXim1mvtEgwdybUQ9BfwFuxQPCUQYPM47+CGokoUeOb1ygDhtQoPhMvaE4M DSJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807944; x=1721412744; 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=yTWyT8gKTKays8rE64DnYrzhErijM5o6wos0PD63SLQ=; b=o8e/fMQixDc5XdQF/EqSl5+pAZFiQRIh4ppHS/MCI7+twB5ld+4tz6wzUEjyakPsXt w/+VIcm5LkqZbWtXGDmg1QR/ba5ESk5pJq07NBJjCbRkGojW+YvG01J3EpAt7JUdZVVx srgtamYY3cAFaNbscCeq46DenxL4cfRPzyYtxJ0ETS/KFyUdnzVHLihAZ9gU8LjayheD r4oZG6+t6nHUHD5mceaqhE6rFcIiYZ/k2W89wovE8lHSf39V0a5Cea7VMOBc3xYWGkj8 7HlG3vEid8elW1dbzx2VHdC3s+CKBSFBPW+w6LDFnr/F25MSpaYcwfPFeMRfUIrEfNzh nywQ== X-Forwarded-Encrypted: i=1; AJvYcCU/OkNnX5JMHxiSRSnRSotAkpN2le7HwsJ1gSheIeGBS3qQ3PQ9656z3xECtK5osr6U2ZD8vKzuvX0hNDV1hixEf98W7Pdpf+2uatrZ X-Gm-Message-State: AOJu0Yw11yTOxHj9GY07hDMtgFzgCkb6uDao0GK+TPsiZEONrLlZvMu0 An2+YZ6P4cqar69U+hOxrwE/N4NyvtT9SlJFtpG78YsBw0+3mSubk8ddd5uY5C+aQbt2x9hn4t/ w+TVSVQ== X-Google-Smtp-Source: AGHT+IFDEg4qCvDKsL+VVqYz1OMCn926w9P2XUU2yFncmeWDbh5Ial6YC4Tg3xMQVgD4UPTtY6N8u5MhM92P X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:100d:b0:dfa:b47e:b99f with SMTP id 3f1490d57ef6-e041b0314afmr26058276.2.1720807944323; Fri, 12 Jul 2024 11:12:24 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:47 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-7-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 06/27] perf kmem: 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" Reduce the scope of the tool from global/static to just that of the cmd_kmem function where the session is scoped. Use the perf_tool__init to initialize default values. Signed-off-by: Ian Rogers --- tools/perf/builtin-kmem.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 859ff018eace..b3cbac40b8c7 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -986,15 +986,6 @@ static int process_sample_event(const struct perf_tool= *tool __maybe_unused, return err; } =20 -static struct perf_tool perf_kmem =3D { - .sample =3D process_sample_event, - .comm =3D perf_event__process_comm, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .namespaces =3D perf_event__process_namespaces, - .ordered_events =3D true, -}; - static double fragmentation(unsigned long n_req, unsigned long n_alloc) { if (n_alloc =3D=3D 0) @@ -1971,6 +1962,7 @@ int cmd_kmem(int argc, const char **argv) NULL }; struct perf_session *session; + struct perf_tool perf_kmem; static const char errmsg[] =3D "No %s allocation events found. Have you = run 'perf kmem record --%s'?\n"; int ret =3D perf_config(kmem_config, NULL); =20 @@ -1998,6 +1990,13 @@ int cmd_kmem(int argc, const char **argv) =20 data.path =3D input_name; =20 + perf_tool__init(&perf_kmem, /*ordered_events=3D*/true); + perf_kmem.sample =3D process_sample_event; + perf_kmem.comm =3D perf_event__process_comm; + perf_kmem.mmap =3D perf_event__process_mmap; + perf_kmem.mmap2 =3D perf_event__process_mmap2; + perf_kmem.namespaces =3D perf_event__process_namespaces; + kmem_session =3D session =3D perf_session__new(&data, &perf_kmem); if (IS_ERR(session)) return PTR_ERR(session); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 298B417995E for ; Fri, 12 Jul 2024 18:12:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807948; cv=none; b=upZwJrwE5Uu5FvHZL83hZhryoBPKshLvReH2IUhhvf1yhKrV06onKzdOvOfVaQuuBMjP47Lo4jBW+YXM2L+SNL1YDawbNiGVIjRcXqE+mp0YKwJWa2clPdpHUxuOChTBqmAqaLRg7zVq8Z1t+877/TFsmYrNDLbPbKAlOQL6+x4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807948; c=relaxed/simple; bh=s0Rh4l6oRIEgtvRI2f9plGMJwLFvIN4S58NEHTolpq4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=VrjJ32ZJ981YPFDSYnO455l1XYze4tq2+UF+kMuFcGIqrzpkXhZonwuIblq8vD0k8oTYLms8junMKhjTU8RQ+u9UJeM6oslAfk6LSLaC9j1rqoxmp5cFBgcJI3hwu5Exxe6KjqCGFMazvzyaHTcbGxfaezv59VhSpTZhs2rThyQ= 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=RJzrsft2; arc=none smtp.client-ip=209.85.128.202 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="RJzrsft2" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-64f4b849b7cso37284887b3.2 for ; Fri, 12 Jul 2024 11:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807946; x=1721412746; 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=FzYClsD3sREquZ0ApOheKgsIb1ZvzAHTtY7Hmf1CzXE=; b=RJzrsft243l78GXVPq+dHweIBqAiBJmLNc8heAkqvzPYKPoTXHZwLoET7cLVsYp6YV kui4BTlIUjKxfEM7v+rE1oXESzCT7imPINBQXnEn3N270bgMi9h8cJ22j1nwSnOvbL8v bobYpX1EvKFKH/8upGXSF2LePBF6rdMc1WDfzLN+lJZJosZb7ac8ejRkdPkDKsgOLfWA IjZEHyLteEZYi4f9OIpoBCo5fXvhUatMMc9YcVek+oalhBauCoHTa1qA/iUa8gG0aWvK LidtSgTKGUycrqegzMbpfumfkTTaFrNALGFtE7D/9Cfgua6OmJaGcoCt8NxBOUyJiz3Y jXCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807946; x=1721412746; 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=FzYClsD3sREquZ0ApOheKgsIb1ZvzAHTtY7Hmf1CzXE=; b=tFjOtPZm7UjFuV4+LxaMF4tAtcGh/SgqTTg2si5GMxjMVz8DEvNRs28L/Nd7J1KKHJ Sc8x80nMAHAQZyG5v13zRSW8H1jovTiIUFg63iSNQ7kJeVb1ZZGYxlTkoWgLhVCLNeWK ApeTbZbgMpPbcpXwgk1DQMKn4jdC1gCScJgE5M4j7BmtIKF1w4s9JbnGR/+NBERnskU/ Mz9iid4hkqzPdrIgEKR8g4BCWl014iXn6+5x2cpzVOE205pnwiXyM7y1CMxKxAUMxCAA 5MteR99FJuxA+7pDXZxeHHuSxy8zx5HtEePY/KdM/AXiUjLp6FqcCtmFhLn73E6TqRPO bLvw== X-Forwarded-Encrypted: i=1; AJvYcCVkfh9JJPiqfqQwAK2WeDPZh9CiAPlLsEGDJxELlHqe85Q4dbGUhnTLTtogfySFiVa2XZCPYQdRtHHBhWiRqDZjdq7EG4jnUSed94vD X-Gm-Message-State: AOJu0Yxpsu456UCmGeI7brIYz2fWA87DyJxocrrnliz3rlCqHvu2eCT3 UQ8l07kGBblnMCi5uevZeq/Ge3+2jmlY6zTMSbTpcjJHBzE0Gr6M8tAyTfNAc/fX0YzP+eUceok Y0jDlvw== X-Google-Smtp-Source: AGHT+IGu9ERSnkB72Njm49McR9BnBORB8petqywRDFaMNRJA5XXoPxz9Swd7cbx9vSO/F5mT3cZKr+TqR1MJ X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:f11:b0:64a:bd29:c5cf with SMTP id 00721157ae682-658ee790ee4mr1592817b3.1.1720807946360; Fri, 12 Jul 2024 11:12:26 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:48 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-8-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 07/27] perf buildid-list: 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" Reduce scope of build_id__mark_dso_hit_ops to the scope of function perf_session__list_build_ids, its only use, and use perf_tool__init for the default values. Move perf_event__exit_del_thread to event.[ch] so it can be used in builtin-buildid-list.c. Signed-off-by: Ian Rogers --- tools/perf/builtin-buildid-list.c | 10 ++++++++++ tools/perf/util/build-id.c | 32 ------------------------------- tools/perf/util/build-id.h | 4 +--- tools/perf/util/event.c | 20 +++++++++++++++++++ tools/perf/util/event.h | 4 ++++ 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid= -list.c index 383d5de36ce4..52dfacaff8e3 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c @@ -89,6 +89,7 @@ static int perf_session__list_build_ids(bool force, bool = with_hits) .mode =3D PERF_DATA_MODE_READ, .force =3D force, }; + struct perf_tool build_id__mark_dso_hit_ops; =20 symbol__elf_init(); /* @@ -97,6 +98,15 @@ static int perf_session__list_build_ids(bool force, bool= with_hits) if (filename__fprintf_build_id(input_name, stdout) > 0) goto out; =20 + perf_tool__init(&build_id__mark_dso_hit_ops, /*ordered_events=3D*/true); + build_id__mark_dso_hit_ops.sample =3D build_id__mark_dso_hit; + build_id__mark_dso_hit_ops.mmap =3D perf_event__process_mmap; + build_id__mark_dso_hit_ops.mmap2 =3D perf_event__process_mmap2; + build_id__mark_dso_hit_ops.fork =3D perf_event__process_fork; + build_id__mark_dso_hit_ops.exit =3D perf_event__exit_del_thread; + build_id__mark_dso_hit_ops.attr =3D perf_event__process_attr; + build_id__mark_dso_hit_ops.build_id =3D perf_event__process_build_id; + session =3D perf_session__new(&data, &build_id__mark_dso_hit_ops); if (IS_ERR(session)) return PTR_ERR(session); diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 098fcc625d91..451d145fa4ed 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -67,38 +67,6 @@ int build_id__mark_dso_hit(const struct perf_tool *tool = __maybe_unused, return 0; } =20 -static int perf_event__exit_del_thread(const struct perf_tool *tool __mayb= e_unused, - union perf_event *event, - struct perf_sample *sample - __maybe_unused, - struct machine *machine) -{ - struct thread *thread =3D machine__findnew_thread(machine, - event->fork.pid, - event->fork.tid); - - dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid, - event->fork.ppid, event->fork.ptid); - - if (thread) { - machine__remove_thread(machine, thread); - thread__put(thread); - } - - return 0; -} - -struct perf_tool build_id__mark_dso_hit_ops =3D { - .sample =3D build_id__mark_dso_hit, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .fork =3D perf_event__process_fork, - .exit =3D perf_event__exit_del_thread, - .attr =3D perf_event__process_attr, - .build_id =3D perf_event__process_build_id, - .ordered_events =3D true, -}; - int build_id__sprintf(const struct build_id *build_id, char *bf) { char *bid =3D bf; diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index ae87c4c58d5b..a212497bfdb0 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -16,11 +16,9 @@ struct build_id { size_t size; }; =20 -struct nsinfo; - -extern struct perf_tool build_id__mark_dso_hit_ops; struct dso; struct feat_fd; +struct nsinfo; =20 void build_id__init(struct build_id *bid, const u8 *data, size_t size); int build_id__sprintf(const struct build_id *build_id, char *bf); diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index c2f0e7f40ad5..aac96d5d1917 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -426,6 +426,26 @@ int perf_event__process_exit(const struct perf_tool *t= ool __maybe_unused, return machine__process_exit_event(machine, event, sample); } =20 +int perf_event__exit_del_thread(const struct perf_tool *tool __maybe_unuse= d, + union perf_event *event, + struct perf_sample *sample __maybe_unused, + struct machine *machine) +{ + struct thread *thread =3D machine__findnew_thread(machine, + event->fork.pid, + event->fork.tid); + + dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid, + event->fork.ppid, event->fork.ptid); + + if (thread) { + machine__remove_thread(machine, thread); + thread__put(thread); + } + + return 0; +} + size_t perf_event__fprintf_aux(union perf_event *event, FILE *fp) { return fprintf(fp, " offset: %#"PRI_lx64" size: %#"PRI_lx64" flags: %#"PR= I_lx64" [%s%s%s]\n", diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 4b24f1c580fd..f8742e6230a5 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -319,6 +319,10 @@ int perf_event__process_exit(const struct perf_tool *t= ool, union perf_event *event, struct perf_sample *sample, struct machine *machine); +int perf_event__exit_del_thread(const struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine); int perf_event__process_ksymbol(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 53CD017A5A1 for ; Fri, 12 Jul 2024 18:12:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807950; cv=none; b=pWl5K7yaazAxAhNpxzjmozTVI+FZD3JZeCtXMnckbRIHqcIXsQxUL2e9SXBB8O0hFzujXL5LQnrwlIwBphLdMrWIrCQ1SqXXaEEx8Sip99WtRxOQt3rS/XBf5NGsLQO/l329yfRsS7LYHb15cUJyZzMQYWupd833khGPjF0TsAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807950; c=relaxed/simple; bh=R2cr19QUh/0PZGh9ohFFVIVNT0Cp0G9UBlrYuAQOwdI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=HaZpATrsNGP2ur2HtzY6suNKlskzGEOui+cbUUovoJbl3B0TVL+I6k/iHia6iqzUk13J/yL7JVGEhGxA2V5muPJJt//dsTtuCa9o/VaedHy7lqXplphBxYHP0NwhxJ+DRPIeE+trZ5RrerCc3Fk8m7H7hsVFEeuwtRL2dZXfOUw= 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=EK/OhTau; arc=none smtp.client-ip=209.85.219.202 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="EK/OhTau" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e039fe0346eso4189858276.1 for ; Fri, 12 Jul 2024 11:12:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807948; x=1721412748; 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=byfF1KS0n4MzwFOMTsFSRoLAA/Zhxt2Mi8AKEzVn+O0=; b=EK/OhTauSZzIU5BMw+rGHnwzVqGOZT8XBr/FhjavtEZrs4Y2do5ngoe4iJVa3Jthmy OUBxUl553RvmKiAuuvxapLOx5/1oGoJxeWoDLTJ+OeIpHBXPziUN9tjpg4ql2Vg4DzL3 4FkBHSoN5KQnzJvHqN3OK7NdBrg7vw3Wv1VVrtSnciRrm+zRrrJ6EYyS7pmDXF3bGc5j 854PgRC4EzbKeEWzjB978lA7oJmeHJS3R8Gkac0AQq5LU02oYdnLorFy1N/++6s7j8WW DtVCskyWra+FEXXbGlO9bymFtbGcchOO9ZjbpIfixD7h2uwA+UDHiM+ImGC53E4S4grS 6C/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807948; x=1721412748; 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=byfF1KS0n4MzwFOMTsFSRoLAA/Zhxt2Mi8AKEzVn+O0=; b=HA9GATVXhhQ2UZvODX+A2uFS4r4O3u1OBehYQz5S6WyTADIMGSm+1/GplnaizQ8YAZ 3OAhRarEbVsHkWC6ogF6KkmlRvwjeIezHUvfHeUe6/pfrc4hjN++pibr90QEh9koFX90 R42mleYpb4qIvvc5RZnP/Lm18grLEbuSyv4oc8Hm5cRrNcQEYFE0i/UHiYDsvE/Oy5NU U5OtJByhiP1U1gjppIzD9IQFVck9nAKZmuX/CFdgew2Jus4ioEjaerSwmGouwHfG6XuF i9BI2WLD2iN0vBV4jzZydlOJ4STJJKLkktOoKHq7q1NQYqVi8c5Yl5Yo1N6apxX13HaF 9CHg== X-Forwarded-Encrypted: i=1; AJvYcCXlVYJ14Hqqv9qMrPoHbtQO7R7xoqXVoFWTQcjXP7n0t8RqRESoCixcdtnRdFTAcEwoxxClGFlUrohL1wopePVMQcpHBtBKgCV4mSVN X-Gm-Message-State: AOJu0Yy5p6uFYAQwHNkrztaW0sSx9EcgNSgne1o5iW68lLMLCSbY1dSV j+vbG+SIbuTd86Xqj/XeWEGuBMXas5qpPtci0yffUewJ6g57NmkRcSRJneFyYDt9aVpvhjLBpGe 4fvc18w== X-Google-Smtp-Source: AGHT+IEDxd6QeNUvZWRQqBsrbT8Osq0gxiaqUBWAnKcNrHvP+zbFleqnJBw9O4ojwhJ+vbzxebyogc6l9y+y X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:228e:b0:e02:c06f:1db8 with SMTP id 3f1490d57ef6-e041b051473mr24667276.4.1720807948405; Fri, 12 Jul 2024 11:12:28 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:49 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-9-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 08/27] perf kvm: 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-kvm.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index a3b903cf4311..692267b1b7e8 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1603,19 +1603,17 @@ static int read_events(struct perf_kvm_stat *kvm) { int ret; =20 - struct perf_tool eops =3D { - .sample =3D process_sample_event, - .comm =3D perf_event__process_comm, - .namespaces =3D perf_event__process_namespaces, - .ordered_events =3D true, - }; struct perf_data file =3D { .path =3D kvm->file_name, .mode =3D PERF_DATA_MODE_READ, .force =3D kvm->force, }; =20 - kvm->tool =3D eops; + perf_tool__init(&kvm->tool, /*ordered_events=3D*/true); + kvm->tool.sample =3D process_sample_event; + kvm->tool.comm =3D perf_event__process_comm; + kvm->tool.namespaces =3D perf_event__process_namespaces; + kvm->session =3D perf_session__new(&file, &kvm->tool); if (IS_ERR(kvm->session)) { pr_err("Initializing perf session failed\n"); @@ -1919,14 +1917,13 @@ static int kvm_events_live(struct perf_kvm_stat *kv= m, =20 =20 /* event handling */ + perf_tool__init(&kvm->tool, /*ordered_events=3D*/true); kvm->tool.sample =3D process_sample_event; kvm->tool.comm =3D perf_event__process_comm; kvm->tool.exit =3D perf_event__process_exit; kvm->tool.fork =3D perf_event__process_fork; kvm->tool.lost =3D process_lost_event; kvm->tool.namespaces =3D perf_event__process_namespaces; - kvm->tool.ordered_events =3D true; - perf_tool__fill_defaults(&kvm->tool); =20 /* set defaults */ kvm->display_time =3D 1; --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 AE18317A92F for ; Fri, 12 Jul 2024 18:12:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807953; cv=none; b=t3t4q4qC9irnE8KcSPx97H/7naHBrgDX2TbujjpO2ty0ANgFg1ZvjxVjWioCctcB9M6IA7rJCG3hgg0yVbrqml07dnCT12sUUUUcRbUhVdmQtqn++vXcxM7Vf9f+o5siMgB49Lrg2uRLX2pMiM1YvzhFJwW9NL0wA3HAMjARxBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807953; c=relaxed/simple; bh=LWeT84SQaD/ZqxsdujULbunWNxfNaZERjhKf3ganreg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=BQYN7c4TDQilzL6WXH/EbqtDab9rnpFwctUFC70+p/TEh8G84D4BJV32nHw11tbFYIkK8SY8ecUTfAoABm9fg280GRTYWhc18mktkhZocM0aoC7ji+NoX+NFaaGb/2w8EPmmiWlA+WK3CoVh3KCYH+UNSSg92Iv2MN+wcpkHx6M= 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=3wbr92Zo; arc=none smtp.client-ip=209.85.128.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="3wbr92Zo" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-64f4b849b7cso37285717b3.2 for ; Fri, 12 Jul 2024 11:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807950; x=1721412750; 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=jf/366lvU4AUPtbGBpn9zhF7c/C+EcohgCe44YuCQ7Y=; b=3wbr92ZoWcB9ueDv6oKidA3jdtZEPVFK+TxOSUOUL0E71QA+F0oI0J0NzZBxzXxbYp qNphE0IhHEHk2VZSvwLKvYuCTRqLB2VwG/UbuV4u2hYQ8pNQHY14CoygDk/W2bg3L5AS E07A1BHRqTpUPQCV9Tt4Okr+K+dotW9qLp+crlhmjulCaG69xJ1HJqUa1uI24eVbTMza xc1xZjtUn438kqAgKqoiosVxOOtszkCDy3Mr3t3n/VLh3XbHLseYtJD+aC0/nqAMS+iQ cowkGKmM2BPqpsDEhHlyrVfEaFiUEvxalH3P4IEwERaxvh0Kh7rXyrYQ2M7Pos1Dd/k6 UJ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807950; x=1721412750; 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=jf/366lvU4AUPtbGBpn9zhF7c/C+EcohgCe44YuCQ7Y=; b=JHQ31ud4LvKZVcMqBRKtljAltcokg1M9MxhRWVJqah3H5Zw2M2Ww7gxa8is96ZvQTl yPOw4A7S+i1EEi73SETR2QbBH1/8Wb0DmCt8i4A+YMQYvL84ED2LdO/w1RHxVnZmiJem ep5cVc8IisK3RIBvonz9SYEWPUn4MUeK7y+68J9LIL8ETvR7y+gpZ04D7+Ynlt0d0ZAe Bba7BryYWlN1NNpHa9FtdJXNoAzmdqPhK43Bgh7mjAtjA2u8ou/KJSjttoQO8Bk2qOsW gEV7SQkWKAzcZ+gigrtuR7jNkjGh34ur9hNrjkCz3mFJWmoy3slaWudRKWL/CXj45Tuo 2D7g== X-Forwarded-Encrypted: i=1; AJvYcCXVwAf5pZ4IgvpsuMW8hTNZXz9+uVDwKpHt3pdup+PDiac/5GT2CMDHDUfHTNhwY93XrOCRn/2qQShiuOvlD5suoyfYez/rZZrISaLQ X-Gm-Message-State: AOJu0YzXYYYd0kJe9bk+G4rfi8diQxzhleXeL2nVIkZnhksruFwPeZEj fA6XbPPE2MPbpTvaFUTMRgjw1yOI5x9uAt/cMTFpcK+zToBY+lLCpM0SaHhmIrGyF+q1qo0N2hF atdRZsg== X-Google-Smtp-Source: AGHT+IFlsKuGpxVNyWoLObgwAYJDkigpd5ozGArlXoag4yrjnwDea6v3GSNUcs145Zpeoo6bG+3lCKfvRy4y X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:25c5:b0:62a:4932:68de with SMTP id 00721157ae682-658f06db413mr2068187b3.8.1720807950582; Fri, 12 Jul 2024 11:12:30 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:50 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-10-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 09/27] perf lock: 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-lock.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 6efa9d646637..2c216427e929 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1933,22 +1933,21 @@ static bool force; static int __cmd_report(bool display_info) { int err =3D -EINVAL; - struct perf_tool eops =3D { - .attr =3D perf_event__process_attr, - .event_update =3D process_event_update, - .sample =3D process_sample_event, - .comm =3D perf_event__process_comm, - .mmap =3D perf_event__process_mmap, - .namespaces =3D perf_event__process_namespaces, - .tracing_data =3D perf_event__process_tracing_data, - .ordered_events =3D true, - }; + struct perf_tool eops; struct perf_data data =3D { .path =3D input_name, .mode =3D PERF_DATA_MODE_READ, .force =3D force, }; =20 + perf_tool__init(&eops, /*ordered_events=3D*/true); + eops.attr =3D perf_event__process_attr; + eops.event_update =3D process_event_update; + eops.sample =3D process_sample_event; + eops.comm =3D perf_event__process_comm; + eops.mmap =3D perf_event__process_mmap; + eops.namespaces =3D perf_event__process_namespaces; + eops.tracing_data =3D perf_event__process_tracing_data; session =3D perf_session__new(&data, &eops); if (IS_ERR(session)) { pr_err("Initializing perf session failed\n"); @@ -2069,15 +2068,7 @@ static int check_lock_contention_options(const struc= t option *options, static int __cmd_contention(int argc, const char **argv) { int err =3D -EINVAL; - struct perf_tool eops =3D { - .attr =3D perf_event__process_attr, - .event_update =3D process_event_update, - .sample =3D process_sample_event, - .comm =3D perf_event__process_comm, - .mmap =3D perf_event__process_mmap, - .tracing_data =3D perf_event__process_tracing_data, - .ordered_events =3D true, - }; + struct perf_tool eops; struct perf_data data =3D { .path =3D input_name, .mode =3D PERF_DATA_MODE_READ, @@ -2100,6 +2091,14 @@ static int __cmd_contention(int argc, const char **a= rgv) =20 con.result =3D &lockhash_table[0]; =20 + perf_tool__init(&eops, /*ordered_events=3D*/true); + eops.attr =3D perf_event__process_attr; + eops.event_update =3D process_event_update; + eops.sample =3D process_sample_event; + eops.comm =3D perf_event__process_comm; + eops.mmap =3D perf_event__process_mmap; + eops.tracing_data =3D perf_event__process_tracing_data; + session =3D perf_session__new(use_bpf ? NULL : &data, &eops); if (IS_ERR(session)) { pr_err("Initializing perf session failed\n"); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 C821617B40E for ; Fri, 12 Jul 2024 18:12:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807955; cv=none; b=mk1P98sNr07D+Li8s2R+2XVbnw7vOSVeWcOpHnQcLPZMGtEuejr2Cg6j5NWNPLbwd0w4xOU2M1BCg1vfU9PvgDqvS4aXnDaD3V8paBRZdR61RndtmYEqEDtip1d3B1nuHTRNxnEU7Y9MWUveSEb7TjiG6MqbSNXgP6606eyPNkk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807955; c=relaxed/simple; bh=5L2/QmV0UtQIb+mYzp5cKQ3gtaLl7JsRv/EFzdZAMCU=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=KrTPPtPNmmkPXRcHvx/gyFAHD4ZH6dVsXvVuunWiNffjemTpMFaCzykbMcn0gYwdCpFTECvP8mJlH1UlLwjBQvUiXLAPgXohGI1IOpb/9JFb+Jws1IekeDg5u3nH3QVSU87UW+TJxlz6TcxaPPsZXqeP497UF7cM36oCwafuKbQ= 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=jGNGynvT; arc=none smtp.client-ip=209.85.219.202 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="jGNGynvT" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e03fe45dc0bso3904637276.0 for ; Fri, 12 Jul 2024 11:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807953; x=1721412753; 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=h8vxN+BliJztZySzkr/g5CS+2PgB0g7RSTmLzIMrgEM=; b=jGNGynvTj0Cz1FibCSuMBAt80y7S0syWA2f+nwkor+oqqTTeg3gStwTF66McR7QMRf /Exwga0usnxl6chNl6MQ7IRq1IIz/Rly1vw9s0xqhunuQD21sywwUneLcRtqb/4G6xpn rPD7yexfAHu0hH7SiRVPNPr7Gop+9nkbQmh01fd+rcP75lvVjurXxhGtcQOGymwyfIqU Xqh1ArDTiKN71SzBrksi9SWmrvAe5k+nZHzsMGU+5l4FilvR2xv5qNZdPWjiSQweieOa vOQ/peSdvFEX2GU+XQGTorw/QI7Z2rgSkEMeWU8W0iyBAGqaY0GABrxjvCkouH289b3H WhFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807953; x=1721412753; 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=h8vxN+BliJztZySzkr/g5CS+2PgB0g7RSTmLzIMrgEM=; b=i4CAOy30C+A8QlSMWEBBH9pCdV3OscFj0IV+snrkQ4B95ANgN2nuPGhthifMaQQRux gdKjUPxxQs/gJ+d1VYgPHRgBiTINks1X2LGZf/ueTxXVi4reDDsNCMpcT3IxlByRvRi3 j9Ytv3QcOSbmEbqU6gKblDN6F/xdALgtqEBvahYWwPLFlKVjLGD0gVYb5AcDIWP2zUd5 UWdeGC1JBWUpa7fCzHwSn32zAfmHUOA0ujfDm8yh4mDkWTEL7wQSIdIOoIKZ0tqf5EG9 S8evh4t+GswzVVf6J2IhzJPdbd3uUV9x6R+TB7iiZa4Unr3tEPKTnT3Tm0MALYk1hCy1 QK3Q== X-Forwarded-Encrypted: i=1; AJvYcCW6gT19c48tvlGby9UApA4yVzO7HJsUbCQcfDPIUtpn+hBjI5Si2xbeGqYIvfY5XOUklhR8ZPVqTLJPQIq9az5r+vDv90ecIhUhUrpU X-Gm-Message-State: AOJu0YzLufpw9gPemIIjaEDAEThKDOGy+6Utur1f775h7NlGO7IO0ha2 hm2Hr2GePqT7w7+i3sDUdYrEtZPnlJDelpld+gXQNApmemxmBjJ162Jhcp8om9YL+PN1qEikJGJ 75HEZNg== X-Google-Smtp-Source: AGHT+IFvEFbuuviGSmLFXUVSDoQ/Q3jbvrU0W1ZoOeFfj2ue4Hk0CIvrQDw/sTMW/RbAltKLHza9t11YT2eW X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:260d:b0:df7:9ac4:f1b2 with SMTP id 3f1490d57ef6-e041b04f0a6mr910569276.5.1720807952786; Fri, 12 Jul 2024 11:12:32 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:51 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-11-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 10/27] perf evlist: 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-evlist.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c index 7117656939e7..818ab21c3f73 100644 --- a/tools/perf/builtin-evlist.c +++ b/tools/perf/builtin-evlist.c @@ -35,13 +35,13 @@ static int __cmd_evlist(const char *file_name, struct p= erf_attr_details *details .mode =3D PERF_DATA_MODE_READ, .force =3D details->force, }; - struct perf_tool tool =3D { - /* only needed for pipe mode */ - .attr =3D perf_event__process_attr, - .feature =3D process_header_feature, - }; + struct perf_tool tool; bool has_tracepoint =3D false; =20 + perf_tool__init(&tool, /*ordered_events=3D*/false); + /* only needed for pipe mode */ + tool.attr =3D perf_event__process_attr; + tool.feature =3D process_header_feature; session =3D perf_session__new(&data, &tool); if (IS_ERR(session)) return PTR_ERR(session); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 A481117B426 for ; Fri, 12 Jul 2024 18:12:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807957; cv=none; b=S+xEkTHksuspPuIIjbAWByd+10yj3bWWXLdOZAEHzU/UeGp7+oab3MBUB6qWChx0fiKK0ehqDIl0kMqqs2I6o+232+X6/gvWMdVG8SfyPTUQg5jAJ2hQVd1FEDNgXOCxl+ecva2x40tnBq8GOoISHpl3JG2QlX3XQ4zQQ0Od2sE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807957; c=relaxed/simple; bh=PB51RKImsC3lHPo6fW3ScTVlasWqH0blF1j09wP+J1U=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=c7XpC+Bb7Z1w6IsUiPSqts1EZqG09Cw74zMeQMWG2DPNjxGqOsjfmxtBemEdSmUPhjfIYnHIwR2OGLiZ9mt0OPQ9vJcpJEnikNxkH0fr13rsK2Q6ZHUXrdoYDtaBA21oy9lXnzL5URi6dMnCfGuG2LD+3aLqFTt6j5Mcvd/myeE= 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=zLS0Dulk; arc=none smtp.client-ip=209.85.128.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="zLS0Dulk" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6502e4c5aafso27176677b3.1 for ; Fri, 12 Jul 2024 11:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807955; x=1721412755; 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=W3N+sXEIdDW4FZ9MEavkeCx7Ak5mBAvz0H4sFCDbHeI=; b=zLS0DulkNiPjIzwZEfrNkafhuYq9lp8559BiAfy8u2cR05sblxZ5RwEEp/aEpyJDg/ E0DT0ZlNfSN19/IpnMMI4IuM49O2G8BNA73heYW55vL0p53stIfg4n/6koUbLXZKE3uU CD8it3zvNUhcXreDEZ4mMgcJ5eHPuPsOqEz5tnkdfSSY+uCQ6VCcj7WjWf5WFx/LRL9S ZZJ17TUL8oPm0v8SuyH2xocWDuiuYrbOuHLSXcuPKP2f82LA/wyy2But/ArkWCT/tk+D czbjCVwfq8ki4pQpRDDYxRdQ2BQbsmwEsIv7vnAU+GxATz1giJasKTi9rbttJwRGQEAH x8bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807955; x=1721412755; 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=W3N+sXEIdDW4FZ9MEavkeCx7Ak5mBAvz0H4sFCDbHeI=; b=P4BFohJAkCT+VfQaMF35Jnj7SHpFMaz3jT6/9Ad8LplEQeTPbR8f0Cok4n4dnFhRwA /HwKzK/WkAPK4SgdKWN5sWwaMwqTHcBQXSnFHsXbvflOocMQurgrJbJnq4V/xx4ntDpS J9PrQOiLN5///THgTP190XszfGpZDTaeAbXis6fgsj+FNI67Y3X1ccEmx87edzABPuk4 SvPbswfYVxe6VMezMoZnHTHjG/F4i9ppdOP9h4VRYHm//uwM2MOa6mCNQ2ZddQ36PjQw GgVhW2DJYOvOq8jhfBRZaM6KZawDJzgIqwauyTW/LCNz7IzljSDDfKxlHKfFDkpO+EBk N0LA== X-Forwarded-Encrypted: i=1; AJvYcCVa3wlXVvkuxSmmOPCxPENrHBVYqA1mPmgcpUJpFhi2l2ZLJIMl0Xj+kpsFoARlY7vrIl54NBP1WTre6A5y59BbVetpc5TeV6LrgxVV X-Gm-Message-State: AOJu0YyL7pjJD/ezWlDy5cRXC6hlrWeTJRBzfG3/pGiZAcGiQ2qkwzZB SkA487YkA3HNcXx/QMMtEv/Xf5g5yQvWYAYoqSRxIDrWfMRag1zx97CERW4x4OyqhsFq9xJY0kr 55FWMrA== X-Google-Smtp-Source: AGHT+IExEZhqBBcIexchHpBnvFmTKUgMli03JoYZcn32JuoHYiPGuJJ58g8CD6QprTxwGaZs6P7o4XHXSCM9 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:dd3:b0:620:32ea:e1d4 with SMTP id 00721157ae682-65df661ceb7mr703737b3.0.1720807954828; Fri, 12 Jul 2024 11:12:34 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:52 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-12-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 11/27] perf record: 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-record.c | 33 ++++++++++++++++++++------------- tools/perf/util/tool.c | 10 +++++----- tools/perf/util/tool.h | 6 ++++++ 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index f27f725913d7..12a5170d9193 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -193,6 +193,15 @@ static const char *affinity_tags[PERF_AFFINITY_MAX] = =3D { "SYS", "NODE", "CPU" }; =20 +static int build_id__process_mmap(const struct perf_tool *tool, union perf= _event *event, + struct perf_sample *sample, struct machine *machine); +static int build_id__process_mmap2(const struct perf_tool *tool, union per= f_event *event, + struct perf_sample *sample, struct machine *machine); +static int process_timestamp_boundary(const struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine); + #ifndef HAVE_GETTID static inline pid_t gettid(void) { @@ -1458,7 +1467,7 @@ static int process_buildids(struct record *rec) * first/last samples. */ if (rec->buildid_all && !rec->timestamp_boundary) - rec->tool.sample =3D NULL; + rec->tool.sample =3D process_event_sample_stub; =20 return perf_session__process_events(session); } @@ -2386,6 +2395,16 @@ static int __cmd_record(struct record *rec, int argc= , const char **argv) signal(SIGUSR2, SIG_IGN); } =20 + perf_tool__init(tool, /*ordered_events=3D*/true); + tool->sample =3D process_sample_event; + tool->fork =3D perf_event__process_fork; + tool->exit =3D perf_event__process_exit; + tool->comm =3D perf_event__process_comm; + tool->namespaces =3D perf_event__process_namespaces; + tool->mmap =3D build_id__process_mmap; + tool->mmap2 =3D build_id__process_mmap2; + tool->itrace_start =3D process_timestamp_boundary; + tool->aux =3D process_timestamp_boundary; session =3D perf_session__new(data, tool); if (IS_ERR(session)) { pr_err("Perf session creation failed.\n"); @@ -3326,18 +3345,6 @@ static struct record record =3D { .ctl_fd_ack =3D -1, .synth =3D PERF_SYNTH_ALL, }, - .tool =3D { - .sample =3D process_sample_event, - .fork =3D perf_event__process_fork, - .exit =3D perf_event__process_exit, - .comm =3D perf_event__process_comm, - .namespaces =3D perf_event__process_namespaces, - .mmap =3D build_id__process_mmap, - .mmap2 =3D build_id__process_mmap2, - .itrace_start =3D process_timestamp_boundary, - .aux =3D process_timestamp_boundary, - .ordered_events =3D true, - }, }; =20 const char record_callchain_help[] =3D CALLCHAIN_RECORD_HELP diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c index cbd9b888bd73..a4ca16e5eefe 100644 --- a/tools/perf/util/tool.c +++ b/tools/perf/util/tool.c @@ -99,11 +99,11 @@ static int process_event_synth_event_update_stub(const = struct perf_tool *tool __ return 0; } =20 -static int process_event_sample_stub(const struct perf_tool *tool __maybe_= unused, - union perf_event *event __maybe_unused, - struct perf_sample *sample __maybe_unused, - struct evsel *evsel __maybe_unused, - struct machine *machine __maybe_unused) +int process_event_sample_stub(const struct perf_tool *tool __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_sample *sample __maybe_unused, + struct evsel *evsel __maybe_unused, + struct machine *machine __maybe_unused) { dump_printf(": unhandled!\n"); return 0; diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index 897c6c44b6b2..fb7e32d98dda 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -93,4 +93,10 @@ void perf_tool__fill_defaults(struct perf_tool *tool); =20 bool perf_tool__compressed_is_stub(const struct perf_tool *tool); =20 +int process_event_sample_stub(const struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample, + struct evsel *evsel, + struct machine *machine); + #endif /* __PERF_TOOL_H */ --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 0CBFB17B4ED for ; Fri, 12 Jul 2024 18:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807959; cv=none; b=d6l4aATQOI3gZOMaN4FBak4xzw98ogWLi7iwd3St7/B/i3IVphxi5nOHo1RlYHxGv6+Q+qOnqKWEEcYpeuTZU9ok1FWmsLZH9egUpEDiw/V8xZ9313TiyPx20uvseabQd+f94wsyQmha6yTIBE/74Ak+QpZ4mn/F6yYCJuKUDx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807959; c=relaxed/simple; bh=QyWrdcj/7yIk1kCDwEAAgyYccYi84Zy4FDV3Stu0DB8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=flRO4+vsTdPpZVL5U0pdKYcEzxXIhtxCfjrWtIaNLhGj8jOcSUz1Mp0QwZX5Fu7ht/EbK655ovQE4CkeJYvz75kcWYEVxDjw7dsL3cmvkogVcmeuzEBVY7aLrFpsixNBnVs92YzkVDlvivxuPEmuz/gYzym8mqKIO479B6bBPvM= 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=Sm1y1/AX; arc=none smtp.client-ip=209.85.128.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="Sm1y1/AX" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-64c3f08ca52so34518357b3.3 for ; Fri, 12 Jul 2024 11:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807957; x=1721412757; 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=GLiukIuXpfj1RuwI+7tVJ3j4buaKUCfjcNd2gIIAnuE=; b=Sm1y1/AXL5FUzoJAYL23KIr4Hm3zGbeSjA8xgo/yb03vyoe8AVxlVzxypDj+VfPe5B oVlH4lHmHLVoMXmkX5kBV9vbRSQEY27XfAD9r3yhWUzeXwkBEStDnl5Xr7a14rKLTzcS uCDx/xcSrBglEYP2H7fa/W5FxYYjMpdvdRvC/tNyFqAsx7LPcNt+hlH5wTXLx2ft3qTH DH9qBNkZMHFxaoxpqxT9kXiVa4aBlN1tyhQHqMCp2seTbvNa8H4eep8BJRDZXI1cq+i/ UKmFBjGCoHdzRL9WILUcwmt2+NqngWJApzmAJUy7uNsZ9l672HlFq6FBZiVQ9lQeO1p9 I/VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807957; x=1721412757; 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=GLiukIuXpfj1RuwI+7tVJ3j4buaKUCfjcNd2gIIAnuE=; b=PdfxanvhRGuoRF8B0D2tTpkfvAg+JTrHbyZr3rSyc4q1v/jsu8c48frUCf3/Hh6/h5 +9We3FsZHyL+KnHGz+1Qe3ZrfquXWMWu566xO4dbHK1enANERtTaeQz0UAu3lP4cwnZP UG9piVLwiROcR3JW7fVtIikGL8/YhcEZvslSZanpQTmXOMmHbfofvQv6UdzWNynZ51u9 PyrlenR1c6HomaeRgsTfdHwyA8esZAAKmvKdXcHgynuCKL7MVHltKNU7fNLgtjG0O2C5 XlHuWSwsDdOY7dYYk96qROI+Irpmf8mTScm+F//bz8E4vkPG3a7HV5GIKZj8ws3Io47g 3hkQ== X-Forwarded-Encrypted: i=1; AJvYcCUVrQ173qFvZMpD9TvMHM5d9zjk17TgrweLODeSPpu8yqCOtFmPrivO6WU6gIPvaUoqyAjHcvDSLQunNlAhFUGpH+Y4H8uPviH2d2Lo X-Gm-Message-State: AOJu0YxZGo88WvmVfsJ9xsQnOv87p9qf2Ss8UeSmO5OsuMbN5rzHi6qf oREADtsblXxCkHT1V8zwee6aj007fJ/XTMUHQBgUT47VzFYdEvdqEY+FRJmrqG+azef5uxp7Bvv cHD1tCQ== X-Google-Smtp-Source: AGHT+IH4uAq+0GE3bX9Ncu3ZBlmhnrDD+38cgOfHCMtyr/CPZ8u/8k78H/BkrIM5m6XYB9naIU9QLIw6gVAU X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:660a:b0:64b:683f:795e with SMTP id 00721157ae682-658ee5a10abmr2551797b3.2.1720807957092; Fri, 12 Jul 2024 11:12:37 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:53 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-13-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 12/27] perf c2c: 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-c2c.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 88c131d05186..cd2bd573bfc3 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -385,24 +385,6 @@ static int process_sample_event(const struct perf_tool= *tool __maybe_unused, goto out; } =20 -static struct perf_c2c c2c =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, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .lost =3D perf_event__process_lost, - .attr =3D perf_event__process_attr, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .auxtrace_error =3D perf_event__process_auxtrace_error, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, -}; - static const char * const c2c_usage[] =3D { "perf c2c {record|report}", NULL @@ -3070,6 +3052,19 @@ static int perf_c2c__report(int argc, const char **a= rgv) data.path =3D input_name; data.force =3D symbol_conf.force; =20 + perf_tool__init(&c2c.tool, /*ordered_events=3D*/true); + c2c.tool.sample =3D process_sample_event; + c2c.tool.mmap =3D perf_event__process_mmap; + c2c.tool.mmap2 =3D perf_event__process_mmap2; + c2c.tool.comm =3D perf_event__process_comm; + c2c.tool.exit =3D perf_event__process_exit; + c2c.tool.fork =3D perf_event__process_fork; + c2c.tool.lost =3D perf_event__process_lost; + c2c.tool.attr =3D perf_event__process_attr; + c2c.tool.auxtrace_info =3D perf_event__process_auxtrace_info; + c2c.tool.auxtrace =3D perf_event__process_auxtrace; + c2c.tool.auxtrace_error =3D perf_event__process_auxtrace_error; + c2c.tool.ordering_requires_timestamps =3D true; session =3D perf_session__new(&data, &c2c.tool); if (IS_ERR(session)) { err =3D PTR_ERR(session); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 3741717B50D for ; Fri, 12 Jul 2024 18:12:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807961; cv=none; b=V9CFibKBAXoqjM55htAngHMKvC6tuzC7FbBt2fE0RPtHh21T0X4guchi5O+j2sDaUVqsLStNi21JenHQaDm8vIPkWKHDtka+DIP/3MRAs85IAncT+QYMXZECah/lMyiMtQ4OlpREmeB513R83JgWatfDBzQR00rP9LPRzR46/ng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807961; c=relaxed/simple; bh=gdWytOna78avdV8ta1mlF796MEMlXufN3RbPM1j+MUo=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ZOjnWt3L8UsXWvACQRMmVFZwYxQNf8rSPFrkgZkNnEArXom1xGgtgtpxMhgJIu02B6KkUvHn8IBJp2XpEJDYSZ1RITfJ+4QxbQlj4yoYDosWxYn5O5G/G8rkxJvQtvFT45vBlREHOtE0+3gLskfCZzBFLC6hgSpvRbpmXeiOCQo= 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=aeYFLDj0; arc=none smtp.client-ip=209.85.128.202 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="aeYFLDj0" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-64b5588bcafso39766207b3.1 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=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=aeYFLDj0olUKf9HOKySFHWrUNisKcR1hz2njupqtn94EDMF/OQv4O9zJ2XCoe/b96W 4gzf2iLJ5mIFcRCOu5ieMHslWpOD4lQe/srwUwMfIoQBt+WkmmiuheaaCA86DOFl5wOZ vN7qsbHkYnYzSQnFV3x4bhJOpSNphXia1wvY7oAokuP6A2b+hLI/ZJ25MsLDOL6/EZHr 1iILpzz1FYnyev5h6cWFFxMJXZmqYkFB0bMvAxUsSdwFsU+3YehGsnplIHS92O/DEbdf 8Po+29euvgRHgQuRyBdfhju+YndiTFmrEvPrNgM8FePQPU1Z5nlLowTfk3cw+NeHi2Bo 5pwQ== 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=Z0wVTO2o7m+6a7WoHvMo1Y47YmaKH6ma6v5rT8+56FVaX/OBZ4Lob+vt06pPsRk3ih F8EESN9qihS5hmLgGcxfGQHcXDbzzP+aWXyoGhX20ZffZtfQtX9fk39pcf05MrNr3Fp6 4K9t0BCjrQqnbEnwBkXJCO15liWPqcjpEU0Hn/hRTd7pnvUcvct+QnwRgc1fo3ztlFiU lnbRGr5mYpfUhPnj/8PSZjv3R4mzRoMqm1I8vsVdm71fyg7zJM30TE24wONbmJhxbQb5 oHhnLRcL4TxbLPZJwbvLpq9aCItiQ1xZWDBaqn3OJM/6XIPMMJnIh60YZY2YAeuktORC o/Ag== X-Forwarded-Encrypted: i=1; AJvYcCVY+USCFSAVsRgNEq4ArtcLC9eLxtfyCP7+8KkaHW0tNUhOSkqBIRTcS/dIsrUyH+Jk8OlDLcbEJyUv3z4hTt+1tslNOkYZcT1xi5R6 X-Gm-Message-State: AOJu0Yxda7Kfdma+QXFgPUMdSnp7JfctgLo+49f6MNqHI7wOYb6NbCde iXkki+e40H6TSSnYH2K3RE2EDk4wWi0XMduGlaxz6SiFjlfqrUe2eK7N5ZC3H8xvGe1oZbuTFHO gs9O9Fw== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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 From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 2647917BB05 for ; Fri, 12 Jul 2024 18:12:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807963; cv=none; b=LD++9mpy+kB9jtcSGgj2HHwQRntZg4GakoyG3pYHl0x5i6bBEAYysuCbJftyM0hLkclF5Q7ExE7rZkIFAciXFERZVJppR13HowIFsue4tvxPEoRFNl2XCsFuf6KsPxuEXkO0uswY9lQToUu/Z+MkgFga78INQ2eqADUmUoKFp84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807963; c=relaxed/simple; bh=4jN3iUFdg2T8oVK3z25P8DkRtidUU7UFK1/cu+ERcs0=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=kW279L0HOKJ8lvka2JUZGo4d2jDKlO/05Z2uq93qfYD9+YseQ+laFl/MFpVmREcDIzSTqSVYdH/wt8EJmH8cjQekkiDKo4ZT18MGskN0pR1BbkCWvWYBEd2Sq1bdjofqCOdAPM9mQlVAu/QKJzMKuuxtx2smTsqHLmmQAMCBmDc= 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=lBgUKvE4; arc=none smtp.client-ip=209.85.128.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="lBgUKvE4" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6502e4c5aafso27178117b3.1 for ; Fri, 12 Jul 2024 11:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807961; x=1721412761; 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=+Ae5Vk3XcnDdaj5BKYKsQnIS/haF5dLJg944D3m7A54=; b=lBgUKvE4d54CtJKX8vAjzb0R6BSQ4vNUSPUIDfCNnrEcmpH9xI5Ny+ByJ3y+sfXOvp s77+6oKZLjWLjLXY5qEONDHCpvCAbpjTIH5WtlhLOigm45AzDNmZC+WPzNAV/wUOsUuX 0fKHp09UcLu2QQG3gAXep2lImlUw8kofLVi2OC/6os6lBXiTVirxYYoF/XXtxEEV9qj9 sgVkB2xZKXXu8nli+Jb3ZomHg6c2B7IbvoHSU3vBLJYpq7P8FkoejSkkt622xmoPqOf+ rBPDz2G5emYXAiW5n8R1m2yXvQCYeblJv/e+E1y7q8fhvIrlVa0peBUcAVtSROtCQ36d Vnjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807961; x=1721412761; 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=+Ae5Vk3XcnDdaj5BKYKsQnIS/haF5dLJg944D3m7A54=; b=MFGiPjJfET4jFOoEeQ+JobqG2sNeth7WscReBMFHlbpqsZhov3sPtgq1DBseqfpV0Z 03O5TtRa+ijOJBXXV/V2/VRlw2Rit/vdubVTsmY3FjSCPfY9/tkmZ+RRVX/ZpCqoO9uX iw07UFSTH5DYQBbKt6Oe5e359moeKbJ7D6QgC9JIbmgnmQt2OEiN/teFshhyVmnGPELu gh/J5FPSgXj+17dJp7HUPqgXBaOBu1fVW8atB8Or/eipsnmDcdUhr0TwpjE4Li8bileK 1OYcDA4OV5lRybUv1qyNvEmGpgD/yLyHuvA2PkToGv9xB6dKT/rXVJ1HsJhiPCXpa23x D1GA== X-Forwarded-Encrypted: i=1; AJvYcCVMxfWDoISTcB+qXYpwv3+M9+hwqXbRMk2mJRagKpXGpa6eEf+//rApzs0puN8Ov+XqckCeYT4TmTIM2Dx+qbHkyIrDtBAEabFAlQpP X-Gm-Message-State: AOJu0Yx/kFx7jOR+ptPYspdIQgra6GhGXE+mvpUmrS+WGzCBeqJCVBT7 W8nJ/nlbGu5MeEjBwoLnsGRvignqtsredz9Kd+rErCqCuM0qoupCuFk6Jdo//ugLt0wSiA2QK6C iYud0bg== X-Google-Smtp-Source: AGHT+IFS1r1FmLnw95nK6fekqupiE/8fso8FKO9OPR/6xFjZmjb3YizoL3Mqh3+zh+gKZgF8dAs4daXgaaxI X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a81:4404:0:b0:63c:7fa:86a7 with SMTP id 00721157ae682-65df4ae7d19mr124097b3.3.1720807961168; Fri, 12 Jul 2024 11:12:41 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:55 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-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: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 14/27] perf inject: 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-inject.c | 89 +++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 47 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index be74e2bf1f00..2866756d5060 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -2165,46 +2165,6 @@ static int __cmd_inject(struct perf_inject *inject) int cmd_inject(int argc, const char **argv) { struct perf_inject inject =3D { - .tool =3D { - .sample =3D perf_event__repipe_sample, - .read =3D perf_event__repipe_sample, - .mmap =3D perf_event__repipe, - .mmap2 =3D perf_event__repipe, - .comm =3D perf_event__repipe, - .namespaces =3D perf_event__repipe, - .cgroup =3D perf_event__repipe, - .fork =3D perf_event__repipe, - .exit =3D perf_event__repipe, - .lost =3D perf_event__repipe, - .lost_samples =3D perf_event__repipe, - .aux =3D perf_event__repipe, - .itrace_start =3D perf_event__repipe, - .aux_output_hw_id =3D perf_event__repipe, - .context_switch =3D perf_event__repipe, - .throttle =3D perf_event__repipe, - .unthrottle =3D perf_event__repipe, - .ksymbol =3D perf_event__repipe, - .bpf =3D perf_event__repipe, - .text_poke =3D perf_event__repipe, - .attr =3D perf_event__repipe_attr, - .event_update =3D perf_event__repipe_event_update, - .tracing_data =3D perf_event__repipe_op2_synth, - .finished_round =3D perf_event__repipe_oe_synth, - .build_id =3D perf_event__repipe_op2_synth, - .id_index =3D perf_event__repipe_op2_synth, - .auxtrace_info =3D perf_event__repipe_op2_synth, - .auxtrace_error =3D perf_event__repipe_op2_synth, - .time_conv =3D perf_event__repipe_op2_synth, - .thread_map =3D perf_event__repipe_op2_synth, - .cpu_map =3D perf_event__repipe_op2_synth, - .stat_config =3D perf_event__repipe_op2_synth, - .stat =3D perf_event__repipe_op2_synth, - .stat_round =3D perf_event__repipe_op2_synth, - .feature =3D perf_event__repipe_op2_synth, - .finished_init =3D perf_event__repipe_op2_synth, - .compressed =3D perf_event__repipe_op4_synth, - .auxtrace =3D perf_event__repipe_auxtrace, - }, .input_name =3D "-", .samples =3D LIST_HEAD_INIT(inject.samples), .output =3D { @@ -2269,6 +2229,7 @@ int cmd_inject(int argc, const char **argv) "perf inject []", NULL }; + bool ordered_events; =20 if (!inject.itrace_synth_opts.set) { /* Disable eager loading of kernel symbols that adds overhead to perf in= ject. */ @@ -2333,7 +2294,47 @@ int cmd_inject(int argc, const char **argv) if (strcmp(inject.input_name, "-")) repipe =3D false; } - + ordered_events =3D inject.jit_mode || inject.sched_stat || + (inject.build_ids && !inject.build_id_all); + perf_tool__init(&inject.tool, ordered_events); + inject.tool.sample =3D perf_event__repipe_sample; + inject.tool.read =3D perf_event__repipe_sample; + inject.tool.mmap =3D perf_event__repipe; + inject.tool.mmap2 =3D perf_event__repipe; + inject.tool.comm =3D perf_event__repipe; + inject.tool.namespaces =3D perf_event__repipe; + inject.tool.cgroup =3D perf_event__repipe; + inject.tool.fork =3D perf_event__repipe; + inject.tool.exit =3D perf_event__repipe; + inject.tool.lost =3D perf_event__repipe; + inject.tool.lost_samples =3D perf_event__repipe; + inject.tool.aux =3D perf_event__repipe; + inject.tool.itrace_start =3D perf_event__repipe; + inject.tool.aux_output_hw_id =3D perf_event__repipe; + inject.tool.context_switch =3D perf_event__repipe; + inject.tool.throttle =3D perf_event__repipe; + inject.tool.unthrottle =3D perf_event__repipe; + inject.tool.ksymbol =3D perf_event__repipe; + inject.tool.bpf =3D perf_event__repipe; + inject.tool.text_poke =3D perf_event__repipe; + inject.tool.attr =3D perf_event__repipe_attr; + inject.tool.event_update =3D perf_event__repipe_event_update; + inject.tool.tracing_data =3D perf_event__repipe_op2_synth; + inject.tool.finished_round =3D perf_event__repipe_oe_synth; + inject.tool.build_id =3D perf_event__repipe_op2_synth; + inject.tool.id_index =3D perf_event__repipe_op2_synth; + inject.tool.auxtrace_info =3D perf_event__repipe_op2_synth; + inject.tool.auxtrace_error =3D perf_event__repipe_op2_synth; + inject.tool.time_conv =3D perf_event__repipe_op2_synth; + inject.tool.thread_map =3D perf_event__repipe_op2_synth; + inject.tool.cpu_map =3D perf_event__repipe_op2_synth; + inject.tool.stat_config =3D perf_event__repipe_op2_synth; + inject.tool.stat =3D perf_event__repipe_op2_synth; + inject.tool.stat_round =3D perf_event__repipe_op2_synth; + inject.tool.feature =3D perf_event__repipe_op2_synth; + inject.tool.finished_init =3D perf_event__repipe_op2_synth; + inject.tool.compressed =3D perf_event__repipe_op4_synth; + inject.tool.auxtrace =3D perf_event__repipe_auxtrace; inject.session =3D __perf_session__new(&data, repipe, output_fd(&inject), &inject.tool); @@ -2372,7 +2373,6 @@ int cmd_inject(int argc, const char **argv) * mmaps. We cannot generate the buildid hit list and * inject the jit mmaps at the same time for now. */ - inject.tool.ordered_events =3D true; inject.tool.ordering_requires_timestamps =3D true; if (known_build_ids !=3D NULL) { inject.known_build_ids =3D @@ -2385,15 +2385,10 @@ int cmd_inject(int argc, const char **argv) } } =20 - if (inject.sched_stat) { - inject.tool.ordered_events =3D true; - } - #ifdef HAVE_JITDUMP if (inject.jit_mode) { inject.tool.mmap2 =3D perf_event__jit_repipe_mmap2; inject.tool.mmap =3D perf_event__jit_repipe_mmap; - inject.tool.ordered_events =3D true; inject.tool.ordering_requires_timestamps =3D true; /* * JIT MMAP injection injects all MMAP events in one go, so it --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 5368317BB26 for ; Fri, 12 Jul 2024 18:12:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807966; cv=none; b=IdWb9diEB9uZA9yRYJp8/hP0SbSYdgD2MXQjjIMeUb2EhdbN6mTZBZQn0JbZBPVDP9m1NWgMF21Bytdb2cuuZN3RBpqtvUWyjEV4YBDqp7BOsGW3bKRYqcdVBhReVuO0BZCWINt0Oky1wGflZQoY2FOD8mNlffb6bhLMo/0SSCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807966; c=relaxed/simple; bh=Poyvi9HGQwQC12qF/8SGE3BV1oK/lWq58PuPKRxVztA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=G3Py+eVR98YHaqj2JWaJb4CDaqp2T7dc2XFuQDzwpB+cAf32TEHTYlVrpm3I2mvQQB8gPfhaQYkEkM+uAvjLaOzqe9zAwmDGQqYdDKSeplmZTE78vTGU2C3stgULGofVNpmLxkS7gtmcMUEHinwlqfk6zgM+Cdz+dHDUWjFlG5A= 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=rLPC5gqw; arc=none smtp.client-ip=209.85.128.202 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="rLPC5gqw" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-651a0aa7463so38953407b3.2 for ; Fri, 12 Jul 2024 11:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807963; x=1721412763; 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=QTSkE2wJ/0ArGbZAlv+dCStory8B9jtqpGvumW8ARXs=; b=rLPC5gqw04o3hQALOnnq4R/LT+GFz5+dhBPtSnIL2UMILL2PpQKUdNgz42nNZKyFk5 uIJDBbr5DIOyvrv+LP7lY6iMoxG4ld7ian7WLAMTAIi/lHB+1ZklIAebJAo/i//aCQaW 7NE9hmu9YgWolX3jRphYGTiyXPyyRnzZWGqkq2KSwlmAjkfuOTi2h+xA3f4zlwebt3lh efO01B9XO0yL9msZg3Xv0/yCvpNVWKMRndXJ+aXb0DV/c/oaR6s1yRCuJbCuCly2pQAI XIQ8imJ7aRUqszZ+VktHqdwrjvuG2eijzZk2WwaDIBhQbb5nvibKeT8KM9VCeFnIyjOi b/sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807963; x=1721412763; 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=QTSkE2wJ/0ArGbZAlv+dCStory8B9jtqpGvumW8ARXs=; b=a5dqvJdLusUo7BqInScvAnwD26rfkZAHA0MBTkV5827QhUK5whuoo+aiVGpI0rWe8B QTbiYODLkCJqeuoW4A4veJeJzNyK5/BvYPxAOgxdpwndkk7vLJ+2V5g/G9xn1htqP3gX Xx/j4RDVONC08btVIHn7SsY3F1Lzmfzd6kKQr1I+xDz89DvU2ZKnKihjQORbiuHxBUbw pquyQ1bu7CnLlUgoz81RxeE8hTCC1ukEia/JMzBHQDOY+4m4ZJ7Xgfu8oQnB97dKzzAa b/iFZTZVo120KYIF9uH90wqzoCnvjYBtVjrlgl9FxDr8FnPG9Ey5qIJzdF+E6TvyRP4/ RuWw== X-Forwarded-Encrypted: i=1; AJvYcCVPVvefnrNAtPPKYpNM8NrBKkqYh5B+jWM32IgOgrtwxtFetYIPmP8ysWvKbo1fKDBPa9Drc/QxorwnvCp4XUif7DXb5+B6sLKQfVyS X-Gm-Message-State: AOJu0YzjFHgXKKZwRBtEIwbV91par3GwMQ+nP1cmZ9B4xKDRUSOLZu+d 0UgdoSyUzOPlzz0QTDmc8HcSdqd/xEcXpnuHAvaXQif8mtkHvIYE6PWa7Dna/Jc6HSoUeNrgOm2 UNouI2Q== X-Google-Smtp-Source: AGHT+IEblV+LCk1KeV8fImuRJAGAXrqJSnRd0Y2lGfb50NUegiQTWmLeQGEx7ynGu/qD8BUtkEWv8J60bYVx X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:d81:b0:64a:d9c2:42c1 with SMTP id 00721157ae682-658f000551fmr2773277b3.5.1720807963503; Fri, 12 Jul 2024 11:12:43 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:56 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-16-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 15/27] perf report: 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-report.c | 55 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index c402d9b3dca6..cd5caf1c974c 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -799,7 +799,7 @@ static int process_attr(const struct perf_tool *tool __= maybe_unused, =20 static void stats_setup(struct report *rep) { - memset(&rep->tool, 0, sizeof(rep->tool)); + perf_tool__init(&rep->tool, /*ordered_events=3D*/false); rep->tool.attr =3D process_attr; rep->tool.sample =3D count_sample_event; rep->tool.lost_samples =3D count_lost_samples_event; @@ -817,8 +817,7 @@ static int stats_print(struct report *rep) =20 static void tasks_setup(struct report *rep) { - memset(&rep->tool, 0, sizeof(rep->tool)); - rep->tool.ordered_events =3D true; + perf_tool__init(&rep->tool, /*ordered_events=3D*/true); if (rep->mmaps_mode) { rep->tool.mmap =3D perf_event__process_mmap; rep->tool.mmap2 =3D perf_event__process_mmap2; @@ -1272,30 +1271,6 @@ int cmd_report(int argc, const char **argv) NULL }; struct report report =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, - .lost =3D perf_event__process_lost, - .read =3D process_read_event, - .attr =3D process_attr, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data =3D perf_event__process_tracing_data, -#endif - .build_id =3D perf_event__process_build_id, - .id_index =3D perf_event__process_id_index, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .event_update =3D perf_event__process_event_update, - .feature =3D process_feature_event, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, .max_stack =3D PERF_MAX_STACK_DEPTH, .pretty_printing_style =3D "normal", .socket_filter =3D -1, @@ -1477,6 +1452,7 @@ int cmd_report(int argc, const char **argv) }; int ret =3D hists__init(); char sort_tmp[128]; + bool ordered_events =3D true; =20 if (ret < 0) goto exit; @@ -1531,7 +1507,7 @@ int cmd_report(int argc, const char **argv) report.tasks_mode =3D true; =20 if (dump_trace && report.disable_order) - report.tool.ordered_events =3D false; + ordered_events =3D false; =20 if (quiet) perf_quiet_option(); @@ -1562,6 +1538,29 @@ int cmd_report(int argc, const char **argv) symbol_conf.skip_empty =3D report.skip_empty; =20 repeat: + perf_tool__init(&report.tool, ordered_events); + report.tool.sample =3D process_sample_event; + report.tool.mmap =3D perf_event__process_mmap; + report.tool.mmap2 =3D perf_event__process_mmap2; + report.tool.comm =3D perf_event__process_comm; + report.tool.namespaces =3D perf_event__process_namespaces; + report.tool.cgroup =3D perf_event__process_cgroup; + report.tool.exit =3D perf_event__process_exit; + report.tool.fork =3D perf_event__process_fork; + report.tool.lost =3D perf_event__process_lost; + report.tool.read =3D process_read_event; + report.tool.attr =3D process_attr; +#ifdef HAVE_LIBTRACEEVENT + report.tool.tracing_data =3D perf_event__process_tracing_data; +#endif + report.tool.build_id =3D perf_event__process_build_id; + report.tool.id_index =3D perf_event__process_id_index; + report.tool.auxtrace_info =3D perf_event__process_auxtrace_info; + report.tool.auxtrace =3D perf_event__process_auxtrace; + report.tool.event_update =3D perf_event__process_event_update; + report.tool.feature =3D process_feature_event; + report.tool.ordering_requires_timestamps =3D true; + session =3D perf_session__new(&data, &report.tool); if (IS_ERR(session)) { ret =3D PTR_ERR(session); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 7FDDB17C208 for ; Fri, 12 Jul 2024 18:12:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807967; cv=none; b=tpl06o863UZhWC8hdksceQsicvArPMPpV2Kff6F4jWeYKcOPbzb0hHdxiRpWUsH3KdXTGgKuGHgMJdDmDm7d+uae7R9BAimSeCRwxtnf+lwVR0IAKr8/4Ua9QkhkcDtVO8kHDlkEArC7fHL8M3SbABdkIWeUvTf3RKlKBKc10jM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807967; c=relaxed/simple; bh=Oatp9vP9864WSMM6h8L2eaSDz2osyW3W6s5tTUlCsXc=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Wt18QXEo7V2s+D8DPLYw7jOtbB24qKxB4TZi0UC8vIKlCKP/pgfXEiFVSzNw0QsRqbNEm8Ch80+WN81wWW23gd9JOf0G90Dg1gVE6VKQXBneuCgnlOOeH72Fa+4xzpdqCHwb5feT9sx4ITGL6bhtIc13UOYWZEh0wwRq6JcdB8c= 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=sJevOxMw; arc=none smtp.client-ip=209.85.128.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="sJevOxMw" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-65b985bb059so39750457b3.2 for ; Fri, 12 Jul 2024 11:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807965; x=1721412765; 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=GhKzAhRYOz6Ff/7gM3raH2p2+7D3XZwc5l/hw9g7Qeo=; b=sJevOxMw3gvebegY6KUhx5Yc7gmhNzCyc4XsuZY52Axk8uInIYgcFstMGW5Qm59unI HWsZHLFJ8POlHw1NhHDhww9V10tiuu9P6Oz6fBSvIr7ziEwFDnW9QjjOp9YG2MEMUIlJ Zw6kQcwh3xkWHaxinH4jaGorIV/fioX42IWmApxmLxq9uMEnQAexsliEAl70EPkO1tKP dDC0kPKhlglkq64s5ODFEZtpx+lD0E6mAujEny03OIAssxqY6nlI1kXrBMY/TjyGoA8d CBIRAO5JgaFr28/bfXSgEQKA91FSV9gGhGzNFsud3bTtLMtrKfrq1AD+qV8YNFKHgPJr yABQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807965; x=1721412765; 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=GhKzAhRYOz6Ff/7gM3raH2p2+7D3XZwc5l/hw9g7Qeo=; b=XlWJhvtdOIu3h+PApffDnSY7aGsOunYNgjvYyOOY1AW1+GFYewrsXJc08TKiYdfpW+ X4VPB6wTaOFJtu53xSKUnUJKt8Cz9SvRTY4D85BClUcuvopgMA1pGPWEjxH7118s0Xmr PRbnpW/ke3DjsBwqxstHwztjwpNEs9tgtElrM7LoBr6N2fDcxZUI9IM8nkKmmEaqKoHz 7PhXQa5Thb4zQllVPtMekiodJIY9VPydAxwNhOOphZdR6hU++27WMK5nGeRz1bjSpoLJ lPTgC80d7b82SjUsDxFMdiK/V5jrT3Zf2yEpLt2CZNJ8HJ95QpANRJUg5hEZuEAKisY0 X6nw== X-Forwarded-Encrypted: i=1; AJvYcCVlQ/NdwG8iB9H9dVFZFNXzqL3B9h4MYdaCssE7BJYXaZUswjIf182qiWpHt/bnUldApR//xOKE9nWCMxwj9BNP4WoFECseWZMdDT8A X-Gm-Message-State: AOJu0YyXqB3zH7lAuBnEODo56VyVkIcsmZhejNAGN+6wboiDLzDahdKh Lr0xwrltvJRwFNLBu+HLCIX7/V0p8/PzbE1T1KHwKbQuBmjRxn4rsY+xV03mhvknPqv80RbXecA oFT5fnQ== X-Google-Smtp-Source: AGHT+IFhYPk2jTBuMlhB8gOtTxMBnApQKnxVWvq+XTICOK0WnJmqAo1AkbwwG2wHV+rrMbesLDOHGcXiSffq X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:114b:b0:e05:74ca:70ce with SMTP id 3f1490d57ef6-e0574ca77fbmr459024276.4.1720807965562; Fri, 12 Jul 2024 11:12:45 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:57 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-17-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 16/27] perf stat: 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-stat.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index d460c46f15fd..a3d77a55d17f 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2271,15 +2271,6 @@ static const char * const stat_report_usage[] =3D { }; =20 static struct perf_stat perf_stat =3D { - .tool =3D { - .attr =3D perf_event__process_attr, - .event_update =3D perf_event__process_event_update, - .thread_map =3D process_thread_map_event, - .cpu_map =3D process_cpu_map_event, - .stat_config =3D process_stat_config_event, - .stat =3D perf_event__process_stat_event, - .stat_round =3D process_stat_round_event, - }, .aggr_mode =3D AGGR_UNSET, .aggr_level =3D 0, }; @@ -2322,6 +2313,15 @@ static int __cmd_report(int argc, const char **argv) perf_stat.data.path =3D input_name; perf_stat.data.mode =3D PERF_DATA_MODE_READ; =20 + perf_tool__init(&perf_stat.tool, /*ordered_events=3D*/false); + perf_stat.tool.attr =3D perf_event__process_attr; + perf_stat.tool.event_update =3D perf_event__process_event_update; + perf_stat.tool.thread_map =3D process_thread_map_event; + perf_stat.tool.cpu_map =3D process_cpu_map_event; + perf_stat.tool.stat_config =3D process_stat_config_event; + perf_stat.tool.stat =3D perf_event__process_stat_event; + perf_stat.tool.stat_round =3D process_stat_round_event; + session =3D perf_session__new(&perf_stat.data, &perf_stat.tool); if (IS_ERR(session)) return PTR_ERR(session); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 75FFB17C22C for ; Fri, 12 Jul 2024 18:12:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807970; cv=none; b=X8mZ/EAvGH3anHzSTqsjQdbCualshxGau4GmJ8ck3mwKqxdz8+T71O4ChaZNe1c/1/xU+8vUqttdzhZRkw7cEJdVzPIWguBfkgW/4XLtJ6rspaIhYoHLoEkhDSNtQ3Vy/LpThMAIZ+LqQX1JmrULf5y46qKTSK7nA2FNfmuElvc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807970; c=relaxed/simple; bh=qWVb8s7IPdoN6VP7CoH6NHZGVGFRy7E/MCr32tMRu8Y=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=LtJ+jtwVYvSlS4wdrNZ3uLLXUl9KHrRnP3umJCzZbX9yFCC//AQaswPzDpW5fytjHws87cqPwAfLYSqDNAPoeops1JEVy8S1M7aiXhc4PvaM57rHIw+aMbWO5JxZKFjuTedsplt7hnwvCjMigod1G8YXVmCCu+xlaEKqD+usuN0= 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=Cxog61AB; arc=none smtp.client-ip=209.85.128.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="Cxog61AB" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-65e7c42f28dso17127957b3.2 for ; Fri, 12 Jul 2024 11:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807967; x=1721412767; 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=mHHBS2O6oNY6SeiT+OH+p80VI/Bl4EiQ8pJoP1UpZWA=; b=Cxog61ABs2xbixjRvs4chZTA6ssFlvKf80FHI2GCMqTNwXtZEV/WE11lty+PX0fKPJ aQ6DAJYHYUxAYRcbye/jmlRwsR0Iu1zh3K/TE8m03b9LrRIy78SE2XrZSE/jPSL5w4ij kXKwuHk79ymwg2LGOZZZfaVjb61d01wKo+hJDX45aiTvx5je3gGjtnVYmu4O7yLDtRNB svtTjX7Fde+UYZu6BpCgd/nT6ldoxtDmeJv3U0TXAsPnDgsca4xMYOGBvbWKpb7mJzND uPO/TVz7YOAB87PPWp92tZ0cq4bcr3PNPaFsJvwBU9niebrf2IVpgwJw9oVdawfFtykN +eCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807968; x=1721412768; 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=mHHBS2O6oNY6SeiT+OH+p80VI/Bl4EiQ8pJoP1UpZWA=; b=b9twvSIf7g+ngnmxLuBj+0Nc0QHblsCNO4RanZizKuTGsBUXywr1P9e+jYf3DUOexK g/CJ48cvKk6DMay5+MXR4Tc32Sx/cX0VoKswDkGHDWWNh8XCrJZ321eskaqq96Waiadv j6FRuQCTp/eoLe7mOUUVfuNEPr49a4ezC2iPRrZmOZJKAFeG/3b1prlU9jIpKq61Ctub QPqftDoJbHDmyxDBtI8FXybTo77nba64ZKo01ebocucGh4zVrCV6VN4m4zKf+x+spHro 7JK/LZUl0DVkDwy+RQiNVit1xNPGiMgz3QhJROduzyUf2+gae4V9j71YWYij5jVssVAE H7/g== X-Forwarded-Encrypted: i=1; AJvYcCUNbEqSBy+ul4kQ9z8w00Ys6YY/Y6ZoeR4BlnmIrKlgemkxPmrPnYdBF6WZxmfQT9LaGXSonuSssO08a4EHVn2ZdYM9Jn9y98qrGE6D X-Gm-Message-State: AOJu0YyBkQSl7eUm1/enWp6gBBR8Vgs7U6S6fxMlpz96B4sYy10nhWSK vDHBofcxDPaYo/bXdQLco46FhKTytwrr/ACOThO6t1/1aIpvYTsseV9Gtz3G82EZWOnriHfUJsX NSwtxKg== X-Google-Smtp-Source: AGHT+IHi0RESPy1M1p6v6upGm6fDMbixV6F9q5HB/w4IM/nxGzbjXT13DQBQQev04cZgDR3Ow3mnnlitBBVY 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-e041b058ccbmr26284276.6.1720807967661; Fri, 12 Jul 2024 11:12:47 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:58 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-18-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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 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-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 c0685d2c8de1..598ab854b9f3 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -686,28 +686,7 @@ static const char * const annotate_usage[] =3D { =20 int cmd_annotate(int argc, const char **argv) { - struct perf_annotate annotate =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, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .namespaces =3D perf_event__process_namespaces, - .attr =3D perf_event__process_attr, - .build_id =3D perf_event__process_build_id, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data =3D perf_event__process_tracing_data, -#endif - .id_index =3D perf_event__process_id_index, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .feature =3D process_feature_event, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, - }; + struct perf_annotate annotate =3D {}; struct perf_data data =3D { .mode =3D PERF_DATA_MODE_READ, }; @@ -864,6 +843,25 @@ int cmd_annotate(int argc, const char **argv) =20 data.path =3D input_name; =20 + perf_tool__init(&annotate.tool, /*ordered_events=3D*/true); + annotate.tool.sample =3D process_sample_event; + annotate.tool.mmap =3D perf_event__process_mmap; + annotate.tool.mmap2 =3D perf_event__process_mmap2; + annotate.tool.comm =3D perf_event__process_comm; + annotate.tool.exit =3D perf_event__process_exit; + annotate.tool.fork =3D perf_event__process_fork; + annotate.tool.namespaces =3D perf_event__process_namespaces; + annotate.tool.attr =3D perf_event__process_attr; + annotate.tool.build_id =3D perf_event__process_build_id; +#ifdef HAVE_LIBTRACEEVENT + annotate.tool.tracing_data =3D perf_event__process_tracing_data; +#endif + annotate.tool.id_index =3D perf_event__process_id_index; + annotate.tool.auxtrace_info =3D perf_event__process_auxtrace_info; + annotate.tool.auxtrace =3D perf_event__process_auxtrace; + annotate.tool.feature =3D process_feature_event; + annotate.tool.ordering_requires_timestamps =3D true; + annotate.session =3D perf_session__new(&data, &annotate.tool); if (IS_ERR(annotate.session)) return PTR_ERR(annotate.session); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 C214A17C7C4 for ; Fri, 12 Jul 2024 18:12:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807972; cv=none; b=TM+aUTwnnMG1AaMEVRo93pRGU5y67LMl1GcStyhv6cUoAikXHAqwOWl4RlMoa5Pkx3rMvkvHHbSprJmEGlXFfOcnEG3eIzaiwkgd66yc/82FSc5yxFnd/q1rg26ZnYGZb6+v0zuh8+X1VOqJS6Xv1txlmybx0sfHjFEh3FP4o7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807972; c=relaxed/simple; bh=D3YBUpPEwBmyis+zCkqbR93QP3d0FEANSJQVPRT7Pgk=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=dUDQL2hEOuDqTqjc853/XHwX190vW4amruIIJRfo2v4zu1mAYBGGwoOlYrqJ2ceztS8cpoJV7mBwQZW4b7NJCYunQk/2Zapy0BkqCmDpof9bwvC3eKa/JVSdQvMUzHoccWnfZTzRZBB88d3cRXdewr82ktWVpO9FtvyhTAEywc8= 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=cjU+BudP; arc=none smtp.client-ip=209.85.128.202 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="cjU+BudP" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-654d96c2bb5so38502287b3.2 for ; Fri, 12 Jul 2024 11:12:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807970; x=1721412770; 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=ZfGB4qYIWwtakjvzGQZNS3+imagxPcgxRVJoCFymO4s=; b=cjU+BudPbZsBUSeaGHx5zaJTmI1KeNJHyNvyR9kWfrKnaDL+LwD5INDi3e2Qpt/Gr2 CB3WEPaG0k9tCCNXJ+NwPKv1qkogToVagt3/bBcZZHvxsJqN5B4MGz3BnTqgoQETyPv0 4vJypz5IUuuYGIdvqpgR3ohHHm05w2UDgwI0+vbe73eX/5r3hPUKpVV/4MXIsXxXRvZ3 Uft3Aez9mMFo5U5264xkTza2/3thRI+n6qmlNe+WJdA5GN8p8OKgh/BKMN2u/ttQoPPZ gdOfF7I7n7coxJeAWXF3Yrbt2PxR6ZfcGPwx5xjts1xnuerL32rXTOoT4yKdreJpBAYC hZrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807970; x=1721412770; 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=ZfGB4qYIWwtakjvzGQZNS3+imagxPcgxRVJoCFymO4s=; b=giXsHmsiW2EwXEXJ7kbWc5xh7Ju2G84MrD6c79dPvkPeETsfbMKZijuVmsASQq1MQK /jUeifOs9UDzYPwa1SsqEBRw5Vvk6++p8Bu7jK/bF+U41x6442iYhZKH3z3GFuuEZ7l1 gqNE/g6SRCc5TkK5Umi/YOm1YHq2Pd9uTDo6Kr6nyyWacpt0rkJ3YsHxtPX31z2eVTP1 hqiqsWBAJiUep0dZEkFBjBXh3yL6iNUWkzCaFH8NxtmWIcoRQg5d6vXeGukmpymu2rHi MHbD77R40OkAj7X9OktKowbfeFt8wzYZyqYWKJuixiuZ66IRo2weC96NTwX1UuIlLRc5 KTdg== X-Forwarded-Encrypted: i=1; AJvYcCUzmvySl97DM7zWVws8kj5NiN7KMdVPe+g6X5uhvG6uZ/dby9NRdK8lqMEGj9VViYc3Xzhylh8STCAfLP9yDROcyS5OSI+14BZKtcmb X-Gm-Message-State: AOJu0YzLD9+fAbC/kgp3pSAnChhqQfOeO7UyvzHcx3LYqbTv4mDyBltJ 3YSe9NuuyyjO3Qv+6ivqA3qA+ZH1BzbNnL22TVb+35+P2oMVTw9Ivs+r3uVcOiExNppxhlrfl1T iTxMUaw== X-Google-Smtp-Source: AGHT+IGwm97iX/hGe03hY3o8dBT3RVSvlUNVeKVGrABZ6gQou1GSxK9awtmr+31vBv1Cj2NXc9MdjmjFPQQ1 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:fc4:b0:61b:e103:804d with SMTP id 00721157ae682-658ebbb801cmr734427b3.0.1720807969781; Fri, 12 Jul 2024 11:12:49 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:59 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-19-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 18/27] perf sched: 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-sched.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 2c60bd3a8149..34fe8e540c43 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -3100,7 +3100,6 @@ static int perf_sched__timehist(struct perf_sched *sc= hed) sched->tool.tracing_data =3D perf_event__process_tracing_data; sched->tool.build_id =3D perf_event__process_build_id; =20 - sched->tool.ordered_events =3D true; sched->tool.ordering_requires_timestamps =3D true; =20 symbol_conf.use_callchain =3D sched->show_callchain; @@ -3605,14 +3604,6 @@ int cmd_sched(int argc, const char **argv) { static const char default_sort_order[] =3D "avg, max, switch, runtime"; struct perf_sched sched =3D { - .tool =3D { - .sample =3D perf_sched__process_tracepoint_sample, - .comm =3D perf_sched__process_comm, - .namespaces =3D perf_event__process_namespaces, - .lost =3D perf_event__process_lost, - .fork =3D perf_sched__process_fork_event, - .ordered_events =3D true, - }, .cmp_pid =3D LIST_HEAD_INIT(sched.cmp_pid), .sort_list =3D LIST_HEAD_INIT(sched.sort_list), .sort_order =3D default_sort_order, @@ -3733,6 +3724,13 @@ int cmd_sched(int argc, const char **argv) }; int ret; =20 + perf_tool__init(&sched.tool, /*ordered_events=3D*/true); + sched.tool.sample =3D perf_sched__process_tracepoint_sample; + sched.tool.comm =3D perf_sched__process_comm; + sched.tool.namespaces =3D perf_event__process_namespaces; + sched.tool.lost =3D perf_event__process_lost; + sched.tool.fork =3D perf_sched__process_fork_event; + argc =3D parse_options_subcommand(argc, argv, sched_options, sched_subcom= mands, sched_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (!argc) --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 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 5344F17CA00 for ; Fri, 12 Jul 2024 18:12:53 +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=1720807974; cv=none; b=nSDAUuoWNX1/6VNmHYpFamBgsNBW85iox6hBxdRlfgDsdTv0hvPtqu3DRofoCwIBmvEenBqrhx4Y9eTkQ5ALMYEOpInlRGsGcBIPdR+rwqb86fLUNO8cJdDA4vU6NmhN0r4GulKZJQgMbuF67uTBqIKEcXBHONY1DacC+bfbicU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807974; c=relaxed/simple; bh=PQFAc94b+3E6J2xiJdbKRsuyLtZHAm+NZj3v+mP90Hc=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=lkAT6ZdDQvD4Yp1eVATlCaaL1ZCGWBasG4g2CX9eOs5rcY71vDbdAjtZ+oy1BcHujAzf9QImoadLZYoyU7sbm26sRP05lou41sM3cLvAsSehkbt95SmK15JUsxT0mqIMUcU29/YSNuIfvKUnsfZCQcKXjKU3zqlz6iZRJL4vf0Y= 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=CGLxMRCj; 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="CGLxMRCj" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e03a92302d1so3686675276.1 for ; Fri, 12 Jul 2024 11:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807972; x=1721412772; 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=dI8yaROyMxBgkl/C6HStDZ1DbB4Rpu7ZnQVumFggSVU=; b=CGLxMRCjyiGKsZNLZBfsHfkedwFQZ/BLnEm30ySaBUPCUrpaBZqZIsOPlloR6SiN97 zZRuFO+kEcbmnO5RgXYvnKC2jGvcRe5Ms4fodNBADG3UHGM0cfCRWlm62buB6b/aQ9Ms 8MDtg6ZnpJ8Sx9FaL+AVEMu2UGMF3PvpHa5pO9rrpHVNhaXjApCq2GrxitURLF8CUNfT 80PUzkYsYSeXHfJvJJM6aBU5EY7Yy4epd/HHDtd428elb2hIv8XbiYYBadPesa/60ChQ UWtlI91Oqe5Tr4gpdf3h4YcaQywa3QdNxlRYBcp1OlUVE3bfpIaBJ4QolgvZ4KHZfc6w sOyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807972; x=1721412772; 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=dI8yaROyMxBgkl/C6HStDZ1DbB4Rpu7ZnQVumFggSVU=; b=RftWne8bPikvG9dhds/adpKsjjllVatGbnV1EYAR7k2vMjusGypgDho7JKkwPHkpa7 SFL02hqY6LW5Vc5QPnMpCt0wawxVEhsnuF55c75USHcE+wvlI88bfZHnPBVw9qcae13s KaLCQg0vFuArjdrnvzNMlOSPyS1t7eK86INa89IaMUylqOZZOy7IdyDS7FzSS+A9khfo zODGhS1ETPzLMd1yJYIorpXgHQLdaa/sIn4niGUcdLA+FXL40QL6D8DHzMKn6ISZPt+0 kZqc+bh9Aql8KWaPfzqkpvxhnrs3iydL3N8RNuVhTC/R69xgGHxoVEGtcrogea6VxVqC oCFA== X-Forwarded-Encrypted: i=1; AJvYcCVuP/csKnJKRBa+IkVXyKJPHzX/T58w6//lSK4qHM/n4pPgyejilBnTeEeYazZk6/RhAaveMlW40/3v4wTY5NvrZywbCbPcloGI/ZZl X-Gm-Message-State: AOJu0Yzna1Dm0HVNFSTfh+2aapVqbwvIQVBgQONRP/g4S3NHoMfV1S70 PpCuLi6wmMFyBLiG+0GW/zsRRuto/GV7g/y5dRwxd1F59OqPynIhtkL4NOIzRDR2o1KCBauWqwz eqRrxSw== X-Google-Smtp-Source: AGHT+IEdjKOWNbH6lHnQ3hQD9ZpV0aONsOjoRMeD9l9g2HUs1hV6yUVjuLwzYNk5GAitqb5lFTEdkOp686G6 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:1146:b0:e03:6556:9fa1 with SMTP id 3f1490d57ef6-e041b11d3demr762464276.8.1720807972320; Fri, 12 Jul 2024 11:12:52 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:00 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-20-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 19/27] perf mem: 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-mem.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index c2038a32543c..c12ca0ec1237 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -285,7 +285,23 @@ static int report_raw_events(struct perf_mem *mem) .force =3D mem->force, }; int ret; - struct perf_session *session =3D perf_session__new(&data, &mem->tool); + struct perf_session *session; + + perf_tool__init(&mem->tool, /*ordered_events=3D*/true); + mem->tool.sample =3D process_sample_event; + mem->tool.mmap =3D perf_event__process_mmap; + mem->tool.mmap2 =3D perf_event__process_mmap2; + mem->tool.comm =3D perf_event__process_comm; + mem->tool.lost =3D perf_event__process_lost; + mem->tool.fork =3D perf_event__process_fork; + mem->tool.attr =3D perf_event__process_attr; + mem->tool.build_id =3D perf_event__process_build_id; + mem->tool.namespaces =3D perf_event__process_namespaces; + mem->tool.auxtrace_info =3D perf_event__process_auxtrace_info; + mem->tool.auxtrace =3D perf_event__process_auxtrace; + mem->tool.auxtrace_error =3D perf_event__process_auxtrace_error; + + session =3D perf_session__new(&data, &mem->tool); =20 if (IS_ERR(session)) return PTR_ERR(session); @@ -449,21 +465,6 @@ int cmd_mem(int argc, const char **argv) { struct stat st; struct perf_mem mem =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, - .lost =3D perf_event__process_lost, - .fork =3D perf_event__process_fork, - .attr =3D perf_event__process_attr, - .build_id =3D perf_event__process_build_id, - .namespaces =3D perf_event__process_namespaces, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .auxtrace_error =3D perf_event__process_auxtrace_error, - .ordered_events =3D true, - }, .input_name =3D "perf.data", /* * default to both load an store sampling --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 726E317D37B for ; Fri, 12 Jul 2024 18:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807977; cv=none; b=A+AK2phVUQz/5IJCA9tl3+IwOiukxQrppaSdqYLWApAjPMOagK42iWuXmVK7BNpXBANYQeTgw1Wmk+XSJJCugThYeMO5vF6gSX55oKVtDPO7iYsBaKMuVBU/qALq6/91hP5nf479mlD+BOywQSaUEDX+kbkDVGw/m6ksHYoNeKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807977; c=relaxed/simple; bh=ulxtdrULVFXHxSwGu1u6ejOo2/3AvfXoc6ANmm1gsuE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Ic2iS1rMwqspgOF360Fuob29A0ZdMYoC9mGtzZaT21qyzgNHf+8RfK/j85yMgN/pkhA1XMsNrp39tz7O/P+4J+pdVaWjM76TTzffvWlFLWmdeHTcRzXBqVPCfV6wFufNpSS0Lf7HhzGLRrmd3RE76xVvfQE8tlqDL9LjnpXV60U= 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=1ClGWyWt; arc=none smtp.client-ip=209.85.128.202 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="1ClGWyWt" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6533680c788so40099927b3.1 for ; Fri, 12 Jul 2024 11:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807974; x=1721412774; 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=30wTiCp+NVIhDTuqUvYj4YUy4HL96R/Tpq22ji595AI=; b=1ClGWyWtTuFou/TpdBKtJAUT/Gc4d7WIjYbzoQqzWmGT8+HsobO0b5bO1JzZcybu8H L/0Erg9vcZFnIk0xBwJUvgKvADsKURtq2IvN0dYqo4jJh+9m1R9uPchCWhXTTzUZN9K7 PU0wiCSFrLhElPUEgQSe0cQGPHBXN2FOJmFvDAP/H9tuS0+QBrBth7m8eDEcGW/bdyxb UAZfLDAi7CgAXR84OXrhK9TUFSCclEp8XFm21sIJ0/nDu0Ltn/TMOs8TEjw4D9bjTw2H JqVp7xHebye1xcfnnMfWftUZdgKaFL4f8Vk7YZ/pZ2ZQeXBosOdhlEOzqOerzmqLG0Sw c8UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807974; x=1721412774; 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=30wTiCp+NVIhDTuqUvYj4YUy4HL96R/Tpq22ji595AI=; b=s7JtsWfc/uxzRo1zkTXFDasKqHM3ufUycGLSJeXfgzY2rAxNnCle13CCLly3NF0x53 +W9wANJTWRmv3D1j0RTDJ9A1RDhHdLk2CCI095+BHLH02Dw+kgBBqV+By1O2ysr7h2Co qSWlWNHWBLBvYkFPBOrD/budeJMprQcTUJTfVbBiEeZ3mXpYvrbdYNBG7DwRvtGKKlvl 7BrM3YLf716To+aDg9W+YXwvo/PgWJWwQNdnoQ8T9yAzSNtaFT1KGbIrm7S/Hzw+LRJc m6A3ghV1kyDmlVo533GgbG4KmD6dP9ZwD43SR5lQKFBM1UVPPD7xW/3LL15FV4qiJk7s 8TIQ== X-Forwarded-Encrypted: i=1; AJvYcCUmBFs10+FGqBJ0IADequu0D/gi94R1NGAOsxqMTMMZl1usquJMQyiUkfQFtO/tsVXb8LddRbc/z8mCWLlkSYPeuq5mzdeQ117/wbZO X-Gm-Message-State: AOJu0YydJQXaDrfZ+fReNb/cDQQvhsoZA6vyUcwjT+sADlG8nkkGasWY XpUIpMpXZnG5/opOAfCwT5dhvMUxVT4gqDvPiqqDXqqrlYCf1ohkx416OnRfzOboxf509vPL2EU 6jHi9RQ== X-Google-Smtp-Source: AGHT+IGMtuukUah6sKAK0S8MwrL9axUruMElBWLKJaJXxc54g2LyjBNvkewqR7HlUBQ0L+JgA3dM6zS6xMnA X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:6404:b0:651:a724:dd0d with SMTP id 00721157ae682-658f06d9d6amr2241857b3.7.1720807974345; Fri, 12 Jul 2024 11:12:54 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:01 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-21-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 20/27] perf timechart: 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-timechart.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 5bf818baa662..218c8b44d7be 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -1606,10 +1606,16 @@ static int __cmd_timechart(struct timechart *tchart= , const char *output_name) .mode =3D PERF_DATA_MODE_READ, .force =3D tchart->force, }; - - struct perf_session *session =3D perf_session__new(&data, &tchart->tool); + struct perf_session *session; int ret =3D -EINVAL; =20 + perf_tool__init(&tchart->tool, /*ordered_events=3D*/true); + tchart->tool.comm =3D process_comm_event; + tchart->tool.fork =3D process_fork_event; + tchart->tool.exit =3D process_exit_event; + tchart->tool.sample =3D process_sample_event; + + session =3D perf_session__new(&data, &tchart->tool); if (IS_ERR(session)) return PTR_ERR(session); =20 @@ -1924,13 +1930,6 @@ parse_time(const struct option *opt, const char *arg= , int __maybe_unused unset) int cmd_timechart(int argc, const char **argv) { struct timechart tchart =3D { - .tool =3D { - .comm =3D process_comm_event, - .fork =3D process_fork_event, - .exit =3D process_exit_event, - .sample =3D process_sample_event, - .ordered_events =3D true, - }, .proc_num =3D 15, .min_time =3D NSEC_PER_MSEC, .merge_dist =3D 1000, --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 7ED7F17DA13 for ; Fri, 12 Jul 2024 18:12:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807979; cv=none; b=dxTSi4s15S2EVl4ksDKGS7i5E9bDaWzNvNh3SSTXszrNgERmbdkFSISDP+j6YG7wYt1tR+1WeArLZdfByuzwD9erHLQLGGKAgTvDQ5AJJKmxeq3rIY832FdOfyPPBNrRe4g5rYo39ILyusJjdjsvryXj/clM2P2x5ZhognQ6ED0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807979; c=relaxed/simple; bh=voKswfKfj3xVUdanTG/Vv01I1kScl7Vgd1gUmqiYueA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=cRWWixUOFXFg/r4zLP90gouj0fkPMsXvINjfVK+EXy2fayoD7ZTaUxbkV390o/hd2ZQmhoCsBlW/i6QrpazZdBH82Z9Pjj7BoT9VgDePahy6+l2BZRPP1aVvRryaPquntRmnZjr24Tz1uiX35VgsP1bWrIm+YTNXQjDZ7ggbzqU= 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=RjxIIe6J; arc=none smtp.client-ip=209.85.128.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="RjxIIe6J" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-64f30b1f8ecso35116377b3.3 for ; Fri, 12 Jul 2024 11:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807976; x=1721412776; 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=Yt616h8hRCivHeAdqJzIY5ztVTyVV8Crah5Wq3Zf1UM=; b=RjxIIe6JK8aIiU3xHoxlAVKgHnwARDfDy1PlfDqsfzO0n3dnwEMVTOeZHEEEX9pZZG sfnzHVdndapFTlgzCTuSWtsES++yoWMC9SXgvBVEEVyzs+sdeMeauvCesUFDw2cviV+e 4LSms1R6mmxCNN6XcW0BgTo6FNBgqGU1FXEKxmWLjYI52iguvbhT96JBFAUjN+/QGpVP FbhPytkPZLsU55NpCfY+C1ywH0C2bgbKys07/Jyql+OKOoGxHXbN8F/sV2CvSvzR5r3M eyCMUn1g+iP3npgApJtJMD7FLHVFeRE5Y68DPC+gT0s0Hm8ho3WWciwcbt2t6lYD+Y2i 2qkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807976; x=1721412776; 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=Yt616h8hRCivHeAdqJzIY5ztVTyVV8Crah5Wq3Zf1UM=; b=mgHs1CZVL2TWIByC6q6ALsAwYY4nX528EwjNx4hjD0oQ5m2jnBvtVRNz8P8sbbA82J flvbYF31Bc49eKUd1wpmiD6RY6SXna5k9phICGq0ombJwTfavrHFmf3dPDOdur2YFkJf rGmCkMw5EabI5v1f3lasnRgmj/SjyXH5H88P0AsECAg50/7e5LrARPsMeL2f4ai1PaTS a4ZO0W5F/37h1PoO66WzXmPCA86G3qgr4dNLj806c2kC3ZPDwbrr+63RO03a3uLHUFD+ JCRWG8D++wCMifcy1FebHp4jAw0VpCvAv9ogFpRpQga5cGCNIxDxROV6cr7sp8LBppzK 4jHQ== X-Forwarded-Encrypted: i=1; AJvYcCViE4sfL+u+2oUKVs3RauOl3ymummUnaSesYVYKHlH3lPnLnJU4d9k9pQ+bIw6hxJWEEeFnzi6a0Kxt5c0x6+8vh79DOOnizs6PyJQv X-Gm-Message-State: AOJu0YxWE4iN+FIS+SOg9fNswplbnO9FTihF6Y7L69y90tlIFrZVF3nU HPrl2qvtTpEwKM+5Yr5Z2pXB2JQyAEh4V136mOjphFJNoWvqqkj7YjhjHrXx8ttL8K9aJh/zBfv OFdjGeQ== X-Google-Smtp-Source: AGHT+IEoiv7jL/sMkb1DG/QD598pjkLvo+odw5YGkLQIBl/s8wzmd3RFOvk+HEu5aaX3z2x7O3Zr1FccgHT0 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:67c5:b0:627:dad9:bf54 with SMTP id 00721157ae682-658f10b0c9emr1670067b3.10.1720807976515; Fri, 12 Jul 2024 11:12:56 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:02 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-22-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 21/27] perf diff: 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-diff.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 4c0567882a7a..28c5208fcdc9 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -467,21 +467,7 @@ static int diff__process_sample_event(const struct per= f_tool *tool, return ret; } =20 -static struct perf_diff pdiff =3D { - .tool =3D { - .sample =3D diff__process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .lost =3D perf_event__process_lost, - .namespaces =3D perf_event__process_namespaces, - .cgroup =3D perf_event__process_cgroup, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, -}; +static struct perf_diff pdiff; =20 static struct evsel *evsel_match(struct evsel *evsel, struct evlist *evlist) @@ -1959,6 +1945,18 @@ int cmd_diff(int argc, const char **argv) if (ret < 0) return ret; =20 + perf_tool__init(&pdiff.tool, /*ordered_events=3D*/true); + pdiff.tool.sample =3D diff__process_sample_event; + pdiff.tool.mmap =3D perf_event__process_mmap; + pdiff.tool.mmap2 =3D perf_event__process_mmap2; + pdiff.tool.comm =3D perf_event__process_comm; + pdiff.tool.exit =3D perf_event__process_exit; + pdiff.tool.fork =3D perf_event__process_fork; + pdiff.tool.lost =3D perf_event__process_lost; + pdiff.tool.namespaces =3D perf_event__process_namespaces; + pdiff.tool.cgroup =3D perf_event__process_cgroup; + pdiff.tool.ordering_requires_timestamps =3D true; + perf_config(diff__config, NULL); =20 argc =3D parse_options(argc, argv, options, diff_usage, 0); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 0662A17E446 for ; Fri, 12 Jul 2024 18:12:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807981; cv=none; b=V8Ka714YG7h1bdDSngQgptv/XyX7k6uun8GYl25IKl0wgxhIp++aoWUPt50a9K1yyEzPC/xbxp15zzs6JBtNBOOA25uMQG9OJOw7FuKOGYct8itDAmH4y7UtWTJNDvo8CpVEImB0bA1aolNgq9jLYmKSRrXCQqxvhCAWW6PnoPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807981; c=relaxed/simple; bh=Zg5U84S1ofRY2jiFZPVeAVTNxheJYumCpecsmhgwjUo=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=gLTMI7tWrXfu5EUvbntgoktZntxw+NqZbwVhcexHM3G32WsJOwEb/RoG1eG9aFsxPOxjUV0mCf1XPXerxNv5ZBCzF6OCM8pcrSF9K6HirvEaXB9Tba4L0ezMXI9pK5ssR7NyNJb5k6g6PFH2clt9oXk4zoDgZ233JDKGCgecpdk= 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=bOD/Bbt9; arc=none smtp.client-ip=209.85.128.202 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="bOD/Bbt9" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6533680c788so40101197b3.1 for ; Fri, 12 Jul 2024 11:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807979; x=1721412779; 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=QqtdDMsD55pEoQfMNz6zeYZQAoeVSzSneBvTBBwc7VY=; b=bOD/Bbt9p0oq+UIlI6yQUt/3spsVvCQJ45K8QxXKMW+tF/zvIdPBb34i+2VMJy0Gl8 2RFtgNNDXFTZb048q++osDhntcY833jldIYkcECeAn0iP8agOxhP/8D8AdTYsHoZ+/QT IA4TY6qYRo1am7amPf0sOP2I+WC5jIWaqkUTTy46mGkW0y0G96BLvdaVCcGBS8FwhRYo F69fXKDa4pOmNVvEHxRuZR+JvTHUZ+s8DjD4wWMbmIZq7gsxb2fUJzW02bmPMkOopS7k /Hrc6TMetBU/d3Vao7HD3M60SXQZeDOkbQr8BFUoyN4QyoKYNVESbmY7QM7lymbtmUxH rvvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807979; x=1721412779; 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=QqtdDMsD55pEoQfMNz6zeYZQAoeVSzSneBvTBBwc7VY=; b=E7JXJT9aWDM1UU7Z7n+g1bu6u0lyUMC75kJWKpWmBxQMgo8Ey9M9dUNisirdWUZD+G eygAWkW+auAKdTIhEy0+3i490KNz0jPfDCpMyFgIP9tCs70knmMCCIwsI8RKBEoHJFRB IwUFlzzSVLn+JxVt3YndrFxyCKIbcDcOvCeNg13WW0gZAJ1DGXtgvMiLCf4fKctWqAze nKZockqcI9SohSphfY/0T77WGi/eXPW5VGvIUu0BlDVdBrcTDs6B0atWYPL8dQCfrnrH b3ilaNhrZ7yHLZVcGHGCJ9SrSz0874TGtVBBp1DFSOXsG7/rLRqvtqnsk4y0L9jx0XP2 dNyQ== X-Forwarded-Encrypted: i=1; AJvYcCUz4CeTGz0X+FqOa+R3j8zUuu2TirpI7W1muwTT6kXz2N0WbdWhKsG+7dJ49Rx3ck8g+X5XkSxGp6YMPHzD0Ga00xSr97DBNAq0teV2 X-Gm-Message-State: AOJu0Yx06WnWR0Ta+mLrvemG0qjHKTm+EDbduJT+T81I+Yz/ecGXq6iq 0ksHlR+VBl0vStBfG9FuRo+JotEE5xmuGfn/SiQo80C5MCt1nrraqiMLx5tosSOeueljwkVG+JW FjXooMw== X-Google-Smtp-Source: AGHT+IEnchojDdZ76Vxn9f7h4DhTLRV8huHLPOkuO6TlwqAevAk9P1WjzXQqv38Bbw3agIDos4xIMuc27TcD X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:1208:b0:dfa:48f9:186a with SMTP id 3f1490d57ef6-e041b0370bbmr26212276.3.1720807978826; Fri, 12 Jul 2024 11:12:58 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:03 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-23-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 22/27] perf data convert json: 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/util/data-convert-json.c | 43 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-con= vert-json.c index 905ea9823f9d..20bfb0884e9e 100644 --- a/tools/perf/util/data-convert-json.c +++ b/tools/perf/util/data-convert-json.c @@ -316,39 +316,36 @@ int bt_convert__perf2json(const char *input_name, con= st char *output_name, struct perf_session *session; int fd; int ret =3D -1; - struct convert_json c =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, - .lost =3D perf_event__process_lost, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data =3D perf_event__process_tracing_data, -#endif - .build_id =3D perf_event__process_build_id, - .id_index =3D perf_event__process_id_index, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .event_update =3D perf_event__process_event_update, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, .first =3D true, .events_count =3D 0, }; - struct perf_data data =3D { .mode =3D PERF_DATA_MODE_READ, .path =3D input_name, .force =3D opts->force, }; =20 + perf_tool__init(&c.tool, /*ordered_events=3D*/true); + c.tool.sample =3D process_sample_event; + c.tool.mmap =3D perf_event__process_mmap; + c.tool.mmap2 =3D perf_event__process_mmap2; + c.tool.comm =3D perf_event__process_comm; + c.tool.namespaces =3D perf_event__process_namespaces; + c.tool.cgroup =3D perf_event__process_cgroup; + c.tool.exit =3D perf_event__process_exit; + c.tool.fork =3D perf_event__process_fork; + c.tool.lost =3D perf_event__process_lost; +#ifdef HAVE_LIBTRACEEVENT + c.tool.tracing_data =3D perf_event__process_tracing_data; +#endif + c.tool.build_id =3D perf_event__process_build_id; + c.tool.id_index =3D perf_event__process_id_index; + c.tool.auxtrace_info =3D perf_event__process_auxtrace_info; + c.tool.auxtrace =3D perf_event__process_auxtrace; + c.tool.event_update =3D perf_event__process_event_update; + c.tool.ordering_requires_timestamps =3D true; + if (opts->all) { pr_err("--all is currently unsupported for JSON output.\n"); goto err; --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 A0B2B17E8E7 for ; Fri, 12 Jul 2024 18:13:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807984; cv=none; b=PLD2Rb3rX7XodMD9ymGGjPu82k86zISZ1eEfOIXtVQprY6uarzqWSvZikwIsxK0waKXiieB3mmnTdROzKVkSXmWpV0vJqbWopeCirM5HCujYI4BnSjXkIByAbX5A+uQqN06HPa+Zb9uaw+bmce6svFv9IgdpkU5Wffz8WHJcj5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807984; c=relaxed/simple; bh=IiOUbHu6Xz1VISLL+B0ayGxLanWqPidsSe75Qtiw59I=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=TXvAsPTDSSLDcgKR29OD70pINWf7SSODnOflwGqtRSG/Jh8y+sNueXKnaEBJSNqCFpe9wsy9jHt7nkutgDUq2ofdkA+tocebZqDF2AsOvLa3H+gx/MBj9I28fsC6JxqGMlXL1iRD2mehOqYmvc6Km+gheaPHbQ7uWTMnyDE7q78= 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=rlrBGB07; arc=none smtp.client-ip=209.85.128.202 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="rlrBGB07" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-654d96c2bb5so38505127b3.2 for ; Fri, 12 Jul 2024 11:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807981; x=1721412781; 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=I9Nrbi73tEJWZxPfyj1GxchBACZKBze8WVP6UfEoRnc=; b=rlrBGB07ulbu38xgl3cGaQeG9QqD1iHSJBKuxu1e6/yw9E+xSDkoP3McAA+VD3sFFP 3sT7TDEisyHiglyNfTGNzMc3HEnKEokO/FiJSj1gB+j5LVbNs2pCVMU/m9N6phRqqU2R sPADzogBaXBnk2yqY+l5tZarWHR8uOZilBqy50DPbWSDs4Hn5GhBmfI6okx8PEjljbnh 6894QmX/uUN/o6IDh5Udp5AN/eZEdcioEwp2d4n7ersmdfgYGk1YEKeumtsHPKXAWvA9 CTT54B98ulcuyrkZum3m7hvVtjK7AkiCRyd1EVkkCsS6tYupLm0kW9m5Flg6T1lGOe/R cpvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807981; x=1721412781; 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=I9Nrbi73tEJWZxPfyj1GxchBACZKBze8WVP6UfEoRnc=; b=YztraMvt0KUrZJmUXpp6T9l8oDPqrluyLZbGC6jtLd+qwMWLtV+05B2+5tzOdxkEOs G13oTm5mcLHU/QKCF0UQBhhVHqn6dkyODR5KrchhPe2MOeKdTzu5OpT64HAtwrNB1Ij+ 1u2/JuvWBe4F+h7Eh4u4LWvJriz+b41mDerhCGxjeduB1ffqPxYbaN7KUL7t1e6utdRj ge/N4eAG+8oQJso8DkoHYPxeGN2FEDpSi74jp0o6NUC08CQ9DXEhPlzBJvc4I5mrG3SG AA1KszpU/7RGWmL9CSkVX+xt/5ah9PxEk0XmncBFoSiMhkFRlyXyuOljtrQmRSJ63yuq mm4A== X-Forwarded-Encrypted: i=1; AJvYcCVgFxuqQnlmFWuzj1Gq8jpooEQ7FsA8jM1mGZqfkqELSFSKgUj7eXNukBNCt13L/2UHoU+WX4K0NSZ46ZDGv6BnqPB9mxlAhQ1imWeq X-Gm-Message-State: AOJu0Yy5FZRtNtFG9NKWc2glmR0iqQlTVE10IfLQebzL9ivpPJysckrh HRO4ORKppYZ4Wt1uyxl9JNams8f010elkx6745Qn5jhg1Aa9JbohJvA0858ppmNBU5dKZEEb6cT R37JTOg== X-Google-Smtp-Source: AGHT+IHbbwHCzdchAfHj2SPmGVg9X+8SLDnkVDWoP3VU6MRCDTDk07UDfpwPw7rKkSi8K/BWJzAXGMd4QWb8 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:2b0d:b0:dda:d7cf:5c2c with SMTP id 3f1490d57ef6-e041b17798cmr23901276.13.1720807981253; Fri, 12 Jul 2024 11:13:01 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:04 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-24-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 23/27] perf data convert ctf: 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/util/data-convert-bt.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-conve= rt-bt.c index 9e2170604b66..021e9b1d5cc5 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -1607,25 +1607,23 @@ int bt_convert__perf2ctf(const char *input, const c= har *path, .mode =3D PERF_DATA_MODE_READ, .force =3D opts->force, }; - struct convert c =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, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .lost =3D perf_event__process_lost, - .tracing_data =3D perf_event__process_tracing_data, - .build_id =3D perf_event__process_build_id, - .namespaces =3D perf_event__process_namespaces, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, - }; + struct convert c =3D {}; struct ctf_writer *cw =3D &c.writer; int err; =20 + perf_tool__init(&c.tool, /*ordered_events=3D*/true); + c.tool.sample =3D process_sample_event; + c.tool.mmap =3D perf_event__process_mmap; + c.tool.mmap2 =3D perf_event__process_mmap2; + c.tool.comm =3D perf_event__process_comm; + c.tool.exit =3D perf_event__process_exit; + c.tool.fork =3D perf_event__process_fork; + c.tool.lost =3D perf_event__process_lost; + c.tool.tracing_data =3D perf_event__process_tracing_data; + c.tool.build_id =3D perf_event__process_build_id; + c.tool.namespaces =3D perf_event__process_namespaces; + c.tool.ordering_requires_timestamps =3D true; + if (opts->all) { c.tool.comm =3D process_comm_event; c.tool.exit =3D process_exit_event; --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 579EA17E8E3 for ; Fri, 12 Jul 2024 18:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807985; cv=none; b=t8p3fxoDLg7vafjmFsZ6VThS/w6E6NJu55egtezfiLpsLWMAG1cGPU1CSFtVqGCYSal5gErne1ZcgD/VGxE2U6LyxBQGjd+C1p0eFEMi/VTh1lfN8nguByf/mmsDKEDJOXNX2HsrMTlNRxlDa3nxBNvx2E+gTkfEWeTyAefKUkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807985; c=relaxed/simple; bh=QJTLBouB03fYPDSHR5NUfnIzNoxc+9fFEDyXtvrnJyA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ACse9cYcYgO7NF1dAV0KD6Y8Rxci1fV6hl0MFL5HZGIHXT9HF8B0uMz04roTwkxlIScDfA+ScDLtvBniAdWyWIWoAdauudG64sXZFU2XgkUdnaghEw9kuKOZWVcAj7KuCXtvG19fTTUHHa5Oo2J1vLXWRyOBe6bDNxoAZsy9pLI= 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=g+2dJRJG; arc=none smtp.client-ip=209.85.128.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="g+2dJRJG" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-64b5588bcafso39773307b3.1 for ; Fri, 12 Jul 2024 11:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807983; x=1721412783; 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=2MNiLSniwVv1E9e5Lf2m3HZTOrICLuX9boz579z3/KM=; b=g+2dJRJGLes43brEiSWMPR4dnlcdJ38NfQNdreNPiMZImCQlxoGZsBtX/Y94P6e79r caR/NL12WEjfXJxYXQpxaM0+H0L1W92rAO/Xb+TaywL0X8BuSGkCxtn8zfqZmkGxImew +gkiTH/0sQMy18STO7sD+5QYmLzdQJiLhHSvxwnBVrMkIwacqAmp/AF5UCdeN5rdboPw wi/Nh5BYbviYmLpQsRKv6zMM/v8poVKQX5YJ6u6KslgjCkqgVpk5pLWL/A1Xo8Hg6TmU x4GzbT10fBv7hkGIdWoHObtKTFN1pODaVWjqReVuley0qqrxRca9BbatShDcui4hHew0 APNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807983; x=1721412783; 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=2MNiLSniwVv1E9e5Lf2m3HZTOrICLuX9boz579z3/KM=; b=YTEJTk16aze4LnrTxQ2+ouP9JjTuQvF36SV+2X54w3X4apDLHb7ELU2jj5gww6UdSk iNnPBvuhNZS9XD3nK3fcLEg041KkG1MFtA4nWpwffFRZmp/LmRdVfA3c9pGYQaAdojXB j6shdLbz2M5PCJTpDlNDwDEzdGW2S+fMDj+ovZJJazhtzFp3GevribXTHQfwBgnJNVNL cj8XE/PQf/waIUAMu9gJn4Ks0VV1+ufAJwHjD6DdbLC81gRKSyyLkv2TDD0ls3Ux6DUc YLxgJjK7z8nN+IGlel1aBVN1agZw2PtdV7K2wTCIHmvB1YQJExp6d5eHEePL9Ab9jSSK ObQQ== X-Forwarded-Encrypted: i=1; AJvYcCUJsUuxvBy7D+N8RjNhpcIbqh04SQcxVtEH7qlpp5tn/LvkHskyND6maiWWzIA3VWkzueZmSWZuE3bdZ0hkMsx+fjpoD27q3Qt78T08 X-Gm-Message-State: AOJu0Yy68t7wkXNn8YlY8SE2vwi9fsu/xWwj5mAuR3/tDMm8U8ORyhf3 WTFl/2UU2Diomrrwf+tWyyDPjv5f5lu8gxgiBn4XpmDQ7wFOVobi91ymdamqajkvbrxtroauu4d wupQhQw== X-Google-Smtp-Source: AGHT+IHT+bmwbpCCDDBGyKMSZDJyWfQuQtb+HSakU4o5bWugocQR0tn5FoTRKGbLNL6FlQgXTAEyTtQZuZbw X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:4d8a:b0:64a:d1b0:4f24 with SMTP id 00721157ae682-658f06da930mr3078967b3.7.1720807983544; Fri, 12 Jul 2024 11:13:03 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:05 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-25-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 24/27] perf test event_update: Ensure tools is initialized 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" Ensure tool is initialized to avoid lazy initialization pattern so that more uses of struct perf_tool can be made const. Signed-off-by: Ian Rogers --- tools/perf/tests/event_update.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_updat= e.c index fdecad920f59..d6b4ce3ef4ee 100644 --- a/tools/perf/tests/event_update.c +++ b/tools/perf/tests/event_update.c @@ -103,6 +103,7 @@ static int test__event_update(struct test_suite *test _= _maybe_unused, int subtes TEST_ASSERT_VAL("failed to synthesize attr update scale", !perf_event__synthesize_event_update_scale(NULL, evsel, process_event_s= cale)); =20 + perf_tool__init(&tmp.tool, /*ordered_events=3D*/false); tmp.name =3D evsel__name(evsel); =20 TEST_ASSERT_VAL("failed to synthesize attr update name", --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 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 B703417E91D for ; Fri, 12 Jul 2024 18:13:06 +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=1720807988; cv=none; b=PXh+IlU75t6I+nziVYpChx4xvIUGZ04C8K/mydDmo5/okR1eOaNp5OotC+otfDbXPGC5swHQREStXf2jyAIo1gN1WyUdTMaftoGE0745zQzt0eFATVM5KWUO34oLLI2/wpelXdtIlsbWgwhEdJ0Jwft5ZoQy5jn18nsPJsnr2QA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807988; c=relaxed/simple; bh=Vut48/dGoEfPl82dZRBs1EiuBD2BZmTC7MWAiL1FIkY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=l8Vqt8qfOYu7Fo8Akh/5LQCgHGUIS4wOio9JBMio7DfyUNFUNg/tx04gYzvaDf2t1OaOEjVjh/cHLVseTWFmyh9SCJGGO2pxlS+WaGEcQERWTztuV3Aq0DhlN2KY/t5fMa73dlg1KK78Q16CSPOibF11H3wOEeK0MQDqJn5SseY= 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=YVyQYX1S; 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="YVyQYX1S" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e03641334e0so3751691276.3 for ; Fri, 12 Jul 2024 11:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807986; x=1721412786; 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=phxqvYyYZFcsS+fO7HmN6BaHRpzOxQeFfvDLLgr+3hE=; b=YVyQYX1S3LMTGLFTT5Y3VofmBblpBhm40WZsFqC0DhUR+YCrormI6gn17OAEveBj7A e8TqMKC50XcDb6pJ4Jt64k3XN/4OP53GfroTcB8+6X+sJzMXcgrvzvCy2ODo4TuWTwrJ OwMbD6S4pQLBph4IHIYqHINMGJkvzLplMBMMufplUOnYYx5zQKiUrMmuRiLC3O/lJlJA HlILyqc4/ZS1at0nwlk/285wsL+MuyZGR+5newwO2UpPx6KLjYzbkZ+1QjgC67n68S88 IYpb7CRi3qNd1OykG7141ASiobJLzeXSJoEQd9zGbOK4dDKYACpHa2TjXjnrLXDEgJez gLEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807986; x=1721412786; 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=phxqvYyYZFcsS+fO7HmN6BaHRpzOxQeFfvDLLgr+3hE=; b=ajrtE6r2uDf7w0Sxa1JHkw+a/8xwIRVbj1KWcC9HEvmjGqu7mjlC+5kdB4jrvXyd9i H7+YC0pZ3o5nd13riAC9r6rwWY41B8fsc/QZiF3mJChczsPgHpjGeItCAeN1G/clhXBj mnB/JsKRmPUHCqEc4/4DprVRO3pBp4M1DIa2L4ECzvWPFqvH6r3D652gHkW9km2l75H+ QW6WHDGdYsR/LZUysA+F1NL9NyVbpJhtrMEooWdE6eV7arSkRo+WG6ZeCGSNtRvfBx0/ qerHDyN1zW5LOXlSUudEOqWtUAIM2+aCM5dH4AJX3gQoKf+X+M4n6u4grPoAgXGIzKDq B1NA== X-Forwarded-Encrypted: i=1; AJvYcCWH5HcPvTCHxlXKfkE2H7sOjNhHQyV2swynhjqaBpkW/l5AJmkOjGsxBsA87yPSWjK5jJSDqIA6/hmJn9bKSHKrTTO+7/TjfE4Y1oSt X-Gm-Message-State: AOJu0YxTQrCPwj39IMwh1IiF+r3KceYEMhGeyg0IfIjGGW4nWOpcy7de iqC+HOr9CQhDdDBydozgS7J/IvLmOQa/IeDlWRcZP42NPcGyeekoLErebOUxqTWytYzHM/w6BNC jqqwlvw== X-Google-Smtp-Source: AGHT+IH55ouNUARRkV/7vwiojtMsBJqnZMjnyHFWfmbeG3E2oRRjNgYMj3GXuyIvTVcz6xeK7mzL5W5Xp8yA X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:1b0c:b0:dff:396c:c457 with SMTP id 3f1490d57ef6-e041b0364b6mr21640276.3.1720807985767; Fri, 12 Jul 2024 11:13:05 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:06 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-26-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 25/27] perf kwork: 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-kwork.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 8ffaa80a2d1d..6a4281b8fd10 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -2322,12 +2322,6 @@ int cmd_kwork(int argc, const char **argv) { static struct perf_kwork kwork =3D { .class_list =3D LIST_HEAD_INIT(kwork.class_list), - .tool =3D { - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .sample =3D perf_kwork__process_tracepoint_sample, - .ordered_events =3D true, - }, .atom_page_list =3D LIST_HEAD_INIT(kwork.atom_page_list), .sort_list =3D LIST_HEAD_INIT(kwork.sort_list), .cmp_id =3D LIST_HEAD_INIT(kwork.cmp_id), @@ -2462,6 +2456,11 @@ int cmd_kwork(int argc, const char **argv) "record", "report", "latency", "timehist", "top", NULL }; =20 + perf_tool__init(&kwork.tool, /*ordered_events=3D*/true); + kwork.tool.mmap =3D perf_event__process_mmap; + kwork.tool.mmap2 =3D perf_event__process_mmap2; + kwork.tool.sample =3D perf_kwork__process_tracepoint_sample; + argc =3D parse_options_subcommand(argc, argv, kwork_options, kwork_subcommands, kwork_usage, PARSE_OPT_STOP_AT_NON_OPTION); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 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 D0A9117F38B for ; Fri, 12 Jul 2024 18:13:08 +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=1720807990; cv=none; b=sXOTi2iSR2z9hXEgumsHsABbbtEn4Q9OvMMnydVEWl4jHfsiocPtokEEOYcJlYW70YPQce76Zyo1MyMZMlVgc95wdcGAHzCTQHpYLSIKgvzbJx0WfeS4B+qWzoi9gRFoZsfv2f1leKNl7m/zVCfwY2urp4OZDM3IqfqCRw1vfW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807990; c=relaxed/simple; bh=nog9HAZnBs/Uc6gA5S1tlyf5AbSf3UPE1Jgj8toxgcs=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=uhJViRNm/HuuZtathjX7szvjYgbuiSn2+3jtTwCiyaS8Cu8/R8ix7/picrVVZjs5+GE+GznM/swYFyZnz9HVE8a8vhFzeWMAB+6evdSUdQ5fflEaM2SQw/iCtIG/Y3rHKum5Tztjy58fTNxi43+sr5WQQKAlQlU2+1TJCdv87Rg= 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=Bs2SyOg2; 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="Bs2SyOg2" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e03a59172dbso3772743276.3 for ; Fri, 12 Jul 2024 11:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807988; x=1721412788; 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=7XS/BS2tmrMYCpclJsc0ik1l+h9pEP1QMQPO1IiW0Pw=; b=Bs2SyOg2D3OFDLbReFChqQNX2Pf0FmnZ3miW+zEbK/DPu/krL+iPFj8x9opMqSy1C9 388TnuJkECz8F690zHGtUUyNHOQu2D+/8oFlUaX0bpjt841F5qdIlGcjz34SRcCTE3Pv v8NG7uB1Nz4wtRHnS37JSlvpS44BLmmiww+skIcJAEwLViOaQT1Era9PIGZGy2KmKmWb 1NFdFhI99oaUxYbcDuNKVwQ+aoN5IDWJStYkSu+izPIWuKECuUN0o4Oe4Nc3wvZ45gRE j9BJcWaWJTYHEfxJ87sJeHdFc6qODrQHe9GrL5v9NTIqQ8Sa6aPiGwYZwPyKhBRGPHfY +J/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807988; x=1721412788; 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=7XS/BS2tmrMYCpclJsc0ik1l+h9pEP1QMQPO1IiW0Pw=; b=iab+VvyKbFSegRAYIXyFXiscDIZahC2LcNXFXHw89/MKVf9kqreKTv6fO9Iaxlq3I8 +LIpseKdf3IeHIvz9BR0wXQkl/IbQ+3eEo4CZmQrA+e4XEmf3mDRuKSrLwpG3AGSM+mj 1t/SaY/kY4wqyncHzfxPx8015zS4F9w3UZC5qLm5Z2CW8ejTyaDCbRuvd5vaFStbDWcy U9jGSYyIreZxleV6ehcTvGvB++OV/GLecbgZnY+yIIVQ3cfdoUpzGjXZ1Zcbvyk4Ee6N qlymW1io4pjRSZdT08vDwUlpt0Irinut43M54p6pguMyMTv2gXzaVsWI0eVOY3ymBvFh llWQ== X-Forwarded-Encrypted: i=1; AJvYcCXRttbmKZRm4QRDaEkGxJ+qiZnS6Q5/nC/OIRoITeFhy1xIrb3WNU/CbF3/kGstO2Uyk5aBm4jfEAyz8jyvzEkMrMrQAIJYiEgk1MXs X-Gm-Message-State: AOJu0YySWDg34rhnvg07+ZpQkNGConBVbEOjUKRBkl1QEk5co9/PCzOR nTi3diS1j+8MMncjCB+twumlRMEQ4X+NzZr1VmAnt1HpNlsj4xXuh0xkHWtHGQWBIyYWyyoJ1o1 cGkoSRg== X-Google-Smtp-Source: AGHT+IGRQeviKtJ7AI/SKvJvmycZj8/fIM55epBno0pPkXZ9si90TtF8Qxi1wIa6axTSZEDzMtO8YxPJZp54 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:1ac1:b0:e03:62dc:63de with SMTP id 3f1490d57ef6-e041b0593efmr961462276.6.1720807987989; Fri, 12 Jul 2024 11:13:07 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:07 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-27-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 26/27] perf tool: Remove perf_tool__fill_defaults 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" Now all tools are fully initialized prior to use it has no use so remove. Signed-off-by: Ian Rogers --- tools/perf/util/session.c | 6 --- tools/perf/util/tool.c | 89 --------------------------------------- tools/perf/util/tool.h | 1 - 3 files changed, 96 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 5359ee055c85..ad5da61d2330 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1776,8 +1776,6 @@ static int __perf_session__process_pipe_events(struct= perf_session *session) void *p; bool update_prog =3D false; =20 - perf_tool__fill_defaults(tool); - /* * If it's from a file saving pipe data (by redirection), it would have * a file name other than "-". Then we can get the total size and show @@ -2201,8 +2199,6 @@ static int __perf_session__process_events(struct perf= _session *session) struct ui_progress prog; int err; =20 - perf_tool__fill_defaults(tool); - if (rd.data_size =3D=3D 0) return -1; =20 @@ -2255,8 +2251,6 @@ static int __perf_session__process_dir_events(struct = perf_session *session) u64 total_size =3D perf_data__size(session->data); struct reader *rd; =20 - perf_tool__fill_defaults(tool); - ui_progress__init_size(&prog, total_size, "Processing events..."); =20 nr_readers =3D 1; diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c index a4ca16e5eefe..3b7f390f26eb 100644 --- a/tools/perf/util/tool.c +++ b/tools/perf/util/tool.c @@ -288,95 +288,6 @@ void perf_tool__init(struct perf_tool *tool, bool orde= red_events) tool->finished_init =3D process_event_op2_stub; } =20 -void perf_tool__fill_defaults(struct perf_tool *tool) -{ - if (tool->sample =3D=3D NULL) - tool->sample =3D process_event_sample_stub; - if (tool->mmap =3D=3D NULL) - tool->mmap =3D process_event_stub; - if (tool->mmap2 =3D=3D NULL) - tool->mmap2 =3D process_event_stub; - if (tool->comm =3D=3D NULL) - tool->comm =3D process_event_stub; - if (tool->namespaces =3D=3D NULL) - tool->namespaces =3D process_event_stub; - if (tool->cgroup =3D=3D NULL) - tool->cgroup =3D process_event_stub; - if (tool->fork =3D=3D NULL) - tool->fork =3D process_event_stub; - if (tool->exit =3D=3D NULL) - tool->exit =3D process_event_stub; - if (tool->lost =3D=3D NULL) - tool->lost =3D perf_event__process_lost; - if (tool->lost_samples =3D=3D NULL) - tool->lost_samples =3D perf_event__process_lost_samples; - if (tool->aux =3D=3D NULL) - tool->aux =3D perf_event__process_aux; - if (tool->itrace_start =3D=3D NULL) - tool->itrace_start =3D perf_event__process_itrace_start; - if (tool->context_switch =3D=3D NULL) - tool->context_switch =3D perf_event__process_switch; - if (tool->ksymbol =3D=3D NULL) - tool->ksymbol =3D perf_event__process_ksymbol; - if (tool->bpf =3D=3D NULL) - tool->bpf =3D perf_event__process_bpf; - if (tool->text_poke =3D=3D NULL) - tool->text_poke =3D perf_event__process_text_poke; - if (tool->aux_output_hw_id =3D=3D NULL) - tool->aux_output_hw_id =3D perf_event__process_aux_output_hw_id; - if (tool->read =3D=3D NULL) - tool->read =3D process_event_sample_stub; - if (tool->throttle =3D=3D NULL) - tool->throttle =3D process_event_stub; - if (tool->unthrottle =3D=3D NULL) - tool->unthrottle =3D process_event_stub; - if (tool->attr =3D=3D NULL) - tool->attr =3D process_event_synth_attr_stub; - if (tool->event_update =3D=3D NULL) - tool->event_update =3D process_event_synth_event_update_stub; - if (tool->tracing_data =3D=3D NULL) - tool->tracing_data =3D process_event_synth_tracing_data_stub; - if (tool->build_id =3D=3D NULL) - tool->build_id =3D process_event_op2_stub; - if (tool->finished_round =3D=3D NULL) { - if (tool->ordered_events) - tool->finished_round =3D perf_event__process_finished_round; - else - tool->finished_round =3D process_finished_round_stub; - } - if (tool->id_index =3D=3D NULL) - tool->id_index =3D process_event_op2_stub; - if (tool->auxtrace_info =3D=3D NULL) - tool->auxtrace_info =3D process_event_op2_stub; - if (tool->auxtrace =3D=3D NULL) - tool->auxtrace =3D process_event_auxtrace_stub; - if (tool->auxtrace_error =3D=3D NULL) - tool->auxtrace_error =3D process_event_op2_stub; - if (tool->thread_map =3D=3D NULL) - tool->thread_map =3D process_event_thread_map_stub; - if (tool->cpu_map =3D=3D NULL) - tool->cpu_map =3D process_event_cpu_map_stub; - if (tool->stat_config =3D=3D NULL) - tool->stat_config =3D process_event_stat_config_stub; - if (tool->stat =3D=3D NULL) - tool->stat =3D process_stat_stub; - if (tool->stat_round =3D=3D NULL) - tool->stat_round =3D process_stat_round_stub; - if (tool->time_conv =3D=3D NULL) - tool->time_conv =3D process_event_time_conv_stub; - if (tool->feature =3D=3D NULL) - tool->feature =3D process_event_op2_stub; - if (tool->compressed =3D=3D NULL) { -#ifdef HAVE_ZSTD_SUPPORT - tool->compressed =3D perf_session__process_compressed_event; -#else - tool->compressed =3D perf_session__process_compressed_event_stub; -#endif - } - if (tool->finished_init =3D=3D NULL) - tool->finished_init =3D process_event_op2_stub; -} - bool perf_tool__compressed_is_stub(const struct perf_tool *tool) { return tool->compressed =3D=3D perf_session__process_compressed_event_stu= b; diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index fb7e32d98dda..0874e7924687 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -89,7 +89,6 @@ struct perf_tool { }; =20 void perf_tool__init(struct perf_tool *tool, bool ordered_events); -void perf_tool__fill_defaults(struct perf_tool *tool); =20 bool perf_tool__compressed_is_stub(const struct perf_tool *tool); =20 --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:56:08 2025 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 2F52E17F4E6 for ; Fri, 12 Jul 2024 18:13:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807993; cv=none; b=aZU8/aovDl4Y9+7bFKTqD4VdN3cn0gj4sFADI+ZgEk9IO47iy50q94EaOAYtEwsLdY4qd2px8sJ0n5/r8exYNntbHuVggzFnBr+3+644ysl9RIAxRQcP6hkhmNXRanB2azwzOodcw3//+ZRXDd9ntvtReMnL46M+PaYXKFhkxSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720807993; c=relaxed/simple; bh=sUheNSIamO8SvMj19zBLNxCVmjvlLRxDlh7AUAyjtXE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=YOi8HZsA6mlrh6q+D03Iw9jOMIgbp9QwiR5bQhDUverIU2RrtqCsEQ7cLMrwhcCUVgVL7qWFp4yVt1Jgc3cw+h7LFJeuGGhgqzxjwG7DPy59jvdh+EiSVs8MbYbU/Q4SdlCH01tSFw9mk1m3hZxBwGEpT0R71DBfSQfsJFHSd8A= 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=SjQrw9WO; arc=none smtp.client-ip=209.85.128.202 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="SjQrw9WO" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-653306993a8so37569207b3.1 for ; Fri, 12 Jul 2024 11:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807990; x=1721412790; 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=DzgUQ0L67yHK9ZgYOmZnLIT3MZDT9EVRhOxDmj12OGQ=; b=SjQrw9WOhPtCuoJDNhuMHweOV7gQ9mK7LuDbSS2TafyJHxozCGDaudmRZmuvbwNzkC AQJtP3//pCleloSeRtPxj3XZdKwarSMcNDYoIarIaEgdr96/GuEnD1zTnpCGFxyrmhl3 2gCOkgXB7rqukJ2KBjxRGlRvoTAA6GdSoG9EYFsbWlsQvEB47dOfFV5MIDKlp4dAxfA/ hTCCSuE3slbHIYE2aPyCAyaGw/AwlVdrVrX3PmxztJZl0qbizmktkBKJje/rNrUsjJND pjFp8zSSxAkTLqPtKwIL7XayZxHnxx4IQ01voSnVVxzd98/uNFMIIl7JuwCh45ja06uv 5L7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807990; x=1721412790; 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=DzgUQ0L67yHK9ZgYOmZnLIT3MZDT9EVRhOxDmj12OGQ=; b=kS16KEgJGdXl2MF6P8lF93TqZBrF6Y6HiB/eNRP5ih8WqCis8292Ud8e5Nv6w3oKuQ em/cWiSIs+gu8VPi5hEo1Z4e3INuWP96Nn+lF0KNM2hXfnljo/M1KVp8PXV3bOz2CHkf rRMqyENeB436Fu1Xgy0xKj0XALTXQMIgEI2G2yuOZzXvOVB5jHwWm2y/FI4WTSPcWkHx 4ugc5aByT9Bp++kBEOW9kfTvpCHzvXtbMLuwHni64E6eO+8lzXUsXw+zMxCWoCiVEfYQ uFIxb5Pda7BX9Ct7WLHmn8awBz9GSH/ywyAdLhyfE1SMK3udba0St2P4iPhafSN+tYnY 9dLQ== X-Forwarded-Encrypted: i=1; AJvYcCXjAi/kni5TvUCfmVX3nJzyDcPK6UKfWqnRzi1OEKWuxQy63rirrHmFBJKFPJnifW6s0F88sNZB1vZIe/ImlQYNgB0jFqCsBYjKroZT X-Gm-Message-State: AOJu0YxhP9RbpAzcdwcHGRFtEE8fPnnqluxUck0pPIJkprj/9L5ihZX4 mp18wPzdm7oyQdRVp4eOS38lwx8zaT6HPo36uOMiySUtZyux6BSbses//kP/PVQykxdzfp6qv9n m0vt8+A== X-Google-Smtp-Source: AGHT+IHiAKXzsCdcEZM+MFSDfgz1r4L7ozGy4B9BF+4puH4qqiiY89mJfDURywhS/WGVSxBcH3QuZhcuBDvg X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:188a:b0:e03:2217:3c8f with SMTP id 3f1490d57ef6-e041b035055mr23746276.2.1720807990114; Fri, 12 Jul 2024 11:13:10 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:08 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-28-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 27/27] perf session: Constify tool 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" Make tool const now that all uses are const and perf_tool__fill_defaults won't be used. The aim is to better capture that sessions don't mutate tools. Signed-off-by: Ian Rogers --- tools/perf/util/session.c | 6 +++--- tools/perf/util/session.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index ad5da61d2330..0c7cc092887d 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1765,7 +1765,7 @@ static int __perf_session__process_decomp_events(stru= ct perf_session *session); static int __perf_session__process_pipe_events(struct perf_session *sessio= n) { struct ordered_events *oe =3D &session->ordered_events; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct ui_progress prog; union perf_event *event; uint32_t size, cur_size =3D 0; @@ -2195,7 +2195,7 @@ static int __perf_session__process_events(struct perf= _session *session) .in_place_update =3D session->data->in_place_update, }; struct ordered_events *oe =3D &session->ordered_events; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct ui_progress prog; int err; =20 @@ -2245,7 +2245,7 @@ static int __perf_session__process_events(struct perf= _session *session) static int __perf_session__process_dir_events(struct perf_session *session) { struct perf_data *data =3D session->data; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; int i, ret, readers, nr_readers; struct ui_progress prog; u64 total_size =3D perf_data__size(session->data); diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 7f69baeae7fb..7c8dd6956330 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -43,7 +43,7 @@ struct perf_session { u64 one_mmap_offset; struct ordered_events ordered_events; struct perf_data *data; - struct perf_tool *tool; + const struct perf_tool *tool; u64 bytes_transferred; u64 bytes_compressed; struct zstd_data zstd_data; --=20 2.45.2.993.g49e7a77208-goog