From nobody Wed Dec 17 08:55:21 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 99DCC16D9BA for ; Thu, 11 Jul 2024 18:00:16 +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=1720720818; cv=none; b=VSQxKfAP899vCzlJ/JU9q9o4c0Uordpy8ySuzzxZu21Ok8p2XOMNgMcLGs4CSef8iz9X8fxOsGYbPvsRtdzpWuuQwOvcp0wUd9rsi6+djRCjAXxkKHqFUlqyzds9T/he5qKKhzKd5S5GnbMlV1T/4NNmNPGtW9lqUhqYAq/hMqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720818; c=relaxed/simple; bh=a6VbSrYVQRFfI8leebjVbvnR7hh3RWsV95BO6C3pM2A=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=nhPhN8lUTIztHT8bZfCViPKSE33yZQKhkgumzlurEadykq7hM1y1QjKqCNDUEKrTzXwJ/WWIdCUk7rBmLMj57y35V3R1Em1nufXe51xAua+Tz+KmJwHYYb7HKjAho/4hELZAYwDejwAAo0GVSwE7+4ICRtKo8hNpaiaIQUUq5Zk= 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=gb+mQFG6; 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="gb+mQFG6" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e056d640abbso1899328276.0 for ; Thu, 11 Jul 2024 11:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720816; x=1721325616; 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=EMOmsjjbfRL4hNLPYFWbLSO5w8t6s+E/XHk9xV0Hop4=; b=gb+mQFG6IwAYCj9SzaYjm7RorpV5JzZLTFILXnp1/Qd/6H6br+BeBQVVrbKLkn3cSu NhWaz4GInn5RQicxhEYtoV4vOBwOsgvHNG1DMLowSplM9uxr/GCDGbTarbd+yiefpR9D vlBTLUaA1U7JJCWM9VLfjY1IafIfuiTwfoyhj5dtBsEqkK86Sf6XgmQzWYP5rx6n0T5Q W6VcrmGzVB0R78dy7P/71Lh4nqoqrH9M+c6wqOOK4qRHoMhf/TygiYbtht8wcaOH135L YwkXSflfANifWkg5NXKpB0Yy8hLZEJggRU2rz/B/l3tHyqaqFFNznFUsE2lfVsoIKQ4p WKgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720816; x=1721325616; 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=EMOmsjjbfRL4hNLPYFWbLSO5w8t6s+E/XHk9xV0Hop4=; b=ko45o7l5l5a8b5AC+Jg2BcSKJgFsEDfRZA8tOfNEJC7PzvMVYsLOdPQKsLrbD6odZD dqQYoqDV1gIdDw+loUrisjsr6G7eI9hqqreFBJjd19WrTl0vqPjfwRj6DpE0h5KKtss8 N1p6MuRLvtcdXAGezCdwScIY0I+O3oIMqE3pQ4CZqJuhjOLwKARaO2kOHef2IlowKiHY mGsxUiebghrKdyww1mc5kMNaxT39Z3sW3nUTi9B2JRD3GjOZi5uCmO+CcfN9BiGij+8Y k94vWAzyUOmOKcDtuOO4h1GC+5/CAEOshQ1Fsv0aOLFMnDBJMsLLf2oWIw+drWQdlOjz KtHw== X-Forwarded-Encrypted: i=1; AJvYcCWgNQ9XPOnPcql1B2g6+w4IZQ/lVlbzsdwQ570V9TOY/FZXANgmUIV9c9hfSEOvPUJlp9p4oRm83w0VHJbnhis+JfW0W/OXGpFB9OlD X-Gm-Message-State: AOJu0Yz8EwbO4Z1SdF9KcswIH9TDxcBLkGaW+IqB488oaESHpkUsi+CN VY3qK17DEsgZ2ljY5OoGtbUUXFXgRAxC77ni5g3x3CQj/aL34hVpJlwM0RoUARS3+kKWOZcNBqP wxT0l/Q== X-Google-Smtp-Source: AGHT+IGOU/jkyqa8KF9IeY0lS+BXQshpKVVzBAK7j+pR5Ms6PbYBjWcy+MJQoCU8MzleeGZ+ePXJBV2b9ql1 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1106:b0:e03:3c8c:e82c with SMTP id 3f1490d57ef6-e041b17e019mr569632276.9.1720720815591; Thu, 11 Jul 2024 11:00:15 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:41 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 01/28] perf auxtrace: Remove dummy tools From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add perf_session__deliver_synth_attr_event that synthesizes a perf_record_header_attr event with one id. Remove use of perf_event__synthesize_attr that necessitates the use of the dummy tool in order to pass the session. Signed-off-by: Ian Rogers --- 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 32818bd7cd17..c53812f343e9 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1595,35 +1595,6 @@ static int cs_etm__synth_branch_sample(struct cs_etm= _queue *etmq, return ret; } =20 -struct cs_etm_synth { - struct perf_tool dummy_tool; - struct perf_session *session; -}; - -static int cs_etm__event_synth(struct perf_tool *tool, - union perf_event *event, - struct perf_sample *sample __maybe_unused, - struct machine *machine __maybe_unused) -{ - struct cs_etm_synth *cs_etm_synth =3D - container_of(tool, struct cs_etm_synth, dummy_tool); - - return perf_session__deliver_synth_event(cs_etm_synth->session, - event, NULL); -} - -static int cs_etm__synth_event(struct perf_session *session, - struct perf_event_attr *attr, u64 id) -{ - struct cs_etm_synth cs_etm_synth; - - memset(&cs_etm_synth, 0, sizeof(struct cs_etm_synth)); - cs_etm_synth.session =3D session; - - return perf_event__synthesize_attr(&cs_etm_synth.dummy_tool, attr, 1, - &id, cs_etm__event_synth); -} - static int cs_etm__synth_events(struct cs_etm_auxtrace *etm, struct perf_session *session) { @@ -1675,7 +1646,7 @@ static int cs_etm__synth_events(struct cs_etm_auxtrac= e *etm, attr.config =3D PERF_COUNT_HW_BRANCH_INSTRUCTIONS; attr.sample_period =3D 1; attr.sample_type |=3D PERF_SAMPLE_ADDR; - err =3D cs_etm__synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; etm->branches_sample_type =3D attr.sample_type; @@ -1698,7 +1669,7 @@ static int cs_etm__synth_events(struct cs_etm_auxtrac= e *etm, attr.config =3D PERF_COUNT_HW_INSTRUCTIONS; attr.sample_period =3D etm->synth_opts.period; etm->instructions_sample_period =3D attr.sample_period; - err =3D cs_etm__synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; etm->instructions_sample_type =3D attr.sample_type; diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index ec1b3bd9f530..160d346cb450 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -737,35 +737,6 @@ static bool intel_bts_evsel_is_auxtrace(struct perf_se= ssion *session, return evsel->core.attr.type =3D=3D bts->pmu_type; } =20 -struct intel_bts_synth { - struct perf_tool dummy_tool; - struct perf_session *session; -}; - -static int intel_bts_event_synth(struct perf_tool *tool, - union perf_event *event, - struct perf_sample *sample __maybe_unused, - struct machine *machine __maybe_unused) -{ - struct intel_bts_synth *intel_bts_synth =3D - container_of(tool, struct intel_bts_synth, dummy_tool); - - return perf_session__deliver_synth_event(intel_bts_synth->session, - event, NULL); -} - -static int intel_bts_synth_event(struct perf_session *session, - struct perf_event_attr *attr, u64 id) -{ - struct intel_bts_synth intel_bts_synth; - - memset(&intel_bts_synth, 0, sizeof(struct intel_bts_synth)); - intel_bts_synth.session =3D session; - - return perf_event__synthesize_attr(&intel_bts_synth.dummy_tool, attr, 1, - &id, intel_bts_event_synth); -} - static int intel_bts_synth_events(struct intel_bts *bts, struct perf_session *session) { @@ -814,7 +785,7 @@ static int intel_bts_synth_events(struct intel_bts *bts, attr.sample_type |=3D PERF_SAMPLE_ADDR; pr_debug("Synthesizing 'branches' event with id %" PRIu64 " sample type = %#" PRIx64 "\n", id, (u64)attr.sample_type); - err =3D intel_bts_synth_event(session, &attr, id); + err =3D perf_session__deliver_synth_attr_event(session, &attr, id); if (err) { pr_err("%s: failed to synthesize 'branches' event type\n", __func__); diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index d6d7b7512505..1fc03bfd14c3 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -3659,37 +3659,15 @@ static int intel_pt_queue_data(struct perf_session = *session, data_offset, timestamp); } =20 -struct intel_pt_synth { - struct perf_tool dummy_tool; - struct perf_session *session; -}; - -static int intel_pt_event_synth(struct perf_tool *tool, - union perf_event *event, - struct perf_sample *sample __maybe_unused, - struct machine *machine __maybe_unused) -{ - struct intel_pt_synth *intel_pt_synth =3D - container_of(tool, struct intel_pt_synth, dummy_tool); - - return perf_session__deliver_synth_event(intel_pt_synth->session, event, - NULL); -} - static int intel_pt_synth_event(struct perf_session *session, const char *= name, struct perf_event_attr *attr, u64 id) { - struct intel_pt_synth intel_pt_synth; int err; =20 pr_debug("Synthesizing '%s' event with id %" PRIu64 " sample type %#" PRI= x64 "\n", name, id, (u64)attr->sample_type); =20 - memset(&intel_pt_synth, 0, sizeof(struct intel_pt_synth)); - intel_pt_synth.session =3D session; - - err =3D perf_event__synthesize_attr(&intel_pt_synth.dummy_tool, attr, 1, - &id, intel_pt_event_synth); + err =3D perf_session__deliver_synth_attr_event(session, attr, id); if (err) pr_err("%s: failed to synthesize '%s' event type\n", __func__, name); diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 5596bed1b8c8..18a8f4a84045 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1764,6 +1764,30 @@ int perf_session__deliver_synth_event(struct perf_se= ssion *session, return machines__deliver_event(&session->machines, evlist, event, sample,= tool, 0, NULL); } =20 +int perf_session__deliver_synth_attr_event(struct perf_session *session, + const struct perf_event_attr *attr, + u64 id) +{ + union { + struct { + struct perf_record_header_attr attr; + u64 ids[1]; + } attr_id; + union perf_event ev; + } ev =3D { + .attr_id.attr.header.type =3D PERF_RECORD_HEADER_ATTR, + .attr_id.attr.header.size =3D sizeof(ev.attr_id), + .attr_id.ids[0] =3D id, + }; + + if (attr->size !=3D sizeof(ev.attr_id.attr.attr)) { + pr_debug("Unexpected perf_event_attr size\n"); + return -EINVAL; + } + ev.attr_id.attr.attr =3D *attr; + return perf_session__deliver_synth_event(session, &ev.ev, NULL); +} + static void event_swap(union perf_event *event, bool sample_id_all) { perf_event__swap_op swap; diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 4c29dc86956f..cc28976bb00e 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -154,6 +154,9 @@ extern volatile int session_done; int perf_session__deliver_synth_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample); +int perf_session__deliver_synth_attr_event(struct perf_session *session, + const struct perf_event_attr *attr, + u64 id); =20 int perf_session__dsos_hit_all(struct perf_session *session); =20 --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 BAF4816DEA3 for ; Thu, 11 Jul 2024 18:00:18 +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=1720720820; cv=none; b=gTD9nIMxUyncjxavM+RaH6rL1gpGM/cQyLO82TO0UGTlE3RVGJhI0IGqQMrxvS6opiOSglTpGiRsBJVAflna4ZFLNpUn75fAcRkyhI5L3TNRZW6B1zg2AiR4K9hl97aX+OWSwSk2IxPSBLoDiXZlkcZAXiKRCECjdmrEPqMfmqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720820; c=relaxed/simple; bh=LctEg2Je3fRQdJP1aZySQP64dlbQCviuGkAlqwvn5oA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Wk6DW1PttqKAV7UfRg2Q4ICjoyBH8+RYpqBqPkZ781MT0iNFaLxYAvthKEjPiqauaOJZH2Vm7fevNErfDQL5o6oQm2z/IJQtPcZ9IcmkP6j4wRbDcOztgYb7KM7YRD9LjfnPnpj97/bgNw52lftQboZRYLSkREls/uOOU0g0qPE= 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=0nnfwzFT; 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="0nnfwzFT" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-650b621f4cdso17261887b3.1 for ; Thu, 11 Jul 2024 11:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720818; x=1721325618; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=AbSFIAjgELn8En/ODTzECP6YTzi/bZUaiF8JxVDqD4U=; b=0nnfwzFTMJA3TwWBy/o/JeiG/UXbrr7liokMprepstpUAY1Rg5RBdx7RXbyGX8ly+1 DF/GKlpLu/P7gPWe5tCevM2lG3lw5CqOEQXbrrOCWbInlF/0oTuxfRssCxsu602tWzx1 ECkK8tlzNSH9qK/QOTd55OdtH2TiP49vJG9f0hUh0tTF0u682h1rHALsh4b7nAtCpEJK QWpVvGzbFM/Wi0OwO8/K1QkXbqp4sE+ftnAftxeEAeStew+hpB5XlqsojfTa1D7F0TSl L01pm/ZzeJ9QhQ/a4O0PiT0srNTzpZ2sMwZm/hawkmRjMXbaok0mdFRDQNLO3v703p2+ 0vrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720818; x=1721325618; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AbSFIAjgELn8En/ODTzECP6YTzi/bZUaiF8JxVDqD4U=; b=BBRPVliNVZ3rSQWjQHW/3697/Ssdt2toFi4ImWJ8ZFSrTDls85k+drcgh8BXyB74Pr buihWh+fo7O46S71XoQS1SHjbEmI435EQkea6xdXcVJQmT9DafwSbEceVgQHHTU6nBh9 N1EKJRWhYjAqxmKLgJA5Q/1rtGtsmVe9wrd/XkpektjO9452LDC6EyPF92vshWfzOjdN Mq52FjB1Idk6Eli1BR7lxNyOBTOtsiBTVzdFo1rqPFMqrBqP7cKZxOFMJmcowY6t9PU7 Ydbrub0BDw2KvmhrhHc1OSWTsCv6QEOYn6aacY8f1Rq1a2AHfpV+GdQMTzMhbgdmpfxY 5NpA== X-Forwarded-Encrypted: i=1; AJvYcCWDkb7IiVcJisWi/mHen+oiCu9nqsHftSnPO3w6cvECdHMFS7o06OUI6oFWECY0bnZeRPPn8B6MkpwlK/i+qJq5u2JXRcu1w3tq2Fvw X-Gm-Message-State: AOJu0YymLS4Y7MLFS3JTzdFic1+Yo08TiG/nZ6B1KVKrKWDQTNZyJA7/ TJMisVbaKaDw6Ab75ESRVkglV0Q2nCisA6inJYOaQ8Ww85o4AWa9W8JmbrK/nIVCQPCPCUQLcrM lpykKaw== X-Google-Smtp-Source: AGHT+IGeXhaeoNjn7pRRBMER91nAV7MjXLe7mlhn6vY1im3CgeEvPZqQsZteJ+XWeT5joa2vWOBK1cIwB1BE X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1025:b0:e03:5a51:382f with SMTP id 3f1490d57ef6-e041b1153f4mr804588276.8.1720720817740; Thu, 11 Jul 2024 11:00:17 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:42 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 02/28] perf s390-cpumsf: Remove unused struct From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" struct s390_cpumsf_synth was likely cargo culted from other auxtrace examples. It has no users, so remove. Signed-off-by: Ian Rogers --- tools/perf/util/s390-cpumsf.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index 6fe478b0b61b..4ec583e511af 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -952,11 +952,6 @@ s390_cpumsf_process_event(struct perf_session *session, return err; } =20 -struct s390_cpumsf_synth { - struct perf_tool cpumsf_tool; - struct perf_session *session; -}; - static int s390_cpumsf_process_auxtrace_event(struct perf_session *session, union perf_event *event __maybe_unused, --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 3C65F16E861 for ; Thu, 11 Jul 2024 18:00:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720822; cv=none; b=pJnD8tMkRm2r6E+x9arnI0JkiL4lxd+A70NLZzLA2zPvWRjt6KjQJIY3wTDHLUf2UmQjy+hsC9zr2/5q52gAcrgfNFnFZWgfqvqqShzgVXlmhdx3MpmqmvzSIB2DO0RDEQ4qO7Gncc70vNwwC4lK+Om5IOzxbxauJGvrZrtnd1E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720822; c=relaxed/simple; bh=MIIPAWLI0WoNL5OJW6h8lhVqWFcyLLZdhSdtRXLZ1T4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=pWjPmKwN1KqTo7Xh8k9QREN1vyrwwxXzikTZhwjy9qHpiKTRLzwMUACD7mzpMVrEFpr9Ums93+kRI9UL2g+AYG3AnJ5B0SueOBxZTtmLmKXVe/gTROIM3JnpEDIQPHxcfmIlXyU+pvrqGQiyzMhE5vAMpHMvXRCBI27a9loBjiU= 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=wJUOL54z; 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="wJUOL54z" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-651e54bb41bso17348037b3.1 for ; Thu, 11 Jul 2024 11:00:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720820; x=1721325620; 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=EzUK4p38UkhKDsbfF93yQRR2GPAzqU4EO+HGDDPIb8o=; b=wJUOL54zlCKWRgBqG0vTrTEPJ3JIkhvVC41EjvZJfmkJySztLfVuaDvlvkQwl04Sn7 hxgT2+7wPQCZwAlmo1qlaShC2ionI6xOTYDgdxvJQkq7+Tsu3Mf5p1kdQYBD7yQk/UvX aXfaaNqixyvguJ0AmMkExaHSdB6QL2Gzc6JjM3aKgzfkBP41XqdtTtiJ4tLsnACQrV3B W2YuItARD6B3x8ekdnjthDwLC9qqhoYAviPBtAF/pXQaUHOI4I/q3k/zRy5Edkcn+xPy cSsA5p6worJY4XMEFkTW6JGZxPECdjwA6qQZ9AmVj82zMAl7b/0HtlzTMhmOZ6Ictc8E 5yQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720820; x=1721325620; 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=EzUK4p38UkhKDsbfF93yQRR2GPAzqU4EO+HGDDPIb8o=; b=QWvzRv4LQW5PWThd8g1VF9p9cJBP3LdS7z7XQxbmqmSJPILFV6CGAviT1fXaSZc2+6 Pi8LMEFVfseLLCT0pdEs0zMXMU+H/4MvYd2EQ6HieaUepFFegnc5qF4e9ZSFA5dONRhL Pabv5XyqGGgs4pAiVrof2jWyGey7TlZNMOFX/ISjNb4yr4HfauDtkChJ0Q1OrlzoMOYr NFgyZXoZXL+Dt97Gs0iJeqkp0b0jHSuhneslniVDacVWGtcIxll8yrOlUbb8eW1+Guj/ tmuG3T6fPI8Ef/NCqJ6EvJ5r57Mjn2r8etJx+QhO9wAvKHtNaOsLYnbmi1HtsSxZibDJ 3C+w== X-Forwarded-Encrypted: i=1; AJvYcCVbbTXpci7cg7G7+O0LJSOek4YZgsOUzJUVm+YgdB5d6rl9oP7+jqG+HnbDJp3cx9YrWpcOTU8DYzWyt1rjLQ6P9NGJGZKPviMLrkgi X-Gm-Message-State: AOJu0YyktUZ67ZF7akjcGZW6kHJZeyliLDo1D5MfaVwJtZc19WiQV3T/ csKNaQyZhlc5MufQgi1i0ID7evi/cRc9ujlhzSm2UA6HB2b0HQFKzpA2WKbSu0R86qPu1iObtGd 7q+jCSQ== X-Google-Smtp-Source: AGHT+IGk7HjCBqWpD+d/XmopT/Hsmtv7wH1IyWS+4QZ4y11/DDN/Lx4J0Msqdj8IwaEOMsdGEitrp70cKoog X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:a07:b0:e03:b5d0:2aa2 with SMTP id 3f1490d57ef6-e041b1e255amr599255276.13.1720720820135; Thu, 11 Jul 2024 11:00:20 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:43 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 03/28] perf cs-etm: Fix address sanitizer dso build failure 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" cs-etm.c had been missed from having accessor functions added for the sake of reference count checking. Add the function calls and missing dso accessor functions. Fixes: ee756ef7491e ("perf dso: Add reference count checking and accessor f= unctions") Signed-off-by: Ian Rogers --- tools/perf/util/cs-etm.c | 10 +++++----- tools/perf/util/dso.h | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index c53812f343e9..7fd976ea954b 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1013,7 +1013,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *et= mq, u8 trace_chan_id, if (!dso) goto out; =20 - if (dso->data.status =3D=3D DSO_DATA_STATUS_ERROR && + if (dso__data(dso)->status =3D=3D DSO_DATA_STATUS_ERROR && dso__data_status_seen(dso, DSO_DATA_STATUS_SEEN_ITRACE)) goto out; =20 @@ -1027,11 +1027,11 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *= etmq, u8 trace_chan_id, if (len <=3D 0) { ui__warning_once("CS ETM Trace: Missing DSO. Use 'perf archive' or debug= infod to export data from the traced system.\n" " Enable CONFIG_PROC_KCORE or use option '-k /path/to/vm= linux' for kernel symbols.\n"); - if (!dso->auxtrace_warned) { + if (!dso__auxtrace_warned(dso)) { pr_err("CS ETM Trace: Debug data not found for address %#"PRIx64" in %s= \n", - address, - dso->long_name ? dso->long_name : "Unknown"); - dso->auxtrace_warned =3D true; + address, + dso__long_name(dso) ? dso__long_name(dso) : "Unknown"); + dso__set_auxtrace_warned(dso); } goto out; } diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index d72f3b8c37f6..878c1f441868 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -280,6 +280,16 @@ static inline void dso__set_annotate_warned(struct dso= *dso) RC_CHK_ACCESS(dso)->annotate_warned =3D 1; } =20 +static inline bool dso__auxtrace_warned(const struct dso *dso) +{ + return RC_CHK_ACCESS(dso)->auxtrace_warned; +} + +static inline void dso__set_auxtrace_warned(struct dso *dso) +{ + RC_CHK_ACCESS(dso)->auxtrace_warned =3D 1; +} + static inline struct auxtrace_cache *dso__auxtrace_cache(struct dso *dso) { return RC_CHK_ACCESS(dso)->auxtrace_cache; --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 5E63F1459E3 for ; Thu, 11 Jul 2024 18:00:23 +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=1720720828; cv=none; b=frqdvadGmhIYH9RmRxpBiG9pIp8xqy6n3TW8aTIZjAWZUK4aFEbg6eJUlE+sx8bDDktvfZF1x6eNwVFxLDYRrSzVj8seS8gQshxuVrTpqfDCHRttRwZ1QsEML7nTu4fYlgfOaQ8OouSKEAfJk5paqwSwtd8aidu4W7AUqWaCjpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720828; c=relaxed/simple; bh=9T+yGO/f9jySX5IZwq1+BK84FVogbzE7BR+sfw+bRZw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=QRAFBXYxTTfGvpv4DVo3WCTkrc1LtncdYxfIhe0MJd2QvVT1aNfxoar94B5GdJ10hpWD6FnT5POdiBaom6I3lq8e+eh1KM7GkiBOrkHuhxPX+zfGX9XqcPreKExIa0WTmDWIXiN1RaACaV8GapMRWWB90dVxCRMqz3XIxY4C3zM= 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=30k+BMHm; 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="30k+BMHm" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e057ae54529so1922282276.2 for ; Thu, 11 Jul 2024 11:00:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720822; x=1721325622; 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=T1Wq1aBDpvOj6N0rtMLa7aLr9DFiDK25TMCxnfR1oGM=; b=30k+BMHm5P5BJy+n56xG2IKK1zsf2GAy9RP4RTkQQJbF1GarJo/vKCmB3M3yn3h+gf tfxU2X/60J5qcvB+MyX/UGSG4GPSQhg1TyNnUQbo2pGLmQ8A1bD3DDI/jJRlrbULnOn6 jeK9iJLbWTpGZ+C1jChk9EK1gH1E8Rk5CZOIZF+mXhgIYa3RYNIY7QmBPHfesleFtL7S h5+WnTsFSGc99W8KK6ACoIu7KLMYnLC8MW5YyjNACnvtTMCkx3dK6uc4BDLZgpfa6a9t e/Z4aMGgJYRZcQfgumE5QpJfRQ5wN0wolLODb8YRI3kmXWVWgihtw7gimOxgTQkM+sQZ pFEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720822; x=1721325622; 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=T1Wq1aBDpvOj6N0rtMLa7aLr9DFiDK25TMCxnfR1oGM=; b=wPaMEetgTVXpDQ8K0hkppglGO5Ir7WAsK+PgF70pPmZjXAwmimMHrwIKLsBxpl6353 a4PGWc6c1f/k4OdL7DcVGOtI/98KlhKYtlTpp0bFIbPez3Ba1avlUq+TJJBQsbpmUCgK 08sx8QtKUrp4JjImOWXHvW2OXKPGpCs6VhmjfXyJzQR4Nn7Abr18y1/vczlk3Fz3fPKY foNsguals1uRR5UF1KNmmpQWIh8FfNRBwxDKwTXMBXna/AeWJBFi2QA7JWI/OHoy9zfp xa3l6elRjuVudUnaCM9qSezfUqR4BHUyRq6RE6awxT0XtZaAoOtKTUyqOW6pP6qe3vHL ydQw== X-Forwarded-Encrypted: i=1; AJvYcCUc0QPXNQ+FKBez+dlKvBMLAW6ipu/yXEpggdNou+AB/DV7/1O2fH7QMwpKLsa63efUNAv1of4UchjlyIELoa03255UWAoffCXALcku X-Gm-Message-State: AOJu0YxZPsbLP8nZ9zhGiIS9wpY7tT+s1b/BuehPDHev6GIRiHg5KeHm 6s11v+IkREs/WTP1GEyqVXvv4gzzGkOeWanIbtNg6+kfXHDxDnzaaz3yJWa8C9spAgo9QJjUi0u fYZMKkw== X-Google-Smtp-Source: AGHT+IHTYBjw89cZ1pmEhOGw+BvY6+P+M5r6Fdu7SzGh+DR0i9y+Y98KIyDF1VL9IUcmPmd9o5J0jIZa/uPv X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:158c:b0:e03:a0b2:f73 with SMTP id 3f1490d57ef6-e041b05c952mr226433276.6.1720720822430; Thu, 11 Jul 2024 11:00:22 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:44 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 04/28] perf tool: Constify tool pointers From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The tool pointer (to a struct largely of function pointers) is passed around but is unchanged except at initialization. Change parameter and variable types to be const to lower the possibilities of what could happen with a tool. Signed-off-by: Ian Rogers --- tools/perf/arch/x86/util/event.c | 4 +- tools/perf/bench/synthesize.c | 2 +- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-c2c.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-inject.c | 70 ++++++++++++------------- tools/perf/builtin-kmem.c | 3 +- tools/perf/builtin-kvm.c | 4 +- tools/perf/builtin-kwork.c | 22 ++++---- tools/perf/builtin-lock.c | 4 +- tools/perf/builtin-mem.c | 4 +- tools/perf/builtin-record.c | 14 ++--- tools/perf/builtin-report.c | 12 ++--- tools/perf/builtin-sched.c | 34 ++++++------ tools/perf/builtin-script.c | 41 ++++++++------- tools/perf/builtin-stat.c | 8 +-- tools/perf/builtin-timechart.c | 8 +-- tools/perf/builtin-top.c | 2 +- tools/perf/builtin-trace.c | 4 +- tools/perf/tests/cpumap.c | 6 +-- tools/perf/tests/dlfilter-test.c | 2 +- tools/perf/tests/dwarf-unwind.c | 2 +- tools/perf/tests/event_update.c | 8 +-- tools/perf/tests/stat.c | 6 +-- tools/perf/tests/thread-map.c | 2 +- tools/perf/util/arm-spe.c | 6 +-- tools/perf/util/auxtrace.c | 12 ++--- tools/perf/util/auxtrace.h | 20 ++++---- tools/perf/util/bpf-event.c | 4 +- tools/perf/util/build-id.c | 4 +- tools/perf/util/build-id.h | 4 +- tools/perf/util/cs-etm.c | 6 +-- tools/perf/util/data-convert-bt.c | 4 +- tools/perf/util/data-convert-json.c | 4 +- tools/perf/util/event.c | 34 ++++++------ tools/perf/util/event.h | 34 ++++++------ tools/perf/util/header.c | 6 +-- tools/perf/util/header.h | 4 +- tools/perf/util/hisi-ptt.c | 6 +-- tools/perf/util/intel-bts.c | 6 +-- tools/perf/util/intel-pt.c | 6 +-- tools/perf/util/jitdump.c | 4 +- tools/perf/util/s390-cpumsf.c | 6 +-- tools/perf/util/session.c | 30 +++++------ tools/perf/util/session.h | 2 +- tools/perf/util/synthetic-events.c | 80 ++++++++++++++--------------- tools/perf/util/synthetic-events.h | 70 ++++++++++++------------- tools/perf/util/tool.h | 8 +-- tools/perf/util/tsc.c | 2 +- 49 files changed, 314 insertions(+), 316 deletions(-) diff --git a/tools/perf/arch/x86/util/event.c b/tools/perf/arch/x86/util/ev= ent.c index e65b7dbe27fb..a0400707180c 100644 --- a/tools/perf/arch/x86/util/event.c +++ b/tools/perf/arch/x86/util/event.c @@ -15,7 +15,7 @@ #if defined(__x86_64__) =20 struct perf_event__synthesize_extra_kmaps_cb_args { - struct perf_tool *tool; + const struct perf_tool *tool; perf_event__handler_t process; struct machine *machine; union perf_event *event; @@ -65,7 +65,7 @@ static int perf_event__synthesize_extra_kmaps_cb(struct m= ap *map, void *data) return 0; } =20 -int perf_event__synthesize_extra_kmaps(struct perf_tool *tool, +int perf_event__synthesize_extra_kmaps(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine) { diff --git a/tools/perf/bench/synthesize.c b/tools/perf/bench/synthesize.c index 7401ebbac100..9b333276cbdb 100644 --- a/tools/perf/bench/synthesize.c +++ b/tools/perf/bench/synthesize.c @@ -49,7 +49,7 @@ static const char *const bench_usage[] =3D { =20 static atomic_t event_count; =20 -static int process_synthesized_event(struct perf_tool *tool __maybe_unused, +static int process_synthesized_event(const struct perf_tool *tool __maybe_= unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index b10b7f005658..c0685d2c8de1 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -279,7 +279,7 @@ static int evsel__add_sample(struct evsel *evsel, struc= t perf_sample *sample, return ret; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index c157bd31f2e5..88c131d05186 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -273,7 +273,7 @@ static void compute_stats(struct c2c_hist_entry *c2c_he, update_stats(&cstats->load, weight); } =20 -static int process_sample_event(struct perf_tool *tool __maybe_unused, +static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 57d300d8e570..4c0567882a7a 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -388,7 +388,7 @@ struct hist_entry_ops block_hist_ops =3D { .free =3D block_hist_free, }; =20 -static int diff__process_sample_event(struct perf_tool *tool, +static int diff__process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index a212678d47be..be74e2bf1f00 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -134,7 +134,7 @@ struct event_entry { union perf_event event[]; }; =20 -static int dso__inject_build_id(struct dso *dso, struct perf_tool *tool, +static int dso__inject_build_id(struct dso *dso, const struct perf_tool *t= ool, struct machine *machine, u8 cpumode, u32 flags); =20 static int output_bytes(struct perf_inject *inject, void *buf, size_t sz) @@ -149,7 +149,7 @@ static int output_bytes(struct perf_inject *inject, voi= d *buf, size_t sz) return 0; } =20 -static int perf_event__repipe_synth(struct perf_tool *tool, +static int perf_event__repipe_synth(const struct perf_tool *tool, union perf_event *event) { struct perf_inject *inject =3D container_of(tool, struct perf_inject, @@ -158,7 +158,7 @@ static int perf_event__repipe_synth(struct perf_tool *t= ool, return output_bytes(inject, event, event->header.size); } =20 -static int perf_event__repipe_oe_synth(struct perf_tool *tool, +static int perf_event__repipe_oe_synth(const struct perf_tool *tool, union perf_event *event, struct ordered_events *oe __maybe_unused) { @@ -166,7 +166,7 @@ static int perf_event__repipe_oe_synth(struct perf_tool= *tool, } =20 #ifdef HAVE_JITDUMP -static int perf_event__drop_oe(struct perf_tool *tool __maybe_unused, +static int perf_event__drop_oe(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct ordered_events *oe __maybe_unused) { @@ -188,7 +188,7 @@ static int perf_event__repipe_op4_synth(struct perf_ses= sion *session, return perf_event__repipe_synth(session->tool, event); } =20 -static int perf_event__repipe_attr(struct perf_tool *tool, +static int perf_event__repipe_attr(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist) { @@ -206,7 +206,7 @@ static int perf_event__repipe_attr(struct perf_tool *to= ol, return perf_event__repipe_synth(tool, event); } =20 -static int perf_event__repipe_event_update(struct perf_tool *tool, +static int perf_event__repipe_event_update(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist __maybe_unused) { @@ -237,7 +237,7 @@ static int copy_bytes(struct perf_inject *inject, struc= t perf_data *data, off_t static s64 perf_event__repipe_auxtrace(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_inject *inject =3D container_of(tool, struct perf_inject, tool); int ret; @@ -284,7 +284,7 @@ perf_event__repipe_auxtrace(struct perf_session *sessio= n __maybe_unused, =20 #endif =20 -static int perf_event__repipe(struct perf_tool *tool, +static int perf_event__repipe(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -292,7 +292,7 @@ static int perf_event__repipe(struct perf_tool *tool, return perf_event__repipe_synth(tool, event); } =20 -static int perf_event__drop(struct perf_tool *tool __maybe_unused, +static int perf_event__drop(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -300,7 +300,7 @@ static int perf_event__drop(struct perf_tool *tool __ma= ybe_unused, return 0; } =20 -static int perf_event__drop_aux(struct perf_tool *tool, +static int perf_event__drop_aux(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct machine *machine __maybe_unused) @@ -341,13 +341,13 @@ perf_inject__cut_auxtrace_sample(struct perf_inject *= inject, return ev; } =20 -typedef int (*inject_handler)(struct perf_tool *tool, +typedef int (*inject_handler)(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine); =20 -static int perf_event__repipe_sample(struct perf_tool *tool, +static int perf_event__repipe_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -372,7 +372,7 @@ static int perf_event__repipe_sample(struct perf_tool *= tool, return perf_event__repipe_synth(tool, event); } =20 -static int perf_event__repipe_mmap(struct perf_tool *tool, +static int perf_event__repipe_mmap(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -386,7 +386,7 @@ static int perf_event__repipe_mmap(struct perf_tool *to= ol, } =20 #ifdef HAVE_JITDUMP -static int perf_event__jit_repipe_mmap(struct perf_tool *tool, +static int perf_event__jit_repipe_mmap(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -455,7 +455,7 @@ static struct dso *findnew_dso(int pid, int tid, const = char *filename, return dso; } =20 -static int perf_event__repipe_buildid_mmap(struct perf_tool *tool, +static int perf_event__repipe_buildid_mmap(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -474,7 +474,7 @@ static int perf_event__repipe_buildid_mmap(struct perf_= tool *tool, return perf_event__repipe(tool, event, sample, machine); } =20 -static int perf_event__repipe_mmap2(struct perf_tool *tool, +static int perf_event__repipe_mmap2(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -500,7 +500,7 @@ static int perf_event__repipe_mmap2(struct perf_tool *t= ool, } =20 #ifdef HAVE_JITDUMP -static int perf_event__jit_repipe_mmap2(struct perf_tool *tool, +static int perf_event__jit_repipe_mmap2(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -524,7 +524,7 @@ static int perf_event__jit_repipe_mmap2(struct perf_too= l *tool, } #endif =20 -static int perf_event__repipe_buildid_mmap2(struct perf_tool *tool, +static int perf_event__repipe_buildid_mmap2(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -565,7 +565,7 @@ static int perf_event__repipe_buildid_mmap2(struct perf= _tool *tool, return 0; } =20 -static int perf_event__repipe_fork(struct perf_tool *tool, +static int perf_event__repipe_fork(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -578,7 +578,7 @@ static int perf_event__repipe_fork(struct perf_tool *to= ol, return err; } =20 -static int perf_event__repipe_comm(struct perf_tool *tool, +static int perf_event__repipe_comm(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -591,7 +591,7 @@ static int perf_event__repipe_comm(struct perf_tool *to= ol, return err; } =20 -static int perf_event__repipe_namespaces(struct perf_tool *tool, +static int perf_event__repipe_namespaces(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -603,7 +603,7 @@ static int perf_event__repipe_namespaces(struct perf_to= ol *tool, return err; } =20 -static int perf_event__repipe_exit(struct perf_tool *tool, +static int perf_event__repipe_exit(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -712,7 +712,7 @@ static bool perf_inject__lookup_known_build_id(struct p= erf_inject *inject, return false; } =20 -static int dso__inject_build_id(struct dso *dso, struct perf_tool *tool, +static int dso__inject_build_id(struct dso *dso, const struct perf_tool *t= ool, struct machine *machine, u8 cpumode, u32 flags) { struct perf_inject *inject =3D container_of(tool, struct perf_inject, @@ -743,7 +743,7 @@ static int dso__inject_build_id(struct dso *dso, struct= perf_tool *tool, return 0; } =20 -int perf_event__inject_buildid(struct perf_tool *tool, union perf_event *e= vent, +int perf_event__inject_buildid(const struct perf_tool *tool, union perf_ev= ent *event, struct perf_sample *sample, struct evsel *evsel __maybe_unused, struct machine *machine) @@ -776,7 +776,7 @@ int perf_event__inject_buildid(struct perf_tool *tool, = union perf_event *event, return 0; } =20 -static int perf_inject__sched_process_exit(struct perf_tool *tool, +static int perf_inject__sched_process_exit(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel __maybe_unused, @@ -796,7 +796,7 @@ static int perf_inject__sched_process_exit(struct perf_= tool *tool, return 0; } =20 -static int perf_inject__sched_switch(struct perf_tool *tool, +static int perf_inject__sched_switch(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -821,7 +821,7 @@ static int perf_inject__sched_switch(struct perf_tool *= tool, } =20 #ifdef HAVE_LIBTRACEEVENT -static int perf_inject__sched_stat(struct perf_tool *tool, +static int perf_inject__sched_stat(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel, @@ -866,7 +866,7 @@ static int guest_session__output_bytes(struct guest_ses= sion *gs, void *buf, size return ret < 0 ? ret : 0; } =20 -static int guest_session__repipe(struct perf_tool *tool, +static int guest_session__repipe(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -1032,7 +1032,7 @@ static struct guest_id *guest_session__lookup_id(stru= ct guest_session *gs, u64 i return NULL; } =20 -static int process_attr(struct perf_tool *tool, union perf_event *event, +static int process_attr(const struct perf_tool *tool, union perf_event *ev= ent, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) { @@ -1160,7 +1160,7 @@ static u64 evlist__first_id(struct evlist *evlist) return 0; } =20 -static int process_build_id(struct perf_tool *tool, +static int process_build_id(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -1210,7 +1210,7 @@ static int guest_session__add_build_ids(struct guest_= session *gs) gs); } =20 -static int guest_session__ksymbol_event(struct perf_tool *tool, +static int guest_session__ksymbol_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -1574,7 +1574,7 @@ static int guest_session__flush_events(struct guest_s= ession *gs) return guest_session__inject_events(gs, -1); } =20 -static int host__repipe(struct perf_tool *tool, +static int host__repipe(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -1647,7 +1647,7 @@ static int host__finished_init(struct perf_session *s= ession, union perf_event *e * guest events up to the same time. Finally write out the FINISHED_ROUND = event * itself. */ -static int host__finished_round(struct perf_tool *tool, +static int host__finished_round(const struct perf_tool *tool, union perf_event *event, struct ordered_events *oe) { @@ -1665,7 +1665,7 @@ static int host__finished_round(struct perf_tool *too= l, return perf_event__repipe_oe_synth(tool, event, oe); } =20 -static int host__context_switch(struct perf_tool *tool, +static int host__context_switch(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -1719,7 +1719,7 @@ static int evsel__check_stype(struct evsel *evsel, u6= 4 sample_type, const char * return 0; } =20 -static int drop_sample(struct perf_tool *tool __maybe_unused, +static int drop_sample(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct evsel *evsel __maybe_unused, diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 6fd95be5032b..859ff018eace 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -955,7 +955,7 @@ static bool perf_kmem__skip_sample(struct perf_sample *= sample) typedef int (*tracepoint_handler)(struct evsel *evsel, struct perf_sample *sample); =20 -static int process_sample_event(struct perf_tool *tool __maybe_unused, +static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -2061,4 +2061,3 @@ int cmd_kmem(int argc, const char **argv) =20 return ret; } - diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 71165036e4ca..a3b903cf4311 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1166,7 +1166,7 @@ static void print_result(struct perf_kvm_stat *kvm) } =20 #if defined(HAVE_TIMERFD_SUPPORT) && defined(HAVE_LIBTRACEEVENT) -static int process_lost_event(struct perf_tool *tool, +static int process_lost_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -1187,7 +1187,7 @@ static bool skip_sample(struct perf_kvm_stat *kvm, return false; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 56e3f3a5e03a..8ffaa80a2d1d 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -958,7 +958,7 @@ static int top_sched_switch_event(struct perf_kwork *kw= ork, } =20 static struct kwork_class kwork_irq; -static int process_irq_handler_entry_event(struct perf_tool *tool, +static int process_irq_handler_entry_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -971,7 +971,7 @@ static int process_irq_handler_entry_event(struct perf_= tool *tool, return 0; } =20 -static int process_irq_handler_exit_event(struct perf_tool *tool, +static int process_irq_handler_exit_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1037,7 +1037,7 @@ static struct kwork_class kwork_irq =3D { }; =20 static struct kwork_class kwork_softirq; -static int process_softirq_raise_event(struct perf_tool *tool, +static int process_softirq_raise_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1051,7 +1051,7 @@ static int process_softirq_raise_event(struct perf_to= ol *tool, return 0; } =20 -static int process_softirq_entry_event(struct perf_tool *tool, +static int process_softirq_entry_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1065,7 +1065,7 @@ static int process_softirq_entry_event(struct perf_to= ol *tool, return 0; } =20 -static int process_softirq_exit_event(struct perf_tool *tool, +static int process_softirq_exit_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1167,7 +1167,7 @@ static struct kwork_class kwork_softirq =3D { }; =20 static struct kwork_class kwork_workqueue; -static int process_workqueue_activate_work_event(struct perf_tool *tool, +static int process_workqueue_activate_work_event(const struct perf_tool *t= ool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1181,7 +1181,7 @@ static int process_workqueue_activate_work_event(stru= ct perf_tool *tool, return 0; } =20 -static int process_workqueue_execute_start_event(struct perf_tool *tool, +static int process_workqueue_execute_start_event(const struct perf_tool *t= ool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1195,7 +1195,7 @@ static int process_workqueue_execute_start_event(stru= ct perf_tool *tool, return 0; } =20 -static int process_workqueue_execute_end_event(struct perf_tool *tool, +static int process_workqueue_execute_end_event(const struct perf_tool *too= l, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1266,7 +1266,7 @@ static struct kwork_class kwork_workqueue =3D { }; =20 static struct kwork_class kwork_sched; -static int process_sched_switch_event(struct perf_tool *tool, +static int process_sched_switch_event(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) @@ -1945,12 +1945,12 @@ static int perf_kwork__report(struct perf_kwork *kw= ork) return 0; } =20 -typedef int (*tracepoint_handler)(struct perf_tool *tool, +typedef int (*tracepoint_handler)(const struct perf_tool *tool, struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 -static int perf_kwork__process_tracepoint_sample(struct perf_tool *tool, +static int perf_kwork__process_tracepoint_sample(const struct perf_tool *t= ool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 0253184b3b58..6efa9d646637 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1501,7 +1501,7 @@ static const struct evsel_str_handler contention_trac= epoints[] =3D { { "lock:contention_end", evsel__process_contention_end, }, }; =20 -static int process_event_update(struct perf_tool *tool, +static int process_event_update(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist) { @@ -1520,7 +1520,7 @@ static int process_event_update(struct perf_tool *too= l, typedef int (*tracepoint_handler)(struct evsel *evsel, struct perf_sample *sample); =20 -static int process_sample_event(struct perf_tool *tool __maybe_unused, +static int process_sample_event(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index 863fcd735dae..c2038a32543c 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -188,7 +188,7 @@ static int __cmd_record(int argc, const char **argv, st= ruct perf_mem *mem) } =20 static int -dump_raw_samples(struct perf_tool *tool, +dump_raw_samples(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -262,7 +262,7 @@ dump_raw_samples(struct perf_tool *tool, return 0; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel __maybe_unused, diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 019305b94e5f..e8677f9e1ccb 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 24e9d83c7bb6..2ad28c49d31f 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1485,7 +1485,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) @@ -1498,7 +1498,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) @@ -1683,7 +1683,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) @@ -1709,7 +1709,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) @@ -1722,7 +1722,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) @@ -1739,7 +1739,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) @@ -1752,12 +1752,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, @@ -1773,7 +1773,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) @@ -2419,7 +2419,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, @@ -2428,7 +2428,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, @@ -2512,7 +2512,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, @@ -2540,7 +2540,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, @@ -2671,7 +2671,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, @@ -2680,7 +2680,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) @@ -2923,13 +2923,13 @@ static void timehist_print_summary(struct perf_sche= d *sched, printf(" (x %d)\n", sched->max_cpu.cpu); } =20 -typedef int (*sched_handler)(struct perf_tool *tool, +typedef int (*sched_handler)(const struct perf_tool *tool, union perf_event *event, struct evsel *evsel, struct perf_sample *sample, struct machine *machine); =20 -static int perf_timehist__process_sample(struct perf_tool *tool, +static int perf_timehist__process_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index c16224b1fef3..394bce9f5338 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2399,7 +2399,7 @@ static bool filter_cpu(struct perf_sample *sample) return false; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, @@ -2486,7 +2486,7 @@ static int process_sample_event(struct perf_tool *too= l, // Used when scr->per_event_dump is not set static struct evsel_script es_stdout; =20 -static int process_attr(struct perf_tool *tool, union perf_event *event, +static int process_attr(const struct perf_tool *tool, union perf_event *ev= ent, struct evlist **pevlist) { struct perf_script *scr =3D container_of(tool, struct perf_script, tool); @@ -2552,7 +2552,7 @@ static int process_attr(struct perf_tool *tool, union= perf_event *event, return 0; } =20 -static int print_event_with_time(struct perf_tool *tool, +static int print_event_with_time(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine, @@ -2588,14 +2588,14 @@ static int print_event_with_time(struct perf_tool *= tool, return 0; } =20 -static int print_event(struct perf_tool *tool, union perf_event *event, +static int print_event(const struct perf_tool *tool, union perf_event *eve= nt, struct perf_sample *sample, struct machine *machine, pid_t pid, pid_t tid) { return print_event_with_time(tool, event, sample, machine, pid, tid, 0); } =20 -static int process_comm_event(struct perf_tool *tool, +static int process_comm_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2607,7 +2607,7 @@ static int process_comm_event(struct perf_tool *tool, event->comm.tid); } =20 -static int process_namespaces_event(struct perf_tool *tool, +static int process_namespaces_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2619,7 +2619,7 @@ static int process_namespaces_event(struct perf_tool = *tool, event->namespaces.tid); } =20 -static int process_cgroup_event(struct perf_tool *tool, +static int process_cgroup_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2631,7 +2631,7 @@ static int process_cgroup_event(struct perf_tool *too= l, sample->tid); } =20 -static int process_fork_event(struct perf_tool *tool, +static int process_fork_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2643,7 +2643,7 @@ static int process_fork_event(struct perf_tool *tool, event->fork.pid, event->fork.tid, event->fork.time); } -static int process_exit_event(struct perf_tool *tool, +static int process_exit_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2656,7 +2656,7 @@ static int process_exit_event(struct perf_tool *tool, return perf_event__process_exit(tool, event, sample, machine); } =20 -static int process_mmap_event(struct perf_tool *tool, +static int process_mmap_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2668,7 +2668,7 @@ static int process_mmap_event(struct perf_tool *tool, event->mmap.tid); } =20 -static int process_mmap2_event(struct perf_tool *tool, +static int process_mmap2_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2680,7 +2680,7 @@ static int process_mmap2_event(struct perf_tool *tool, event->mmap2.tid); } =20 -static int process_switch_event(struct perf_tool *tool, +static int process_switch_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2712,7 +2712,7 @@ static int process_auxtrace_error(struct perf_session= *session, } =20 static int -process_lost_event(struct perf_tool *tool, +process_lost_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2722,7 +2722,7 @@ process_lost_event(struct perf_tool *tool, } =20 static int -process_throttle_event(struct perf_tool *tool __maybe_unused, +process_throttle_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2733,7 +2733,7 @@ process_throttle_event(struct perf_tool *tool __maybe= _unused, } =20 static int -process_finished_round_event(struct perf_tool *tool __maybe_unused, +process_finished_round_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct ordered_events *oe __maybe_unused) =20 @@ -2743,7 +2743,7 @@ process_finished_round_event(struct perf_tool *tool _= _maybe_unused, } =20 static int -process_bpf_events(struct perf_tool *tool __maybe_unused, +process_bpf_events(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -2755,7 +2755,7 @@ process_bpf_events(struct perf_tool *tool __maybe_unu= sed, sample->tid); } =20 -static int process_text_poke_events(struct perf_tool *tool, +static int process_text_poke_events(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -3757,7 +3757,7 @@ static int process_thread_map_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_script *script =3D container_of(tool, struct perf_script, too= l); =20 if (dump_trace) @@ -3779,7 +3779,7 @@ static int process_cpu_map_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_script *script =3D container_of(tool, struct perf_script, too= l); =20 if (dump_trace) @@ -3809,11 +3809,10 @@ static int process_feature_event(struct perf_sessio= n *session, static int perf_script__process_auxtrace_info(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; - int ret =3D perf_event__process_auxtrace_info(session, event); =20 if (ret =3D=3D 0) { + const struct perf_tool *tool =3D session->tool; struct perf_script *script =3D container_of(tool, struct perf_script, to= ol); =20 ret =3D perf_script__setup_per_event_dump(script); diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 661832756a24..d460c46f15fd 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -248,7 +248,7 @@ static void perf_stat__reset_stats(void) perf_stat__reset_shadow_stats(); } =20 -static int process_synthesized_event(struct perf_tool *tool __maybe_unused, +static int process_synthesized_event(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -2180,7 +2180,7 @@ static int process_stat_config_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_stat *st =3D container_of(tool, struct perf_stat, tool); =20 perf_event__read_stat_config(&stat_config, &event->stat_config); @@ -2229,7 +2229,7 @@ static int process_thread_map_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_stat *st =3D container_of(tool, struct perf_stat, tool); =20 if (st->threads) { @@ -2248,7 +2248,7 @@ static int process_cpu_map_event(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_stat *st =3D container_of(tool, struct perf_stat, tool); struct perf_cpu_map *cpus; =20 diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 19d4542ea18a..5bf818baa662 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -320,7 +320,7 @@ static int *cpus_cstate_state; static u64 *cpus_pstate_start_times; static u64 *cpus_pstate_state; =20 -static int process_comm_event(struct perf_tool *tool, +static int process_comm_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -330,7 +330,7 @@ static int process_comm_event(struct perf_tool *tool, return 0; } =20 -static int process_fork_event(struct perf_tool *tool, +static int process_fork_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -340,7 +340,7 @@ static int process_fork_event(struct perf_tool *tool, return 0; } =20 -static int process_exit_event(struct perf_tool *tool, +static int process_exit_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -571,7 +571,7 @@ typedef int (*tracepoint_handler)(struct timechart *tch= art, struct perf_sample *sample, const char *backtrace); =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index e8cbbf10d361..d6fcc6c122da 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -740,7 +740,7 @@ static int hist_iter__top_callback(struct hist_entry_it= er *iter, return 0; } =20 -static void perf_event__process_sample(struct perf_tool *tool, +static void perf_event__process_sample(const struct perf_tool *tool, const union perf_event *event, struct evsel *evsel, struct perf_sample *sample, diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index a547ccfa92c9..e39469808ef5 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1637,7 +1637,7 @@ static int trace__process_event(struct trace *trace, = struct machine *machine, return ret; } =20 -static int trace__tool_process(struct perf_tool *tool, +static int trace__tool_process(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -3009,7 +3009,7 @@ static void trace__set_base_time(struct trace *trace, trace->base_time =3D sample->time; } =20 -static int trace__process_sample(struct perf_tool *tool, +static int trace__process_sample(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c index bd8e396f3e57..2f0168b2a5a9 100644 --- a/tools/perf/tests/cpumap.c +++ b/tools/perf/tests/cpumap.c @@ -11,7 +11,7 @@ =20 struct machine; =20 -static int process_event_mask(struct perf_tool *tool __maybe_unused, +static int process_event_mask(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -47,7 +47,7 @@ static int process_event_mask(struct perf_tool *tool __ma= ybe_unused, return 0; } =20 -static int process_event_cpus(struct perf_tool *tool __maybe_unused, +static int process_event_cpus(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -73,7 +73,7 @@ static int process_event_cpus(struct perf_tool *tool __ma= ybe_unused, return 0; } =20 -static int process_event_range_cpus(struct perf_tool *tool __maybe_unused, +static int process_event_range_cpus(const struct perf_tool *tool __maybe_u= nused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/tests/dlfilter-test.c b/tools/perf/tests/dlfilter-t= est.c index da3a9b50b1b1..54f59d1246bc 100644 --- a/tools/perf/tests/dlfilter-test.c +++ b/tools/perf/tests/dlfilter-test.c @@ -62,7 +62,7 @@ static int test_result(const char *msg, int ret) return ret; } =20 -static int process(struct perf_tool *tool, union perf_event *event, +static int process(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) { diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwin= d.c index d01aa931fe81..f85d391ced98 100644 --- a/tools/perf/tests/dwarf-unwind.c +++ b/tools/perf/tests/dwarf-unwind.c @@ -37,7 +37,7 @@ #define NO_TAIL_CALL_BARRIER __asm__ __volatile__("" : : : "memory"); #endif =20 -static int mmap_handler(struct perf_tool *tool __maybe_unused, +static int mmap_handler(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_updat= e.c index d093a9b878d1..fdecad920f59 100644 --- a/tools/perf/tests/event_update.c +++ b/tools/perf/tests/event_update.c @@ -12,7 +12,7 @@ #include "tests.h" #include "debug.h" =20 -static int process_event_unit(struct perf_tool *tool __maybe_unused, +static int process_event_unit(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -25,7 +25,7 @@ static int process_event_unit(struct perf_tool *tool __ma= ybe_unused, return 0; } =20 -static int process_event_scale(struct perf_tool *tool __maybe_unused, +static int process_event_scale(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -43,7 +43,7 @@ struct event_name { const char *name; }; =20 -static int process_event_name(struct perf_tool *tool, +static int process_event_name(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -57,7 +57,7 @@ static int process_event_name(struct perf_tool *tool, return 0; } =20 -static int process_event_cpus(struct perf_tool *tool __maybe_unused, +static int process_event_cpus(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/tests/stat.c b/tools/perf/tests/stat.c index 706780fb5695..6468cc0d0204 100644 --- a/tools/perf/tests/stat.c +++ b/tools/perf/tests/stat.c @@ -21,7 +21,7 @@ static bool has_term(struct perf_record_stat_config *conf= ig, return false; } =20 -static int process_stat_config_event(struct perf_tool *tool __maybe_unused, +static int process_stat_config_event(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -62,7 +62,7 @@ static int test__synthesize_stat_config(struct test_suite= *test __maybe_unused, return 0; } =20 -static int process_stat_event(struct perf_tool *tool __maybe_unused, +static int process_stat_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -93,7 +93,7 @@ static int test__synthesize_stat(struct test_suite *test = __maybe_unused, int sub return 0; } =20 -static int process_stat_round_event(struct perf_tool *tool __maybe_unused, +static int process_stat_round_event(const struct perf_tool *tool __maybe_u= nused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c index 74308c1368fe..1fe521466bf4 100644 --- a/tools/perf/tests/thread-map.c +++ b/tools/perf/tests/thread-map.c @@ -60,7 +60,7 @@ static int test__thread_map(struct test_suite *test __may= be_unused, int subtest return 0; } =20 -static int process_event(struct perf_tool *tool __maybe_unused, +static int process_event(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index fa40f3cb6266..138ffc71b32d 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -899,7 +899,7 @@ static int arm_spe_context_switch(struct arm_spe *spe, = union perf_event *event, static int arm_spe_process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { int err =3D 0; u64 timestamp; @@ -947,7 +947,7 @@ static int arm_spe_process_event(struct perf_session *s= ession, =20 static int arm_spe_process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct arm_spe *spe =3D container_of(session->auxtrace, struct arm_spe, auxtrace); @@ -985,7 +985,7 @@ static int arm_spe_process_auxtrace_event(struct perf_s= ession *session, } =20 static int arm_spe_flush(struct perf_session *session __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct arm_spe *spe =3D container_of(session->auxtrace, struct arm_spe, auxtrace); diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index e2f317063eec..cbb773ed6f1a 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -1240,7 +1240,7 @@ void auxtrace_synth_error(struct perf_record_auxtrace= _error *auxtrace_error, int } =20 int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, - struct perf_tool *tool, + const struct perf_tool *tool, struct perf_session *session, perf_event__handler_t process) { @@ -1831,7 +1831,7 @@ int __weak compat_auxtrace_mmap__write_tail(struct au= xtrace_mmap *mm, u64 tail) =20 static int __auxtrace_mmap__read(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn, + const struct perf_tool *tool, process_auxtrace_t fn, bool snapshot, size_t snapshot_size) { struct auxtrace_mmap *mm =3D &map->auxtrace_mmap; @@ -1942,14 +1942,14 @@ static int __auxtrace_mmap__read(struct mmap *map, } =20 int auxtrace_mmap__read(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn) + const struct perf_tool *tool, process_auxtrace_t fn) { return __auxtrace_mmap__read(map, itr, tool, fn, false, 0); } =20 int auxtrace_mmap__read_snapshot(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn, + const struct perf_tool *tool, process_auxtrace_t fn, size_t snapshot_size) { return __auxtrace_mmap__read(map, itr, tool, fn, true, snapshot_size); @@ -2829,7 +2829,7 @@ int auxtrace_parse_filters(struct evlist *evlist) } =20 int auxtrace__process_event(struct perf_session *session, union perf_event= *event, - struct perf_sample *sample, struct perf_tool *tool) + struct perf_sample *sample, const struct perf_tool *tool) { if (!session->auxtrace) return 0; @@ -2847,7 +2847,7 @@ void auxtrace__dump_auxtrace_sample(struct perf_sessi= on *session, session->auxtrace->dump_auxtrace_sample(session, sample); } =20 -int auxtrace__flush_events(struct perf_session *session, struct perf_tool = *tool) +int auxtrace__flush_events(struct perf_session *session, const struct perf= _tool *tool) { if (!session->auxtrace) return 0; diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 8a6ec9565835..d405efcd8708 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -208,17 +208,17 @@ struct auxtrace { int (*process_event)(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool); + const struct perf_tool *tool); int (*process_auxtrace_event)(struct perf_session *session, union perf_event *event, - struct perf_tool *tool); + const struct perf_tool *tool); int (*queue_data)(struct perf_session *session, struct perf_sample *sample, union perf_event *event, u64 data_offset); void (*dump_auxtrace_sample)(struct perf_session *session, struct perf_sample *sample); int (*flush_events)(struct perf_session *session, - struct perf_tool *tool); + const struct perf_tool *tool); void (*free_events)(struct perf_session *session); void (*free)(struct perf_session *session); bool (*evsel_is_auxtrace)(struct perf_session *session, @@ -508,17 +508,17 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mm= ap_params *mp, struct evlist *evlist, struct evsel *evsel, int idx); =20 -typedef int (*process_auxtrace_t)(struct perf_tool *tool, +typedef int (*process_auxtrace_t)(const struct perf_tool *tool, struct mmap *map, union perf_event *event, void *data1, size_t len1, void *data2, size_t len2); =20 int auxtrace_mmap__read(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn); + const struct perf_tool *tool, process_auxtrace_t fn); =20 int auxtrace_mmap__read_snapshot(struct mmap *map, struct auxtrace_record *itr, - struct perf_tool *tool, process_auxtrace_t fn, + const struct perf_tool *tool, process_auxtrace_t fn, size_t snapshot_size); =20 int auxtrace_queues__init_nr(struct auxtrace_queues *queues, int nr_queues= ); @@ -639,10 +639,10 @@ int addr_filters__parse_bare_filter(struct addr_filte= rs *filts, int auxtrace_parse_filters(struct evlist *evlist); =20 int auxtrace__process_event(struct perf_session *session, union perf_event= *event, - struct perf_sample *sample, struct perf_tool *tool); + struct perf_sample *sample, const struct perf_tool *tool); void auxtrace__dump_auxtrace_sample(struct perf_session *session, struct perf_sample *sample); -int auxtrace__flush_events(struct perf_session *session, struct perf_tool = *tool); +int auxtrace__flush_events(struct perf_session *session, const struct perf= _tool *tool); void auxtrace__free_events(struct perf_session *session); void auxtrace__free(struct perf_session *session); bool auxtrace__evsel_is_auxtrace(struct perf_session *session, @@ -809,7 +809,7 @@ static inline int auxtrace__process_event(struct perf_session *session __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } @@ -822,7 +822,7 @@ void auxtrace__dump_auxtrace_sample(struct perf_session= *session __maybe_unused, =20 static inline int auxtrace__flush_events(struct perf_session *session __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c index 827695cd0408..13608237c50e 100644 --- a/tools/perf/util/bpf-event.c +++ b/tools/perf/util/bpf-event.c @@ -170,7 +170,7 @@ static int perf_event__synthesize_one_bpf_prog(struct p= erf_session *session, { struct perf_record_ksymbol *ksymbol_event =3D &event->ksymbol; struct perf_record_bpf_event *bpf_event =3D &event->bpf; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct bpf_prog_info_node *info_node; struct perf_bpil *info_linear; struct bpf_prog_info *info; @@ -310,7 +310,7 @@ struct kallsyms_parse { union perf_event *event; perf_event__handler_t process; struct machine *machine; - struct perf_tool *tool; + const struct perf_tool *tool; }; =20 static int diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 83a1581e8cf1..098fcc625d91 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -42,7 +42,7 @@ =20 static bool no_buildid_cache; =20 -int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused, +int build_id__mark_dso_hit(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct evsel *evsel __maybe_unused, @@ -67,7 +67,7 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe= _unused, return 0; } =20 -static int perf_event__exit_del_thread(struct perf_tool *tool __maybe_unus= ed, +static int perf_event__exit_del_thread(const struct perf_tool *tool __mayb= e_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index 3fa8bffb07ca..ae87c4c58d5b 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -35,11 +35,11 @@ char *dso__build_id_filename(const struct dso *dso, cha= r *bf, size_t size, char *__dso__build_id_filename(const struct dso *dso, char *bf, size_t siz= e, bool is_debug, bool is_kallsyms); =20 -int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, +int build_id__mark_dso_hit(const struct perf_tool *tool, union perf_event = *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine); =20 -int perf_event__inject_buildid(struct perf_tool *tool, union perf_event *e= vent, +int perf_event__inject_buildid(const struct perf_tool *tool, union perf_ev= ent *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine); =20 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 7fd976ea954b..21023d2a58ee 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -788,7 +788,7 @@ static void cs_etm__dump_event(struct cs_etm_queue *etm= q, } =20 static int cs_etm__flush_events(struct perf_session *session, - struct perf_tool *tool) + const struct perf_tool *tool) { struct cs_etm_auxtrace *etm =3D container_of(session->auxtrace, struct cs_etm_auxtrace, @@ -2711,7 +2711,7 @@ static int cs_etm__process_switch_cpu_wide(struct cs_= etm_auxtrace *etm, static int cs_etm__process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { struct cs_etm_auxtrace *etm =3D container_of(session->auxtrace, struct cs_etm_auxtrace, @@ -2781,7 +2781,7 @@ static void dump_queued_data(struct cs_etm_auxtrace *= etm, =20 static int cs_etm__process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct cs_etm_auxtrace *etm =3D container_of(session->auxtrace, struct cs_etm_auxtrace, diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-conve= rt-bt.c index 2b732bccabad..9e2170604b66 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -792,7 +792,7 @@ static bool is_flush_needed(struct ctf_stream *cs) return cs->count >=3D STREAM_FLUSH_COUNT; } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *_event, struct perf_sample *sample, struct evsel *evsel, @@ -871,7 +871,7 @@ do { \ } while(0) =20 #define __FUNC_PROCESS_NON_SAMPLE(_name, body) \ -static int process_##_name##_event(struct perf_tool *tool, \ +static int process_##_name##_event(const struct perf_tool *tool, \ union perf_event *_event, \ struct perf_sample *sample, \ struct machine *machine) \ diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-con= vert-json.c index 3cf64f5b23ee..905ea9823f9d 100644 --- a/tools/perf/util/data-convert-json.c +++ b/tools/perf/util/data-convert-json.c @@ -118,7 +118,7 @@ static void output_json_key_format(FILE *out, bool comm= a, int depth, va_end(args); } =20 -static void output_sample_callchain_entry(struct perf_tool *tool, +static void output_sample_callchain_entry(const struct perf_tool *tool, u64 ip, struct addr_location *al) { struct convert_json *c =3D container_of(tool, struct convert_json, tool); @@ -146,7 +146,7 @@ static void output_sample_callchain_entry(struct perf_t= ool *tool, output_json_format(out, false, 4, "}"); } =20 -static int process_sample_event(struct perf_tool *tool, +static int process_sample_event(const struct perf_tool *tool, union perf_event *event __maybe_unused, struct perf_sample *sample, struct evsel *evsel __maybe_unused, diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index f32f9abf6344..c2f0e7f40ad5 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -216,7 +216,7 @@ size_t perf_event__fprintf_cgroup(union perf_event *eve= nt, FILE *fp) event->cgroup.id, event->cgroup.path); } =20 -int perf_event__process_comm(struct perf_tool *tool __maybe_unused, +int perf_event__process_comm(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -224,7 +224,7 @@ int perf_event__process_comm(struct perf_tool *tool __m= aybe_unused, return machine__process_comm_event(machine, event, sample); } =20 -int perf_event__process_namespaces(struct perf_tool *tool __maybe_unused, +int perf_event__process_namespaces(const struct perf_tool *tool __maybe_un= used, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -232,7 +232,7 @@ int perf_event__process_namespaces(struct perf_tool *to= ol __maybe_unused, return machine__process_namespaces_event(machine, event, sample); } =20 -int perf_event__process_cgroup(struct perf_tool *tool __maybe_unused, +int perf_event__process_cgroup(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -240,7 +240,7 @@ int perf_event__process_cgroup(struct perf_tool *tool _= _maybe_unused, return machine__process_cgroup_event(machine, event, sample); } =20 -int perf_event__process_lost(struct perf_tool *tool __maybe_unused, +int perf_event__process_lost(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -248,7 +248,7 @@ int perf_event__process_lost(struct perf_tool *tool __m= aybe_unused, return machine__process_lost_event(machine, event, sample); } =20 -int perf_event__process_aux(struct perf_tool *tool __maybe_unused, +int perf_event__process_aux(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -256,7 +256,7 @@ int perf_event__process_aux(struct perf_tool *tool __ma= ybe_unused, return machine__process_aux_event(machine, event); } =20 -int perf_event__process_itrace_start(struct perf_tool *tool __maybe_unused, +int perf_event__process_itrace_start(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -264,7 +264,7 @@ int perf_event__process_itrace_start(struct perf_tool *= tool __maybe_unused, return machine__process_itrace_start_event(machine, event); } =20 -int perf_event__process_aux_output_hw_id(struct perf_tool *tool __maybe_un= used, +int perf_event__process_aux_output_hw_id(const struct perf_tool *tool __ma= ybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -272,7 +272,7 @@ int perf_event__process_aux_output_hw_id(struct perf_to= ol *tool __maybe_unused, return machine__process_aux_output_hw_id_event(machine, event); } =20 -int perf_event__process_lost_samples(struct perf_tool *tool __maybe_unused, +int perf_event__process_lost_samples(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -280,7 +280,7 @@ int perf_event__process_lost_samples(struct perf_tool *= tool __maybe_unused, return machine__process_lost_samples_event(machine, event, sample); } =20 -int perf_event__process_switch(struct perf_tool *tool __maybe_unused, +int perf_event__process_switch(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -288,7 +288,7 @@ int perf_event__process_switch(struct perf_tool *tool _= _maybe_unused, return machine__process_switch_event(machine, event); } =20 -int perf_event__process_ksymbol(struct perf_tool *tool __maybe_unused, +int perf_event__process_ksymbol(const struct perf_tool *tool __maybe_unuse= d, union perf_event *event, struct perf_sample *sample __maybe_unused, struct machine *machine) @@ -296,7 +296,7 @@ int perf_event__process_ksymbol(struct perf_tool *tool = __maybe_unused, return machine__process_ksymbol(machine, event, sample); } =20 -int perf_event__process_bpf(struct perf_tool *tool __maybe_unused, +int perf_event__process_bpf(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -304,7 +304,7 @@ int perf_event__process_bpf(struct perf_tool *tool __ma= ybe_unused, return machine__process_bpf(machine, event, sample); } =20 -int perf_event__process_text_poke(struct perf_tool *tool __maybe_unused, +int perf_event__process_text_poke(const struct perf_tool *tool __maybe_unu= sed, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -387,7 +387,7 @@ size_t perf_event__fprintf_cpu_map(union perf_event *ev= ent, FILE *fp) return ret; } =20 -int perf_event__process_mmap(struct perf_tool *tool __maybe_unused, +int perf_event__process_mmap(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -395,7 +395,7 @@ int perf_event__process_mmap(struct perf_tool *tool __m= aybe_unused, return machine__process_mmap_event(machine, event, sample); } =20 -int perf_event__process_mmap2(struct perf_tool *tool __maybe_unused, +int perf_event__process_mmap2(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -410,7 +410,7 @@ size_t perf_event__fprintf_task(union perf_event *event= , FILE *fp) event->fork.ppid, event->fork.ptid); } =20 -int perf_event__process_fork(struct perf_tool *tool __maybe_unused, +int perf_event__process_fork(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -418,7 +418,7 @@ int perf_event__process_fork(struct perf_tool *tool __m= aybe_unused, return machine__process_fork_event(machine, event, sample); } =20 -int perf_event__process_exit(struct perf_tool *tool __maybe_unused, +int perf_event__process_exit(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) @@ -587,7 +587,7 @@ size_t perf_event__fprintf(union perf_event *event, str= uct machine *machine, FIL return ret; } =20 -int perf_event__process(struct perf_tool *tool __maybe_unused, +int perf_event__process(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine) diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index d8bcee2e9b93..4b24f1c580fd 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -267,71 +267,71 @@ struct perf_tool; void perf_event__read_stat_config(struct perf_stat_config *config, struct perf_record_stat_config *event); =20 -int perf_event__process_comm(struct perf_tool *tool, +int perf_event__process_comm(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_lost(struct perf_tool *tool, +int perf_event__process_lost(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_lost_samples(struct perf_tool *tool, +int perf_event__process_lost_samples(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_aux(struct perf_tool *tool, +int perf_event__process_aux(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_itrace_start(struct perf_tool *tool, +int perf_event__process_itrace_start(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_aux_output_hw_id(struct perf_tool *tool, +int perf_event__process_aux_output_hw_id(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_switch(struct perf_tool *tool, +int perf_event__process_switch(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_namespaces(struct perf_tool *tool, +int perf_event__process_namespaces(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_cgroup(struct perf_tool *tool, +int perf_event__process_cgroup(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_mmap(struct perf_tool *tool, +int perf_event__process_mmap(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_mmap2(struct perf_tool *tool, +int perf_event__process_mmap2(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_fork(struct perf_tool *tool, +int perf_event__process_fork(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_exit(struct perf_tool *tool, +int perf_event__process_exit(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_ksymbol(struct perf_tool *tool, +int perf_event__process_ksymbol(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_bpf(struct perf_tool *tool, +int perf_event__process_bpf(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process_text_poke(struct perf_tool *tool, +int perf_event__process_text_poke(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); -int perf_event__process(struct perf_tool *tool, +int perf_event__process(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine); diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 55e9553861d0..3309fe7f1d12 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -4326,7 +4326,7 @@ int perf_session__read_header(struct perf_session *se= ssion, int repipe_fd) int perf_event__process_feature(struct perf_session *session, union perf_event *event) { - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct feat_fd ff =3D { .fd =3D 0 }; struct perf_record_header_feature *fe =3D (struct perf_record_header_feat= ure *)event; int type =3D fe->header.type; @@ -4405,7 +4405,7 @@ size_t perf_event__fprintf_event_update(union perf_ev= ent *event, FILE *fp) return ret; } =20 -int perf_event__process_attr(struct perf_tool *tool __maybe_unused, +int perf_event__process_attr(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct evlist **pevlist) { @@ -4444,7 +4444,7 @@ int perf_event__process_attr(struct perf_tool *tool _= _maybe_unused, return 0; } =20 -int perf_event__process_event_update(struct perf_tool *tool __maybe_unused, +int perf_event__process_event_update(const struct perf_tool *tool __maybe_= unused, union perf_event *event, struct evlist **pevlist) { diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index 7c16a250e738..07ff647197ff 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h @@ -156,9 +156,9 @@ int perf_header__fprintf_info(struct perf_session *s, F= ILE *fp, bool full); =20 int perf_event__process_feature(struct perf_session *session, union perf_event *event); -int perf_event__process_attr(struct perf_tool *tool, union perf_event *eve= nt, +int perf_event__process_attr(const struct perf_tool *tool, union perf_even= t *event, struct evlist **pevlist); -int perf_event__process_event_update(struct perf_tool *tool, +int perf_event__process_event_update(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist); size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp); diff --git a/tools/perf/util/hisi-ptt.c b/tools/perf/util/hisi-ptt.c index 37ea987017f6..e4cc4785f744 100644 --- a/tools/perf/util/hisi-ptt.c +++ b/tools/perf/util/hisi-ptt.c @@ -79,14 +79,14 @@ static void hisi_ptt_dump_event(struct hisi_ptt *ptt, u= nsigned char *buf, static int hisi_ptt_process_event(struct perf_session *session __maybe_unu= sed, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } =20 static int hisi_ptt_process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct hisi_ptt *ptt =3D container_of(session->auxtrace, struct hisi_ptt, auxtrace); @@ -123,7 +123,7 @@ static int hisi_ptt_process_auxtrace_event(struct perf_= session *session, } =20 static int hisi_ptt_flush(struct perf_session *session __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index 160d346cb450..27d9b5c9fec8 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -591,7 +591,7 @@ static int intel_bts_process_queues(struct intel_bts *b= ts, u64 timestamp) static int intel_bts_process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { struct intel_bts *bts =3D container_of(session->auxtrace, struct intel_bt= s, auxtrace); @@ -634,7 +634,7 @@ static int intel_bts_process_event(struct perf_session = *session, =20 static int intel_bts_process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct intel_bts *bts =3D container_of(session->auxtrace, struct intel_bt= s, auxtrace); @@ -675,7 +675,7 @@ static int intel_bts_process_auxtrace_event(struct perf= _session *session, } =20 static int intel_bts_flush(struct perf_session *session, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct intel_bts *bts =3D container_of(session->auxtrace, struct intel_bt= s, auxtrace); diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index 1fc03bfd14c3..fd2597613f3d 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -3449,7 +3449,7 @@ static int intel_pt_text_poke(struct intel_pt *pt, un= ion perf_event *event) static int intel_pt_process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { struct intel_pt *pt =3D container_of(session->auxtrace, struct intel_pt, auxtrace); @@ -3533,7 +3533,7 @@ static int intel_pt_process_event(struct perf_session= *session, return err; } =20 -static int intel_pt_flush(struct perf_session *session, struct perf_tool *= tool) +static int intel_pt_flush(struct perf_session *session, const struct perf_= tool *tool) { struct intel_pt *pt =3D container_of(session->auxtrace, struct intel_pt, auxtrace); @@ -3600,7 +3600,7 @@ static bool intel_pt_evsel_is_auxtrace(struct perf_se= ssion *session, =20 static int intel_pt_process_auxtrace_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct intel_pt *pt =3D container_of(session->auxtrace, struct intel_pt, auxtrace); diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index 1f657ef8975f..5ce13653512b 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c @@ -424,7 +424,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd= , union jr_entry *jr) { struct perf_sample sample; union perf_event *event; - struct perf_tool *tool =3D jd->session->tool; + const struct perf_tool *tool =3D jd->session->tool; uint64_t code, addr; uintptr_t uaddr; char *filename; @@ -543,7 +543,7 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd= , union jr_entry *jr) { struct perf_sample sample; union perf_event *event; - struct perf_tool *tool =3D jd->session->tool; + const struct perf_tool *tool =3D jd->session->tool; char *filename; size_t size; struct stat st; diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index 4ec583e511af..73846b73d0cf 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -912,7 +912,7 @@ static int s390_cpumsf_process_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool) + const struct perf_tool *tool) { struct s390_cpumsf *sf =3D container_of(session->auxtrace, struct s390_cpumsf, @@ -955,7 +955,7 @@ s390_cpumsf_process_event(struct perf_session *session, static int s390_cpumsf_process_auxtrace_event(struct perf_session *session, union perf_event *event __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { struct s390_cpumsf *sf =3D container_of(session->auxtrace, struct s390_cpumsf, @@ -998,7 +998,7 @@ static void s390_cpumsf_free_events(struct perf_session= *session __maybe_unused) } =20 static int s390_cpumsf_flush(struct perf_session *session __maybe_unused, - struct perf_tool *tool __maybe_unused) + const struct perf_tool *tool __maybe_unused) { return 0; } diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 18a8f4a84045..7e9827e61d1b 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -102,7 +102,7 @@ static int perf_session__process_compressed_event(struc= t perf_session *session, =20 static int perf_session__deliver_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool, + const struct perf_tool *tool, u64 file_offset, const char *file_path); =20 @@ -328,7 +328,7 @@ static int process_event_synth_tracing_data_stub(struct= perf_session *session return 0; } =20 -static int process_event_synth_attr_stub(struct perf_tool *tool __maybe_un= used, +static int process_event_synth_attr_stub(const struct perf_tool *tool __ma= ybe_unused, union perf_event *event __maybe_unused, struct evlist **pevlist __maybe_unused) @@ -337,7 +337,7 @@ static int process_event_synth_attr_stub(struct perf_to= ol *tool __maybe_unused, return 0; } =20 -static int process_event_synth_event_update_stub(struct perf_tool *tool __= maybe_unused, +static int process_event_synth_event_update_stub(const struct perf_tool *t= ool __maybe_unused, union perf_event *event __maybe_unused, struct evlist **pevlist __maybe_unused) @@ -349,7 +349,7 @@ static int process_event_synth_event_update_stub(struct= perf_tool *tool __maybe_ return 0; } =20 -static int process_event_sample_stub(struct perf_tool *tool __maybe_unused, +static int process_event_sample_stub(const struct perf_tool *tool __maybe_= unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct evsel *evsel __maybe_unused, @@ -359,7 +359,7 @@ static int process_event_sample_stub(struct perf_tool *= tool __maybe_unused, return 0; } =20 -static int process_event_stub(struct perf_tool *tool __maybe_unused, +static int process_event_stub(const struct perf_tool *tool __maybe_unused, union perf_event *event __maybe_unused, struct perf_sample *sample __maybe_unused, struct machine *machine __maybe_unused) @@ -368,7 +368,7 @@ static int process_event_stub(struct perf_tool *tool __= maybe_unused, return 0; } =20 -static int process_finished_round_stub(struct perf_tool *tool __maybe_unus= ed, +static int process_finished_round_stub(const struct perf_tool *tool __mayb= e_unused, union perf_event *event __maybe_unused, struct ordered_events *oe __maybe_unused) { @@ -1076,7 +1076,7 @@ static perf_event__swap_op perf_event__swap_ops[] =3D= { * Flush every events below timestamp 7 * etc... */ -int perf_event__process_finished_round(struct perf_tool *tool __maybe_unus= ed, +int perf_event__process_finished_round(const struct perf_tool *tool __mayb= e_unused, union perf_event *event __maybe_unused, struct ordered_events *oe) { @@ -1470,7 +1470,7 @@ static struct machine *machines__find_for_cpumode(str= uct machines *machines, } =20 static int deliver_sample_value(struct evlist *evlist, - struct perf_tool *tool, + const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct sample_read_value *v, @@ -1502,7 +1502,7 @@ static int deliver_sample_value(struct evlist *evlist, } =20 static int deliver_sample_group(struct evlist *evlist, - struct perf_tool *tool, + const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine, @@ -1521,7 +1521,7 @@ static int deliver_sample_group(struct evlist *evlist, return ret; } =20 -static int evlist__deliver_sample(struct evlist *evlist, struct perf_tool = *tool, +static int evlist__deliver_sample(struct evlist *evlist, const struct perf= _tool *tool, union perf_event *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine) { @@ -1546,7 +1546,7 @@ static int machines__deliver_event(struct machines *m= achines, struct evlist *evlist, union perf_event *event, struct perf_sample *sample, - struct perf_tool *tool, u64 file_offset, + const struct perf_tool *tool, u64 file_offset, const char *file_path) { struct evsel *evsel; @@ -1634,7 +1634,7 @@ static int machines__deliver_event(struct machines *m= achines, =20 static int perf_session__deliver_event(struct perf_session *session, union perf_event *event, - struct perf_tool *tool, + const struct perf_tool *tool, u64 file_offset, const char *file_path) { @@ -1667,7 +1667,7 @@ static s64 perf_session__process_user_event(struct pe= rf_session *session, const char *file_path) { struct ordered_events *oe =3D &session->ordered_events; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct perf_sample sample =3D { .time =3D 0, }; int fd =3D perf_data__fd(session->data); int err; @@ -1754,7 +1754,7 @@ int perf_session__deliver_synth_event(struct perf_ses= sion *session, struct perf_sample *sample) { struct evlist *evlist =3D session->evlist; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; =20 events_stats__inc(&evlist->stats, event->header.type); =20 @@ -1886,7 +1886,7 @@ static s64 perf_session__process_event(struct perf_se= ssion *session, const char *file_path) { struct evlist *evlist =3D session->evlist; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; int ret; =20 if (session->header.needs_swap) diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index cc28976bb00e..6886cc85600f 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -163,7 +163,7 @@ int perf_session__dsos_hit_all(struct perf_session *ses= sion); int perf_event__process_id_index(struct perf_session *session, union perf_event *event); =20 -int perf_event__process_finished_round(struct perf_tool *tool, +int perf_event__process_finished_round(const struct perf_tool *tool, union perf_event *event, struct ordered_events *oe); =20 diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic= -events.c index 5498048f56ea..7f884d70de81 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0-only=20 +// SPDX-License-Identifier: GPL-2.0-only =20 #include "util/cgroup.h" #include "util/data.h" @@ -47,7 +47,7 @@ =20 unsigned int proc_map_timeout =3D DEFAULT_PROC_MAP_PARSE_TIMEOUT; =20 -int perf_tool__process_synth_event(struct perf_tool *tool, +int perf_tool__process_synth_event(const struct perf_tool *tool, union perf_event *event, struct machine *machine, perf_event__handler_t process) @@ -187,7 +187,7 @@ static int perf_event__prepare_comm(union perf_event *e= vent, pid_t pid, pid_t ti return 0; } =20 -pid_t perf_event__synthesize_comm(struct perf_tool *tool, +pid_t perf_event__synthesize_comm(const struct perf_tool *tool, union perf_event *event, pid_t pid, perf_event__handler_t process, struct machine *machine) @@ -218,7 +218,7 @@ static void perf_event__get_ns_link_info(pid_t pid, con= st char *ns, } } =20 -int perf_event__synthesize_namespaces(struct perf_tool *tool, +int perf_event__synthesize_namespaces(const struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, @@ -257,7 +257,7 @@ int perf_event__synthesize_namespaces(struct perf_tool = *tool, return 0; } =20 -static int perf_event__synthesize_fork(struct perf_tool *tool, +static int perf_event__synthesize_fork(const struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, pid_t ppid, perf_event__handler_t process, @@ -418,7 +418,7 @@ static void perf_record_mmap2__read_build_id(struct per= f_record_mmap2 *event, dso__put(dso); } =20 -int perf_event__synthesize_mmap_events(struct perf_tool *tool, +int perf_event__synthesize_mmap_events(const struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, @@ -542,7 +542,7 @@ int perf_event__synthesize_mmap_events(struct perf_tool= *tool, } =20 #ifdef HAVE_FILE_HANDLE -static int perf_event__synthesize_cgroup(struct perf_tool *tool, +static int perf_event__synthesize_cgroup(const struct perf_tool *tool, union perf_event *event, char *path, size_t mount_len, perf_event__handler_t process, @@ -582,7 +582,7 @@ static int perf_event__synthesize_cgroup(struct perf_to= ol *tool, return 0; } =20 -static int perf_event__walk_cgroup_tree(struct perf_tool *tool, +static int perf_event__walk_cgroup_tree(const struct perf_tool *tool, union perf_event *event, char *path, size_t mount_len, perf_event__handler_t process, @@ -630,7 +630,7 @@ static int perf_event__walk_cgroup_tree(struct perf_too= l *tool, return ret; } =20 -int perf_event__synthesize_cgroups(struct perf_tool *tool, +int perf_event__synthesize_cgroups(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine) { @@ -657,7 +657,7 @@ int perf_event__synthesize_cgroups(struct perf_tool *to= ol, return 0; } #else -int perf_event__synthesize_cgroups(struct perf_tool *tool __maybe_unused, +int perf_event__synthesize_cgroups(const struct perf_tool *tool __maybe_un= used, perf_event__handler_t process __maybe_unused, struct machine *machine __maybe_unused) { @@ -666,7 +666,7 @@ int perf_event__synthesize_cgroups(struct perf_tool *to= ol __maybe_unused, #endif =20 struct perf_event__synthesize_modules_maps_cb_args { - struct perf_tool *tool; + const struct perf_tool *tool; perf_event__handler_t process; struct machine *machine; union perf_event *event; @@ -717,7 +717,7 @@ static int perf_event__synthesize_modules_maps_cb(struc= t map *map, void *data) return 0; } =20 -int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__han= dler_t process, +int perf_event__synthesize_modules(const struct perf_tool *tool, perf_even= t__handler_t process, struct machine *machine) { int rc; @@ -763,7 +763,7 @@ static int __event__synthesize_thread(union perf_event = *comm_event, union perf_event *fork_event, union perf_event *namespaces_event, pid_t pid, int full, perf_event__handler_t process, - struct perf_tool *tool, struct machine *machine, + const struct perf_tool *tool, struct machine *machine, bool needs_mmap, bool mmap_data) { char filename[PATH_MAX]; @@ -852,7 +852,7 @@ static int __event__synthesize_thread(union perf_event = *comm_event, return rc; } =20 -int perf_event__synthesize_thread_map(struct perf_tool *tool, +int perf_event__synthesize_thread_map(const struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine, @@ -929,7 +929,7 @@ int perf_event__synthesize_thread_map(struct perf_tool = *tool, return err; } =20 -static int __perf_event__synthesize_threads(struct perf_tool *tool, +static int __perf_event__synthesize_threads(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine, bool needs_mmap, @@ -993,7 +993,7 @@ static int __perf_event__synthesize_threads(struct perf= _tool *tool, } =20 struct synthesize_threads_arg { - struct perf_tool *tool; + const struct perf_tool *tool; perf_event__handler_t process; struct machine *machine; bool needs_mmap; @@ -1015,7 +1015,7 @@ static void *synthesize_threads_worker(void *arg) return NULL; } =20 -int perf_event__synthesize_threads(struct perf_tool *tool, +int perf_event__synthesize_threads(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine, bool needs_mmap, bool mmap_data, @@ -1104,14 +1104,14 @@ int perf_event__synthesize_threads(struct perf_tool= *tool, return err; } =20 -int __weak perf_event__synthesize_extra_kmaps(struct perf_tool *tool __may= be_unused, +int __weak perf_event__synthesize_extra_kmaps(const struct perf_tool *tool= __maybe_unused, perf_event__handler_t process __maybe_unused, struct machine *machine __maybe_unused) { return 0; } =20 -static int __perf_event__synthesize_kernel_mmap(struct perf_tool *tool, +static int __perf_event__synthesize_kernel_mmap(const struct perf_tool *to= ol, perf_event__handler_t process, struct machine *machine) { @@ -1183,7 +1183,7 @@ static int __perf_event__synthesize_kernel_mmap(struc= t perf_tool *tool, return err; } =20 -int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, +int perf_event__synthesize_kernel_mmap(const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine) { @@ -1196,7 +1196,7 @@ int perf_event__synthesize_kernel_mmap(struct perf_to= ol *tool, return perf_event__synthesize_extra_kmaps(tool, process, machine); } =20 -int perf_event__synthesize_thread_map2(struct perf_tool *tool, +int perf_event__synthesize_thread_map2(const struct perf_tool *tool, struct perf_thread_map *threads, perf_event__handler_t process, struct machine *machine) @@ -1346,7 +1346,7 @@ static struct perf_record_cpu_map *cpu_map_event__new= (const struct perf_cpu_map } =20 =20 -int perf_event__synthesize_cpu_map(struct perf_tool *tool, +int perf_event__synthesize_cpu_map(const struct perf_tool *tool, const struct perf_cpu_map *map, perf_event__handler_t process, struct machine *machine) @@ -1364,7 +1364,7 @@ int perf_event__synthesize_cpu_map(struct perf_tool *= tool, return err; } =20 -int perf_event__synthesize_stat_config(struct perf_tool *tool, +int perf_event__synthesize_stat_config(const struct perf_tool *tool, struct perf_stat_config *config, perf_event__handler_t process, struct machine *machine) @@ -1403,7 +1403,7 @@ int perf_event__synthesize_stat_config(struct perf_to= ol *tool, return err; } =20 -int perf_event__synthesize_stat(struct perf_tool *tool, +int perf_event__synthesize_stat(const struct perf_tool *tool, struct perf_cpu cpu, u32 thread, u64 id, struct perf_counts_values *count, perf_event__handler_t process, @@ -1425,7 +1425,7 @@ int perf_event__synthesize_stat(struct perf_tool *too= l, return process(tool, (union perf_event *) &event, NULL, machine); } =20 -int perf_event__synthesize_stat_round(struct perf_tool *tool, +int perf_event__synthesize_stat_round(const struct perf_tool *tool, u64 evtime, u64 type, perf_event__handler_t process, struct machine *machine) @@ -1826,7 +1826,7 @@ int perf_event__synthesize_id_sample(__u64 *array, u6= 4 type, const struct perf_s return (void *)array - (void *)start; } =20 -int __perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__= handler_t process, +int __perf_event__synthesize_id_index(const struct perf_tool *tool, perf_e= vent__handler_t process, struct evlist *evlist, struct machine *machine, size_t from) { union perf_event *ev; @@ -1918,13 +1918,13 @@ int __perf_event__synthesize_id_index(struct perf_t= ool *tool, perf_event__handle return err; } =20 -int perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__ha= ndler_t process, +int perf_event__synthesize_id_index(const struct perf_tool *tool, perf_eve= nt__handler_t process, struct evlist *evlist, struct machine *machine) { return __perf_event__synthesize_id_index(tool, process, evlist, machine, = 0); } =20 -int __machine__synthesize_threads(struct machine *machine, struct perf_too= l *tool, +int __machine__synthesize_threads(struct machine *machine, const struct pe= rf_tool *tool, struct target *target, struct perf_thread_map *threads, perf_event__handler_t process, bool needs_mmap, bool data_mmap, unsigned int nr_threads_synthesize) @@ -1985,7 +1985,7 @@ static struct perf_record_event_update *event_update_= event__new(size_t size, u64 return ev; } =20 -int perf_event__synthesize_event_update_unit(struct perf_tool *tool, struc= t evsel *evsel, +int perf_event__synthesize_event_update_unit(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process) { size_t size =3D strlen(evsel->unit); @@ -2002,7 +2002,7 @@ int perf_event__synthesize_event_update_unit(struct p= erf_tool *tool, struct evse return err; } =20 -int perf_event__synthesize_event_update_scale(struct perf_tool *tool, stru= ct evsel *evsel, +int perf_event__synthesize_event_update_scale(const struct perf_tool *tool= , struct evsel *evsel, perf_event__handler_t process) { struct perf_record_event_update *ev; @@ -2019,7 +2019,7 @@ int perf_event__synthesize_event_update_scale(struct = perf_tool *tool, struct evs return err; } =20 -int perf_event__synthesize_event_update_name(struct perf_tool *tool, struc= t evsel *evsel, +int perf_event__synthesize_event_update_name(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process) { struct perf_record_event_update *ev; @@ -2036,7 +2036,7 @@ int perf_event__synthesize_event_update_name(struct p= erf_tool *tool, struct evse return err; } =20 -int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, struc= t evsel *evsel, +int perf_event__synthesize_event_update_cpus(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process) { struct synthesize_cpu_map_data syn_data =3D { .map =3D evsel->core.own_cp= us }; @@ -2059,7 +2059,7 @@ int perf_event__synthesize_event_update_cpus(struct p= erf_tool *tool, struct evse return err; } =20 -int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *ev= list, +int perf_event__synthesize_attrs(const struct perf_tool *tool, struct evli= st *evlist, perf_event__handler_t process) { struct evsel *evsel; @@ -2087,7 +2087,7 @@ static bool has_scale(struct evsel *evsel) return evsel->scale !=3D 1; } =20 -int perf_event__synthesize_extra_attr(struct perf_tool *tool, struct evlis= t *evsel_list, +int perf_event__synthesize_extra_attr(const struct perf_tool *tool, struct= evlist *evsel_list, perf_event__handler_t process, bool is_pipe) { struct evsel *evsel; @@ -2143,7 +2143,7 @@ int perf_event__synthesize_extra_attr(struct perf_too= l *tool, struct evlist *evs return 0; } =20 -int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_= attr *attr, +int perf_event__synthesize_attr(const struct perf_tool *tool, struct perf_= event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process) { union perf_event *ev; @@ -2177,7 +2177,7 @@ int perf_event__synthesize_attr(struct perf_tool *too= l, struct perf_event_attr * } =20 #ifdef HAVE_LIBTRACEEVENT -int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, st= ruct evlist *evlist, +int perf_event__synthesize_tracing_data(const struct perf_tool *tool, int = fd, struct evlist *evlist, perf_event__handler_t process) { union perf_event ev; @@ -2225,7 +2225,7 @@ int perf_event__synthesize_tracing_data(struct perf_t= ool *tool, int fd, struct e } #endif =20 -int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *po= s, u16 misc, +int perf_event__synthesize_build_id(const struct perf_tool *tool, struct d= so *pos, u16 misc, perf_event__handler_t process, struct machine *machine) { union perf_event ev; @@ -2249,7 +2249,7 @@ int perf_event__synthesize_build_id(struct perf_tool = *tool, struct dso *pos, u16 return process(tool, &ev, NULL, machine); } =20 -int perf_event__synthesize_stat_events(struct perf_stat_config *config, st= ruct perf_tool *tool, +int perf_event__synthesize_stat_events(struct perf_stat_config *config, co= nst struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process, bool attr= s) { int err; @@ -2286,7 +2286,7 @@ int perf_event__synthesize_stat_events(struct perf_st= at_config *config, struct p =20 extern const struct perf_header_feature_ops feat_ops[HEADER_LAST_FEATURE]; =20 -int perf_event__synthesize_features(struct perf_tool *tool, struct perf_se= ssion *session, +int perf_event__synthesize_features(const struct perf_tool *tool, struct p= erf_session *session, struct evlist *evlist, perf_event__handler_t process) { struct perf_header *header =3D &session->header; @@ -2349,7 +2349,7 @@ int perf_event__synthesize_features(struct perf_tool = *tool, struct perf_session return ret; } =20 -int perf_event__synthesize_for_pipe(struct perf_tool *tool, +int perf_event__synthesize_for_pipe(const struct perf_tool *tool, struct perf_session *session, struct perf_data *data, perf_event__handler_t process) diff --git a/tools/perf/util/synthetic-events.h b/tools/perf/util/synthetic= -events.h index 53737d1619a4..31df7653677f 100644 --- a/tools/perf/util/synthetic-events.h +++ b/tools/perf/util/synthetic-events.h @@ -40,45 +40,45 @@ enum perf_record_synth { =20 int parse_synth_opt(char *str); =20 -typedef int (*perf_event__handler_t)(struct perf_tool *tool, union perf_ev= ent *event, +typedef int (*perf_event__handler_t)(const struct perf_tool *tool, union p= erf_event *event, struct perf_sample *sample, struct machine *machine); =20 -int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *ev= list, perf_event__handler_t process); -int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_= attr *attr, u32 ids, u64 *id, perf_event__handler_t process); -int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *po= s, u16 misc, perf_event__handler_t process, struct machine *machine); -int perf_event__synthesize_cpu_map(struct perf_tool *tool, const struct pe= rf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine); -int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, struc= t evsel *evsel, perf_event__handler_t process); -int perf_event__synthesize_event_update_name(struct perf_tool *tool, struc= t evsel *evsel, perf_event__handler_t process); -int perf_event__synthesize_event_update_scale(struct perf_tool *tool, stru= ct evsel *evsel, perf_event__handler_t process); -int perf_event__synthesize_event_update_unit(struct perf_tool *tool, struc= t evsel *evsel, perf_event__handler_t process); -int perf_event__synthesize_extra_attr(struct perf_tool *tool, struct evlis= t *evsel_list, perf_event__handler_t process, bool is_pipe); -int perf_event__synthesize_extra_kmaps(struct perf_tool *tool, perf_event_= _handler_t process, struct machine *machine); -int perf_event__synthesize_features(struct perf_tool *tool, struct perf_se= ssion *session, struct evlist *evlist, perf_event__handler_t process); -int perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__ha= ndler_t process, struct evlist *evlist, struct machine *machine); -int __perf_event__synthesize_id_index(struct perf_tool *tool, perf_event__= handler_t process, struct evlist *evlist, struct machine *machine, size_t f= rom); +int perf_event__synthesize_attrs(const struct perf_tool *tool, struct evli= st *evlist, perf_event__handler_t process); +int perf_event__synthesize_attr(const struct perf_tool *tool, struct perf_= event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process); +int perf_event__synthesize_build_id(const struct perf_tool *tool, struct d= so *pos, u16 misc, perf_event__handler_t process, struct machine *machine); +int perf_event__synthesize_cpu_map(const struct perf_tool *tool, const str= uct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *mach= ine); +int perf_event__synthesize_event_update_cpus(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process); +int perf_event__synthesize_event_update_name(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process); +int perf_event__synthesize_event_update_scale(const struct perf_tool *tool= , struct evsel *evsel, perf_event__handler_t process); +int perf_event__synthesize_event_update_unit(const struct perf_tool *tool,= struct evsel *evsel, perf_event__handler_t process); +int perf_event__synthesize_extra_attr(const struct perf_tool *tool, struct= evlist *evsel_list, perf_event__handler_t process, bool is_pipe); +int perf_event__synthesize_extra_kmaps(const struct perf_tool *tool, perf_= event__handler_t process, struct machine *machine); +int perf_event__synthesize_features(const struct perf_tool *tool, struct p= erf_session *session, struct evlist *evlist, perf_event__handler_t process); +int perf_event__synthesize_id_index(const struct perf_tool *tool, perf_eve= nt__handler_t process, struct evlist *evlist, struct machine *machine); +int __perf_event__synthesize_id_index(const struct perf_tool *tool, perf_e= vent__handler_t process, struct evlist *evlist, struct machine *machine, si= ze_t from); int perf_event__synthesize_id_sample(__u64 *array, u64 type, const struct = perf_sample *sample); -int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, perf_event_= _handler_t process, struct machine *machine); -int perf_event__synthesize_mmap_events(struct perf_tool *tool, union perf_= event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, struct = machine *machine, bool mmap_data); -int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__han= dler_t process, struct machine *machine); -int perf_event__synthesize_namespaces(struct perf_tool *tool, union perf_e= vent *event, pid_t pid, pid_t tgid, perf_event__handler_t process, struct m= achine *machine); -int perf_event__synthesize_cgroups(struct perf_tool *tool, perf_event__han= dler_t process, struct machine *machine); +int perf_event__synthesize_kernel_mmap(const struct perf_tool *tool, perf_= event__handler_t process, struct machine *machine); +int perf_event__synthesize_mmap_events(const struct perf_tool *tool, union= perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, s= truct machine *machine, bool mmap_data); +int perf_event__synthesize_modules(const struct perf_tool *tool, perf_even= t__handler_t process, struct machine *machine); +int perf_event__synthesize_namespaces(const struct perf_tool *tool, union = perf_event *event, pid_t pid, pid_t tgid, perf_event__handler_t process, st= ruct machine *machine); +int perf_event__synthesize_cgroups(const struct perf_tool *tool, perf_even= t__handler_t process, struct machine *machine); int perf_event__synthesize_sample(union perf_event *event, u64 type, u64 r= ead_format, const struct perf_sample *sample); -int perf_event__synthesize_stat_config(struct perf_tool *tool, struct perf= _stat_config *config, perf_event__handler_t process, struct machine *machin= e); -int perf_event__synthesize_stat_events(struct perf_stat_config *config, st= ruct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process,= bool attrs); -int perf_event__synthesize_stat_round(struct perf_tool *tool, u64 time, u6= 4 type, perf_event__handler_t process, struct machine *machine); -int perf_event__synthesize_stat(struct perf_tool *tool, struct perf_cpu cp= u, u32 thread, u64 id, struct perf_counts_values *count, perf_event__handle= r_t process, struct machine *machine); -int perf_event__synthesize_thread_map2(struct perf_tool *tool, struct perf= _thread_map *threads, perf_event__handler_t process, struct machine *machin= e); -int perf_event__synthesize_thread_map(struct perf_tool *tool, struct perf_= thread_map *threads, perf_event__handler_t process, struct machine *machine= , bool needs_mmap, bool mmap_data); -int perf_event__synthesize_threads(struct perf_tool *tool, perf_event__han= dler_t process, struct machine *machine, bool needs_mmap, bool mmap_data, u= nsigned int nr_threads_synthesize); -int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, st= ruct evlist *evlist, perf_event__handler_t process); -int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, str= uct perf_tool *tool, perf_event__handler_t process, struct machine *machine= ); -pid_t perf_event__synthesize_comm(struct perf_tool *tool, union perf_event= *event, pid_t pid, perf_event__handler_t process, struct machine *machine); - -int perf_tool__process_synth_event(struct perf_tool *tool, union perf_even= t *event, struct machine *machine, perf_event__handler_t process); +int perf_event__synthesize_stat_config(const struct perf_tool *tool, struc= t perf_stat_config *config, perf_event__handler_t process, struct machine *= machine); +int perf_event__synthesize_stat_events(struct perf_stat_config *config, co= nst struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t pr= ocess, bool attrs); +int perf_event__synthesize_stat_round(const struct perf_tool *tool, u64 ti= me, u64 type, perf_event__handler_t process, struct machine *machine); +int perf_event__synthesize_stat(const struct perf_tool *tool, struct perf_= cpu cpu, u32 thread, u64 id, struct perf_counts_values *count, perf_event__= handler_t process, struct machine *machine); +int perf_event__synthesize_thread_map2(const struct perf_tool *tool, struc= t perf_thread_map *threads, perf_event__handler_t process, struct machine *= machine); +int perf_event__synthesize_thread_map(const struct perf_tool *tool, struct= perf_thread_map *threads, perf_event__handler_t process, struct machine *m= achine, bool needs_mmap, bool mmap_data); +int perf_event__synthesize_threads(const struct perf_tool *tool, perf_even= t__handler_t process, struct machine *machine, bool needs_mmap, bool mmap_d= ata, unsigned int nr_threads_synthesize); +int perf_event__synthesize_tracing_data(const struct perf_tool *tool, int = fd, struct evlist *evlist, perf_event__handler_t process); +int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, con= st struct perf_tool *tool, perf_event__handler_t process, struct machine *m= achine); +pid_t perf_event__synthesize_comm(const struct perf_tool *tool, union perf= _event *event, pid_t pid, perf_event__handler_t process, struct machine *ma= chine); + +int perf_tool__process_synth_event(const struct perf_tool *tool, union per= f_event *event, struct machine *machine, perf_event__handler_t process); =20 size_t perf_event__sample_event_size(const struct perf_sample *sample, u64= type, u64 read_format); =20 -int __machine__synthesize_threads(struct machine *machine, struct perf_too= l *tool, +int __machine__synthesize_threads(struct machine *machine, const struct pe= rf_tool *tool, struct target *target, struct perf_thread_map *threads, perf_event__handler_t process, bool needs_mmap, bool data_mmap, unsigned int nr_threads_synthesize); @@ -87,7 +87,7 @@ int machine__synthesize_threads(struct machine *machine, = struct target *target, unsigned int nr_threads_synthesize); =20 #ifdef HAVE_AUXTRACE_SUPPORT -int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, stru= ct perf_tool *tool, +int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, cons= t struct perf_tool *tool, struct perf_session *session, perf_event__handler_t process); =20 #else // HAVE_AUXTRACE_SUPPORT @@ -96,7 +96,7 @@ int perf_event__synthesize_auxtrace_info(struct auxtrace_= record *itr, struct per =20 static inline int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr __maybe_u= nused, - struct perf_tool *tool __maybe_unused, + const struct perf_tool *tool __maybe_unused, struct perf_session *session __maybe_unused, perf_event__handler_t process __maybe_unused) { @@ -117,7 +117,7 @@ static inline int perf_event__synthesize_bpf_events(str= uct perf_session *session } #endif // HAVE_LIBBPF_SUPPORT =20 -int perf_event__synthesize_for_pipe(struct perf_tool *tool, +int perf_event__synthesize_for_pipe(const struct perf_tool *tool, struct perf_session *session, struct perf_data *data, perf_event__handler_t process); diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index c957fb849ac6..b192d44fe91f 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -15,14 +15,14 @@ struct perf_tool; struct machine; struct ordered_events; =20 -typedef int (*event_sample)(struct perf_tool *tool, union perf_event *even= t, +typedef int (*event_sample)(const struct perf_tool *tool, union perf_event= *event, struct perf_sample *sample, struct evsel *evsel, struct machine *machine); =20 -typedef int (*event_op)(struct perf_tool *tool, union perf_event *event, +typedef int (*event_op)(const struct perf_tool *tool, union perf_event *ev= ent, struct perf_sample *sample, struct machine *machine); =20 -typedef int (*event_attr_op)(struct perf_tool *tool, +typedef int (*event_attr_op)(const struct perf_tool *tool, union perf_event *event, struct evlist **pevlist); =20 @@ -31,7 +31,7 @@ typedef s64 (*event_op3)(struct perf_session *session, un= ion perf_event *event); typedef int (*event_op4)(struct perf_session *session, union perf_event *e= vent, u64 data, const char *str); =20 -typedef int (*event_oe)(struct perf_tool *tool, union perf_event *event, +typedef int (*event_oe)(const struct perf_tool *tool, union perf_event *ev= ent, struct ordered_events *oe); =20 enum show_feature_header { diff --git a/tools/perf/util/tsc.c b/tools/perf/util/tsc.c index f19791d46e99..2e33a20e1e1b 100644 --- a/tools/perf/util/tsc.c +++ b/tools/perf/util/tsc.c @@ -72,7 +72,7 @@ int perf_read_tsc_conversion(const struct perf_event_mmap= _page *pc, } =20 int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, - struct perf_tool *tool, + const struct perf_tool *tool, perf_event__handler_t process, struct machine *machine) { --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 B837416EBE0 for ; Thu, 11 Jul 2024 18:00:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720827; cv=none; b=K9K8d/7mDpdFFrGhugWEAfKHMfXxLjZx9Dvlux39YHiTTMR2Q/z5oia3JNppOVm7DIHU+6TjT0xe5Ap1uYbARr6KJ1yv8WtmeROqrzfQ8Y6hpjadWmfU2Y27zm0XVcKeyLN0oPrkHJldoRA2EjXaUmaouMBKWUKGk8G19GRFkBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720827; c=relaxed/simple; bh=PtBRXc0c+0allU3O64DiNYmraKLIDmcwEXLGEG6EUWQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=jEQuIMTnJT/U/yCQxWVW0pnIVUV4mX0IeFpiuGhHTzKftJxNpvtQ/+5TyUfAx6ZBUkABGFrw8RWkK1VQ/cb1U4b6rZ41jK7+94vGEJYvvpSFGwn7ffdh+eBHBhBVstIVRCVccOmLV8Mc7BqnIaMiPRdoppq+MqfbTW6gFB1s+Yw= 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=YIjD2bRQ; 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="YIjD2bRQ" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e02a4de4f4eso1992236276.1 for ; Thu, 11 Jul 2024 11:00:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720825; x=1721325625; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=7irtahaUgZZ2kadtdQTAIVJwXhey7Hso05gQMGn03JQ=; b=YIjD2bRQife26ofr3m5uxiuibNXv6NUgdxztknnwRjtfcMcOmMk/l2wLXA/NPdDszT xT0UehaNSZcEoE/7M0QEIWldlOOaRlSvP8r0engcxbh79IdAiPyJ5gdPSdsDSRE9jhaC m3cei+7qJUMLzebkToILXbCItf4cTW4F8vnBEqyP7vzGDDheZv0GTcLLtmVTE3CuARNo A3R6rd6OJ3ZFL/NtbpvCY2YzmMDfG1bE8Q+KZbh1PPostzydE3qJMwTCI9y1DEfaah8A zDa2ln8GuAKMoh3LkKosgtEsru5uvLm31EkYDIFNn9XmRX0gZ9337rg4NHga8NOG+LtA 0+KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720825; x=1721325625; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7irtahaUgZZ2kadtdQTAIVJwXhey7Hso05gQMGn03JQ=; b=EJUgaDWEbKRVvl705cKuzFxJm1uIgdFYD1Q6s1YYMl+TBkatFOsCJwJRjTaOZ3l9eH CEZx7VMyn4n24Is8YN2cCR2ojmdiJJRZZQTuGIhq4xK2dO4C6TvelcJjzvmsUk1Q6sCx 9WJqcQaq1m7Y9N2ZsE/BqtcZf5OJsJVmTWUg6+JnJnKjaJkzogpHPE/BiGs1zTYQgVCF pCxINmYnXxl19UhFJWgQEZuKOVaY4/uJJbDuLHsxd1tikY1mHIe+p/EsLiYCcgsZp5lP 4sd1zfSOZIM8rUXL8P7BMPeTQY4bRNKAw3S+ieh3t5BNte6cJCHBp2zxchFZkiiqe8uV 64uA== X-Forwarded-Encrypted: i=1; AJvYcCVxEzlJfS1RKb8vMDTzQY1GxeBLwbv/DXbCvcb393UeuYAl8hVUkKNFzI9oBb3EqgLQ3Dig1kpKYMHAIUWq2P1xqYsIsWfVCDwN3hG8 X-Gm-Message-State: AOJu0Yy7CR7500cNTEIU3xaGF7BfNP+hXNWO5wCUMOM7pl32qJxCBrS9 jNCTSznxaxhwT4zqK9H11e/AWxL7h0z5Z77jyVO+PzGl7GajsR08PDkgfuNGentWUEu4K3OSS8d 3yrSCKQ== X-Google-Smtp-Source: AGHT+IGMj2daCCdfqUIMVyxFiaBOl2uNvUMGL0sEZfXJ00x70OsfOTwTplPhBU9/aZ/vlnQv3brgWNx7JDSm X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:248e:b0:e03:3cfa:1aa7 with SMTP id 3f1490d57ef6-e041b03709dmr19480276.1.1720720824552; Thu, 11 Jul 2024 11:00:24 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:45 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 05/28] perf tool: Move fill defaults into tool.c From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The aim here is to eventually make perf_tool__fill_defaults an init function so that the tools struct is more const. Create a tool.c to go along with tool.h. Move perf_tool__fill_defaults out of session.c into tool.c along with the default stub values. Add perf_tool__compressed_is_stub for a test in perf_session__process_user_event. perf_session__process_compressed_event is only used from being default initialized so migrate into tool.c. Signed-off-by: Ian Rogers --- tools/perf/util/Build | 1 + tools/perf/util/session.c | 310 +----------------------------------- tools/perf/util/session.h | 2 - tools/perf/util/tool.c | 325 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/tool.h | 4 + 5 files changed, 331 insertions(+), 311 deletions(-) create mode 100644 tools/perf/util/tool.c diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 0f18fe81ef0b..f3633342374a 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -65,6 +65,7 @@ perf-util-y +=3D map.o perf-util-y +=3D maps.o perf-util-y +=3D pstack.o perf-util-y +=3D session.o +perf-util-y +=3D tool.o perf-util-y +=3D sample-raw.o perf-util-y +=3D s390-sample-raw.o perf-util-y +=3D amd-sample-raw.o diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 7e9827e61d1b..5359ee055c85 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -38,68 +38,6 @@ #include "units.h" #include =20 -#ifdef HAVE_ZSTD_SUPPORT -static int perf_session__process_compressed_event(struct perf_session *ses= sion, - union perf_event *event, u64 file_offset, - const char *file_path) -{ - void *src; - size_t decomp_size, src_size; - u64 decomp_last_rem =3D 0; - size_t mmap_len, decomp_len =3D session->header.env.comp_mmap_len; - struct decomp *decomp, *decomp_last =3D session->active_decomp->decomp_la= st; - - if (decomp_last) { - decomp_last_rem =3D decomp_last->size - decomp_last->head; - decomp_len +=3D decomp_last_rem; - } - - mmap_len =3D sizeof(struct decomp) + decomp_len; - decomp =3D mmap(NULL, mmap_len, PROT_READ|PROT_WRITE, - MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); - if (decomp =3D=3D MAP_FAILED) { - pr_err("Couldn't allocate memory for decompression\n"); - return -1; - } - - decomp->file_pos =3D file_offset; - decomp->file_path =3D file_path; - decomp->mmap_len =3D mmap_len; - decomp->head =3D 0; - - if (decomp_last_rem) { - memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_las= t_rem); - decomp->size =3D decomp_last_rem; - } - - src =3D (void *)event + sizeof(struct perf_record_compressed); - src_size =3D event->pack.header.size - sizeof(struct perf_record_compress= ed); - - decomp_size =3D zstd_decompress_stream(session->active_decomp->zstd_decom= p, src, src_size, - &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem); - if (!decomp_size) { - munmap(decomp, mmap_len); - pr_err("Couldn't decompress data\n"); - return -1; - } - - decomp->size +=3D decomp_size; - - if (session->active_decomp->decomp =3D=3D NULL) - session->active_decomp->decomp =3D decomp; - else - session->active_decomp->decomp_last->next =3D decomp; - - session->active_decomp->decomp_last =3D decomp; - - pr_debug("decomp (B): %zd to %zd\n", src_size, decomp_size); - - return 0; -} -#else /* !HAVE_ZSTD_SUPPORT */ -#define perf_session__process_compressed_event perf_session__process_compr= essed_event_stub -#endif - static int perf_session__deliver_event(struct perf_session *session, union perf_event *event, const struct perf_tool *tool, @@ -319,251 +257,6 @@ void perf_session__delete(struct perf_session *sessio= n) free(session); } =20 -static int process_event_synth_tracing_data_stub(struct perf_session *sess= ion - __maybe_unused, - union perf_event *event - __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_synth_attr_stub(const struct perf_tool *tool __ma= ybe_unused, - union perf_event *event __maybe_unused, - struct evlist **pevlist - __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_synth_event_update_stub(const struct perf_tool *t= ool __maybe_unused, - union perf_event *event __maybe_unused, - struct evlist **pevlist - __maybe_unused) -{ - if (dump_trace) - perf_event__fprintf_event_update(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_sample_stub(const struct perf_tool *tool __maybe_= unused, - union perf_event *event __maybe_unused, - struct perf_sample *sample __maybe_unused, - struct evsel *evsel __maybe_unused, - struct machine *machine __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_stub(const struct perf_tool *tool __maybe_unused, - union perf_event *event __maybe_unused, - struct perf_sample *sample __maybe_unused, - struct machine *machine __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_finished_round_stub(const struct perf_tool *tool __mayb= e_unused, - union perf_event *event __maybe_unused, - struct ordered_events *oe __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -static int skipn(int fd, off_t n) -{ - char buf[4096]; - ssize_t ret; - - while (n > 0) { - ret =3D read(fd, buf, min(n, (off_t)sizeof(buf))); - if (ret <=3D 0) - return ret; - n -=3D ret; - } - - return 0; -} - -static s64 process_event_auxtrace_stub(struct perf_session *session __mayb= e_unused, - union perf_event *event) -{ - dump_printf(": unhandled!\n"); - if (perf_data__is_pipe(session->data)) - skipn(perf_data__fd(session->data), event->auxtrace.size); - return event->auxtrace.size; -} - -static int process_event_op2_stub(struct perf_session *session __maybe_unu= sed, - union perf_event *event __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - - -static -int process_event_thread_map_stub(struct perf_session *session __maybe_unu= sed, - union perf_event *event __maybe_unused) -{ - if (dump_trace) - perf_event__fprintf_thread_map(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static -int process_event_cpu_map_stub(struct perf_session *session __maybe_unused, - union perf_event *event __maybe_unused) -{ - if (dump_trace) - perf_event__fprintf_cpu_map(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static -int process_event_stat_config_stub(struct perf_session *session __maybe_un= used, - union perf_event *event __maybe_unused) -{ - if (dump_trace) - perf_event__fprintf_stat_config(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_stat_stub(struct perf_session *perf_session __maybe_unu= sed, - union perf_event *event) -{ - if (dump_trace) - perf_event__fprintf_stat(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_stat_round_stub(struct perf_session *perf_session __may= be_unused, - union perf_event *event) -{ - if (dump_trace) - perf_event__fprintf_stat_round(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int process_event_time_conv_stub(struct perf_session *perf_session = __maybe_unused, - union perf_event *event) -{ - if (dump_trace) - perf_event__fprintf_time_conv(event, stdout); - - dump_printf(": unhandled!\n"); - return 0; -} - -static int perf_session__process_compressed_event_stub(struct perf_session= *session __maybe_unused, - union perf_event *event __maybe_unused, - u64 file_offset __maybe_unused, - const char *file_path __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - -void perf_tool__fill_defaults(struct perf_tool *tool) -{ - if (tool->sample =3D=3D NULL) - tool->sample =3D process_event_sample_stub; - if (tool->mmap =3D=3D NULL) - tool->mmap =3D process_event_stub; - if (tool->mmap2 =3D=3D NULL) - tool->mmap2 =3D process_event_stub; - if (tool->comm =3D=3D NULL) - tool->comm =3D process_event_stub; - if (tool->namespaces =3D=3D NULL) - tool->namespaces =3D process_event_stub; - if (tool->cgroup =3D=3D NULL) - tool->cgroup =3D process_event_stub; - if (tool->fork =3D=3D NULL) - tool->fork =3D process_event_stub; - if (tool->exit =3D=3D NULL) - tool->exit =3D process_event_stub; - if (tool->lost =3D=3D NULL) - tool->lost =3D perf_event__process_lost; - if (tool->lost_samples =3D=3D NULL) - tool->lost_samples =3D perf_event__process_lost_samples; - if (tool->aux =3D=3D NULL) - tool->aux =3D perf_event__process_aux; - if (tool->itrace_start =3D=3D NULL) - tool->itrace_start =3D perf_event__process_itrace_start; - if (tool->context_switch =3D=3D NULL) - tool->context_switch =3D perf_event__process_switch; - if (tool->ksymbol =3D=3D NULL) - tool->ksymbol =3D perf_event__process_ksymbol; - if (tool->bpf =3D=3D NULL) - tool->bpf =3D perf_event__process_bpf; - if (tool->text_poke =3D=3D NULL) - tool->text_poke =3D perf_event__process_text_poke; - if (tool->aux_output_hw_id =3D=3D NULL) - tool->aux_output_hw_id =3D perf_event__process_aux_output_hw_id; - if (tool->read =3D=3D NULL) - tool->read =3D process_event_sample_stub; - if (tool->throttle =3D=3D NULL) - tool->throttle =3D process_event_stub; - if (tool->unthrottle =3D=3D NULL) - tool->unthrottle =3D process_event_stub; - if (tool->attr =3D=3D NULL) - tool->attr =3D process_event_synth_attr_stub; - if (tool->event_update =3D=3D NULL) - tool->event_update =3D process_event_synth_event_update_stub; - if (tool->tracing_data =3D=3D NULL) - tool->tracing_data =3D process_event_synth_tracing_data_stub; - if (tool->build_id =3D=3D NULL) - tool->build_id =3D process_event_op2_stub; - if (tool->finished_round =3D=3D NULL) { - if (tool->ordered_events) - tool->finished_round =3D perf_event__process_finished_round; - else - tool->finished_round =3D process_finished_round_stub; - } - if (tool->id_index =3D=3D NULL) - tool->id_index =3D process_event_op2_stub; - if (tool->auxtrace_info =3D=3D NULL) - tool->auxtrace_info =3D process_event_op2_stub; - if (tool->auxtrace =3D=3D NULL) - tool->auxtrace =3D process_event_auxtrace_stub; - if (tool->auxtrace_error =3D=3D NULL) - tool->auxtrace_error =3D process_event_op2_stub; - if (tool->thread_map =3D=3D NULL) - tool->thread_map =3D process_event_thread_map_stub; - if (tool->cpu_map =3D=3D NULL) - tool->cpu_map =3D process_event_cpu_map_stub; - if (tool->stat_config =3D=3D NULL) - tool->stat_config =3D process_event_stat_config_stub; - if (tool->stat =3D=3D NULL) - tool->stat =3D process_stat_stub; - if (tool->stat_round =3D=3D NULL) - tool->stat_round =3D process_stat_round_stub; - if (tool->time_conv =3D=3D NULL) - tool->time_conv =3D process_event_time_conv_stub; - if (tool->feature =3D=3D NULL) - tool->feature =3D process_event_op2_stub; - if (tool->compressed =3D=3D NULL) - tool->compressed =3D perf_session__process_compressed_event; - if (tool->finished_init =3D=3D NULL) - tool->finished_init =3D process_event_op2_stub; -} - static void swap_sample_id_all(union perf_event *event, void *data) { void *end =3D (void *) event + event->header.size; @@ -1672,8 +1365,7 @@ static s64 perf_session__process_user_event(struct pe= rf_session *session, int fd =3D perf_data__fd(session->data); int err; =20 - if (event->header.type !=3D PERF_RECORD_COMPRESSED || - tool->compressed =3D=3D perf_session__process_compressed_event_stub) + if (event->header.type !=3D PERF_RECORD_COMPRESSED || perf_tool__compress= ed_is_stub(tool)) dump_event(session->evlist, event, file_offset, &sample, file_path); =20 /* These events are processed right away */ diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 6886cc85600f..7f69baeae7fb 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -92,8 +92,6 @@ int perf_session__process_events(struct perf_session *ses= sion); int perf_session__queue_event(struct perf_session *s, union perf_event *ev= ent, u64 timestamp, u64 file_offset, const char *file_path); =20 -void perf_tool__fill_defaults(struct perf_tool *tool); - int perf_session__resolve_callchain(struct perf_session *session, struct evsel *evsel, struct thread *thread, diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c new file mode 100644 index 000000000000..17219ecb8fa6 --- /dev/null +++ b/tools/perf/util/tool.c @@ -0,0 +1,325 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "data.h" +#include "debug.h" +#include "header.h" +#include "session.h" +#include "stat.h" +#include "tool.h" +#include "tsc.h" +#include +#include + +#ifdef HAVE_ZSTD_SUPPORT +static int perf_session__process_compressed_event(struct perf_session *ses= sion, + union perf_event *event, u64 file_offset, + const char *file_path) +{ + void *src; + size_t decomp_size, src_size; + u64 decomp_last_rem =3D 0; + size_t mmap_len, decomp_len =3D session->header.env.comp_mmap_len; + struct decomp *decomp, *decomp_last =3D session->active_decomp->decomp_la= st; + + if (decomp_last) { + decomp_last_rem =3D decomp_last->size - decomp_last->head; + decomp_len +=3D decomp_last_rem; + } + + mmap_len =3D sizeof(struct decomp) + decomp_len; + decomp =3D mmap(NULL, mmap_len, PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); + if (decomp =3D=3D MAP_FAILED) { + pr_err("Couldn't allocate memory for decompression\n"); + return -1; + } + + decomp->file_pos =3D file_offset; + decomp->file_path =3D file_path; + decomp->mmap_len =3D mmap_len; + decomp->head =3D 0; + + if (decomp_last_rem) { + memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_las= t_rem); + decomp->size =3D decomp_last_rem; + } + + src =3D (void *)event + sizeof(struct perf_record_compressed); + src_size =3D event->pack.header.size - sizeof(struct perf_record_compress= ed); + + decomp_size =3D zstd_decompress_stream(session->active_decomp->zstd_decom= p, src, src_size, + &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem); + if (!decomp_size) { + munmap(decomp, mmap_len); + pr_err("Couldn't decompress data\n"); + return -1; + } + + decomp->size +=3D decomp_size; + + if (session->active_decomp->decomp =3D=3D NULL) + session->active_decomp->decomp =3D decomp; + else + session->active_decomp->decomp_last->next =3D decomp; + + session->active_decomp->decomp_last =3D decomp; + + pr_debug("decomp (B): %zd to %zd\n", src_size, decomp_size); + + return 0; +} +#endif + +static int process_event_synth_tracing_data_stub(struct perf_session *sess= ion + __maybe_unused, + union perf_event *event + __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_synth_attr_stub(const struct perf_tool *tool __ma= ybe_unused, + union perf_event *event __maybe_unused, + struct evlist **pevlist + __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_synth_event_update_stub(const struct perf_tool *t= ool __maybe_unused, + union perf_event *event __maybe_unused, + struct evlist **pevlist + __maybe_unused) +{ + if (dump_trace) + perf_event__fprintf_event_update(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_sample_stub(const struct perf_tool *tool __maybe_= unused, + union perf_event *event __maybe_unused, + struct perf_sample *sample __maybe_unused, + struct evsel *evsel __maybe_unused, + struct machine *machine __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_stub(const struct perf_tool *tool __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_sample *sample __maybe_unused, + struct machine *machine __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_finished_round_stub(const struct perf_tool *tool __mayb= e_unused, + union perf_event *event __maybe_unused, + struct ordered_events *oe __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +static int skipn(int fd, off_t n) +{ + char buf[4096]; + ssize_t ret; + + while (n > 0) { + ret =3D read(fd, buf, min(n, (off_t)sizeof(buf))); + if (ret <=3D 0) + return ret; + n -=3D ret; + } + + return 0; +} + +static s64 process_event_auxtrace_stub(struct perf_session *session __mayb= e_unused, + union perf_event *event) +{ + dump_printf(": unhandled!\n"); + if (perf_data__is_pipe(session->data)) + skipn(perf_data__fd(session->data), event->auxtrace.size); + return event->auxtrace.size; +} + +static int process_event_op2_stub(struct perf_session *session __maybe_unu= sed, + union perf_event *event __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + + +static +int process_event_thread_map_stub(struct perf_session *session __maybe_unu= sed, + union perf_event *event __maybe_unused) +{ + if (dump_trace) + perf_event__fprintf_thread_map(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static +int process_event_cpu_map_stub(struct perf_session *session __maybe_unused, + union perf_event *event __maybe_unused) +{ + if (dump_trace) + perf_event__fprintf_cpu_map(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static +int process_event_stat_config_stub(struct perf_session *session __maybe_un= used, + union perf_event *event __maybe_unused) +{ + if (dump_trace) + perf_event__fprintf_stat_config(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_stat_stub(struct perf_session *perf_session __maybe_unu= sed, + union perf_event *event) +{ + if (dump_trace) + perf_event__fprintf_stat(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_stat_round_stub(struct perf_session *perf_session __may= be_unused, + union perf_event *event) +{ + if (dump_trace) + perf_event__fprintf_stat_round(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int process_event_time_conv_stub(struct perf_session *perf_session = __maybe_unused, + union perf_event *event) +{ + if (dump_trace) + perf_event__fprintf_time_conv(event, stdout); + + dump_printf(": unhandled!\n"); + return 0; +} + +static int perf_session__process_compressed_event_stub(struct perf_session= *session __maybe_unused, + union perf_event *event __maybe_unused, + u64 file_offset __maybe_unused, + const char *file_path __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + +void perf_tool__fill_defaults(struct perf_tool *tool) +{ + if (tool->sample =3D=3D NULL) + tool->sample =3D process_event_sample_stub; + if (tool->mmap =3D=3D NULL) + tool->mmap =3D process_event_stub; + if (tool->mmap2 =3D=3D NULL) + tool->mmap2 =3D process_event_stub; + if (tool->comm =3D=3D NULL) + tool->comm =3D process_event_stub; + if (tool->namespaces =3D=3D NULL) + tool->namespaces =3D process_event_stub; + if (tool->cgroup =3D=3D NULL) + tool->cgroup =3D process_event_stub; + if (tool->fork =3D=3D NULL) + tool->fork =3D process_event_stub; + if (tool->exit =3D=3D NULL) + tool->exit =3D process_event_stub; + if (tool->lost =3D=3D NULL) + tool->lost =3D perf_event__process_lost; + if (tool->lost_samples =3D=3D NULL) + tool->lost_samples =3D perf_event__process_lost_samples; + if (tool->aux =3D=3D NULL) + tool->aux =3D perf_event__process_aux; + if (tool->itrace_start =3D=3D NULL) + tool->itrace_start =3D perf_event__process_itrace_start; + if (tool->context_switch =3D=3D NULL) + tool->context_switch =3D perf_event__process_switch; + if (tool->ksymbol =3D=3D NULL) + tool->ksymbol =3D perf_event__process_ksymbol; + if (tool->bpf =3D=3D NULL) + tool->bpf =3D perf_event__process_bpf; + if (tool->text_poke =3D=3D NULL) + tool->text_poke =3D perf_event__process_text_poke; + if (tool->aux_output_hw_id =3D=3D NULL) + tool->aux_output_hw_id =3D perf_event__process_aux_output_hw_id; + if (tool->read =3D=3D NULL) + tool->read =3D process_event_sample_stub; + if (tool->throttle =3D=3D NULL) + tool->throttle =3D process_event_stub; + if (tool->unthrottle =3D=3D NULL) + tool->unthrottle =3D process_event_stub; + if (tool->attr =3D=3D NULL) + tool->attr =3D process_event_synth_attr_stub; + if (tool->event_update =3D=3D NULL) + tool->event_update =3D process_event_synth_event_update_stub; + if (tool->tracing_data =3D=3D NULL) + tool->tracing_data =3D process_event_synth_tracing_data_stub; + if (tool->build_id =3D=3D NULL) + tool->build_id =3D process_event_op2_stub; + if (tool->finished_round =3D=3D NULL) { + if (tool->ordered_events) + tool->finished_round =3D perf_event__process_finished_round; + else + tool->finished_round =3D process_finished_round_stub; + } + if (tool->id_index =3D=3D NULL) + tool->id_index =3D process_event_op2_stub; + if (tool->auxtrace_info =3D=3D NULL) + tool->auxtrace_info =3D process_event_op2_stub; + if (tool->auxtrace =3D=3D NULL) + tool->auxtrace =3D process_event_auxtrace_stub; + if (tool->auxtrace_error =3D=3D NULL) + tool->auxtrace_error =3D process_event_op2_stub; + if (tool->thread_map =3D=3D NULL) + tool->thread_map =3D process_event_thread_map_stub; + if (tool->cpu_map =3D=3D NULL) + tool->cpu_map =3D process_event_cpu_map_stub; + if (tool->stat_config =3D=3D NULL) + tool->stat_config =3D process_event_stat_config_stub; + if (tool->stat =3D=3D NULL) + tool->stat =3D process_stat_stub; + if (tool->stat_round =3D=3D NULL) + tool->stat_round =3D process_stat_round_stub; + if (tool->time_conv =3D=3D NULL) + tool->time_conv =3D process_event_time_conv_stub; + if (tool->feature =3D=3D NULL) + tool->feature =3D process_event_op2_stub; + if (tool->compressed =3D=3D NULL) { +#ifdef HAVE_ZSTD_SUPPORT + tool->compressed =3D perf_session__process_compressed_event; +#else + tool->compressed =3D perf_session__process_compressed_event_stub; +#endif + } + if (tool->finished_init =3D=3D NULL) + tool->finished_init =3D process_event_op2_stub; +} + +bool perf_tool__compressed_is_stub(const struct perf_tool *tool) +{ + return tool->compressed =3D=3D perf_session__process_compressed_event_stu= b; +} diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index b192d44fe91f..7913b698033a 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -88,4 +88,8 @@ struct perf_tool { enum show_feature_header show_feat_hdr; }; =20 +void perf_tool__fill_defaults(struct perf_tool *tool); + +bool perf_tool__compressed_is_stub(const struct perf_tool *tool); + #endif /* __PERF_TOOL_H */ --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 D7CAF16EBFC for ; Thu, 11 Jul 2024 18:00:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720829; cv=none; b=WDViAmi/RCg/oohq8nQGf8HtniKrVcezRExksntSZTd9e5KyjbvX4zocRVB4eGjPrVc8+LONeUUHluHDNlJozjc5nFPaXAoetkkcAgMSu3B7KJ4ZAHBb0HJt718V/HJpo4Gs3pFa3Ze8GILHZo9KbgEYsA/g2rI9v7sRGzBLnLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720829; c=relaxed/simple; bh=0sUGypKycMkQkspjkBVoBrgTbEB/yfeNI4tZZobPQAE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=kvyWBazs1i3lnxWbK9VpG7ad8u0h8ANx2BbfcZI1qsR9f24Yp5dUE2+EXDTcUk6HnjBkYHxXjZl/MQA1UI9cJ3Z1JDbOJLf97jDvxbN2efL+Dh3OGWbdo58VnM3mOLb18g9DdYNcVVk0jKTXm7qUpEwDqFPa5JucrZHA6L1Y9SY= 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=ppyPFD+W; 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="ppyPFD+W" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-64a5503e253so19837327b3.0 for ; Thu, 11 Jul 2024 11:00:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720827; x=1721325627; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=PUbNGHbJusTOA2CgJOpkojrr3Ag9eG/HXr7a91E5F44=; b=ppyPFD+WeU9PlFJ4c7YMoVnVNKecUKzucpvTVkXxIaBGK9kC58zxnEOn7Fr8fuDizw zd62W/SyQdAOrpYiY6jN6zmTBKEtN2ly+FNddVBl5XHePryThqmET/09d2SbFf9KoZ/Y ucQSF4VrsMwEFaxXb4NhcKX2DNuw8qyQD3+f0L3wLP/k9gYpTTDhIm5L3DkC/jamDzTZ eq0Aar674zG1oRT4FYth4wDGP+1HDuAb8hzZ83Pj0NhEyUnMC3CChep1VLPGFx86tCZ0 yJrib7dJ4wKPlDIPPDapT9abSkly/cIejGGbAmGQWzjDmiw58wi3oS7W0xwk/ZudAdb1 N+kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720827; x=1721325627; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PUbNGHbJusTOA2CgJOpkojrr3Ag9eG/HXr7a91E5F44=; b=fKbII+5vCwoGgkxiZNE9MOEQTmlyVyP+ZupOV9yquLLcBa2duFfDrE4TJ/eZfO3OS2 S6QvSpdRb7xNgpbQe/MM6ZaLMqosqYIoGrCEveaRPDBnTCmbdbTT3yJ5gcg0CEMylQ1Z hgHwQrS9A9Zb1+m7taKfmm2RF8zIq5QkZEm1K0Nlya51Zl1ukDyHyJyj0clRcpCMEf3C yx6WwAtjCfGwgSKOWu+SM3BhcVss9TBBRd/4nwb+eWlI6DehVY2C6X3s29jVhyhvP6hc JpsfKH7ODMs/OAxdSB9jYw+iOAf1yBA40N/q3mm1SYxcDACYyM+QZ41/V4e7Me6wPmjq vxgw== X-Forwarded-Encrypted: i=1; AJvYcCWs1+loD95Jep+OYhGOiXaqKqG3UxRgLgt06Tv8JqO71ShFTEZEw15W8DwwMkynkHLtQrmiu/BFE0oTHFODM5JYCINxifwDP8Czzsgt X-Gm-Message-State: AOJu0Yw4X7fZpo9UMcHbAfEh9G5K0kxOL3+nfDBEHVHRfR/INlaxhJzz YyR7gjd/hbrh9kcDpyaN04xGkwgAeRHT6Ke4kJteo6iuqQKIpCm3nDn9zVL3293vFjQkTQLqWCL k4Th8Ag== X-Google-Smtp-Source: AGHT+IGpjmXnPZG6ET95BcM0LX++X4FSpZehPMsvXd/XHk3OIv4vX9bTses9QahK6eBa9XlUvUAYslXgj71k X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:360d:b0:631:d4ea:3749 with SMTP id 00721157ae682-658eeb6e079mr421397b3.4.1720720826737; Thu, 11 Jul 2024 11:00:26 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:46 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 06/28] perf tool: Add perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add init function that behaves like perf_tool__fill_defaults but assumes all values haven't been initialized. Signed-off-by: Ian Rogers --- tools/perf/util/tool.c | 58 ++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/tool.h | 1 + 2 files changed, 59 insertions(+) diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c index 17219ecb8fa6..cbd9b888bd73 100644 --- a/tools/perf/util/tool.c +++ b/tools/perf/util/tool.c @@ -230,6 +230,64 @@ static int perf_session__process_compressed_event_stub= (struct perf_session *sess return 0; } =20 +void perf_tool__init(struct perf_tool *tool, bool ordered_events) +{ + tool->ordered_events =3D ordered_events; + tool->ordering_requires_timestamps =3D false; + tool->namespace_events =3D false; + tool->cgroup_events =3D false; + tool->no_warn =3D false; + tool->show_feat_hdr =3D SHOW_FEAT_NO_HEADER; + + tool->sample =3D process_event_sample_stub; + tool->mmap =3D process_event_stub; + tool->mmap2 =3D process_event_stub; + tool->comm =3D process_event_stub; + tool->namespaces =3D process_event_stub; + tool->cgroup =3D process_event_stub; + tool->fork =3D process_event_stub; + tool->exit =3D process_event_stub; + tool->lost =3D perf_event__process_lost; + tool->lost_samples =3D perf_event__process_lost_samples; + tool->aux =3D perf_event__process_aux; + tool->itrace_start =3D perf_event__process_itrace_start; + tool->context_switch =3D perf_event__process_switch; + tool->ksymbol =3D perf_event__process_ksymbol; + tool->bpf =3D perf_event__process_bpf; + tool->text_poke =3D perf_event__process_text_poke; + tool->aux_output_hw_id =3D perf_event__process_aux_output_hw_id; + tool->read =3D process_event_sample_stub; + tool->throttle =3D process_event_stub; + tool->unthrottle =3D process_event_stub; + tool->attr =3D process_event_synth_attr_stub; + tool->event_update =3D process_event_synth_event_update_stub; + tool->tracing_data =3D process_event_synth_tracing_data_stub; + tool->build_id =3D process_event_op2_stub; + + if (ordered_events) + tool->finished_round =3D perf_event__process_finished_round; + else + tool->finished_round =3D process_finished_round_stub; + + tool->id_index =3D process_event_op2_stub; + tool->auxtrace_info =3D process_event_op2_stub; + tool->auxtrace =3D process_event_auxtrace_stub; + tool->auxtrace_error =3D process_event_op2_stub; + tool->thread_map =3D process_event_thread_map_stub; + tool->cpu_map =3D process_event_cpu_map_stub; + tool->stat_config =3D process_event_stat_config_stub; + tool->stat =3D process_stat_stub; + tool->stat_round =3D process_stat_round_stub; + tool->time_conv =3D process_event_time_conv_stub; + tool->feature =3D process_event_op2_stub; +#ifdef HAVE_ZSTD_SUPPORT + tool->compressed =3D perf_session__process_compressed_event; +#else + tool->compressed =3D perf_session__process_compressed_event_stub; +#endif + tool->finished_init =3D process_event_op2_stub; +} + void perf_tool__fill_defaults(struct perf_tool *tool) { if (tool->sample =3D=3D NULL) diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index 7913b698033a..897c6c44b6b2 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -88,6 +88,7 @@ struct perf_tool { enum show_feature_header show_feat_hdr; }; =20 +void perf_tool__init(struct perf_tool *tool, bool ordered_events); void perf_tool__fill_defaults(struct perf_tool *tool); =20 bool perf_tool__compressed_is_stub(const struct perf_tool *tool); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 BCDFC16DC08 for ; Thu, 11 Jul 2024 18:00:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720831; cv=none; b=BtQ0k9o54q+cjAlx2p37WKHeOLEdmH/0LoXAggo5V7bhjWUEU2ZwT+x0O60Grs3OemTgnUnFFFJDRPlRrQSO1OB/e26cL9mNzaS6P+6GhwNX3biIGR0W7+DL6Rf6Nm5tYlHTQkqX/ORlGxJrhLA4NiG94eWurcKvxA2F4OT6Chw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720831; c=relaxed/simple; bh=z5wXs6v0oTEwyKPVEdDTOwtt2S/GFG3uzWXLUE9bRVQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=flPHdZTiykNhy6Rdm8pK+9FMFAVx+Tqa762f0qjdoXQ71e1r9pOM1zJq8SZ3dVK6RE+a9x8UI+A1MTqRiftSnC0qJ/WdLRU7j+h2JhZBppGDMIqJIFPPq12XYnk8jp4f3FY2W6PxaeJbw8ugSnui6tVyR/T3+rBMgNlXp20+0Wg= 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=uMkRCVVg; 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="uMkRCVVg" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e037c3d20a6so2005016276.0 for ; Thu, 11 Jul 2024 11:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720829; x=1721325629; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=yTWyT8gKTKays8rE64DnYrzhErijM5o6wos0PD63SLQ=; b=uMkRCVVg4+8d8UHW2YpYBHCtJBFje+SEQ/PtYN4xKeintSCODVi8bzFQjGf+JyWLvq C9O91iCbxN0puvu6UiQrUZqlTHm8HISz1+HDFiejJj3uQyY1zHZ2Qq+B9T3xvR+jNoyi bL9HCCnMX59sGNYHBAvX5NzA19VgROlVZWwDg816cNtlLSGyREjdcGYvyT+8Iq5E18yE ORHKkdmBH/CWY445jQucXaZEXC7hlBToVCoifn7R1aONTYuNMw33DTo36DjXKg5+y+rr 027GfqegzGBOU7dm0IUiXKAd30dTthN1ZqyiipL9py83iI/CZGTHL7JVFHzYqD2PKou1 HONA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720829; x=1721325629; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yTWyT8gKTKays8rE64DnYrzhErijM5o6wos0PD63SLQ=; b=hXdOlFC9NlJK+BJbLFhXpdMxS+7lCrHsFUSv/EsY/qxUWqJeSZXofKJ4/fqyHCFoQm S4p3NKWVY208Guh57qz87EMjMsGF7jZ2lh7qZWOxylMesIKinVb9oJyHEOks4VY4IsKs wxDJl1tWVGOWiHiC9o09R8yjM6zt3MiQ5YvZWe/xaMC/LPO+Myzbo0JyNOwyLCSwMxfm grNnBd4pHo6nUSV3WmcEu9wWGBnK7htuckz9UmEGAkLkZtohju6hevLBePKHCBnFORZQ uQSNlRGJr84VslXRIzf5VT80pMhVCek9COwD5m1904gX5ByQHneyg51tVarAPsQFkiV0 b+0Q== X-Forwarded-Encrypted: i=1; AJvYcCU+qXacLelo9CWs9R6gFyKs5igI6n2+anPi94ne9vAAiIO3sZ3Z5TW4BB3xmYsvxyUfJ9nkcRjnC4/g1VYD+UKA9T+fgFjHVf7BhDDY X-Gm-Message-State: AOJu0Yy3YfiKFSOXML4aUMlpfyyNHll5f1xTPCNeD+WiszgZ5V7t2A4F MZvhY6JC+fJnSct+B18J3kADYwdtdD0i4ThvB4LGL8ySzOA/LaamFJkjtpHAfzd3pYSe/QdMs/V UK47hPg== X-Google-Smtp-Source: AGHT+IHHvO9Dhy0kBlcS6+TF6u533W13vm3/nzwkXeSVQqKTUfz4Z3LP7tKCWbiDOEGivVzU7ZTCq/u5C+Mt X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:2b0d:b0:e03:3cfa:1aa9 with SMTP id 3f1490d57ef6-e041b1134afmr21767276.8.1720720828932; Thu, 11 Jul 2024 11:00:28 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:47 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 07/28] perf kmem: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Reduce the scope of the tool from global/static to just that of the cmd_kmem function where the session is scoped. Use the perf_tool__init to initialize default values. Signed-off-by: Ian Rogers --- tools/perf/builtin-kmem.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 859ff018eace..b3cbac40b8c7 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -986,15 +986,6 @@ static int process_sample_event(const struct perf_tool= *tool __maybe_unused, return err; } =20 -static struct perf_tool perf_kmem =3D { - .sample =3D process_sample_event, - .comm =3D perf_event__process_comm, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .namespaces =3D perf_event__process_namespaces, - .ordered_events =3D true, -}; - static double fragmentation(unsigned long n_req, unsigned long n_alloc) { if (n_alloc =3D=3D 0) @@ -1971,6 +1962,7 @@ int cmd_kmem(int argc, const char **argv) NULL }; struct perf_session *session; + struct perf_tool perf_kmem; static const char errmsg[] =3D "No %s allocation events found. Have you = run 'perf kmem record --%s'?\n"; int ret =3D perf_config(kmem_config, NULL); =20 @@ -1998,6 +1990,13 @@ int cmd_kmem(int argc, const char **argv) =20 data.path =3D input_name; =20 + perf_tool__init(&perf_kmem, /*ordered_events=3D*/true); + perf_kmem.sample =3D process_sample_event; + perf_kmem.comm =3D perf_event__process_comm; + perf_kmem.mmap =3D perf_event__process_mmap; + perf_kmem.mmap2 =3D perf_event__process_mmap2; + perf_kmem.namespaces =3D perf_event__process_namespaces; + kmem_session =3D session =3D perf_session__new(&data, &perf_kmem); if (IS_ERR(session)) return PTR_ERR(session); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 CFD7616F0F0 for ; Thu, 11 Jul 2024 18:00:31 +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=1720720833; cv=none; b=t7ZGaHXXHj3MI4NE7aeKmCOsfpSKuoZz4X4S2GEgoXXTfQstdMv7bpULRirR8MFrkDCcSsfpGocm7UU3yQRsLRUQsG4PLQtKbR+hewmJ6aSJp89h89IOwuAYLZrMoZUk8dukyUYXsSJ2l9xVR/BTmPYDffT4h8H5dpf5Ec8u/A4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720833; c=relaxed/simple; bh=s0Rh4l6oRIEgtvRI2f9plGMJwLFvIN4S58NEHTolpq4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=QE7Ir/AJbSYPaDxyZ+4/PG1ui5IQlRwm4mx9HYqmL73VXtLhi3WgwYSyuKZaTDn0w9xc+zEZpYnzvEbbE5sb3IYyd92ES34jdafMeMGCwhmtkHN4VgiL/GGOkA+SxQ3M2Y3Ge+OKVp6v9K5rSOPodMMYjSupmAO5kd3auM5j3M8= 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=OWkXuGVk; 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="OWkXuGVk" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e03c68c7163so2023510276.0 for ; Thu, 11 Jul 2024 11:00:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720831; x=1721325631; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=FzYClsD3sREquZ0ApOheKgsIb1ZvzAHTtY7Hmf1CzXE=; b=OWkXuGVkK+H1oZBCloV/Wt4x6PwuhRV++dpxEJOZYIDqBq+0s2VcNZYiU261DNnCY5 6YgNStsaZ4juaqOenwEJRhCtFQbcn3aAWYlyl8p7tnddHV0yt3MEdhU4C9HR6CgVUQ4o +U0nbsMW7xy4TMO4kyYsOO5qyQ71uGKx4TUpqpsZMWtKfBoDDOA67uyov95SAPH7EZXp +4fEqsBtjt4XmEznO5V8L0rvKOu/vw391P3hEptxybSqFheflmctaybMgYakd69Q6IzZ 3AUuc1g6U4cXh38V21S6ij1Ggw0JrxaTtVZZY/OxJ0WOCRSDNZVPaus5t16QaSIm8ivE GZ+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720831; x=1721325631; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FzYClsD3sREquZ0ApOheKgsIb1ZvzAHTtY7Hmf1CzXE=; b=vEGcXbMdUj4Yro0NdTrdjPlT5qhX95RbsM3B7W7/6qpJWWb/dp/+6c5V9hEEuTNrqc yMBFy1JeSt2EwUKNYDOrNntpQJK/BIoHPRJsa+67QVvd5EqnV+rDFWYQ9tSrEX1pJixC PKAfPaiz9PwZWWNRVXND6ndXY+4vQVW8JESUTuwbXauHh0q1jvw5bFWUpb+hOzo3ZnrQ cO/tEJHoQlI0p7vzriNblcLHcfM8gIqLqKI/PPyWgjjjCuLPZukmht6y3+t4xl8dcLlf +wjDBS+oWhv6UffjdYe5xELhLv//vqBAkPafDCrtovIN7M8+ufBBLFD1m8mlhVZ9NBPE jczQ== X-Forwarded-Encrypted: i=1; AJvYcCUHoVa71rI+0qESfd9Xjf4F7OhBlKCgELw8b9Il+PMpeEYj11aGM/TcQK8ZNhu35TKu5kggZEIrq+o2WRrIv/3pimEYaAVsmnuqkRKD X-Gm-Message-State: AOJu0YxHQaXQdf03iHqq8Zue4Ae2xzOtC0im+2s0IDLubHyumuXKVONe KVPBCBkkmtYDeyC4/Hf2LAiqZA7BffTbum4Iz+0MUTWHRWoQAPo39u8I0I6R0BNHH1vmiJJfMDW 9zFt+og== X-Google-Smtp-Source: AGHT+IEoRhLEoKiYyvi7r4ABe+97oJFK6E4DcbiXpAicbuYG+DrIdJXbjZPDGV9iy39BHmd5HC8B0tefOmQD X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1146:b0:e03:bbaf:94 with SMTP id 3f1490d57ef6-e041b185a52mr799592276.13.1720720831039; Thu, 11 Jul 2024 11:00:31 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:48 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 08/28] perf buildid-list: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Reduce scope of build_id__mark_dso_hit_ops to the scope of function perf_session__list_build_ids, its only use, and use perf_tool__init for the default values. Move perf_event__exit_del_thread to event.[ch] so it can be used in builtin-buildid-list.c. Signed-off-by: Ian Rogers --- tools/perf/builtin-buildid-list.c | 10 ++++++++++ tools/perf/util/build-id.c | 32 ------------------------------- tools/perf/util/build-id.h | 4 +--- tools/perf/util/event.c | 20 +++++++++++++++++++ tools/perf/util/event.h | 4 ++++ 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid= -list.c index 383d5de36ce4..52dfacaff8e3 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c @@ -89,6 +89,7 @@ static int perf_session__list_build_ids(bool force, bool = with_hits) .mode =3D PERF_DATA_MODE_READ, .force =3D force, }; + struct perf_tool build_id__mark_dso_hit_ops; =20 symbol__elf_init(); /* @@ -97,6 +98,15 @@ static int perf_session__list_build_ids(bool force, bool= with_hits) if (filename__fprintf_build_id(input_name, stdout) > 0) goto out; =20 + perf_tool__init(&build_id__mark_dso_hit_ops, /*ordered_events=3D*/true); + build_id__mark_dso_hit_ops.sample =3D build_id__mark_dso_hit; + build_id__mark_dso_hit_ops.mmap =3D perf_event__process_mmap; + build_id__mark_dso_hit_ops.mmap2 =3D perf_event__process_mmap2; + build_id__mark_dso_hit_ops.fork =3D perf_event__process_fork; + build_id__mark_dso_hit_ops.exit =3D perf_event__exit_del_thread; + build_id__mark_dso_hit_ops.attr =3D perf_event__process_attr; + build_id__mark_dso_hit_ops.build_id =3D perf_event__process_build_id; + session =3D perf_session__new(&data, &build_id__mark_dso_hit_ops); if (IS_ERR(session)) return PTR_ERR(session); diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 098fcc625d91..451d145fa4ed 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -67,38 +67,6 @@ int build_id__mark_dso_hit(const struct perf_tool *tool = __maybe_unused, return 0; } =20 -static int perf_event__exit_del_thread(const struct perf_tool *tool __mayb= e_unused, - union perf_event *event, - struct perf_sample *sample - __maybe_unused, - struct machine *machine) -{ - struct thread *thread =3D machine__findnew_thread(machine, - event->fork.pid, - event->fork.tid); - - dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid, - event->fork.ppid, event->fork.ptid); - - if (thread) { - machine__remove_thread(machine, thread); - thread__put(thread); - } - - return 0; -} - -struct perf_tool build_id__mark_dso_hit_ops =3D { - .sample =3D build_id__mark_dso_hit, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .fork =3D perf_event__process_fork, - .exit =3D perf_event__exit_del_thread, - .attr =3D perf_event__process_attr, - .build_id =3D perf_event__process_build_id, - .ordered_events =3D true, -}; - int build_id__sprintf(const struct build_id *build_id, char *bf) { char *bid =3D bf; diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index ae87c4c58d5b..a212497bfdb0 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -16,11 +16,9 @@ struct build_id { size_t size; }; =20 -struct nsinfo; - -extern struct perf_tool build_id__mark_dso_hit_ops; struct dso; struct feat_fd; +struct nsinfo; =20 void build_id__init(struct build_id *bid, const u8 *data, size_t size); int build_id__sprintf(const struct build_id *build_id, char *bf); diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index c2f0e7f40ad5..aac96d5d1917 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -426,6 +426,26 @@ int perf_event__process_exit(const struct perf_tool *t= ool __maybe_unused, return machine__process_exit_event(machine, event, sample); } =20 +int perf_event__exit_del_thread(const struct perf_tool *tool __maybe_unuse= d, + union perf_event *event, + struct perf_sample *sample __maybe_unused, + struct machine *machine) +{ + struct thread *thread =3D machine__findnew_thread(machine, + event->fork.pid, + event->fork.tid); + + dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid, + event->fork.ppid, event->fork.ptid); + + if (thread) { + machine__remove_thread(machine, thread); + thread__put(thread); + } + + return 0; +} + size_t perf_event__fprintf_aux(union perf_event *event, FILE *fp) { return fprintf(fp, " offset: %#"PRI_lx64" size: %#"PRI_lx64" flags: %#"PR= I_lx64" [%s%s%s]\n", diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 4b24f1c580fd..f8742e6230a5 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -319,6 +319,10 @@ int perf_event__process_exit(const struct perf_tool *t= ool, union perf_event *event, struct perf_sample *sample, struct machine *machine); +int perf_event__exit_del_thread(const struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine); int perf_event__process_ksymbol(const struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 3085416F830 for ; Thu, 11 Jul 2024 18:00:34 +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=1720720835; cv=none; b=c4WYXuGz0+xaNzxQJQ5Zj7t7k/V+j8P1OIPqddWKfkZDELcHNOw+xDWsaInX4uUwg92z3JctJEL3h6Z8tMJwpF2Fk/Macz0Qk9bj0G/KMFf9LQY2xO4V42sbdR4CGG7B9pkv800AkRUbDrs3XSVITFvJbiK610VG5rQs0FXo/z8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720835; c=relaxed/simple; bh=R2cr19QUh/0PZGh9ohFFVIVNT0Cp0G9UBlrYuAQOwdI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=lKJ3cXQ2Itz23nbldRgVDkVlWv6hfjKd/Pv7/ECmJwS/szVcT741Tqovkr7kTztN8xqLT0qXhfSPPxcNIjwJjXq09HVhvOvXjvQV6gO2ctdRRGVtTOLkEngjJtkqgkLdkHtPq6dKv3UdYAbIf8ht1njIS1lhH3USwNhjSThEaWU= 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=Cm8dn/NR; 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="Cm8dn/NR" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e05600ade22so2354172276.1 for ; Thu, 11 Jul 2024 11:00:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720833; x=1721325633; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=byfF1KS0n4MzwFOMTsFSRoLAA/Zhxt2Mi8AKEzVn+O0=; b=Cm8dn/NRLfNcWn4wNBR7Izz67H3ZSekQlx3m89/DoRO84qqxByOiSluP4J7AAxskxp axpjKoCy1kvqBALMtEaX9TY7XALWqa/bLQ32yBerEaOsdDDrZlucZrnFYG3sBYXYSJSR vcMBgpcROEtxbQH4MugC74QZCEC2B1mSidJNRe7djNvjj9KJFXyHSo2mw5+mO3J+PT7r OZ/W1iEhuBSEBCKwfVq7B3bQrGY6b8cCQMEmYoXR65o3WK6sxwZx58Fv+hum+pCrElWR MeJNgcbzAm8oZrkoVOOxy3xZv14TTpCCo7meVQMHIZSfk5Lml71/HvorvPuKqOsW/w/Y XILw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720833; x=1721325633; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=byfF1KS0n4MzwFOMTsFSRoLAA/Zhxt2Mi8AKEzVn+O0=; b=ifaIWDRubXFLQ9huN3W2Q4rwJjvXn4wRlovejTQJHsaThwNyGHSNLA1eENF1BXFF3z M1opHo6ijSUcWza47YOf8YgG6K+vNoX/WkTChbKdgrN0WyoNNacYhgsKzTLHCLXqp4Oy FyDcDcWXLD8eaKI3Mh2sXfKP8WNWHJ9t48E23iZUfRU+KW7xAswvo4KJYR6NTeL/yVQb nFKhga1Uo01AozZg1LpumNymTzJpjSPfxUuOcdkUbdEq4BCBmYlIYjvZfI8I3xPhygbj 03BiygFQxO3LFaG25iNgE+35y8K0iNpHTPztK/mDH4ztYbyPk100KeFEgLefWF0uVa9o CzdA== X-Forwarded-Encrypted: i=1; AJvYcCUHXEs/vazR+zOdU4xOLC/qizdjba4PsEo06jWYQsUW3dgGBhiwfCZeDVjJNVJwdHKLn5qciHdTfDSBGwgfk6UwxlSijcIOq4IPi06S X-Gm-Message-State: AOJu0YwInqLUUBOvLETwfGOO/qavRKuPDcFOHMmLUR2dQZV9Moays1+g ihcBaSjfT+HYeNbmbJURjIZdCaHm5Pryp4euZiUKHrkqycECnSlKOkO2YaKeEf0MLPZkkmYhmfh yHOXLHA== X-Google-Smtp-Source: AGHT+IHr46EqKsmYnSPwqHtEtQqAbJbduJBfkql3qcbWmp+qi69+FUgSATsZrC/sYGw83ur4i+SBO0yT6dWE X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1389:b0:e02:f35c:d398 with SMTP id 3f1490d57ef6-e058a707db8mr1062276.0.1720720833194; Thu, 11 Jul 2024 11:00:33 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:49 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 09/28] perf kvm: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-kvm.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index a3b903cf4311..692267b1b7e8 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -1603,19 +1603,17 @@ static int read_events(struct perf_kvm_stat *kvm) { int ret; =20 - struct perf_tool eops =3D { - .sample =3D process_sample_event, - .comm =3D perf_event__process_comm, - .namespaces =3D perf_event__process_namespaces, - .ordered_events =3D true, - }; struct perf_data file =3D { .path =3D kvm->file_name, .mode =3D PERF_DATA_MODE_READ, .force =3D kvm->force, }; =20 - kvm->tool =3D eops; + perf_tool__init(&kvm->tool, /*ordered_events=3D*/true); + kvm->tool.sample =3D process_sample_event; + kvm->tool.comm =3D perf_event__process_comm; + kvm->tool.namespaces =3D perf_event__process_namespaces; + kvm->session =3D perf_session__new(&file, &kvm->tool); if (IS_ERR(kvm->session)) { pr_err("Initializing perf session failed\n"); @@ -1919,14 +1917,13 @@ static int kvm_events_live(struct perf_kvm_stat *kv= m, =20 =20 /* event handling */ + perf_tool__init(&kvm->tool, /*ordered_events=3D*/true); kvm->tool.sample =3D process_sample_event; kvm->tool.comm =3D perf_event__process_comm; kvm->tool.exit =3D perf_event__process_exit; kvm->tool.fork =3D perf_event__process_fork; kvm->tool.lost =3D process_lost_event; kvm->tool.namespaces =3D perf_event__process_namespaces; - kvm->tool.ordered_events =3D true; - perf_tool__fill_defaults(&kvm->tool); =20 /* set defaults */ kvm->display_time =3D 1; --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 490C616F8E5 for ; Thu, 11 Jul 2024 18:00:36 +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=1720720838; cv=none; b=NkItfuApjXHwm75Q4EWWZrFHIXfMEWNX5QTpZI28PcsJjfolte7OrfF7l7P2AKqrRWjBbzvnyEPUtSJ0ukhkFAQb04nLyj9k7KnUSSoNlT+oqPvZaMDoxXZ2YwVlgYNxdzzmu2Clm+XmZ06cFWQIoO6JfB4ows6i5LozoKEbrkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720838; c=relaxed/simple; bh=LWeT84SQaD/ZqxsdujULbunWNxfNaZERjhKf3ganreg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=azZ6/uPWJt1V3/LyFaUa7GZLjJH9AAC2sQs6zJi10MmnNkr06wA9WzAu/yZzAg6aGp8kxSPpTcJ6pPZ5cogtCvpeER3SsznlenLDxXiCSpJZtIoKwlhXCzjEkKUpC6bd1x2t7ggqmcuFgneQoKME8olhd86gbm35GASbCjS2jJQ= 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=vd2oRw2J; 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="vd2oRw2J" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6525230ceeaso20906577b3.2 for ; Thu, 11 Jul 2024 11:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720835; x=1721325635; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=jf/366lvU4AUPtbGBpn9zhF7c/C+EcohgCe44YuCQ7Y=; b=vd2oRw2JzLJmuRlDZ82IACc+5+br3h1F6RVS8jTUeTpNzqNvo3bGRRMnsLdli4NyOS El4oSnXGv903vTqDlE2t+oTRF7htei4u3Ggd56xE/7rB5Xj7LFKyrAwnJyt2OgeODUT/ pdg1fVE3zNxV/sSKDuJH8yX8yN3CY9SiR7DiRns8Mz3AlPknLBCWc4L0O3fUlNK2Clw4 LmRa/gpKWXAbYmx/Qn5Qy3qs4T7C790/tc22//2BZHPa2qGDuWGxgODihyC1y/Ph+4Oc e+ZoAncAxreIql8dkH6Y77NW3rvxErflYdFhAUu201jbT2okBffKvbNLS6MWjpfgEAUS fIEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720835; x=1721325635; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jf/366lvU4AUPtbGBpn9zhF7c/C+EcohgCe44YuCQ7Y=; b=QDbwRbhJP2Fh1aSvfrqn74MOOVXiUxqmDTT/pHaAowLqgtOffoE8rsCvF3seZo5x2d 4b+ZX00I2dif+PiCbwwdfShtGxi8koACYlHEhT3JuqwLZk14Ew9fJDwHCVCWbXC6CkM0 vS9mX7OFRWv0NEd/Zu7NxIKwEL3Y2Hka7wTaLZzFFMBjcOPOHKQEG1HwIn/dspFnHUWA CNuK6P1ChjbDcFpYmepdzc+mnwSzJRflKeslBn7MukjupYZZP3AFCgUuQfWk8apAZB66 bCbeznbZlZ3YG4qFHWgCAGYbShC1V4YIpfYJDBpfXZ5YfFbtesH+sOkRc8RPabAQ/N45 rClA== X-Forwarded-Encrypted: i=1; AJvYcCUuRegHbqsubO9Ck3cw1z12w/Yrw6nfFNRRYgE8JrdxK6muQMhHYdr5irDsVDfFTjDTVeb21aNLq3VSbW1GKpI4zqB6uY/n3m1DW3c2 X-Gm-Message-State: AOJu0YxgFxUH1gAGsISzuE9UJ2zSfBEbps1xGcdnRX4C0wjut31TcqCz xpfT0awtnzrS3VaQzzFY7ibta0WqIlkrnLaJi7H69/5a5mwq7xYxjQCPE+QtqzWaVSI40igvgsu Vs3ZDog== X-Google-Smtp-Source: AGHT+IHgRRHzENtJjdaIKJzPMb2H1HDZVK/Rf4u2rJiQyfph07pK93KyOLIPHnJjFuZcvCLU340y0vsp3u3Z X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:3510:b0:64b:5dc3:e4fe with SMTP id 00721157ae682-658ee699c87mr1323597b3.1.1720720835320; Thu, 11 Jul 2024 11:00:35 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:50 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 10/28] perf lock: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-lock.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 6efa9d646637..2c216427e929 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1933,22 +1933,21 @@ static bool force; static int __cmd_report(bool display_info) { int err =3D -EINVAL; - struct perf_tool eops =3D { - .attr =3D perf_event__process_attr, - .event_update =3D process_event_update, - .sample =3D process_sample_event, - .comm =3D perf_event__process_comm, - .mmap =3D perf_event__process_mmap, - .namespaces =3D perf_event__process_namespaces, - .tracing_data =3D perf_event__process_tracing_data, - .ordered_events =3D true, - }; + struct perf_tool eops; struct perf_data data =3D { .path =3D input_name, .mode =3D PERF_DATA_MODE_READ, .force =3D force, }; =20 + perf_tool__init(&eops, /*ordered_events=3D*/true); + eops.attr =3D perf_event__process_attr; + eops.event_update =3D process_event_update; + eops.sample =3D process_sample_event; + eops.comm =3D perf_event__process_comm; + eops.mmap =3D perf_event__process_mmap; + eops.namespaces =3D perf_event__process_namespaces; + eops.tracing_data =3D perf_event__process_tracing_data; session =3D perf_session__new(&data, &eops); if (IS_ERR(session)) { pr_err("Initializing perf session failed\n"); @@ -2069,15 +2068,7 @@ static int check_lock_contention_options(const struc= t option *options, static int __cmd_contention(int argc, const char **argv) { int err =3D -EINVAL; - struct perf_tool eops =3D { - .attr =3D perf_event__process_attr, - .event_update =3D process_event_update, - .sample =3D process_sample_event, - .comm =3D perf_event__process_comm, - .mmap =3D perf_event__process_mmap, - .tracing_data =3D perf_event__process_tracing_data, - .ordered_events =3D true, - }; + struct perf_tool eops; struct perf_data data =3D { .path =3D input_name, .mode =3D PERF_DATA_MODE_READ, @@ -2100,6 +2091,14 @@ static int __cmd_contention(int argc, const char **a= rgv) =20 con.result =3D &lockhash_table[0]; =20 + perf_tool__init(&eops, /*ordered_events=3D*/true); + eops.attr =3D perf_event__process_attr; + eops.event_update =3D process_event_update; + eops.sample =3D process_sample_event; + eops.comm =3D perf_event__process_comm; + eops.mmap =3D perf_event__process_mmap; + eops.tracing_data =3D perf_event__process_tracing_data; + session =3D perf_session__new(use_bpf ? NULL : &data, &eops); if (IS_ERR(session)) { pr_err("Initializing perf session failed\n"); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 343FE16FF4E for ; Thu, 11 Jul 2024 18:00:38 +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=1720720839; cv=none; b=PEDCiVbUPgDZNDBFY6jCa5qs+mzWK1DkYbJQwmwgyEphtniAGhb1ILtZs4GTNAtmLD0cFkn4OndRkN26yBkMJ/AhHtRttAwyYaGVUCBBESYlXLx0nDgJi1cygkvYi5XnvN/8Fx/umWF3ZZl9zNJwuf/7lLsoGk0h0OAH9X9CpWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720839; c=relaxed/simple; bh=5L2/QmV0UtQIb+mYzp5cKQ3gtaLl7JsRv/EFzdZAMCU=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=LZ4e2Fulal4tP2BP0TMVC40ukgsuDxEo5inQYZgoya9LBZyfUZgZaXsbgjdUJgP/uxBfeq/58lAPb48f9clJ8XooTqqIEkZZqvtCzG2AfFu9O0Ai9rY6gi8D7B4v49UZAjv1q4lMEbB28eLueBd9Egz1H+E6LT/WjEmcMOkOsC4= 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=WbunmfsA; 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="WbunmfsA" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e039fe0346eso2148274276.1 for ; Thu, 11 Jul 2024 11:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720837; x=1721325637; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=h8vxN+BliJztZySzkr/g5CS+2PgB0g7RSTmLzIMrgEM=; b=WbunmfsAH7SzMxu+o9d2M0xyzLO5sflMfJAipcsGaKFf/pZkx67eYFqm42TR42x7Mv ERv86jbSKBylN3Ybqq88RQj4/r8v/ihvhynz/TFy5olu2IJE0yTLpsvSLgFjGZxOlet2 dq9YIQS43eiEz9Kp0gvC/42krwzfMGiWAiIpfUmrG5UojObr3tj6ByvnTbIlhfGKpb7q 65pbQEMvhk3XnUt6o47TepdZ3BQD+vZWYKEcaI3Um5RTeoVAHm5tsVBsxUz+kQjHosr5 s+Mb5tV7gLaAzxlN3TTfDXyEs3NQUmhJln8+ToUF838M7Hmu/IawX0uINyEECyxLhwsv dumA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720837; x=1721325637; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h8vxN+BliJztZySzkr/g5CS+2PgB0g7RSTmLzIMrgEM=; b=O1TLGTpePrmOA/leEgGLG5fe5Qvfg9Ho5Pds9KP0ltlorSyGTmQMzgnH7rr6G90ftm +m8mXVyjOl1EZ5zxUlmHBODYdaoSQg9SMpBxbMso9msbEFww0KnWDLAfOxyuq8GA2vtt oT/sWh72fxmB7KQDvc+o8oJ+skNP8FrtNfaZ7V8nhR6nIHnTntk/MX1z3entfSrYl+mU uXs9GF5MZzwEsvjTJqhLMsiH7sUclwgBGR/58KA4dSbxtW0jtRt6fUsoAYdPS41UMnvu ByAmyp5LFoXPqak4O1ihkOIDvazPrDoRgtuu6gkridOYbKhzKU4GCpIAw8yNgPbAjy3N LCHw== X-Forwarded-Encrypted: i=1; AJvYcCVWX/Qf2yD9si5KBsNiPB32WwKM2EXha1ul2SUh54FYte7OOYVSImwZzdX0Zri2Gu6chNgVXTVYUoRDc+aqxPx6v2dY0CEzCwFwDooI X-Gm-Message-State: AOJu0YwFyCzFc/KZtmvxX6EaCponDWJNT0U4EoiUn0T5R1fuicBLWT4w Eh63pMKHpAovKVriJHumB2ifB9vXQ/Yb9ceC6739awnvLNjodPOwl22fEX/r4GVGL960+zf1ib+ AFV9y8w== X-Google-Smtp-Source: AGHT+IHI3dipL7Tp3GQH7MxH3mucgQeoKyx/ymoTPxvLOSdOaV57AwCmKrqrRNCKs1TjxRfG+nIlfE0jSUsa X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:2089:b0:e03:2bfe:40c9 with SMTP id 3f1490d57ef6-e041b032f48mr17980276.3.1720720837264; Thu, 11 Jul 2024 11:00:37 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:51 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 11/28] perf evlist: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-evlist.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c index 7117656939e7..818ab21c3f73 100644 --- a/tools/perf/builtin-evlist.c +++ b/tools/perf/builtin-evlist.c @@ -35,13 +35,13 @@ static int __cmd_evlist(const char *file_name, struct p= erf_attr_details *details .mode =3D PERF_DATA_MODE_READ, .force =3D details->force, }; - struct perf_tool tool =3D { - /* only needed for pipe mode */ - .attr =3D perf_event__process_attr, - .feature =3D process_header_feature, - }; + struct perf_tool tool; bool has_tracepoint =3D false; =20 + perf_tool__init(&tool, /*ordered_events=3D*/false); + /* only needed for pipe mode */ + tool.attr =3D perf_event__process_attr; + tool.feature =3D process_header_feature; session =3D perf_session__new(&data, &tool); if (IS_ERR(session)) return PTR_ERR(session); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 94FC6171079 for ; Thu, 11 Jul 2024 18:00:40 +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=1720720842; cv=none; b=lIsxwiUhYCr6P85+KXvJib18bMqOHocgOUg7nvINgHWq+gg7h8MCoeygRFdZSO6B+1vRQDlD4WlC/iSRU4mVB6EVYV7ePislx8tma2AwyzRpJ078e1i8uqvcAyDoIPcUPawhKU0zu0JxNWQS5wu7Ritm62m43hmwYg3zLcQj7e4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720842; c=relaxed/simple; bh=n//5b9kLUBxzTee5X6iEwJUArQuNUyNCVfEklgkgJ5M=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=emeELTug1xZGEQU+j2YA8xkhxKLHeWT/OQgpLZiiG9bbNnFhWAQsHJa66+/4TYPU5cfpDmoCJCRDEwfVTAHvRCi6AUqSjyLutbWUDPQUulPmnZR0CYl84hlHwaj45TqK/2p68LlUmlDUZzIROxFfF9uI5syMOki3RgtrX7VsZM4= 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=ykOTJylY; 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="ykOTJylY" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6501bac2d6aso13422747b3.0 for ; Thu, 11 Jul 2024 11:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720839; x=1721325639; 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=5Ff/gAGDG2aAEbUu/hDCKYzzmvI/uHVZRadY3JBl8Rs=; b=ykOTJylYM4kejbans6L9wi6z5noWr22pvllYU/L5bBt+1Oex1OE7WETxL92bae9lSF fujWywgWguB7zsstRZ4/O7HZm1zkVp6zQJTHj0U3sQnHQFGVeSgDz720xAqNrfHj8Ifv maEpqvIp/AMWFqhxlwDMsckdKZsFtzGC1ADcnI+RiVh/r1GJmfGA8uHrp4+GZ57IbAQo zcqDM6HFOudi2kOLM3YiGgJZ/KhSCcTZszrX38Wv45IKiJSd7A7udUsmePJg/hEIS3rd 5y53v1xEayH/fmbC3rfUh468Gz6c0vX5gy0fw1t04ljIk21wo18VpuFJSGO64+eC8Iam FzCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720839; x=1721325639; 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=5Ff/gAGDG2aAEbUu/hDCKYzzmvI/uHVZRadY3JBl8Rs=; b=mpKMJU3+hXLCgse7eief1wm2AzFZj1qAqjQYqgfVoNtKbMe3+kkgIgOBSByW7BCx/+ RL/8SMP2l1SzbQ4/gjlWnvZK0wtKcbWc8z/WzFBKJvPbCXEjgBzPnAQddnt0SGUx/nn9 xy9rcsi1ahXsIVYJjvOJjituVxd6+4ExDd3fgYDLnvGwiNmfsa6xILSH5mgT6tnvaZXM 6e5w0SKYrOzHTYBxqZhXN3UuFwuE1WTlzbc7uJ4JUAfBIt7zaVTtgTwmbaiM8snPChnX o3j557ISlNvaJKN612MRD2xu34JYL34dV4FZ0OBp1LmnOSmF4ogymeQYw3nlxlwzMX4R U9tw== X-Forwarded-Encrypted: i=1; AJvYcCWNfpkGczGnah2DMv5JKvBO8MB/V257cgJRBqlUOaxLje6Wc7JO+bRMiiojoJfnbqfwyXT5ruBvQUrbUBIXGgg6OVT2ooL5tvAXkPc9 X-Gm-Message-State: AOJu0Yyt/713rCd3aYPdy2Si1hV8a1T/9+VIwq9jU3JV+FPG42zvCJaA 9GvSRke/tA4Aq0I0n0jbilNeSe17sNvx/o9un4dEh1WONZpKk24FIkMusGjIDF13I0mk2JcXRjt bxEgRzg== X-Google-Smtp-Source: AGHT+IFj9eydv65A7J7SzzeWQzPfBnQ3Mr87UOA0hqpnZkLQstHLPEsb9+ha7vzF8KoEQHxSj3FAFxPIHkwL X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a0d:ea49:0:b0:64b:a38:31d0 with SMTP id 00721157ae682-65df50b328amr15277b3.4.1720720839402; Thu, 11 Jul 2024 11:00:39 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:52 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 12/28] perf record: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-record.c | 33 ++++++++++++++++++++------------- tools/perf/util/tool.c | 10 +++++----- tools/perf/util/tool.h | 6 ++++++ 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index e8677f9e1ccb..4b9309b4c07e 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -193,6 +193,15 @@ static const char *affinity_tags[PERF_AFFINITY_MAX] = =3D { "SYS", "NODE", "CPU" }; =20 +static int build_id__process_mmap(const struct perf_tool *tool, union perf= _event *event, + struct perf_sample *sample, struct machine *machine); +static int build_id__process_mmap2(const struct perf_tool *tool, union per= f_event *event, + struct perf_sample *sample, struct machine *machine); +static int process_timestamp_boundary(const struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine); + #ifndef HAVE_GETTID static inline pid_t gettid(void) { @@ -1458,7 +1467,7 @@ static int process_buildids(struct record *rec) * first/last samples. */ if (rec->buildid_all && !rec->timestamp_boundary) - rec->tool.sample =3D NULL; + rec->tool.sample =3D process_event_sample_stub; =20 return perf_session__process_events(session); } @@ -2386,6 +2395,16 @@ static int __cmd_record(struct record *rec, int argc= , const char **argv) signal(SIGUSR2, SIG_IGN); } =20 + perf_tool__init(tool, /*ordered_events=3D*/true); + tool->sample =3D process_sample_event; + tool->fork =3D perf_event__process_fork; + tool->exit =3D perf_event__process_exit; + tool->comm =3D perf_event__process_comm; + tool->namespaces =3D perf_event__process_namespaces; + tool->mmap =3D build_id__process_mmap; + tool->mmap2 =3D build_id__process_mmap2; + tool->itrace_start =3D process_timestamp_boundary; + tool->aux =3D process_timestamp_boundary; session =3D perf_session__new(data, tool); if (IS_ERR(session)) { pr_err("Perf session creation failed.\n"); @@ -3326,18 +3345,6 @@ static struct record record =3D { .ctl_fd_ack =3D -1, .synth =3D PERF_SYNTH_ALL, }, - .tool =3D { - .sample =3D process_sample_event, - .fork =3D perf_event__process_fork, - .exit =3D perf_event__process_exit, - .comm =3D perf_event__process_comm, - .namespaces =3D perf_event__process_namespaces, - .mmap =3D build_id__process_mmap, - .mmap2 =3D build_id__process_mmap2, - .itrace_start =3D process_timestamp_boundary, - .aux =3D process_timestamp_boundary, - .ordered_events =3D true, - }, }; =20 const char record_callchain_help[] =3D CALLCHAIN_RECORD_HELP diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c index cbd9b888bd73..a4ca16e5eefe 100644 --- a/tools/perf/util/tool.c +++ b/tools/perf/util/tool.c @@ -99,11 +99,11 @@ static int process_event_synth_event_update_stub(const = struct perf_tool *tool __ return 0; } =20 -static int process_event_sample_stub(const struct perf_tool *tool __maybe_= unused, - union perf_event *event __maybe_unused, - struct perf_sample *sample __maybe_unused, - struct evsel *evsel __maybe_unused, - struct machine *machine __maybe_unused) +int process_event_sample_stub(const struct perf_tool *tool __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_sample *sample __maybe_unused, + struct evsel *evsel __maybe_unused, + struct machine *machine __maybe_unused) { dump_printf(": unhandled!\n"); return 0; diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index 897c6c44b6b2..fb7e32d98dda 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -93,4 +93,10 @@ void perf_tool__fill_defaults(struct perf_tool *tool); =20 bool perf_tool__compressed_is_stub(const struct perf_tool *tool); =20 +int process_event_sample_stub(const struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample, + struct evsel *evsel, + struct machine *machine); + #endif /* __PERF_TOOL_H */ --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 8E8CD17165A for ; Thu, 11 Jul 2024 18:00:42 +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=1720720844; cv=none; b=NzOcMBlyaAZmqZqgbX7okGcQ4aFf+UPaFzflGhyVs39K5OAWCg9fe6N7FhChRunLFy6T6ZNRgQdrLNB7BGTD6aitYxnXXcOYmh02qZDpfu7LZNhuVdQEeOR05j0JAyh0ZWdEav+VjAZSlieohMfxHmxaQmOPRjvEC9p3PEPqVJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720844; c=relaxed/simple; bh=QyWrdcj/7yIk1kCDwEAAgyYccYi84Zy4FDV3Stu0DB8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=X5dO4VwWjwPgPlgDGi+EOU0Kh+i8ZxGGfs8jVgr3UMgJfvW5i6mRG+b0AhML4lvO54E/460fB2lohCKzA2EKxHREdTJuHW/CSqBuFM8BtSjE4tWbkupCKTFcNc22JQD64tcanflJw6/KScrg945+Zcf6lvnLqbp2J4NpBgF6rJU= 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=2FlNrWio; 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="2FlNrWio" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e03b3f48c65so1861056276.0 for ; Thu, 11 Jul 2024 11:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720842; x=1721325642; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=GLiukIuXpfj1RuwI+7tVJ3j4buaKUCfjcNd2gIIAnuE=; b=2FlNrWioZ6GI9cljTZm5U4jHQM8L1rnNABWMa43WiG1RxSGG4SkunOpD09phRnnP9K euph8Iu13xjNOQGjjbbbgbE8oKuM7sYzT6l3DrN5uRaRxSrK2Djgt1nMNLe4DhiYfaZk yU3FVrfRJEJW0PtspKgkackuTKZdxRrt7X1zWfBRHQKlh+wwNtvcBkPZzyZYJav9Y0EK jDUHf+2IFgM2n6kdhpulbmoU31pZpfwHH0FoNqLnNtT3siv/vVezSBgCSNvpZ8dHOXH4 jCGExJo1TEN7fF3dLGrPw0b5Ale9uNr7mxkjfps/+RHWpLtGtqBtAigFx+Ix7LAfIODZ /6nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720842; x=1721325642; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GLiukIuXpfj1RuwI+7tVJ3j4buaKUCfjcNd2gIIAnuE=; b=Ufssb+YLC+38w/fPPFXdDly6tUofs/gGrvjeSUA5UIl4W+debYv/fhh0Nz3yC2+eem 4o+HKm9aZIrAbvLpFwGkUzMbDddUcFpUaSz30HPAPJeByu2dUzY4z68nr7bg/5hwiv8s 2Q4y+xRejqgLwO6n1oxI/BGAnZ26Nq6XMCGVzNuufO78fiRI451N/Z4JlFxtlwv56gV2 dGJO+Vj7/O8RmVp527JEui1Cf38rxknmougS5Rm6Tq5iNWEY4FIuBYMfj/YVzQSIqeyQ wQE45jvNR8U/oCDlI5M1lPf28tS7dqj4x2lBtZpC+0SYuGgtoIkOlFbD8fuLu6ou3clK 5wNA== X-Forwarded-Encrypted: i=1; AJvYcCXF0b1KM+gtwizFs0XjmxnonmUNrj1fBBDKXIdHVkgzimvaHMzqrF7VrB12cGt0GgOYrwYsQSnXIcUYXl9AUsLhn/rhrfdlB7syvcaJ X-Gm-Message-State: AOJu0YxRuFuA0wja14OslZ9KcjNarqkzaxwR7my1V5RQ/oIwpSO+sDbj pcbw4/W6T4HEzbQqrc2ohTRexPLVENGlttVblnlFFAyaOmisz6JDsBF8MU/4YM79+9bQhLQHQfv BvE1bpA== X-Google-Smtp-Source: AGHT+IEXF5wj8ayTVT9jirmz9sHwimvl3fY+5kUcaEScOacOHrr5WKsgjJfB+7NPgApJ3Zze2HXsuC0tMBh0 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1002:b0:e02:b51f:ceac with SMTP id 3f1490d57ef6-e041b1415d3mr391043276.9.1720720841581; Thu, 11 Jul 2024 11:00:41 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:53 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 13/28] perf c2c: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-c2c.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 88c131d05186..cd2bd573bfc3 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -385,24 +385,6 @@ static int process_sample_event(const struct perf_tool= *tool __maybe_unused, goto out; } =20 -static struct perf_c2c c2c =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .lost =3D perf_event__process_lost, - .attr =3D perf_event__process_attr, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .auxtrace_error =3D perf_event__process_auxtrace_error, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, -}; - static const char * const c2c_usage[] =3D { "perf c2c {record|report}", NULL @@ -3070,6 +3052,19 @@ static int perf_c2c__report(int argc, const char **a= rgv) data.path =3D input_name; data.force =3D symbol_conf.force; =20 + perf_tool__init(&c2c.tool, /*ordered_events=3D*/true); + c2c.tool.sample =3D process_sample_event; + c2c.tool.mmap =3D perf_event__process_mmap; + c2c.tool.mmap2 =3D perf_event__process_mmap2; + c2c.tool.comm =3D perf_event__process_comm; + c2c.tool.exit =3D perf_event__process_exit; + c2c.tool.fork =3D perf_event__process_fork; + c2c.tool.lost =3D perf_event__process_lost; + c2c.tool.attr =3D perf_event__process_attr; + c2c.tool.auxtrace_info =3D perf_event__process_auxtrace_info; + c2c.tool.auxtrace =3D perf_event__process_auxtrace; + c2c.tool.auxtrace_error =3D perf_event__process_auxtrace_error; + c2c.tool.ordering_requires_timestamps =3D true; session =3D perf_session__new(&data, &c2c.tool); if (IS_ERR(session)) { err =3D PTR_ERR(session); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 2025 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E2B9171658 for ; Thu, 11 Jul 2024 18:00:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720846; cv=none; b=cMDqM7ZvD/1o0UAMxs4e476mm54e75JdVsjQwPPWy5YYpuIbiOzC3VJkK6klLfEJVR2YAjLhNJhV7UY42IEBSDkQUkrW4ipxVVZtbKNWTHraARSQEoSAW04yh9gwhsxkQhjZZhQkiVBxl+kVLwsM94dVkDje84TZRGwIo+8tE8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720846; c=relaxed/simple; bh=gdWytOna78avdV8ta1mlF796MEMlXufN3RbPM1j+MUo=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=avNSqge3bsUKYQ1zNsSR4zu5K0bXU+FGBuJ0BUHqVgAayz4KfijlOpRD++2AIJU6sPOalyLaY6PEf8CoZzlXiGKllRiNt0SVmtko3BqtTxT8/fCUFvVSm6sCnObAeaLCCvGRqQmYRT+MbG4EPZaDRXkWEHyc6griLYqx5qrmw74= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=XcXE+d54; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XcXE+d54" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e035949cc4eso2128147276.1 for ; Thu, 11 Jul 2024 11:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720843; x=1721325643; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=BgJSCF9yLnG02WKUg8SfX7odmyVBKa2lGRMN+iopItY=; b=XcXE+d54E/nI0W6uHdDcD7cyNaaCflJCceyJ/vJLLYDG9IDo/S3QYH5sMk8aUI6nHJ AX4MiYmGLhvBsuUNHiBjEVPRnd7NoMHqdtYbMQjO3/yrow7VEeNCkJW70xDx3Ux5DA4w Pw3RstYTx6rFs5p/7wSfp6TJiuT9JlCXYTFaUB8kqWMs6m8HitI3650rOreEdbNIHNKB BxK6DHj+e4gBM+v0OEDiLu/cNB+9Pk5QQ3dfMooE7YXfjoREzVi+WHDf02pi8sMcAevu xWuiPExgkVZ7LV15w2ANhH26e7UgmXK/gPiM4bXhl1DKpEgp0X1/B0mF/854pBNmxnM6 cLeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720843; x=1721325643; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BgJSCF9yLnG02WKUg8SfX7odmyVBKa2lGRMN+iopItY=; b=eMrgorFANtzJNTZ21PREeU5ltHBg/N6nUaPe6yy9HUdmv72abhkLLPy5GDQSzuXDMe eiZDclv//GxkCMoU3QW4UBj4G0DWLAcoUYCcBWxNpUN7aNqunaH78bDj1l/zaZdSqGwr RSkbn4eX8BtKOJsbaroGg1KcVFBfOC+/k8NaJFDq8Ce8t/Bk0uyGlGVnB6HR7qFsy53L 1KgbQu+P3Ta+dis7dFjQAk/H6TRYAyulRWq6GcDhNtocZyP3G43+NrqUFgkROFg/BqAV alrGWcc0h3JVnzhZ64MIdjhwW+9xRPFIAv/taLmnyuJ7mt58wzxXJkbQaO0TSES+9sE9 WI3Q== X-Forwarded-Encrypted: i=1; AJvYcCVGQI6OLO8ztsMi1aQB1K81/9j+qyXJ8UZVlV4lqo9CaMu6eiz0x/abAezcsrr4Dsz+jMtAn5kvatSlyGIhaAZnwxN8kP35ekZPuWfJ X-Gm-Message-State: AOJu0YwZtQ5aJdG9q3iikd4o+l9MJaesX1GZLZgt+pPzFewZtE5kFYnz Mbak795ghFCujrCGuiQl/7GfFUoZX6BzY6oBlb28zAXeYh1TzRFhBx4dHmUCNaOWV4Cg45bO8Ap R5tWEYQ== X-Google-Smtp-Source: AGHT+IGUZPma1/UNbVlFLgQNB3aw1ju3QFq7+jgs3bRCoCKdY1pYTS0J6J1QQ1ukZSK8z62+IBuYguGU+ptP X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:2386:b0:e03:9d57:57ee with SMTP id 3f1490d57ef6-e041b0545c2mr460225276.4.1720720843539; Thu, 11 Jul 2024 11:00:43 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:54 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-15-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 14/28] perf script: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-script.c | 65 +++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 394bce9f5338..b4fc2971335b 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -3899,38 +3899,7 @@ int cmd_script(int argc, const char **argv) const char *dlfilter_file =3D NULL; const char **__argv; int i, j, err =3D 0; - struct perf_script script =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .namespaces =3D perf_event__process_namespaces, - .cgroup =3D perf_event__process_cgroup, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .attr =3D process_attr, - .event_update =3D perf_event__process_event_update, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data =3D perf_event__process_tracing_data, -#endif - .feature =3D process_feature_event, - .build_id =3D perf_event__process_build_id, - .id_index =3D perf_event__process_id_index, - .auxtrace_info =3D perf_script__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .auxtrace_error =3D perf_event__process_auxtrace_error, - .stat =3D perf_event__process_stat_event, - .stat_round =3D process_stat_round_event, - .stat_config =3D process_stat_config_event, - .thread_map =3D process_thread_map_event, - .cpu_map =3D process_cpu_map_event, - .throttle =3D process_throttle_event, - .unthrottle =3D process_throttle_event, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, - }; + struct perf_script script =3D {}; struct perf_data data =3D { .mode =3D PERF_DATA_MODE_READ, }; @@ -4102,10 +4071,8 @@ int cmd_script(int argc, const char **argv) data.path =3D input_name; data.force =3D symbol_conf.force; =20 - if (unsorted_dump) { + if (unsorted_dump) dump_trace =3D true; - script.tool.ordered_events =3D false; - } =20 if (symbol__validate_sym_arguments()) return -1; @@ -4296,6 +4263,34 @@ int cmd_script(int argc, const char **argv) use_browser =3D 0; } =20 + perf_tool__init(&script.tool, !unsorted_dump); + script.tool.sample =3D process_sample_event; + script.tool.mmap =3D perf_event__process_mmap; + script.tool.mmap2 =3D perf_event__process_mmap2; + script.tool.comm =3D perf_event__process_comm; + script.tool.namespaces =3D perf_event__process_namespaces; + script.tool.cgroup =3D perf_event__process_cgroup; + script.tool.exit =3D perf_event__process_exit; + script.tool.fork =3D perf_event__process_fork; + script.tool.attr =3D process_attr; + script.tool.event_update =3D perf_event__process_event_update; +#ifdef HAVE_LIBTRACEEVENT + script.tool.tracing_data =3D perf_event__process_tracing_data; +#endif + script.tool.feature =3D process_feature_event; + script.tool.build_id =3D perf_event__process_build_id; + script.tool.id_index =3D perf_event__process_id_index; + script.tool.auxtrace_info =3D perf_script__process_auxtrace_info; + script.tool.auxtrace =3D perf_event__process_auxtrace; + script.tool.auxtrace_error =3D perf_event__process_auxtrace_error; + script.tool.stat =3D perf_event__process_stat_event; + script.tool.stat_round =3D process_stat_round_event; + script.tool.stat_config =3D process_stat_config_event; + script.tool.thread_map =3D process_thread_map_event; + script.tool.cpu_map =3D process_cpu_map_event; + script.tool.throttle =3D process_throttle_event; + script.tool.unthrottle =3D process_throttle_event; + script.tool.ordering_requires_timestamps =3D true; session =3D perf_session__new(&data, &script.tool); if (IS_ERR(session)) return PTR_ERR(session); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 C8A36172BAD for ; Thu, 11 Jul 2024 18:00:46 +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=1720720848; cv=none; b=AjCosfFCY/rRytNqapmKSbtnmcreS+/QIuN/v78CIr9QzvsyTtk8yT1TCjXdv8y0ElFnNsR45RIttOdJzJ/Xfht7+6rIuYxX9vN2mNM4BUQy0vn2NtBY/HX5kryeyfxnKkrIK7ZmmXzhPH3LlouAOCBy9UTP1zOBw4GmttdfIEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720848; c=relaxed/simple; bh=4jN3iUFdg2T8oVK3z25P8DkRtidUU7UFK1/cu+ERcs0=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=cnSOWAHdY79w5+rcm9SDaxZLNzsr5uiw/fwlm3Y6A1qjkk0znOPtNE+ynZoU9YN9jYouQONkm9II/MzDQmigQETdexTtMg+A71IX4p3UnffcMYfIABH97ajXSB6Wzwr2LweEu0CDyc+CBP1bBmigtkroJKTE0o1pP1LaAIj5pko= 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=YDF7UWpM; 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="YDF7UWpM" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e03c68c7163so2024286276.0 for ; Thu, 11 Jul 2024 11:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720846; x=1721325646; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=+Ae5Vk3XcnDdaj5BKYKsQnIS/haF5dLJg944D3m7A54=; b=YDF7UWpM+JnXk5dIMxmLuvQStF1JT103JTGiYA1niuMgNzmcWKciwHXKX6SUa1ZUMC mqbhsgayhbl1Y+wQBx2okNwgWKQAv3UMYTBOyBW3fsNp7s51m5fNw8fW6l68ERZegoLk 27KaLwt4GjBYahR2v2lHbix44M47vEBkST2z7de6pIhO9cxtVnDdleg7bDKYB+7GLik6 7i0DoKIi3x6SYnALliX12NbWCJXUaZCUATh+xvQ1c0kPgtsbaxbEwJ58D0x4YxTAqM3/ U115yFgvtg+ZXN+9tg20OGq9OMxpM9DoPOyg9sNI2XgY9uqygxd5aL2gTZtJUYwUCmLV 6OtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720846; x=1721325646; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+Ae5Vk3XcnDdaj5BKYKsQnIS/haF5dLJg944D3m7A54=; b=DC51YK7Fpbo/zSgC4dsjvWCfnqjQA2EtYWlYH4F/6Swh9RAyk4Qm0dFyxfyf8lLXD8 NSfb1M5IaMTG0u1fNinnkUFqDofxFsUaQr2uQonRCtoq47oLh9xhnx9ZJLJzXvtZF9at crclPyvKdTGdY82BMW1bpICv2FLKu264P8Jmo0cXfQJFDT64AyklhpDecsh30jwNOPj+ II2G+c8rcLh7OWz5u94aDUdpL4xtKV3f7f1yW/ARr/B5S9ZvW3F+C45cjy7N90fHZIHh J7wO05JqPGiXljr8jL2EkniLoJGlSrNKDGXgoAgfUNqW3ipGSxmR77kDzGmDCYH1O2nr CD7w== X-Forwarded-Encrypted: i=1; AJvYcCWO+jTvQ0Z4gMqkNJ/lqAEX4gNgCyaCJWfFl/KWOYvTVvF9iFWWKjmapBsPJxPo5nXeFaq401XFzUp+dWGe1smVlE2Ok6xfdcTuZ8jn X-Gm-Message-State: AOJu0YxG2cB6Q+zxGvCvhgv3YZ5hl5hKWbxawBKAu5nR8ShPzyfrlJdf yYl6xxpSZatUj2IC8Bh7X13o3Lgei2tBFawOVNkeIrn3OrONAMzizdHyohZD8fLcWV55aUWQx3J m3HnSdw== X-Google-Smtp-Source: AGHT+IHVhenVRnd5F5tnfG6kCLAubJrvmicfzrrx2Otspjm5CzZecpN6HNk6oOjRDCkpD1S2I42nDbp5QdCI X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1247:b0:e05:6840:178a with SMTP id 3f1490d57ef6-e0568401c6amr349237276.2.1720720845858; Thu, 11 Jul 2024 11:00:45 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:55 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 15/28] perf inject: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-inject.c | 89 +++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 47 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index be74e2bf1f00..2866756d5060 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -2165,46 +2165,6 @@ static int __cmd_inject(struct perf_inject *inject) int cmd_inject(int argc, const char **argv) { struct perf_inject inject =3D { - .tool =3D { - .sample =3D perf_event__repipe_sample, - .read =3D perf_event__repipe_sample, - .mmap =3D perf_event__repipe, - .mmap2 =3D perf_event__repipe, - .comm =3D perf_event__repipe, - .namespaces =3D perf_event__repipe, - .cgroup =3D perf_event__repipe, - .fork =3D perf_event__repipe, - .exit =3D perf_event__repipe, - .lost =3D perf_event__repipe, - .lost_samples =3D perf_event__repipe, - .aux =3D perf_event__repipe, - .itrace_start =3D perf_event__repipe, - .aux_output_hw_id =3D perf_event__repipe, - .context_switch =3D perf_event__repipe, - .throttle =3D perf_event__repipe, - .unthrottle =3D perf_event__repipe, - .ksymbol =3D perf_event__repipe, - .bpf =3D perf_event__repipe, - .text_poke =3D perf_event__repipe, - .attr =3D perf_event__repipe_attr, - .event_update =3D perf_event__repipe_event_update, - .tracing_data =3D perf_event__repipe_op2_synth, - .finished_round =3D perf_event__repipe_oe_synth, - .build_id =3D perf_event__repipe_op2_synth, - .id_index =3D perf_event__repipe_op2_synth, - .auxtrace_info =3D perf_event__repipe_op2_synth, - .auxtrace_error =3D perf_event__repipe_op2_synth, - .time_conv =3D perf_event__repipe_op2_synth, - .thread_map =3D perf_event__repipe_op2_synth, - .cpu_map =3D perf_event__repipe_op2_synth, - .stat_config =3D perf_event__repipe_op2_synth, - .stat =3D perf_event__repipe_op2_synth, - .stat_round =3D perf_event__repipe_op2_synth, - .feature =3D perf_event__repipe_op2_synth, - .finished_init =3D perf_event__repipe_op2_synth, - .compressed =3D perf_event__repipe_op4_synth, - .auxtrace =3D perf_event__repipe_auxtrace, - }, .input_name =3D "-", .samples =3D LIST_HEAD_INIT(inject.samples), .output =3D { @@ -2269,6 +2229,7 @@ int cmd_inject(int argc, const char **argv) "perf inject []", NULL }; + bool ordered_events; =20 if (!inject.itrace_synth_opts.set) { /* Disable eager loading of kernel symbols that adds overhead to perf in= ject. */ @@ -2333,7 +2294,47 @@ int cmd_inject(int argc, const char **argv) if (strcmp(inject.input_name, "-")) repipe =3D false; } - + ordered_events =3D inject.jit_mode || inject.sched_stat || + (inject.build_ids && !inject.build_id_all); + perf_tool__init(&inject.tool, ordered_events); + inject.tool.sample =3D perf_event__repipe_sample; + inject.tool.read =3D perf_event__repipe_sample; + inject.tool.mmap =3D perf_event__repipe; + inject.tool.mmap2 =3D perf_event__repipe; + inject.tool.comm =3D perf_event__repipe; + inject.tool.namespaces =3D perf_event__repipe; + inject.tool.cgroup =3D perf_event__repipe; + inject.tool.fork =3D perf_event__repipe; + inject.tool.exit =3D perf_event__repipe; + inject.tool.lost =3D perf_event__repipe; + inject.tool.lost_samples =3D perf_event__repipe; + inject.tool.aux =3D perf_event__repipe; + inject.tool.itrace_start =3D perf_event__repipe; + inject.tool.aux_output_hw_id =3D perf_event__repipe; + inject.tool.context_switch =3D perf_event__repipe; + inject.tool.throttle =3D perf_event__repipe; + inject.tool.unthrottle =3D perf_event__repipe; + inject.tool.ksymbol =3D perf_event__repipe; + inject.tool.bpf =3D perf_event__repipe; + inject.tool.text_poke =3D perf_event__repipe; + inject.tool.attr =3D perf_event__repipe_attr; + inject.tool.event_update =3D perf_event__repipe_event_update; + inject.tool.tracing_data =3D perf_event__repipe_op2_synth; + inject.tool.finished_round =3D perf_event__repipe_oe_synth; + inject.tool.build_id =3D perf_event__repipe_op2_synth; + inject.tool.id_index =3D perf_event__repipe_op2_synth; + inject.tool.auxtrace_info =3D perf_event__repipe_op2_synth; + inject.tool.auxtrace_error =3D perf_event__repipe_op2_synth; + inject.tool.time_conv =3D perf_event__repipe_op2_synth; + inject.tool.thread_map =3D perf_event__repipe_op2_synth; + inject.tool.cpu_map =3D perf_event__repipe_op2_synth; + inject.tool.stat_config =3D perf_event__repipe_op2_synth; + inject.tool.stat =3D perf_event__repipe_op2_synth; + inject.tool.stat_round =3D perf_event__repipe_op2_synth; + inject.tool.feature =3D perf_event__repipe_op2_synth; + inject.tool.finished_init =3D perf_event__repipe_op2_synth; + inject.tool.compressed =3D perf_event__repipe_op4_synth; + inject.tool.auxtrace =3D perf_event__repipe_auxtrace; inject.session =3D __perf_session__new(&data, repipe, output_fd(&inject), &inject.tool); @@ -2372,7 +2373,6 @@ int cmd_inject(int argc, const char **argv) * mmaps. We cannot generate the buildid hit list and * inject the jit mmaps at the same time for now. */ - inject.tool.ordered_events =3D true; inject.tool.ordering_requires_timestamps =3D true; if (known_build_ids !=3D NULL) { inject.known_build_ids =3D @@ -2385,15 +2385,10 @@ int cmd_inject(int argc, const char **argv) } } =20 - if (inject.sched_stat) { - inject.tool.ordered_events =3D true; - } - #ifdef HAVE_JITDUMP if (inject.jit_mode) { inject.tool.mmap2 =3D perf_event__jit_repipe_mmap2; inject.tool.mmap =3D perf_event__jit_repipe_mmap; - inject.tool.ordered_events =3D true; inject.tool.ordering_requires_timestamps =3D true; /* * JIT MMAP injection injects all MMAP events in one go, so it --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 EB8CA1741CC for ; Thu, 11 Jul 2024 18:00:48 +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=1720720850; cv=none; b=TBBPOhLGxRf3rOr9QmPY/WAC+sX0HMJJ+jOoFinSowCf1Vi90C5iZ30aEST3MPw4so05oK6/EbmGOcLdCoFkA3Md0rK6VD8VNenDVbXkOQwjTFFkKtl4fMkShs5wg8j2RSt+NXdcNu57RQkjJ2tmcaihIRrzCrBuLxQesblCXZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720850; c=relaxed/simple; bh=Poyvi9HGQwQC12qF/8SGE3BV1oK/lWq58PuPKRxVztA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=dEsH3vllyJ0xqV50G7Y+YmxVkCfRXhaliz65PddeIifR2v2Y80ceZjSrzFU084g/AgMz59l4HBY2bwU+7bS4HxdfqOj5BVcLS4M4WA1xNakjIY6dVHXba8otYVVTK1btiEy+EGhVwd0kvqQ9ejb0V37KvB4e91D/uLOutX9lcvQ= 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=mqZdmlmt; 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="mqZdmlmt" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e05600ade22so2354629276.1 for ; Thu, 11 Jul 2024 11:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720848; x=1721325648; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=QTSkE2wJ/0ArGbZAlv+dCStory8B9jtqpGvumW8ARXs=; b=mqZdmlmtTRksASY8sGwnMjZqJBv18zosDKEGMjsUA3Oa299TFariNkPYHBlZblBh/A JYkb1B4S3kFCd+gR0Rgies5QNlmUD5M0cYt+JvmGx6y+Drdw6iR24nncvJd/mIp/5+ba UgEpuT+U7I8zmJAHAOJWIS70q1rG24RkWdEBnQDXzxd7nIqYmEtEBO9xvM5FO+nzQZZX 3tNhPvWddAIGJve7cmzsJc8Y0OfgcskDEf27CvavSXipj3qI4qfMWwbMjnRG+CGsp95j /C2WS0/0pOXyWxEHMLrppJIfzud94rtrLJUQ/qpow3HJWdeqrHk7FfS/t7enuBA/NkgT dTjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720848; x=1721325648; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QTSkE2wJ/0ArGbZAlv+dCStory8B9jtqpGvumW8ARXs=; b=mfuN4b2LtBsZvr8/S1aCrfwN48RGh0mGE7eAM9xycLM2soIOnNtXUrQjeDBrIFYF/F joOaGTJB6B0SGYQvIaEC2Ax4oih3ioRlW/OJC86XjPzxKigtvz8LIGJLmXpEgxzkjrM3 7hNBrxx47ZvNHu6v3zstmp1TzO76/zYjPeqbTy57eGar01LqRYNZWJdxqwtgxuGqJVXS 94T+EwUUaWmaMK04OeZma6yAFg0l9YbLI7+e+6ODOv112dgR9blFJdRdA9aQLzm+iBwX MWzPCDK0k0DyNiLAXSzKabeyGQw81eFZxkDjoqINI6aLKh/Qw3ANZxKliliyafPm6a/z 6yQQ== X-Forwarded-Encrypted: i=1; AJvYcCWd3tyw9TEUywZSkFi+n5Lzrxy7gt0WR5w45Lr8WLg03gNlKxkfDa+cFU268HUreZRwQuQB4yewYN9Nx2tCTkZmSwukOlQDskGVNDLT X-Gm-Message-State: AOJu0YwLBXIMo3hDk+Wu5I8u52Efeyaeb9NkYO0LM2Aiy4S61c2WpK9u ASh6CxP0MNsEUezXL1s+opXgprXwOMF3QHJvqZlCcKgcYObA60skjktNQXPN5q/zQCg1Pb6wIVN hh6ktgA== X-Google-Smtp-Source: AGHT+IGlt20vZYur011SdPu6+QS+oJZqOUoXE1o+BRrQgv2s0bzDCcgJLzE/EenlRtLxPWLHv7UOmrxEaNS4 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a25:7d42:0:b0:e03:61bb:6032 with SMTP id 3f1490d57ef6-e058a47ba0emr1176276.1.1720720848062; Thu, 11 Jul 2024 11:00:48 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:56 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 16/28] perf report: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-report.c | 55 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index c402d9b3dca6..cd5caf1c974c 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -799,7 +799,7 @@ static int process_attr(const struct perf_tool *tool __= maybe_unused, =20 static void stats_setup(struct report *rep) { - memset(&rep->tool, 0, sizeof(rep->tool)); + perf_tool__init(&rep->tool, /*ordered_events=3D*/false); rep->tool.attr =3D process_attr; rep->tool.sample =3D count_sample_event; rep->tool.lost_samples =3D count_lost_samples_event; @@ -817,8 +817,7 @@ static int stats_print(struct report *rep) =20 static void tasks_setup(struct report *rep) { - memset(&rep->tool, 0, sizeof(rep->tool)); - rep->tool.ordered_events =3D true; + perf_tool__init(&rep->tool, /*ordered_events=3D*/true); if (rep->mmaps_mode) { rep->tool.mmap =3D perf_event__process_mmap; rep->tool.mmap2 =3D perf_event__process_mmap2; @@ -1272,30 +1271,6 @@ int cmd_report(int argc, const char **argv) NULL }; struct report report =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .namespaces =3D perf_event__process_namespaces, - .cgroup =3D perf_event__process_cgroup, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .lost =3D perf_event__process_lost, - .read =3D process_read_event, - .attr =3D process_attr, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data =3D perf_event__process_tracing_data, -#endif - .build_id =3D perf_event__process_build_id, - .id_index =3D perf_event__process_id_index, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .event_update =3D perf_event__process_event_update, - .feature =3D process_feature_event, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, .max_stack =3D PERF_MAX_STACK_DEPTH, .pretty_printing_style =3D "normal", .socket_filter =3D -1, @@ -1477,6 +1452,7 @@ int cmd_report(int argc, const char **argv) }; int ret =3D hists__init(); char sort_tmp[128]; + bool ordered_events =3D true; =20 if (ret < 0) goto exit; @@ -1531,7 +1507,7 @@ int cmd_report(int argc, const char **argv) report.tasks_mode =3D true; =20 if (dump_trace && report.disable_order) - report.tool.ordered_events =3D false; + ordered_events =3D false; =20 if (quiet) perf_quiet_option(); @@ -1562,6 +1538,29 @@ int cmd_report(int argc, const char **argv) symbol_conf.skip_empty =3D report.skip_empty; =20 repeat: + perf_tool__init(&report.tool, ordered_events); + report.tool.sample =3D process_sample_event; + report.tool.mmap =3D perf_event__process_mmap; + report.tool.mmap2 =3D perf_event__process_mmap2; + report.tool.comm =3D perf_event__process_comm; + report.tool.namespaces =3D perf_event__process_namespaces; + report.tool.cgroup =3D perf_event__process_cgroup; + report.tool.exit =3D perf_event__process_exit; + report.tool.fork =3D perf_event__process_fork; + report.tool.lost =3D perf_event__process_lost; + report.tool.read =3D process_read_event; + report.tool.attr =3D process_attr; +#ifdef HAVE_LIBTRACEEVENT + report.tool.tracing_data =3D perf_event__process_tracing_data; +#endif + report.tool.build_id =3D perf_event__process_build_id; + report.tool.id_index =3D perf_event__process_id_index; + report.tool.auxtrace_info =3D perf_event__process_auxtrace_info; + report.tool.auxtrace =3D perf_event__process_auxtrace; + report.tool.event_update =3D perf_event__process_event_update; + report.tool.feature =3D process_feature_event; + report.tool.ordering_requires_timestamps =3D true; + session =3D perf_session__new(&data, &report.tool); if (IS_ERR(session)) { ret =3D PTR_ERR(session); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 24E5217622D for ; Thu, 11 Jul 2024 18:00:51 +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=1720720852; cv=none; b=UkKzDcvxkmTryrtimtkL3Nw8CRM/M5thE8qIDGFc12W4URe44H3PhfE9rpl3O5bjonV3fqJRU60L/zvIH7DvuEHau7EI6H4ZW/ya5zEIY0SQsd3eZQiLZzv5xEtZtFeH9fmS7WqbcOumXrl8x9y3byeYmfTv7VVhDWCONLS+jXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720852; c=relaxed/simple; bh=Oatp9vP9864WSMM6h8L2eaSDz2osyW3W6s5tTUlCsXc=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=m3U7P5iTiSSD/iDuAoYosM9a74WfvnCxMyT6nOazZ9MG4kdI6Z9U+buwJNJmCuj0uvJLnPPQfsL8OpVqE7dgHGs59D9YgbMBmkA1pWKGxSw4Q1jocIENpyCWW/cvrZUZ3mSpuCjYkCFOFCWCLo/HkIyR/TcDXDqbVzfWCynLbUY= 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=XQ+EHzBs; 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="XQ+EHzBs" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e039fe0346eso2148878276.1 for ; Thu, 11 Jul 2024 11:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720850; x=1721325650; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=GhKzAhRYOz6Ff/7gM3raH2p2+7D3XZwc5l/hw9g7Qeo=; b=XQ+EHzBsqiEcyC1OLV/z6kbr3tYYMGObVGtYoVNXSJEn4JGBMNUHFolsOsa/v6O/Ao pJmhk/BUYUpkU/Gi/iDDK+X/ucQjHaYCUSFv2D6Xwct/nlvxemA0gXNp3PyJ8cBQRbHa viJAcHRsoTwea0jNxa6sEIKZqvrArsxfgHSRMMXOM34WIiPfM07IqqImHpaQOoxBDLUM C/iwqzlSCKpHoy/3fDMe9N6SFTL8fas3dMPfBsVfm6WE9l8HODMhwHKRhbWlTO0ER++O 4zNg11iOSNNYZShnbvXEVyI+scqGKb0wUuEgMl/nz2jIriYnu2yZ5peGmN6612U7estA w83Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720850; x=1721325650; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GhKzAhRYOz6Ff/7gM3raH2p2+7D3XZwc5l/hw9g7Qeo=; b=bAJ9oS+KebqB8RXdc51kYYQUSapIR4o+Kl7BL6WqHCOWUgEK8tsGn+SpqlGPbUj55E zC2g3hhq7158xiyMl2GeIcPLbsX9EOArOuxBrMJlZ1Hj1fjnEl4ZUjUQW3ZjYqpzZ3VY kIFkUrRAVhEluyBwdsNCeRlwTuUW2hcODs48i+QLAhgm1Vir5/0ZH+NejUDbOwiIAFiu mx4p03NA8Jp2zbyoMXig6z5LrvlrxqTNgh0WZxt+p5UOFwwMmnyWE2N8dU2z527DkLdW 66emAWFIrqBAkVby5YUN8AGpf+8DuN5nRcSI5XtqegLg6ZDnKCNnF+tZQ92wMXxM9IPt 04cg== X-Forwarded-Encrypted: i=1; AJvYcCXE8N6Wy6/X6AfgawzA9CKHCaBoRfSAEEFhYS7k0ot1Of3wKZlvgAaLRI9+iqyHqW+q2c+o22K4RUdiK5baa63RkoSwq9X+5FkisGJP X-Gm-Message-State: AOJu0YxyQ0CfO/+Wcbw2ejprPr3/KiBBZohkyXrcRZbEtnU1XAaBCOB9 skKRHzkr5gBoKsg4CCh3nxDiJZmBCkhdIRLv0/6zYMjqwssgqnEzg7KCZECG4zDLti9UKNwb8OD Y665FDA== X-Google-Smtp-Source: AGHT+IFqVvherAEk1x3Ir8n4fHhcFmi1xD/c2UbKwwjpP39A7XPMyOqoevAXhv8slX5yfHAkD3bxc1fO1Qwh X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:274a:b0:e03:2f8e:9d81 with SMTP id 3f1490d57ef6-e041af3b67amr47129276.0.1720720850095; Thu, 11 Jul 2024 11:00:50 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:57 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 17/28] perf stat: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-stat.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index d460c46f15fd..a3d77a55d17f 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2271,15 +2271,6 @@ static const char * const stat_report_usage[] =3D { }; =20 static struct perf_stat perf_stat =3D { - .tool =3D { - .attr =3D perf_event__process_attr, - .event_update =3D perf_event__process_event_update, - .thread_map =3D process_thread_map_event, - .cpu_map =3D process_cpu_map_event, - .stat_config =3D process_stat_config_event, - .stat =3D perf_event__process_stat_event, - .stat_round =3D process_stat_round_event, - }, .aggr_mode =3D AGGR_UNSET, .aggr_level =3D 0, }; @@ -2322,6 +2313,15 @@ static int __cmd_report(int argc, const char **argv) perf_stat.data.path =3D input_name; perf_stat.data.mode =3D PERF_DATA_MODE_READ; =20 + perf_tool__init(&perf_stat.tool, /*ordered_events=3D*/false); + perf_stat.tool.attr =3D perf_event__process_attr; + perf_stat.tool.event_update =3D perf_event__process_event_update; + perf_stat.tool.thread_map =3D process_thread_map_event; + perf_stat.tool.cpu_map =3D process_cpu_map_event; + perf_stat.tool.stat_config =3D process_stat_config_event; + perf_stat.tool.stat =3D perf_event__process_stat_event; + perf_stat.tool.stat_round =3D process_stat_round_event; + session =3D perf_session__new(&perf_stat.data, &perf_stat.tool); if (IS_ERR(session)) return PTR_ERR(session); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 55B6B172BAD for ; Thu, 11 Jul 2024 18:00:53 +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=1720720854; cv=none; b=DdDeT1eMqSS0ypPjg40JEgVDzGtMlYDKjC1LP4PrdOLj5drqvHwrFgBn2uJLWBvB5btcRvX79/cWQ95587tDU6bWQ9+BGDF1fUnDRhidNQ/7eUizBVUBx25j0VYLX+ytHziFmxsrbZYzPKgMJ2TefS9kklg+rGq+8Kt3U3mVm6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720854; c=relaxed/simple; bh=qWVb8s7IPdoN6VP7CoH6NHZGVGFRy7E/MCr32tMRu8Y=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=fDgw9zYpoDCeFBmH7TC4XtWb+PMBZLU3bN+LZiuNtnWJrQdJ8qsZzfnOFS6kePuk8vF9MAyEzPIEiowgBta3C+u+mJ5Fg2j2W9JO9ZFOc/wl2suvUa08oPu1OYFc4tr3527uev7EKZmYQO1yey19Q15TTOSiyIvY+L1pI9BO3Uc= 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=NUQTZEMr; 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="NUQTZEMr" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dfa73db88dcso2101074276.0 for ; Thu, 11 Jul 2024 11:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720852; x=1721325652; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=mHHBS2O6oNY6SeiT+OH+p80VI/Bl4EiQ8pJoP1UpZWA=; b=NUQTZEMrpW+YMgk4aLsq9CDPcjHsFI/sJKcdCJN2OdHZl6cb/L+hV3fHCl5D2pr7Wy K1FMax47ygwQ/qD0slxaDULQbqT6gXn8BEvb8n9/ttYCU16pTlbaAzSEVX6xrazxho79 yMBy0DQWI+ufEHDt73tT5Cb6Z9CnXt4bqF51pWYkuaRt/vdVAuKcxmAvbyCI0D+NnNMD pDZ1GwvbzpQ786kdqNqVYBCe+B+V+cdY6mADxQOaTuyd3wVx7m1PiS1k7MpyAItTFySF 9pe7NALJo2QEhI+EceUFj3HyXHHMQ0gflfWjnB2YQ7hncieOhLvpCK+aIZZ5TaQseDPI kDDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720852; x=1721325652; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mHHBS2O6oNY6SeiT+OH+p80VI/Bl4EiQ8pJoP1UpZWA=; b=HQVmLiFJaF7ZeC5a5LSE1TfJHJtwX0Nu559pUty9cMclhzeyOVCgUtPiXjxQ3kcPSq qpfM7BdCllqFrtTfAMHD5m10mtarmXAElmZvKr2OF6RD0jmIwEYW1K1EyfIdNzkTcVHa Oqg1imj4AsivdL9Cr07CxJaGAo5JS9MWg/3dzOmIdl7m6XnY0L+mOVx64GvUNXE07Ce7 sMrrHuN/GkuwLPprdMsNmpx+Lhp02EhPdMKkdYsQnULXGsgXuK7o4LmwoAcXc38Wqorn XMWuxWwbeqMagDjkN+bEepomKTApJGho0r5qnraD271y6OM/RVmUlUGr9B7SSzN+XPp1 1l3A== X-Forwarded-Encrypted: i=1; AJvYcCWbfCpcX9+LWb6lKd+gKDHWOKhJFz5QD4KBt3alCrx9K7IV8WH9wLrTTtxA4ihF2UQs1ZOhwRYgjFiCPN4+Bd4Tio834BH3wu0DE/bx X-Gm-Message-State: AOJu0YyAQmyr2HbjcVySETf3uczadIGT3y0bvI2TYCHUPGXOozsiUh5e vX+fX7sOhgf/Rs5uEwV6WiL39kSPtT7/mfH9ynDW/elSUf0yRTVU3Lnc4nPbIoOe9GNG8mZwqXS VK9mChQ== X-Google-Smtp-Source: AGHT+IGqpkWSNHuIk6znTjQKp37a4qhNUCcyhSSKbaeHKidGnzOJPe4kpolhyZ0aaZjRKcwzNmoatuj2V+U4 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1507:b0:e03:5b06:6db2 with SMTP id 3f1490d57ef6-e041b0347b7mr21103276.3.1720720852509; Thu, 11 Jul 2024 11:00:52 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:58 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 18/28] perf annotate: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-annotate.c | 42 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index c0685d2c8de1..598ab854b9f3 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -686,28 +686,7 @@ static const char * const annotate_usage[] =3D { =20 int cmd_annotate(int argc, const char **argv) { - struct perf_annotate annotate =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .namespaces =3D perf_event__process_namespaces, - .attr =3D perf_event__process_attr, - .build_id =3D perf_event__process_build_id, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data =3D perf_event__process_tracing_data, -#endif - .id_index =3D perf_event__process_id_index, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .feature =3D process_feature_event, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, - }; + struct perf_annotate annotate =3D {}; struct perf_data data =3D { .mode =3D PERF_DATA_MODE_READ, }; @@ -864,6 +843,25 @@ int cmd_annotate(int argc, const char **argv) =20 data.path =3D input_name; =20 + perf_tool__init(&annotate.tool, /*ordered_events=3D*/true); + annotate.tool.sample =3D process_sample_event; + annotate.tool.mmap =3D perf_event__process_mmap; + annotate.tool.mmap2 =3D perf_event__process_mmap2; + annotate.tool.comm =3D perf_event__process_comm; + annotate.tool.exit =3D perf_event__process_exit; + annotate.tool.fork =3D perf_event__process_fork; + annotate.tool.namespaces =3D perf_event__process_namespaces; + annotate.tool.attr =3D perf_event__process_attr; + annotate.tool.build_id =3D perf_event__process_build_id; +#ifdef HAVE_LIBTRACEEVENT + annotate.tool.tracing_data =3D perf_event__process_tracing_data; +#endif + annotate.tool.id_index =3D perf_event__process_id_index; + annotate.tool.auxtrace_info =3D perf_event__process_auxtrace_info; + annotate.tool.auxtrace =3D perf_event__process_auxtrace; + annotate.tool.feature =3D process_feature_event; + annotate.tool.ordering_requires_timestamps =3D true; + annotate.session =3D perf_session__new(&data, &annotate.tool); if (IS_ERR(annotate.session)) return PTR_ERR(annotate.session); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 CDC1817799B for ; Thu, 11 Jul 2024 18:00:55 +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=1720720857; cv=none; b=dyPSrQTbfsZIHCC30MdagQnhQIgXB8Uuk1JOzW++vJ0qQYHH4sHUgwS5XVaIH8dYCkh6M528AZ2OBo2p/UTJ6Xp4XLlJnyKnC5i5dzly8NlcIuEXlvCOCdXlcKbI18ktl+2uDH7Hi8miLwvgZR0xZa9k3q9DzsTkFj9xr+rMZzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720857; c=relaxed/simple; bh=gNOBCSXUt6q2RNMyq4ocRalcmgQ3v89szoAVlhw4o0U=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=kRxQIVvNRfej5PbxGtOJrn78/IiY2cAOh3XuZPY9alBiMfdzUBYplf+Uii3dVTdVlljxd1xyA3vDe9bVLaDcg8ZMm/t6821Q6LwhYx81t2cjWFghyCxh8QjsZBQ9Ngr/HaHp850JGvDNsEsK9UhM2pSGjHQVv6qaYqsOrHQQ2QI= 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=pFafmqok; 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="pFafmqok" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-64b49f4232eso16896357b3.2 for ; Thu, 11 Jul 2024 11:00:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720855; x=1721325655; 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=C2p7tcOr0jm/PV9j5iKk7FyAUNGqEU9AzkGnAwI7vp8=; b=pFafmqokiqHkISFYh02EMeeOysOU5/Q6voL6hfkkqvTAo4KCQFrWyAPQIBP7RCZFrt uZoujR2IYRXwLe8dil1UK1wWjKsntZJXqqpKaFdyGgW0HrWmo+m5vSDAZCoBLDT07DYi f8ymHSXCzBRIlug0H2YyWkcrvvmS7BUom5YpP2c6/II8o0X8vyHtQCTEMb38snT1zyQy qjOQBd4Tvm3/NF2nEuDBbgcpB+DrsMWzm7E5ZNVU7ohEGzVHCeU5FB8eopGC8f6feyq4 BeB4/hp4a9Fj+upRU/2vbn19tC+L7yTTDdbRyksLtJ8VBx/2RkN+EwCAcmQox7Bkdqdx Og3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720855; x=1721325655; 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=C2p7tcOr0jm/PV9j5iKk7FyAUNGqEU9AzkGnAwI7vp8=; b=aWkBobsxoJgofkHPojpoPPd9jpvLXVpsj4DcLrIszAtXE2wVCtqOMH7OBZHZ8/4m0M uFr5KyoZl8jbuCMThov2p653o0FKK9j6PNRSXmSjE0NXOWNeQ28ZMNXpB/ulbDWN1HSf pEDhQYR8eez/fgbHMJg+ypHEqfTGDGwYZwxhalyG+kocBeIOhG2uh2q5JBsXHeVR6OAb 5SIYlBsxDJ5dsGNbgpGxcPKBuACW1Gj4NEkGW3hr8H+zBX2ZbJYosRzsbFJVbRWMLnlK cPYkrnBnGd3GqS6AYCTs4558XbtHihYZr5UvQrYwGa879YTUuOsx0Srg1SvXK6Swr+Sj r41g== X-Forwarded-Encrypted: i=1; AJvYcCVYly12MPH0vFeJSSLZOkXdC4BdJ6BvBzHkEGY89QJPsa4XN6blzW3242+9dOOz/yxYqwXNZaxQuF1LPwzFXy44G6gdfP+RTNExJXur X-Gm-Message-State: AOJu0YzyWs8yhcv405X9rXvWu3bttM4+hgx7a3aZ8zW24v3hVS2nFipv 4E6Da8RUzGjMdLsYeDQVSW/5rByBF0mEssQfnlzT2UWmkmz42A86XvGa/DgApyx5QjANkKJBpfB qqo/cBg== X-Google-Smtp-Source: AGHT+IErKn7vIcO/EMczv8pt4H8ZLfTYCzTGeuAeHkDtRqbCFgVHP61ZAZdJy2vh7qsOzMlOjPpLcCM9CM6N X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:60c8:b0:630:28e3:2568 with SMTP id 00721157ae682-658eeb6df10mr472117b3.3.1720720854737; Thu, 11 Jul 2024 11:00:54 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:59 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 19/28] perf sched: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-sched.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 2ad28c49d31f..fe2bddd63d96 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -3013,7 +3013,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; @@ -3514,14 +3513,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, @@ -3638,6 +3629,13 @@ int cmd_sched(int argc, const char **argv) }; int ret; =20 + perf_tool__init(&sched.tool, /*ordered_events=3D*/true); + sched.tool.sample =3D perf_sched__process_tracepoint_sample; + sched.tool.comm =3D perf_sched__process_comm; + sched.tool.namespaces =3D perf_event__process_namespaces; + sched.tool.lost =3D perf_event__process_lost; + sched.tool.fork =3D perf_sched__process_fork_event; + argc =3D parse_options_subcommand(argc, argv, sched_options, sched_subcom= mands, sched_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (!argc) --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 1A2CC178397 for ; Thu, 11 Jul 2024 18:00:58 +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=1720720859; cv=none; b=j2SuvQC1fv9CF3H8lGVALz6nmtRIDJJoRr5cqUiwp56edNXM8hdBRqo5HjziLZ+N0MMJW6xz57dFrUxl15Tm31IcdaZMUJTNQiJ3Qnd9oh4sjSh4vahnubXFt9zQsGM5+gvKaHGO5fqcPjw+1GmgjxegP3BzLL/cc8fysWyMeL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720859; c=relaxed/simple; bh=PQFAc94b+3E6J2xiJdbKRsuyLtZHAm+NZj3v+mP90Hc=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=MaheY1iyCdqjCEjgdRP132LM7EA4j2TxrmDzlpOqU8oIyQ9by62wE82D4I4phS1I8CPs+ZdspDD0MmHeDMH4yyIX+NUTzt/te0Wc46OP+lEggbymri7+eTjS5OUFf+/qlexJjSRF0qd8kggzyA0ZV3NFx6bZCb5gZ59rGk4Eq2s= 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=YhzsTlIG; 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="YhzsTlIG" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-650f5b28822so20060277b3.2 for ; Thu, 11 Jul 2024 11:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720857; x=1721325657; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=dI8yaROyMxBgkl/C6HStDZ1DbB4Rpu7ZnQVumFggSVU=; b=YhzsTlIG4ABnF3bTg2LroNQPualviC4lcq/b373kK66v/F5DHwjQ5CwDliKgSKmf9q v3zBBJArimfiD/U6UCHtyOoKaBAw6uIPdN/zo1RiCOfChCjDKW0V4KClmqC9vkdRof+U 3EBUOcILho5Ji6g7C6F49dmIqQDd0HlkHIrojhbBVd/H3kYll5Em4RMNbBjZKRJBy4Lt iW7SRb8GpuCVCbMxXwt2IMwC5O0fo9UVRW+IW+dyc3Z+pomVLbjpU4LcO635HxiodFn5 Ras+foFVUtswXL/he5H0QqLVkGqcK51yvNAu2oZF3+oXj2Vdne9rIl1D/ycxEDk3OUSH zT6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720857; x=1721325657; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dI8yaROyMxBgkl/C6HStDZ1DbB4Rpu7ZnQVumFggSVU=; b=nLSCy25GH+KjBopLL4bgN+uMhrsTvLA0BWwS8w5GPizJHzE49L7V+TT2WPX6XBohkX nHRe4Vwq51wPznNBolmD+cyT7Dl1sFMkcEPddWELftNP65dcU+vFpw33G9CXsNyYwP50 i9IpfLP2ma9SmCW+u8P/mf+3/pF0d+eJBtAUdKyPAkmQHtOX3GkVAs9MZ0qp3NX8vjcU w7b2R5KjIcCbOYw4BZTOr1PmNW5gyjl+IQA0qKGm2yBhr3skpUI/Y5VdQ7oFepENbprC e70r+7zMrIHJk0Fpi0ElzFfV0JEIW64NJ9oP2EnC1jk7uw8VsgeaF5ODOMKnN6/0uUQb +bng== X-Forwarded-Encrypted: i=1; AJvYcCXlEg1xmhfu2CVa3Hcx0kDdjvkRIhoWjNe/VcjU0HoNhinWTzIC5+xPjm5Wascl6IwVuiWFNoBap/MhRk475OyIi1635zB42g1pbPf6 X-Gm-Message-State: AOJu0YxHUx1SCljKNJvuSGGV8t5Uh0WqCxwmdCd+iEoRvZzCCyTWu4hV hMuFcubeDl2H4vJfAObA23vkzfLH5yTDB134Us3fPTW6DwLYgqfvo6yQmZIz61dSIsmW60bMqG+ GM5criQ== X-Google-Smtp-Source: AGHT+IGlvSq0w61dchsRb8EQOsbrRTrATl43/YP+LZQ7kANYJWmfCN5j/cK30JXClPJuEw9Y52zfl0N/IRks X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:124a:b0:dff:4c99:915 with SMTP id 3f1490d57ef6-e041b1134a3mr494223276.10.1720720857211; Thu, 11 Jul 2024 11:00:57 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:00 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 20/28] perf mem: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-mem.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index c2038a32543c..c12ca0ec1237 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -285,7 +285,23 @@ static int report_raw_events(struct perf_mem *mem) .force =3D mem->force, }; int ret; - struct perf_session *session =3D perf_session__new(&data, &mem->tool); + struct perf_session *session; + + perf_tool__init(&mem->tool, /*ordered_events=3D*/true); + mem->tool.sample =3D process_sample_event; + mem->tool.mmap =3D perf_event__process_mmap; + mem->tool.mmap2 =3D perf_event__process_mmap2; + mem->tool.comm =3D perf_event__process_comm; + mem->tool.lost =3D perf_event__process_lost; + mem->tool.fork =3D perf_event__process_fork; + mem->tool.attr =3D perf_event__process_attr; + mem->tool.build_id =3D perf_event__process_build_id; + mem->tool.namespaces =3D perf_event__process_namespaces; + mem->tool.auxtrace_info =3D perf_event__process_auxtrace_info; + mem->tool.auxtrace =3D perf_event__process_auxtrace; + mem->tool.auxtrace_error =3D perf_event__process_auxtrace_error; + + session =3D perf_session__new(&data, &mem->tool); =20 if (IS_ERR(session)) return PTR_ERR(session); @@ -449,21 +465,6 @@ int cmd_mem(int argc, const char **argv) { struct stat st; struct perf_mem mem =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .lost =3D perf_event__process_lost, - .fork =3D perf_event__process_fork, - .attr =3D perf_event__process_attr, - .build_id =3D perf_event__process_build_id, - .namespaces =3D perf_event__process_namespaces, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .auxtrace_error =3D perf_event__process_auxtrace_error, - .ordered_events =3D true, - }, .input_name =3D "perf.data", /* * default to both load an store sampling --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 96F78179957 for ; Thu, 11 Jul 2024 18:01:00 +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=1720720862; cv=none; b=WKdW7WduM0G80kM4P4nw8GmUdHF/b2fd87zgcc06JFYCkSCvUcc3408sbRkaVQQAf+BZir71Lk217wAnMjXXHXc+hqbH/82S+RbipYsoJ0z7doATHFFb6Xq1XZ1Sqp+eZhU2Z/cpKAahe/pShD3qqFsbDb6fbvvB3UuhS5FRS7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720862; c=relaxed/simple; bh=ulxtdrULVFXHxSwGu1u6ejOo2/3AvfXoc6ANmm1gsuE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=hCC5zPjFUVTfXd6SscrqEh3P95KN94sz0nzmUxh3SnBzT+WyyKiib30+psM+5mfAH/2ySDgfD237YMw5LBW/fVrBBWgXI0MyjzFDvptF3nsh+XIPVCUYVbI9jbUfUsmpwr8abnS+XCGOb/2dsemKeinlU/WYCLVNON5OxkxKxHo= 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=oY5wAVSY; 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="oY5wAVSY" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6501bac2d6aso13428847b3.0 for ; Thu, 11 Jul 2024 11:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720859; x=1721325659; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=30wTiCp+NVIhDTuqUvYj4YUy4HL96R/Tpq22ji595AI=; b=oY5wAVSYr8CgW5eQIgnVB0RZy+wBrReOOpsBcJs7qimpREAuhJHWIQ0ENgNWuE3uC8 tl7iOx1zKbdJzb1fA7ZpoGWqbUyhZDltDVb6DWzCXKEpHdKRLHkw7Zd70vyRge2z3dp2 skYZikwwpB2xHePvmwZKPolbIFUDcvaFR5poZKJhKPW9QL0qyzrAptMszPsDd/3ESyta 0HXkE9O6nKUmOTIlqF63hjrSj/3p95473n6AWEbfLq7inqVT4XoogrDxyoGdbB8s4qy8 bmhHNzn/GYG7Lz7rd8B3cf4vkAcA+2xKwci1iaObPWs4rcuB4rs0xSlQEX7HIZhRAcZp qxNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720859; x=1721325659; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=30wTiCp+NVIhDTuqUvYj4YUy4HL96R/Tpq22ji595AI=; b=JCU1vJ1JbUembimer5p+lOmShu+ApIMsteTaLgliEf7Slw1OBkEKtY3zG4/8BirQtM w97t3ANVGDbGq6Xi2cOZQo2A8WYlUOTw8ctVcpmIPrIS/57UpqetDpYhztxBfyaDp8NE aKbGHQrNoqUhZddlGu2kcmJdEv8IRgwH3DRdI/bU8Wna7qo1yUAo/N/DXpg14QpM6QJs VyjT8GOf9U9u4TaZMeH0JbrlEtJ9gcE504sKgR70kvhw+O9E6YK0TDUCNiO7Iwnf6Igc zqT1ysEoeLXAm8BFgc3thsnTJWx0QRTcNtH77hwgnRGNEP/yPkz0bD3Nr3pScUCdfUuU no1w== X-Forwarded-Encrypted: i=1; AJvYcCXKrkVNbJj5rYYT7gsegL5PJN+eexvJKeb6bgLx2rUXywnK2IcRK56fXtmpcdnIedqAUqeAwaQpcXcQV2AbUnF0h35SjNlPokwxgmwF X-Gm-Message-State: AOJu0Yxh3RCArNObqQzI5RFFRWEuzGyQMEFH8KebMwdjOGzS1B3bu45T fAOYSKX5GOERpXMkArEzIvtFQH/2no/oPqrr7JkKAmRWlYjV1G9cSfnRpS7SNWTr/ZR+vqfWEqM 8DRInVQ== X-Google-Smtp-Source: AGHT+IFZpTMg4BQB94SCXas1IM8Xhd/IszdibFEMqZP5+uba0vWSTxmY0iKOvfL8EAF9shV0sCKOMUKx0Nvd X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a0d:ea49:0:b0:64b:a38:31d0 with SMTP id 00721157ae682-65df50b328amr15297b3.4.1720720859459; Thu, 11 Jul 2024 11:00:59 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:01 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 21/28] perf timechart: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-timechart.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 5bf818baa662..218c8b44d7be 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -1606,10 +1606,16 @@ static int __cmd_timechart(struct timechart *tchart= , const char *output_name) .mode =3D PERF_DATA_MODE_READ, .force =3D tchart->force, }; - - struct perf_session *session =3D perf_session__new(&data, &tchart->tool); + struct perf_session *session; int ret =3D -EINVAL; =20 + perf_tool__init(&tchart->tool, /*ordered_events=3D*/true); + tchart->tool.comm =3D process_comm_event; + tchart->tool.fork =3D process_fork_event; + tchart->tool.exit =3D process_exit_event; + tchart->tool.sample =3D process_sample_event; + + session =3D perf_session__new(&data, &tchart->tool); if (IS_ERR(session)) return PTR_ERR(session); =20 @@ -1924,13 +1930,6 @@ parse_time(const struct option *opt, const char *arg= , int __maybe_unused unset) int cmd_timechart(int argc, const char **argv) { struct timechart tchart =3D { - .tool =3D { - .comm =3D process_comm_event, - .fork =3D process_fork_event, - .exit =3D process_exit_event, - .sample =3D process_sample_event, - .ordered_events =3D true, - }, .proc_num =3D 15, .min_time =3D NSEC_PER_MSEC, .merge_dist =3D 1000, --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 D7EC517A5A6 for ; Thu, 11 Jul 2024 18:01:02 +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=1720720864; cv=none; b=lR4c5zzDaESJxqQZ+wV6QYsP3Lm/984Sjux+DrzjGP9lbRPdFJGZI0MeJnlDzlxQM1qyeDTn9/1xUP1yHmaayOQJRaCgbAu1LblGJEpxymPYk+2ZGDMLNMeVvOaP9KaR5xSWKBWjMwKKuiAAjx1KxPIxYL1FrT3P/92As+ijHpk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720864; c=relaxed/simple; bh=voKswfKfj3xVUdanTG/Vv01I1kScl7Vgd1gUmqiYueA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=bb6fTIprsLBkH905sYXjD+5S6CZWZoomitMJUxxayNpj/j4AfOqX6wKAi6/DUsf1ndd6uMXzDUwa0t3A8nQfUmSwJ7TJMLP4nBjnVDwfyP72ikjMSHI25NwhgbxDDU6U0K9WZdKiJjBH5HrngltzZk8waX/E8M27sIbiIiYxf5Y= 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=njjrVgWa; 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="njjrVgWa" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6524309be45so22935207b3.0 for ; Thu, 11 Jul 2024 11:01:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720862; x=1721325662; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Yt616h8hRCivHeAdqJzIY5ztVTyVV8Crah5Wq3Zf1UM=; b=njjrVgWar1PupsOHTA9f4dyQsKwtocH1cP8j0ptvkmjcQ+awOX1prnKnHPayGPzwJy EXxvsilQA7/K+9tjnCXJKvqsxukLGmLqjjEupSaMWQfP7eNC1IzTNiQiRNBWRzPXtQrp qazr0vvZ85UrevU5UjyrPeRool9O8Q32aF0yJ2YCtgEIYJEI6In66W77ospxE0bBHN2n nxVKq9G2EZwwx2k46OLXFsnUAQKFUWysTCcG8QkOf4U86kAmw+dnW9DNjsVACp9MMHge ntBV1zq0ioz8gj90ZTIqqFYlx3SHmR1KWd1mhvbsN0DbvuuHPW4p1QZYAFhTh5jM9ma+ WpAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720862; x=1721325662; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Yt616h8hRCivHeAdqJzIY5ztVTyVV8Crah5Wq3Zf1UM=; b=SXvvkmDzdYIEUBKLzyhUfEdz6MOlQBaNdXzLeL698nXLLcMF7IgqqroroSECzh3BZn cu1NLCb7gszfjptFfYzm8kTDB1XK6PCn7fLCN1FuwPqbYku9dzuRJAtZTeeZn20uE9ip +oxlaWF88T3EJvwWcagRT4m5G6V0Fique6iOS9mWcRu0gn3OmO5NumqquR6OnmXorfBf PtvxbIfhpzWJDRoasXr3LtyoSNrwFV7zNV5veBRa7a7DQPOU1lpq3TYJTOupRQcwIqyo V1l4pwfN4yXBA+htREsH5FLNpFqY189yJncXLQwf7kt8/ZN0TgWdocMZ27NswZz5+e+v GVIQ== X-Forwarded-Encrypted: i=1; AJvYcCU33koaPN2xnbdZzZjbgj0I1phr+x9XOcQELjt2O8sgYyccFVOwDh42FuNwDai1UMuCBCO4+OhFDePdwXaEBNvgzZx5bhgr5m+oTv+W X-Gm-Message-State: AOJu0YzC+dFf0f7R/LOZX5rSERJMg0H4nG8Vle3d6wY4Y1Iea8OI0l8d e8W4G3JM3afmJPIbrwggftH+8jVo5A3b1mX26/Uidbi/xM3FFWX8TvGs83N2zqYrcdWXVbkacP1 bLpWigQ== X-Google-Smtp-Source: AGHT+IEX9oO7/QxRJKOh3p4hGI/yZCLEqpz98Pi8rexdVxqsNShjq1Lvluub4NnTvVJr1wr4NjxC6/p3kgg0 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:d17:b0:627:dd6a:134 with SMTP id 00721157ae682-658eeb6d6demr1963327b3.3.1720720861856; Thu, 11 Jul 2024 11:01:01 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:02 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 22/28] perf diff: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-diff.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 4c0567882a7a..28c5208fcdc9 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -467,21 +467,7 @@ static int diff__process_sample_event(const struct per= f_tool *tool, return ret; } =20 -static struct perf_diff pdiff =3D { - .tool =3D { - .sample =3D diff__process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .lost =3D perf_event__process_lost, - .namespaces =3D perf_event__process_namespaces, - .cgroup =3D perf_event__process_cgroup, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, -}; +static struct perf_diff pdiff; =20 static struct evsel *evsel_match(struct evsel *evsel, struct evlist *evlist) @@ -1959,6 +1945,18 @@ int cmd_diff(int argc, const char **argv) if (ret < 0) return ret; =20 + perf_tool__init(&pdiff.tool, /*ordered_events=3D*/true); + pdiff.tool.sample =3D diff__process_sample_event; + pdiff.tool.mmap =3D perf_event__process_mmap; + pdiff.tool.mmap2 =3D perf_event__process_mmap2; + pdiff.tool.comm =3D perf_event__process_comm; + pdiff.tool.exit =3D perf_event__process_exit; + pdiff.tool.fork =3D perf_event__process_fork; + pdiff.tool.lost =3D perf_event__process_lost; + pdiff.tool.namespaces =3D perf_event__process_namespaces; + pdiff.tool.cgroup =3D perf_event__process_cgroup; + pdiff.tool.ordering_requires_timestamps =3D true; + perf_config(diff__config, NULL); =20 argc =3D parse_options(argc, argv, options, diff_usage, 0); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 D455F17B027 for ; Thu, 11 Jul 2024 18:01:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720866; cv=none; b=qYpQgV99qyWY3N+RRRVUAzJt8macswDNFRgnVib+ZFaCxjo72Ayiitlf5L/1WPk1KGZN3v06d8MWtYbBfmOfegW7bohgiv+gdCRfyyOvfLocxQPwpOWIwT5ngGgt5Vg5zTqtwvO2M0Tb+bJle3yOVBtH1Dcf3q+JMtlov53jlmo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720866; c=relaxed/simple; bh=Zg5U84S1ofRY2jiFZPVeAVTNxheJYumCpecsmhgwjUo=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=NplxTUtrLTkujRQXLokcIKq5pi2+YNDNevS6Qb1FWpiLcUUCdO2LXVH59OXIBHPvabh4HdDK/bjnO3jo+DrEVLf89jUlbi9eM0geYzRZnpKTok8x9MGFDsDy2ef+aQysBc9UCxsE93dFM9Ej0jh/Nlz6+uljPlxsdA3dlloGITM= 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=AnmXHAdY; 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="AnmXHAdY" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-651e54bb41bso17365377b3.1 for ; Thu, 11 Jul 2024 11:01:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720864; x=1721325664; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=QqtdDMsD55pEoQfMNz6zeYZQAoeVSzSneBvTBBwc7VY=; b=AnmXHAdYP4uCFgtMdgvkHBu7QdTvAvOaSiREvWAy7huTrTo2KCMqcfYVGS28q8Gh+n 5zXhm0D0inWyxWxdP+MDpSnZmDwObzClyU88yYzz7cNY4/XMTTsIictQGXz5XAUOhl1+ iyrHXoBW/lw0L560KPLFYOXWJfK1DdTjyGpUViWbQJKYC7OhAbDtW0lBJzJAalM4d6ym myV2LYN4lCoOUjwW74P7JoszU5G3IWY3nk+wHGCSDz6Dt/5VefQwtuc4jZIgtsKeqRUE MegE2zUYA1XAfleyAXleaasbS0TdbDT0bUAoEWmEGj5iC3FGQEht/2ITPI4UQ1pdZL5l 9dnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720864; x=1721325664; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QqtdDMsD55pEoQfMNz6zeYZQAoeVSzSneBvTBBwc7VY=; b=GrBENR+NrS8vyBrKZs7EPhYuSjWfHDTqw6LDwDi31aHHAFMyDJM4xIMVAyTTQ+qAcF N8967Ab265Ln4CvIyyuXyTRbxL+isVO1VDnh88W3lLY7875Y1UrEAG2u/HmFLzBF3XUj lksc8S0vCEJsYcQp4aAG+9kVMQzwZnuZHIQeQA8pOFerBL+6Liiyp753A1OAihMvO+91 HFn+AYOdgWPsshl1OGzcE+MrdkS1kOCQmQnTd0zNstsDzGmWczNmZDnOb6NCbkeeM3nH nNzaICsN/oKspGobru+VRyE8NN0N7xNN2HHs67sfT2DG6nFpZE4rrtxp6T3tLWJjee8A rdqQ== X-Forwarded-Encrypted: i=1; AJvYcCV0tMXe3tRqVkRYF5wdbgdoW8eZ4QFuTeGWOci+HfP2Hm4EFBKW6XvB4e2NiqKyVtIPmBlz8rUzvoLE60uF8D/sgpc8KVrA+R6RhAaz X-Gm-Message-State: AOJu0YyZcnAPcrVp3Z+lnAqF8okuaROVeSBz6s9nQy6s3Ony9OTFP/Jt tjUWNA2YYdoTteviejJ1bxgI/KyvhM9tITwZKnkHeIUjpNoP3cT3xO6VbkJ9Rt0HKwlfLV+x0bD eXfcQWQ== X-Google-Smtp-Source: AGHT+IFm7iteUqTnpFU/9RIErlfRTtg3oqwxjOCKfDaCl4dOg8omYu/CwVrqY1dpL402Zc1R9QmK5RmuQget X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:6b0c:b0:648:afcb:a7d0 with SMTP id 00721157ae682-658f06d9ecdmr530397b3.8.1720720863879; Thu, 11 Jul 2024 11:01:03 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:03 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 23/28] perf data convert json: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/util/data-convert-json.c | 43 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-con= vert-json.c index 905ea9823f9d..20bfb0884e9e 100644 --- a/tools/perf/util/data-convert-json.c +++ b/tools/perf/util/data-convert-json.c @@ -316,39 +316,36 @@ int bt_convert__perf2json(const char *input_name, con= st char *output_name, struct perf_session *session; int fd; int ret =3D -1; - struct convert_json c =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .namespaces =3D perf_event__process_namespaces, - .cgroup =3D perf_event__process_cgroup, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .lost =3D perf_event__process_lost, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data =3D perf_event__process_tracing_data, -#endif - .build_id =3D perf_event__process_build_id, - .id_index =3D perf_event__process_id_index, - .auxtrace_info =3D perf_event__process_auxtrace_info, - .auxtrace =3D perf_event__process_auxtrace, - .event_update =3D perf_event__process_event_update, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, .first =3D true, .events_count =3D 0, }; - struct perf_data data =3D { .mode =3D PERF_DATA_MODE_READ, .path =3D input_name, .force =3D opts->force, }; =20 + perf_tool__init(&c.tool, /*ordered_events=3D*/true); + c.tool.sample =3D process_sample_event; + c.tool.mmap =3D perf_event__process_mmap; + c.tool.mmap2 =3D perf_event__process_mmap2; + c.tool.comm =3D perf_event__process_comm; + c.tool.namespaces =3D perf_event__process_namespaces; + c.tool.cgroup =3D perf_event__process_cgroup; + c.tool.exit =3D perf_event__process_exit; + c.tool.fork =3D perf_event__process_fork; + c.tool.lost =3D perf_event__process_lost; +#ifdef HAVE_LIBTRACEEVENT + c.tool.tracing_data =3D perf_event__process_tracing_data; +#endif + c.tool.build_id =3D perf_event__process_build_id; + c.tool.id_index =3D perf_event__process_id_index; + c.tool.auxtrace_info =3D perf_event__process_auxtrace_info; + c.tool.auxtrace =3D perf_event__process_auxtrace; + c.tool.event_update =3D perf_event__process_event_update; + c.tool.ordering_requires_timestamps =3D true; + if (opts->all) { pr_err("--all is currently unsupported for JSON output.\n"); goto err; --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 2B02D17B437 for ; Thu, 11 Jul 2024 18:01:07 +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=1720720868; cv=none; b=gn5I3Z2LPYkX5PcbG7jtVQT2vbg3jFbURc50QPD/a2fndF6x1kJ+J9h7wuEN6fcR7zqeq8YV4i6Oo4ndCHUav2HzoI3rb/ClcuWpZAjDsqewI8p6is3vYL3jnCPHo2BFz0SeM91d893zs3aEp8yC7TVmjogAZx/z8J+t5OEIikg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720868; c=relaxed/simple; bh=IiOUbHu6Xz1VISLL+B0ayGxLanWqPidsSe75Qtiw59I=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=YRwG/c7vZw2RCfU+9oOSOYNk8WNH8Wxefh5ulQnm61j0aNBcEQ9vj09Ofe+iujV5dxCw/cy6KSpEuIHnmeSZyFatNOv2+Z1Auit39TGHjqyWJMom56emYf1plOj2jftA0xX6NKsbw4l2rv2G/zjBwSjz8+OMVT7K3XfJSrDHz8E= 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=sdSqoH2t; 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="sdSqoH2t" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-62d054b1ceeso19343817b3.2 for ; Thu, 11 Jul 2024 11:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720866; x=1721325666; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=I9Nrbi73tEJWZxPfyj1GxchBACZKBze8WVP6UfEoRnc=; b=sdSqoH2t81PvJ6GsUw+sMoNeUz1KocrBXJbalFJPr1epzjThDBfC3NpWsJle26W9iD 0Y8YXEHQXAODcRMTxGr5OF/u9cl4tk5EdkTpBtk3bpDzctPHc5ku0cXVKz1Pp2g5RY26 hAUaJwP/HbaBWSZVs+jxcTyxePfTZdrqKZkbXJV0rI8WECBNinanu6NqURV6X4S5LgN4 WSewClM61kBjaO9eS82gdZZJgo2dTk+Wfghuadr+VsstrPTbIHifGknCv+JlL6P3yyUw 6R+Lsa60xTqWOmHNQhDxg4mCfDA98Hy5yV7v0BEwseNtKf4y5aKMy8CkTskxXg0qOKNm 3jZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720866; x=1721325666; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=I9Nrbi73tEJWZxPfyj1GxchBACZKBze8WVP6UfEoRnc=; b=a+g6cEGTRMMS2vyFRTCFU92yGX9EVfedX2iCt6a69DX5tfCbUly/oOujRe+g6yBHLs 6mUCDR7lCgxG5R495KXr/7eZHpydeKXGh5YgzzmlUp/Otu18GlMoz9RkNsBkhP7zgd6Q K/T9/5y1YaoOvsIwJE13Vg/I3IUh6aVKMnSFpWURwDLKTPDbIqLGBq3uxHDQqZm2xUHW PTs6HJ8yUqlpOl8WxWvT1Nfu+wKk/olkc9URxROAVkV3a4SY73FwmVYrGyfwuh+lrAut vhmT9aYVWTZ0ry0H21Iwy1aUxA9JU3xXIT6By0cY06+onF3ela5l5f3FUbPRZxVF7e2X Gg+g== X-Forwarded-Encrypted: i=1; AJvYcCWTjqTO4Pi1yn5kRqHUAwCAVnRHpJd6somVL4ER6619Y7jXR55pyivFJjR2NZKr5g9vBrGuTbVdblerQs97j9QklLAnN77E+E/B+l+t X-Gm-Message-State: AOJu0YyJKQAtwuRlk27jb2UWJv8S4vB4qsm/ekyQNwujy16chKEYapgS WQaSl4LEc38QFFTyfdzo3mB4LdTlnzrqJo0VJdoV/TTwiAZbdMrXd1XtZ+6cM/yxjPcs961hOl+ DsL0Teg== X-Google-Smtp-Source: AGHT+IGhziChfBYedmxyjnMHcf3Bobknr15gAzBmJdGEG+V/V+Zw+9Pj/8QUbWISbMzVlIJAKmFQYf39s2q6 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:d0b:b0:61b:ed85:5d3f with SMTP id 00721157ae682-658f0cc859amr2392417b3.10.1720720866335; Thu, 11 Jul 2024 11:01:06 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:04 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 24/28] perf data convert ctf: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/util/data-convert-bt.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-conve= rt-bt.c index 9e2170604b66..021e9b1d5cc5 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -1607,25 +1607,23 @@ int bt_convert__perf2ctf(const char *input, const c= har *path, .mode =3D PERF_DATA_MODE_READ, .force =3D opts->force, }; - struct convert c =3D { - .tool =3D { - .sample =3D process_sample_event, - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .comm =3D perf_event__process_comm, - .exit =3D perf_event__process_exit, - .fork =3D perf_event__process_fork, - .lost =3D perf_event__process_lost, - .tracing_data =3D perf_event__process_tracing_data, - .build_id =3D perf_event__process_build_id, - .namespaces =3D perf_event__process_namespaces, - .ordered_events =3D true, - .ordering_requires_timestamps =3D true, - }, - }; + struct convert c =3D {}; struct ctf_writer *cw =3D &c.writer; int err; =20 + perf_tool__init(&c.tool, /*ordered_events=3D*/true); + c.tool.sample =3D process_sample_event; + c.tool.mmap =3D perf_event__process_mmap; + c.tool.mmap2 =3D perf_event__process_mmap2; + c.tool.comm =3D perf_event__process_comm; + c.tool.exit =3D perf_event__process_exit; + c.tool.fork =3D perf_event__process_fork; + c.tool.lost =3D perf_event__process_lost; + c.tool.tracing_data =3D perf_event__process_tracing_data; + c.tool.build_id =3D perf_event__process_build_id; + c.tool.namespaces =3D perf_event__process_namespaces; + c.tool.ordering_requires_timestamps =3D true; + if (opts->all) { c.tool.comm =3D process_comm_event; c.tool.exit =3D process_exit_event; --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 90A8B17BB3A for ; Thu, 11 Jul 2024 18:01:09 +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=1720720872; cv=none; b=ntDeoCDx1f44urfWRs1TV/YifRm74iTYnL5qTg6kf+iZl/ygQq5kjNAoHhP1OorQyUjCAiIrbEBeNjIUliYJWViMVuni9cnTXVDBsxLTVJld3/NI/SfrJuXKXHw1XM9W+7NGRyaq0fenyaq2PqCl2CJnEnTxAcqX1ho1pN+UC58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720872; c=relaxed/simple; bh=QJTLBouB03fYPDSHR5NUfnIzNoxc+9fFEDyXtvrnJyA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=V2FQDDTC4Qx1B+QcvOZxwQQDdbqkbaYqnc9FYNAnwm0DuKrpcxLPk6BQ9N9iIrOOzwqJ5jOyWdJg//CX5WT/zCdQt/QQDQGJSslMpzfhtxwQs77kT1CRdo//Wt3CUd2cLmShFlq1NqU2wJTSauG66a1W9UX668lpBD7R9l1Z08M= 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=UwMXmUMw; 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="UwMXmUMw" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e0353b731b8so2287953276.2 for ; Thu, 11 Jul 2024 11:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720869; x=1721325669; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=2MNiLSniwVv1E9e5Lf2m3HZTOrICLuX9boz579z3/KM=; b=UwMXmUMwukNa6Nd4r6YnVtVgunpqe4UQZWTgZ7Qm/+RfdggDEzq3fC2n7mRjGMXVTk znxKHWl2b9MH5ZvZB27gJgbCGHTBMELZFao55TuzHH3FQob/siuw0U3lL37fkqciMMKs gGFyiq1F/+YNWrc1R+O+ut4tVAe0uT9NF3lW3CiUgy0snEM5d3o+k9v5axZGex74uf52 m0EXL0B13ukHOs4cmlEWji+iRu88nxT8v4YF6k2c7P2U+m1dJ31X+Z6HGvuj1JAzpYJ9 PReKqWbJi3MvygF1Q+RO2CeYmRz9SrTVGu+8Y2tGD/SVXhUpChCnAEOB00sS2OfDWusx t+vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720869; x=1721325669; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2MNiLSniwVv1E9e5Lf2m3HZTOrICLuX9boz579z3/KM=; b=LWM/MuH2vb0I/9jcmSDalZr6k3BgtO/EgfiPFQPQ0hH4BPGVyYYqMxKOA2pWBEoLqy oDKM+WKS+GlHRnkj4Bgn+9pEhjDrGMcWhhbY3Vc/pkAWb+mBEySc2NUzvIP43SdKvNMS ssaCbeze5syCkiTZWDyq0gCgb/BpHeYBF350HmWm22QuIM7x/+OKs45FUTqugWUfm5e/ h3MLRGx86tdwvcnbltuBrbDKZ4KK0hLfYhVyeGpbp34ZCTi8Kct5Wrln+jl9Ypkdz99M WQ2235QhUYhFtwE/9RaxbPCMqMkvdJbc2Z1y+iChFotT1RPblmLXWyVZIcbVqCuxZp4q gA7A== X-Forwarded-Encrypted: i=1; AJvYcCWYXvekVWq2HF2f6VkQ58csWKVZALzml/u2FOpV5JlvBONzTlt7cidJD20L/D++WGroJxKpROa7lQIixQ4egyd0bmV95XStzacz2WnA X-Gm-Message-State: AOJu0YxcmwVhBv8lTdb+6K0AYPbcBMW3DZCf5AfBTgEsVDJcHmeE08dq diJB9M7+qnqGkHfU0njIzMzkix3tEOq+AAQS1LYtQawZA9yVqT+DYYGy1b4tEhDGf1qokhRZcJR 6DLmlOg== X-Google-Smtp-Source: AGHT+IGM2xQme0Hs8QJpMwRrl0GnjElIf4QWIdg7meyT8+jpTN98FNf8secObYryk9mDw0GyqbyaX812usu1 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1206:b0:e03:59e2:e82 with SMTP id 3f1490d57ef6-e041b134afbmr16523276.10.1720720868643; Thu, 11 Jul 2024 11:01:08 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:05 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 25/28] perf test event_update: Ensure tools is initialized From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Ensure tool is initialized to avoid lazy initialization pattern so that more uses of struct perf_tool can be made const. Signed-off-by: Ian Rogers --- tools/perf/tests/event_update.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_updat= e.c index fdecad920f59..d6b4ce3ef4ee 100644 --- a/tools/perf/tests/event_update.c +++ b/tools/perf/tests/event_update.c @@ -103,6 +103,7 @@ static int test__event_update(struct test_suite *test _= _maybe_unused, int subtes TEST_ASSERT_VAL("failed to synthesize attr update scale", !perf_event__synthesize_event_update_scale(NULL, evsel, process_event_s= cale)); =20 + perf_tool__init(&tmp.tool, /*ordered_events=3D*/false); tmp.name =3D evsel__name(evsel); =20 TEST_ASSERT_VAL("failed to synthesize attr update name", --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 CA02617C21B for ; Thu, 11 Jul 2024 18:01:11 +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=1720720873; cv=none; b=doyBkGCdJUC/U6cPRQQLyhulJfk2XpSY5aWBRVi/mtq03IZATJHQ+fraCNA2fcthRttJyHaoDgFjHPBXv5px5EVNDIre3+MHDVAAh62WhLeD3hvXMh8ppYk+/RWf2Q+9TnGh5C+ZsGLG3FbpONY8E35Nj+8+QCyndJ2h6dv2r9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720873; c=relaxed/simple; bh=Vut48/dGoEfPl82dZRBs1EiuBD2BZmTC7MWAiL1FIkY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=i4lrlHUSpai/5SGsJrXkP/PmORqFKmy8JNHB6o+MLVo37aZw6tQyiw5K9zw919BSxlAwqE4U6MWOtP16T8Z+My7KCHnX84IN/ws9vWs6nPVUgoGC8oPGCEoeSbEwfzbYZj19/B6E9Ob75GYlNHbMrqJz5wudUZ2GYu6sN3xdvHA= 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=0xUqBDCG; 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="0xUqBDCG" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e05600ade22so2355458276.1 for ; Thu, 11 Jul 2024 11:01:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720871; x=1721325671; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=phxqvYyYZFcsS+fO7HmN6BaHRpzOxQeFfvDLLgr+3hE=; b=0xUqBDCGfyuwy8qpZpVlBqmQVconYW645bN8exRhjwVOWu3WDrrzfXJOR9HD1en6Dw 9FPkwG7/Gv/KSEmtCri8dhMGLzd/AGLke6btrFcpUaHYwPpY3O1rMZ+3w/L6ZXR6ruw/ U8z1gM26CUfkSaVWqEBOWhFpbP1p1Be8Ovb0r+AHsErlTd74MAqNatVx/RAJRfa6rFkH uWZfRVBPyQX9CwSp666FSPluE4BuxnGeVqjTQo7YL+dAw9venK9O0o8pLeqFHg0kH9wp ZWzNgDINgQ3C+rauH9s1i1v6NN/yFROvCZAp99pmirNeOhOeb5QQRO1OEDC8JneclWKH 3Hmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720871; x=1721325671; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=phxqvYyYZFcsS+fO7HmN6BaHRpzOxQeFfvDLLgr+3hE=; b=FZySGItYG4t2X+zUul7EHLS0z/CSNRMr4bP/biJ1yxWocoAY9363HM44Je17BYrOaL aCJjDTClod2rPc4RE90F9j1zxV4mAyYkty1SB3ACxtvtsMUjm1rs86irh/3W8i22Auaq 5AWejEfeTyIeFZVp0TwcWr+JhbjM1wSDS5elA5uEGPaVQYu5I59U9OsakKN6cfaAX0SL xlrmRaVi6gzqAv8GrS8DdjtsEdUCdwkyBHLhuXMZ67G5k46EjEGpyY1R7jOcKwnVM47H zcfa655FCdM6JL5oMCWL4/sh5pGJL0z3G/XPyWEQXNZEdPJSJ1npTOpaly0B50SaLt6r bf1A== X-Forwarded-Encrypted: i=1; AJvYcCWCQOHhA+oR1luMufpmSpK//+7JS6X/p2VyoNTb7E+eRG/paZHownG2Pb3euatRUx2Jxr2srIF3CwSdMx7F1vHiPZVm0G1gBSx9hOGK X-Gm-Message-State: AOJu0YzzcxaSRtDGBSOE3TTACfHVrW4PHLFSbjcMCNUVKp1SE/prgLfA M0+DN/FeWbcf3AFjUFdsu/4zxkwlu0iHvJG8KksxujnzqEgyOove4q7B2s+bCGG7az96DnVmZ3d NQbg75w== X-Google-Smtp-Source: AGHT+IHZsWRlk2KFoxmTrNHpb3twRLUr9YEReI+JPWVj//rgcz8mi631WHmc5+OCJP04cre0HLmnLn54Z7fH X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1389:b0:e02:f35c:d398 with SMTP id 3f1490d57ef6-e058a707db8mr1072276.0.1720720870908; Thu, 11 Jul 2024 11:01:10 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:06 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 26/28] perf kwork: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-kwork.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 8ffaa80a2d1d..6a4281b8fd10 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -2322,12 +2322,6 @@ int cmd_kwork(int argc, const char **argv) { static struct perf_kwork kwork =3D { .class_list =3D LIST_HEAD_INIT(kwork.class_list), - .tool =3D { - .mmap =3D perf_event__process_mmap, - .mmap2 =3D perf_event__process_mmap2, - .sample =3D perf_kwork__process_tracepoint_sample, - .ordered_events =3D true, - }, .atom_page_list =3D LIST_HEAD_INIT(kwork.atom_page_list), .sort_list =3D LIST_HEAD_INIT(kwork.sort_list), .cmp_id =3D LIST_HEAD_INIT(kwork.cmp_id), @@ -2462,6 +2456,11 @@ int cmd_kwork(int argc, const char **argv) "record", "report", "latency", "timehist", "top", NULL }; =20 + perf_tool__init(&kwork.tool, /*ordered_events=3D*/true); + kwork.tool.mmap =3D perf_event__process_mmap; + kwork.tool.mmap2 =3D perf_event__process_mmap2; + kwork.tool.sample =3D perf_kwork__process_tracepoint_sample; + argc =3D parse_options_subcommand(argc, argv, kwork_options, kwork_subcommands, kwork_usage, PARSE_OPT_STOP_AT_NON_OPTION); --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 21A5717CA08 for ; Thu, 11 Jul 2024 18:01:14 +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=1720720875; cv=none; b=jB1R2e/0IZ3uwu04DPZpMgOGhoD2bdq8BwVvXkpDwHt4bryw2KX9ipKKiQN6SDthh3/JzdDEVNl9UmJcGO+pKZP79Q4RXpxSrn3qanNS43PNolUh40oxH5kVDMbDdtsyIHtUB7ThOg93ChiohYgXrziA+fMseMKZVnQQkRrsWVQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720875; c=relaxed/simple; bh=nog9HAZnBs/Uc6gA5S1tlyf5AbSf3UPE1Jgj8toxgcs=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=c6dge4w4ZyEA9ZQdt1xJ2sk+MvG5xhwNxMp3sNOsvOELXvrLtzWuAGvay9dvf5xH/yaKxXIuJ95sCYyzbTTwgsegXCh56RLOAK/BKBLdzuUppUmVqRBKU3Xtzok10Vq8sFIHhVb5V7uDkjXmWNyyA/bbD2FaYoMXc4WtPaM7FW0= 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=lCs4POAJ; 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="lCs4POAJ" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-650f5b28822so20068857b3.2 for ; Thu, 11 Jul 2024 11:01:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720873; x=1721325673; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=7XS/BS2tmrMYCpclJsc0ik1l+h9pEP1QMQPO1IiW0Pw=; b=lCs4POAJlsu4lHu8o6Cpj5wY+cmdM3j2tAykT+Vs8iwDkaHVDsK9wav8wV11w5FvJh Pl/CBDkBe1JNSOs33g95vkrsri5oCyVm/uGwuwLqIPFx8i/s8v+Q+3bwghDXyuhqcjEh 7jZ0yHGWJ67/xud9KoMW255OUtL4n0XtCOZOHTrcXm291R+p3trBB2X8WSnhjihQ49p6 Lh+6ZOuqeGbjRLrfEQQHnzENxb/z7LxKc6nypBCd+5fmHoumKkB0u6hZr+FzCOBVxbkS uP4fiO6QTPfpFUGSwJk3ab4p0IdiJmtcNz/SG6o0cL+KJFNnfnjRn0wgiCFkOjzd1tD6 bGuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720873; x=1721325673; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7XS/BS2tmrMYCpclJsc0ik1l+h9pEP1QMQPO1IiW0Pw=; b=kC3k6HRSfl0mB9TnhIYOCJDLmBLutH8wXHEXsqEPSEG3v2EJUaFoT14899S2AbF1DB uXa1v7Bf0eroVBZq8tc/YD4EF5mksGvVzB4YeZ4jGXQQrMkLRZP6yPsO9j3/07hk+0Ut vqkiyNrZb03fJecndIkXqpczg76WojjOw+r7syQj1fgqTr8IJyovPxKPMPSkwNOxoyPn eNYqRChqa/XEk0gffXrwnp5ikarW2UL7aIHZKt5zOiebARAz8n9Oq28CjVePsWY5/8uf MNNwGz1XowlS8LcZ7pHFMwOF6GIB5wgHoFVlXqzZpCsBkCDhSen+lgwhDKGqRV1eYThE 7yCw== X-Forwarded-Encrypted: i=1; AJvYcCV+CLORi9tFrmMvgbncscCt5Zaa8kJruCf0fHSMOBXqXnU5rFLrwf107dO1kwInJIwXe1h5Sgy9h4XqWVgPCuXJt32vxQpkSVPlD6iP X-Gm-Message-State: AOJu0YwXo3JAZ486IP2Ur+UJ3/jhotyWgUJ70oDq/UageMAiiAgXt8kL iUMXbyz3VIXz6Ok8uZ+TsOKIYhMskUSlZJs6RfVfd+5W1O9b5oVyWIvm+DOfJvJmmbRM0myh2VE Ka+POIw== X-Google-Smtp-Source: AGHT+IFkKG3IgwMxEt/Bk8goVcLqtdaHlpvAh6+KBMB2W8t4X5lnBMdhP8W48LriLi67E/9Scm+C0af9WkpB X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:2403:b0:e03:554e:f396 with SMTP id 3f1490d57ef6-e041b05b915mr366236276.6.1720720873191; Thu, 11 Jul 2024 11:01:13 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:07 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-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: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 27/28] perf tool: Remove perf_tool__fill_defaults From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now all tools are fully initialized prior to use it has no use so remove. Signed-off-by: Ian Rogers --- tools/perf/util/session.c | 6 --- tools/perf/util/tool.c | 89 --------------------------------------- tools/perf/util/tool.h | 1 - 3 files changed, 96 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 5359ee055c85..ad5da61d2330 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1776,8 +1776,6 @@ static int __perf_session__process_pipe_events(struct= perf_session *session) void *p; bool update_prog =3D false; =20 - perf_tool__fill_defaults(tool); - /* * If it's from a file saving pipe data (by redirection), it would have * a file name other than "-". Then we can get the total size and show @@ -2201,8 +2199,6 @@ static int __perf_session__process_events(struct perf= _session *session) struct ui_progress prog; int err; =20 - perf_tool__fill_defaults(tool); - if (rd.data_size =3D=3D 0) return -1; =20 @@ -2255,8 +2251,6 @@ static int __perf_session__process_dir_events(struct = perf_session *session) u64 total_size =3D perf_data__size(session->data); struct reader *rd; =20 - perf_tool__fill_defaults(tool); - ui_progress__init_size(&prog, total_size, "Processing events..."); =20 nr_readers =3D 1; diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c index a4ca16e5eefe..3b7f390f26eb 100644 --- a/tools/perf/util/tool.c +++ b/tools/perf/util/tool.c @@ -288,95 +288,6 @@ void perf_tool__init(struct perf_tool *tool, bool orde= red_events) tool->finished_init =3D process_event_op2_stub; } =20 -void perf_tool__fill_defaults(struct perf_tool *tool) -{ - if (tool->sample =3D=3D NULL) - tool->sample =3D process_event_sample_stub; - if (tool->mmap =3D=3D NULL) - tool->mmap =3D process_event_stub; - if (tool->mmap2 =3D=3D NULL) - tool->mmap2 =3D process_event_stub; - if (tool->comm =3D=3D NULL) - tool->comm =3D process_event_stub; - if (tool->namespaces =3D=3D NULL) - tool->namespaces =3D process_event_stub; - if (tool->cgroup =3D=3D NULL) - tool->cgroup =3D process_event_stub; - if (tool->fork =3D=3D NULL) - tool->fork =3D process_event_stub; - if (tool->exit =3D=3D NULL) - tool->exit =3D process_event_stub; - if (tool->lost =3D=3D NULL) - tool->lost =3D perf_event__process_lost; - if (tool->lost_samples =3D=3D NULL) - tool->lost_samples =3D perf_event__process_lost_samples; - if (tool->aux =3D=3D NULL) - tool->aux =3D perf_event__process_aux; - if (tool->itrace_start =3D=3D NULL) - tool->itrace_start =3D perf_event__process_itrace_start; - if (tool->context_switch =3D=3D NULL) - tool->context_switch =3D perf_event__process_switch; - if (tool->ksymbol =3D=3D NULL) - tool->ksymbol =3D perf_event__process_ksymbol; - if (tool->bpf =3D=3D NULL) - tool->bpf =3D perf_event__process_bpf; - if (tool->text_poke =3D=3D NULL) - tool->text_poke =3D perf_event__process_text_poke; - if (tool->aux_output_hw_id =3D=3D NULL) - tool->aux_output_hw_id =3D perf_event__process_aux_output_hw_id; - if (tool->read =3D=3D NULL) - tool->read =3D process_event_sample_stub; - if (tool->throttle =3D=3D NULL) - tool->throttle =3D process_event_stub; - if (tool->unthrottle =3D=3D NULL) - tool->unthrottle =3D process_event_stub; - if (tool->attr =3D=3D NULL) - tool->attr =3D process_event_synth_attr_stub; - if (tool->event_update =3D=3D NULL) - tool->event_update =3D process_event_synth_event_update_stub; - if (tool->tracing_data =3D=3D NULL) - tool->tracing_data =3D process_event_synth_tracing_data_stub; - if (tool->build_id =3D=3D NULL) - tool->build_id =3D process_event_op2_stub; - if (tool->finished_round =3D=3D NULL) { - if (tool->ordered_events) - tool->finished_round =3D perf_event__process_finished_round; - else - tool->finished_round =3D process_finished_round_stub; - } - if (tool->id_index =3D=3D NULL) - tool->id_index =3D process_event_op2_stub; - if (tool->auxtrace_info =3D=3D NULL) - tool->auxtrace_info =3D process_event_op2_stub; - if (tool->auxtrace =3D=3D NULL) - tool->auxtrace =3D process_event_auxtrace_stub; - if (tool->auxtrace_error =3D=3D NULL) - tool->auxtrace_error =3D process_event_op2_stub; - if (tool->thread_map =3D=3D NULL) - tool->thread_map =3D process_event_thread_map_stub; - if (tool->cpu_map =3D=3D NULL) - tool->cpu_map =3D process_event_cpu_map_stub; - if (tool->stat_config =3D=3D NULL) - tool->stat_config =3D process_event_stat_config_stub; - if (tool->stat =3D=3D NULL) - tool->stat =3D process_stat_stub; - if (tool->stat_round =3D=3D NULL) - tool->stat_round =3D process_stat_round_stub; - if (tool->time_conv =3D=3D NULL) - tool->time_conv =3D process_event_time_conv_stub; - if (tool->feature =3D=3D NULL) - tool->feature =3D process_event_op2_stub; - if (tool->compressed =3D=3D NULL) { -#ifdef HAVE_ZSTD_SUPPORT - tool->compressed =3D perf_session__process_compressed_event; -#else - tool->compressed =3D perf_session__process_compressed_event_stub; -#endif - } - if (tool->finished_init =3D=3D NULL) - tool->finished_init =3D process_event_op2_stub; -} - bool perf_tool__compressed_is_stub(const struct perf_tool *tool) { return tool->compressed =3D=3D perf_session__process_compressed_event_stu= b; diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index fb7e32d98dda..0874e7924687 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -89,7 +89,6 @@ struct perf_tool { }; =20 void perf_tool__init(struct perf_tool *tool, bool ordered_events); -void perf_tool__fill_defaults(struct perf_tool *tool); =20 bool perf_tool__compressed_is_stub(const struct perf_tool *tool); =20 --=20 2.45.2.993.g49e7a77208-goog From nobody Wed Dec 17 08:55:21 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 60F2316EB4E for ; Thu, 11 Jul 2024 18:01:16 +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=1720720877; cv=none; b=WlawUJiJ6YFmG+d5wF15LBXwAfVoTRLJGy1gNy9XFs9Cav0JhRFel/aRbmbdcaXhWwl026Q9k5rpO6MTMF8jayOUOI7YmfZIINZldBQ1R+8liis+qMtol5NckzoZHaJa/RQ+DXH/Ile5INu7HXDEOk1kJVuiJlEqtXT1JtmuHYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720720877; c=relaxed/simple; bh=sUheNSIamO8SvMj19zBLNxCVmjvlLRxDlh7AUAyjtXE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ml853xuOMgYeZ6dhOSPtPPbe06gJBvj2yp5NyRrIJgSWdwcLVLV5p7Rm9KkTTNG7s/+Ql+1TvVRtvXYGjGlyC3Xdlez8zckhaLG/Tphh5A9rws3YccWmyK1tooZ3/FC6SwjzmyJn4XFwrO+sDZZqEXpOhlFygKV4sDer1YQihaU= 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=A62cr04h; 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="A62cr04h" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6511c587946so20063057b3.1 for ; Thu, 11 Jul 2024 11:01:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720875; x=1721325675; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=DzgUQ0L67yHK9ZgYOmZnLIT3MZDT9EVRhOxDmj12OGQ=; b=A62cr04hkQQibp8J0OdcECSoPMzacbWQ/GxOr3Az4CjlWJJe12QTN8OUPgQSRlkVhF ENyvH1fbqpWq/A5FViAXBwUCHsV9FXQgC4lYX/GN33y6VApwYa9+vs47xiH+vOozn6Vq rff/IzHvuo8VlT29alNRbdHzWcyBDzAUo3SeZ5o2OuOSDioa/57NMBFsh2bGG7WChNdB fjSEbn5wUDbv3BCVnukhWLAOn5EygM+uc9LV9ttxFn7GAwO7tYNBK+3cy7wPfra5io+o TWDdF2QH0Nchz4oAL5oZ/OZWPaYGZiZy22rBGWNTXxy4tMQlC3ak5HoPtTJU7bGVq2Sd 2NxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720875; x=1721325675; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DzgUQ0L67yHK9ZgYOmZnLIT3MZDT9EVRhOxDmj12OGQ=; b=RBUdPxM/wjK3Llq7wzCEsaLmYEpBaBtw2g+r2iyPHtzFCh8tzzUdQ+DOF4T5AJaAki F2UJch4S6reWKp2j+SRhmKWMEOTGdDnDDW0wqUl2gVsEne7ZzHg0f1I7yaQQl7RRw4Y1 2YM6f2KkwyosrjUf3MTUeEx4VLIZwsbjdS96n2iCJlkY7m9STfXTw+ROzI+ZJrWFX5q5 QOLb3CFwsmDEfMmEiJ5dd0RYe0Hcy4/Mf0BIFuMSwy7HST7A1ijinGQsl2GyEU2mQvUo St3/v5J6QY+l7LZdfk7+C8+YJz5BDzyc5FHYfvWttBSTreTlp2mS0yTcKNCbzNuzWjcI Z+TA== X-Forwarded-Encrypted: i=1; AJvYcCXDphCJ7WMnCKM/oaLBg74td0HonrI+oIMfNJ6Md1jKr2Jl5kN1tpeeqp54zV8yddCkDy7KiROKfCOgM8I/6adM6ZQhiRgxpTLVdZun X-Gm-Message-State: AOJu0YxOyboNXyUWHNN+4HYSSjj9eDLuRrVZ/WfvaDKuwdzeZ7hzWTDL hN92hJdR+DtTDCfgcGqMMyVuO2oPua6jHUK+MEePkp+Bdtb6ssFMlzOfaNp1tOEj1JrqIBl2NrT llrF9kQ== X-Google-Smtp-Source: AGHT+IF6ZsAvtsfjEpCo3Gdjx73peL+tpHFo6fSjhaKLM0gD5zmtULo0VxwhlOW9Ohb+tLATOGzcVSe0U1oD X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:2403:b0:e03:554e:f396 with SMTP id 3f1490d57ef6-e041b05b915mr366242276.6.1720720875256; Thu, 11 Jul 2024 11:01:15 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:08 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-29-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 28/28] perf session: Constify tool From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make tool const now that all uses are const and perf_tool__fill_defaults won't be used. The aim is to better capture that sessions don't mutate tools. Signed-off-by: Ian Rogers --- tools/perf/util/session.c | 6 +++--- tools/perf/util/session.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index ad5da61d2330..0c7cc092887d 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1765,7 +1765,7 @@ static int __perf_session__process_decomp_events(stru= ct perf_session *session); static int __perf_session__process_pipe_events(struct perf_session *sessio= n) { struct ordered_events *oe =3D &session->ordered_events; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct ui_progress prog; union perf_event *event; uint32_t size, cur_size =3D 0; @@ -2195,7 +2195,7 @@ static int __perf_session__process_events(struct perf= _session *session) .in_place_update =3D session->data->in_place_update, }; struct ordered_events *oe =3D &session->ordered_events; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; struct ui_progress prog; int err; =20 @@ -2245,7 +2245,7 @@ static int __perf_session__process_events(struct perf= _session *session) static int __perf_session__process_dir_events(struct perf_session *session) { struct perf_data *data =3D session->data; - struct perf_tool *tool =3D session->tool; + const struct perf_tool *tool =3D session->tool; int i, ret, readers, nr_readers; struct ui_progress prog; u64 total_size =3D perf_data__size(session->data); diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 7f69baeae7fb..7c8dd6956330 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -43,7 +43,7 @@ struct perf_session { u64 one_mmap_offset; struct ordered_events ordered_events; struct perf_data *data; - struct perf_tool *tool; + const struct perf_tool *tool; u64 bytes_transferred; u64 bytes_compressed; struct zstd_data zstd_data; --=20 2.45.2.993.g49e7a77208-goog