From patchwork Thu Jul 18 00:59:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 001BAC3DA60 for ; Thu, 18 Jul 2024 01:01:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=h3hGifXSQjj3nm6fESVDyQ4AnTNn7U8iAdJU/7HOQ5M=; b=yor8WeaV2mseMHqjEpghHoP3RL VRUeGtVnIYpbGdp7Qju9auf7/JLYbZy38ne/IUSdQGUu5tFWDwMEII7VKoC63USWPRD5PuuQ87L43 Hqj8VGFYxCqbfPLY6Zt76oQdwyBe5I+AooJCwQxaJQtwVs0vDylOSrUlxZxyNZYiL7k+nMNVLLEBq IC4r8rUYus12McIG7tU78lqYiHsUi5hvvlMBHSNGFgZpmSRmBuhUkl2wy3846xPr794yab5SyLRyp z6NYo6NlMXEP5+tfR6NnZdADMQrLtUOb6fdLiKyJV4TQWnjp9zmGA9SPrc5Q2R178f0KSMbHaIbt6 Wn5OWKUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWN-0000000FJmi-35gP; Thu, 18 Jul 2024 01:01:24 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFVg-0000000FJRQ-1Yq5 for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:00:41 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-665a6dd38c8so6531367b3.1 for ; Wed, 17 Jul 2024 18:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264438; x=1721869238; darn=lists.infradead.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=h3hGifXSQjj3nm6fESVDyQ4AnTNn7U8iAdJU/7HOQ5M=; b=fm/xnS//MfSK0V8EiJcnsXiEmAwbhOW3gufdoHkVc+0UGzBSPYr1x/Lfxe7MiMIK/B Siu3JoFPKhI0pL6g9jotDyw7jeBBGRjPeL2nW1CH63SPyrvbQkw2/cJf2hMJY+M6LmVr tmqjj9Q8wM9rKKmrNXBFaTJgRVpA2FoctvvpHgn0ZK1taRX6rQ7guWC9PoWqmlHF0gXc Xp8ny3BkIpDcMxOneEiSQ/CNEEUqxTqj4RtlABJ5V/hTchfZLf8CIicNFjVGkLc0b+TQ WsivS+fT1G9SjC01hsqYguVIYE7B8bW67NoeyXhX+V9Ian94EUYqiRLecBgiN+6PjNhZ 7Xiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264438; x=1721869238; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h3hGifXSQjj3nm6fESVDyQ4AnTNn7U8iAdJU/7HOQ5M=; b=UOs3aMKiItwG+xfmxt+uFk7OiaVcPV5kOfrX0c4FidvGjYvlXWr7AVp4H3my+242G3 TGyQ4YZrunIyNnbXIVWwCGPZbGhLXyW3imD40c7hBjxbWvF9EnN9HaGYsvoW50XaEJxs c+u2oevS7I/2zhhCCw539yIuMaBAf4eLcHA2LC/2qW1B2fQQyQMdgcyB2caRX1VqJRS7 SSOQ4fYNGs7H4OWMvC8o5zNFVWp+lafGJ0G5Ja24Dur3+eGJaEuh30xl8Z0TFvOajBOX ixTQQvouxGOoDLXVd22/1BzO1G5190BohGulyZD4Eq51uiF3oVk9Hq6rHLhEB6W7InX5 KelQ== X-Forwarded-Encrypted: i=1; AJvYcCWBXzjrMD/CPXyHfs9jjdArs15b19ZKVjCQHYUKgdjU+xnXuDlJMFX8BRbFF3HRz6DL1o9UCEEbkAPNbEodrurT/fBaiB2PDKzwHYeSeHNRtiOI3i4= X-Gm-Message-State: AOJu0YwZW6J1coBygd5mDQGrsbFXFly9A7cM6yStqttQ26Rok3tRbkRA MnzmOC8CsPVXWA7biliJaFzY6L/nGAAvwbuoQXTFZARprA7id7UdrtjslcgRdzh96yEVAKD8CrB GqvDVNA== X-Google-Smtp-Source: AGHT+IHw3VaaUAUkP9J/OduZR01vk+bxSTc0XaiCAt/SDLKwoDxaATIJIqZVnUceV4pBafhIsjwxsfpQNkph X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:c13:b0:e07:2e88:89fe with SMTP id 3f1490d57ef6-e072e888d78mr3276.3.1721264437877; Wed, 17 Jul 2024 18:00:37 -0700 (PDT) Date: Wed, 17 Jul 2024 17:59:57 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-2-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 01/27] perf auxtrace: Remove dummy tools From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180040_442735_74C4D8DD X-CRM114-Status: GOOD ( 16.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add perf_session__deliver_synth_attr_event that synthesizes a perf_record_header_attr event with one id. Remove use of perf_event__synthesize_attr that necessitates the use of the dummy tool in order to pass the session. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter Tested-by: Adrian Hunter Tested-by: Leo Yan --- tools/perf/util/arm-spe.c | 49 ++++++++----------------------------- tools/perf/util/cs-etm.c | 33 ++----------------------- tools/perf/util/intel-bts.c | 31 +---------------------- tools/perf/util/intel-pt.c | 24 +----------------- tools/perf/util/session.c | 24 ++++++++++++++++++ tools/perf/util/session.h | 3 +++ 6 files changed, 41 insertions(+), 123 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index afbd5869f6bf..fa40f3cb6266 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -1073,35 +1073,6 @@ static void arm_spe_print_info(__u64 *arr) fprintf(stdout, arm_spe_info_fmts[ARM_SPE_PMU_TYPE], arr[ARM_SPE_PMU_TYPE]); } -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 = - 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 = 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 = true; /* Level 1 data cache miss */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->l1d_miss_id = id; @@ -1180,7 +1151,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) id += 1; /* Level 1 data cache access */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->l1d_access_id = id; @@ -1192,7 +1163,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) spe->sample_llc = true; /* Last level cache miss */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->llc_miss_id = id; @@ -1200,7 +1171,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) id += 1; /* Last level cache access */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->llc_access_id = id; @@ -1212,7 +1183,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) spe->sample_tlb = true; /* TLB miss */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->tlb_miss_id = id; @@ -1220,7 +1191,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) id += 1; /* TLB access */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->tlb_access_id = id; @@ -1232,7 +1203,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) spe->sample_branch = true; /* Branch miss */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->branch_miss_id = id; @@ -1244,7 +1215,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) spe->sample_remote_access = true; /* Remote access */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->remote_access_id = 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 = true; - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->memory_id = id; @@ -1276,7 +1247,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) attr.config = PERF_COUNT_HW_INSTRUCTIONS; attr.sample_period = spe->synth_opts.period; spe->instructions_sample_period = attr.sample_period; - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->instructions_id = id; diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 5e9fbcfad7d4..7fd976ea954b 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1595,35 +1595,6 @@ static int cs_etm__synth_branch_sample(struct cs_etm_queue *etmq, return ret; } -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 = - 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 = 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_auxtrace *etm, attr.config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS; attr.sample_period = 1; attr.sample_type |= PERF_SAMPLE_ADDR; - err = cs_etm__synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; etm->branches_sample_type = attr.sample_type; @@ -1698,7 +1669,7 @@ static int cs_etm__synth_events(struct cs_etm_auxtrace *etm, attr.config = PERF_COUNT_HW_INSTRUCTIONS; attr.sample_period = etm->synth_opts.period; etm->instructions_sample_period = attr.sample_period; - err = cs_etm__synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; etm->instructions_sample_type = 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_session *session, return evsel->core.attr.type == bts->pmu_type; } -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 = - 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 = 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 |= PERF_SAMPLE_ADDR; pr_debug("Synthesizing 'branches' event with id %" PRIu64 " sample type %#" PRIx64 "\n", id, (u64)attr.sample_type); - err = intel_bts_synth_event(session, &attr, id); + err = 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); } -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 = - 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; pr_debug("Synthesizing '%s' event with id %" PRIu64 " sample type %#" PRIx64 "\n", name, id, (u64)attr->sample_type); - memset(&intel_pt_synth, 0, sizeof(struct intel_pt_synth)); - intel_pt_synth.session = session; - - err = perf_event__synthesize_attr(&intel_pt_synth.dummy_tool, attr, 1, - &id, intel_pt_event_synth); + err = 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_session *session, return machines__deliver_event(&session->machines, evlist, event, sample, tool, 0, NULL); } +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 = { + .attr_id.attr.header.type = PERF_RECORD_HEADER_ATTR, + .attr_id.attr.header.size = sizeof(ev.attr_id), + .attr_id.ids[0] = id, + }; + + if (attr->size != sizeof(ev.attr_id.attr.attr)) { + pr_debug("Unexpected perf_event_attr size\n"); + return -EINVAL; + } + ev.attr_id.attr.attr = *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); int perf_session__dsos_hit_all(struct perf_session *session); From patchwork Thu Jul 18 00:59:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735894 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 72A2DC3DA60 for ; Thu, 18 Jul 2024 01:01:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Rfk9ucJoML9tijv9a95Eu3szNeRcTXRIy2V/XQr/gxQ=; b=EnYYyMxlSDEazbH9zhgqYhsHLh U/oFZdlPqSun/7P+yPRXyDmGyER94p9sap0ZQisUByztNSnRlGf0Qs7DIRmDQWZuHiJWRGNu0rEH5 9Cmj9lUWTF0wsH7X1T+tXS2sref4BkUV8W1dFHfkcXVa4F+qfmQ3ZgCjouE8hDcfqKSJcYrIF5kaM /cc8j3jdGB51Ke6uDQOXKApWw0rQUVkrFWAYeDcckp3EK34q2gbz8o8v8l2A9jzNiweVaUZbJDQvm APywzf4Kakbvwu4MRbcFhGJzJxscvhqFKef3sTlKBC12Zchz1evKh2GTF9nRCw1SksEupmgGpU7j4 b+vw6i1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWj-0000000FJzd-3Q7r; Thu, 18 Jul 2024 01:01:45 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFVi-0000000FJSD-1KPA for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:00:43 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-664bc570740so6601027b3.0 for ; Wed, 17 Jul 2024 18:00:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264441; x=1721869241; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Rfk9ucJoML9tijv9a95Eu3szNeRcTXRIy2V/XQr/gxQ=; b=nnwQI7e09R4EZZO3u0mLHTbnRthqqv0EgcXnmM9cVNL+3qWOBtUTCa5meOWdfO7osV EoNSEAzIM+WJvgpQqeNpnFom2o8Hn9BTfXJyoj4cZq71A+d4Xds99nrc7OVN9GdXMPdy Oz/fCxHt/0a0NJoT1xo8kqQM2Bm+OIcM+gYKYjD0b/jGiTKfBEnIaxsDr+MPjx2qtXmX jAIqnCPREJIrtWq3/fm1IDRc0JAULQvuy5QE3UDKOdcPkl4JZwPnabQg8E5lmEwvaWe+ EXk6oMTW+Z2SaUpfB+HZ+UoOYCDrNi2Pf9KNFJr71sbW4KtI8zR042KWdgbqq7/wdNXe uGZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264441; x=1721869241; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Rfk9ucJoML9tijv9a95Eu3szNeRcTXRIy2V/XQr/gxQ=; b=PxnIltAgBMXj+SwHDAvf/1dUYSMk8aYuABv0/HUWyJ35/WWlJx0EtCp5keJV14f5+8 LcdMkTSvJRMRd/Idsa2C4OzYNX56a0/pSPDUCboTM+ICLKBEuP3PprmtHKBZHMFeKU+r w8gEdD+RpSl2SZwFM9lg8S8SdkF7cTogTHIY931v2qIyZn4Hiza7je9/RDS8JwM9Y2Pm uG3dwlmmoq+yU26AW6381G58ZJCH7gyMyp/jDwc7qDpwd3WyQcVo1qoPjz+T2r7KEpum XMieohWDDhRHIOQny9Tscmm8RANr9JgbC/yiYzj33uNkCpRpcB7iuJ8eJ1Ps+z4RUmSJ 47Yw== X-Forwarded-Encrypted: i=1; AJvYcCV3K1mAmnoopN/2Pp3Erl7gQzYQ4jrVaf6eEV1B1HOg2uqnQSz/33KDTzW0RqyYH3pmxWvPt7gSh5xFe0IKigZBQcGDD3Iz9ihBU3r6l50X8us3mxo= X-Gm-Message-State: AOJu0Ywj1dqBCEf0MBXHi0tq4TGLzYZ7jPsjOrEjUu9kwwIi/90xXgvL lKGtZNyO8rPccZhoqrwD+NCAutriPbwBy1jd57w5R6JgDdu6tL6rKM3jiU9XdvMwS2SJUE3IWrr LJPJm3g== X-Google-Smtp-Source: AGHT+IF1OSvxnc+b1qvFcgOaFfrd5/kufXk1J812jAsRRfTuvf0iLiBjVTC4aFaquSt3jO72OgbZ/5EwdMFh X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:4784:b0:665:24b0:e936 with SMTP id 00721157ae682-6660a82d4d3mr115707b3.4.1721264440715; Wed, 17 Jul 2024 18:00:40 -0700 (PDT) Date: Wed, 17 Jul 2024 17:59:58 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-3-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 02/27] perf s390-cpumsf: Remove unused struct From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180042_388501_15141D85 X-CRM114-Status: UNSURE ( 9.70 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct s390_cpumsf_synth was likely cargo culted from other auxtrace examples. It has no users, so remove. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/util/s390-cpumsf.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index 6fe478b0b61b..4ec583e511af 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -952,11 +952,6 @@ s390_cpumsf_process_event(struct perf_session *session, return err; } -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, From patchwork Thu Jul 18 01:00:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735896 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 89C59C3DA5D for ; Thu, 18 Jul 2024 01:02:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PachKYZvt+Ak/HJwDRx0Q9HBCPHIc5Z6FnMj3PkVK3Y=; b=0sFQJU4J5MEwPVLxrD+4fZTHZy 2H/kX3FY8N7RtvlwIDmGoVHNmrFBbpjW28o2tL1YOwo0Cbw+v8aEDvZOPS/gJ5jaOSCYH4o69KxUV khzDg7s2sceguJy5zdEXrtRrLq1JZYsAvJ19f+z6m8DZIAuCXKPYvQ2BpzsJ8b9yIVoNFVXZ5GbVv FHHh2WayvsAUfPdKrLpA8iXvjnblRYryYxusM1pSOT8evOgCH2QgSnlh5Kkn9NEjC1KvdUz2yg93t TTQGCMl55cNJT+8pdc86I6hiVmvWZaL5Zh8hyw6QA2K9gEu1g+F3hplg4wwnEHgA6kgPIM96wYqSi nynM61mg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFXP-0000000FKGr-1BlV; Thu, 18 Jul 2024 01:02:27 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFVn-0000000FJTQ-0RGF for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:00:53 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-664bc570740so6602407b3.0 for ; Wed, 17 Jul 2024 18:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264446; x=1721869246; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=PachKYZvt+Ak/HJwDRx0Q9HBCPHIc5Z6FnMj3PkVK3Y=; b=Ii810e1tdSlczRwMr3hiNCW3IynEtvI72AmlcTRDSu+hck1omMXQ/ZeU858WY+jpEv N3C6WSFfulfTj6IamwroI4fG55M+73PK6ouNiQpzcPF6dK6crS7TBS0VXxGfHlFWuZtp Oo6/CJ2be9dKaMsoIshfAZc8HrTNHhPHg/l3FApApeZYcSCdj1uG1Nr3RE1jA67F3udi 8TYMbUmHY0grQukOv4Jd+EQXxO/eM/21FpOyP4DQKQnkK6W2UGqlMstU4VSTm9nRC/uV W1fp5MOaX/TyZ3Ds5Ih1/5AEV8DWhsvCW8BlJBfe2vJHt3EtmAip/TRn4ia4sLQWunT2 DgRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264446; x=1721869246; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PachKYZvt+Ak/HJwDRx0Q9HBCPHIc5Z6FnMj3PkVK3Y=; b=oMV9SpjwBrX6nN2tg4QctnLHX6HJb7cWX0mQ/wWzUY9aFBJScnKx2rAOB1no6qUdek ipr5ZW8S95OAXpqtZjUqdwdCN49GhB3cOT8uPEFtYieaJ+sIY4BDwdk7iTiEhgKNEiJc A8uTv8rcaKnDnnCgQr+umkZb/M4vpweQhTUZJmAwZog+HfcvPXXVQltS8pi142P6CV1C 0npXz5+Xj6rJ5bPj2D5vPWR6zhSIaXnsnDI8yXygqRx/LE3ohNEqhawJiDdVOzskRqfN v6TieCm4ednyI899OAzAcRahgva7wgTS5kFzJE7HoSG4BBeYR41bDC9Sm3NDTUqJPcde t9QA== X-Forwarded-Encrypted: i=1; AJvYcCWH06TWXNm4q0r1HJbGSnTjKKPISkCmfKzipN9D7P/dsWMnuP41vy2ycLAm3RbDfw2IOBdJsgj3UBCktMx/Ds0CIrkHsqfnWx6AGRBB6D3nj2yzkpE= X-Gm-Message-State: AOJu0Yy9mdfVuNNeeozE0ZetP6HWfL/p7koq7uf6HBasubPFpiMXVIcV IApvIn+lgZ5FXdopLraK7vSVAZlklR/H9sNffZFgBl+sPpPmTdUyVecBQMdW8uhyuV+Qnk3iWnT V2fCKuA== X-Google-Smtp-Source: AGHT+IFZFSTWAVWYgQVywZ+faXv2VZaCBdht+bFDTqrSwDPm61j24HaG5zSH1Ii1f3maRyN6OLPLbe+mWMok X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a25:ce94:0:b0:e05:7113:920c with SMTP id 3f1490d57ef6-e05ff327141mr15993276.6.1721264445674; Wed, 17 Jul 2024 18:00:45 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:00 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-5-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 04/27] perf tool: Move fill defaults into tool.c From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180047_256156_5E9BDE73 X-CRM114-Status: GOOD ( 18.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The aim here is to eventually make perf_tool__fill_defaults an init function so that the tools struct is more const. Create a tool.c to go along with tool.h. Move perf_tool__fill_defaults out of session.c into tool.c along with the default stub values. Add perf_tool__compressed_is_stub for a test in perf_session__process_user_event. perf_session__process_compressed_event is only used from being default initialized so migrate into tool.c. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/util/Build | 1 + tools/perf/util/session.c | 310 +----------------------------------- tools/perf/util/session.h | 2 - tools/perf/util/tool.c | 325 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/tool.h | 4 + 5 files changed, 331 insertions(+), 311 deletions(-) create mode 100644 tools/perf/util/tool.c diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 0f18fe81ef0b..f3633342374a 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -65,6 +65,7 @@ perf-util-y += map.o perf-util-y += maps.o perf-util-y += pstack.o perf-util-y += session.o +perf-util-y += tool.o perf-util-y += sample-raw.o perf-util-y += s390-sample-raw.o perf-util-y += 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 -#ifdef HAVE_ZSTD_SUPPORT -static int perf_session__process_compressed_event(struct perf_session *session, - union perf_event *event, u64 file_offset, - const char *file_path) -{ - void *src; - size_t decomp_size, src_size; - u64 decomp_last_rem = 0; - size_t mmap_len, decomp_len = session->header.env.comp_mmap_len; - struct decomp *decomp, *decomp_last = session->active_decomp->decomp_last; - - if (decomp_last) { - decomp_last_rem = decomp_last->size - decomp_last->head; - decomp_len += decomp_last_rem; - } - - mmap_len = sizeof(struct decomp) + decomp_len; - decomp = mmap(NULL, mmap_len, PROT_READ|PROT_WRITE, - MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); - if (decomp == MAP_FAILED) { - pr_err("Couldn't allocate memory for decompression\n"); - return -1; - } - - decomp->file_pos = file_offset; - decomp->file_path = file_path; - decomp->mmap_len = mmap_len; - decomp->head = 0; - - if (decomp_last_rem) { - memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_last_rem); - decomp->size = decomp_last_rem; - } - - src = (void *)event + sizeof(struct perf_record_compressed); - src_size = event->pack.header.size - sizeof(struct perf_record_compressed); - - decomp_size = zstd_decompress_stream(session->active_decomp->zstd_decomp, 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 += decomp_size; - - if (session->active_decomp->decomp == NULL) - session->active_decomp->decomp = decomp; - else - session->active_decomp->decomp_last->next = decomp; - - session->active_decomp->decomp_last = 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_compressed_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 *session) free(session); } -static int process_event_synth_tracing_data_stub(struct perf_session *session - __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 __maybe_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 *tool __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 __maybe_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 = read(fd, buf, min(n, (off_t)sizeof(buf))); - if (ret <= 0) - return ret; - n -= ret; - } - - return 0; -} - -static s64 process_event_auxtrace_stub(struct perf_session *session __maybe_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_unused, - union perf_event *event __maybe_unused) -{ - dump_printf(": unhandled!\n"); - return 0; -} - - -static -int process_event_thread_map_stub(struct perf_session *session __maybe_unused, - 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_unused, - 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_unused, - 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 __maybe_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 == NULL) - tool->sample = process_event_sample_stub; - if (tool->mmap == NULL) - tool->mmap = process_event_stub; - if (tool->mmap2 == NULL) - tool->mmap2 = process_event_stub; - if (tool->comm == NULL) - tool->comm = process_event_stub; - if (tool->namespaces == NULL) - tool->namespaces = process_event_stub; - if (tool->cgroup == NULL) - tool->cgroup = process_event_stub; - if (tool->fork == NULL) - tool->fork = process_event_stub; - if (tool->exit == NULL) - tool->exit = process_event_stub; - if (tool->lost == NULL) - tool->lost = perf_event__process_lost; - if (tool->lost_samples == NULL) - tool->lost_samples = perf_event__process_lost_samples; - if (tool->aux == NULL) - tool->aux = perf_event__process_aux; - if (tool->itrace_start == NULL) - tool->itrace_start = perf_event__process_itrace_start; - if (tool->context_switch == NULL) - tool->context_switch = perf_event__process_switch; - if (tool->ksymbol == NULL) - tool->ksymbol = perf_event__process_ksymbol; - if (tool->bpf == NULL) - tool->bpf = perf_event__process_bpf; - if (tool->text_poke == NULL) - tool->text_poke = perf_event__process_text_poke; - if (tool->aux_output_hw_id == NULL) - tool->aux_output_hw_id = perf_event__process_aux_output_hw_id; - if (tool->read == NULL) - tool->read = process_event_sample_stub; - if (tool->throttle == NULL) - tool->throttle = process_event_stub; - if (tool->unthrottle == NULL) - tool->unthrottle = process_event_stub; - if (tool->attr == NULL) - tool->attr = process_event_synth_attr_stub; - if (tool->event_update == NULL) - tool->event_update = process_event_synth_event_update_stub; - if (tool->tracing_data == NULL) - tool->tracing_data = process_event_synth_tracing_data_stub; - if (tool->build_id == NULL) - tool->build_id = process_event_op2_stub; - if (tool->finished_round == NULL) { - if (tool->ordered_events) - tool->finished_round = perf_event__process_finished_round; - else - tool->finished_round = process_finished_round_stub; - } - if (tool->id_index == NULL) - tool->id_index = process_event_op2_stub; - if (tool->auxtrace_info == NULL) - tool->auxtrace_info = process_event_op2_stub; - if (tool->auxtrace == NULL) - tool->auxtrace = process_event_auxtrace_stub; - if (tool->auxtrace_error == NULL) - tool->auxtrace_error = process_event_op2_stub; - if (tool->thread_map == NULL) - tool->thread_map = process_event_thread_map_stub; - if (tool->cpu_map == NULL) - tool->cpu_map = process_event_cpu_map_stub; - if (tool->stat_config == NULL) - tool->stat_config = process_event_stat_config_stub; - if (tool->stat == NULL) - tool->stat = process_stat_stub; - if (tool->stat_round == NULL) - tool->stat_round = process_stat_round_stub; - if (tool->time_conv == NULL) - tool->time_conv = process_event_time_conv_stub; - if (tool->feature == NULL) - tool->feature = process_event_op2_stub; - if (tool->compressed == NULL) - tool->compressed = perf_session__process_compressed_event; - if (tool->finished_init == NULL) - tool->finished_init = process_event_op2_stub; -} - static void swap_sample_id_all(union perf_event *event, void *data) { void *end = (void *) event + event->header.size; @@ -1672,8 +1365,7 @@ static s64 perf_session__process_user_event(struct perf_session *session, int fd = perf_data__fd(session->data); int err; - if (event->header.type != PERF_RECORD_COMPRESSED || - tool->compressed == perf_session__process_compressed_event_stub) + if (event->header.type != PERF_RECORD_COMPRESSED || perf_tool__compressed_is_stub(tool)) dump_event(session->evlist, event, file_offset, &sample, file_path); /* 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 *session); int perf_session__queue_event(struct perf_session *s, union perf_event *event, u64 timestamp, u64 file_offset, const char *file_path); -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 *session, + union perf_event *event, u64 file_offset, + const char *file_path) +{ + void *src; + size_t decomp_size, src_size; + u64 decomp_last_rem = 0; + size_t mmap_len, decomp_len = session->header.env.comp_mmap_len; + struct decomp *decomp, *decomp_last = session->active_decomp->decomp_last; + + if (decomp_last) { + decomp_last_rem = decomp_last->size - decomp_last->head; + decomp_len += decomp_last_rem; + } + + mmap_len = sizeof(struct decomp) + decomp_len; + decomp = mmap(NULL, mmap_len, PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); + if (decomp == MAP_FAILED) { + pr_err("Couldn't allocate memory for decompression\n"); + return -1; + } + + decomp->file_pos = file_offset; + decomp->file_path = file_path; + decomp->mmap_len = mmap_len; + decomp->head = 0; + + if (decomp_last_rem) { + memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_last_rem); + decomp->size = decomp_last_rem; + } + + src = (void *)event + sizeof(struct perf_record_compressed); + src_size = event->pack.header.size - sizeof(struct perf_record_compressed); + + decomp_size = zstd_decompress_stream(session->active_decomp->zstd_decomp, 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 += decomp_size; + + if (session->active_decomp->decomp == NULL) + session->active_decomp->decomp = decomp; + else + session->active_decomp->decomp_last->next = decomp; + + session->active_decomp->decomp_last = 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 *session + __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 __maybe_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 *tool __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 __maybe_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 = read(fd, buf, min(n, (off_t)sizeof(buf))); + if (ret <= 0) + return ret; + n -= ret; + } + + return 0; +} + +static s64 process_event_auxtrace_stub(struct perf_session *session __maybe_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_unused, + union perf_event *event __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + + +static +int process_event_thread_map_stub(struct perf_session *session __maybe_unused, + 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_unused, + 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_unused, + 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 __maybe_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 == NULL) + tool->sample = process_event_sample_stub; + if (tool->mmap == NULL) + tool->mmap = process_event_stub; + if (tool->mmap2 == NULL) + tool->mmap2 = process_event_stub; + if (tool->comm == NULL) + tool->comm = process_event_stub; + if (tool->namespaces == NULL) + tool->namespaces = process_event_stub; + if (tool->cgroup == NULL) + tool->cgroup = process_event_stub; + if (tool->fork == NULL) + tool->fork = process_event_stub; + if (tool->exit == NULL) + tool->exit = process_event_stub; + if (tool->lost == NULL) + tool->lost = perf_event__process_lost; + if (tool->lost_samples == NULL) + tool->lost_samples = perf_event__process_lost_samples; + if (tool->aux == NULL) + tool->aux = perf_event__process_aux; + if (tool->itrace_start == NULL) + tool->itrace_start = perf_event__process_itrace_start; + if (tool->context_switch == NULL) + tool->context_switch = perf_event__process_switch; + if (tool->ksymbol == NULL) + tool->ksymbol = perf_event__process_ksymbol; + if (tool->bpf == NULL) + tool->bpf = perf_event__process_bpf; + if (tool->text_poke == NULL) + tool->text_poke = perf_event__process_text_poke; + if (tool->aux_output_hw_id == NULL) + tool->aux_output_hw_id = perf_event__process_aux_output_hw_id; + if (tool->read == NULL) + tool->read = process_event_sample_stub; + if (tool->throttle == NULL) + tool->throttle = process_event_stub; + if (tool->unthrottle == NULL) + tool->unthrottle = process_event_stub; + if (tool->attr == NULL) + tool->attr = process_event_synth_attr_stub; + if (tool->event_update == NULL) + tool->event_update = process_event_synth_event_update_stub; + if (tool->tracing_data == NULL) + tool->tracing_data = process_event_synth_tracing_data_stub; + if (tool->build_id == NULL) + tool->build_id = process_event_op2_stub; + if (tool->finished_round == NULL) { + if (tool->ordered_events) + tool->finished_round = perf_event__process_finished_round; + else + tool->finished_round = process_finished_round_stub; + } + if (tool->id_index == NULL) + tool->id_index = process_event_op2_stub; + if (tool->auxtrace_info == NULL) + tool->auxtrace_info = process_event_op2_stub; + if (tool->auxtrace == NULL) + tool->auxtrace = process_event_auxtrace_stub; + if (tool->auxtrace_error == NULL) + tool->auxtrace_error = process_event_op2_stub; + if (tool->thread_map == NULL) + tool->thread_map = process_event_thread_map_stub; + if (tool->cpu_map == NULL) + tool->cpu_map = process_event_cpu_map_stub; + if (tool->stat_config == NULL) + tool->stat_config = process_event_stat_config_stub; + if (tool->stat == NULL) + tool->stat = process_stat_stub; + if (tool->stat_round == NULL) + tool->stat_round = process_stat_round_stub; + if (tool->time_conv == NULL) + tool->time_conv = process_event_time_conv_stub; + if (tool->feature == NULL) + tool->feature = process_event_op2_stub; + if (tool->compressed == NULL) { +#ifdef HAVE_ZSTD_SUPPORT + tool->compressed = perf_session__process_compressed_event; +#else + tool->compressed = perf_session__process_compressed_event_stub; +#endif + } + if (tool->finished_init == NULL) + tool->finished_init = process_event_op2_stub; +} + +bool perf_tool__compressed_is_stub(const struct perf_tool *tool) +{ + return tool->compressed == perf_session__process_compressed_event_stub; +} 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; }; +void perf_tool__fill_defaults(struct perf_tool *tool); + +bool perf_tool__compressed_is_stub(const struct perf_tool *tool); + #endif /* __PERF_TOOL_H */ From patchwork Thu Jul 18 01:00:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 226D1C3DA5D for ; Thu, 18 Jul 2024 01:02:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UnSPlghBx3VkMv83qbGk/P7jIBEF9LRODtE5BbjiJPc=; b=GiG4k2wZPoa/sXFxJ4GtEgdS4f imzPgenQIExNKM1MInX5kUXy25zRbLjqhaaSAWlzVpx4GUD54taF2ZDiusdIskoEo1bb3SB4eXxz7 0ollZ+pfkPLSAI+C9Eik76RusAKRA+lVGstqxsiozgoIKW2pcWiHcrJV8VadILXyHtonifWJcgSKF Nh6GSFAhP9JN58kAhMYgMB819sFp4op9HKX4xs5WnTfWUV3H0G6roRhmA5yh24QDgSZpuJaxG0nFr vtRV3B9BHFCzhPC8AiWCNECkSQ6HVCH5hQ9XGPkIxDg0Hr+anUhAS4jtVdmeiHzqd6VL/waWKnR0k 8Cfdxjng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFX5-0000000FK81-2Mqj; Thu, 18 Jul 2024 01:02:07 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFVp-0000000FJUR-1SYs for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:00:52 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-64b70c4a269so6429257b3.1 for ; Wed, 17 Jul 2024 18:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264448; x=1721869248; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=UnSPlghBx3VkMv83qbGk/P7jIBEF9LRODtE5BbjiJPc=; b=qaLiOvd6VqUzPYGLjl5bYEWx/MsxLBuNUVTbgd34fp85uIqIfc+K4tgZfWHEp7xfTM XMq96obHROhktefLnOgqJYwUcV+ukrvFdkP1NgpTcYONTEU0giAI4CY9kTJLC0IdDrQ7 ly5mBVlAUavRNSwdNBLOBB+ZnRO9gWHIT3aSOxPbrps20vzVfo7jn18ForKxpjuNlIMG uzbH2/TYIAoRX28Ow9tlG3RFguFgsjMZ+Nmi2rixP+I8BwfNUlJ1c4BNxhq3O4ZOaZoB D117Ac0CTYCJNwbdvAq3I4vUbfZ4nXwY+73j4yEkuoesKjYwepXAOZbQcFA0gVOM+enU qc7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264448; x=1721869248; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UnSPlghBx3VkMv83qbGk/P7jIBEF9LRODtE5BbjiJPc=; b=mx02OVtYwOlQJ4PAcmaA/7dKGKho7PVCKnjxf4dm9KgVOHyIDf7o7wktW2/5LK7MPa HWLboNwYurvMmDYOeDm+crYCvbD6yakTvjZV/YC8oRXiigv1JwU87swPohAgi/uuj+gI eoGl7yhWIDjDZH8RKai9P1gjiv/pgyBuK7edhY9pHo13PBJ6WqjuCl8PfujzVqrcMAgn HoOZQTvASIjnHSLdNnHqI7hlRTL/XX1u41iL441gVC2u5oa7Ax1HX6RnKmSjlgyk9Gy2 tnvSGYvS71s29OFrQCyJBcpODmohKFY44fEG6EVYwMntcNRxwIJHzh2KmGabHyrLfvgC 4bGw== X-Forwarded-Encrypted: i=1; AJvYcCXZ0ZQ0s0KXeqihG/ukVslqv5CReTdXLixA0LVPT2K2gxKrNnay5mQ6myldxJ0H8DmYIGuwvM2dVh6Es5sUFYngCHiq1W4P8qV+pIJcL5k/TSHum3k= X-Gm-Message-State: AOJu0YwkgR3fAnfRcOMOck7Rvp0dVHjN6hK8DLPFayHKDnJCKnIhmnbc 9tdQNkF8zxfwvbx6RK7SAJosZL7TeiFce2HQjGBwdzJlEYk5KTR76CpFQCQvdcYFGHxmrvhWyMM sKXftug== X-Google-Smtp-Source: AGHT+IEtJVGPJ7X377yE2YXSNRqiPai0lkaBu0kyQ7M1ExKy3MUuhJpxePliNSESNkfKYo7HPJkc1WZwBgQJ X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:110:b0:65c:1db1:9235 with SMTP id 00721157ae682-666005395bbmr263657b3.0.1721264447940; Wed, 17 Jul 2024 18:00:47 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:01 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-6-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 05/27] perf tool: Add perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180049_536927_7CB098A5 X-CRM114-Status: GOOD ( 11.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add init function that behaves like perf_tool__fill_defaults but assumes all values haven't been initialized. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/util/tool.c | 58 ++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/tool.h | 1 + 2 files changed, 59 insertions(+) diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c index 17219ecb8fa6..cbd9b888bd73 100644 --- a/tools/perf/util/tool.c +++ b/tools/perf/util/tool.c @@ -230,6 +230,64 @@ static int perf_session__process_compressed_event_stub(struct perf_session *sess return 0; } +void perf_tool__init(struct perf_tool *tool, bool ordered_events) +{ + tool->ordered_events = ordered_events; + tool->ordering_requires_timestamps = false; + tool->namespace_events = false; + tool->cgroup_events = false; + tool->no_warn = false; + tool->show_feat_hdr = SHOW_FEAT_NO_HEADER; + + tool->sample = process_event_sample_stub; + tool->mmap = process_event_stub; + tool->mmap2 = process_event_stub; + tool->comm = process_event_stub; + tool->namespaces = process_event_stub; + tool->cgroup = process_event_stub; + tool->fork = process_event_stub; + tool->exit = process_event_stub; + tool->lost = perf_event__process_lost; + tool->lost_samples = perf_event__process_lost_samples; + tool->aux = perf_event__process_aux; + tool->itrace_start = perf_event__process_itrace_start; + tool->context_switch = perf_event__process_switch; + tool->ksymbol = perf_event__process_ksymbol; + tool->bpf = perf_event__process_bpf; + tool->text_poke = perf_event__process_text_poke; + tool->aux_output_hw_id = perf_event__process_aux_output_hw_id; + tool->read = process_event_sample_stub; + tool->throttle = process_event_stub; + tool->unthrottle = process_event_stub; + tool->attr = process_event_synth_attr_stub; + tool->event_update = process_event_synth_event_update_stub; + tool->tracing_data = process_event_synth_tracing_data_stub; + tool->build_id = process_event_op2_stub; + + if (ordered_events) + tool->finished_round = perf_event__process_finished_round; + else + tool->finished_round = process_finished_round_stub; + + tool->id_index = process_event_op2_stub; + tool->auxtrace_info = process_event_op2_stub; + tool->auxtrace = process_event_auxtrace_stub; + tool->auxtrace_error = process_event_op2_stub; + tool->thread_map = process_event_thread_map_stub; + tool->cpu_map = process_event_cpu_map_stub; + tool->stat_config = process_event_stat_config_stub; + tool->stat = process_stat_stub; + tool->stat_round = process_stat_round_stub; + tool->time_conv = process_event_time_conv_stub; + tool->feature = process_event_op2_stub; +#ifdef HAVE_ZSTD_SUPPORT + tool->compressed = perf_session__process_compressed_event; +#else + tool->compressed = perf_session__process_compressed_event_stub; +#endif + tool->finished_init = process_event_op2_stub; +} + void perf_tool__fill_defaults(struct perf_tool *tool) { if (tool->sample == 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; }; +void perf_tool__init(struct perf_tool *tool, bool ordered_events); void perf_tool__fill_defaults(struct perf_tool *tool); bool perf_tool__compressed_is_stub(const struct perf_tool *tool); From patchwork Thu Jul 18 01:00:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0C907C3DA5D for ; Thu, 18 Jul 2024 01:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Y0AwPG4o0G47V27ShPbkOoNNhsGypnaaBt/qve64P2w=; b=Y+DhkGea78cI92z5+G6dP+WYS3 FaPcdWvgggny9ZLNAGJU3VnetHmSaehKmS7ayBFK5bfHD+oo0RrIULNJPQkjbzleGnx5XQduzrO42 c4HQDoTEJPVB6SflUkzv3ORbb15/MnWvysTuj7edWQ1EhArsjIYiBK2UQOt2jU5SYfiFH1dPw1JjJ tUh3P6S49J7jx0062G6fyMw15M5ryNpKq5ouovVLZXCDI8sd+K1pJ1Mc8AG976COsPH7A7EavoZPt PWq8+P4GxAdC8yFOrKAXWLKBHcDW5+lZfzkr6Xrr/m7ml3khySGyywWnb1oBXOZZsoQ0OVZpkI1Dk xgRQ0KQQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFXi-0000000FKO0-3BTB; Thu, 18 Jul 2024 01:02:47 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFVs-0000000FJVj-1GiG for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:00:54 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6648363b329so5845697b3.3 for ; Wed, 17 Jul 2024 18:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264450; x=1721869250; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Y0AwPG4o0G47V27ShPbkOoNNhsGypnaaBt/qve64P2w=; b=25koUhE8hdxywsfahcS//Wpv+6EDla7XhjeNA7kd/rqqVwo4GaH2fdCTzUd5n1QO2W u1dO30lLLxvbc4bY6CE9zE6EEN7EHgf04ikc3vdF1+APjhdlL6DO8gFJuYG8HRfUrZIv zJqXgK6lFOGKFN6bnyA/ewobO/jdy+zDGESHeL1XXar14WWNtMd9HCmsoafMRkZCCcy2 8p8hxRCSXHU8+MgF6yN1goaVW2/TsTDxsFb7i9FBf0z7xILREjU2nVIjOqAQ/PIrl3M/ 3g5F30/yYglw6sYQ8Q86WX648GR2MubKE7kjIpseRAiRiM9ymx5oD/A4O+klO+IvdeI2 eI+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264450; x=1721869250; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Y0AwPG4o0G47V27ShPbkOoNNhsGypnaaBt/qve64P2w=; b=qijmT8I4ZXDXVsvs1FF/WFxaak5vWHlOcrZlVebfzoSkGyHKvYUhRIzTkZlEdZrsF3 nO67+SYjnQZS5y6DjE4S71RrJV9hN0PZRPtzCBvYRkRj+egx/T8l7loAobePvsigGdKi RAZ+veU7p8vRXE7XKT/hXh0nv6NBet3n/3tCCzLVUIL6spPtyU2QzisVqNucLdojN27L 3XrkXoJ0NX1FTqxEs5Nbwzkgt/cuyfNfGhd2BvbF/zbzwwod5sVe6QUtNh/QP+YETxIZ SPitDrSJneJ4tSf1O4JMB/ESkQRxvSa/XxquX7SP3m9EJyGQ4V6jCjOoXtn1OlHf8HRH m5IA== X-Forwarded-Encrypted: i=1; AJvYcCW7atyykJvUYSPIvEmViki/i7QI8tsfBehTgp5C5Jl4se/qhRUyW5KYh5c5M0+mSai0RbsRGWuwnLpzZcEGHSiF2SusmISoot9+gbD8TlYR9+VUAcs= X-Gm-Message-State: AOJu0YxyP2dZw4MiSQwbuByefbUhiJnVCi+gDQQoSfRe3gFw6ZhZgYDm kguFVpcExpMtFc815axpixzP4fQTgg4lX/pGy2xYWxWmy0IL5r4aIOpIh7wMlHADq6kGza6zx8X x9sgo4A== X-Google-Smtp-Source: AGHT+IF6Z+ddaWru78kkv+Rbe/2ixIoAa0Oh0Ttd6cumo1XTW3h3Qcnj/31TOiTWD2HXbFwryaFb3vcyoCHV X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:ec8:b0:665:a4a4:57c1 with SMTP id 00721157ae682-666015f3170mr275337b3.2.1721264450488; Wed, 17 Jul 2024 18:00:50 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:02 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-7-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 06/27] perf kmem: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180052_499751_5FA92CB2 X-CRM114-Status: GOOD ( 14.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Reduce the scope of the tool from global/static to just that of the cmd_kmem function where the session is scoped. Use the perf_tool__init to initialize default values. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-kmem.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 859ff018eace..b3cbac40b8c7 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -986,15 +986,6 @@ static int process_sample_event(const struct perf_tool *tool __maybe_unused, return err; } -static struct perf_tool perf_kmem = { - .sample = process_sample_event, - .comm = perf_event__process_comm, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .namespaces = perf_event__process_namespaces, - .ordered_events = true, -}; - static double fragmentation(unsigned long n_req, unsigned long n_alloc) { if (n_alloc == 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[] = "No %s allocation events found. Have you run 'perf kmem record --%s'?\n"; int ret = perf_config(kmem_config, NULL); @@ -1998,6 +1990,13 @@ int cmd_kmem(int argc, const char **argv) data.path = input_name; + perf_tool__init(&perf_kmem, /*ordered_events=*/true); + perf_kmem.sample = process_sample_event; + perf_kmem.comm = perf_event__process_comm; + perf_kmem.mmap = perf_event__process_mmap; + perf_kmem.mmap2 = perf_event__process_mmap2; + perf_kmem.namespaces = perf_event__process_namespaces; + kmem_session = session = perf_session__new(&data, &perf_kmem); if (IS_ERR(session)) return PTR_ERR(session); From patchwork Thu Jul 18 01:00:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735898 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2DD54C3DA60 for ; Thu, 18 Jul 2024 01:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=82lJtR2QiowtdojpRIK0xRJphQA1CgRwB82Bes7qNdo=; b=h4H15DMATAMF2WFxzNwjxQyBSZ sEhYTKRX3Ds4QgYG3joZI1O9WNxY5NmXD86+DKwaWO4vEmZPN+kP/AgcR+gs7bv3ZnDaM7yXzbKGQ 1kMl0seC87nEt7pl+XicJQPBI4ogTL1B2Be+d+upbvBkhLWTmArDPyC5cJ6jo3VOa2MObaiG2Wqin XVIjCM/Z6MqvuNCyph46UyXVBfNx7M+ZxkcmJQ3ApgXGk2qJ0UWeFAD1UejOSEkgK5Z9RUxfMi6qG LE9AdXRwZY/kfbN/zKK9FW7wrvsLYfZPlx2vb2zV4RMCgoi2WWapUuet4lbibXyPJ7qJJXox09aSx oz/DyjPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFY1-0000000FKUT-2Hq0; Thu, 18 Jul 2024 01:03:05 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFVu-0000000FJX6-1uXu for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:00:56 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6648363b329so5847207b3.3 for ; Wed, 17 Jul 2024 18:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264453; x=1721869253; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=82lJtR2QiowtdojpRIK0xRJphQA1CgRwB82Bes7qNdo=; b=T7Ubcpn4POpK01R+Q/6JOKb6VMy/kNhZ/TRaa9a5bPrOCvnLx34peKpLquuBjDnfDH HcxBibMJFQ87J9F+r5zPmp4cV0aHaE3Yx/h6HYdqAohGM9ZGIfbfAhU299Ogb1L+5Ohl wxLk4q1FeQfriwY88UswgaNhJpzYm6OcpOtGjYu45VgJTzYo1MpWo0aXQGmE+j8/YVVz R1NDbNeZ5FoR/S16TxX756Nq/0RSa5k/VW9WwBt/72Om4F/KyziNkGC8qz0cGIhl9cQJ YnlwPXIBBDNTD0/8smaUzhjvQMCrVdDLwOXqZva2XPnTMOjnHu1VvCi0Y4dWzIyuyPd4 OD8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264453; x=1721869253; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=82lJtR2QiowtdojpRIK0xRJphQA1CgRwB82Bes7qNdo=; b=JgvTes/i00kCKtzvsKgJwdDVkIch/jLN6LjCUSV2ZVshc09FHXmrlSF3Qr6LgzBSmP VBhKzAf9vQMwsfThcSuzs3V27BVvxzCoKhyd97vOzk4dxDiA0m/u9+eLoF7JdEHXW6jI ykdF9G9ficHtLsXbTzDSFR//e/DfmpH178VxG9yVpq4LZrDlB2EuHp5Nz+RZrh1xAr/O vxuhYtke2HdiyZij/b0szvGM9Zn29wyGSn+8N1r8MPjldhfGxGH7gc05ECfKcupBJnLD 9DpV+K6Ux/RV4AvJdPtDNSvQDbQCHuZj1gpGE4m6+1sIzVvpHHw8fbbSPlRf4oyrzjMC WcpQ== X-Forwarded-Encrypted: i=1; AJvYcCWoO1sgNyfNiW7UPIixuYeuTp8dVmnTGD7g3WxOlUCcAE4yjLxaR87agz/Yy8nDrPpCeYkNqs6k6oL3rN9bNrykSLIDWS9hn3TLK+sjVgCNHOLvCMg= X-Gm-Message-State: AOJu0YyQ2mpD2i7NEDxQ1NNqMNo5wDKpneGGIrLW0ZVKKr+SCiR1o5rY oKTdk4xVFnlVtdtjXap/kCZRdc9zSC0pQEt8gPIYVZFsFnqoLCnCvkQXedn5PkRZI47mCLngwvo rI8pq7A== X-Google-Smtp-Source: AGHT+IEyKD1zw/SRriBJYp/5PAftCKkg1vVG8YgDL9BHxzbdv3Dg4Oi+rhd7WFZsx5MgVc5quGMumQEfcIPT X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:ec8:b0:665:a4a4:57c1 with SMTP id 00721157ae682-666015f3170mr275457b3.2.1721264452941; Wed, 17 Jul 2024 18:00:52 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:03 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-8-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 07/27] perf buildid-list: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180054_629285_E7E20E1B X-CRM114-Status: GOOD ( 16.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Reduce scope of build_id__mark_dso_hit_ops to the scope of function perf_session__list_build_ids, its only use, and use perf_tool__init for the default values. Move perf_event__exit_del_thread to event.[ch] so it can be used in builtin-buildid-list.c. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-buildid-list.c | 10 ++++++++++ tools/perf/util/build-id.c | 32 ------------------------------- tools/perf/util/build-id.h | 4 +--- tools/perf/util/event.c | 20 +++++++++++++++++++ tools/perf/util/event.h | 4 ++++ 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index 383d5de36ce4..52dfacaff8e3 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c @@ -89,6 +89,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits) .mode = PERF_DATA_MODE_READ, .force = force, }; + struct perf_tool build_id__mark_dso_hit_ops; 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; + perf_tool__init(&build_id__mark_dso_hit_ops, /*ordered_events=*/true); + build_id__mark_dso_hit_ops.sample = build_id__mark_dso_hit; + build_id__mark_dso_hit_ops.mmap = perf_event__process_mmap; + build_id__mark_dso_hit_ops.mmap2 = perf_event__process_mmap2; + build_id__mark_dso_hit_ops.fork = perf_event__process_fork; + build_id__mark_dso_hit_ops.exit = perf_event__exit_del_thread; + build_id__mark_dso_hit_ops.attr = perf_event__process_attr; + build_id__mark_dso_hit_ops.build_id = perf_event__process_build_id; + session = 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; } -static int perf_event__exit_del_thread(const struct perf_tool *tool __maybe_unused, - union perf_event *event, - struct perf_sample *sample - __maybe_unused, - struct machine *machine) -{ - struct thread *thread = 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 = { - .sample = build_id__mark_dso_hit, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .fork = perf_event__process_fork, - .exit = perf_event__exit_del_thread, - .attr = perf_event__process_attr, - .build_id = perf_event__process_build_id, - .ordered_events = true, -}; - int build_id__sprintf(const struct build_id *build_id, char *bf) { char *bid = 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; }; -struct nsinfo; - -extern struct perf_tool build_id__mark_dso_hit_ops; struct dso; struct feat_fd; +struct nsinfo; 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 *tool __maybe_unused, return machine__process_exit_event(machine, event, sample); } +int perf_event__exit_del_thread(const struct perf_tool *tool __maybe_unused, + union perf_event *event, + struct perf_sample *sample __maybe_unused, + struct machine *machine) +{ + struct thread *thread = 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: %#"PRI_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 *tool, 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, From patchwork Thu Jul 18 01:00:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 27A0BC3DA60 for ; Thu, 18 Jul 2024 01:03:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ai5lnf0BUO6/UnVTaHRIu7hu7sAuyoUd1EC+9E9ZCBs=; b=I9/eUJoulXBNjSUxHYuMRR5gru AF40laShHF5G8xtXljyQmtg16mRSXnEFrHFVYNCEN97ZKGyxMKblcLdpkie+5TWZfngp0AMD60G/q FSaO56PUtrT8w2Z1xVAykwhLnDSk0/KxSW2xboVtzVV7+9fZNfmbaEzEOBeP4PqfyAnMYfK36gXQa y/M5AFy4jec/aknZ3/GuSF5MDvFW5gLQRDrbytGXOubStQdz46q1V5N1twdG6BG65knVEmVJOqQaH phccX/y3ZMrVv87C2l8WeH9qK6CMBtRVXMfMa18MdjGenM0FbZ+grFkQGbsQ53K0sZrZyxBZPIGCL BbPHbsUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFYL-0000000FKd0-0JZl; Thu, 18 Jul 2024 01:03:25 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFVw-0000000FJY3-3XCf for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:00:58 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e05f08adcacso780614276.0 for ; Wed, 17 Jul 2024 18:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264455; x=1721869255; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=ai5lnf0BUO6/UnVTaHRIu7hu7sAuyoUd1EC+9E9ZCBs=; b=JLa2X/wigXr+eyybkI85QSSJ5UqdRrYtTOgVM6kPpVv3p+/JcknOIZ/h4DIGEU4Hho qdjbLSO28bAncZ6kjmea70vLhh+UNEQfq8pXHM5Q6l2kiOrnu2JHTNbhOGh2auiOKqfw pYquKxHRUVniEgr8JfPMWisC4uGy9ULeHue17yso3++8MJgCPJtMHqL12U/Jzg+02JJF Mzx/o1nKYL44AyTwQj7jkA10LkV7qX6xhFx0ySM/LFVvPwzJR412Qkh6JVgOhYwZYpKw eIWtRtgwz+N+scCRnFaN86NQDPCWWa673MVhbDqSNoHvLwG6AQrh95hKmwi65odd+zwq CsXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264455; x=1721869255; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ai5lnf0BUO6/UnVTaHRIu7hu7sAuyoUd1EC+9E9ZCBs=; b=laByMS86J2XrUhZcJ4idZsN1+Pc+1UqmJfx/1xWxkZoCQ7kl7vBP4QNHXWOsgZP71D cvfETKoINRhX+xcs2M2+IHB/bqXr6qttBWW18o2bzHVe4Lm75ilopb5+A6jeyaRt/e53 HeFtQE1HGkyRJ71XCO8YdG5z5B660FzZFzAMuYvmpmrjOWOjGZ0PU0j5FfAVgkpkTRXY iob9ztIGJhGy2Vhv1Oq+Y77DYriU4Ac9m4c2OGdGFZe6NNqJJ0cPBFFD3PJMITKLowiz 7lNJEakaID1Pa2Usd3cDsIzNpNA7FpM4SKYde9Zz1+4GLq1t64z/iCVeJV7+k20gxlBD Tspg== X-Forwarded-Encrypted: i=1; AJvYcCXVsQzsEc4gO7SBR9v0rk1IcuveQAYROC1P7WgW+i/QQaFu3gJxGx676nrt0e+p36hoE/bu/7oRgtR5gd3ugwQNBom2qJtWZTttuZ/AQn/KtnLuLpE= X-Gm-Message-State: AOJu0YwDaV3XBTMQjsmPRwKITu7nFf17J8S4JEz98jDIyLalqw08P9lb Xa+77OLCLYaaUrpzzEVfUTjJ9PXOBR6rKWLGE2W3Q2ZnYZShwq9ws5dpz/ubKTFZz+Hauyjmxb2 pbUpCqA== X-Google-Smtp-Source: AGHT+IFez645P/F0hZdJQXU/7kuPyHdktbnSXSbfLcl/dMKl+NBTQzET3BcxRmAOKtpToRAendNoVwwOs114 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:102e:b0:e05:eb99:5f73 with SMTP id 3f1490d57ef6-e05fe83bae5mr2806276.0.1721264455354; Wed, 17 Jul 2024 18:00:55 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:04 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-9-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 08/27] perf kvm: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180056_908305_AE7C4721 X-CRM114-Status: GOOD ( 12.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-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; - struct perf_tool eops = { - .sample = process_sample_event, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .ordered_events = true, - }; struct perf_data file = { .path = kvm->file_name, .mode = PERF_DATA_MODE_READ, .force = kvm->force, }; - kvm->tool = eops; + perf_tool__init(&kvm->tool, /*ordered_events=*/true); + kvm->tool.sample = process_sample_event; + kvm->tool.comm = perf_event__process_comm; + kvm->tool.namespaces = perf_event__process_namespaces; + kvm->session = 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 *kvm, /* event handling */ + perf_tool__init(&kvm->tool, /*ordered_events=*/true); kvm->tool.sample = process_sample_event; kvm->tool.comm = perf_event__process_comm; kvm->tool.exit = perf_event__process_exit; kvm->tool.fork = perf_event__process_fork; kvm->tool.lost = process_lost_event; kvm->tool.namespaces = perf_event__process_namespaces; - kvm->tool.ordered_events = true; - perf_tool__fill_defaults(&kvm->tool); /* set defaults */ kvm->display_time = 1; From patchwork Thu Jul 18 01:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735900 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 65BEEC3DA60 for ; Thu, 18 Jul 2024 01:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+bihPZPBGJ6d8qN0fHDZAaoj4FmhnLovUYATiB5ueYI=; b=LYGHNkUXevQ2fNAOQmF18X9nKy 6IJYodixr3tPv6ksk/bPrMNVhSU/itBCUBXMKdSgc5pDSNkWx2FGcjTGpB8lGMxn8o22CNr6KYW77 n27aYAWOcOh43slWUnDU9tS7sZLfT70D6f2z/Z4JIzd9wb2ZCzC/s9RkoZprs7eE/ywbQgoH6EoZU ivwaP0H6hTRDw4zu4kLd6mWSWTV5OVMi6xgdx0Wir31f/B2PxpsoqK6TfK34SYQ31meNzMaozRqLa G5Qv6mJTLRSU4H9FtT1K/ebJevvRqcOVf5M7sj3oLQJup+RkvfGBEc04A9XcUXdDpYY5LTaWfRoOv 7fFfT3BQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFYg-0000000FKmp-1Q6k; Thu, 18 Jul 2024 01:03:46 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFVy-0000000FJYw-46t3 for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:00 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-66480c1a6b5so7330497b3.1 for ; Wed, 17 Jul 2024 18:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264458; x=1721869258; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=+bihPZPBGJ6d8qN0fHDZAaoj4FmhnLovUYATiB5ueYI=; b=N9k05I3OB3oH1N3VaEVYDd1kgPT3rAJrCCwFUf9vcp8hDb//weLRsW6o76Hp2BxzJw JUscW/NIhI7wq51WGL+xfqUIXWAG7Zk384BTZGB+JYvgoUK3zAkh++OuxXySaz/G/VJO QVn/Y/CZJTbgyTebyHraLuSZYda/HVp2jUV1Lrvf4xJyZ5p5bY7A3+b3j8dKByjqUBDB Zi/KbYZAqictWOo8VnO9UjhSspvnzu6yjj2/2d27pC7msRwWf49QbpTQc3TpR6l/JRHJ pct3KJBPh7j+ynKQiIsCrknLDaumeoNlosB2OABQ8kX3MoOR1nCzD6b5HOTeMJIUUPeF /D8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264458; x=1721869258; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+bihPZPBGJ6d8qN0fHDZAaoj4FmhnLovUYATiB5ueYI=; b=BDXE5+32eT2hArfnumDmvmLoRALAA4zuF6S9iwyjCrs2xRczqmbOCkl3vaM6G+F4Dr 3QfUUNMX+L9xxojlJ65vabhh21OdaRLNNCI9Q2JiSz72ebhRYAfL1R4Nvux2xMT9Fs8q AR+q8e2Lfopr+pdu0KKYfNgXMk5DjfxT7nrWCbyzBhPIF9+xU2a42e0jvalb9639YAim 3hn5YxmIveKkgqF8Zr+zPEHAPKVbdkbV9MmtOsySt4HvWOtyiF+uJgg1vRnMo1wkaXG+ MbQxWjdI/YXDDoSI/aIBHAp0YewYEDBCvHGTbYrWkAU+7hmIE91et5YdBCuatjLMtypm khuA== X-Forwarded-Encrypted: i=1; AJvYcCXxfC8aNN5nnsQuCsIgbu/igkYW2UswVqlDn18HKAPJpL4UMlIzGLbm87vR9BEyKW+cQ4Z2y0Oh4LvVEcekoJ8hnM1UJPycXQR9E3Yjqg3J6M7dkZM= X-Gm-Message-State: AOJu0YzV9LcB3kVvDZ8DhNDrQumQsKa9kzUCR7BXOBhdA6qiXDct/gsv 8iVAqQvRiay6X9x58hJMpsmaKnk8wxi4L3kYeZBX1ItgeXdt9x9Xml3NGJeKVwgHDQRFCblunrs 8TABWjQ== X-Google-Smtp-Source: AGHT+IGDEF3uZXg4slq61N/gjbSuBnIZfH69MFL5bkSpRqZ+m4jNhYliSi0lDnLt9dM73d7tpplzPVLMX02w X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a81:ae04:0:b0:64b:a85:e2c5 with SMTP id 00721157ae682-666019e3b2amr337027b3.3.1721264457820; Wed, 17 Jul 2024 18:00:57 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:05 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-10-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 09/27] perf lock: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180059_050570_0863EBB8 X-CRM114-Status: GOOD ( 12.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-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 = -EINVAL; - struct perf_tool eops = { - .attr = perf_event__process_attr, - .event_update = process_event_update, - .sample = process_sample_event, - .comm = perf_event__process_comm, - .mmap = perf_event__process_mmap, - .namespaces = perf_event__process_namespaces, - .tracing_data = perf_event__process_tracing_data, - .ordered_events = true, - }; + struct perf_tool eops; struct perf_data data = { .path = input_name, .mode = PERF_DATA_MODE_READ, .force = force, }; + perf_tool__init(&eops, /*ordered_events=*/true); + eops.attr = perf_event__process_attr; + eops.event_update = process_event_update; + eops.sample = process_sample_event; + eops.comm = perf_event__process_comm; + eops.mmap = perf_event__process_mmap; + eops.namespaces = perf_event__process_namespaces; + eops.tracing_data = perf_event__process_tracing_data; session = 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 struct option *options, static int __cmd_contention(int argc, const char **argv) { int err = -EINVAL; - struct perf_tool eops = { - .attr = perf_event__process_attr, - .event_update = process_event_update, - .sample = process_sample_event, - .comm = perf_event__process_comm, - .mmap = perf_event__process_mmap, - .tracing_data = perf_event__process_tracing_data, - .ordered_events = true, - }; + struct perf_tool eops; struct perf_data data = { .path = input_name, .mode = PERF_DATA_MODE_READ, @@ -2100,6 +2091,14 @@ static int __cmd_contention(int argc, const char **argv) con.result = &lockhash_table[0]; + perf_tool__init(&eops, /*ordered_events=*/true); + eops.attr = perf_event__process_attr; + eops.event_update = process_event_update; + eops.sample = process_sample_event; + eops.comm = perf_event__process_comm; + eops.mmap = perf_event__process_mmap; + eops.tracing_data = perf_event__process_tracing_data; + session = perf_session__new(use_bpf ? NULL : &data, &eops); if (IS_ERR(session)) { pr_err("Initializing perf session failed\n"); From patchwork Thu Jul 18 01:00:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B56ECC3DA60 for ; Thu, 18 Jul 2024 01:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BRYCHYYbMGKjB3Qvf71te5ARgV5gIJcFTXBlC43nr00=; b=NZhsNfZ2aYCdIN3B8/WmmTxUil 3YDzv/T3LiJUTpgCeM+AkapmqLH3LP5VSZ2d5gZ/Hnj2LoLg6KZbSIbTwCdQ7cm3PSPODL6xE+FDK ujp+hHdL4oVw7vX+HGqLjvZp1Swmdz+zFWF8DNDM39H7y7x72k4+EJbNxOHkiqDYiLJNYxOVvEE3U NvhWj3RsTSogOMHJ94WgErknEZmNayYOJvkIkhJrtqiDmgv2G6SljqaHG0OXhcp0Q8ow7EivMLixV muR71n7mpjc9mP+34RpPWJNeSvbXZZrj7bmQuyZ04IaUBS/pakp+306RgOltTvO3unP7B0USNetHX 6pUFSAZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFYz-0000000FKut-3UTH; Thu, 18 Jul 2024 01:04:05 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFW1-0000000FJZh-2O5q for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:04 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e05a8aa4478so705886276.1 for ; Wed, 17 Jul 2024 18:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264460; x=1721869260; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=BRYCHYYbMGKjB3Qvf71te5ARgV5gIJcFTXBlC43nr00=; b=gr+TxFgGT2ux/pfvZiEHlHKB06ZvxlRmjecExrR0UsQcu2lwYXKaqNmTLrKGRTSLYV gxUbiwvq+a7bmCCZ39ia1eNKxYB1Ybx0zJjgRYOEIG8NxBrvA+rO0xTN00bbeBK6tYJD tNC9wxxaiTU7HQVKztEdoFFBSYsrJZwtdgvlOWG274ilKuPm89Y0D6ZJNO3S5qXBFTjZ 2S3+Ob66kdIAQAoqwNPjr1v2CyINRDBGm2Mr0q5b97C2q/0IXXejnPPoDg/G8LnMHY3K nsDRFREC/38dAvg+LbQgEZyskgX1JV9KxEzjOi60u1fteKhDah1hRl5bT43GlZfMQdyW 8scA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264460; x=1721869260; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BRYCHYYbMGKjB3Qvf71te5ARgV5gIJcFTXBlC43nr00=; b=g9PLnG+Q0nTkMhb/xJ6lXVId1/6sbFE5yllyafSKRbhljAXsk/5cLX7blnsh+s3+7B qPEifTpPzHQOa+OU9mcg5/m/geFMyAoQCjUY3korB/2xlvrCHMsW1WWlJvr8gI+XpwMG Xtuyd5J6QYe2orGI5uBrb7xdhOoMD+r8L3rfDShNsKxQbRySa8M7vFJseBrIOKK5wN9z sv29crUFeQQP2HW+YMdNt8Cp0yEzw+80Fq6O4a0F7da3Rb4/IhW8tva9uh4lPaLgZFNy QsUtiidM5ZgY/eJ+lfXDiuJpsGCCUDYqwKDnuTA7QHX/CgOPsYX+aDV/ryE3F7xEpnxC CBVA== X-Forwarded-Encrypted: i=1; AJvYcCUzs56iYZY6580SwfXHVHwgWTKnbnuspaXnBPYS4aqwsKJBBtOli/9eYoVHijZsY2pu0o5OjQJ1XyGprTDo8HBFWF8TtBDE1Ge8X2LtcKS+IFxkUZQ= X-Gm-Message-State: AOJu0YwXTsM4koafRqBggt0CbHDNhepO/o9FcAMlnJ/smzmZhmn9soWO iuFTNynGI1H8ALPFvSzIViA5uQQ4eTn2L8k6ISEhl/yWURDV8ODgCOsd5NHeZ/x1/rxmV5WLCb1 2E3cPAw== X-Google-Smtp-Source: AGHT+IFYtrxkbVfYcmj/8+44DV+o0ePqkzDO07+yzQP4ulp2Q9arWW+kMFkiLAGqIisbVnxNl9FY7TnY38mC X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:100b:b0:e05:a1df:5644 with SMTP id 3f1490d57ef6-e05ff4c5bedmr36307276.2.1721264460178; Wed, 17 Jul 2024 18:01:00 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:06 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-11-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 10/27] perf evlist: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180101_650208_1634B89D X-CRM114-Status: GOOD ( 14.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-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 perf_attr_details *details .mode = PERF_DATA_MODE_READ, .force = details->force, }; - struct perf_tool tool = { - /* only needed for pipe mode */ - .attr = perf_event__process_attr, - .feature = process_header_feature, - }; + struct perf_tool tool; bool has_tracepoint = false; + perf_tool__init(&tool, /*ordered_events=*/false); + /* only needed for pipe mode */ + tool.attr = perf_event__process_attr; + tool.feature = process_header_feature; session = perf_session__new(&data, &tool); if (IS_ERR(session)) return PTR_ERR(session); From patchwork Thu Jul 18 01:00:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735902 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EC990C3DA5D for ; Thu, 18 Jul 2024 01:04:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WcLk/IdzOPY+RjxovTTq+hic/bNKHt+pBKiPhBtB+zE=; b=4fZNaiaIb5fLiaeTQTP0Vk9lkG X3dRoZgcDNSYcAfgv3Ef4sR3qPct7oO4WlfmCaVHayVMpWtAVYq8kwk1RIFNMQG39FSI1FOsVSGRj B69zblpFP/5xjkSQLFtuLDiGzt7df9Xurs3lESg28IX2fzq2kFI8YRQ055hliJezemPwmPx8+y1Ei J9V2WzP7zETEjpv+5mG5W7hBq0NlxELM0SX6FD01fKfRJYiMyeYA8/RWBWdlTRih43XSgvFahcEPr S+XUEANTBdY1dHBaNVIV6Embj3sQbqBNPFIsgUwMxHnC8XAqje4XG1bcYec0V89GDYYQb/MZ/4Jxh QJvhqAGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFZI-0000000FL1f-19l2; Thu, 18 Jul 2024 01:04:24 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFW4-0000000FJax-0Edh for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:06 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6511c587946so7305857b3.1 for ; Wed, 17 Jul 2024 18:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264462; x=1721869262; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=WcLk/IdzOPY+RjxovTTq+hic/bNKHt+pBKiPhBtB+zE=; b=ZeM/o++R+MMVPTGHIByLQDiTsHThqRhy66hs44FYPAwxnqhRQz8dm+jd8iWi+t5xUm DVCl6JCSINyzkLufBXCLerDc70V0W/I/DFI0l28c7V2Ht91lWVqL7sAunSe6OGWedQQg 27Lft7GQAd565Gx+qstrWENI0R5PU93NrpbEf8tnO6NkUmV65ATOpLoZWBc1WKwK2BgI eOMYLxLqcrHt1tB63HbfFqjGvaKUyFumkIfpdkpiKr/AyX2i/jzvUFAm4n7MV2dAIppp jjyrTESutAWDWTw+9BManJKLrK+aaib774afmEamg3HZt8kpFZwWuL2CKUsKJg4ntF5g Qu9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264462; x=1721869262; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WcLk/IdzOPY+RjxovTTq+hic/bNKHt+pBKiPhBtB+zE=; b=o19/PKtiqPg4fHGGWnLd6lJ1Ahg4jmt5/4drB224yGydMkol+/NPgGTu3iYkZCZo+0 PDmFB+nYWDhjgoZ7CBjVyEdJJaSS6nihL3hY32BjSIZPNjQgmZ4NtCiNLB8DQDhdlw8/ Ngf3M1WMH5A4me7vHDgtdGUHH8PxmJlMfDP4lJC1xOEooufg+Va+jcFeIdd648K4eZOD mCBS11HdJYgiU2TK8tnh5UOiiWLDpXBhC2wTe5tS5o4cDqq7f2Kd8GXnVodfUP+29KOZ BsHvMUxI+MDIcDb2UPZRlPOsF8ekdLIxfmZ4Yus67BGs1Xp8xkEBoANY36If7xjsgXp4 i1ag== X-Forwarded-Encrypted: i=1; AJvYcCUXRyfszapnQw0XlJJjqBr1D0ygwl7Yg8wI4SLrcO5M1NDt5ep9+VSiwWdWLMV6Iwbt2rfeWgTpm+OulGcs0X9iq7RJrUX7FUToxTPTcDkTURYuUww= X-Gm-Message-State: AOJu0YxdFMr7oN1A8yy9iTxFBlXlNiMvcbp70P5HXkRR7GINRqlnY/lT wDk+kf1Y9tQykeJbaBg7fKMAmW3dremn+DfQMxibYL6lmNOT2RtWAKBIfd36gg07wJgiYe3/cg0 ED/skTQ== X-Google-Smtp-Source: AGHT+IEKHTyblJoo125sOHAe4wzZxtfBlpdtI8dNPSpZYT1yA/iN+KaAbZBujqa3GKfkudcZLR62quUfwf8I X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:288:b0:65c:2536:be7f with SMTP id 00721157ae682-66604a8c105mr572767b3.7.1721264462396; Wed, 17 Jul 2024 18:01:02 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:07 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-12-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 11/27] perf record: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180104_195478_21CEE51F X-CRM114-Status: GOOD ( 15.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-record.c | 33 ++++++++++++++++++++------------- tools/perf/util/tool.c | 10 +++++----- tools/perf/util/tool.h | 6 ++++++ 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index f27f725913d7..12a5170d9193 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -193,6 +193,15 @@ static const char *affinity_tags[PERF_AFFINITY_MAX] = { "SYS", "NODE", "CPU" }; +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 perf_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 = NULL; + rec->tool.sample = process_event_sample_stub; 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); } + perf_tool__init(tool, /*ordered_events=*/true); + tool->sample = process_sample_event; + tool->fork = perf_event__process_fork; + tool->exit = perf_event__process_exit; + tool->comm = perf_event__process_comm; + tool->namespaces = perf_event__process_namespaces; + tool->mmap = build_id__process_mmap; + tool->mmap2 = build_id__process_mmap2; + tool->itrace_start = process_timestamp_boundary; + tool->aux = process_timestamp_boundary; session = perf_session__new(data, tool); if (IS_ERR(session)) { pr_err("Perf session creation failed.\n"); @@ -3326,18 +3345,6 @@ static struct record record = { .ctl_fd_ack = -1, .synth = PERF_SYNTH_ALL, }, - .tool = { - .sample = process_sample_event, - .fork = perf_event__process_fork, - .exit = perf_event__process_exit, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .mmap = build_id__process_mmap, - .mmap2 = build_id__process_mmap2, - .itrace_start = process_timestamp_boundary, - .aux = process_timestamp_boundary, - .ordered_events = true, - }, }; const char record_callchain_help[] = 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; } -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); bool perf_tool__compressed_is_stub(const struct perf_tool *tool); +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 */ From patchwork Thu Jul 18 01:00:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1C0A4C3DA60 for ; Thu, 18 Jul 2024 01:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6ObbEjhFM3S/nqQ2a9JTWztyQVhPi6FIfEEKm2Nh8Ec=; b=bt2xLyNnqmyW36DiGpX5OzmyH6 O2MFD2Q3ACveqZ/fUpzgLl9rkgHAWtJSrXlC+iK4OKy94c/00WERPJSfCPuzd+wyqXQYE8iuAJnUq 3fF7Wpa8XoyCAbgsGQ6SeO6WSW/eWSW/KLg7aSRXPkai6MCvKR7E9H3QonO1+NB+HJtcQCUjLBwiP x5vfWSlzL2VMiNi3PL8TqQFkoontP9bRvKHWiHoirWXlqI+82merx3DXM0+xURPcrPSLrPfIq5pAp OVtAR6pP9UgeYaxiyRY6wtp4dpgE5f3MBUZtHRM+Q+BoHL4r5qMHGZxwTGoZfrg6XJ6eyRQyIcgie skuagM5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFZb-0000000FL9C-2rms; Thu, 18 Jul 2024 01:04:43 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFW6-0000000FJcO-0QRP for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:07 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-664b7a67ad4so6037167b3.2 for ; Wed, 17 Jul 2024 18:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264465; x=1721869265; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=6ObbEjhFM3S/nqQ2a9JTWztyQVhPi6FIfEEKm2Nh8Ec=; b=IaluyEEOVLy6aCnJc1yCGjevyf7eCF1e0pT0fy9+mFMIoMEzFLdFKfsiAc4ds9ue4f QFmsmDX++tZCbPXDaNpN63joevplXHSfGcOuRwBCluFdFN9HbmIMLYXjADki9Wd/rSKD KalvBg1jNx3McSWyKBlSx9CuAViZCx+bYO0kaAb1wl/A8ImONHsU9JfFElLencW02y+r xqTush2KrpTKaat/652yfmgXoy7rBsBZuGsoD6IuUMfyhJCFi1Dhkzt7ZMtiM7TYo2Q4 U2+PBWHOzWAGDVBZKshOaEiHfi5HxNO92Qh4sgSqsLuwFA8EkJzlt2KJMQKltjRaUfW4 sgHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264465; x=1721869265; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6ObbEjhFM3S/nqQ2a9JTWztyQVhPi6FIfEEKm2Nh8Ec=; b=thwgE+3HCC86sUxehkTan9grJnC1SxIWCHHhtAzWF0jPUIr2fUsQYjW6DN4Jg9OASS K5UeI8R9izyZ5T4Cr8ou2l2dQI1SSVZGF/IA4e2gkElilAzeIO5U9twAdLXvQW6ftCKh GXeVVq76JAGStBs6pzhHKqiDxiO1n5gbCQrTs4w14RXGL6lwZdn/Sqz4qSHBlSKNluRP LYYKfY1Pa3kwbhuWZTbFe903WCOY0oTkCafQiz+UlVHVx2QXmA3yBiE096KHRRiRDMVL 0DzvDZoyWmnaaPI9Ln0VuilnCZZTXaWKUVJ+4orXD4/UsIciPNQrYOz9I0wTC7JYjiuw XHqw== X-Forwarded-Encrypted: i=1; AJvYcCWWxIO0Y/j/xBPhkooOvMZFIpKR6gi5oeSM1ptIAsMG0ZMRAYgkF3zm7+OQfP1WjuMzyBRWOWO6Bh2h6Hai9cu3NC/0vCd0mF2rz6Vc+E1D/si1xUQ= X-Gm-Message-State: AOJu0YyRKYGXYIY+F2KgjoHgCRvVBWpM/0WWBvP6IxrhdffIOKwlNqXf EwV/vAuEtNNeXtV1vgLA8GL2NySupyZigyRfEkgliJPXO9dqrqlxosfwxGtCLGc15OaLs0WrqlK O+DNmZw== X-Google-Smtp-Source: AGHT+IFdgOy/X0s/tSjgL8YFyCv2y+t9vrNn3n8rqeB7qn0Nz6DvIZ6Nsl/HvGV8i0mKMunHPP3MdC/NEvT0 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:3405:b0:622:cd7d:fec4 with SMTP id 00721157ae682-66605444531mr325627b3.9.1721264464720; Wed, 17 Jul 2024 18:01:04 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:08 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-13-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 12/27] perf c2c: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180106_188291_6B820576 X-CRM114-Status: GOOD ( 11.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-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; } -static struct perf_c2c c2c = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, - .attr = perf_event__process_attr, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .auxtrace_error = perf_event__process_auxtrace_error, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, -}; - static const char * const c2c_usage[] = { "perf c2c {record|report}", NULL @@ -3070,6 +3052,19 @@ static int perf_c2c__report(int argc, const char **argv) data.path = input_name; data.force = symbol_conf.force; + perf_tool__init(&c2c.tool, /*ordered_events=*/true); + c2c.tool.sample = process_sample_event; + c2c.tool.mmap = perf_event__process_mmap; + c2c.tool.mmap2 = perf_event__process_mmap2; + c2c.tool.comm = perf_event__process_comm; + c2c.tool.exit = perf_event__process_exit; + c2c.tool.fork = perf_event__process_fork; + c2c.tool.lost = perf_event__process_lost; + c2c.tool.attr = perf_event__process_attr; + c2c.tool.auxtrace_info = perf_event__process_auxtrace_info; + c2c.tool.auxtrace = perf_event__process_auxtrace; + c2c.tool.auxtrace_error = perf_event__process_auxtrace_error; + c2c.tool.ordering_requires_timestamps = true; session = perf_session__new(&data, &c2c.tool); if (IS_ERR(session)) { err = PTR_ERR(session); From patchwork Thu Jul 18 01:00:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735904 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D03F4C3DA60 for ; Thu, 18 Jul 2024 01:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pNFK3i3CL2hY169owdLoin8oWSW6A2yJIcLVmlGvbqE=; b=B3rNRwUO9BQquq9uNHgQ2EP9xA cvh1eG5rQLLK3gUXAlN9eWkemQ0DnSHiOYFbdjpEBMcFwkpT8xOkXthO/P3JJWYBTBiWN8+B27iBJ Kh/xJoJKow14oA3Qt4nNnep57GUbrFRn6hu1EEsSUXPKC799vDWXQkWmp9IrZ/Yyzvu+wjJ8VUVIx 4pRj1xhqG5ELVbhADckRT3ZRGKm5aOOlHaHDS4dukIxOYFNtbDsE1hq/xZ9X8l8Fmh1BEgWxfpPAY l3FJlPTZdDimtNgxTzzToeHzTnk3LohjSdmM5fNOawyKtHs0xL8yFR7MW2D96nwSMRsoauvKpxMom t/GJFbQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFZt-0000000FLGH-38nY; Thu, 18 Jul 2024 01:05:01 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFW8-0000000FJe3-1YQT for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:10 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e05faf3fdc4so650951276.2 for ; Wed, 17 Jul 2024 18:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264467; x=1721869267; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=pNFK3i3CL2hY169owdLoin8oWSW6A2yJIcLVmlGvbqE=; b=nOLAqD46QZ2jSguJZEUVTox4wGvU8r3Ej1JSpL2i73Kh5fD84s1J00r3sbnJ4WmZtU lOLGg/+74a6HKwrDq/7aOToP4ZU2fKlogKB8Q6VM4vA7GuN1cqNXIBUnTyHKbVt1U9J6 kv8a3sTGJIO1YhMUfE/OTq/KkS/LkoN/vebdJ5rlizj98hTQeXAO3xyOfx/lbvLN1mJq EeppUkXgTh6cdtWeJ1W5AHMXNiYkwxXO4ELPbH0V16IDHITLex8kD8uuNBLa9u+Scajf 1HlhykMW34K9Rh9ocQjJBg4cbwn/DQ6huZVylEX8d3dUXkfktyEdWIUJuQPpo6hN7YyX 8R2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264467; x=1721869267; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pNFK3i3CL2hY169owdLoin8oWSW6A2yJIcLVmlGvbqE=; b=o78/vVT6re7H9fB2hYIek4c+K+jf3iwGTrlDCWNHncdm19wqqAwjWYLOkjH38YC+qb /duLkE0luE1cbvZfsoKKpUQPzFNOQRNioAHpjS1AP+Amtd7ZwWMafma+AuS98MNtrsmh F+3o05eva4PO/UnmYA8IIkoIhNHnisTbYDA8++zAIkN7T+ctQUiZrR8UPyFcsuLusVfr +udrwLfbZoXDWp6C7fo9DKDB+dy+gqCE1IQMOqbCQ9lJwfglJphlyxpS5JVwrX4qiafI 18dN49RyaUxBcIV/OPqmmdIg8DK13yHfnYrMUfBXSXC58NIcXxItGUZBw289LxXtqIET iIOg== X-Forwarded-Encrypted: i=1; AJvYcCV2xuvKXrXGspgkTqDzBicpQMT5/X9ckxpuenknnA+RaqcGkOak3LYlpAR0soR2hMWss5Ib56sJ5336ZDaZ33f8j5dUcxns5AvdxrPyeg94lPdlQXw= X-Gm-Message-State: AOJu0Yy0Ef238pZuOuZ9+dBbmK7hwsPAIfShaxglJTMpHhT7ag9sr5eS LiGfALh/DPQTX6h6I62nd4HKY97lS5QFQ18Ud6WY9507mve6ZXSk7Qwn4EBgF6II9K7xu287339 Eh47p2A== X-Google-Smtp-Source: AGHT+IFHPEUR6SHxDxIGONs3PPAyxDcCJ98okKUpCTVwExnLyEiQ71Kvctfkm9eZdP+bwodMy6NLwOHXvMHK X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:1003:b0:e05:a345:259a with SMTP id 3f1490d57ef6-e05febdcb0bmr22837276.9.1721264467108; Wed, 17 Jul 2024 18:01:07 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:09 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-14-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 13/27] perf script: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180108_522869_A28A6B6B X-CRM114-Status: GOOD ( 13.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-script.c | 65 +++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 394bce9f5338..b4fc2971335b 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -3899,38 +3899,7 @@ int cmd_script(int argc, const char **argv) const char *dlfilter_file = NULL; const char **__argv; int i, j, err = 0; - struct perf_script script = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .cgroup = perf_event__process_cgroup, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .attr = process_attr, - .event_update = perf_event__process_event_update, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .feature = process_feature_event, - .build_id = perf_event__process_build_id, - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_script__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .auxtrace_error = perf_event__process_auxtrace_error, - .stat = perf_event__process_stat_event, - .stat_round = process_stat_round_event, - .stat_config = process_stat_config_event, - .thread_map = process_thread_map_event, - .cpu_map = process_cpu_map_event, - .throttle = process_throttle_event, - .unthrottle = process_throttle_event, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, - }; + struct perf_script script = {}; struct perf_data data = { .mode = PERF_DATA_MODE_READ, }; @@ -4102,10 +4071,8 @@ int cmd_script(int argc, const char **argv) data.path = input_name; data.force = symbol_conf.force; - if (unsorted_dump) { + if (unsorted_dump) dump_trace = true; - script.tool.ordered_events = false; - } if (symbol__validate_sym_arguments()) return -1; @@ -4296,6 +4263,34 @@ int cmd_script(int argc, const char **argv) use_browser = 0; } + perf_tool__init(&script.tool, !unsorted_dump); + script.tool.sample = process_sample_event; + script.tool.mmap = perf_event__process_mmap; + script.tool.mmap2 = perf_event__process_mmap2; + script.tool.comm = perf_event__process_comm; + script.tool.namespaces = perf_event__process_namespaces; + script.tool.cgroup = perf_event__process_cgroup; + script.tool.exit = perf_event__process_exit; + script.tool.fork = perf_event__process_fork; + script.tool.attr = process_attr; + script.tool.event_update = perf_event__process_event_update; +#ifdef HAVE_LIBTRACEEVENT + script.tool.tracing_data = perf_event__process_tracing_data; +#endif + script.tool.feature = process_feature_event; + script.tool.build_id = perf_event__process_build_id; + script.tool.id_index = perf_event__process_id_index; + script.tool.auxtrace_info = perf_script__process_auxtrace_info; + script.tool.auxtrace = perf_event__process_auxtrace; + script.tool.auxtrace_error = perf_event__process_auxtrace_error; + script.tool.stat = perf_event__process_stat_event; + script.tool.stat_round = process_stat_round_event; + script.tool.stat_config = process_stat_config_event; + script.tool.thread_map = process_thread_map_event; + script.tool.cpu_map = process_cpu_map_event; + script.tool.throttle = process_throttle_event; + script.tool.unthrottle = process_throttle_event; + script.tool.ordering_requires_timestamps = true; session = perf_session__new(&data, &script.tool); if (IS_ERR(session)) return PTR_ERR(session); From patchwork Thu Jul 18 01:00:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A411C3DA5D for ; Thu, 18 Jul 2024 01:05:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=J3n+jIbMDyTv9OsUu+Yn1PYjr67tOBgDw7h0k4Rcb5A=; b=3OW6otss8SsdPC/kBFG+hsAdOx SjSz0psWBfkPPoVq/1NQTRgrwn9TKZcFTpUnIAFiIO/rqA7yWLB5fNNesuTrbV6+XNcgtZzbr3CSO Z4irrsGIBlXKclHkbBlX4eUYwdIEoVVHowRE71Np5ySF5g8mGInSpIPEs+w5E8844dsQjUlwzowNS +McRUQPMvYkAr9rKGkaS3hS4JZXAtXoVSsQz+gNO29+7HGrlHkIRtIQjgJ1Jnd+jRy/K+y51FC9P5 tToFpNYLWV46wJY/gqIynsBQ9cx+AUI3jI/uni6evcSZ+6L3oNYPIES1JSxydGOuNxeHdOwX6DP5U /MLET55A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFaD-0000000FLNN-1BZN; Thu, 18 Jul 2024 01:05:21 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWB-0000000FJfE-0dJW for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:13 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-65f94703b89so6286877b3.2 for ; Wed, 17 Jul 2024 18:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264469; x=1721869269; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=J3n+jIbMDyTv9OsUu+Yn1PYjr67tOBgDw7h0k4Rcb5A=; b=E4wR2jQRVlduE1+0ofWAO5DDt9p0SadRL7nIqWYxfcXTata9UXFNMIT5bJHLOORkMy deAxW5S8h+bd0dqWbcwvXe4bvLU1IsTkkqFNitnd9CTyEpNrCCe1sBgArZeUFT0CKWuQ Fh+qYCoETuVspTQtJUYbJHggf90Nai0HcF3c5PSUO2TtBrwJtvOF4sLayA8EgovNQLea PkyOyw9cNFvdCLEGKTnjU0Whl32yymWTy0IwOG83244uY/1E4DD6zEXnUhDJdGtsIJsh q4oO+w6aYo+2yJddtV2MRJj27vxdKRiaR8EA84i7MR4bSZSRnvjHka1o6c53pwX8FaZ3 e5sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264469; x=1721869269; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=J3n+jIbMDyTv9OsUu+Yn1PYjr67tOBgDw7h0k4Rcb5A=; b=qqk1qv2xFp3xNDK1iXkoM4/rt1Ej4vAAvuOrUJ9S8QAqHzeXOUPnHmh48lc4bPMbxF 5dSHpjsR5woSGmjnmf2bGxUhyRIDLdHtTQl+Bd/o2TLleFRTZxhjwyLWZs3fWDDaVyU+ RtMtl4GcAo6oWg2kJs0BiM1umZ274hRRCl/hpgnaISaKx2TZet2losMoF5UdJiMnPZBr l9T1ajTPgNcrq7cBvGktHBvibp5EOxHuqAzWnzKLD0KeDSILojNrFEETLC7dBbmfENWg W7UGfLojl7O6bDtyfQJDy+FM37YyWYEF3xumVyLsB8ByTss6hLnA03n1MkEqZHHTj794 PJzg== X-Forwarded-Encrypted: i=1; AJvYcCVUoPl5eRu/nRNnVCCKPtRIURseHQOLpoLCf3h96dyi6/XHN+S3CmFWmtwpMU8NPpYKgsskQdkBUfnYrabDZnTdKomlxQy/Y/18wf0/pca2ovzF6m4= X-Gm-Message-State: AOJu0YzUy8PF9+OOZeCLWYHcFXCDv+++NfgfFsQRjk09SbKpaxcgKr0r mWXTWHEjJj9iL3RfQunwjFwH6MCTzFmK34OFaovM4DadDW0A5oUUhLAWGePPyb98du7/6fmmkLr 9c5ID9A== X-Google-Smtp-Source: AGHT+IFlQGqFOHeHMR/DGL+G6fjGn0fdEKvd5NgFiT0bl+zqTRXmSKSTl9yhxhzwBha6DARQbLlP2reD5spx X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:1244:b0:e05:f6ba:1982 with SMTP id 3f1490d57ef6-e05fe83bfd0mr6992276.0.1721264469346; Wed, 17 Jul 2024 18:01:09 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:10 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-15-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 14/27] perf inject: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180111_228596_CF15F7B4 X-CRM114-Status: GOOD ( 14.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-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 = { - .tool = { - .sample = perf_event__repipe_sample, - .read = perf_event__repipe_sample, - .mmap = perf_event__repipe, - .mmap2 = perf_event__repipe, - .comm = perf_event__repipe, - .namespaces = perf_event__repipe, - .cgroup = perf_event__repipe, - .fork = perf_event__repipe, - .exit = perf_event__repipe, - .lost = perf_event__repipe, - .lost_samples = perf_event__repipe, - .aux = perf_event__repipe, - .itrace_start = perf_event__repipe, - .aux_output_hw_id = perf_event__repipe, - .context_switch = perf_event__repipe, - .throttle = perf_event__repipe, - .unthrottle = perf_event__repipe, - .ksymbol = perf_event__repipe, - .bpf = perf_event__repipe, - .text_poke = perf_event__repipe, - .attr = perf_event__repipe_attr, - .event_update = perf_event__repipe_event_update, - .tracing_data = perf_event__repipe_op2_synth, - .finished_round = perf_event__repipe_oe_synth, - .build_id = perf_event__repipe_op2_synth, - .id_index = perf_event__repipe_op2_synth, - .auxtrace_info = perf_event__repipe_op2_synth, - .auxtrace_error = perf_event__repipe_op2_synth, - .time_conv = perf_event__repipe_op2_synth, - .thread_map = perf_event__repipe_op2_synth, - .cpu_map = perf_event__repipe_op2_synth, - .stat_config = perf_event__repipe_op2_synth, - .stat = perf_event__repipe_op2_synth, - .stat_round = perf_event__repipe_op2_synth, - .feature = perf_event__repipe_op2_synth, - .finished_init = perf_event__repipe_op2_synth, - .compressed = perf_event__repipe_op4_synth, - .auxtrace = perf_event__repipe_auxtrace, - }, .input_name = "-", .samples = LIST_HEAD_INIT(inject.samples), .output = { @@ -2269,6 +2229,7 @@ int cmd_inject(int argc, const char **argv) "perf inject []", NULL }; + bool ordered_events; if (!inject.itrace_synth_opts.set) { /* Disable eager loading of kernel symbols that adds overhead to perf inject. */ @@ -2333,7 +2294,47 @@ int cmd_inject(int argc, const char **argv) if (strcmp(inject.input_name, "-")) repipe = false; } - + ordered_events = inject.jit_mode || inject.sched_stat || + (inject.build_ids && !inject.build_id_all); + perf_tool__init(&inject.tool, ordered_events); + inject.tool.sample = perf_event__repipe_sample; + inject.tool.read = perf_event__repipe_sample; + inject.tool.mmap = perf_event__repipe; + inject.tool.mmap2 = perf_event__repipe; + inject.tool.comm = perf_event__repipe; + inject.tool.namespaces = perf_event__repipe; + inject.tool.cgroup = perf_event__repipe; + inject.tool.fork = perf_event__repipe; + inject.tool.exit = perf_event__repipe; + inject.tool.lost = perf_event__repipe; + inject.tool.lost_samples = perf_event__repipe; + inject.tool.aux = perf_event__repipe; + inject.tool.itrace_start = perf_event__repipe; + inject.tool.aux_output_hw_id = perf_event__repipe; + inject.tool.context_switch = perf_event__repipe; + inject.tool.throttle = perf_event__repipe; + inject.tool.unthrottle = perf_event__repipe; + inject.tool.ksymbol = perf_event__repipe; + inject.tool.bpf = perf_event__repipe; + inject.tool.text_poke = perf_event__repipe; + inject.tool.attr = perf_event__repipe_attr; + inject.tool.event_update = perf_event__repipe_event_update; + inject.tool.tracing_data = perf_event__repipe_op2_synth; + inject.tool.finished_round = perf_event__repipe_oe_synth; + inject.tool.build_id = perf_event__repipe_op2_synth; + inject.tool.id_index = perf_event__repipe_op2_synth; + inject.tool.auxtrace_info = perf_event__repipe_op2_synth; + inject.tool.auxtrace_error = perf_event__repipe_op2_synth; + inject.tool.time_conv = perf_event__repipe_op2_synth; + inject.tool.thread_map = perf_event__repipe_op2_synth; + inject.tool.cpu_map = perf_event__repipe_op2_synth; + inject.tool.stat_config = perf_event__repipe_op2_synth; + inject.tool.stat = perf_event__repipe_op2_synth; + inject.tool.stat_round = perf_event__repipe_op2_synth; + inject.tool.feature = perf_event__repipe_op2_synth; + inject.tool.finished_init = perf_event__repipe_op2_synth; + inject.tool.compressed = perf_event__repipe_op4_synth; + inject.tool.auxtrace = perf_event__repipe_auxtrace; inject.session = __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 = true; inject.tool.ordering_requires_timestamps = true; if (known_build_ids != NULL) { inject.known_build_ids = @@ -2385,15 +2385,10 @@ int cmd_inject(int argc, const char **argv) } } - if (inject.sched_stat) { - inject.tool.ordered_events = true; - } - #ifdef HAVE_JITDUMP if (inject.jit_mode) { inject.tool.mmap2 = perf_event__jit_repipe_mmap2; inject.tool.mmap = perf_event__jit_repipe_mmap; - inject.tool.ordered_events = true; inject.tool.ordering_requires_timestamps = true; /* * JIT MMAP injection injects all MMAP events in one go, so it From patchwork Thu Jul 18 01:00:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735906 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E357EC3DA5D for ; Thu, 18 Jul 2024 01:05:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ydpPh1ZiMiP0pvro6tyDS2/nf8jKqmo5vUIGWKndW+c=; b=dDYnPBcO5HDXH1LNCb3IMGyeOn FVQjHZLzOYLbdRJi9di/QAhvoOFRi3vzAHwOWBfdxKhZ2bUVeGviU0HzIedcf8Pi6c+08WrjD2gI+ cHl5WMGfTuK9lxcqJaVMrlS9BIGiCyBBDGH4zZQz5QjZMaSUz/0WkWbiRm3y28l1XWiBHlFg5fTED wW7LLYSI62aqzLRdK5IhlMx1OKTKbuzxvPoHprbW4NvPg7cXnEN3umYwh/L573uEKyy+oXRhbUfmy TVaINROYaDNiNryoyGKQeDETzAsXCzK/YQerq5hz0g21eC7AvZBi9aH2GFzllGyBNR1iMw2lDar96 8hXWVuCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFaV-0000000FLVw-3DOm; Thu, 18 Jul 2024 01:05:39 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWD-0000000FJgz-29sr for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:15 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-65f94703b89so6288717b3.2 for ; Wed, 17 Jul 2024 18:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264472; x=1721869272; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=ydpPh1ZiMiP0pvro6tyDS2/nf8jKqmo5vUIGWKndW+c=; b=RxtwGHcsgTYkmL1WmtxK3aerPuRAXuyU7aLQSre41shb7AMiwMltuc0lROJ0PKsp9u CZKTOWKgVasN+r8q6RYy0/Ya45cfvyueR2lb7d53a1itzDsQnWruzr35L7WefODW2cz6 2Okhvxp5qGlDSk0lUCXoVsLf17eyOpl/knscDfsKGr1sEOKPlTRvXIU0ArpvuOSaNU0b iFUUEdU30xhcVlr0bMWD4jIs5MjaUTuyHJRz0DiyOwtNMDa1Ysue8tukPRqq/B5I6B6N JF7CTLVfJV/Lin9iTr/lKOhJJwQtjCh1xtM2ABytlCJoz4W8Wz+xFzXH/J1xhStUktoA 6tNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264472; x=1721869272; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ydpPh1ZiMiP0pvro6tyDS2/nf8jKqmo5vUIGWKndW+c=; b=Eg7OZlF+Zc4HI/ZsQQluJur2JPZopdcW2fd7xbWGrY+FugboqMfYxjhXTEpcfAE6uz mR4qizoqC0p4R9ZsidsXDs4McDQV68Ktc5Zy9ZB6qnnMkbGDFoSzDNtZgXurFHXs1TbG ECuivwAyHy7LsOEYmp43lIriGYGy8ndM2myOjcvTJ6anc/GoGz8For3ocCypDSc/IX63 8aF/n9DxH2Bi64HhX6V8Hln6ccsyMP5XuA9ZLqkAAjNwZ3MltawYx4cCO/JRx1ZE6Dy0 68QVA7F8WNV/C+AZ4BeCg9PUBAK1DUFrFyQs4s3RtTDSTivKwzg+fDmySCdvraCYd6PP s53w== X-Forwarded-Encrypted: i=1; AJvYcCVc0qSyTFV9VIYJY+1zSDw0mphfbmD6zoVxx8HAEugjhQPJQgE2cW9n00kwpYADOt8AyarPJUHUfbO7N0G/Z7Bw/2XVwl4mNbQD7bGJWdEuEux75cw= X-Gm-Message-State: AOJu0Ywfalp7hmJiJVpydAGzswAWZUyaQJMIL9pgeN6DgLbsAk3p6HAB S/RlMQSq5ApxGo63FciOPySmBQfbmMgCD9iFyZVmY5lm1LJzGkZS0G0DpGA/NGzayyqN5y+HM14 xNHdnUA== X-Google-Smtp-Source: AGHT+IEC7jMCN1PYvXYSFjQ+yMmz4uzntJ34atRdjn0CJuW8F47EslAtvO50ljkTVZhuGVg3mcO9QZPODSju X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:1504:b0:e03:510d:3b6e with SMTP id 3f1490d57ef6-e05feb30c26mr8201276.3.1721264471615; Wed, 17 Jul 2024 18:01:11 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:11 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-16-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 15/27] perf report: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180113_694473_67CF8C25 X-CRM114-Status: GOOD ( 13.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-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, static void stats_setup(struct report *rep) { - memset(&rep->tool, 0, sizeof(rep->tool)); + perf_tool__init(&rep->tool, /*ordered_events=*/false); rep->tool.attr = process_attr; rep->tool.sample = count_sample_event; rep->tool.lost_samples = count_lost_samples_event; @@ -817,8 +817,7 @@ static int stats_print(struct report *rep) static void tasks_setup(struct report *rep) { - memset(&rep->tool, 0, sizeof(rep->tool)); - rep->tool.ordered_events = true; + perf_tool__init(&rep->tool, /*ordered_events=*/true); if (rep->mmaps_mode) { rep->tool.mmap = perf_event__process_mmap; rep->tool.mmap2 = perf_event__process_mmap2; @@ -1272,30 +1271,6 @@ int cmd_report(int argc, const char **argv) NULL }; struct report report = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .cgroup = perf_event__process_cgroup, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, - .read = process_read_event, - .attr = process_attr, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .build_id = perf_event__process_build_id, - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .event_update = perf_event__process_event_update, - .feature = process_feature_event, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, .max_stack = PERF_MAX_STACK_DEPTH, .pretty_printing_style = "normal", .socket_filter = -1, @@ -1477,6 +1452,7 @@ int cmd_report(int argc, const char **argv) }; int ret = hists__init(); char sort_tmp[128]; + bool ordered_events = true; if (ret < 0) goto exit; @@ -1531,7 +1507,7 @@ int cmd_report(int argc, const char **argv) report.tasks_mode = true; if (dump_trace && report.disable_order) - report.tool.ordered_events = false; + ordered_events = false; if (quiet) perf_quiet_option(); @@ -1562,6 +1538,29 @@ int cmd_report(int argc, const char **argv) symbol_conf.skip_empty = report.skip_empty; repeat: + perf_tool__init(&report.tool, ordered_events); + report.tool.sample = process_sample_event; + report.tool.mmap = perf_event__process_mmap; + report.tool.mmap2 = perf_event__process_mmap2; + report.tool.comm = perf_event__process_comm; + report.tool.namespaces = perf_event__process_namespaces; + report.tool.cgroup = perf_event__process_cgroup; + report.tool.exit = perf_event__process_exit; + report.tool.fork = perf_event__process_fork; + report.tool.lost = perf_event__process_lost; + report.tool.read = process_read_event; + report.tool.attr = process_attr; +#ifdef HAVE_LIBTRACEEVENT + report.tool.tracing_data = perf_event__process_tracing_data; +#endif + report.tool.build_id = perf_event__process_build_id; + report.tool.id_index = perf_event__process_id_index; + report.tool.auxtrace_info = perf_event__process_auxtrace_info; + report.tool.auxtrace = perf_event__process_auxtrace; + report.tool.event_update = perf_event__process_event_update; + report.tool.feature = process_feature_event; + report.tool.ordering_requires_timestamps = true; + session = perf_session__new(&data, &report.tool); if (IS_ERR(session)) { ret = PTR_ERR(session); From patchwork Thu Jul 18 01:00:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735907 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 90487C3DA5D for ; Thu, 18 Jul 2024 01:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AE1o9GzylDTNU/tj+neWnduRfzORtFIhqRzpNenF16s=; b=KQQwjHXjhIjWi0n/DRsUXXaUSZ lz/F9cKMvXdFRyDwpoT/3UzQqYkPnss2C6+l+AgKxqgS34vRpJIBpRX5oaA3MK/75bp/gZ1pvZnbg YJ0dXT1cJlgY13KrD1xnmtTp4pzA9o3Y+sf7/r/gInl1yvTmgOK+s/4j/8vYwBCfSgUH3bzY9/AUS UNlgajdNuf+Hc9v3YSeKp8NNWuKAH4DAyicqMiDRxi/wB37hB7rBKZI69R754L6LPDy/WA9MRV6sr /f13ANSyWZvSUG8dhhB0wqy/1YKjKLcwJrt4+QYwqpECyVXrzyk3PNSeKn3BaiITcMMqm8ZrnCgpX acSYuEgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFao-0000000FLcA-1CO0; Thu, 18 Jul 2024 01:05:58 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWF-0000000FJiU-2uXi for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:17 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-650ab31aabdso6016607b3.3 for ; Wed, 17 Jul 2024 18:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264474; x=1721869274; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=AE1o9GzylDTNU/tj+neWnduRfzORtFIhqRzpNenF16s=; b=Yt3Zl+2J6U9ggu898PN4xg518AUMMQnA7B3Z1GaELDF706GU5eusde9d29ViJArdpi xbMuLZEXFVjnIBn8VOO1gaEWt8KSMeRF1HryVOiNql3acXHeQ0FWg0HfHah6iDfM2Ifn ffYm1sjbVjYrQNTQSE/Ctmri4FgUXJiGxdn7PMvrgw+v6cwJaNLGrDIQvED88GF24DJv wZsxSLJGvzbkBcskcHeOuTZ1IgXdoeODllUp+IaM3n9vxN/K6U9sDrQWPLy13dt5ieqZ A2OgJxH/WhdCg6KXS6RwOTGsxKlKDMoiDV9WA7yHJtAwfOL4DxX8wdyfFBc+V7kKwvDA FMew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264474; x=1721869274; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AE1o9GzylDTNU/tj+neWnduRfzORtFIhqRzpNenF16s=; b=QtEeePm3wccyb5LJZAVte5a5uUx4Eu+ojeWy3G0ddzmDQqFivulm5yF75U/JLxXK9n xG9QA3jOF+Kf1Vl9tOKWKdL7+RI3wAgeWuyh//2fvCL56opqtrmv2Jaf8XBUVXOQ6JwY GP4qDtjX2XY/LUpLqCRcMGEP9M3BaDvD2BRi2snFhlXPIU1HLH2OqgVTZ5yPwWrEUbZ+ qRb2+KF5IPy9yakCa5H3XrYwglpi6cpzSsiOzH+SSh9+dcQdaCTPT9zxpvyMpC6reFVC j1xOe5WCTDGyOnvrdw7hZ5BVFXjPgfUr8MsYZjsJuFh+X7WUAz568dfA/8kbpItU41eO a5qQ== X-Forwarded-Encrypted: i=1; AJvYcCXlzcLzX84yYhZIsjm8FOzIo+MEGeZnEF9OQwYjE6T4IcvxUzoWgf6CNRLZ4d7t3knIjjvEB11DoSAFEh4S3gzbnaamm3F//TJ3OZDJ0ksQPCaTR7E= X-Gm-Message-State: AOJu0YwjNYpHJz9XRBaT/fs+pGkn2DfflI+JZbisNkTCDKNFL5NcT324 aQbW2FkvEQDIsdzDwPlsMzr4/sZHu4pyv6HKyY3RwecyO3SlRtTNZkndRphpsXH/2jQ5s07YSFE tv1e6QQ== X-Google-Smtp-Source: AGHT+IGgBhJ/vZuBVSyFSptR6UrX0xinXo4sb/hBXkBYSLP3hMqMO6tKzBxK9aNEcm7jyYNyXiyoQrcO72E7 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:1245:b0:e03:a0dd:43c1 with SMTP id 3f1490d57ef6-e05fe74c656mr10367276.0.1721264473975; Wed, 17 Jul 2024 18:01:13 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:12 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-17-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 16/27] perf stat: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180115_798415_5F2511C8 X-CRM114-Status: GOOD ( 12.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-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[] = { }; static struct perf_stat perf_stat = { - .tool = { - .attr = perf_event__process_attr, - .event_update = perf_event__process_event_update, - .thread_map = process_thread_map_event, - .cpu_map = process_cpu_map_event, - .stat_config = process_stat_config_event, - .stat = perf_event__process_stat_event, - .stat_round = process_stat_round_event, - }, .aggr_mode = AGGR_UNSET, .aggr_level = 0, }; @@ -2322,6 +2313,15 @@ static int __cmd_report(int argc, const char **argv) perf_stat.data.path = input_name; perf_stat.data.mode = PERF_DATA_MODE_READ; + perf_tool__init(&perf_stat.tool, /*ordered_events=*/false); + perf_stat.tool.attr = perf_event__process_attr; + perf_stat.tool.event_update = perf_event__process_event_update; + perf_stat.tool.thread_map = process_thread_map_event; + perf_stat.tool.cpu_map = process_cpu_map_event; + perf_stat.tool.stat_config = process_stat_config_event; + perf_stat.tool.stat = perf_event__process_stat_event; + perf_stat.tool.stat_round = process_stat_round_event; + session = perf_session__new(&perf_stat.data, &perf_stat.tool); if (IS_ERR(session)) return PTR_ERR(session); From patchwork Thu Jul 18 01:00:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735908 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1C37BC3DA60 for ; Thu, 18 Jul 2024 01:06:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=D4D79+IUkfPytCkqQCFYniN8I4X54SHHR0HOTbDEr6c=; b=iw/t2ooMct8W6ppwBJdLSBQ47T tYWzSmGfpBDG8TMgDaojw46lmbXWnXIpbJZt7EYNLAUEoCEB50Go2F7uNI9NdfhDjjuvwbQlqf6mY IwlL8R9hkbJnyJz2TzVGuuPE3f0VPMMD9KL3CZW7dekRklQCU3ipQIKz6BTOtKb06Umbu/IVvwok9 bR8Vgk5dEr1IMV6B/ccL3OLojj+YDYVQQvJBHNI1ys/8lAvmTUhSpcxd22hIQ9HrHaL9IcfPFI3d7 d+rNWZgOmOOfL3t5bYzuCJjCdD5NYxTBwtgLaMgGYBJF1iejqzNpPPs1oSfXfws8X9Ykf3xIlzy27 VVx/lYxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFb8-0000000FLjf-0P5J; Thu, 18 Jul 2024 01:06:18 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWH-0000000FJk4-28lA for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:18 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e036150efc6so659954276.2 for ; Wed, 17 Jul 2024 18:01:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264476; x=1721869276; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=D4D79+IUkfPytCkqQCFYniN8I4X54SHHR0HOTbDEr6c=; b=kY8JTfsHedRHCzvRNRaMt+DI99Jpmk6Je17gw9G2vuUvEoWaPUmvTb8A4b7A4JPthE jGIXdtT3VvLX8Dtb3xkUBeloBA6XwFVZL6tNuxcHLfqc1bp2Sz3cd4VeXH7sT9ZwL7zl BxiTAf3xbb0ovqyPAYZJxpzwPWaFT8L2KUXAv16VK8pwoH/RqUUFKZTHGMwopOf9j7ca xERkOh9y44Tfp/iS6L6l4EWdpMVOSO08af7WGPeHogYjmlKAIi+wrog7IyyqAWa7MMVQ zjsO+9oElmiwmPp6+GpIKzyN5fygnpCWNHO2EGIKIIrj1exZ8Oas6bmwrAIMhszStWmA RbTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264476; x=1721869276; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=D4D79+IUkfPytCkqQCFYniN8I4X54SHHR0HOTbDEr6c=; b=Hea8+lsqyP1eLUogUIxJ8j8QWeiv0yW1jIE5lb0Uw5Wfzk5K4bYA97pZWak5yiVLI/ KKHh8YnSsCAOaZYE0PSwnTjZUgZQzxQRkOOvrJTy0vo0H4brVdAGw1HCermgXadPc0TZ zFV19BjlFizYL2OTucxx56wqdIJ7cDEbAEJyuwIM/mgzS3T6icpBMhd/Ezb4/RTvz+47 xIuTISEMAbnYIzyGCEZ7RlWLya5A72ZpNTZDSRLZzLdDZBXpScApcaxWfmCXvVixfcwL PAXmGEVN6jIADTUPzPIIqCS3LjYEnReJUfv6wap0u8MaAjWVN1YFZdTkfOlM1aHgnMY8 PWkA== X-Forwarded-Encrypted: i=1; AJvYcCVFeCCTyB5JqNZz9TmbHSGIrT5COaISe3GpN2+tMtcX4iejA06E7zLDC3MtOSHHaC8DKtMg+flMQLHUlvdw9McAbkl5nB405n/RRgTA7aTMCTQ9pHM= X-Gm-Message-State: AOJu0Yz6H3Do+SDLylUbLwkw6/AsIz9ymPBeCeUwshwMScvztp1Ezlzu 9E4fgi9iTH3eoSEW5RdK9aL13VoFktB6E0oIHcgFx3m75mM6ajnGxuasphvp7kO4ioL40y8FhBl auAEAdQ== X-Google-Smtp-Source: AGHT+IFdcXueyp+PMAvktitAsznwCgBObp3v+ssLmbsVDVTn4IUrAVOTsIsjGyiwtSBsWfywOqLvQluTAWWt X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:2b8e:b0:e03:62f0:a297 with SMTP id 3f1490d57ef6-e05fea28f01mr2107276.2.1721264476138; Wed, 17 Jul 2024 18:01:16 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:13 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-18-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 17/27] perf annotate: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180117_574527_FFA8DF0F X-CRM114-Status: GOOD ( 12.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-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[] = { int cmd_annotate(int argc, const char **argv) { - struct perf_annotate annotate = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .namespaces = perf_event__process_namespaces, - .attr = perf_event__process_attr, - .build_id = perf_event__process_build_id, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .feature = process_feature_event, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, - }; + struct perf_annotate annotate = {}; struct perf_data data = { .mode = PERF_DATA_MODE_READ, }; @@ -864,6 +843,25 @@ int cmd_annotate(int argc, const char **argv) data.path = input_name; + perf_tool__init(&annotate.tool, /*ordered_events=*/true); + annotate.tool.sample = process_sample_event; + annotate.tool.mmap = perf_event__process_mmap; + annotate.tool.mmap2 = perf_event__process_mmap2; + annotate.tool.comm = perf_event__process_comm; + annotate.tool.exit = perf_event__process_exit; + annotate.tool.fork = perf_event__process_fork; + annotate.tool.namespaces = perf_event__process_namespaces; + annotate.tool.attr = perf_event__process_attr; + annotate.tool.build_id = perf_event__process_build_id; +#ifdef HAVE_LIBTRACEEVENT + annotate.tool.tracing_data = perf_event__process_tracing_data; +#endif + annotate.tool.id_index = perf_event__process_id_index; + annotate.tool.auxtrace_info = perf_event__process_auxtrace_info; + annotate.tool.auxtrace = perf_event__process_auxtrace; + annotate.tool.feature = process_feature_event; + annotate.tool.ordering_requires_timestamps = true; + annotate.session = perf_session__new(&data, &annotate.tool); if (IS_ERR(annotate.session)) return PTR_ERR(annotate.session); From patchwork Thu Jul 18 01:00:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735909 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ACA03C3DA60 for ; Thu, 18 Jul 2024 01:06:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sIDIj8ohh0nflT4KD3kHem3lEjHwYWuoIZyNVV8EfDA=; b=i5K6zdgsm3y8/dUVL/7DYL3X96 SNu/tlrQqwRygeg9eWbmrOYT68T7Mut6TyaIfAcWKytpM3Dx5a6eCzT6G3Q2QFBc5CVGvID5eGYi7 8SPVtPSbfyodQe+b9+b4MT7JJe80hKswi6CCDr8jCy2ysTIUs76miHKx0/R2FAh/qcHJJhNVMRuwK CQdjFzCyc526Uhd88qFWEe74a/7bPIxweyhZ4ekkcAyYs2/Qo/95q+O0vgJw1h5iLtcwqIQ74OM1e KAuWHLP2FWmfMs8i8FMjJYI+/dKjoMiO5cG8bUwkKOvcJmWuG5Z9/yrSlqFCgPZSqMBU5d0escmaS BXDeFwAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFbQ-0000000FLqj-0hDz; Thu, 18 Jul 2024 01:06:36 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWK-0000000FJl7-0Os1 for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:21 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-65b985bb059so6581237b3.2 for ; Wed, 17 Jul 2024 18:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264479; x=1721869279; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=sIDIj8ohh0nflT4KD3kHem3lEjHwYWuoIZyNVV8EfDA=; b=GM94SiQVrFBgL5smHRQHa1o9hAd3cGtSmiCX1tjO0nKN20BtWIPxqDuJzCtnQrFAhP J7Xjek/aV6U2X0wmUsV36y1k2wdouS4RVP14kx6/GUbl9M6JyvEWWsgB99jHFCG37/zA 47oIfBCpQnYBATYdblLj3rTsbPwUPKOFeyKcWmaqcbSJuESpfqlKgvldti0402Aq4Exm 8EAGkQwl8dTY0pfTB8xdf61nYtRfBuNinIFyfcssxYEJOkaYe2wdpb4MelnWgso2Lvw6 auiC1YF2X+7vTnMz0UDbIzeebD4f+80zHG2qbGCqLyIzsqVvkFvvyDqErHAsDafjQ04X MjSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264479; x=1721869279; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sIDIj8ohh0nflT4KD3kHem3lEjHwYWuoIZyNVV8EfDA=; b=UTO9yIVUOqmE4dxxCEP6+4T3pBgoGxhBar6vmqa2928vn15a9MzUJIN/MiNZu2Fri5 UY3WhRGATdiOmr8PodZC+6a3l8is/UR7mOnJjhr0kWpXNG3CqGpjrVvvz8jRllPkqNqX DYQs0NTiExq7C4BochSV81wGUQOjCWDYC+U22aVOZ8J1XEtqRtW8DW0tufmtawZAXnqy zAKx72/rdgmmgB7+ahqUbYsxb8CoiErfceD4yjFypl9iDNpjCFa2ih+75r2PGM8z2/zH 9MVwuAZTNaAbGaPjf8wVVEzskuLNe9ddNx1MeiDhTQodNZHFJPXHBLzb2WkPuAIzFo7h E9Vg== X-Forwarded-Encrypted: i=1; AJvYcCUaGg1AD/GBT3c/nw64ZZ9gy+mbLMwzb0y6H2JJ9irnIMW/P10g9rOzfjMpM9Yj4n1egAL+dtGe6yxtTXnfiC1m9unZY6sTzIbkHrX9CeGbM0FH4Dc= X-Gm-Message-State: AOJu0YziGS251ldecHkMHyuyHCy7sN7jBGE1TEuIi46DIB1sFICGKA9c knPrjdCDGJeji9EC/INxXoEHu/dtI3wyafYQNnMr7iCCYQKPEBJqocmi2Zw3fhgaEbrj14wLFMA dDMpsiA== X-Google-Smtp-Source: AGHT+IE7eyYkV30IAuJJyVKolxf68gGRG23Ds+4kcgr2lLuAa9Klg1hxPx68W8tgqNMyLyGzarxdoaI7qyDF X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:18c6:b0:e05:a890:5abb with SMTP id 3f1490d57ef6-e05fea8885bmr27243276.1.1721264478691; Wed, 17 Jul 2024 18:01:18 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:14 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-19-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 18/27] perf sched: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180120_168906_A754FA12 X-CRM114-Status: GOOD ( 11.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-sched.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 2c60bd3a8149..34fe8e540c43 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -3100,7 +3100,6 @@ static int perf_sched__timehist(struct perf_sched *sched) sched->tool.tracing_data = perf_event__process_tracing_data; sched->tool.build_id = perf_event__process_build_id; - sched->tool.ordered_events = true; sched->tool.ordering_requires_timestamps = true; symbol_conf.use_callchain = sched->show_callchain; @@ -3605,14 +3604,6 @@ int cmd_sched(int argc, const char **argv) { static const char default_sort_order[] = "avg, max, switch, runtime"; struct perf_sched sched = { - .tool = { - .sample = perf_sched__process_tracepoint_sample, - .comm = perf_sched__process_comm, - .namespaces = perf_event__process_namespaces, - .lost = perf_event__process_lost, - .fork = perf_sched__process_fork_event, - .ordered_events = true, - }, .cmp_pid = LIST_HEAD_INIT(sched.cmp_pid), .sort_list = LIST_HEAD_INIT(sched.sort_list), .sort_order = default_sort_order, @@ -3733,6 +3724,13 @@ int cmd_sched(int argc, const char **argv) }; int ret; + perf_tool__init(&sched.tool, /*ordered_events=*/true); + sched.tool.sample = perf_sched__process_tracepoint_sample; + sched.tool.comm = perf_sched__process_comm; + sched.tool.namespaces = perf_event__process_namespaces; + sched.tool.lost = perf_event__process_lost; + sched.tool.fork = perf_sched__process_fork_event; + argc = parse_options_subcommand(argc, argv, sched_options, sched_subcommands, sched_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (!argc) From patchwork Thu Jul 18 01:00:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735910 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8DAA4C3DA60 for ; Thu, 18 Jul 2024 01:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=m98Flvn2VBr3LNYvnCJEqVyEBIqxTtcaN90lyN420CY=; b=KZFlETrY69RvoCZDyI7fTL0KJw mzFN7DrzOIUpPY84Fk62Budeq3NwDep6Sf/g1rAUn2ZAr7YnE1v4KwNG1Keha0DEYrVctbgER0U7z YFc3xEeueJcScRKYC2iPyh8agsz+W+jr3VrWUKxdnzRnCUWIlsin8zZgC/holgre+hnA6CiR63qTc QZCidQeJXyRFN1OJWsFupVYexnq6muGYnUdSF8wSNcIGWpumhv4Njo5T8STpJXcog4O04UCQHi/M9 M+Drw68g80ZOtWo6iYntY50MWETNlDCNQiLZGiexhDCl6pAfaGB5RRYx09BhUCQCHlAy6YY4wsgjZ ijgl42pA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFbj-0000000FLyH-2NxA; Thu, 18 Jul 2024 01:06:55 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWM-0000000FJm3-36zt for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:24 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-664fc7c4e51so5221817b3.3 for ; Wed, 17 Jul 2024 18:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264481; x=1721869281; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=m98Flvn2VBr3LNYvnCJEqVyEBIqxTtcaN90lyN420CY=; b=a//8xifOhNwYz0/kQ8U12WndP7hZAr1k479zdRQubEvpNjPRbeMcBA81jjL69FMRGM 8IlcciJ2xoO6h+UuGEGjW70xKGnV3DWLf9huSVnYgAmyVNRT2XyNusNjL6BRyoqEFM5c p0axyiCAR1tQTztvXkpu8MLgygAhtBvMLW/vbdrjlY4X+pij5NKYQSG+uWeEUVL8GYgi 4vOydJ5Sc9OccioxoqL5Mfy/wrDj4TZbOAzIWhfhLP5g0YJp/nP//VOj1fyzHfWQGx6l H+spBUreoMfzraTugSqSuugwKMWnk2tB+IrY418CJBGgzO3W+8l5ibZsP5ytNC14LAmJ RCCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264481; x=1721869281; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=m98Flvn2VBr3LNYvnCJEqVyEBIqxTtcaN90lyN420CY=; b=uJTdeNNS3pen9GaFsNqSoa7epY+zClXXGwmgu+FM/8njEkBZTLbJFcPXrse+6oTYvl GztycWiItaU0xKsZaIMgTli3k1+/E1ozM/x2oiZTPqitrj0IOQo7ktUfLF5BHG4G9FPe H7saAVmrbcwwRXZLQS4uHPCFD0Ys+DMl466a1j80ltHXPg4fx74B3b05MbmMVDuFt+10 kcUbAVLfya38EHj+rEU0pF+DoAIx1RJCf5btm5xkyMPszUntDRtBIv+lYzp0JGIl1uLU 4qIVzcl8Wv9BqWpciW7yh6RxTsvSkE9vSVIluDD5KPnLLwHw+lk4g3Zy+zX4iwiIadCg 7c4Q== X-Forwarded-Encrypted: i=1; AJvYcCW3LnVJD43xcWWNYZfzxoUlKp8koJE6BvB7iKH2q8ilF3nKmpO7hSp9oXkQcKoRyNDJbta1piOrd+id21n/ExPY9NWpE1ofE/koTMh7htKg4keQNa0= X-Gm-Message-State: AOJu0Yzp32GKfjpDC2su3JMIRO7iH2VMuiGlUjVqal6kh5O8HwuO4KOr VDLQ/7yhz9c7RW+C4yKpHFNsQ3mfI+KdDeXQX56t0EDW/i3zsSwofzLYyRSRbA2sTSNSSKI4YID cJ4tC7g== X-Google-Smtp-Source: AGHT+IEWEjgKHZq/295YiLw+T2zNbbynCG/+Of132DZ6uzEmgnVr1Fi3xV7AcLhcv2Pa2K2jMXGhS06h3I/A X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:fce:b0:666:e184:4dfe with SMTP id 00721157ae682-666e1845003mr139337b3.6.1721264481114; Wed, 17 Jul 2024 18:01:21 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:15 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-20-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 19/27] perf mem: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180122_806872_F76D1B6E X-CRM114-Status: GOOD ( 12.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-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 = mem->force, }; int ret; - struct perf_session *session = perf_session__new(&data, &mem->tool); + struct perf_session *session; + + perf_tool__init(&mem->tool, /*ordered_events=*/true); + mem->tool.sample = process_sample_event; + mem->tool.mmap = perf_event__process_mmap; + mem->tool.mmap2 = perf_event__process_mmap2; + mem->tool.comm = perf_event__process_comm; + mem->tool.lost = perf_event__process_lost; + mem->tool.fork = perf_event__process_fork; + mem->tool.attr = perf_event__process_attr; + mem->tool.build_id = perf_event__process_build_id; + mem->tool.namespaces = perf_event__process_namespaces; + mem->tool.auxtrace_info = perf_event__process_auxtrace_info; + mem->tool.auxtrace = perf_event__process_auxtrace; + mem->tool.auxtrace_error = perf_event__process_auxtrace_error; + + session = perf_session__new(&data, &mem->tool); 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 = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .lost = perf_event__process_lost, - .fork = perf_event__process_fork, - .attr = perf_event__process_attr, - .build_id = perf_event__process_build_id, - .namespaces = perf_event__process_namespaces, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .auxtrace_error = perf_event__process_auxtrace_error, - .ordered_events = true, - }, .input_name = "perf.data", /* * default to both load an store sampling From patchwork Thu Jul 18 01:00:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4F6EC3DA60 for ; Thu, 18 Jul 2024 01:07:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fnEjjhiFWiWK1ZjHSoRI+4nKrjjHTPs3eA/kl5KV2XA=; b=rpODkve54p1kjufa2jzDS9ZfMS soXoDnp3+ZfqpW2/VQsA9LexEaLTVbZq1fAc2qjuhiZvHveEcpBxnU4XtY9gCEKA2JZ7+Ugx+rEpK qnELWpx8gDHlpJEgxsETt/RF84ha/qAy3S+AckxfwpQToSkJgwdk4Xz1+SVslvuaqgD50AXgKrwUo JDQi5K1JUT3RBIQAk5TR+wF38UgXhifOac/Ux3gYgy66BSBa7stTU8VvWchLMyGvWzbv0M8po5g73 jzYYFzvwnzLtCWoseVtKXlOnUzflGwNFURYKGZcIdW+ydBmMXltvt7LXETHqRGIMjcJR5Uuhq9+ld tgdv+r5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFc1-0000000FM5y-3SX9; Thu, 18 Jul 2024 01:07:13 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWO-0000000FJmj-3cKx for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:26 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e05f08adcacso782421276.0 for ; Wed, 17 Jul 2024 18:01:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264483; x=1721869283; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=fnEjjhiFWiWK1ZjHSoRI+4nKrjjHTPs3eA/kl5KV2XA=; b=xFlPipDG0WLJT1SEop5we2K2RA8OrNPWa1y1PFbbzL77srMra7J191kAP7vnA8paDb LF4+pKuCEAaTw7EwdKJfZoQEikxs0ILGZ9Sc+sXkIrPg8o0mM8+oSMG8540d2n0uFZ+j Og2KWrMRSD7mNyuVBJ939vcInR4+tLK2YLUDDyP+p3Y9RIXnCn/nE7ZEFIlx/kJRAJ6x Vzv1cmjcDsOAvgPoMSTSDn3Wj7NIWjseMslTmtjfILpDBynZbVXIQ3q8N5HSrKjuz4AE 3xUE0sk/+xM0yV4X2AWlSI5zLFj0+8hgRrw+GoViKI3uGJ7WcS3MsIb1tUyfwFo3scem R6zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264483; x=1721869283; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fnEjjhiFWiWK1ZjHSoRI+4nKrjjHTPs3eA/kl5KV2XA=; b=M+yM14zjgAX5neohIK4JH7KQXwRbSx6R2Mlz0SNiPZAPpbNr9bGOpKatdnMcuLPSIE w9wKmYuF9/rQTvNWrtghyprfPnpv8Iy0DlekR9NX4vro01k8THMrp/0Z3/byB5tBhle/ n6+Fb0pI6xYFRxCyYAnGf55D1nPZv9ZJ0aw8yGIloDXgGWQLrtbNACTisDJANnkQivmd pPf6cQGsmgtwm3etULopdTDHbJ5aGXnyv6CgVbb8q/PabO/hTEVYnzhZqecvBUlLNVYJ MHvIgRz/Jm4AhDI2l1kui62Xmq2C/xo2ahtXtWrKDesxv+U0zTz2fo2JCw9LrgM8epUP cDnw== X-Forwarded-Encrypted: i=1; AJvYcCVMT5FOpgWiv7cB2uYjdns/yZ6t/ga60/ldPuCo+GElOCEJL+CVF8JNzNiCjJC3Gl+QZy/Z7KWX7hB0MiZHqTZU0SCRcGkzs6knTD3253fZbt03eqY= X-Gm-Message-State: AOJu0YzWrAAlztuIGrrtEGQhfwQft1nfWEpp0bnNFmxIJ5DEbCSbXrjW LbdfddRY1KnMvav3x9MTWH6XbAe7nM/czfrmmlFTaLNYIVpxXAYp7TOrDivLl6oTmmxBFFZB6lD LalJn3Q== X-Google-Smtp-Source: AGHT+IGc02dcns067S/+Js+jqFzEtFv/PZyENgn6kRY6kp4H5xE8Md1QOSwjwqbLR9srevWvPq7mRSuwgOSG X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a5b:885:0:b0:e03:5a51:382f with SMTP id 3f1490d57ef6-e05fed80951mr2244276.8.1721264483228; Wed, 17 Jul 2024 18:01:23 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:16 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-21-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 20/27] perf timechart: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180124_960891_3CD312DD X-CRM114-Status: GOOD ( 12.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-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 = PERF_DATA_MODE_READ, .force = tchart->force, }; - - struct perf_session *session = perf_session__new(&data, &tchart->tool); + struct perf_session *session; int ret = -EINVAL; + perf_tool__init(&tchart->tool, /*ordered_events=*/true); + tchart->tool.comm = process_comm_event; + tchart->tool.fork = process_fork_event; + tchart->tool.exit = process_exit_event; + tchart->tool.sample = process_sample_event; + + session = perf_session__new(&data, &tchart->tool); if (IS_ERR(session)) return PTR_ERR(session); @@ -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 = { - .tool = { - .comm = process_comm_event, - .fork = process_fork_event, - .exit = process_exit_event, - .sample = process_sample_event, - .ordered_events = true, - }, .proc_num = 15, .min_time = NSEC_PER_MSEC, .merge_dist = 1000, From patchwork Thu Jul 18 01:00:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735912 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37D54C3DA5D for ; Thu, 18 Jul 2024 01:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=86P6lehyXq0UCz+szOa7LpHKfu0TP8+WJUv3yJsN71E=; b=actlRBv4rnCfJPyVivRHjEHxh2 ZvEfqF9xec+4gLNh3zUGYCCRWNk9D+Cfhc7APmS6Uqk4TT4dl87iJ02lfJhGo7KmANYUmMf6ceYDP 8oDrzLAhreHunslPuAkyaTtGXVe/2nLqKERbrRwyWHopFYQyekSK8l6L0jvXq77wHa4x68xqg+tTh OQT2JJt61YLL3YRHJ1JyJ+sboyRb4zYTo5rp/cedl/H9TWNePKCKIoA7jg54MfH9t+1bHPuinaxV2 bDrCi32/EDmWU6fUSQv2Y7xi9TqGD2NuxtIAJZYAUjcsCmfNm8Dj7IGkgeyZ9MNgbo7xG3iosgYM3 IuKjGB9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFcL-0000000FMDx-1LMB; Thu, 18 Jul 2024 01:07:33 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWQ-0000000FJo0-2v9k for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:27 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-65ef46e8451so7674387b3.0 for ; Wed, 17 Jul 2024 18:01:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264485; x=1721869285; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=86P6lehyXq0UCz+szOa7LpHKfu0TP8+WJUv3yJsN71E=; b=vNdRK9gA5Sq8caXjiNoZKDhHVPE+zeSd73zPslaClRnnoCzwAzJd45tWtJ8P3K/la7 LLGYJ0qCGrXPmaS50S/toiLjrTdQ+LCQ3bGSXKrAqeQoQwjyha33EQqVP1fi2bXKLzoQ MhDN4JBbJWm7jm0N8JR+rffQaSnNBYD7XvsAhbWPr7WqFAuV1FXbWP3MP2QXojppo0e4 5BddMk6Lk7X7NwIj/nyhO1/alk9BIxvzG5HOxx9RpO3Sr9/dh0Wlgk7kjFsQderUHqt1 SgHyiU10v1I56BGjP++imo+rXP/6VQ8J5v1hjhGIFJJ6obnaiJNyhM4mWTbWxXAhWLmI tAnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264485; x=1721869285; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=86P6lehyXq0UCz+szOa7LpHKfu0TP8+WJUv3yJsN71E=; b=o7BFoGM0Y12SIZ2JSFTWgzG0k7zj6hcm6GfKrgJh5RZb3tglx0D3xTZ3Gl61xcIz9F 5QgEwpit8FPVAT91igL/1PHQTMLiN8ZmX9D7bp9cbII+0RtjOTIihtOb+0cYCXVGtR5b LwmdNuxOhvzxBNvKLS7mw6fkNcW6f4+BTexju31E3Lidq7mz0mOZk1N2trCK91ZH6iCR pY6uB3VoYUuk+p4rVQxhfh7+orLpYlnuAp8w3dwdlPwT80tVpqRyHUUvgBt6LTdqUnwR qJn/mpUN37ZGl45THj+47hct1NCZCzMtMCXIx5unNOIBrEknoArBPG+2LcP+fVwBHMYJ emMw== X-Forwarded-Encrypted: i=1; AJvYcCXq/+Y92SAN9VvjplAN2FiU8mO1Pl8Kb+yQdYOw8RtoiAeeWNWUlPATgQ/rZIXF2zHS4HnAMQ0oVHDhqn9NwrGUEgxGY5peDmjJtjd6pkxJ7tQ28Mg= X-Gm-Message-State: AOJu0YyblXOT8frgohikd2ThNAk8xdsaVrCqvObubACkeDT0D0fa5jGz BgIxjmyx0cIIRKSWtm7JMCZGbITpIFZgkhCkUr9SZ/97YkWYmudMOGlekaQ/pcsYrB4filesrVL PGg+bBg== X-Google-Smtp-Source: AGHT+IGW5p0HgLAn8l5aYZBJ4Boo4bm6ly1P78GV/4bDdqw7hMUFDKApK0Y7U+/yyqc8Q3iikYnotrKwO6YX X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:10d:b0:631:259b:fce6 with SMTP id 00721157ae682-66603ed354fmr233327b3.9.1721264485416; Wed, 17 Jul 2024 18:01:25 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:17 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-22-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 21/27] perf diff: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180126_764082_42692F3C X-CRM114-Status: GOOD ( 12.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-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 perf_tool *tool, return ret; } -static struct perf_diff pdiff = { - .tool = { - .sample = diff__process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, - .namespaces = perf_event__process_namespaces, - .cgroup = perf_event__process_cgroup, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, -}; +static struct perf_diff pdiff; 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; + perf_tool__init(&pdiff.tool, /*ordered_events=*/true); + pdiff.tool.sample = diff__process_sample_event; + pdiff.tool.mmap = perf_event__process_mmap; + pdiff.tool.mmap2 = perf_event__process_mmap2; + pdiff.tool.comm = perf_event__process_comm; + pdiff.tool.exit = perf_event__process_exit; + pdiff.tool.fork = perf_event__process_fork; + pdiff.tool.lost = perf_event__process_lost; + pdiff.tool.namespaces = perf_event__process_namespaces; + pdiff.tool.cgroup = perf_event__process_cgroup; + pdiff.tool.ordering_requires_timestamps = true; + perf_config(diff__config, NULL); argc = parse_options(argc, argv, options, diff_usage, 0); From patchwork Thu Jul 18 01:00:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F496C3DA60 for ; Thu, 18 Jul 2024 01:08:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UZ3Drtsbb7xK9GFR3k7+K4AhjLYb+mQoMq9GLVm8nd8=; b=I5Ao12HkctjFd/ZpLZnuWBBJxc nIarJpQZyntGJLtlACLng5eH/dgB2pUm8yEZ4lc7cZB98Q+xEBxvsxFXD5jN+hG4RzOTGvRbv1rm8 BIJjHw5xVIb442aYeayX8q+y50DAFtXlsusJJIzEfIrNCi+r78DTlHUqnko2VmzEm7MFuBQptS9fd BoZXPMqtAOE4v8WOwgOWqUsd7Lao4/7lCRIYGpNKSQm/iZrj1Wliq4LFFLKs8wwVL8sU0dsvQ1jzt lO87gePVDTUYDV+OSfpn4eJGUvuKA74IQjZO9C0k/yyK1GN7dyZNIqFEmjk66Lpmx8wa1/7wl/RLC FPyQ6BAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFce-0000000FMLZ-3c6K; Thu, 18 Jul 2024 01:07:52 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWS-0000000FJpD-4ANz for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:30 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-664916e5b40so4737067b3.1 for ; Wed, 17 Jul 2024 18:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264488; x=1721869288; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=UZ3Drtsbb7xK9GFR3k7+K4AhjLYb+mQoMq9GLVm8nd8=; b=045BtxJ+OwnaTVSoyro7yoISfHRhrPQLxr0c+4pIaxt38NGydM+xX6iRykMXJ9Rs8n l3ClkriujGjC6uq11Mm0x7gKDv+S+58iZ/afnfnOpUNAP4lqw0CSPTuSKTQ8W2DKjkno RVzRZY68ZWiIQl84gS3bFndjcqXuktH3lGxuQ60MVBv3VYIj+pgEXoh04rIHs96inR84 3mk81aTe1IqpJTjve+5QYKWSjrGjyHq2S+tPbBQ+Tw9EXRRQuWlPMr4TtCmCTJTeYCDy 4xKRZZJdSf/6gTWfFf+4fkUejN65LKEX0zz8lkEbyWimdR+95dwzu5N1/vqxzo3+/jpX nP3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264488; x=1721869288; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UZ3Drtsbb7xK9GFR3k7+K4AhjLYb+mQoMq9GLVm8nd8=; b=qgKalHh/XnETfKor0qDt1mgxVYgHDQuMgTDdIaR8+4Kk4FyaXt/2CR6Oi6owNiCKrJ PVBlxmq3boPl5HEhReWLv9vncPwWJkMCCI7UNpBQGibwpf2w3PWCfILnA+ZBSCeE0gBT gZhp62EhI/ROQ8/fY5/E3V+priivbN0zBbaTeam7JeM0z5Ym+rMstZSRAEuy6a6Uu1ys 6GNx1Y6TWc496/mZv/8fpS27Ui47dAu0Rdw9I7sRs/Xcmr1QFeI73+InF/HrQzq1C22B kqWRHJN1Rnj5NR9DRg+Ra/LV0mV+xDx3lyGo2ao0duFDqL/opVdVaW6uvc+c5nAvz7E3 kaEQ== X-Forwarded-Encrypted: i=1; AJvYcCXhIYs9FNnxh6WWZbjkP0uZYO2+ofIJfCJ0czWqSMpXmTP4eUOaZ2ivMs80J1ST6XT0vR1aO1YdsRYDioU8U4+7Av4T+cr9/wJc3q0QJ3vthztQmig= X-Gm-Message-State: AOJu0YwdPH7uTHB8ohv+oh7qStpoYI0eIc9F4ytgzp9GnWzBbOpgmO1H ZjoCV2gFqIMAa+nzvl4DwvLv4Q5Dg5VcY5CIL6j7Xw3i8+EeI0aKPLgo+BaDNkbdJSJvuDrFgvM sD67RtA== X-Google-Smtp-Source: AGHT+IEMIegm6jNE4CQClsw7GOzZrobtpwCpbE8HwTGUbjxQR6jEtSbn4ARwhdR3fei25wrA9LB/QeoUjXvX X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:385:b0:620:32ea:e1d4 with SMTP id 00721157ae682-6660af16a6fmr758457b3.0.1721264487742; Wed, 17 Jul 2024 18:01:27 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:18 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-23-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 22/27] perf data convert json: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180129_056061_6B200826 X-CRM114-Status: GOOD ( 11.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/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-convert-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, const char *output_name, struct perf_session *session; int fd; int ret = -1; - struct convert_json c = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .cgroup = perf_event__process_cgroup, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, -#ifdef HAVE_LIBTRACEEVENT - .tracing_data = perf_event__process_tracing_data, -#endif - .build_id = perf_event__process_build_id, - .id_index = perf_event__process_id_index, - .auxtrace_info = perf_event__process_auxtrace_info, - .auxtrace = perf_event__process_auxtrace, - .event_update = perf_event__process_event_update, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, .first = true, .events_count = 0, }; - struct perf_data data = { .mode = PERF_DATA_MODE_READ, .path = input_name, .force = opts->force, }; + perf_tool__init(&c.tool, /*ordered_events=*/true); + c.tool.sample = process_sample_event; + c.tool.mmap = perf_event__process_mmap; + c.tool.mmap2 = perf_event__process_mmap2; + c.tool.comm = perf_event__process_comm; + c.tool.namespaces = perf_event__process_namespaces; + c.tool.cgroup = perf_event__process_cgroup; + c.tool.exit = perf_event__process_exit; + c.tool.fork = perf_event__process_fork; + c.tool.lost = perf_event__process_lost; +#ifdef HAVE_LIBTRACEEVENT + c.tool.tracing_data = perf_event__process_tracing_data; +#endif + c.tool.build_id = perf_event__process_build_id; + c.tool.id_index = perf_event__process_id_index; + c.tool.auxtrace_info = perf_event__process_auxtrace_info; + c.tool.auxtrace = perf_event__process_auxtrace; + c.tool.event_update = perf_event__process_event_update; + c.tool.ordering_requires_timestamps = true; + if (opts->all) { pr_err("--all is currently unsupported for JSON output.\n"); goto err; From patchwork Thu Jul 18 01:00:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735914 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC80DC3DA5D for ; Thu, 18 Jul 2024 01:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Clkf8d2hIy3r9JhAIXh+9vb9zWkbL7cEj4ImfbK/zRA=; b=gsx1BhXtLvPylh8DCGCopoT9W5 qBn8mrQkNT8FNq1SLfyk32DD8CF1InuPwmBfsQxWVbZxDcwN59vJTJD1MVxIjrIf1pSqz+g7HA3Nr 4IZsmCQjBJ1BafbnwrZLr6o9lXUbJwadmSjHkVZ0JH+GXULEtaZ4+ELnzb32d4k0n56MC/teaURb2 qfTm6mJdosjFwbEg/YdiJ3oKE3ee9Wgu7nKBbiaBuLbI1qg4bB47nH+3DN6JZ8F7O2ZmLlTAlF/AS d0zXDDaGxouo9iu46uUODUNBPuXLzLGKyBtZgSdOQRO/VU7GcEhry8oNqG8ecCWWjH3uWai/hTPpF jGlm0SyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFcx-0000000FMQ4-04Rx; Thu, 18 Jul 2024 01:08:11 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWV-0000000FJqB-1V1a for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:32 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-666010fb35cso5204747b3.0 for ; Wed, 17 Jul 2024 18:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264490; x=1721869290; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Clkf8d2hIy3r9JhAIXh+9vb9zWkbL7cEj4ImfbK/zRA=; b=YYEFIkfYQQjPVQWNN5pDnfgc7BbaPeFcXT1VAn4PwQBz7PGvjTUEaRw7Bl//bS6Skk DS2/TPKzz7MSLAXZOedZlWhg7s+gK2mPYFcxCIR0baGeekXZ2jKQPFkX+Y46JpTTghTW unEJDpQeCx/9Yeyfcff7A0EoT/K8IDztITQ2iyWy2rek/46r5CucnuE+mDVXMAqqzHpW YJVvoi11/tJan+vuA8pPzJRgVkf3X6FI7mpzU9H3KGzU+K/qQBCmK+8Tk1Yz2xJbNZa0 ZpgiOW+JByahmljTgkboQHGfGfbZBorZcbVknZ6Y8BuYElbwlZ9MpQTPCyzrs19Y3q+R YnfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264490; x=1721869290; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Clkf8d2hIy3r9JhAIXh+9vb9zWkbL7cEj4ImfbK/zRA=; b=PxNK8bw+GAiveWd0cV8gG2Ub8Y58DzTQM7m0CfyG11aGcwhuNzf8T2OGSTEu63mN1E uqMMBi0HwbfCjv4s/eCYM5MEXEoMv8VERwoSMK4F8ntiKWufqTbskV2P+xQdGEASPqXp MwGib9rmxEOnnkq9lnl6m4E7gkEF1wtFwJRq/gmG7x5l1rBoTtxJXRrcAEKC29dpLqPx 6dvBwvuj/vwasiMt6cQEMNIPLuzhXwOqeJ7bZNymRi7CVAAEWdxvU3qAJs42wi1ZGTK3 cLLccrKgSkrEDZMpTxSkqH/W36H6jkETkV3WHl4FLPDwSkiTx051xVbvexKZVMok8Y+T 5jcA== X-Forwarded-Encrypted: i=1; AJvYcCVKGgkz3NCo9Frw69g+SwOXGqfOHeJZ95UivVxYKQ4WPQDi+KLW5IbM3HDCrufLjCYorqiyyC3TRNtHo12ThC/6BjcL+seIbio6RCceNIZhpg8MZZo= X-Gm-Message-State: AOJu0YyAkQHYBe4aRRltmeb3RtvlbTgsqv9LgbYDtbJlcTXKNbXCa0tn cSOzmn85lPg+Tchw+/ojwRP5NkIl7qVOnKKSxqtPZf57DCoWK1GObOW5VHS0mEBO/jUN1OwuYeV mdzPeoA== X-Google-Smtp-Source: AGHT+IG3uW51DaI0jwt64D2aVkFsd0oCKXhiJ/qB6/tX+ACDLixR+siknXwDm1ELbOkMHzZQc1ESlEtW9OiS X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:2b04:b0:665:7b0d:ed27 with SMTP id 00721157ae682-66608017be9mr125757b3.2.1721264489810; Wed, 17 Jul 2024 18:01:29 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:19 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-24-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 23/27] perf data convert ctf: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180131_448917_56CEA54C X-CRM114-Status: GOOD ( 11.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/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-convert-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 char *path, .mode = PERF_DATA_MODE_READ, .force = opts->force, }; - struct convert c = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, - .tracing_data = perf_event__process_tracing_data, - .build_id = perf_event__process_build_id, - .namespaces = perf_event__process_namespaces, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, - }; + struct convert c = {}; struct ctf_writer *cw = &c.writer; int err; + perf_tool__init(&c.tool, /*ordered_events=*/true); + c.tool.sample = process_sample_event; + c.tool.mmap = perf_event__process_mmap; + c.tool.mmap2 = perf_event__process_mmap2; + c.tool.comm = perf_event__process_comm; + c.tool.exit = perf_event__process_exit; + c.tool.fork = perf_event__process_fork; + c.tool.lost = perf_event__process_lost; + c.tool.tracing_data = perf_event__process_tracing_data; + c.tool.build_id = perf_event__process_build_id; + c.tool.namespaces = perf_event__process_namespaces; + c.tool.ordering_requires_timestamps = true; + if (opts->all) { c.tool.comm = process_comm_event; c.tool.exit = process_exit_event; From patchwork Thu Jul 18 01:00:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 090EBC3DA60 for ; Thu, 18 Jul 2024 01:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=REzOwcnCQMi8P53oskFE/aACHZkwc/UlMI8wZ8Kriac=; b=R0OyCex7Ka50IFD70AM0VQWEt0 YkQ+zDgbbEIRyE1v5mqcDuauqJljIC8YlSfmD+swOVx5lEFDyemUJgrsyGQOjH5trFqS3rNKYKrgv ZTjfsPL0CFj8pXGxnpdA7O2jmi/DGQqWE0KRtlJ3zA9poN6WcRHvHQt1+xlsAM7HJgduzKUBfHQMZ 5sXrwQnfwZ7WiEcrwBtVRUGwgnYfv1jIHdRY7hD17gLfn7kE4sdHCAKg/VP1wFcs5hsidTnKHTJuj 1S5WCVLDt1Y2k24lBEmrUNr0gPOzQ0sXDTjMtG39A+3/0xx9ejS+e8PjYvYSMTt+ROf6J1TnUII0A fBMOqM/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFdF-0000000FMVG-1svW; Thu, 18 Jul 2024 01:08:29 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWX-0000000FJrN-1118 for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:34 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-65eb8845bc6so6978647b3.3 for ; Wed, 17 Jul 2024 18:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264492; x=1721869292; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=REzOwcnCQMi8P53oskFE/aACHZkwc/UlMI8wZ8Kriac=; b=mIrH4maJhiQF9/BgyZS2y4pzb9vC/nb/0EQr8sl6rZMjEB5IiuTmwbZXbuM5FuSAZA hZpu1IJC/48UhZ/HHHdFyEbJC2OpHW0HN5+wRmEUY3AG98rl3NsEE9+UuMeyHn0Vhvg3 lQigx10nfBl9hWfDCKvuggmejnE5A+gWm/cjtNq7EpYp14eB3AqWbNxJgmkLfVKxk3rp WDWhqWWkl9rk7ZeW0ol4is9lUqih//yC9WpATgN71N5WIHGyNIxE+apEFAtbx5IwPi5V niM0WPxF0040lhHjmw5SSIfu9mGzx/72bs9YXlOd+ahbW4ZRywwTUvjQBw7iPYFaoZzc FErQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264492; x=1721869292; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=REzOwcnCQMi8P53oskFE/aACHZkwc/UlMI8wZ8Kriac=; b=eeeXd3CVH9oK/gYd+WqQIZfG93xEsL3m/C8JZXYSJULMlNNcFrFtVbIj8ZfOhpQAls oYAGVWVcKb3+U4Y4b5C0frXgoG01TL5nI8b6jv3mdDThn9in0smgChjhM39Cyixz8loY EvneWb052OdfIFVJlyEVzI/uThvLFA8JpSYsetnJU+wrB2hiuevyXintVcQjgvKagVD6 ARVIeoSIjz0eB99K5+yKbuCR5ocBh0HwW0Ytp2y6LEr/4CH2OrOBiKvvwc5sMNgCXSKy sBMzjybZB/Jv6JHybRKwqaMZNWLvMyXqlnwHoxwQ5z0RPyZWJyGA2pairOs3LCq9CFPB wR4Q== X-Forwarded-Encrypted: i=1; AJvYcCVr20LIVT+W77FxqsLQnZQQEIeatDAz0uRbium951atzNT7Np7rwYZxoGBXL/PwZwvfu6saNY+auTtKHmUb1bFTNvTX4lpqQNmnMEf+Wc7XQ6MWadE= X-Gm-Message-State: AOJu0YxJ5pU3xki88Tnqj+OpEYwAfRTVek+lO6ZGh9LQbk50j955SVG8 xL79i6bfkwVxTQKkBbZ48QchswnXPxcLUWzXXtgDYtYqcuc1x7tOjN+OMZZHSo4QZ/mzfu3izzE Jn3nAZA== X-Google-Smtp-Source: AGHT+IENJRTJFBxLEruydNwMFvGZtwUd9yw7NYoBiIOr6hcXSjFkwsbhRtb36vAKwTB1IMSXwJ8aHdyUAnC0 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a25:a2c4:0:b0:e03:39fb:5729 with SMTP id 3f1490d57ef6-e05fedaf378mr2117276.10.1721264491944; Wed, 17 Jul 2024 18:01:31 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:20 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-25-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 24/27] perf test event_update: Ensure tools is initialized From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180133_340000_6172EA52 X-CRM114-Status: GOOD ( 10.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Ensure tool is initialized to avoid lazy initialization pattern so that more uses of struct perf_tool can be made const. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/tests/event_update.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_update.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_scale)); + perf_tool__init(&tmp.tool, /*ordered_events=*/false); tmp.name = evsel__name(evsel); TEST_ASSERT_VAL("failed to synthesize attr update name", From patchwork Thu Jul 18 01:00:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735916 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CE8D8C3DA5D for ; Thu, 18 Jul 2024 01:09:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CK59PJHvthhN1XqhU8dM7HWi+8LWSLWxbFsmB17zlH0=; b=g1g6cXZYmYRqXUzK3CdZmBBEP5 ELZXvM/4g1skxgq/KAGeNqmwQcUT0gRBdQOsmm/rU4wBPG1oBCpu1CgSDszu3ql4N51XEcSS7+Qo5 RxCews0oTdBdJMvfCWKVszAwzObwfGY1Xy3cNKaXUZp04W8rz3sb1vLbFJwUOvyOBG+QTE4c5CRfD iF8Im8tu9LsLlf+8n2qZehplRTfiOsl2Ff8nXf9E1ALdV80qXqCoi4BPuN7sQbp61ortMG/XzFot7 wIroZy9wId/us/bBoR4DM8vkZYlgxrIk84W5ufZMLT1mizQYLpY8uhhbNGyUznCz5+MwbHaPpINUx E06dEfSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFdY-0000000FMaG-1xmx; Thu, 18 Jul 2024 01:08:48 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWZ-0000000FJsM-21rF for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:37 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e0360f8d773so677544276.3 for ; Wed, 17 Jul 2024 18:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264494; x=1721869294; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=CK59PJHvthhN1XqhU8dM7HWi+8LWSLWxbFsmB17zlH0=; b=32pOdaApVHDEi7Y8H+Uz9hnQCYV92/hZ92QsLIWTp5JmI4GQNJj/GTqrlIhsXL2Myb K/dR+LsPzP2FSI9pmXz6EWcP8y3MJ1lJNARMI0jACFYHlPUa2YL0hiSxpbzzhXco4lZt kQ6I9MR3fE/v3v4wsdnQDVx0ru4l78THOj+TOj7BYmcyhpjWSU0TRax0anPC05aS7JRI W/NSu7d4U4XvPE6pRoC67NHyNQt05ZsEpqrFhsY4gHrYhldE+htpgcm3O3yKtlkQy2+E PVbFLp8smJIQmCU/zzsOWqJccXnohVHLSKcMbzXJ34rnzBMD9CRr3U/bgowN2lz1uAuP ogcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264494; x=1721869294; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CK59PJHvthhN1XqhU8dM7HWi+8LWSLWxbFsmB17zlH0=; b=jUPTdHT5hbcPQmbR4hSQ8TkZSceHTd1VuGgxp8jaoIwj7oYXJ2ITcP5DWkqX/GM4Vp cfE17a81tAcYd8JyQz6V6Hhn4Bxo2DoeDwTM8cKybP14GXrph47DoZR6NxdaNMwypemT dw8P+sbA4F6Hza1uBx9dkSA/6SRpmikQ5EjXz4cMt142nbLEhErlSjnWfN1p0sRt3Ti5 z+2plblBwSabhPmTMOhWr3EvAmgZWxzuelGDoSWqiEu3t2XuUiQsBJgJvEfjsyBoGdqT 6ohH4qa+qOnSUXrINKq3CoxYJGtr9wOWsFSLKzwW5E0EqKahgesJLTPhrH1zpwVPTpGQ Pnog== X-Forwarded-Encrypted: i=1; AJvYcCWndy1xdHRcz3f+vmxIv8sNpxIko5TqQQJhvbagdKD9coVTU47CLVCpodV3lmQXCifryDCIy/f3G9X1WNg4VZqeLlbXpSpb4ZKVw2iERQPkPDaWD98= X-Gm-Message-State: AOJu0YxZuWofBk/cyH9YwMD9o+wY70txdxeUxvmEhvaueFgUzIfwZZKR N1hls1HdHgcu7EzSRwnQ7lYZCtCfKdT0y5wpn1uZjwqrK7hL7OOhriZGQT48v3VF512o9Nnyi8J q6Qm33Q== X-Google-Smtp-Source: AGHT+IF0zgfiI7337Gx4Yjc5WQ+vYPQsx4H9UggbKoSxg5u9Xfw8UkV6hdUgp0OEYyULUUoe/l5TQODhg0kQ X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a5b:8c5:0:b0:e05:b006:9e12 with SMTP id 3f1490d57ef6-e05fed6ced8mr7959276.11.1721264494077; Wed, 17 Jul 2024 18:01:34 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:21 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-26-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 25/27] perf kwork: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180135_552431_9C8E6087 X-CRM114-Status: GOOD ( 11.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/builtin-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 = { .class_list = LIST_HEAD_INIT(kwork.class_list), - .tool = { - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .sample = perf_kwork__process_tracepoint_sample, - .ordered_events = true, - }, .atom_page_list = LIST_HEAD_INIT(kwork.atom_page_list), .sort_list = LIST_HEAD_INIT(kwork.sort_list), .cmp_id = LIST_HEAD_INIT(kwork.cmp_id), @@ -2462,6 +2456,11 @@ int cmd_kwork(int argc, const char **argv) "record", "report", "latency", "timehist", "top", NULL }; + perf_tool__init(&kwork.tool, /*ordered_events=*/true); + kwork.tool.mmap = perf_event__process_mmap; + kwork.tool.mmap2 = perf_event__process_mmap2; + kwork.tool.sample = perf_kwork__process_tracepoint_sample; + argc = parse_options_subcommand(argc, argv, kwork_options, kwork_subcommands, kwork_usage, PARSE_OPT_STOP_AT_NON_OPTION); From patchwork Thu Jul 18 01:00:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2E087C3DA5D for ; Thu, 18 Jul 2024 01:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dsqa4ji/Kru2TpTCpzQSXPab7IPwWK5YnC4MrN+9OsY=; b=Tjy6U4rS8rDN/6CEAAq8m6cNLk 4IbqQ1nEn6zh/Hj6sX5PoClziAoI0JBHc95L3dJ5owqoF7jlISkqStEHdWYYB9i154f2ijLWFYWmc ep7Rhjnx//mWqmtDpiouqOU1HfXa6485yGGkoeo1Y2aYqIUov//3+T/XAkPAt9eYXeeL88uC0o1X2 0boNFcjMpaobOtv2C2VS6cUz0mVZo60h68U8LfXYQODvki4rdDR+rOmP9Trk95a3/IbN4tE2tlIrK GHCFjBkNyBCN0P0pGMzSZNV19BqjPAjMiW6PNOTmsIna708bLA6j3jtWFRORiRGiyBCurhCvYXhtE 97pB7HEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFdq-0000000FMec-2mVf; Thu, 18 Jul 2024 01:09:06 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWc-0000000FJuU-0AK4 for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:39 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e05d72f044cso601179276.3 for ; Wed, 17 Jul 2024 18:01:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264496; x=1721869296; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=dsqa4ji/Kru2TpTCpzQSXPab7IPwWK5YnC4MrN+9OsY=; b=t/VzIlV4omc7PrcPraJuThm3Oa2NpV7oc01hMLuxkjFJTR7szUfE/Ay1TyL5zaEefO D37Za4ldghXmGZr9Eo4cAyb/NBpLgFA0v737AtAzyVjIbIXrERtxyA7dmhafDrBfpsvS G/IWPQDxhUClsgqrKp5NlfawMtc6XCmnd6pPOsHs0mk1ZP+nn5tzvY97zWYlWFkSf36g DjlhFhb1LUlTtw6AXVZlH/HDQoBuasKOsbVhCy1kFSrvK08IgR9HefVexUBJGDnNkaok WD6fD0T3K9oDMkAg5igjMW2IqxznNrJTTaLKr6RWR99swQSzBkYfk7EBZe5QMg/W+Qx7 xj/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264496; x=1721869296; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dsqa4ji/Kru2TpTCpzQSXPab7IPwWK5YnC4MrN+9OsY=; b=uddchhygYwybskOsMdA4hNw6QuTKzwZRHC6MYtRZ+vTt9GA4AFlCdfzTsecZFWbfHV mwTQTbvIxDhuzV6SlyyWSW8+ye8hq0hDKuP+DXSChYb8Jv3WxELVFxwvH+miZYLOwwl3 ezYe+alHCBD2vyg30/fu4vXpSwA2THEYRuZeWosRx4NQi54q+1nBzzINHb3/1crZgBfN 1oU68YrnsCD4PpfOAf1b6sO3/rEND5ApQ+eE/tQU/2OBWphFt2Zu/0oEQ/lojMOXpZYO 0G1j8TsCT7aebGdvo6eYCio2BD2xDozdeTo+WrfxaN5SFBV7u42Kxsb6OENNogdCcO+P 9LLg== X-Forwarded-Encrypted: i=1; AJvYcCUovMnjtypF/XbalbpFkFeIXsFAcKzwhnZTxl95siTe0cRMLKCroFrlijLFlhQtKxskvOLR1+qt5zeRwOjxfWZkKrtER7I09SPcZHcDZ56O1F7PRug= X-Gm-Message-State: AOJu0YzrMKJfhssuLIK2dUNGhKDxAQjeChVSkdaPLvXQxhb/6JHwOcFG oxWxQnQLvlqkF2gZ1sGxDB6nI0N7UH1uCzQMtC8b7H94msZ7lWN7zdkYXfyF6xkyU0U442CgFfN 1WmYBsA== X-Google-Smtp-Source: AGHT+IHCN1faAO+r6hnMX5BHhvSYi2L3MP7xyujmm2Mr7VslcsQx4zStBqwTrKdnZw0UNaH7Tqzijy2cur+u X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:6902:18c6:b0:e05:aba2:43e9 with SMTP id 3f1490d57ef6-e05fea8a868mr2200276.5.1721264496521; Wed, 17 Jul 2024 18:01:36 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:22 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-27-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 26/27] perf tool: Remove perf_tool__fill_defaults From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180138_225994_BADF89B6 X-CRM114-Status: GOOD ( 13.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now all tools are fully initialized prior to use it has no use so remove. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/util/session.c | 6 --- tools/perf/util/tool.c | 89 --------------------------------------- tools/perf/util/tool.h | 1 - 3 files changed, 96 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 5359ee055c85..ad5da61d2330 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1776,8 +1776,6 @@ static int __perf_session__process_pipe_events(struct perf_session *session) void *p; bool update_prog = false; - 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; - perf_tool__fill_defaults(tool); - if (rd.data_size == 0) return -1; @@ -2255,8 +2251,6 @@ static int __perf_session__process_dir_events(struct perf_session *session) u64 total_size = perf_data__size(session->data); struct reader *rd; - perf_tool__fill_defaults(tool); - ui_progress__init_size(&prog, total_size, "Processing events..."); nr_readers = 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 ordered_events) tool->finished_init = process_event_op2_stub; } -void perf_tool__fill_defaults(struct perf_tool *tool) -{ - if (tool->sample == NULL) - tool->sample = process_event_sample_stub; - if (tool->mmap == NULL) - tool->mmap = process_event_stub; - if (tool->mmap2 == NULL) - tool->mmap2 = process_event_stub; - if (tool->comm == NULL) - tool->comm = process_event_stub; - if (tool->namespaces == NULL) - tool->namespaces = process_event_stub; - if (tool->cgroup == NULL) - tool->cgroup = process_event_stub; - if (tool->fork == NULL) - tool->fork = process_event_stub; - if (tool->exit == NULL) - tool->exit = process_event_stub; - if (tool->lost == NULL) - tool->lost = perf_event__process_lost; - if (tool->lost_samples == NULL) - tool->lost_samples = perf_event__process_lost_samples; - if (tool->aux == NULL) - tool->aux = perf_event__process_aux; - if (tool->itrace_start == NULL) - tool->itrace_start = perf_event__process_itrace_start; - if (tool->context_switch == NULL) - tool->context_switch = perf_event__process_switch; - if (tool->ksymbol == NULL) - tool->ksymbol = perf_event__process_ksymbol; - if (tool->bpf == NULL) - tool->bpf = perf_event__process_bpf; - if (tool->text_poke == NULL) - tool->text_poke = perf_event__process_text_poke; - if (tool->aux_output_hw_id == NULL) - tool->aux_output_hw_id = perf_event__process_aux_output_hw_id; - if (tool->read == NULL) - tool->read = process_event_sample_stub; - if (tool->throttle == NULL) - tool->throttle = process_event_stub; - if (tool->unthrottle == NULL) - tool->unthrottle = process_event_stub; - if (tool->attr == NULL) - tool->attr = process_event_synth_attr_stub; - if (tool->event_update == NULL) - tool->event_update = process_event_synth_event_update_stub; - if (tool->tracing_data == NULL) - tool->tracing_data = process_event_synth_tracing_data_stub; - if (tool->build_id == NULL) - tool->build_id = process_event_op2_stub; - if (tool->finished_round == NULL) { - if (tool->ordered_events) - tool->finished_round = perf_event__process_finished_round; - else - tool->finished_round = process_finished_round_stub; - } - if (tool->id_index == NULL) - tool->id_index = process_event_op2_stub; - if (tool->auxtrace_info == NULL) - tool->auxtrace_info = process_event_op2_stub; - if (tool->auxtrace == NULL) - tool->auxtrace = process_event_auxtrace_stub; - if (tool->auxtrace_error == NULL) - tool->auxtrace_error = process_event_op2_stub; - if (tool->thread_map == NULL) - tool->thread_map = process_event_thread_map_stub; - if (tool->cpu_map == NULL) - tool->cpu_map = process_event_cpu_map_stub; - if (tool->stat_config == NULL) - tool->stat_config = process_event_stat_config_stub; - if (tool->stat == NULL) - tool->stat = process_stat_stub; - if (tool->stat_round == NULL) - tool->stat_round = process_stat_round_stub; - if (tool->time_conv == NULL) - tool->time_conv = process_event_time_conv_stub; - if (tool->feature == NULL) - tool->feature = process_event_op2_stub; - if (tool->compressed == NULL) { -#ifdef HAVE_ZSTD_SUPPORT - tool->compressed = perf_session__process_compressed_event; -#else - tool->compressed = perf_session__process_compressed_event_stub; -#endif - } - if (tool->finished_init == NULL) - tool->finished_init = process_event_op2_stub; -} - bool perf_tool__compressed_is_stub(const struct perf_tool *tool) { return tool->compressed == perf_session__process_compressed_event_stub; 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 { }; void perf_tool__init(struct perf_tool *tool, bool ordered_events); -void perf_tool__fill_defaults(struct perf_tool *tool); bool perf_tool__compressed_is_stub(const struct perf_tool *tool); From patchwork Thu Jul 18 01:00:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13735918 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9FA38C3DA5D for ; Thu, 18 Jul 2024 01:09:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VI+1UrmSH+U4tsTCU1WpnUiPEx/6DVcJnUZK6PtxySs=; b=AYWhstxRyB8j6m+bmA95rMtcK7 sAwnpIyd1pbOt92bGu0qECAQ7+YNxIvb4uNkXwMfIkgpToMLljzXkxVbFA2+HYoPnazGaCWNC78e6 Vmymv1Ju3FGcLOSmp+MDlNWL8L2bj9ziys9mw55HaMJG61/mBKHVOWuMjbXlQ3b42+RY9mK/jCONX cvU9hi/CkdpEGLKqTSd7oPHgO3evLKiEcRxllLZOz4UR37+8ijpIIkz1PTZNo1zudVh0W99ooWdw/ qp+l5R1grMh9OcYqwY9g9flULKpZUddtB0Sqh/Pk4hMOahJQnFCxFRXxYeoGDBBKyWyiwVC6CkS5T RnygL0qA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFe8-0000000FMj5-39SM; Thu, 18 Jul 2024 01:09:24 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUFWd-0000000FJvZ-40RK for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2024 01:01:41 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-64b70c4a269so6457897b3.1 for ; Wed, 17 Jul 2024 18:01:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721264499; x=1721869299; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=VI+1UrmSH+U4tsTCU1WpnUiPEx/6DVcJnUZK6PtxySs=; b=qyeay/swvIXtmqvVlfv7QgI2g38s2q+oTXfsDyKzTaQBUDh7K9dleHPSmjCRDvk0KC 7TAdeT75yqwM0mFo+W+/xXRcGDXurd15uitZseHidR2IfP/mahTYfEaIApQVghuhRvsp h0z2dOsc2Uv4IceWY9RziqmpcRgR5UJ5uZxzs9rvTIJT+cWT1LimCLorT1+hXn0gMkAM LEQYlLVB+dPsE5I/9jm0JwyIW4E62nqGs9mwW/ovap5f0DB1ddCa8Al09cO/PNXJhqiR 0o9V3NYSZdGQjfYiZcJAok9L88woUn/0E0M/m2kv2cNHF8u6uKnNXUyPVAXSyl9ifRRv /t4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721264499; x=1721869299; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VI+1UrmSH+U4tsTCU1WpnUiPEx/6DVcJnUZK6PtxySs=; b=s/33XfvyzCP+nz6YckFTeH37EA7tdBn9h/LCzyUzNtL5tv5vpYBXDoBhxewrJYmYRP 6JVb+8e9WuAjJyrOMy8gAWheJvictSBVbJqlkj0PQRR0x8mdVb7AYpl4BIphcZtSp2G8 XstRA55Xbrr7aIdRFsexba5qw1ky78C+dO0Q8IGSuoGouFzZdVn/6XZe2f4VqWBIbRW9 IuJ87pRNpgWAUYDssW0xc0sfzNk5f0ffmbw8i4egip4OT1iBHzeoJHDvqVACxbWHOH3e cMtNWriag79Zczia9pfaL9F0L+nsDK4r06bR/qCQGUec4Mp/w+onPPQbuiYRWrCBckNT oo9w== X-Forwarded-Encrypted: i=1; AJvYcCXGji2dDbz3Vy0SFCI8QufISrXvWv+9uqsxGipGaCUYQBG3BchRRPJQnCxiXG35JoSwSHY0hMDIrqlrwqOFsHxAaTyFspM0RFppjbp12VF4XzkIdes= X-Gm-Message-State: AOJu0YwNAVqkZTyYfldlXJyXTWUmEAHVBI8gkVKnTrEa5TbB49rOdi8+ c8CYYK6/q0cuGaCQTVIjMTVFvbs/It3oy84ogp2FHfDPJ6iIaywOsNZh8a6JLARKHOsxnbnXoUo 55xxSEw== X-Google-Smtp-Source: AGHT+IGQt5ri8LAL7TX8J0R4Z6KxrCn64uDLn1sYG1dmmUfG8en4e1ioo3g5nWqMwIk/M1O4Qs9bCX+5dLdq X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:940b:9044:fa83:4060]) (user=irogers job=sendgmr) by 2002:a05:690c:110:b0:65c:1db1:9235 with SMTP id 00721157ae682-666005395bbmr263907b3.0.1721264498698; Wed, 17 Jul 2024 18:01:38 -0700 (PDT) Date: Wed, 17 Jul 2024 18:00:23 -0700 In-Reply-To: <20240718010023.1495687-1-irogers@google.com> Message-Id: <20240718010023.1495687-28-irogers@google.com> Mime-Version: 1.0 References: <20240718010023.1495687-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog Subject: [PATCH v6 27/27] perf session: Constify tool From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_180140_072954_42C94EE9 X-CRM114-Status: GOOD ( 13.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Make tool const now that all uses are const and perf_tool__fill_defaults won't be used. The aim is to better capture that sessions don't mutate tools. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/util/session.c | 6 +++--- tools/perf/util/session.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index ad5da61d2330..0c7cc092887d 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1765,7 +1765,7 @@ static int __perf_session__process_decomp_events(struct perf_session *session); static int __perf_session__process_pipe_events(struct perf_session *session) { struct ordered_events *oe = &session->ordered_events; - struct perf_tool *tool = session->tool; + const struct perf_tool *tool = session->tool; struct ui_progress prog; union perf_event *event; uint32_t size, cur_size = 0; @@ -2195,7 +2195,7 @@ static int __perf_session__process_events(struct perf_session *session) .in_place_update = session->data->in_place_update, }; struct ordered_events *oe = &session->ordered_events; - struct perf_tool *tool = session->tool; + const struct perf_tool *tool = session->tool; struct ui_progress prog; int err; @@ -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 = session->data; - struct perf_tool *tool = session->tool; + const struct perf_tool *tool = session->tool; int i, ret, readers, nr_readers; struct ui_progress prog; u64 total_size = 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;