From nobody Wed Dec 17 01:10:38 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 84D444A0A for ; Thu, 18 Jul 2024 01:00:39 +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=1721264441; cv=none; b=QG/tFxiBltJsJVWTpiGIu1G9Z5GLG29+Dur+m7uyH6CQa840NBRatpdYW/kV0MclOep7W6Q3lwBxpo3o0WxXs3VKoTEaBUEpe9lC1oTGK60DIRuE4mmd+nZUj6vifjkOZR1jyN/jzU2pFijHs2nTTfs4MVBhtYi4l9lAGqmJsJ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264441; c=relaxed/simple; bh=axSrt07YKEcGyRkfZftuqj4Vl4d+kkSuG6NbQDLQ3sA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=rWhArmR/q6xcTlicJNO95FMy0aT9YojUq6WwaSZKwNJRqQpLVmY28AJEGSYRq1oqVGu4AMhKYq4md6WZ+HEEraBarWtFI1gojYI5RdXuo63oqnaKbbc2Hw++Plx707dG4l5/O4KyGHngARgV3obxSgUN380WyHHDYvZkp1h41B0= 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=G0nh215F; 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="G0nh215F" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e03a5534d58so685793276.1 for ; Wed, 17 Jul 2024 18:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264438; x=1721869238; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=h3hGifXSQjj3nm6fESVDyQ4AnTNn7U8iAdJU/7HOQ5M=; b=G0nh215FKdkcnihpWWH9kqdYLYWJxf6lQ1nZ7b7f0NS1U2aZUEyuwORaZbN/lYjiQn +7R0q75sNm/mUDHfFK1V8IJQKGNikovpq6Yi+eRulykaOB/P+BPNjgZAhlz+Sj/9MZg4 S8o0RuxVephxq7H9P70EMONrQ3UiUkZkrrLFN9fDCWj34cl1HsNgKp3I7ZqXTtXNTdIy oT6n4HIFBa52aaJLWuv+ykHNBtVa0sm/j8CW14kOSn9LhX/XWHu6S40Ik+/JXrngpQ3Q Hav94XOukjlj7k1mylAYENRIkhgkEFxzvrY+oVq+NYVcLAvkuStGy/KeMDfQuym9Bb8T aaKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264438; x=1721869238; h=cc: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=h3hGifXSQjj3nm6fESVDyQ4AnTNn7U8iAdJU/7HOQ5M=; b=W6ABFQrYlynyB/KLmI0yZVQTSRNEtqbJdqq8GEDdKzkhHlR5ZmEdlJyXQ+haumWiB0 r85drRS0HcDtGgwNn383htebc3t7i0EqEK8hZQpMAYq22GAOlS7mtHQkFGjgLMmtHt0G lzkA5AU/JcWTE3iC30vqmXSmyp47j/9XqtYD/FHGUmU0shV1Qg3VBSU5j1A87xy4cjc2 FsSzsoupWbbAtAshJqfZnzVt3dz2QECAwyQJmZGBCqj99fRoOfOiZDnrSmnfobg/MWfZ kkT3Xd0wqUGlbQIVjtTnX2KuV4U2yn6rCpOLEnIewLG9B10asDap/hOj87CGhq+wWAlB ex8w== X-Forwarded-Encrypted: i=1; AJvYcCX/k+05BNrsSomBOKw6fWKpOFt/vOJbhLVe+NJRDk+7usxFQ+5BlCDDxFHaIuSTtQBJlIAlcNm2F7nYthnlsm+P0vknutpJr2CayrGb X-Gm-Message-State: AOJu0YyWKJKeiWH2rYHV/YKan0hLbbncJ77e2MLNeemnbeEs1t3m2TRH F8ZZmZDpwdhUpngka+fNgQcCVhPeERBdAFihQaV01PTygwo6QxPxsgwQhPPAwS1fIv1PUsKR4E0 CA7H5TA== X-Google-Smtp-Source: AGHT+IHw3VaaUAUkP9J/OduZR01vk+bxSTc0XaiCAt/SDLKwoDxaATIJIqZVnUceV4pBafhIsjwxsfpQNkph X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:c13:b0:e07:2e88:89fe with SMTP id 3f1490d57ef6-e072e888d78mr3276.3.1721264437877; Wed, 17 Jul 2024 18:00:37 -0700 (PDT) Date: Wed, 17 Jul 2024 17:59:57 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Cc: Leo Yan 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 DB9671B86EF for ; Thu, 18 Jul 2024 01:00:41 +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=1721264443; cv=none; b=QS3L0uTjUfk2KedV6TtNdZu1yw7/v+xk8uu3u3r4KoCvNx6bQNyl7ZFwJewTzoDvR2GvvejVowB2zp59lyC3fCZRDheEv3N5uPgYkSEKUDNZd/w0Twih6henGs29FgyTEtnnfVCUBN9rl4VIzFN3p1/mWousY2R5gJYc2644NPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264443; c=relaxed/simple; bh=HQ9pjS5EUr1pSL3eFHsOIf2h0mDHhIWLrampeLYlMAs=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=fVduk0mugXIqzs12xxuXr8SbdrT/zR544aL7OFYPUuCCnM+Nd8tY1RWO0MIIc8f6ujljyA2iewb8LVsmhLujRBSkbZTsGUivLf+imjgpD0ZgJD7tLc3kgC7O7NievC+qe+mdoYPCXE+TNcUpg1EJzwVi5wrUdCOVbRmNhXNxQDg= 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=Cqzm34n+; 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="Cqzm34n+" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-654c14abdcfso7013047b3.1 for ; Wed, 17 Jul 2024 18:00:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264441; x=1721869241; 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=Rfk9ucJoML9tijv9a95Eu3szNeRcTXRIy2V/XQr/gxQ=; b=Cqzm34n+XsYfliHmsC6eCxl1AtFWGMX24ljMwmNkZnEUoE8jOG43Hcg2OT0b1Y3tVA c3Mni9YXKsy07iE4pd1+ZtRtU+VsaOtQvXYjNF8zuod/7HvOP3uRaOzhRJbcXKDrHiF/ WHWMPNkJLdWrbqoorkjxPr7jQ/PJWNBzloU78vhugxoNOPjSqcZAcHyXsPFZnCZ5zRIz aMW9O81JZB99b6+5kNV6uDBpxSOPg/+gKaKKlGS0srSIsxGHD8E0P8rurNMmI/hSD/ow 0SkwwSRI3RMUH3fcgD/V3iAskN9F50+y87Jpj/qqCyhLuWKUybcArKe8d5EMpVniIWHt i5Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264441; x=1721869241; 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=Rfk9ucJoML9tijv9a95Eu3szNeRcTXRIy2V/XQr/gxQ=; b=nnnoOq1o9qekWhd6LbXJzzM6tkJwysk9pfIBJKNBayqQbdj8CpT38YvTSpQ2oS7cA6 nsjUtra0Ss4D+xedHxgi+cUsdDVsDF3uug4L836zVEi7qeRem28+4w2PKnTlUh8zsxxU HdOZzrosgMgrYNw3deGdWvxtDThQriA+JGaz/Xah8Di39O4FRVB+A+DF7KtmU1Tr949g gFchk5sVXEx/wmIvcq6vrCD6UYM9XOT0QuF89R3O2T5sNkzIztGBRsazoAwaFj1N9CQK 5ZQ5Sfia1zL3eerDp8QL3ltOL9eft7FsswlutBLqnUVKUh11ijuCqDHgtvwyXR7cqRO0 bDOA== X-Forwarded-Encrypted: i=1; AJvYcCXEEWd+7ttEJthI320CWWUQVHBPBYHuWe2QLsRSUfxmAR4KGS7wDiDyL/FVwrI//KYJNpybHNYeegowPtvnWMSUNWqawbPTmpb+Srpd X-Gm-Message-State: AOJu0YxgAlNzc/YS6P8yZXmUZJZRYb2dw7eDr/uQwyX+cqypeuFHHcZl v5OoHWwYgLxyVpSKlc3UJZyJogrIuwWYbvRJbGFDtVehPPTb2dIiIRGQe4nP+qC4lomH9fgppfO k+JRmvQ== X-Google-Smtp-Source: AGHT+IF1OSvxnc+b1qvFcgOaFfrd5/kufXk1J812jAsRRfTuvf0iLiBjVTC4aFaquSt3jO72OgbZ/5EwdMFh X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:4784:b0:665:24b0:e936 with SMTP id 00721157ae682-6660a82d4d3mr115707b3.4.1721264440715; Wed, 17 Jul 2024 18:00:40 -0700 (PDT) Date: Wed, 17 Jul 2024 17:59:58 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 307ED1946F for ; Thu, 18 Jul 2024 01:00:44 +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=1721264450; cv=none; b=MMNHqt749bbj7GmTC3T5hK7rFoB0eBaUrd5vOEOSB7+//1WMtLNqtjSuOYezVYw8Kpnup460jlb/hP+E1mLdCKjIF7Wn1ekj76BrruBcMl///TTFEEkXJm0qeR35rywWZtKFSkxsqJzyqW2OFgbvFEwOBRtP5pfPPKHrhxpwi1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264450; c=relaxed/simple; bh=5Y64dqP/Qc91VuxFiOFdyoviQ2xlImH6OUYWTeDgHhI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=qioB7NIfrupSF15vxesjqYkxQOmMWljP2mEdNwzsK4oZ7MFXGNKq/ZKkZuH2Y9MRzUKj3Bb5dOpiUqHErSxv6Ny1kacepEd5P1UZXGCjoE8SdCGzTehwtz8XqWJ70SjXdMMW/DNKFN4IAKpg53737xJvPmOj2eGP/louT2/Jkj0= 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=v24kpHHt; 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="v24kpHHt" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-664916e5b40so4722197b3.1 for ; Wed, 17 Jul 2024 18:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264443; x=1721869243; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=VlCqQBubwpzz1bfGXRab4DAyLDf3GaIPLaghrsfoGDQ=; b=v24kpHHtU5vF5rVcNcZLCNUeBXlUq6FMB/tf8A1Vo3K8DPIZwEeRJ44lxH53W0keV/ VImHfgKQRPWdTZxPIFdT3RrjYGZA6wAXp/U3oQNxpWrILDZLdMccUpt0vzU/7p60VP0R lXbxzgiStLzoGWyPNPfi/jUnn59NiQk85IoNjJ6XBtM+FpcMJHaUNmZSZaewofhcB4FL mRngQhTTWgZoGvs1Gjxj9aSIqxuV6Hnr3TXwMy2Q5HLz3wOk4a6E14B8dQKl9oiVcNiI SIfyHp5r3SdtF3JeH1w+DxTiT7mS5hkVPzihpndXmnHBUmHhO/mXUP8MJJ/elXAaYVOv GwzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264443; x=1721869243; h=cc: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=VlCqQBubwpzz1bfGXRab4DAyLDf3GaIPLaghrsfoGDQ=; b=Sgb/hiNHXDhrUJGIcLbjzovy09CK8DTd+ep4p0V2mEkRA3EEb9uZvy5HX0Xdo0atwY mrI34sme1xhX1AAQkqPk4/3DfqDSfmQAUfxmYi0rYkgawGlbsOjw7+uLve/BzFOfv/hu egvyYjjuyKFhoXjjOwH5po1Pk4NcnESof6ilk2IFAeXHLAwriNTI1i8cL7bKZHxDXjxh heWAAdOXjEih2DW+5mke2tP+R3FvrCctxoHUGdM6WQsC+jZkqa/RcrLaI5C4i3fdx6R4 nsKpjyFGWc5uIouztjV6dKBhHNbNQSRuc1ki1U/UdAQy9gAT8yTR7z0uHPds0KmZod7B H/Ag== X-Forwarded-Encrypted: i=1; AJvYcCWMXHaEWpZaY7yVpAVzGMBo8XmgiB/yTnhJsGwqXDbrjaJwo+lZFTc1lNgWJzhXbs8ZLXhOzvtafaQxYi8/fhqoRZMSBXI5kFPbU84Q X-Gm-Message-State: AOJu0Yxkq8ENpfYoSF/Pf/PYKqTXE2qGAAqC5wns2+q1hTMalQ9CxjiG H9kybeLpxbr+bdomVklNf0sabpwCsx+F2lzezYS2w3Tfi+8dzZ6v0HiifqR0v5ygVcIPccwMpYj ayOtscA== X-Google-Smtp-Source: AGHT+IFoHgGR+TZLilyop+sKqN9IKy2CyDAYHVj1mZFWPbqRwe4DJiT5cFwMrS0OBThg7beQc8DW6T9DdQUW X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:f0a:b0:648:2f1d:1329 with SMTP id 00721157ae682-6660dcade59mr805807b3.1.1721264443214; Wed, 17 Jul 2024 18:00:43 -0700 (PDT) Date: Wed, 17 Jul 2024 17:59:59 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Cc: Leo Yan 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 Reviewed-by: Adrian Hunter Tested-by: Adrian Hunter Tested-by: Leo Yan --- 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 8449f2beb54d..3b9a0278d4a4 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 CAD042943F for ; Thu, 18 Jul 2024 01:00:46 +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=1721264452; cv=none; b=blWGsYGtaf0Sj6+lWLsw7XjX+Lq32B65vigLBa1BG0Qw3si/S/aKL1OMGxeSP/cDEBHcCq6HV+miPYoh/MhpeEXRjS2AnugHZtC3yhhXnVtlIdvY+ti2la0pGbaAEITqIgPHjjCfScPgFO6YK8a82zlWrM0VpqqN2g751/QsbQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264452; c=relaxed/simple; bh=WIuz0J5swC5B6Xh/u1bQt40r+XQODr7MjUk8+B7ih9E=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=LGiFsk4vYhpcACNU3JnUZWVRJAfpDxcoM8s8v4qVbq5muEY70ikKDnG1iad7c7WUwKkN9ZhgcHRohICvmOw2IN8IAWe4jbhDbIpVGssnpHRjLsjm1AhGScImn9TatqXQMlnHRUyJBvYk70XCoJxNwo7hX4YRR1u2IrvbHz7LvNc= 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=j2+fTp+o; 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="j2+fTp+o" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e035f7b5976so826837276.0 for ; Wed, 17 Jul 2024 18:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264446; x=1721869246; 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=PachKYZvt+Ak/HJwDRx0Q9HBCPHIc5Z6FnMj3PkVK3Y=; b=j2+fTp+okCp7di7+TXWanaiFpOQ2LDtmL2I+LNRhgiZBM2RHNOd5Ct1fUSkKqOcFR1 2cVFIKBXJiGC0phJf7s/cmk+8HycEza6KMoBETPImRW6yfRNoKa57OqzuGOd35xUoDB+ YcEAPbUTEo/L4r1X/65B/EonS+0LUPLrHiKF5F+8q6HYwWe7CfxtVcFv9RkOaFpOGkA9 btdcdqwR/055UQZhqyZaFabKJK4pL68WyHakdfTZeARPnaZHY27yyRY1Cs7+sY7I4a4K +krCN21/ELWL3tE85pKK5hCe3PLfyQIEV22qPxl2lZ122Z6zXu6yDjqYggsPPVe6Jrjh bUrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264446; x=1721869246; 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=PachKYZvt+Ak/HJwDRx0Q9HBCPHIc5Z6FnMj3PkVK3Y=; b=wC8b5bxEQpOFr8j+UFLVKV/NS02/HoFkr46G4fEh95AMI61/ufdKzkuCbSr3O+POzS TVzW/bTkqCLuUqticVUpfWN6Fwppt+H+pA2YZ6wfYqF5lFRhQzSzHDbgrBjtqIW5eZTG c5LfaZZnpHoDmsN6JH2TRgvqmw4H25aRDJytuCIC8XwVQ2hp93Gs5tTfl/Dv5G9cHmMR /PPrfiiGQnGpxPagmmMYiURbBQRa+aoGj+DIzfF5KkxFXU3L0ug5NDpDCq7heSLbMomk idJwmxjCaMKRORzgdi0OUrUhpwBD/JhxV1Lhg92jnnG7Txb+pJwCg45+CaIt5IxAAQkK e9sw== X-Forwarded-Encrypted: i=1; AJvYcCUS0RJ1sCYO7lv26vTJDN4jGJVzYXBItZLu2kSgBF30ldu+yZXVwccuAWvYVoOO4iiWB/YtZ1cEHvX1Nj2kdPU+BBnHD2IXaUUC9p2w X-Gm-Message-State: AOJu0YxsvPycuoOJRTBiX0+48NXEMFBDUDNyOv28vUgsEtBmAaX+KsIA 2dtQkV0+5Ozy7a6Xnkbzba+sbbkZ02z6wQNCw/O9EsHWREPaU/zvv1NK/b52w7NvtJr8se171Y0 sGpZgMw== X-Google-Smtp-Source: AGHT+IFZFSTWAVWYgQVywZ+faXv2VZaCBdht+bFDTqrSwDPm61j24HaG5zSH1Ii1f3maRyN6OLPLbe+mWMok X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a25:ce94:0:b0:e05:7113:920c with SMTP id 3f1490d57ef6-e05ff327141mr15993276.6.1721264445674; Wed, 17 Jul 2024 18:00:45 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:00 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 42E841FB5 for ; Thu, 18 Jul 2024 01:00:49 +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=1721264454; cv=none; b=tsEcFC9fiVoAU5Enhjxc6QINJ3ERgsq3lq9UZ7mo9w6k71ujDLflUMbi/akA6Iear4vMM2whABi+sL2dKP3D8pyxcom+Do7Otogit03wMngiTBJCllmIvB+8nSlv6KPg/eu+Jtr9liRuWqbMLxWO49ufmcwGaYAtbf1d+2u+h6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264454; c=relaxed/simple; bh=0BXDyWwgS7S79iHuJLErgWNfQ21DsHxf96EgsvxViOQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=H8Kdt9utB7T8inTPIQ8rVPu3KQjyY8JRWuh9nWjX4wPKxuMAsS6PlYv6hluMOtGs9hAzIICW6PIcv76p7RXuWEzlX4UEeX1ecqitcYtJyCsv6fn8HNLchuaB1fCGmyJnKn/8RGgWwWpbuWHr0qXKaUUTKEIMtSBiPaMoMiW5UNc= 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=qzTS2RmD; 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="qzTS2RmD" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6525230ceeaso6066987b3.2 for ; Wed, 17 Jul 2024 18:00:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264448; x=1721869248; 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=UnSPlghBx3VkMv83qbGk/P7jIBEF9LRODtE5BbjiJPc=; b=qzTS2RmDKJyFvLCmshMsIiJdqV/oMTdC+c32o586AkXa9huq07cDkxDteocs3tvB6S MVh1vsA758cZdEiw6vG0A3XWFMbbG7vWJwCexglb/s24/aczuvqwACP6+9L92Dez/BkB kV/nPMMPalL+hC/5wsKtDxHxKXsp096uaut0FjnhzlBcKJf/NQCtlxVhEITeLGomx6gh wVLJeMlYi+gQ8QzVVjjl6DMWmhqjxLiTmcmvcgKpEZNNR4jSU0dbCzRSxWtDWCzz03NW Ss2Io0EVRv9yWSJcCGPL3+X8eKRW9Scz9LXke302jAGK6h0cvzlUUDHhAI2u0dmAWcFY vVAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264448; x=1721869248; 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=UnSPlghBx3VkMv83qbGk/P7jIBEF9LRODtE5BbjiJPc=; b=csfMVEiMolQrMtFxfDNtWMujcOr8BpDgP34EcHaQ2tGcQde34d+EPW1oZMIEYWPHx2 S3OWx2ZpowuwMafr6gCOFrg7QYvfPhZK3PB2+6c7AK5XzJJ8c6+VBwl9p2mvd2H1JZaP Oh+xJedicoj6BsFq020TJxvZ//YSp0MjzTWOkoM3biSac+BGzcnIfOYZHbj6cUn33Mwx AlPnG/FFFfgF3C7ABTIvZax0UjPstByOJRBbbWq3qfZqCqodl8y/pa5SY//r8dT2OvAk RE89hxzEiHzN0VfgFc7SFUlKpwhMhUxDR5oJUEG0LOnbRmXR4im+b3Sop7hRi1Op7LaK bHAg== X-Forwarded-Encrypted: i=1; AJvYcCVmZD8ncmngIeZXsavMgOVmIm3YTjWDqrHjfCiiIZz4Sxn0UWW73EQpcZqcgN/Z5Gkm3crQVDZHYVZ4AHL9XQ9TyS/KGEPNWxqXGHaR X-Gm-Message-State: AOJu0YwEfN6U9DulWp7s89hg5Ok33hnFtkWQHWHEPjNnc/1+24cahTz8 CraAXID9A4btKyeWxWzGzPGrCkQD2xDdGfIlrhENWQSvdDpzhBe0swhQnru+ev7IAreFcOkWvAU BMuXoQw== X-Google-Smtp-Source: AGHT+IEtJVGPJ7X377yE2YXSNRqiPai0lkaBu0kyQ7M1ExKy3MUuhJpxePliNSESNkfKYo7HPJkc1WZwBgQJ X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:110:b0:65c:1db1:9235 with SMTP id 00721157ae682-666005395bbmr263657b3.0.1721264447940; Wed, 17 Jul 2024 18:00:47 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:01 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 A3FB229CFB for ; Thu, 18 Jul 2024 01:00:51 +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=1721264453; cv=none; b=cJgcxcIwmHT8h+kcC9K6l4W0z7mr9tCDbY/DNUT502oi4W1+eEj2uj1I4aIsa3OzAYadMunViyIyg7sNRBkDZ2NyHXPBc6ystT5ipm5xkJKyu78+q+bQn7hONWLYFPkzIsMAJq+5EjlZu6UqBo0cUEs0NXTL4/RxDnTbCHXOgXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264453; c=relaxed/simple; bh=adFJ4x5J0O4JSdSaPCPDVp0aeGz0NJC8hGerl3ETtpo=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=k4t0ITeyf/CeH4kT4RGFq7jl91Axub+FmcnzJXU8rGcDgEsJNqtZCfT46siY6mzy3Ucl3jQ72P5m+PWtbynDCkNjfEtXqX2HYNeMj9JG6rxcpq6yzq7t3BNU9Z1g9KFwlocblAoLyc29jP+7xMjC7YdXZgpRdtgalmll2Bc9aKc= 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=EaZ8l/nd; 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="EaZ8l/nd" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-654d96c2bb5so6393727b3.2 for ; Wed, 17 Jul 2024 18:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264450; x=1721869250; 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=Y0AwPG4o0G47V27ShPbkOoNNhsGypnaaBt/qve64P2w=; b=EaZ8l/ndFhzdgfK+/dm+kH2/5UAmvE5LS6yAoreAj84MdwqcGihbARKB7NKAAefEhU Q688Lrh0PZ0V9mU3a6kNU/E6NOsUNkDIfdKS4KfZ2kpmpa/0vpIvsh2OMeYfpXz/Domf MXjWdQw4u/3gqR4p1I+F+gMHy7uT9IE03qQ/bgRB2tU9bO/7JAvWhdASnuTIqXVAAd64 yeIwl5nrlKbSjoy/0gQT+Vj3zXM+DnugzwiERno7e2m3PxAURQrUkwLdBCYJRoMKmIre jTyokLUN4ffBfRnnFixxHmbPkzhmDZlkHsgZ1cp9XDGKZ+2Ml73nryY4WGGh8RO0rIrt ydmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264450; x=1721869250; 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=Y0AwPG4o0G47V27ShPbkOoNNhsGypnaaBt/qve64P2w=; b=AjEGP4VIJOM0CKY1DLGDYOhsebDvkowsN6/KZWhU2f3bsxv+prw9GU7o2Kf0qzquAA R9eSQoP+BTslf+8OXDtiFTvwT3LoUFAJTHwjjc6IbzA9m43GcemgAGhVzR1rKHdHnVOA BKZQnJWWJB2I6y5Um58nlJ20PQBl/qEbgKwD7jn+qpGLZM3ZOyzB+1r5lKPwq12J79vJ je0Erdn+q/ji7+N11AFufIsoBTdiqzGlnsQ/VfLvNitQ2DkA+bkkMYCHCoEdR/Dc6gUW jtug/e6kLd3yOHM2rlnbcedrzz5I68oF2qoRvbGhGJYSzv1kwh3QsNfDDtIZklBDr237 280A== X-Forwarded-Encrypted: i=1; AJvYcCXw0XMB1uYu4k6j4hw+wo2I+P5spVDsoM7Plre4kBEd33zGYPzhczxbY9vJDlJ+Qt/8iwvbqE6+ME9bZmwMeTew/iWdvl/boCBebCSD X-Gm-Message-State: AOJu0YwSBc9D1GU79lwvdYj+gGpeKP3zWHKu6GFA5elj1Lp9aFNcueqU SoAa1NmzXEEUhAbtJZoGGvQc0rBouPnx2T+zf2pvBS59GquAKUY9xJUTye+Uw/v6TKRkDtgBV7u HOT/Hww== X-Google-Smtp-Source: AGHT+IF6Z+ddaWru78kkv+Rbe/2ixIoAa0Oh0Ttd6cumo1XTW3h3Qcnj/31TOiTWD2HXbFwryaFb3vcyoCHV X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:ec8:b0:665:a4a4:57c1 with SMTP id 00721157ae682-666015f3170mr275337b3.2.1721264450488; Wed, 17 Jul 2024 18:00:50 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:02 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 C22CB2BAF3 for ; Thu, 18 Jul 2024 01:00:53 +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=1721264455; cv=none; b=R7ys25P0DXmHKD2pbIMjHsPVX2FI8qKl2D11b/m+quSNb7YAYct9Sc/7OhnKp3cnJJEV7o3Bs9l9Pqd3ZKAg/OCtjSESr8vZshkr/v/JTKvPLBQ35q1DGEiDgAYbeXyXe9vYWDz6OTzRjzNMnAZ/wQPuegRO/mVFrBz8KxNvL5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264455; c=relaxed/simple; bh=knmil6GMFDmF9fxKO25Al7zr+dbtmO1yh62jXywG2KM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=AoAhAZ/PcWVd5bXsLy8mSEjJd3ycBcE44d5ESqpoeSbok50/rUxlvWQuFAe3vSkcfqNK3cxk/bv9JkB5S6mVD8t5KPbCKAnhsuIoQKv828sO7S2tgUFyFHTlYRhTjWuLyCvDHTbuImDkCVuC6JOc3H9PC8exd+Ne4UE8rxuSBOY= 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=4gi2Byc/; 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="4gi2Byc/" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-654d96c2bb5so6395617b3.2 for ; Wed, 17 Jul 2024 18:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264453; x=1721869253; 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=82lJtR2QiowtdojpRIK0xRJphQA1CgRwB82Bes7qNdo=; b=4gi2Byc/QSLgEE6CKpb+y6+NyW1re7ExwAZi6/IL4AIY5MJ5XRiOHjCbvFkVEvaWRb jX9NN6L+t79TVUDr8+qFqwmAUcXvVC7d6L+w1toFGn0xP2+hg+U7sgOrEasPujroLhjd tDQdMc7vhdUVldSY67QvID5ouW4q45FLH8Yv7SNGFyeUVpwve1OdBJURmpToAVFpKzy0 tvdsJgFdYVPePxOq0THYKagJcllLyQqnUfdJydNoYCGjK+18qS1QnEeYEEU+6Tu0ESpm C9WS4gzkviYZakJK5Ns9+1vi5Rey0yegajE/R2oXtPT9ZoehTrwDHSO3tPrv6XwfJFDq d5fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264453; x=1721869253; 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=82lJtR2QiowtdojpRIK0xRJphQA1CgRwB82Bes7qNdo=; b=FX5/tCXqsVN0kZW253uFqcEd7VIabMT+h+CR+K+VygcbgPIHTjWdKYBxhKxdXl9vsD DD7FhnpntoZH9wrAsK3r1MPxbuJvKriA3YNjYTxtfbnrYFY0N3IGya7aI+4xZw3pG4NJ eUmMfSmLOPpCaaKzkBptJ6xNhwvBSHEoNk2xBhbhmaR9ZZH3FUoUIdId/hStE5/zCN/v EU/3SRoDjFSUu0fGvuY7HX6FwH9Mi1w30wrIYcumVNbCUQYKtLrg02uCwtHy3HOiL0Y6 iGcTAyscOnfaQA2af6jQr9B+uekNHicvcuOQEW2M/+hIck0m0+mq5Dm15AhObb6bQ1kp Y8hQ== X-Forwarded-Encrypted: i=1; AJvYcCXre7Qo1hDNrh3oAfGVVQ7ptvg3scjgpN7AySOYPSHRGGz+vCEo28h8/grEZJF3wXZMx8+dL5dZ693zkKV6fKnTU6tQTCq4koN9VzgG X-Gm-Message-State: AOJu0YxYC3kFewXSM/OYHdbzM1L7qN3RsEHFNSnXwA+krJQPwvbP981q q7HShG7oxMo4KsWvwFzAQM6YRXFecbcW9xxM+EEWN/ZqUn0YJptwcXYyCbEWHbqvpXR+R96WHjY yo/um1Q== X-Google-Smtp-Source: AGHT+IEyKD1zw/SRriBJYp/5PAftCKkg1vVG8YgDL9BHxzbdv3Dg4Oi+rhd7WFZsx5MgVc5quGMumQEfcIPT X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:ec8:b0:665:a4a4:57c1 with SMTP id 00721157ae682-666015f3170mr275457b3.2.1721264452941; Wed, 17 Jul 2024 18:00:52 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:03 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 65DFE3987D for ; Thu, 18 Jul 2024 01:00:56 +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=1721264458; cv=none; b=SOZTZHvkotQ8WHN0hr1O3pkqXpq2LURNln3JRG/XeZvhtM0gs/VUUu/USxmrptgAwq9dWM3oA8St/y03H2ZLEBc1jNKiDkvbPmvBxHz8P3zgbRoW89lf6UxjxNpqJ+Pni69+u0+vzg9ObuMknX4/leelgUYxlFzzHYTSMuMEXIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264458; c=relaxed/simple; bh=paspNSWQHb6+z/1X51Qf6w7AhPpM2hKwGkk+VGJD374=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=DUcdDb3jB0dQh7+A3ElQmpPeonTAMNE8uSczHHjSFr3kTatvbJC1nRfQYB3bHw6HdYClACPZzrVhqNsILh3YTNTOiRqjV2HcMqgx7AMgJfdymXPPkde4Z6+OdWN61aeqmeUe47gJoI0T2Vm434H31IVWjDFN5BFBPxYp39SCeDU= 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=VqP/vfWd; 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="VqP/vfWd" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e05e3938a37so622144276.2 for ; Wed, 17 Jul 2024 18:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264455; x=1721869255; 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=ai5lnf0BUO6/UnVTaHRIu7hu7sAuyoUd1EC+9E9ZCBs=; b=VqP/vfWdf3VRwNemq77UtD4xhYyvMfnVgxOro//I1dAsfOpB7/vidOxOA2RitD9Q7k qPL4ZCar7FphcqXNcVV6+tYkNSFNcl6vosBruSGyCG68rYOWejoTEWGPDJW+B+1f391X fqDdZ7/Vdilji7vhhh0w09cZfUjdR//RwLNbO+toNoZLQ+NpoSnRuOwlBrXdVx8CLn8z DTnU8YpuELP3V/mUFSaSGWyWOjLLdQOUE1XOS6WRMMamC3KmtM3emMeWiy2H0HA6tQeB bHGYhZOhlWlXfF13oS2r+H0JN03VlRW+8luC1LNBAPFtfoLUQP7OFH0aYXeJDNdcTYib spww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264455; x=1721869255; 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=ai5lnf0BUO6/UnVTaHRIu7hu7sAuyoUd1EC+9E9ZCBs=; b=jukJz8VvYf2a0Ihr/MZcPgrEf63NQ8iQZRmXHHcvk5NxRozzEJoxAHT2IqSfurhN64 KKZuyIKfqnTIAZwxpFvqMqOAxP3rT2Qa8oTznYbWUKSn0FdkEgjKKbkjsaPbPZVYEJjE u0FJkjeq9k8W14w0phvKtk37McQvByMTbkT9ZYYiLyT1amT/Yrsg58wD3UvcmpEPMGgg GOIMqduGcabn9ksWi87EfVj+GsJJ/GKONdkWzxxNcq1O/fqkMZVQFLzVqXEx3vEd4Z7w KBLeXV5VmtnAAyO4bpHAhWQOLzh06c/sBoSuROTdVuzQabZLDNfkHTNEe6Lg5TaMAWl+ w3cw== X-Forwarded-Encrypted: i=1; AJvYcCULu0q/05OeztKyzc0qdoYPXtxTg6xaqRTjAc70lFCfHP5m8VwPsdhQPvHfNeSMtKY+s5BN0tnKbrHYi6Oygvf7uGTBu44xahYmjsaF X-Gm-Message-State: AOJu0Ywg/qHGB5ef90a5Lvikk1swsSWE5lAsC1sgDPLZgYyutrXiIK0y rfFPuUekV4q9xmydD8u42zn7Un4I+CXa6LM/b6KmAxaFBa661Zheq3eHVn6pOW3CAYvO2ou7uDh iHz2DdA== X-Google-Smtp-Source: AGHT+IFez645P/F0hZdJQXU/7kuPyHdktbnSXSbfLcl/dMKl+NBTQzET3BcxRmAOKtpToRAendNoVwwOs114 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:102e:b0:e05:eb99:5f73 with SMTP id 3f1490d57ef6-e05fe83bae5mr2806276.0.1721264455354; Wed, 17 Jul 2024 18:00:55 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:04 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 A5E0440848 for ; Thu, 18 Jul 2024 01:00:58 +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=1721264460; cv=none; b=n6VYD1sjGCqha3zNlfSnQtn9IBpya+cJjiyPT3F5pDoZba/vyNAIisfvX8e40wC/Wep79G1NE8LAtjP+XcJFO9AbO+ZCFLaBqH3sdVF15f9fRyKP8zw5WReE6EwL1a0utyezbGx1L//5EVGwFWyTWtSbojgDTwjQH6tNRJ4bRRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264460; c=relaxed/simple; bh=5NLo6mkryom4NhvGMJNdBdDiyvx9A0lIz7/wg34r5RE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=RvIZc+uwW3X91LiPzQGtTC21k8kYHPH1q/7rMJp/RCcuXWUAn1breSY7+rejXl1FUVO3oNR9NNJyymzJ+JMEViqcQU+RXxFcvHfVlhBf5xx3y2nVyxsjUa4k8cW+gQJeHCu9Z8VFpwUOgOZg8PZGNe2vr1/Y6Gw3ulzR/+wjgoQ= 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=KnuQ5RtU; 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="KnuQ5RtU" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-65194ea3d4dso7041907b3.0 for ; Wed, 17 Jul 2024 18:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264458; x=1721869258; 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=+bihPZPBGJ6d8qN0fHDZAaoj4FmhnLovUYATiB5ueYI=; b=KnuQ5RtUL+jK4ahi/lEVK7dAoT+nuaImkVUZpffMvld/Uqkukc6eVSGRm3UizBpfDP Yaq/NnXYYAAFXKOhtmGQ57z4g6w+AcrJ63a1YCjZmFMj3CNwerObgbDyA1RzT6MwgMWV VaQcU6sZHsBYSpQkCAdvmHzk7sCbZTVo/IBFsSpHnDg2+xiBSgRKcA04D8jmxI9XG7sl tO+S1gzjvaAlufi+oahOmBbm5t8wjnAUZZGv1d1b2W3aCQqtRFyRmS9PuJ3COeBim25N ALN+HkTkC/LiFkKvdf0PkTHSiET/SpRaHjl6Q8tg61HDTZVxMpDMojnV8aAOzrsYrkAJ EIkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264458; x=1721869258; 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=+bihPZPBGJ6d8qN0fHDZAaoj4FmhnLovUYATiB5ueYI=; b=Ru+4E+n46dH0horEllngc8PlLoqsrtyajXbC5SgxgEcFeiuKDTXe+5ozYsEkLF6tDt IC5asgXuA1AqgkalIf6iG+ZaaKlW07CGKatHErbpO5euXxZSxm/ZNGBuEaWTrgwe8xPr FLDIwMjSC97SSpYH+5QeU7tYPbdTv3O0Pgp77jb6ZIHseHoc/HgiR69FTRr8/yVVVECq NX+tN3fTZaq20i9z3AHcqtMvaHXlETk8EQkapJTHKpXJcA3AAn7pgozNdn0/WPNvDMrH 3MQHZ9UNo6zkHjgUNDKGXodVHe1det0bC/eGoDJ52ur9v+g/fQKDnh8hnD303/vXbjXQ M7qw== X-Forwarded-Encrypted: i=1; AJvYcCVy+mjenjCsxUcx/g006FiCJsLnCRebOPyPfIU59fadIV5iaKtDBamZmT+/UtzK7g8PLGiZLc4A6pRDZ6EH40mP/kRy0z4kvzXMEqqM X-Gm-Message-State: AOJu0Yyaunb/LrgF2gaSiEQ3T6A10pUGBRuPGi3cSCGMdnbGBcxaeXWs Adyps8sUEzXXehCgoVFp71/StEVaC+q0L/DwnHJH0mXYt9RnH/hwjSPFk1kGWIiGiBUMZJhKZ9Q 3+ADHHQ== X-Google-Smtp-Source: AGHT+IGDEF3uZXg4slq61N/gjbSuBnIZfH69MFL5bkSpRqZ+m4jNhYliSi0lDnLt9dM73d7tpplzPVLMX02w X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a81:ae04:0:b0:64b:a85:e2c5 with SMTP id 00721157ae682-666019e3b2amr337027b3.3.1721264457820; Wed, 17 Jul 2024 18:00:57 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:05 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 50BBF620 for ; Thu, 18 Jul 2024 01:01:01 +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=1721264462; cv=none; b=a2SHXWp8SQZEFNfVSfhF40oemO7T8lO6eJHnFuUqJuW2wh34aeFe+Nr150daLrAU4Ogdxa377S8Cm4djRxMP4hM+2NeYtzqg7eKPAh/b6I8pXDzqWEEebBv1Mcsje8TTiPU7NRgMfuYZTML7m25Q9NR+xA7gtSPB8TDd6d9AD9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264462; c=relaxed/simple; bh=lx9B36RzjHlRcTa00YroWxsB5FR7jL0RJ2UU+VNJZi4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=fOB1QOLYNgKr15mgxDylMSXQ9hbf+VrUFe7YGPVvXuCP6vHcjX89Z9FQBDm2B30NpKWTWr7hIEDuYdCZD6qtWV2pbIt+vjVtDI0sjRL3JDkQehpk3wv86rq+CCK3op+DL0LNIbNBjey48FRnInt6g4oxyidNUbm2e/2e7vuCQHo= 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=smYjIxup; 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="smYjIxup" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e05eae12defso804720276.0 for ; Wed, 17 Jul 2024 18:01:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264460; x=1721869260; 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=BRYCHYYbMGKjB3Qvf71te5ARgV5gIJcFTXBlC43nr00=; b=smYjIxupq4tHm3CdDh2uwakLulQ/eDW6sNiEWFfs70FfJ9WdZng1l+4U3aoJ+AFuy+ ZxzbYl4yTjugcqqbyjzomRTV5PHzPu8AA2V6ZzoA/4kg/hI/qG6kcygUgtJtbYrn4vWL 4BYWTXO2LtG6PoPidbNwfAUpXCkgjRqGO7F4eW8X7qm0ARhdJEfVJBznes6pBwOrNrb9 /TkbbnSNk+qE585vNqoJaS2ZT0YLOBa/Rkqzef+RpvQ04OP5CwLhYL/cUNlv4p0Rt2vu CqakyMhjcZBh+qbJwYO6XhdnXXCQ5cWe5eRt6g0Y7Gcy5w9TZpETJ5IWEL++jK9+u20A 1rxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264460; x=1721869260; 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=BRYCHYYbMGKjB3Qvf71te5ARgV5gIJcFTXBlC43nr00=; b=bbmtTojwP4yDDssgd5AjwK6LzUPSZU011B4Vt5kUzjTASUBpndNuywo55Yp9vh3prX MxDnTByzVSbt7yc7gz9se/QXeCOS3aDmSqp4Yu7Mlsye+NGzAtvV0j/PrIGgy/43nwYP 8UV+hwHZbYczGnhZvuyIhoYlSzYK5sivf6CwzYFAgtJhuw/Bhk12Ri9UOgo9XFZx89da qY8uLvH8/BACqvuE9bFFD7d09MVutMNOZUmEM4yy3J77INtyPc8EYutQj9kmiWcVAkOk 3RRiTK7kpgCtlnc1/hgWC9KkPjiwS8vyVyYdQcqYNSQEufQcJGoMxZiMcDGzALYUTQ3o iiVg== X-Forwarded-Encrypted: i=1; AJvYcCXtOtzbsfOW77cfsp7+2+zJ6lvS7u2qc3m3kHJvVrTYwr9ls/JMSaxnI3yHmoI1v3RrXSNAV7E9TUZJz8vrv0MKvBP1wy/8+kgThf5m X-Gm-Message-State: AOJu0YwSOtVSYKfGpOxry/lMkMLDQkMuW/32t/IqOI9zTIE20QgFE55k LHba5MIg8LR4MROB4wbAtSUPGVphTeAn/SB2qM+US789MIXypSFjWTAM9DvVOdV6MB1ShqXssSs 78JwOKQ== X-Google-Smtp-Source: AGHT+IFYtrxkbVfYcmj/8+44DV+o0ePqkzDO07+yzQP4ulp2Q9arWW+kMFkiLAGqIisbVnxNl9FY7TnY38mC X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:100b:b0:e05:a1df:5644 with SMTP id 3f1490d57ef6-e05ff4c5bedmr36307276.2.1721264460178; Wed, 17 Jul 2024 18:01:00 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:06 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 79F024AEF5 for ; Thu, 18 Jul 2024 01:01:03 +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=1721264465; cv=none; b=tw2aoyjGgHzl5uWV7IaObETV4KXmuZECUA4vxN7Vbbm3N62jgPcPfCIG7s6Do/wV4vHHX7NJx0UgOTreEqL+IW6IeK9/XT071SUK4BwBLNMe36jopgFXe53vFONhfVjcxydUyUpPBGAhU7W06NGSvBUxToQvUzNCUdA/xy22RGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264465; c=relaxed/simple; bh=H+IPSfdi1XWUevftbp/S5w5ZjSsxdnIbgCEG0f7dgCA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=l6qYFPGKLT9q+iJTFOQb0v/qRfKoGir13epooqwy0SRwFi1Mz6yEc7nImcGUFrP978dr69AwmH3rrJ5ToA6am5dtDclO3omU1X+7U5RN5izsPYr6j+w5tqhRV+Rz0sqK1t0Al/UkcpkUib4pR65Jcfb+O0p+vFBaq+qYpDVBiXs= 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=2ZwRFOn6; 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="2ZwRFOn6" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6643016423fso7260437b3.3 for ; Wed, 17 Jul 2024 18:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264462; x=1721869262; 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=WcLk/IdzOPY+RjxovTTq+hic/bNKHt+pBKiPhBtB+zE=; b=2ZwRFOn6zu6WVu5gJsN2IDA8YuqVvzWzHR4i31TS6L9vGuPSNmAmVSiwqW/CLAFuDi 1w/x4W67aIT77IDxCpe3/KNdZb/ZnhJteGnzjOnT8fIAvD2zGREXy/P+w0x/ZYKp4gXd TtYb2YbTIc1jewshdv5ybPZpc5oNMUPmeQPeTtx5N+lKeirblaUABo0irXRetvQzZWGF 8s45F+/3E9hgGeYOBV58xHcvT7u0zrLIDAMmZmNJHFgx54E8X5reX1EdjS2LSttx+IZm i0DKK3Ak6FFG2j7cTJd6/sZBiPOsMcYzm+49IdPHvmgPmcXODqDOEUaAD9Cit0hB85Ie CDQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264462; x=1721869262; 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=WcLk/IdzOPY+RjxovTTq+hic/bNKHt+pBKiPhBtB+zE=; b=pnjBO19Mu5iyLyldbft+xjh4PaLNSOirnHBGmYMK/sfZnYTo+BBuzsSNILBmhhsIz5 gMO/ZUQ2fV4cjhVbqZAetCWpJqlDVv7AJWe2f8zlWZszL6RENYrsTcvOdH5wg57WcvhX ApAvl+TwOpYI96H2ZOFklTiAGacVnlXBJgA8F+wjZtB9GgrGN8pQJN1EGePnQiiM1WY9 +GW1JUP0BK7OYFzznemTBNq6k4Byb8929lrAm8KvSJc9zHSKfljGM53S2MYazxQNAPj5 4XZp8ExA03rnzSZhy7FNSL8XTYebeh9Vt5nzRCMjD1b3SQrO7nF36oEw/fw7Ajj4OSt6 FeGA== X-Forwarded-Encrypted: i=1; AJvYcCUrS+UMrGEV//w6q3IQTkfVWrlB4V8uOMsIVJbok4rrnWOU59jfhCOEfQT2VLOIzfiBlAK0dXWE3+kzS7vHarYPsvla6s7LXXxw9i4+ X-Gm-Message-State: AOJu0YzjwI28In/+xVKyUmyAI3iCCECenwtRoerSPPWFZHKiSzy6T0oC TnhrdSpGetrViQY7TNIC89eyYH+wTuzG3GR4muMRw3u7aWen0riHJMunPyFp3pPDKOllYdI6Q6V tFJ4vxw== X-Google-Smtp-Source: AGHT+IEKHTyblJoo125sOHAe4wzZxtfBlpdtI8dNPSpZYT1yA/iN+KaAbZBujqa3GKfkudcZLR62quUfwf8I X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:288:b0:65c:2536:be7f with SMTP id 00721157ae682-66604a8c105mr572767b3.7.1721264462396; Wed, 17 Jul 2024 18:01:02 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:07 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 B3C2B55C3E for ; Thu, 18 Jul 2024 01:01:05 +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=1721264467; cv=none; b=FCHoOCjAqaZZxdPEDo4U7O/F/OFeCL4ak2zYgS9qIpUmOTncztx7pTca07SpqQklS/MhCwY//Umk4CSVi2Ef7CEBlgouS50H5keVtWg7U3qiQmqSvwIvktOFHxMweGzfKh501n5DpnDSZ+iiqQQEwdYSzzAxvPjmH5UFX5d9lks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264467; c=relaxed/simple; bh=cDM6cRy256qPkyV0O1yviJXwK4qj6EXmVYKdi+zJvhA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=EsrFBkZ0o/y0rWaZgftSKQsI3w9CxojpCaYJy6SAZx4e3N2UQuki18jLUUdxW+26XRbMnoa67VpjoNGWn8auWEeSV5Kg6YrmgkPcjkVLw1fEXAg7wGeEHUCJ0OOzZMvX40IB7i/DkOU+Tk4MB8ocV3lVxQFt42Z+syYG0DhXjx0= 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=Vz0L8t0V; 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="Vz0L8t0V" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-664b7a67ad4so6037197b3.2 for ; Wed, 17 Jul 2024 18:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264465; x=1721869265; 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=6ObbEjhFM3S/nqQ2a9JTWztyQVhPi6FIfEEKm2Nh8Ec=; b=Vz0L8t0VR+ilYoEvvAC5gVXLWOAXqnNAy10Ci8Qe1fNnZKPYcIfdFSEjwlV8P5SX90 0t4V5ollOYnh1IC8t7MJU5PeHQrsq+5t0DmHG54NM7+/gPyZ2l2Sne4apunD4LjGhhix IdCcHQ+RI9FEYCLHsvONrUWZ/G9Jwhn0o2ryZ0QSxu/zEr+ADt5rYyl9/GzmHnw4JihT KuI6VvN9s5CHRlzLsRRW2RpuHWPGR8v4CgjhIHOijffc4ngc/DGJ3kplkHvcUufZrBXN ySfE/SNgHaXj7x+tYUG427XqyUOsnm+Ic/nbtB35vFmdeyah3RxdZPiL4Tb34/8ZMdt4 XtFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264465; x=1721869265; 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=6ObbEjhFM3S/nqQ2a9JTWztyQVhPi6FIfEEKm2Nh8Ec=; b=XRD+0t85MM4i5Zeox1hoUeZDcIUV/7iDoPdjUMY2opqBJbsgHMHQmCiaiuIjrvVgcc Ln0KIw8sA/lxWjGnGBKGQ2+puBCQOz6IgAFcqWmvs/2BY4rsocpTFb7MTt0JM0Aa98w+ TtQDc3VLSfI395ktrI14KfVcd14pMqzRMcc4ztM1P1ya91Mm/cvTIpE0/MnsaLzq1HMC 8xxC/4tPFm5vSxXgXm1joweIjLp9+3JZokxeunAUfcyhnoswk4sKaOqQkzR0iLRTQOoi 1KM78b7yLtcPzgUHxu1bgpxj3Ms9uVvdoH9cXsJYrKryp0NdGICHi8AjFLk5cc1ifMQ0 oyog== X-Forwarded-Encrypted: i=1; AJvYcCX6LxPlqgZ9TsUeMsyLCMHnrSbj5piAb6KwoZ6dylTPiYKXUTA14B5so5/oHWitFD6AZtfhv8Z4LCV2kCPLp8CjG9LCrUU+2Ozaaff7 X-Gm-Message-State: AOJu0YwKYjHJfAowBEh5vVa7SYe9hzt0WqigtgKVYss04ik+CZdSYuMW FKRl4K/SE1cII7l4tEnZ08B/ZnSF1NukMbQ9aHAj0yLNRZLlV4Ry18jj2PJ739QTFwpsaq5EL3r c9tGvYQ== X-Google-Smtp-Source: AGHT+IFdgOy/X0s/tSjgL8YFyCv2y+t9vrNn3n8rqeB7qn0Nz6DvIZ6Nsl/HvGV8i0mKMunHPP3MdC/NEvT0 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:3405:b0:622:cd7d:fec4 with SMTP id 00721157ae682-66605444531mr325627b3.9.1721264464720; Wed, 17 Jul 2024 18:01:04 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:08 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 0494C6A8D2 for ; Thu, 18 Jul 2024 01:01:08 +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=1721264470; cv=none; b=S9qPNrjZoETs0Pla67X8iXYK0+zMvCzIoBQIVezkF0zBmHl1owATLA4r007BdNJSw/NCn6bXy9FM4jnuQZ8udquGAcMIwVHatRslJ2aIIESSv1XitbZWzM0wakCAggUPvVYd7nvhcuiGxvX2vYUeI+eFrvKVZY8XwB8KMHJiLvQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264470; c=relaxed/simple; bh=/F7/4EIyw7D7CiUXDYCkLJycjGYVjLrkbxfIXcD/YaA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=NpJjhfThevtn+P1TONj8TjzXGUgCR6sIMSuxwX2CMpx8siUsZY07h3zPBUFuUvsStPrH67vqY6dDYShOBzwqVYjwKXbXJ7d5ZHyBGT/KWcgV594+VS3lAhCUyxJ8HTUWgIbFpQKTOL3ERz9uyYhmay8bitCOUKZ5aEKMO4vA2l4= 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=u/mu8pGn; 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="u/mu8pGn" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e03b3f48c65so850641276.0 for ; Wed, 17 Jul 2024 18:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264467; x=1721869267; darn=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=pNFK3i3CL2hY169owdLoin8oWSW6A2yJIcLVmlGvbqE=; b=u/mu8pGnfVZd53SE9RvWYsGXBO7ib8pyHQD4tz4OFISD9nDYuvTh86SKqXxfKUMcxa tJz3vJLymxSgfGb1JzXwNVifckee4K/qSXld1EvndVTv+T6TvZ62jTdwe5PVAeRXEsUr NttKVpcKx4wE5+D/YU6syfplmKWhnJws00LrkxIqQJO12nzL86dnDmh7rXMTng70HEy4 SToj5iOKl/KxxztabbObJPc/AE6ha9hLVzIhg8uMxcOzL7qXbZIlkXTiKkuh+j73koXu 9X/qvior4wPtCJw9JZpbfGmGmjyq9Dng6t3jDWTPLkU1s/mD38b8AP2KEJPPaQe/yzHH ZLIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264467; x=1721869267; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pNFK3i3CL2hY169owdLoin8oWSW6A2yJIcLVmlGvbqE=; b=Kzf4zPQSBKsBC0PA2br9w85lwt2AKdjJ6eRq8+Z6hDXd3cSd4aRRy29vyb8/ihluuI 8JQbuRNlcFFc784YJx/4pjDVhGCWxEX8Brgt4+wG+PZQ8Vns9oCtjP/f6k35ny+BMIi7 2hZvtNPKIYnzZbG64iZtdQtQyQo5Rj/ozmaaKxDwOR54lOtpweZ3U+d43v/IE1qExYDL s+3/W13Awr3sPapTHe01Olff3SRMU6f61SR/FvU+9EJCfUjomVfKQf8Q0KrwZZXvwYre jTY0HtX0HJha58efIyV6ZQh4aVlSVv7zadwIpAqDBgSLd8pkpD6lbnfOygEmiOIlftBO A4Yg== X-Forwarded-Encrypted: i=1; AJvYcCXOOmgzXJtZs4j3ielgpwqA+kvvl5Yos5w/z5uuiSNJDJ9EqoIpY/DQFZl4MpdI6WLRSWVW1YnZ1qYWUEm9U75qr8fS7MV4YYXdylmt X-Gm-Message-State: AOJu0YymA4W8grDPFzPyQbWzzFdyNvWpoXNKvAfxpDePCpBnQ9QE+aJQ /YLBVv/nnKv37gQuyzOB2bMBHE9fS+9DcSv/NIo8u3yRXHuDrohhHOTQW7d5RXhpFXOvNWKXFXd INPP56A== X-Google-Smtp-Source: AGHT+IFHPEUR6SHxDxIGONs3PPAyxDcCJ98okKUpCTVwExnLyEiQ71Kvctfkm9eZdP+bwodMy6NLwOHXvMHK X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:1003:b0:e05:a345:259a with SMTP id 3f1490d57ef6-e05febdcb0bmr22837276.9.1721264467108; Wed, 17 Jul 2024 18:01:07 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:09 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-14-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 13/27] perf script: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 Reviewed-by: Adrian Hunter --- tools/perf/builtin-script.c | 65 +++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 394bce9f5338..b4fc2971335b 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -3899,38 +3899,7 @@ int cmd_script(int argc, const char **argv) const char *dlfilter_file =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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 8142A6F2E6 for ; Thu, 18 Jul 2024 01:01:10 +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=1721264472; cv=none; b=pAYb67RZU05OVJE8AFWVINeYYgbtzUL3qNhjfiCDTsw1NoApupJT/pMRFjET4aM12qgT2d+lEz90gY5QaRq/lVrlsl/+8SKLlyDwLq0SAd2VWkYbo0TFi2CrC4VnLXBS3dbr8l9Gpp6N0iblaaGmMtLejt6tZP8eDiFyEbiVR/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264472; c=relaxed/simple; bh=ooLVBh0y1TjTeQLVc1IMKMPYr1fiYJWWWYFVwgoiAr4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=RH7FhyqbNhFGz672nwYpFWZ1qcY73gxpZypfdsfpHDEgx1WiWuIlLTvPG2qKzJ3Pj0lQsob7Cegm99ymNIxhjN+JJcCI0SB+vSyJ3MPTJ/FQNwTJzYuzU8vQf6cPYgSH45FlsGKs5UVd/TCTGiZW1EoQPtuS8NgMLG5AchB424g= 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=AZov9dd7; 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="AZov9dd7" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-65f94703b89so6286897b3.2 for ; Wed, 17 Jul 2024 18:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264469; x=1721869269; 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=J3n+jIbMDyTv9OsUu+Yn1PYjr67tOBgDw7h0k4Rcb5A=; b=AZov9dd7PwRFoH+wcL03JGmKJBjHiIbYBagrnIJSPHMwkaOYu+KckBaYpL9TbpHqMx IjDulWzCPaJgj6b/w8Jbs1nQXZejNuFJA1h+mhr0I0FRg+j8swkJl2HhT/oRxtlVpn0L ISQqJ2Tok3EXgrLpw8XjCooW4/lN+YquWZQ3CeDQ46vAJ+5tOSI09rkeckyIln35z43a q66AkV+qBzwWaouQeiPry8Qon+KAME7mlIbXWWi69W/U/MhdFwD/ZyY7dNvWAduZbq/8 ypEHtORlBByA8maBjHloK871MmZYs1X4pkcykMu/626pZRJbi9PjWXzJkRlvscqeOJHR n9eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264469; x=1721869269; 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=J3n+jIbMDyTv9OsUu+Yn1PYjr67tOBgDw7h0k4Rcb5A=; b=AKxyg8jFzSAz06mybjKJkL9e6SOVt6KYtQwst4gw4c9aC2XCuN7u2mXgqdQoLs6Xwq oKWbSVz6DpCbRG/P5AxzJcJ54eofPCRAAbsf/aoZbu/zGigCRYYdm/PGt1UAScZYK1vz +J3v9pJLhw4E+v7GS76B7XvzBhbGK8dY5YTxcZhjlSMl9Nq55481+sNqvaqer4NLOXZo xTUoXDiyixh2yxJYS3CrNxwEC4diCW/iQXqRXZUvoCD7k2stJurji2S6KHH8N72mhBWK Z9lm03TIIPUFZhOtX3sNPiUf6zIIAW1fdogxtROMNBhmr7w7KD5pgNNnFLHU/6N8+xyT +McA== X-Forwarded-Encrypted: i=1; AJvYcCWw+gLewvs42EEO5AEzNUFTKyjlztKko98e2y29it3LquGWPdb6HOB6GoN7a/aakXwvgypeiaMC4zThQQmfst3Q87Iudv5Uxmy8vZip X-Gm-Message-State: AOJu0YySPOVT/EhwQP2alOKOgrjKw9aRp++SVqrE2YWhf7iPw/8yktZF 9NyndwHzCL6oJ/VNx+IkStk2A8Jvqwd37Ny/v8uJN/SRljSO6swft8Ym4vvsKpfWDwz3AYlD5SH K7syZGg== X-Google-Smtp-Source: AGHT+IFlQGqFOHeHMR/DGL+G6fjGn0fdEKvd5NgFiT0bl+zqTRXmSKSTl9yhxhzwBha6DARQbLlP2reD5spx X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:1244:b0:e05:f6ba:1982 with SMTP id 3f1490d57ef6-e05fe83bfd0mr6992276.0.1721264469346; Wed, 17 Jul 2024 18:01:09 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:10 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 AA87C73466 for ; Thu, 18 Jul 2024 01:01:12 +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=1721264474; cv=none; b=k3s3tw7PI5pbNKamXAHhqp0jnRsJTKxs3rJq+js3f+c+5lvg5XbrLdl2uN+d4JGpT8erDJyPsZ54UWin8IXYa0JimdfSTNf4/1gzm4bzCq5XuyCopX9VKltiuw9KYhRUlEp1pNzvVKOhNB5+5vP3lqRvRbg3EP5tZD7hfl2adwM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264474; c=relaxed/simple; bh=haQWI5ixWfY5L9Onf5Qhr5TFO+OWkA5CcjaLU2DCVsI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=TSvpSP3aaqzZW4p32KmdOtGBNSP/x5caZ5fDD1W0FVeyQpk7PQfBZWqu2hTYkj7RMeDAXdwz/TFmr1px7draIhljGNjT9IQDoIWvxvEaYftDaIwUsTokcTjd8cMrAOEyc9c+JG0Xq51i85xGvAMT7TLeq5RYCYBuiCwGFFuwVXI= 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=pjoSDZ9N; 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="pjoSDZ9N" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6506bfeaf64so5257767b3.1 for ; Wed, 17 Jul 2024 18:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264472; x=1721869272; 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=ydpPh1ZiMiP0pvro6tyDS2/nf8jKqmo5vUIGWKndW+c=; b=pjoSDZ9NO6aEmG4VWbmpDjCLW7pb/4KLib+RshN7jtUdt1AOlgdJh18UKGV3/Qrgq0 vGYpxlPrivtY/EeEN0v5GdebJsgpzgXyKPxCQMD4V1j7+MPDri2PV16zKv7+sKmW34Td gJdQtFWs/dzsYyiv0EN3B4IVfHn/lByCFWYBUkHio+6/rKu8TfoQvwiKTBQZkfcmZbm7 olGHEKlbo4NcazvrU2HrDzJHAo8NH2MuT4Xiw3iAwj2nEO5C+XH08JH3wmReYc4NUmC8 FzLHN4Sw9oajR6Lb6loCff761R5uOyFGPZ7LwQlEu+h4I+bUwNaKa7yQ9a8tNtctEDKe UIGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264472; x=1721869272; 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=ydpPh1ZiMiP0pvro6tyDS2/nf8jKqmo5vUIGWKndW+c=; b=JdffoOe14k+mPqlssArBCP57tRprZ5hq3yGGM7YUPdpjLrpKRjcHi6SLbNv2aXQz3O opsUK9CbwjmNjw6VZlngor1J3r5zRTIV3rW+HKAlFhGBm+AszhcVDWPt72sDFLasYiHz wKQu7DL85fgx3GzU5RfxsVju/pXnQRMFbRsYgAQhtBoG1pLTgxWzqexuS8R/3ftXF2UX tRlkPbpJSpgVSCZIUo/ZM9qZaAEmiI1OvMDE0SgrMkRqpcQqNCpjNp8imqD8WOn/I7z9 ym5UVDMBNw8MIQ608fmlFpd6S7wqrXp7T4nAsMFQNepVke08/wGeY5LbBQubIY0tR+01 /kqQ== X-Forwarded-Encrypted: i=1; AJvYcCVgCmBRvYi1OL261ITZojOQWfc/o5pjZ99eytD1jz550UWx0Axf2rVAvDQ3d8aa2MbPBV08a9ix5WyXNXZHIwLat0blSfESrtsM/EoQ X-Gm-Message-State: AOJu0YwjzYYnPIOdpIyzKhgepXr4ZBNb/+obxvGgaEw4GRyyYDAHgA35 SHJxd3sgTIOhrs3EflvB48PaS8P+xK1ntQrOZ2Jqkpx+ubAe/ZdTy2wCVmYFtb05rpyMlPXaH8L ILkukPQ== X-Google-Smtp-Source: AGHT+IEC7jMCN1PYvXYSFjQ+yMmz4uzntJ34atRdjn0CJuW8F47EslAtvO50ljkTVZhuGVg3mcO9QZPODSju X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:1504:b0:e03:510d:3b6e with SMTP id 3f1490d57ef6-e05feb30c26mr8201276.3.1721264471615; Wed, 17 Jul 2024 18:01:11 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:11 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 1A8F87581A for ; Thu, 18 Jul 2024 01:01:14 +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=1721264480; cv=none; b=i8KpKHGpkRF3P1jhqD1sgOJiXC8inJhXbodvaeP46GQ9Tvzx5vPVsyVQC31vMmVFAuh5rp4SVFfFw6YS6TApc9SIYWe4BfT58WBglLxf8VSDC+zZ6IdqD2eEADP4kBopuKUxricqvQsGn/oxZ0oELNNrBUMZO000NiKRS3mnzmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264480; c=relaxed/simple; bh=6n88zCXwG9bSPE66xVrogeJqWiH/mhJHqZDV/21qFRs=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=k8YISckYJsSDAU+sHa0oCXMo9kOphbNqva+dmZXsZRA/oRlkoVuDjqIL4TtAPNq0Vd78yAWavZXSrpT6Zmhl0ADPVKxmjb1Xx7ePi/IceQGlyctqwoZgBpF2wPr+m2ngCdnWsiRPBFpehj+NeWorX3iw3OrD24+z1Mjw4PR+OhU= 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=WWZK5MFG; 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="WWZK5MFG" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-65fdbfb8fe9so6128117b3.1 for ; Wed, 17 Jul 2024 18:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264474; x=1721869274; 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=AE1o9GzylDTNU/tj+neWnduRfzORtFIhqRzpNenF16s=; b=WWZK5MFGOscimF/pHy7HO3SHDrp65DK2CYqUmZybdyIHSQRdUmNTKo7e1QcI35wveu 3d95JicckjFaUAZzcJd2O8zhFW0Ql+HTMEYrvsuN3VfuXmwxUKYwnj0xOTqKR1Z3X+wb jlQAbS8gDD8IVecWbSoQi/MrYwNLx43i69Ni8FA2YV7FGhtw21zVCMwjPEtNf/ZDZlNI 2FtZg8tbnDHRyfPidxqKuheIZsS010VDneP4HiUKOI6z4iNxFmk34Jjuljb3GIjCrUyJ YYnENLXzb7hBQzdswvLs+dmLktH2j51WS0CcCASrDoNY9DdVXn1RPWloG00MdLKpUMh5 3+3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264474; x=1721869274; 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=AE1o9GzylDTNU/tj+neWnduRfzORtFIhqRzpNenF16s=; b=gCIkU0HWVe1GjWtNvHdx3dIQYrc6y5iTp4j+SytSfNiDMDZebrFbodVuILBTsqoCsq frTZ74QDaXojynCWWKXKmlYLuQvPcUvI5Athd4hgB7vPc1z4aVBmzhe4ox7S62+s7BrE /DVCFOTvL0/yZH52EMlJugtDZsBcqYcQnpRyRoEsb8u6Xk/jh1oKOjUghm/SN7dNrUAN MEHAl+l6PukapLNQqMQTkQZnuSh/bKOLeKZynYiEGCH/X1+KCqjP1LMXNkHg4XexYf/B bS4lslx3RTqjq3yrYysp8DTDXcozzLVbLIn3qFyCm5cE5Kvj2PdM0Kph/NBeyGIBazuh J1Ag== X-Forwarded-Encrypted: i=1; AJvYcCVrDmMLR1Vs2tpvfhHKgk7AJL7YXhsgwNK+98hClvdgPGKkqyxExp3vpYYXEmq+4uh+qkJV7eNRrr3/Lw8lQueu4OlqBHmDuuGozBFb X-Gm-Message-State: AOJu0Yw8HAY05qPG9BK0ywecwL0G6uSrk0NcTMuPAthiQQAoVCQGJqMR GHnxHkg1w6bPsXrdx0lJqZxiiulBMvGZffvnF8Fp2wyi9wTbpDXvqXWVHk40J+4/0jbpKqjOWvW ZfjNvEw== X-Google-Smtp-Source: AGHT+IGgBhJ/vZuBVSyFSptR6UrX0xinXo4sb/hBXkBYSLP3hMqMO6tKzBxK9aNEcm7jyYNyXiyoQrcO72E7 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:1245:b0:e03:a0dd:43c1 with SMTP id 3f1490d57ef6-e05fe74c656mr10367276.0.1721264473975; Wed, 17 Jul 2024 18:01:13 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:12 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 12C3F7580D for ; Thu, 18 Jul 2024 01:01:17 +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=1721264479; cv=none; b=HP4+v6Jdg9jwrOb4vDf2GJSWPlwyzqiZlhdWuAAocnPnVP5JT9O8X/g3zj0r4wp9KFoswmjkpHWJCND+PjnMHsbac/+NNDjXbdwbQHjNewuLNruBQpdjUy4pfnL+OsyHU1Q9M6QRy0nrG2qIbIboZ/SFdhdb+uf0c2iDfheSmI4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264479; c=relaxed/simple; bh=36EenPax6vCtCaEhr/ZKn10gCViJORPj3sVD/7Dl8M4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=mpbB2iAfzJ3WYCqTynWHFtsL2I7tjqQy+Vv6tjt/gFG9f4sVuCnPSPmjpl5yC1ix78E5pTxfgtabVka/pzCSAs99lwEui5lmw+IYQFGc+CT4e/u3gWvX/KVQVTQsoc6hUtrradfKF+CUAyANkwIab72JQElkIhX5/H4jFRzW9tE= 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=owFrbotK; 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="owFrbotK" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-66480c1a6b5so7343487b3.1 for ; Wed, 17 Jul 2024 18:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264476; x=1721869276; 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=D4D79+IUkfPytCkqQCFYniN8I4X54SHHR0HOTbDEr6c=; b=owFrbotKuYZVS5q/z8RG5Cl79oaZKJl8N8uPnnk8UewP6fm0bVGerf/+/VS/otKrKS X0UqmX2GRi8FfRU8REMplH3AOcGUmx8Gt97PCEHAUS1Qeh4tED/aXV8XJn2o/XQKvxLn +8kAVkwqdt2LkjhuP12XQ88IvaQjSRDJrOXGvbOCanajQAtBp2Dr5bMcUdikQ1/iGyHc kQHhCLd5HGbsvAyOTe2HbW6eauAQb6COJ8Jo+n8qvqB+arJHVH8p4/3oLX+v5okJoYBp dCdEnUwFkareV6LEYEPWZUEZ5AYN/JGO20aHd1+YthVsW4ai355S4txqsW4EKYuEpqpJ 7/CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264476; x=1721869276; 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=D4D79+IUkfPytCkqQCFYniN8I4X54SHHR0HOTbDEr6c=; b=V/ZHaJUj1c6882zzuDGyuDpEyr9fUrQ/IFzlrMKBqM7ef1kh1UjHD8N3QvATXKulKu OL5yX7mSjFS3T/ji+BRlnZ5Rdm+uARxUtRzjdg3Du2EnC2BeWnkHHnCodmlUAW2ihNHZ Tx3D6rGs+S3lbBF0QwCKGG+woHuxsj9/jPtmQOowLOsnbNF2eHfEfXc65rmQlkFaPa8a Pu3SsfXlwpoODjA6tPCv1WNzVFx7DnXnKyp+4d+5bQkuVNDzk+UaP+suM8B9yiTu9lj1 6d+p6pmDQ/Uwgn+Z5PTFWQgmz3dTwDmCbP47kT1bJ4CZv9CpmaLMG7siskFJPZo2S5oB 1NJA== X-Forwarded-Encrypted: i=1; AJvYcCW+5TGcrIeGXAWsiQxJVtN2cxu3Yi8d9xhJSwOiJOt/9nkOwNhhb7XkAkJAOraO3wq5mQ6CsldD+z4dNoXLxIWQ4BLYUvBncc903gbw X-Gm-Message-State: AOJu0YwnwpWAIMatlilok7XsZHwQZuU2J2PlJmjYQcjZYzeeS8QfDtPJ 1dfzgatrXomis3RolMl/8po3X38P83saA0CRWjg3gilVaxT6fcmpHKfvRjNQhBxKDu8yxeuypqv Z2SzCCQ== X-Google-Smtp-Source: AGHT+IFdcXueyp+PMAvktitAsznwCgBObp3v+ssLmbsVDVTn4IUrAVOTsIsjGyiwtSBsWfywOqLvQluTAWWt X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:2b8e:b0:e03:62f0:a297 with SMTP id 3f1490d57ef6-e05fea28f01mr2107276.2.1721264476138; Wed, 17 Jul 2024 18:01:16 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:13 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 B315073466 for ; Thu, 18 Jul 2024 01:01:19 +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=1721264485; cv=none; b=apmQxybeiX8kiZmL4pGHV3dTaAFHMjnhRrQf6cTLhmHL8VMbm9+XwOsIxxrjuXoMqJOaLUPj9bdXcmG2t2y6QYhrflK8sbhQsa9mK6faCBp9SHFLLya19khEiAxBknf/O+n14eW01YW7GFXUqRdoIh5syHjftA0CPmWf/83nc+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264485; c=relaxed/simple; bh=33Aau11uuNpJ23sq1I4eyTYUefvdpQsh49HkERecgwM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Ed/64a0mT3VVo09UVZHt5U8bs+CiRwlB9QXW/DJCVYwPtE3uEQri60t9E9dHrfEXkhN/7GAkrjUanFnG7b8UqMyGFHXwNamm5rRz9eTUCF6kvVVnNVYgWi/2juhucqr9hFqbv5QBRohpwLjgAacHik/FJXK6dVJHM3zp5ab7Q10= 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=0DxNbC8J; 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="0DxNbC8J" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-65bbd01d146so6165867b3.3 for ; Wed, 17 Jul 2024 18:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264479; x=1721869279; 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=sIDIj8ohh0nflT4KD3kHem3lEjHwYWuoIZyNVV8EfDA=; b=0DxNbC8Jhto3QHlP1uXLFskjKmhzhO3EswqdpyEE8DreTRwj66V+b+SLmQ3y3P0BTu 35SOpY13hULFbdDUZpg/7beWfdA+7uikFnAQgHWmLH9zTMuGU+4Iils0ru9DqdP3lGu9 KktHTeLQkI/afRVvIEz+Vv2tLfl05Ud5/yG9i0KFL6+HwWgsC7l9swQagIHXyhXcizrr ESXkxfmpAgfpoL9w9HwU7SAgExcnpSXiuRSyUzTz0U0so35cLZLJ1htgdezlmx98cipN hp+jVqh1ONGg9o2cq92kPHKj6kfUnxR8pGHpN2XbUg1PcX6MZAoloZlh1PyVzcRYb9d6 JHRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264479; x=1721869279; 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=sIDIj8ohh0nflT4KD3kHem3lEjHwYWuoIZyNVV8EfDA=; b=rpZzTKR/4g3LiIiwHzY4IwnOQD7iq03rpA5us4Yo50ku4uqUH+d52G449QkbRw220m h4ls4+x6UnFN61cplJXR6JDqu7DYqu1Q8xq3c0v6i0nBrX2M1qan5Yl1ccm7Lfs+fAeb aLKyiik9IrVW8gfRJEx0M88Grjfu44WS6KFJERFZBXQIfOnz8Xw//PRh4fsBDcOGaEyw +q9K2E/qNPzoNmTNcKoOU32vvDL8kiRmvoxNx1Br7iL7Jm0IgPkEyEmv+9T2R180hCpi oDQ4LAZXohTr30DzkiCGNGWzw4ZQCV0oYGtvQKDItCgz+e2IiXf9Abu23IUIo57He+mc zSUQ== X-Forwarded-Encrypted: i=1; AJvYcCU6oHDXMkRWyCdxXrsgyxn15iGmDQ1k4LqCly0yG1G/yWhPc0sp3B/veWykdXc54ecNSM9nvExMnAymAy13jyFdtAj8ncl5gaCIowid X-Gm-Message-State: AOJu0YytE8L1zFv1/XXR09XtW+N0JEWJGftsSmEfIK7TTCeHPhULzbIx wSTL9V6OPYxNyvSJDavg6M3WpNRDlgqfihOZ56exw1n9Zli+fCBUP2N5hc1cb2rbCccZ9phGKmd 5F6SOSQ== X-Google-Smtp-Source: AGHT+IE7eyYkV30IAuJJyVKolxf68gGRG23Ds+4kcgr2lLuAa9Klg1hxPx68W8tgqNMyLyGzarxdoaI7qyDF X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:18c6:b0:e05:a890:5abb with SMTP id 3f1490d57ef6-e05fea8885bmr27243276.1.1721264478691; Wed, 17 Jul 2024 18:01:18 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:14 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 0E99F770EF for ; Thu, 18 Jul 2024 01:01:21 +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=1721264484; cv=none; b=GZgqGfACCrsuYqjO48OLcHVTJ61LV+RNv5l1EhtVHZz8e3VRQOSCiEoRPP8PgunTu/WnSdfaSFEvP38QU1hhIH1omJFRZGmtLGZxfoOj1sTTInZSKYYfZzN6mf5zOp32bHOsT0S7PY+1uCRlSQZfzgyLWpLLBjdfjX0GcXo9pjg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264484; c=relaxed/simple; bh=saQni68YvlpfViCBo0RhoTj4uuiKa0zwMYVCAC4XijY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=QYL1AFI7hYhsrfDocHJDdnrw+tKZLyWYb/FOgOUJ4O+QPSMWI9VYZvSKE0I8Y24QzHawqOaTCnQHs/ulXpj1OvU/jFGIqDM0r3PiMs8ZZ/zMonanPO8ENnxXEHDyAI8pfzgMLZvlAXTl5P3PAUOS4rMe1NrCycc5bPAedcxw+M4= 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=x/XKBBRl; 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="x/XKBBRl" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-66480c1a6b5so7346967b3.1 for ; Wed, 17 Jul 2024 18:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264481; x=1721869281; 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=m98Flvn2VBr3LNYvnCJEqVyEBIqxTtcaN90lyN420CY=; b=x/XKBBRlOJNjMa4IhpORe3yWMmfUCeA/AVMwVIJBzv1H8lcCoYfZtjaa7+Asa6F/9R Pfv6fa4ZuibamAHiDiWvS/xBfxn82nl7WI+Yjan4awUiLeH0K7CVXG6ZFJ0wiyD3tX+A Qhf1mE/zXMApXHZVD7gTH2BXF1Kr9MC49JpCAVm1duTGclAQTwneeBOl/GVGQIG9ITW6 07dI9xjUWqDhtOGMvXLfXo4gLCH/gKgmpnNahRv57kgqLx3blaweCr3GN+0NLxtiJ9ZW 8oGPSukXLAVaPgzbTy0YUPudnoaVXz14/tWvPGwx7FTrth60fsVinkb1ooTZTgUOklTj 1UBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264481; x=1721869281; 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=m98Flvn2VBr3LNYvnCJEqVyEBIqxTtcaN90lyN420CY=; b=So0m5IiwL6FD3fpf7BWLYUBTdzaN+sSfYkKKgypPp2SJjgrxRT33sAg2G18jYvMfOV Ge5Lb8VKXvqBCyrpuRJ1iiAngsnycNA1/0dEOdylEyMqiUvkezeRFG5p73YBIEZf5/cG 3txxSodzZoBMPvCAum817KRb10Z7B3BvxhjUe1OayibuhlWcYsV975vA9mMgQ9Sak7MQ vi4w+7jlkx1cP0JcuJ/XWlw0p/1XdBOb56mv9QlQcpSGF/O4Ql4vtx8DoQ6rd4wh+Q0g /1dMHK3yowJXleneHMctPEkeBz+buO9ATZTBXTuPaVkrVMl2roo7zU9EqTKpdlhY4t9v XVDg== X-Forwarded-Encrypted: i=1; AJvYcCUSNkQ6086kDPVlQn56lCCEpUaaAJKpxV5C20igTIzcZ4XV4+zdtbeuQqtdGyskRYyZM/SKDJddhUjaTLYERFnDfAx2FjBnKN3MWQju X-Gm-Message-State: AOJu0YyAVYxc5nQfYYajNlwIqL3yH69EErkzBPhHLmSa1y+UMm8mwbTr eht/DOEW7kwqcSuE+x1qoagm7Z5aD818dmQdLRRPxhT0Qm2fGx6mXoF5LQ/4uC/jb062PGGz/Mb 1VoJEoA== X-Google-Smtp-Source: AGHT+IEWEjgKHZq/295YiLw+T2zNbbynCG/+Of132DZ6uzEmgnVr1Fi3xV7AcLhcv2Pa2K2jMXGhS06h3I/A X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:fce:b0:666:e184:4dfe with SMTP id 00721157ae682-666e1845003mr139337b3.6.1721264481114; Wed, 17 Jul 2024 18:01:21 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:15 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 274A57581A for ; Thu, 18 Jul 2024 01:01:24 +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=1721264485; cv=none; b=WbqxkWHNl0JBOvxmC1a1CvrTRqoBNLaoDdLuhCef7qOLgKaLdMFnJExmLgQsUtXnlLu6qEEp39JEvAqrJKCa/9rjEXHc5EN/kWnBNpwhAe5RSDT0MA4idFe49fsJTACxnQC/KYogrnvTskzVMdCs2gHoDSDi818aQvlhtwofdas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264485; c=relaxed/simple; bh=5n56mjuu2839fDPcAxqZPMwy+ARy/VmiiiMQ5jI5utQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=TJQLfcG4if4cut9a6OPlBBmhthe97Pm2wc7pkzVJ+xR0ZeN4f2E+OrBJ7TxbW6ZZIYuigsJYDGkIVGCqGgd/WWfIDhVRXh+k/38lPCL7qW/EfJUU/ibhMdOZat7LWGdMbZtYUN5qCjo55pY/xN8HAUdnGO4KILYamjHpdYhmrOc= 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=qKkev3AH; 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="qKkev3AH" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e05f9611400so633047276.3 for ; Wed, 17 Jul 2024 18:01:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264483; x=1721869283; 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=fnEjjhiFWiWK1ZjHSoRI+4nKrjjHTPs3eA/kl5KV2XA=; b=qKkev3AHRMGFTYcPszyImhUit9bS01+xVUrJp1r8wDqpBZuqYLMOC9OfaoShQh+1Uk fQxqLC1BuftAWVIQjEtQs2FLTL0ZOtWUK/r9Y3sxw0mcEiM0VW+Lg9MlpVZXrHonFQ7B O/Bbu09/SGq5vYQmUQg/Hehht2/YTglioRhPuxH6/pGXjHPu4g+3y01DaQrujfcNCzL1 uIECVrv7Homtr0taq6wgY18mBquBMlXj2r0Q88dbYOu4MoYdqV9IbzRg3doOPIOP3RSp imckauG5tHX6B/+E8kV/T4avJrn1Oed6APuoR9fvtZTGGVPOYTO8mf1NmcLKZCuNassi uakA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264483; x=1721869283; 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=fnEjjhiFWiWK1ZjHSoRI+4nKrjjHTPs3eA/kl5KV2XA=; b=UqtQB8xXI7eH10zqxiWGuqesgCM56HzaOu0kbiG3/oOvpphYSln58fK2sHKSqj6YVL eurpfaT77FJIsPMZ8uy5PwViVZeGBLAVvsyZnJmNCTSR4vucN//6iEJz5dEabQtCYJbh 3ny74zHXV7SvyNC3d3h7n27nqXqhUHZaAJZFVQSOvANoKtURqz/668z+1Ey+6VQNkMkj c+skI4XdZnsAObvJkwsFV4f8kqJXWdijnjb/ADGoS62j2BpuhtSUzs3XSANhRllIUaNz OF3xnLFdGxcIYK1eUy6dU3I+K6jooPGxPx9nobGVIw9QEbkkgAkhmG5RuMDKn9JCx3ni VnSw== X-Forwarded-Encrypted: i=1; AJvYcCU8RnRQL9ZiiySWuOgXAt7x28uUPpUjkcP0ZO36diuD4WnFusEs7+7rO9ENod4sjTe6MHDFrp4pqnZ/Twh+4K5AjhdlxL6xtxvSBlsq X-Gm-Message-State: AOJu0YziNthNJFHv3aiwlUhbJF7ow4di+olp5nYeIGis3QXsgnm8RqgH /0crofvtRN77AXf74qbb/WK3ftC9i4hvlFQlgxeD2n9HXTsm0/wN3YV04YyhS+1EPtZf78YFZON /Al+/Rg== X-Google-Smtp-Source: AGHT+IGc02dcns067S/+Js+jqFzEtFv/PZyENgn6kRY6kp4H5xE8Md1QOSwjwqbLR9srevWvPq7mRSuwgOSG X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a5b:885:0:b0:e03:5a51:382f with SMTP id 3f1490d57ef6-e05fed80951mr2244276.8.1721264483228; Wed, 17 Jul 2024 18:01:23 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:16 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 5E45D7D3F4 for ; Thu, 18 Jul 2024 01:01:26 +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=1721264488; cv=none; b=S715cAUy8COK4Kfrtjp+c+mkLnCaHNnm06FwLqhCi4OKAv/7yGckzysEu/nchxFH2mTM2YDlLdci9B60lbZ9ISCt2bYi+DgZEVT65qV6eORfqjXdKlsWaNpqPFtDZhGnbNlh/+mac7Ls6kwnoJ/P4y9tcMx/MprrIKY+hGNK0gA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264488; c=relaxed/simple; bh=mu4vuD1HD7G3ToT4iQRGX7fu03viURBKFaa4tQ+TMC8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Jx8KRRji8iwxYNuvLaFISeJW3cA7aOac2BMtUN3+qeZfHSONWKmpQ1uGSTDySZr2GiVOoMHrBy1bWfwHB+pXC3/Usnmb/2xvAdLBoBg+OQCJr94vGdwPagCDIfViTEhUY5Y3dJmnSwR1MbnLCvq98yjfGlLXSu+R0LPOjxDvy4w= 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=eNjXwrZP; 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="eNjXwrZP" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-65ef46e8451so7674397b3.0 for ; Wed, 17 Jul 2024 18:01:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264485; x=1721869285; 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=86P6lehyXq0UCz+szOa7LpHKfu0TP8+WJUv3yJsN71E=; b=eNjXwrZPN4xHDS5hqEmnTNdvyPGQUZAp7+busv0w9p7U/x3dB1AvW2ObqmWywwT3Kw AjXovCZEWcOCJQJnkHHOJ3SSL0NIKZb6qKN809m5Fp14K6iqDk2zb9iB6fxy/SFjdb/E m74jCCzLCMp/jdaqCSg6C3PChCgr1pVfiiQ1tzBpkoBJqlCFhbZWH8lQ7I0r5FdV8jn8 jCKhrDenVAYqpjWxYwfF/1VA+7cHA+AxdIxEZhCPK8cmqU9/OQU9yjdFhyM7JzTUTQlC VkREAcT4iWpJr34Y70u6qro3y32ZYzf6tklv3q5OXfD3GcrCBVqxjSvOEzgUPdyMojTj A9mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264485; x=1721869285; 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=86P6lehyXq0UCz+szOa7LpHKfu0TP8+WJUv3yJsN71E=; b=SGjAN51Y0L7ZLjTcgedZuVqvr1VIB1JX18C3yeiPO0LImjTiG+dGJ00HdbArmaehWH el2aIUN7JfxEfHuU3JyxaVxypNie3o5b6irBzeaUXBr4s2AsDqrawJqLJ8FOpCcwV+Yz b+W0rWvKJdF0hRvwSRGaKeToaCb8VdwFzt1Z/S/9PcsnQeBGAnB6RutpFIi9uEgplbUl 7T5kR1VQ1cqdWQUqBU3o+xfysjGs9+QAJijTovu9bisfj/Grn3X2vNj/IW0pPEVkuog2 pquo4XnE00iyLzDRjnXMao3uKgLApb3ZrPDvtCMBRpbgi1ioIRVm/c1lMdct/0zAyoj6 IOvg== X-Forwarded-Encrypted: i=1; AJvYcCVID23gYHbBRKE0FUo7qwndoQFjNOM6G+1Gr558ThE5onzLeZsIOFjneThwzcpyRs/uadkrbDF11M8w46ZTjocyUwXodfwsr1+kHFP/ X-Gm-Message-State: AOJu0YwrT3b0dmHpVwq52vHC6++VjaURIwymSYz1yYWSeZXPZK7RCZd2 lfbjIIw7p6X5ROfs1tWK8vLGKY6bSJ7w6WpJ3wsAJ4eKi3BMJW9gXLZdYgA1AOQwOL2cFpnuJWE rW5kU4w== X-Google-Smtp-Source: AGHT+IGW5p0HgLAn8l5aYZBJ4Boo4bm6ly1P78GV/4bDdqw7hMUFDKApK0Y7U+/yyqc8Q3iikYnotrKwO6YX X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:10d:b0:631:259b:fce6 with SMTP id 00721157ae682-66603ed354fmr233327b3.9.1721264485416; Wed, 17 Jul 2024 18:01:25 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:17 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 A7EB073466 for ; Thu, 18 Jul 2024 01:01:28 +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=1721264490; cv=none; b=OuEh2JHiZiR2Cg5Ob7K8hGOyb0grqmzRkK7Lrt+RKz72qWhZBZQn8ncL4cKTr2kxQphOGZXZKt0i4AADZ4eqoT/0yYb+T74ZfjZxCDBhHIMmptDBO07qhZZEubsGQx+VwAZ6bu+yqblSDEs8yb4tWo6CjyXJAi7S7c8y3oQ2NCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264490; c=relaxed/simple; bh=kfJ6tvBAsXsU6JLfCYIrLBwtKah2svTIRlLfKRZG1DY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=uBzYPt0AQdS2c6nVXtxXgljFZbdxmnOB8MJ6ADPwW8H3ck+hKD+9teZFijfndFmnu5C0xSRDFCOQtJAQzAuPWF3sQr6po44pjE/Rmj8lQGTLukSpGnRax29Mb4+KvDohesiZRc2XfsW/fdYPbGJqEawrLPTfdCdGzkI4ZmGzq1Q= 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=ZDBiD/jT; 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="ZDBiD/jT" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-666010fb35cso5203217b3.0 for ; Wed, 17 Jul 2024 18:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264488; x=1721869288; 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=UZ3Drtsbb7xK9GFR3k7+K4AhjLYb+mQoMq9GLVm8nd8=; b=ZDBiD/jTG8uTOomUobjsCAcsTfZJKCSZgkhhtI4hqF1/OvSGE1Yrr1hcwHfQvSPXF2 pUV1p4fE6YphoEiv7qkkXZrLHje/rG4XUjrGOSEMzZcdapD2Odmbz5qE77sj6rrVguPA 4aU3UuJRLhlMfc9PNDj8lPqthaPfVQU0odfpZ40encLBYfvz+u4O0ufRmiraFPj3vDu/ sTFqJ/zva95UJYbUT12x0Yr4QJtPm4vT88jQOa+PFSVW45gujh7G/0SnmimPEg0NN51k +Pkz5Z8iU19htzWNuZUibFh3/88QJ9j/JXH6G08rsrp2kvX6feK0SVppO+lHFYHVlm1y 5w5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264488; x=1721869288; 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=UZ3Drtsbb7xK9GFR3k7+K4AhjLYb+mQoMq9GLVm8nd8=; b=Fmj54ffJwl690Kj5CMZSqzC8e1oe153HcwMORdtI4vg2NfE52LjhJQoe7YQ+m2KOpF RfgHmzll7xZG8b/yEKiLjUnK755J5tfQZ3m9qisTdaR5nsnjDH9ChqbhJuJTKp5p+tir DvYisfXuO1kT/RrbcahuAPG95srGAZ5lpoXIxtQXagFjm2iLY/uULB5BVI3HthzuCiSH 1iBVcqJNKnrXfjpajEQMoJOj79BrFWcau3tFbxj2bECQO2ZaVwpNs8YOHmMyPp6FfHsj kv26N1kHne7PFd7bBwOz8UsumswLAF3MQmBvuiSPR14r1emrOuFFUOitRSGyKz/irf7j LatQ== X-Forwarded-Encrypted: i=1; AJvYcCXThuWU0sA5lpuOzAUYorZpRS9ihq79B6BKkiIAsypr2AMQCw5hLQMQyVa+fs4Lxrfec66t4+AaxqozEygiTcOKsaxhkX7ZnJvMAtp9 X-Gm-Message-State: AOJu0Yy0/5oHTF4wHY2s5uXdd3H/VheOPfkbjr8lPged47CU7xKSI08J zmcpnSmtuKJKuhsP9IxTuY0lmnzf18jsRLtxCE5soXul3EAwgi4o/pcWDD0UueOS99rZvWTr9Xl Ms0l9TQ== X-Google-Smtp-Source: AGHT+IEMIegm6jNE4CQClsw7GOzZrobtpwCpbE8HwTGUbjxQR6jEtSbn4ARwhdR3fei25wrA9LB/QeoUjXvX X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:385:b0:620:32ea:e1d4 with SMTP id 00721157ae682-6660af16a6fmr758457b3.0.1721264487742; Wed, 17 Jul 2024 18:01:27 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:18 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 A7B08DDB8 for ; Thu, 18 Jul 2024 01:01:30 +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=1721264495; cv=none; b=M8vEQilMgcjqxCf1PNtXawiI/Q86rc2LDla/oA12WvczxEIXFtHWzGwAYP07WiWRaQHzIFdsod2xiM1Up2tD16kNrTVOJrmm1EJMO0r0khgWplKbhL1XhTOUkVg5v4Df9REVkwlotCgAdovfNeDNFvlW7XlI6Yjr6aHIISER3js= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264495; c=relaxed/simple; bh=cmLg3dO793Vu8RRjxUPuYw4PgNi/G99PcpLXCc/ZGCo=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=aJHoZt4tcWzG4HAYo/2hd5tts7QDIJu74/t9MBOg/GSlSdhDY1Fum73ywxnCvWeYpi3hkDox1WPBrZ83u21YZ5U6niS7Thfn7KzDN7abXsuThBrbljrPc+x0/6/EDlRETuUsh16TT8h3vnnqntUSDvB+s81O3sw000FhYnIHMwg= 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=MA4DcuZc; 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="MA4DcuZc" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-664916e5b40so4738387b3.1 for ; Wed, 17 Jul 2024 18:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264490; x=1721869290; 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=Clkf8d2hIy3r9JhAIXh+9vb9zWkbL7cEj4ImfbK/zRA=; b=MA4DcuZcWGdqDM1AW+3Y/o2/J3M7yo4YWw/Cj0fT0yo5AwcPqSfZ0kOwHp+rErHw2o 3mjEtCNz1nkT4jLWW2e+T2LvQ6sloUuR4dLiwDq0LavAkUDFdK0bnjFRqK52+9eA68v+ SFWJUvTyVTPBqxDCm2u1e0hgDalKUahzdTHH6nAOEItLcrat4uxYy7ch8dCcmKiYHgrb ZkAGBiYfJBDGydY+LtITroMfDHT5gdY7dA8NaEmn7mvF5hmfuZhlCTD+PC1SZOQUb5CI xfPRua1tG+C2EozP5gTf7Dhe8LGtQoOAm8KLOjUgbHlG44mB9pBWo25qRQ2qRLJC7QJ/ xmug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264490; x=1721869290; 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=Clkf8d2hIy3r9JhAIXh+9vb9zWkbL7cEj4ImfbK/zRA=; b=iR3OYBY3j6ifyXLzWuGYef99fGgc+mDk5W5sR8jQvLg7XFztX8LEd2/duU1Oi5AF51 w7/+VNdF16gmsuqcsT9NdS1PhADtth49Z+OhQ3EAL6E5+FTSTcCAVrTh0XqetI3qwzKA 3+HTdzHv7pNphK522Eu0Fo3BWf+AbZP7lf22P6LwdVQ6iCIU6CZ9jFx5d3gF+R6bdDsa nKi6Fmv3k1ttPNx7cIM1tXmF0gTNZCCIfmu5ebEclxNqJjEMmgb5t7H46B5NcQQGJ3zI 1qBjLCpHbOp5uSqT1tdXCNrbXpvda3c70pnrx/BxdBM5imzGWsSv4g7BSy4oQ3MWJxkq vAxg== X-Forwarded-Encrypted: i=1; AJvYcCXBdZ7HfIZ2fDWUQtmVy0hnkJOVGmDOF16upl/HXfBv7cs/oOX7JqMlZ0v9DCiiE/82thzwBF+074mFiD2LnahFATf/UObxsNAn3U7M X-Gm-Message-State: AOJu0YzQ8HzNpgc/cHuhlpVh/uecs59NSm+GDAyoC9d7SPeAvpQIi76B vVSo6cb0ZhGLQicObD5xnxnNn1x7JbShh6HbdFpFc+IJ1hrHhHxbM19vTrAnc40wsZ1RHIq0L/H FFKZWPQ== X-Google-Smtp-Source: AGHT+IG3uW51DaI0jwt64D2aVkFsd0oCKXhiJ/qB6/tX+ACDLixR+siknXwDm1ELbOkMHzZQc1ESlEtW9OiS X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:2b04:b0:665:7b0d:ed27 with SMTP id 00721157ae682-66608017be9mr125757b3.2.1721264489810; Wed, 17 Jul 2024 18:01:29 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:19 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 F2ADA8062A for ; Thu, 18 Jul 2024 01:01:32 +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=1721264498; cv=none; b=DJpGf+7qxJmrjCzHy/1QTHYBdlSx1xxLUuikFK4/7eu/2czAL/DWmB3WWcI8vficKMGkYP43xfFaYVQFK2jtbHUVaKikZvUu33JIWI6u9pIBABwSiuXowYSyshxSyWFDkdrHoMqbCCfuY85kqy/csFuBADfOH8Vo3HCdizAgvXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264498; c=relaxed/simple; bh=YbRvpu+uwwMuNTTvEvI4OhddcpMs6oF9/mMJNtkseCc=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=a1XdAlmMUMbEqG/YI0P2MFB4iF+BrqV9TZWwDVgKHA9DP0fUUAVBnhjni9Nb6KrWRf7LhX9kzYm7eXgMTd8s+SyhbUlMCUTXm4BopaPu5vuhsx98w5tm0VX6hmKQkR8UWAo3QfNuwWRWvFqkbJBxX4A0/TnlvQZ/HWPFEM0Lbgs= 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=SQQjWLrr; 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="SQQjWLrr" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e05f08adcacso782946276.0 for ; Wed, 17 Jul 2024 18:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264492; x=1721869292; 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=REzOwcnCQMi8P53oskFE/aACHZkwc/UlMI8wZ8Kriac=; b=SQQjWLrr9ecqnLoGcmCDm5TYrwjsy7H5/tlhASgyuj2ggPopTjzlrdW5Pqy56iGO6O RtwTLOv1oTaPKmf00Rg1cUkoAkJlwUgqFCr8wYSRz+iLMRLYTH8u7tCBeS5DGN4m200h nmd2eTjmHYVPJf7cWFzDGbfd7wjuzG6xr9M1vvXJtrzW5XhD1jA+OQ2gMbQQ530m9Q5R KCtPDc6e4gmqel6G7YuCLng0tCjd78IOjhkHXQS2iAv1LNJmjWUKloXXEa8uKMT3MBHk rhdD3mNaD74Z449VoHQCSgTdJOk9EyvpIDgw75HKcH5v/7urhVVvj0rKV1WLaBB7dUy1 LjPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264492; x=1721869292; 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=REzOwcnCQMi8P53oskFE/aACHZkwc/UlMI8wZ8Kriac=; b=in/7sYUnLYtkFDpeqzumQkJKBZkIGeq38mlKBnfrac6NFr+CFDRrNhS1cEu8nRlWu5 N0Hn6gw4I4Cjg8xgBhOfYyPwXqeDpniLqBaatE4kuSKPDdB68WZxvDKDMxTuTa0vOZPU lpqMQXz/K2VYO1mHp1Eiu0j92rEw8XK/UU/Gy/jpIs1PKFk5emJSXSEIcY/Pmd8zZd2f 3+KOImXTbdcPeR3s3asWiOmdbxDdPK5xlLnSOGH6XoNdH9FG0OJZM5/5cuqhlMIZcHqt lttcQ6nw2EdeqoHPiUrsRhhRkWhZd3WSIQYYFDGkZALAin7arXc5IoIZcVhE1eLmw6/1 XT9g== X-Forwarded-Encrypted: i=1; AJvYcCXegcM93keCn6mD5uBhOdsUry/JrX3jap0XpZLBDEZl0IPtqfeFdEgmVUrzK4wX5aT3cf5/cMcZvsL8clt05NX2zE3hCfLTyEarO2ky X-Gm-Message-State: AOJu0Yz8X2OTbywkhubAruN6pEGTUJKmd4K5irG/T861EUgaaiGk1kcA Gx68QBPRmAghRN+0xAsdKPELTBvLjhiTyidNvVWBGATdMPIByRExpIR1StEMVybW9k0ec99khxM KVFnqzQ== X-Google-Smtp-Source: AGHT+IENJRTJFBxLEruydNwMFvGZtwUd9yw7NYoBiIOr6hcXSjFkwsbhRtb36vAKwTB1IMSXwJ8aHdyUAnC0 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a25:a2c4:0:b0:e03:39fb:5729 with SMTP id 3f1490d57ef6-e05fedaf378mr2117276.10.1721264491944; Wed, 17 Jul 2024 18:01:31 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:20 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 E4CF52BD05 for ; Thu, 18 Jul 2024 01:01:34 +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=1721264500; cv=none; b=P0t9txvWty3Yd2nSsNH9rJAU0kaJtsy9DzxSTek/WsNAXy7YDWr05wMbHT3f8BATmvAlQb0XY0/uZFV4wRr3E2stdcIGRFNkwF2ft8XxDleoMp8aEfFDCosxmKyI9iae0w4Q2on2oXaVFE04T8q236TbFqWevBXtqzcKjyVeN3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264500; c=relaxed/simple; bh=smgrs6vq+/EnN03NBWT8R6qmohPEAkYKFjCcTcvoAz8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=XcGN5dSJfZdW2eBnqf3g8Y/R8LvjaJDAJsgRAe+QQNYDDyWApJKfhNdfm1dwpRjygWjIO9Z/fpZ6vufD92shdpCm9GIrX+eh0Op0w0287RKLTA1pNsnX0Gv9KuynqrPleIcJx6Ldd1+0zikWs6ttn2E3ofU83DkC76z/+OibTRE= 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=IvDvZhK1; 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="IvDvZhK1" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e03fe45dc0bso831077276.0 for ; Wed, 17 Jul 2024 18:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264494; x=1721869294; 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=CK59PJHvthhN1XqhU8dM7HWi+8LWSLWxbFsmB17zlH0=; b=IvDvZhK1hu+SeitPWTOeYxi0QFNA9A3hGz9UQS9A3j+V90p8BPkxrb1o3g4oy4YGrq S6HJn6h4iEiNFhXd/yBsV3gdlNbGVRcgvsMg1RaTX01oLvAv4y5ByLhQOZqZDKdJyyi0 L9n7p1uEFSfKaTIFQVxhG/qmJ1b2PZ6ULH5B8MHbqJY9DfsA89D6Fm+mDKwGY7BBkVie X3cuo9/dxXgE9oii7udIanE2Mb/kAMOZV6YUCzJBfIURe8YIoqvY5Adr5BxZL9Ry7F8t AM4xfs2ru+IOzXdTFeYGpBrQtbqvsAMfPpgks5eV/0oJbpoFD4bEWmYjNo01NyGhim+6 zcYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264494; x=1721869294; 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=CK59PJHvthhN1XqhU8dM7HWi+8LWSLWxbFsmB17zlH0=; b=kkrnNfuS90o5x7brBA7bPUoe/hSbUaKDNd/fsywQh5j1hSWMkRu3LXFw1c1BK5p/7g WIzXEELYtNC/Rnh/ZImkRPfpDYf2EhOQor7rpJWaQiGKVvqTUXlac8NQBVQR6aWeCu70 0GbazB4URg6MdtxAtjpJrqmdFS4E0UCbVhsHe46azl1S+bRz+w705ptDmLYuhImuGqu+ FYpJtlVeOtvCgB1mxAOWnixh6OUVhyXR4ZnUzFWWtQz8rVYPGIOiJwVqeSk8t3Ms87jG pZluML1P8cjjRh3Dvam6OXIWUt65L8+prlq4K8it3Nm/Gdj66cmGN/WEX/VmiPU+uNil hLsg== X-Forwarded-Encrypted: i=1; AJvYcCWFnh9LwLOXBQTAXVqR5hrj7nHxMwL6nARIu0nSC70apchmpga0qyFS3DBu9DVcDTNOwbIbAwrfcmOWob+JC0T0zI9kOBT+Zso+QvOB X-Gm-Message-State: AOJu0YzaL/OB/SxMfxhj6aBhp6A35FhdVyPuD0R+wL2D+VlSMKMIlQdt KYxvKqgfhh77VPmEuBaVESo1KquVmdW8StiF8rXsTwZJzrhMLlQaIgzaV1q8u59Y4g0CQlQH8Ck FF6ZQfw== X-Google-Smtp-Source: AGHT+IF0zgfiI7337Gx4Yjc5WQ+vYPQsx4H9UggbKoSxg5u9Xfw8UkV6hdUgp0OEYyULUUoe/l5TQODhg0kQ X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a5b:8c5:0:b0:e05:b006:9e12 with SMTP id 3f1490d57ef6-e05fed6ced8mr7959276.11.1721264494077; Wed, 17 Jul 2024 18:01:34 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:21 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 94FF880C13 for ; Thu, 18 Jul 2024 01:01:37 +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=1721264502; cv=none; b=CRS59/f/rlqAamJItDuC+vIvZvZM/TSvzwIPK/i8O57D/znlfkGWV1G3eXrtfe5ztE+MpXiHMMO4gQyRCstzbuvIMQZ7Uc/eUxkqz5uGR4EXRceRr5AzMIRii/7xv/WCuRYf5jHSvMTyBlaUiHlPwAy2Maqq2GuH/hEYSxzo7HA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264502; c=relaxed/simple; bh=Bx08tB6feHERnMdXGNueKGNYplrQpkF4l9BhuiL3bjY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=SDjNSIk6T9cdvAOz+eW5ufmMG6Y/TZOMfcEtkMZfju8vAmmO2vQ/dmIBsGG7FlqOYr/atz7gegLQr2q5aeup5AOyYMk1eRYliCaCbi30J3zY6eBYv1Z+WFv8FAhb2TPAIIhrscMH/1TbMBGYoIYJHKnQXUxoZ2yOabke5jXtCrU= 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=xDbHt2VD; 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="xDbHt2VD" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e0335450936so714218276.1 for ; Wed, 17 Jul 2024 18:01:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264496; x=1721869296; 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=dsqa4ji/Kru2TpTCpzQSXPab7IPwWK5YnC4MrN+9OsY=; b=xDbHt2VDZvuYdJrQVNz/b7VwTcLVlCp9pm3X0zLdxRLSbVmCG74XjJDTZG3902+7x1 3YKGDADQSMHSB6Td3chwiYK6n3Wv+UBq17yTKGkNgTsvsk/KVJEVG6ndideXqvf6oTv4 90XRxCRVhW5w+oBwq93QWiQ8lEBWCaDFoCODnqdL6cwDWgl01dOq0UEShHFP+/yMkcNQ nWqxJYsQssWVZEQFRkOPf1x6KEd66C+Dr6EpsqOSO29jL0YlAaDhxcDZMV99czkZE1Xt 6X7BEUwQZw+Z+p0JnhpnMFSiIxVi8KTn/vhQzXJwy4S+deLdjQ061yS2sv+8VQNYd2+K efMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264496; x=1721869296; 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=dsqa4ji/Kru2TpTCpzQSXPab7IPwWK5YnC4MrN+9OsY=; b=UVY1j+a6/fCmnNwEsSdGX26fr/wTkTDXJdM0VgrwK4cXDL0KLr4PmT+RgybaLmfAN8 0qWSD97kkO7eIJL8uvzOw/aNokdqYN+HWwqK9y9kaWdHX4SPVw42WJYAvlPpirBXxmZz D+1WtriPPzdkCJQOJq6B9y3KfioVd/yMhzskT2Wp6s9Wv9Y4ljRZVsmKy/Vu8gxwy7bk EWXCjczWI+36A9BzYIuQtQYdOPv574SLfbxv5MWorCMDRGrr2W5cMU6x0TzKK3ozDbWx TNmpGlrxWTQWC4qi/nAjg5e3CSvY8kcLRwC37sbH+Lqi2Y85fUcLJW/iPPARtQKBGvjW Q2eg== X-Forwarded-Encrypted: i=1; AJvYcCVrFxfZOXyb/B8V6VCtmnKD//uRwrVmY7opO4M4VLuV6odCLMtdD1M9cGKU4mzfgsQdk74Y/enmpHS69snxuQdzCD5y/r0ChjW4SIwg X-Gm-Message-State: AOJu0Yybnjwco6wEMH9ltgZhl8Tvov9Wl8hQY6wx4NAJIUUjscbjBozs fskZCNpR51Q0XbHQKe9txWDGboESZ1wsQ9skn4p5/49x/3i6R5eSTglm7gGhmre8hIjIJciJ2S/ ZT1/byw== X-Google-Smtp-Source: AGHT+IHCN1faAO+r6hnMX5BHhvSYi2L3MP7xyujmm2Mr7VslcsQx4zStBqwTrKdnZw0UNaH7Tqzijy2cur+u X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:18c6:b0:e05:aba2:43e9 with SMTP id 3f1490d57ef6-e05fea8a868mr2200276.5.1721264496521; Wed, 17 Jul 2024 18:01:36 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:22 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog From nobody Wed Dec 17 01:10:38 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 A803681ADA for ; Thu, 18 Jul 2024 01:01:39 +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=1721264504; cv=none; b=r+A/adBxyAHRafkbJQNWxukv7kqt4huU8d4B7XlzZoEiOGGCP0IWiq6V9NOsduqYO4hFBdkCeXMLswF18836snQR1bTVzDxGPE7WrtCaCrIZ29WW/1I9kjXIk2o75kaKpFXsXopFvoByp/Hn1Nne3SInxRJqMW7iZmNZd3AEzhM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721264504; c=relaxed/simple; bh=Nt/c1EHasj2QZc8mVbjZQ0vxsj7VTWwQPPvRYVn2ii8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=slAzAeZA9UwVRooE/+63CsoBB5XX18TksivGRWQCgdBaSgyzTrIlwG3Yvl4E8gox+F+MAbTCcqcGD432a8RGSJVd9lZA5YAgx8vpqGxZEpSDhjLjjj7u4TUzHRsbbOOZ7s2FWfbyjO+qNsnFxup1uyW4vQde5PlSrt9EXzjki4Y= 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=iC3rjNlq; 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="iC3rjNlq" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-65be82a3241so7206327b3.0 for ; Wed, 17 Jul 2024 18:01:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264499; x=1721869299; 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=VI+1UrmSH+U4tsTCU1WpnUiPEx/6DVcJnUZK6PtxySs=; b=iC3rjNlqtXu2d2djsF0UBPeTT5+7b++di0WS/SZsizZ74v6G8vHppOLITCVRyJMXlu kn2WotlbgrBox/E/KSrVHkMzoqs+8X8uhYgA9wO3QgJsiM1gtEXuvtZVXpMvBUsReu17 kWtKhCuAMuD5Veqxan8G7f6yTqnTNTGcyRP9syna61e406YXghn2ZfZj6Y7aE78YhIQR XUG/1I0YRcGs3+wOyui0/aVfUt5jOFZ85yZLZsQuYNU/YIfi61slZGAHIqZQEtNSL2DP n8UPpt/nCpu4lHoep+bF9ncH8Axs/xfc8NGL35FauW79WOqCvX9z47KRq5nB4wn22Ftm aAKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264499; x=1721869299; 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=VI+1UrmSH+U4tsTCU1WpnUiPEx/6DVcJnUZK6PtxySs=; b=M7zAJ6dITaniHH7Lu/ypQfei56w3TKfDGNe2d1G3vmeJIMWy19bDhB2AmDQsfVNFsN M0ea1MippbkkcHM5DkqjShtR4XwoQDCjd1HUE2CoUAdC7UN1GzS8YWu8NboLBviY6Lap tqbX/JAMR5dtId9J4e1SfhV6y7pzj14apJBZH5jXVxSyCbDlPQAe0Fimybx3rypnX6VX Fmsrod81t7iKc6TgZrKC2TSwQTQTsGrs49QPMw03PWI9kBPeiRX2w67dj5rmKB6Chn8j YHte0na5klRwGZiTeKwE84qBIuZCF/0KrvLM88WbF0lVJ7yySaqoiF0+nZmb+tzFPXCk nElg== X-Forwarded-Encrypted: i=1; AJvYcCWaylKGxTY4DvJBUMR7WoyaccT/Mc9tbF5IfZbklflgVuD10jGmCU1Ek7bdHeDp6Qn8gpo4jL0laH5OuYyGat48ul1u/SkwU3uhck4O X-Gm-Message-State: AOJu0YwDL58BjJb8W/KOO0ibT7rWvEceNOhEq+wZ9GClu0aNV8ShlcC+ ludrBVHTlaRUU0M33btWPmJmCaOMByevwd4Y/2iz8ZZb6U/IlXEtFWoU0WB6hLJFR9WOlk6He6a 4CBLOrw== X-Google-Smtp-Source: AGHT+IGQt5ri8LAL7TX8J0R4Z6KxrCn64uDLn1sYG1dmmUfG8en4e1ioo3g5nWqMwIk/M1O4Qs9bCX+5dLdq X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:110:b0:65c:1db1:9235 with SMTP id 00721157ae682-666005395bbmr263907b3.0.1721264498698; Wed, 17 Jul 2024 18:01:38 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:23 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-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: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 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 Reviewed-by: Adrian Hunter --- 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.1089.g2a221341d9-goog