From patchwork Fri Jul 12 18:10:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732136 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 15458C2BD09 for ; Fri, 12 Jul 2024 18:13:05 +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=i9KTqj1XTO1kSrFui3ztj2R2oaLi4f9rlK2QpY6IF3o=; b=Vo0JtAEeo5B0B2kz5Gvb8/k3rZ I52cDMzBGDkD42eBWy8xfnW6ki+fw4MIgSi1+/TD2mCS7loQROBAV9n52bmceC5qzKI/885m4h4A8 QXZAlf8n/j/k6MjINxz2T4lKR2HQj35cw2UGy6J1eI5u32QV4EOPnjdvGPzoKkxLWOHUEOTM79C3y IlJfIr32QIKSJ1v45sWHKIi6g3gKdHO2FHbxQAHzPbq9eMT1xhQr51SnwE8yIMc+5/qaOWicV9kTo JW0yN2JqFFINTVyIDzZyrupxuxpxw6QZcABhsyLw3QAWmYeoBTKLtw6esq9EmLwJo6uLUOVUq5Y36 jO2P+qqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKlH-00000000vWV-2gZx; Fri, 12 Jul 2024 18:12:51 +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 1sSKkg-00000000vCi-1sgU for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:16 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-65026e6285eso35209087b3.3 for ; Fri, 12 Jul 2024 11:12:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807933; x=1721412733; darn=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=i9KTqj1XTO1kSrFui3ztj2R2oaLi4f9rlK2QpY6IF3o=; b=qTFiWTglag9fPY9kufu+0Yun9pe/EYj4Xt1nRy9AybL2+rXm3+Egt1OzGkvvWk6dSx yxmC/nwjeXzykRSbd6r2Y3ASXT+r2+8QV0BDDN0Ku+3SXfVDaj8D/qGpNNmJEVMU8zMp Lw2RZ3AogGt7XWRObHuUYoUMTAxZQYserkmvavqbUskqP1g6R/hrAq1856VZnchPuCLz eBlGL6Y7tlrcfX3uHmmwoCcfinUNP3zWL/J+riTT+C5OkMjgyTktTw6ZGbAHR3WRtec1 p81Lv88rn+wqXNk9iQdvsCMeRu7Qq4GXmyDLM7IBFIos3vL8lSEwHaq7MbDLLk5eoABv gFdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807933; x=1721412733; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=i9KTqj1XTO1kSrFui3ztj2R2oaLi4f9rlK2QpY6IF3o=; b=BAjnOfB6KrgfmyY651vWepYf6eqQcRsophk3YgJIw7ks9qR9C+N8pugfqmAaDphOz2 Tfmw+07Y0uImog9zL9TIRpoabaKmQKYJFRGtYcrNIRmhRjLeqTHeNRPjlgZuO/LpRCrz XW/nN0kRnD2FucumPDhht6GvYIZ11C2CFsp1LqUOdxeUWsgXC/GtntlatSwnRX1lXhsX 8tHTuNOtWFUmbl//e/ZRAwnqKlFha80077PULXur+l2C2HxZJCxP2aYKF43XxqTFnJ/h vNHJlIetcU8zhIbgZ917+TRsM8YYHvjYS0g9FO2kltBEv8mPovZMNZkaH/CVUTXq9Lgm 9SeA== X-Forwarded-Encrypted: i=1; AJvYcCXN6RMUxoyT2hzoj+w1CgvaWLzyJLaXgY7s4tUgmMdGF3YdYcnCc0FY+19LHej213DEL1agyiuOrsT/i8dCeqRkbnmJqbLRE9c9dp/ohfjlN0Ju0Vk= X-Gm-Message-State: AOJu0YwPhAUtmVgskcy/dghcjFpurc/JnmEq4GY/ouyxx9lAj2SUwUyU 1aBX3u//LmpWT9UZvHhRfAGjsw7UF0I8dyz1z2BEkBkXSJctxihE3kBbX8FKzXSgr1+NuQhlqIv FPVxkZg== X-Google-Smtp-Source: AGHT+IGvfJh6Fcob436fAIUAkFPWwgKJ1V+h3C/YNeu+8Ob8fyB7BX4Gx99i+s9g+7X7JG4NXDcKx7uNt6JD X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:6910:b0:650:92da:a97f with SMTP id 00721157ae682-658f0fb318fmr1326627b3.10.1720807932980; Fri, 12 Jul 2024 11:12:12 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:42 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-2-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 01/27] perf auxtrace: Remove dummy tools From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111214_517580_7CA029AE X-CRM114-Status: GOOD ( 17.16 ) 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 Fri Jul 12 18:10:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732137 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 1F0C3C2BD09 for ; Fri, 12 Jul 2024 18:13: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=AbSFIAjgELn8En/ODTzECP6YTzi/bZUaiF8JxVDqD4U=; b=36k8/MhJTSJNO79chlAMcOojmR ef8K3zIF/qRccPvQZjcMgsNjqcf8+s4PidBhdHq8ddvMhZK4QwO9Bnwaa7JnioxdILI0Nf6TzXeiu VA6Z7dateCvNMUhXWSaAano6vGvgR31Qc3lKuL8LCmGQ+ZPNri5idTLTdbiARpy6h98mld2i/hKlM gSVRbWVpG4Jvz8MYBXakY3nyW6+gLRolIp7op9B0D/Z7YzaWxuMqlO4uRP1dgltBPqUDysLu/UIsc q0UiBG0E06R/PXj9iDcKbLJsaJXitJAPtJ2IHLrkg6RCSJ6Dua9HQva4t5BDXwoAhqydxzvCkhEHO GO1qdTsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKlY-00000000vfF-06OG; Fri, 12 Jul 2024 18:13:08 +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 1sSKki-00000000vDM-1xXe for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:17 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e037c3d20a6so4128658276.0 for ; Fri, 12 Jul 2024 11:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807935; x=1721412735; darn=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=AbSFIAjgELn8En/ODTzECP6YTzi/bZUaiF8JxVDqD4U=; b=vVYW6LnSPZgSFMO5vBHhC1vt0oqpmtkvGfcI+aSX5nVUt20OTFIHo1MsoP7YeQnE2B KumssFibl01/x3L81tHMFVUmHNeKqTtqBLJEfnj6AgDLsJP5MX3ewbk/l4Su8Cff/9Q0 5qSATeYUpQ9mD6fB9jWKtbUPAEaBRU39PdT+CfnTd0msmq+43F/uhLBELNrvTtTaM/3i 6VH0ZFYO5PK7L2D+eNe8k4Ju3WLWB5SNcne8noSBhTS+h+Fs2lYU55MJJ9JtZ84QBMGX qSe60CgliPu7PsdJbwc8wuOZr9P78ujzSK8NpgD/kZ3U4AHoFcU9AT0h1k5B546PwFx8 Ps6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807935; x=1721412735; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AbSFIAjgELn8En/ODTzECP6YTzi/bZUaiF8JxVDqD4U=; b=pnnqaKYJsYmMlyWMj6CvsleZ7S1qSBRHQQGSVI6y83mwGqeNvNBsHTh9FfGhXhsmMQ /jUuijb+irKSCW7SKTrt4bXfIEqiGUWTqxC/Wiui8gG65nL3JT28wTRxmmSIzuu/uKow iYi+mKMhCgaa1d5OOyKzDr7IoWszpU6SXcIYqt+W/lnIhjuAHiuu5B+IfsGgxYVhXYMw exEvc2XOv6cZl/hRryH2mH114zYaMMj1qbWb8V/AlLkOg6b2ws2CEbUAJiJaJ4y1zX/o sWKdvrEekHVrFhg6BeQsDIK8UYKb1fgY/OxWFNsM8VzWqwjXACY6nbpeymju4XrBP39J ZjZg== X-Forwarded-Encrypted: i=1; AJvYcCViM7yDHslDuT4GsLxapAMfJ1jWfVlEtFeZ9fHSVSJZCvQ420OtAgJ8qYkMtShUFc7gqcv5cpQTrVh+4PdpA5VshWZiurvIe5+0m6rd16PV8yxMsI0= X-Gm-Message-State: AOJu0YxSNbf4Y04iYhJnEl3EL43sOtuw2/5UjyLavhcyUUEu7B8UTa9X hpumPO6zgfywIQA6dgOhyWbx4WYKRqNCW2z+eslkEPl609Mhcqdbodu4JZR6Z0ghU1AvC/IAqnN dTRoCqA== X-Google-Smtp-Source: AGHT+IFiaKeWftjlYDypGwGYdX+YIN1A5uSwmAuQjC00TFYkgW3S+YBZZ4Y/Pr7DJjydk0jmQ0Rw6pq2PkQl X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:274a:b0:e03:2f8e:9d81 with SMTP id 3f1490d57ef6-e041af3b67amr54130276.0.1720807934990; Fri, 12 Jul 2024 11:12:14 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:43 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-3-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 02/27] perf s390-cpumsf: Remove unused struct From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111216_513653_4FFFD94F X-CRM114-Status: GOOD ( 10.55 ) 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 --- 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 Fri Jul 12 18:10:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732138 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 22A17C3DA45 for ; Fri, 12 Jul 2024 18:13: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=7irtahaUgZZ2kadtdQTAIVJwXhey7Hso05gQMGn03JQ=; b=eDDCMGnGss+UTqkLMI8YnFHncv Iqrj4P38abd2z7GuHyXaxJrx1xcNUL5qmC2OAODQrwmyrjIqfuOjuoTbFWakyEqesHx+IG53CB60R Xa6ndzDqY+s5ANSxb06xcLqrJLu7nxwh7/3fob+t45B8MzuV0gQ28/M9fU7E8w8TsrpCa1eiVkEU8 yqcCVglzmW18WwS0a5UxkFBGqoS5TuUlsp9JMGZvmXhyT6NRMKhogsf2yIdhlNLgMyDLh4rqG0PEA Y36CuW28ZzL5XfKG3Pi83sl747izbKTynrlfqs3sMeuHTSEdwic4DfAp11qzDVHFQx7qFCxNnDzLG 8ea9rBtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKls-00000000vpo-2tlB; Fri, 12 Jul 2024 18:13:28 +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 1sSKkn-00000000vEY-0wqs for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:24 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6502e4c5aafso27173967b3.1 for ; Fri, 12 Jul 2024 11:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807940; x=1721412740; darn=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=7irtahaUgZZ2kadtdQTAIVJwXhey7Hso05gQMGn03JQ=; b=aPkMw1vtSqeXsC52WBVHKC134LLR05J4+C8qEjZMBrVhhFgECnffEb+ElMu3VV236r ZS2lHS5zxzaOZDVkRfoAmR3qgBKlTMMy2I6XYEwQVB0JlF731lfGnjj7ysMkqRPiS5w/ aAjmjWqPh73zl2qd3fgaUcnhWsdpefq6mcSe5RH7aGBwAiTezrMirLEnWtRml8kC31Yj nY46oA/Vf3aMASTHBbPtVt0VD7jN+yGINo1PuU90vM9DCnPe1TG4ogoQW1bBfc/26n9A tJ0rQCQThnAP25N3ims6dv1ztN0cTqJZEkyNDYUsxphcE8t1bFUDajC9/Tv5Z2x4oqD8 TBzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807940; x=1721412740; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7irtahaUgZZ2kadtdQTAIVJwXhey7Hso05gQMGn03JQ=; b=PZuw8yPrYUpRFTVHNrDf11k4lQlYZyXMjWL5ALtUkx+X7jcZsTqkvk2BlXUhDFrJFV tb+9sC5KAMbt8X9XGwFyV/Nw1vv8/C+HD+HKTCEjrfceN2EeSlfgRXbar7eSL+7DgEUn S5XNIBPFD6C57i8J0qEMIaa71kyQpopk8rec+gPcMkZsvwKmSK709eiBaNknc6oifjZT 5LqSZs2Em55OVtw44cX0fhDKGqpFXAViT1QMtWwqStCV8uAOFpd3Jzb4MvV59v1sctZ1 uhl/WTWBeNWE51uEsAz72um3eK6TlDH0vgVKhFjtjRMsKnwa+VqtG3H3puXXDGY0PY26 7KVQ== X-Forwarded-Encrypted: i=1; AJvYcCUnoxp0/o2+Mx1OAHq9cwK/JD3coNkCYhveDO7InfD9B36DNsf+R8hpipnYL5uMP/cShYFYmyV1pJZ3+tTdgLU3q6kv92Mst/gd+ZlH8i45R5pKoDw= X-Gm-Message-State: AOJu0YyM70boY/33LdHGlJk+PE1h/bkMAKnfxBOSFFDUj5JArmh8Oi95 DiTaN+FL/oY9oojYoKjwGZvwQKZiwufGdyYPn6O1akvXhDRcovi6dJW1w5UH8dhnRqlYH6s+x1d vhUidEQ== X-Google-Smtp-Source: AGHT+IEy+F9KU38JefBPwZOtKdQLbKALuCGzUqHQUM3gdJAAlu2RdV1w0fDalFLhNImrlG4cgHl3Dhp9FWi9 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a81:d80a:0:b0:651:2eea:4dfe with SMTP id 00721157ae682-65deffe9b93mr146937b3.0.1720807939878; Fri, 12 Jul 2024 11:12:19 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:45 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-5-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 04/27] perf tool: Move fill defaults into tool.c From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111221_364137_E96E578B X-CRM114-Status: GOOD ( 19.87 ) 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 --- 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 Fri Jul 12 18:10:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732139 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 034B6C3DA45 for ; Fri, 12 Jul 2024 18:13:56 +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=PUbNGHbJusTOA2CgJOpkojrr3Ag9eG/HXr7a91E5F44=; b=4eciT8GRlmiCFundIdlcJkNsAq Vxyz+xls+QlVsBVuBRJ1YEmZqbAQD2Y2u+yvNnW+zWajcIUP+aUwJWYXFq9tMEZHpI3KBC7gEtKLn NGaVwznIAt8hRZqNEVkIyv5Cygb9u1GIcIg/fF98wzI9m8NFOOlHVg8BolEn0HLWNhmxQs0Exzu+o /3fZoB+bhO1Z/THurAPoDRu/GeqyufYseJWaWyfChUAM0c9NzTqmXTUoE3hfwzB6F0eszu1zi7+0W YTtYspr3ngSeVLmoGHvDaWaCJEC6QhtvF96NN8JQ4ejG2CRfpLOwca87VW3fpkt4xCg+A9XQGvCrm ZqNKnazA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKm9-00000000vwD-3t26; Fri, 12 Jul 2024 18:13:46 +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 1sSKkp-00000000vEy-3ZbM for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:26 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-65ef46e8451so9258877b3.0 for ; Fri, 12 Jul 2024 11:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807942; x=1721412742; darn=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=PUbNGHbJusTOA2CgJOpkojrr3Ag9eG/HXr7a91E5F44=; b=G3ercJ37C1/HKciq7D107r3aD4RQP+Nh4g0bZDmWx2A4vDr6QDZ/ZKp3vS9I+sjSvt U0kHoobP5s/yQnEqcmlswPaZsYPHoK0urKJj/AnRF3wQfd2xGFRa3Dw145/9225BO++X YN4tMR0rJLoHgF+aE6Xm2CTVdSNCPxi0TXuavZkzzdzs8M7np5tjVfIur89Ilgj9cpMH rCFHtBNi9oJHp8FFdqE5yk4Q7pugx3J22fFSuNFm1eXWU9vrP3MzOaUD4Xc+glLMzEXX HMddRxKqDJ+lKp59MqbJNA/DUs07ComtFhwStMlUjoP1akvoFfKcpIyyp/qmHXEH8Dfo rRKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807942; x=1721412742; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PUbNGHbJusTOA2CgJOpkojrr3Ag9eG/HXr7a91E5F44=; b=Vvg/xJRqH0k9KkUzAcJzfX0khDrUeNZCvr/WBDW5jV4uRYay0oP0JWk0dAodQ9no05 SNbFvn5KpQGheynF2V7olVwb31RlgQ7Fe7Fws8frtNIIq7kVrLt3npW7m7PjMoh5ZGD5 r4V4EvMgpj//VPMSinHRFz4f0Bj6JnzLPpwMrunV10p06zi72avTd1UsCumeLTlAeYQV KeZgJO0JG3JItFRLhjhmRTeAIhjD2gE9pXHShfh0AcWhhIhaegLRrLjlI9ovYrm1BfAX MCIBzaGOMEO78SbtVemvSUTAI9LfDUIKM37J4nOLJKyc4gwrIGCsR4mWwnqcbU6vXgC3 tZbA== X-Forwarded-Encrypted: i=1; AJvYcCUlLdIOo1gtXXARJjYe7c8tf/7R7gsFGx5vQNZwJ/k2r5ymVkrjaJVfxk2pxcsG/lqpMsmyoggkRrQU3HXTBE+PpQOOmDbgKVAqvaXgYm1riVOer34= X-Gm-Message-State: AOJu0Ywwd7RN72VL6rFw1Vml8MjmMlCVBsf0Qy54XAtpsxjx8v1qbh5Q PSTBPzwB+p97xrnBKo7BTcDu70xkwZVrzY8cTkPwwuYN3a54d08Rr0aLuiJ2Mad638zQfCHAWNN RRxAukA== X-Google-Smtp-Source: AGHT+IEn4aL7gAe/A8RlgnAdU+tNwlNq+Sm/494mGsbEklzNlhOPqAJr26SyTCQFnLjLoMPuNqG7qpfWvCca X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:2b0d:b0:dda:d7cf:5c2c with SMTP id 3f1490d57ef6-e041b17798cmr23897276.13.1720807942024; Fri, 12 Jul 2024 11:12:22 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:46 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-6-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 05/27] perf tool: Add perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111224_022319_79071B46 X-CRM114-Status: GOOD ( 12.42 ) 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 --- 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 Fri Jul 12 18:10:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732140 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 E48D0C3DA45 for ; Fri, 12 Jul 2024 18:14:13 +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=yTWyT8gKTKays8rE64DnYrzhErijM5o6wos0PD63SLQ=; b=4uF3fJ1oPpHUdhgp/neCYUEs32 HQmhT03af4E5HsszfTZLyVejqBgAWPcV201yaZlVZPsyW5RRCXqbwsbHIhODbgwbfjwsQFDPw/ux9 LUxstpPXJJuDLzZ2cqs+xQ4VWgNkdm6Bu+XoUDojs08cmKJnWHESVQjnd8q5c+/nOw3ES9HtGLshR Pt4i1EEhqIg5B6Ns/xsaTk23rH2M2YNhvnzGMEJIHntKd81Lzk7JbycYBuaIbVfU+3rbXWZstsWzY YtromVX0whWDCacT3PWtMrxtHs+7jJ4ncXiD5PzFYwjLAW5BVh1/LABIqGt2F0RJRIwZkIv/gy+J9 B1GP4vrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKmQ-00000000w3P-1FOY; Fri, 12 Jul 2024 18:14:02 +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 1sSKkr-00000000vGH-2m7q for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:27 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e03a694ba5aso3599191276.3 for ; Fri, 12 Jul 2024 11:12:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807944; x=1721412744; darn=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=yTWyT8gKTKays8rE64DnYrzhErijM5o6wos0PD63SLQ=; b=Nej1aWEPcVRIVZS0EgQPoZpsySGTeZZBzuSIKMEf0seVPa4jpTY7tmEeMmWjEhBrww 0+/vGaOoWLHug4FVxqz+WPPL3j1/XNna+iU/0DsyaWhCGb2M+8VzYmtpl/6pavf8ZfW4 hIqmAPSd41T1W+4J/Aj9Bni2mh2BWh/zvZMF/WNXkvsJcmHr7HX4TWcj5346KF1MPA+G 1rWGrA+v7BmZWZC09rQRQyupAfEXUNQZjl7V2RfBnyjdEN989BZVgrGbZjEZThDvrH7a NsojKcryixPHIiY7nNnoH6DsGBaCbFeBKAgXdd+xUClLv8qLdKfxlfcbZr5LXSUPygdn MZJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807944; x=1721412744; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yTWyT8gKTKays8rE64DnYrzhErijM5o6wos0PD63SLQ=; b=pBgom7x45+ogAo9yXkbTNc7pKg1XX2PV2+NVJ3JNFgbcjk3qkiqp8llfDX6hZxeI3M tnTAFQQpfc9er25w1sfOvD+efKVGIo8ElVtoLZyz7OypkKQ8Yct+jbcQsn3cTbJCbSvg ut15wg4QPxY9pul4GyuWL+nbw0Omum8DUt105QYc6fVN/VJPOAAXs8oUrrGRl1IDjPFW YFvXWdmikClIyeXQmV7zYRAVeevrBwnEFDFW+wtpReQFXkEM+clmqsAwQ1HgCPDsfFGH KH9z6XTBGkqStBNJ6Pkd1JlaP63lnv2BNnf5+gLhJ2eLbSzZb4Sps1B4jlNlaHzAVEMb 0pEg== X-Forwarded-Encrypted: i=1; AJvYcCVNh9niLPDhaotqLiPbIz4lwSzSKveR2TpC4VdKF7Ca0pqMJYbRW7yHl1mtbzQqcvhFKOsIkpfoQJUjZP6eFdKt/VZ3mC9oCVMEhoRkb42EukkcqMY= X-Gm-Message-State: AOJu0YzIA/zbSearf3A+sCg40+C3/XTIzhzBzMooIjRxLVBsva/N6drZ bPakE74Rn+8wuU7vgVNjTA9M9y7gHKz9NfphnuxQKm+0icSCnS7HuYc2SINJdnLTfkuN2s8atD8 /3xiAQQ== X-Google-Smtp-Source: AGHT+IFDEg4qCvDKsL+VVqYz1OMCn926w9P2XUU2yFncmeWDbh5Ial6YC4Tg3xMQVgD4UPTtY6N8u5MhM92P X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:100d:b0:dfa:b47e:b99f with SMTP id 3f1490d57ef6-e041b0314afmr26058276.2.1720807944323; Fri, 12 Jul 2024 11:12:24 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:47 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-7-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 06/27] perf kmem: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111225_802031_45F8D3F7 X-CRM114-Status: GOOD ( 15.00 ) 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 --- 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 Fri Jul 12 18:10:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732141 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 1890DC3DA45 for ; Fri, 12 Jul 2024 18:14:29 +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=FzYClsD3sREquZ0ApOheKgsIb1ZvzAHTtY7Hmf1CzXE=; b=qL0DMyrkL/zBIvljRgGI4BKtb9 VQ/3jNkUOkr98R6QzGNrmBzJ4YFMvhagTK3YaDVKrwleAFwDRVeMlZGyX0PU9KAHvVaGKtiI7UgEd J3nv3krTUea3o4p2zhf7q/5ku979QAAh20HCVbmXQeAnd2oGVE0MKg4wdDzMKryEp+8UXCz7soZCY 5fK4aztqHVFVUNNuleMYbC1yDW58mlebw2IPAGWQ1AHadxht8d/3FpPn7YTOoISrsGHpePOCgQwQO ooFgVq5JquDg7geOeMVQioTEhipEuyDhxqZC9+EZ8Jx8cUjFtJ8aq5ZtD2hAXPq/II3wCi/2xDVvh kAjpEV+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKmg-00000000wAI-2AEb; Fri, 12 Jul 2024 18:14:18 +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 1sSKkt-00000000vHT-2RTq for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:28 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6533680c788so40090687b3.1 for ; Fri, 12 Jul 2024 11:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807946; x=1721412746; darn=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=FzYClsD3sREquZ0ApOheKgsIb1ZvzAHTtY7Hmf1CzXE=; b=GVeEKMLQqy1wA4cfEDfh+ZHPaywbN3ZwkMSxIvbCZeAiBrkyG8XPIUy+OcWLYzgGQ2 8e0T7f5WeGCSayEAT7nd2ZRK1as7WU2zsnhSpdwnALoR5Bnu+mMpt1zLxDfQRARwdw9C r04pp7lXvUoOiV9VR3QycjtBcZxWzkjKPuKWiT8yVSBIFBFdzTMBo4k/Bi//55p4wLOG H5Hirzyo3iK7YiqtlFLSXRwj8o0zDho1PnsEw3LEa+Al5cX2fRoNOTXbz4ltseF07RQW 7hAkMhkL47UR/ClZlliQandVQmcWg4jjDK+oxB13dQVdYlXq/C4+NClFDF+h0qaV5jO6 sEnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807946; x=1721412746; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FzYClsD3sREquZ0ApOheKgsIb1ZvzAHTtY7Hmf1CzXE=; b=RLmcUSUGNwBTMaOdC8muPRZqrE7Uptn3ad0+qGYBpBL6i2AkrQLmzFUj0Ol57N24+Q FsuR9noBhZrBhAHAOdFAU0JMQ1GgBKsciztN9RIKjklk/C3///8oJNtLnl8ar7BQtkj+ S0pizEK8QqtSkFPcWREmv12QgGPtQQXGUnjumCnOfo7J5kJNxBqDxdcijD9gm6Z18uUo 0EpG5H66QnaDGTD2fPyPxT6XdW1YCCa0astOEUU/rkKCzIILmZq0RDhMPjQuZfvsKyaJ KfVhePoAYA3e00IFYmgIxatddlwBtZEsOcAnOjenMxJRla6V0Lo07VlUXEKPd/FghKat VU8A== X-Forwarded-Encrypted: i=1; AJvYcCUWoYl7XlQdZ48AbeCyqvdVbT81TXkq05Aj6CFfQtJlVFNHe2wwORoaoA2tk8PMxS2JZC8noD4CiEL1g5fVpA0wSnswOQhIpPYo3trEvudlLnXNLiI= X-Gm-Message-State: AOJu0Yz0ulm+jbyP0WDW8o4C3oQyyz/brqDeE88N0TXAyCwwu4sMZq6A yy2n97/tMl0Ziz3qpQINq3lYyR4I4tj6HSpis7phKmqCFFk5Fk6I/rzoSIarK/BwcM7/eY7TMLb D3rJfGw== X-Google-Smtp-Source: AGHT+IGu9ERSnkB72Njm49McR9BnBORB8petqywRDFaMNRJA5XXoPxz9Swd7cbx9vSO/F5mT3cZKr+TqR1MJ X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:f11:b0:64a:bd29:c5cf with SMTP id 00721157ae682-658ee790ee4mr1592817b3.1.1720807946360; Fri, 12 Jul 2024 11:12:26 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:48 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-8-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 07/27] perf buildid-list: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111227_656308_82D4BBA7 X-CRM114-Status: GOOD ( 17.43 ) 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 --- 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 Fri Jul 12 18:10:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732142 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 2E9E4C2BD09 for ; Fri, 12 Jul 2024 18:14:48 +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=byfF1KS0n4MzwFOMTsFSRoLAA/Zhxt2Mi8AKEzVn+O0=; b=yyjDZMs1vYtwUloqaBFnrfHMVb 7L2aF8O450YNWD3U47XU8btn48l6Uqv25UUKwYQ+BOyQwshgIejTZMLt16ums+8Vf4mEqpdohcwLo x05BbENT84y1WJgnC6D3fixw/uJ0Z8r+8cFpGJJpobDuVyTHx4jD6hj2umVgX7UZFEgJsjVdI/off WtNRtr3qxK/ggHE1o2FYO0n3gVUs0zU55Sy42HuCuBsXrZmRprCBziyJmimwn5Ljh5T1tnTYE4w6Z HB3aElhemsVgmChCr+KHQhCNkrOYinvyoxEH8n5dRVOKnrMg+kUyvSfAkkT1lj2UlRjFCS4lnQs0G Op6gDQIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKmx-00000000wH6-3EGr; Fri, 12 Jul 2024 18:14:35 +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 1sSKkw-00000000vIx-0Ofc for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:31 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e039fe0346eso4189855276.1 for ; Fri, 12 Jul 2024 11:12:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807948; x=1721412748; darn=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=byfF1KS0n4MzwFOMTsFSRoLAA/Zhxt2Mi8AKEzVn+O0=; b=Oka2O9WqZbUWZFVXS/BVPQhOAx+njpEg2nP7Oz8ZBWH9iVF4xN8EI3aC5NMYRdchp/ otcGUgo8PgUZoI7NsootiPI8o1ADormQMrUhPueFCoC7mwOlSE1NM4w1/McxjNHVhYQU 9aVYO2A2jTXfVQna9X7BWQa8EKgJ9+Kk7RKtF0/jz+F0YGHmGaaWpiyPlqdfxACrqBxi Izh2QUD67UGhWHH2UiWDs7jZw6JeB9qki6MdZw8dVQzMRFj4htCv+qkLVJxD4VTLqCDO Lw36ZuoNOdPyvOD1JuCgMmgUBX5/W+jABTA6tJVPmQw+PgM8FfMgwL2k374/MjmTRpWn lQhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807948; x=1721412748; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=byfF1KS0n4MzwFOMTsFSRoLAA/Zhxt2Mi8AKEzVn+O0=; b=By5YRwvt+FoKD51Cr0WhqpCTdrByFmvMj8YyGsIuxdmKiKMCk2M5rf7Gno5nrb8DwU EQhtpvQHQchWpQTfYa6p/c90nYDUi3Lrv0QDk+HvRaFnTTf1wabrTDKXQqiziupMCuDq EAZ9jA6M43EZomVLD53yFHARxo18bEVPG5aqABIxjiKs1ftjVsZ9PVSEBGhU+n4mnqIB 5m/5SnsU79aNOrzdgcZ1AyiA5RfaOGQmfReLHEynkgj/LIycT8vMhNBNxuMxUYo4CN2d OZpTd3qX2zWjIeMrYSThGd34gmLB9X3DyCFIo7pJGUXmhnL1Nbiqd6OXJ8PtOMgL6V5g +sOg== X-Forwarded-Encrypted: i=1; AJvYcCURqf1GbXwTByW5kA7wAqQqy7pLoPaYJx8XCdMIkaKRR+QTOIfAFzTCpXekt4r0OxuT2eePG1q7k2ZwizgXSZ3IF2Kj1HbHsxrAob3hC+32//Sz/+I= X-Gm-Message-State: AOJu0YxgbYCPpiPQrOoo/munxP784WyS4JEBiSBzcA6JtGDrLYSdxvE3 Lt7yMlE8e1Ts7HPPRtQT4p9s30Fn/f8SDZxfJ48Q2QN+Qempk4cDfFUICzTMe5vCayoNn5a5y3M +8CrSUg== X-Google-Smtp-Source: AGHT+IEDxd6QeNUvZWRQqBsrbT8Osq0gxiaqUBWAnKcNrHvP+zbFleqnJBw9O4ojwhJ+vbzxebyogc6l9y+y X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:228e:b0:e02:c06f:1db8 with SMTP id 3f1490d57ef6-e041b051473mr24667276.4.1720807948405; Fri, 12 Jul 2024 11:12:28 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:49 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-9-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 08/27] perf kvm: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111230_143380_959A4B00 X-CRM114-Status: GOOD ( 13.02 ) 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 --- 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 Fri Jul 12 18:10:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732143 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 92C3DC2BD09 for ; Fri, 12 Jul 2024 18:15: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=jf/366lvU4AUPtbGBpn9zhF7c/C+EcohgCe44YuCQ7Y=; b=mJF6xEnO0+Jg+ZGWOcrC55xBdc g4CDzeIeENhGbcZ+x5J8Qz2B1TZAENg200/Z1jb5dPfAV6I2FKn5J6HLGOXlSd1EMnybCj7gxslV9 FvOPoaEBwxKJ9FVF9oa0U+pQpBcWGmpORy1zEYiLZ8A4TFYuuK9HahaEUJfGq8pVp6U73+bwOGS6E uzSrWr+73njWYYVLlbkHb1tLlY0qjIw9GwP6P+Hse6db9A9BR8JaFc2IIC1XE/EVY1yhdm9TpjHtg jC6gu0JfuhhU4WZWg9nrkPqNJpb/90gqjCP9TDKdW3S+U8XA1CZHDSVGDbqzj5q/l7x4E92BUxTFn 4XUVW8Ow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKnE-00000000wNv-293x; Fri, 12 Jul 2024 18:14:52 +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 1sSKky-00000000vK0-0Jjc for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:33 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-65a14a9241bso38192947b3.0 for ; Fri, 12 Jul 2024 11:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807951; x=1721412751; 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=jf/366lvU4AUPtbGBpn9zhF7c/C+EcohgCe44YuCQ7Y=; b=uMec4uHiwkBeDiu6PJa9mjmKwZXxN5C0RFDLw+cnQjpoHkP9yn7V5CHRw1TDYbYBnZ /TVvBdFPQEMPnJkAv30ambHP+z3IR34sQsOI40Ixt8ZDHdq5DiMEqEO2iXd3ZBU9MtVa /wg9F+XrI8sQZLZgFmB0I/uLQxvS28NlXkhGltXHWPKfWyy/TU//4l7qEhCDThye77fd NHbRyHwH4Uzk3MCURD3fNeGOb9AeHnNUiJPG6c/QEIPOsfosoJbLIkTiNMpA6r7wKrYF kU2OZXBeSg5hOR5BMt97ZxBPYkGTLhcAgdz/qS6wl3KrYQMzA/b3JhL5rbV0JViYgdiW 2u7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807951; x=1721412751; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jf/366lvU4AUPtbGBpn9zhF7c/C+EcohgCe44YuCQ7Y=; b=PG6bgCUgpJzQsJzxQD+zRG+X7k88YnjPoBOojPwmdMfEHaq2OEIV5s2VvbsY44etkv 0Yjr6KHAgMDCPAJQnIvRUHGg0xhd1Z6tG4nIwRpQ+N57oHmAeABSDwZeIxHxjalCR2i+ 7LFscIlvdFndLD23zHQB48yQtdizfiokc0sIYNilxCrpvUdC+9rHoPaJMqMxLMA/bG6R 5HNsqxGfvnuC6nRGWeKSJNRH0WXfV2/k+TFdWnaDsYLrIzWf23h0Dh5ZqqxG5VybN6qG UT5ab4AK9qAbTvQ5tEXrqYF0K9vKSIaUe2a/64J9/PWY1ZVUTDErVUWD0fstpwzp/b8N Fv6Q== X-Forwarded-Encrypted: i=1; AJvYcCWcqY9Z+3CCNwaA90o5Iv01xrT9qAisRpEiNFmEh1xHJdsp7hbl9FjA0t8MUwchEaDeHIr4KLBwnhCUlG3KiVvGw+OazXbZ5msjCjwfwvcylxg3lZU= X-Gm-Message-State: AOJu0YzjPmqQlhxLLhrb46GXWaQIsC0KUfiohXZ6H03/v+lEtxYC8OAe 6thuzrz1vGPe5LfV6rYhpboLjFn8z8RGMqZqsIWr+aHpBgEO+YLmJ9w34oqoUIx8FiZhUDBkdUe IYOxD1w== X-Google-Smtp-Source: AGHT+IFlsKuGpxVNyWoLObgwAYJDkigpd5ozGArlXoag4yrjnwDea6v3GSNUcs145Zpeoo6bG+3lCKfvRy4y X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:25c5:b0:62a:4932:68de with SMTP id 00721157ae682-658f06db413mr2068187b3.8.1720807950582; Fri, 12 Jul 2024 11:12:30 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:50 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-10-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 09/27] perf lock: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111232_129062_51D9AA38 X-CRM114-Status: GOOD ( 13.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 --- 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 Fri Jul 12 18:10:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732144 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 252FDC2BD09 for ; Fri, 12 Jul 2024 18:15: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=h8vxN+BliJztZySzkr/g5CS+2PgB0g7RSTmLzIMrgEM=; b=fw9BJdZINVNo35GpmeRUXT53Wd bEsktmURny/xbQ/vlBVNu5Tw77TKfFoeKy3DI80QGdwSBL2usxYyaF5TCOsacgyAyOsIsiT+FRHy/ /X/jdq89s6eTUeh5HRkbLCN0PMgQVUtPBYqIN6i6nQLQLvfA4GwBZpa3y8zO7yBpfV0IHhyzJ6B7U MEAY7qZKZNXxuWQkpiQ3WZbzZFVu+qjecq4dEOB2Fo9b0BiycxcdgHXrcUtXpNjtndkrtoeNmK7XS zjhvyXxkneHhDiO8lRhd8nmOWpPNwXKpXgNhtpqhYbmHu2abwYnon4EV5FEb9WR01b84KzQZ/H0Bo vPjBX16g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKnV-00000000wVE-1LaL; Fri, 12 Jul 2024 18:15:09 +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 1sSKkz-00000000vKl-48KS for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:35 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e02b5792baaso4277298276.2 for ; Fri, 12 Jul 2024 11:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807953; x=1721412753; darn=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=h8vxN+BliJztZySzkr/g5CS+2PgB0g7RSTmLzIMrgEM=; b=W24kOFsT68Wc6QkJiTfnPXkIszEUh+iZCsS90E6uxoq66AgdnlEwN3oTnZWUYMmIOm 8idtU03jaDiMbzM+g9d4fA5R14e80EDphPXpb4alvKsd+cbaz764rXfF5ZyQ2JCfkNmI qGB+ro++ndvnBVjyEQH0jAwiwNioJGv2CMTYwWmC0+LUnvofxpOruF5IQHHHNHEcKrjZ JLvsyuWBtTU61PlB7MZEDF/lUgJgTWzDRno3spD+0mX0vxpH2Jt6qnVZiqmY/nVS30bs s0P9cW6FUWu56bTe/EDLnJ7gr66HK96NTp7g6sc4qNeE3tM0cS+3rsXtM+knukaaAMkE G2ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807953; x=1721412753; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h8vxN+BliJztZySzkr/g5CS+2PgB0g7RSTmLzIMrgEM=; b=XhDiHpIPPA99BnZB3GWERrs+02Jhpiv1GljL7jce+N+X/P6Q3tNAPoFVSMrPB9TtLF CPETISGlY7Z8MYIkArodphQsEc4dQjRVmSyrp5kgAeFLZfoIIlVr0SnJJ0hpqppCLXHO cswtHcRMBZrb5/NdoIc5CDMquHkqKX3DbE8nYLBumGoy6aFcaz2De+8waHWrOi4CK4dw dWNdoST5+HIcXm4FpSGhZawURixTDcIaWPSRnqUFlKO62MNzcdY4MrVLLVGGHs3RU7c1 JciImnqaxmOr18sDNLwDk0Ocdvv+FveEZayfGcbVo2JUCyeoWDVMFMEsZfIgnyGZ/S0O U2vQ== X-Forwarded-Encrypted: i=1; AJvYcCVJmSA9manJJyOTp9Jd9GolPDV/WZtrFkSZiRTiwev8H1y99w2Zd5mkINzMBq9xKdB3pbKTS+3KUgpmbT9rLCAyNCGJ3ZFu0TSOPllz5I64phxK9+8= X-Gm-Message-State: AOJu0YwUS5IdCbWSBP08r4hfHKZnhQuDHCGWK25jUn1Z7Ci0MxJKiClC 28DUbn4QH2yH1sjvBCE3abnsGZ54iqEGpdV5uAczuCaDvhS0+ijMH/vmF63TNbE/1BBBRaZ1Kfo 7vtTv6Q== X-Google-Smtp-Source: AGHT+IFvEFbuuviGSmLFXUVSDoQ/Q3jbvrU0W1ZoOeFfj2ue4Hk0CIvrQDw/sTMW/RbAltKLHza9t11YT2eW X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:260d:b0:df7:9ac4:f1b2 with SMTP id 3f1490d57ef6-e041b04f0a6mr910569276.5.1720807952786; Fri, 12 Jul 2024 11:12:32 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:51 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-11-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 10/27] perf evlist: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111234_030451_E70BD056 X-CRM114-Status: GOOD ( 15.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 --- 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 Fri Jul 12 18:10:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732145 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 536EDC3DA45 for ; Fri, 12 Jul 2024 18:15:34 +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=W3N+sXEIdDW4FZ9MEavkeCx7Ak5mBAvz0H4sFCDbHeI=; b=LaDAWdxlpIGuRUzgaSlexUqeG8 KPHtvEZlafUuTBdBoomlSkQq18XltsGaj7FQc2HVGQcwEvmt5qHJO2R/3yBQjyhHKMPajgNc9ulDh Hh1yKkBvNM/IT5kAdfYePrzZGPRONJQZ0ZUUfwgMMfTru+ficYvJdZuuG7uOhih+INnotaXVSDxcg 87rAVvGfKGbSzaJ4tfTcpGE6YPSSwaDKEL3mmHJ8i2uHLSYdgUiOKTYZG43M8hOwTd4KmEHIpmnh/ qdDfJruaq2pazbibhnFzeqLeXQgR9fxzlyQ0lzNFOrvnRiHepRhn6OLgY/mDQcp1tt3rncQJhAVN3 LDq+A9fg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKnl-00000000wcW-1rGZ; Fri, 12 Jul 2024 18:15:25 +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 1sSKl2-00000000vLm-0U31 for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:37 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6502e4c5aafso27176657b3.1 for ; Fri, 12 Jul 2024 11:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807955; x=1721412755; darn=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=W3N+sXEIdDW4FZ9MEavkeCx7Ak5mBAvz0H4sFCDbHeI=; b=VBTqmwdTCtpV4mK+KEyZ70gG609aOHbX3bP02/c+3L7VERiVnEUnTsHimX7QY62D/7 ZzbwH0F23hosqN+SdXewunUYYjM+eWQCYqXzJ4EpWlfToce1i/kfQ9fFX4cSqGf7LR9k cMU+CBBfgJ99+Oo8W62ot9syrSa4NSUaHOd8gzSrufhYYcoreyWHG6wkU8Bjs04jFqQA lUEGNIvMYlP8664LLsDA1PyHlPV+dJwMrVgJN0e5KLN6U76GZE80v3jBZQFcC0rnoE1v P+2bMaJn6sT5FGeQa6WtywUOV5J2GQuLKXD239ylIXIkaeyCy8gD+1e/Ks7oAUdNsdrD fbmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807955; x=1721412755; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=W3N+sXEIdDW4FZ9MEavkeCx7Ak5mBAvz0H4sFCDbHeI=; b=Isu141KzcEHAXmZ8iZujDwpnWiQvlUk6uk99ICE5d6V8k03Smh+mYPAWrfjEcheCk0 tnY0DBERPXhgyV8O21Cu9dXJpp1iq2zsjZRw/Cva/AIMDgeJu8NcZDC2iNWV7G8z5aGy y+wwi5lV8W7hz8JLR5aoNdfKqmZ12nf3RWvk4PhEZN9gFP2u7I8msFYoi33jNcSQXLbU aLtifogU3k5+Sv8wvckKjkcsJyoDuZTh4Fwlas33/S2sURqa0WrnkSqn9QmocyF7lbH9 lKZjPWj+/XrNC7idLk1SeG3VcPX2afCBBuyO7pqZ4ltOjhV4BSsZzac5e6HTvWbV/CBK 9ejg== X-Forwarded-Encrypted: i=1; AJvYcCXyFvZSa27UstbmesV1KZ4p/deJdzno4oRuhSUKJOhq35rZLAubt9X2gS36qMYLDck96VyTWx+XKr08GbvNGTrcMUYESdBRFbAI3iRipQnFeWsUVUw= X-Gm-Message-State: AOJu0YwIuviJdwVfqNKnycoCCeRpE7PqJSAFZzRHf3YFQPXziRux26tH zNbMC5RoiipU3Nc9WSgdUktL+M3WIAiO0VPzt+P0fBDQ/1Np06qmI8vucS05+TMo1GdlR8vaIow vdtnDbQ== X-Google-Smtp-Source: AGHT+IExEZhqBBcIexchHpBnvFmTKUgMli03JoYZcn32JuoHYiPGuJJ58g8CD6QprTxwGaZs6P7o4XHXSCM9 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:dd3:b0:620:32ea:e1d4 with SMTP id 00721157ae682-65df661ceb7mr703737b3.0.1720807954828; Fri, 12 Jul 2024 11:12:34 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:52 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-12-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 11/27] perf record: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111236_189244_EBB81815 X-CRM114-Status: GOOD ( 16.23 ) 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 --- 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 Fri Jul 12 18:10:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732146 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 89757C3DA45 for ; Fri, 12 Jul 2024 18:15:55 +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=GLiukIuXpfj1RuwI+7tVJ3j4buaKUCfjcNd2gIIAnuE=; b=X4+qekawrqtDMLl2r4a/+vYKL7 dSi1Px2wCai2wmWfYDZkXiZ6rJutuHXvzO/4FYP1rYd+tKRMQLVXjunAVegh/qQQI/A6JWHoTBKaS ltlECGa6ckj1JbNs6XLeybr5/609AxlPwHi2D+1nOM85B7tZWdhfDd+hMBSfUEeSkIZsN3jRNkZ4M Z2VvSUuoS1LaXjkxiMg3wdaZzxaHuN32xguZGr2ftQKHQu6grVb14/1Zqdh/ncma3I1WphDzYmcCP vVQMrge9DY3ZMoB0KSFn5wUEnwI3EpTpf5sxwxOSGhIivBGAbb31xAoQQosPz/mV+HRRXHMH1pwsr MhF8rzrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKo2-00000000wk7-3Ak0; Fri, 12 Jul 2024 18:15:42 +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 1sSKl4-00000000vMT-2Zpm for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:40 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6524309be45so44284847b3.0 for ; Fri, 12 Jul 2024 11:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807957; x=1721412757; darn=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=GLiukIuXpfj1RuwI+7tVJ3j4buaKUCfjcNd2gIIAnuE=; b=mh7jWvB9QHMWc6mRIjSjo1/w/UqFABhl3otJqI3D/wMXR/BQSB1N2MOEJ7/ouXcelo AZJLLs2bBvujFLrZso25Nr/tEqUX1OH3zBsyzBX+yN2UAli/RCyhhwsoVATdSUEoJK9O NAOarpOHuNbX9EX8N0u0z8tB8XG9tNdS4wIBn/KOE9fm9w7fM2sKuEQLbhcnKvc+NYTi /nCnVWZMkbc7bwlv0mpuIX4oVMv83PaYpQId1vT8cv3tiFJfmLrcR0tCa4RbYGh1x+no ELOr7vFpb33cjzMoWpUgjv7gl270Erq/cUqcLRFznivC62xtLB/W4IPPzv23P8FVc+Mz zJCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807957; x=1721412757; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GLiukIuXpfj1RuwI+7tVJ3j4buaKUCfjcNd2gIIAnuE=; b=Wauubtt8i5kVkX46Q/UP1KZf/7y1srbJQvaKu5OS7iVcf6U3vQP0MaKgH59wyi+/Ta TjmN8Q03Cvdokb3cDoEmyN0SazZcGcLpae3ZERB6HGlH+rRN7voiMZScY1QnJQzHdS/0 i+dSjJycgyXlQPoXf/7J9NtehRm408e4aoyl0lUsUU9bENKAASyVo7VEgLWcr1n6bkgn 8ocBhfyQ3ifTY0C16ra82QrHxu2hwWeRUyxN4o41KUoz+V1xMgkzqhHat4Gh+CvqoUHY kSJqkHpNiwVW1i/cCWxu9snnbTZGo3Epa5O4eSqGp3zmQvoJkRWMWlhRy98p2d4u0unk TBgw== X-Forwarded-Encrypted: i=1; AJvYcCV13PaFKV2eAXXIj2lyl0qb3dyHRXZK6K2x7OinYdtQUCwMiv/0kXXLHCMXzSG7KV62V7BkB9vuPWE8NJqBbNGzQlSyeCJ/laiKe6KAl0eJrPvGrnU= X-Gm-Message-State: AOJu0Yw9zYiXK3tqE8wA3YZHwbjibOOb1eko3leVsnCrUWszDhLn+xDU vWzNXs59T7wnHFnz1aCnLbo8EwTM/xfNan72MlmPnj6P/ph++lzQDQhKrfN2WABD+ng7gNIlv2j EcdfRfA== X-Google-Smtp-Source: AGHT+IH4uAq+0GE3bX9Ncu3ZBlmhnrDD+38cgOfHCMtyr/CPZ8u/8k78H/BkrIM5m6XYB9naIU9QLIw6gVAU X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:660a:b0:64b:683f:795e with SMTP id 00721157ae682-658ee5a10abmr2551797b3.2.1720807957092; Fri, 12 Jul 2024 11:12:37 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:53 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-13-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 12/27] perf c2c: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111238_660132_6C8904CC X-CRM114-Status: GOOD ( 12.50 ) 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 --- 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 Fri Jul 12 18:10:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732147 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 261BBC3DA45 for ; Fri, 12 Jul 2024 18:16: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=BgJSCF9yLnG02WKUg8SfX7odmyVBKa2lGRMN+iopItY=; b=lqPqAyzA0qOkXz4teHeNl0xLrR X0E+E2axaVzK37+aj+JNcPtXQde09KXC46EmpRfJrPtsZSoc4U5VgUZ4hnwSRR6kzxhwRv7xELB5F 4ZwMCigAlrQgXXdwbfJgwtXP+k3rN5UZqw253+7mSw8w1W7iuCo6nJBpIFdJpTHNMRr0R+pXhzxGt Imz4Datj4LGIQeXOHs8qXpwWn4WVqwz/HFUPSOjnHHBhDDtiG0rnCC3vqKkK27A1XgUgbL7oH+0Sp kEoPnXEEZEhU/3JIqwhJlZaJsbkJ2DbCDpmsF7O/WUpEMvO9ydoRufRZIzTWIOthA9rP/LuBrbdfU A1FmzPIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKoI-00000000wqQ-1KOq; Fri, 12 Jul 2024 18:15: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 1sSKl6-00000000vOD-2iXP for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:42 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-65194ea3d4dso36987447b3.0 for ; Fri, 12 Jul 2024 11:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807959; x=1721412759; darn=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=BgJSCF9yLnG02WKUg8SfX7odmyVBKa2lGRMN+iopItY=; b=MACPEUz6QVI/VSAXmhTyg9U3H98c71KEKXw+9I7Ia3VwIjsKr73IPsX6kxfJpWp0pY xRIIg1r4p2kp4FqCoConVyCf4eLXr06Gqjk9uM/rQARzhr5ys0gZrtiz9dfH1LuaqqpG w2T7Df3coDZXC4aWBPtgU1464lhhAA1NVUxRMZz2kDqTmntlIn3D1V52Nzm18Nm41T77 +gzGquoBg+PKcH445BPoOF3QLJYLKgj55Q3rm3k6kHhWjPFLJlx/1leucbDTOWIOLyp0 b/gP2C2sDSLTpGrz0wq2qSwmbSoWhzNlAVBEv/2hdUZRCIlfnJvaAjQExNYCzrJ9RLd8 j0xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807959; x=1721412759; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BgJSCF9yLnG02WKUg8SfX7odmyVBKa2lGRMN+iopItY=; b=RHkjIWAT+ltZQIuSHDmf5Od9AP/zGcpi0BCnBIGL2IQ6IHRzRq7sg1sUoVR9P94P3A mEWAFVosHDtAL3HwhImtjDwAKfCZSRvkk5apVhM3m5CivpWudjTCCrBUHuDST140EUOr jQ8uiUiMmWO04FUU9ewGA9M+1SMxuNAgVfGgaHxHaojBppfpqphNc34bqXNsPnMvixvi +w5ulRu9LerDEtuFlnw8yzMVE5x8MAtH+0LzDNiyEIkGwyD2iKxKFi1a3qPPsgHlOuXv 6pHAu/TK2IkDWeqyf8h9CrJER0+o60iYlGsyT+BcT0hh+ZJD3KtecyDvNj9VseQAYIKO P4TQ== X-Forwarded-Encrypted: i=1; AJvYcCUQJSjuBr5UxdBddXnPNoGUpGSAnR45jt8UYFkFl5RW6DwsJ4Go38jcMGJYanaNh1vTpF+J4izxoBwrKVvNMdnt+dQms+4XQ0/hhI4QH50IJkZA5xc= X-Gm-Message-State: AOJu0Yyamt++bbVgB7syB0jJtuU4mGwE2bKzMAbgr1NGOmtmK9Vnv7Zj PlNqsJIaHfO0g487VjYR0KzJpaywT3ugDX0ITQVokBu8cpjKsXkAlDrghN0DGZPWvLuQ0sw4Vio G/YaFnQ== X-Google-Smtp-Source: AGHT+IGSRo1j+8MrlxjlP2j0amUvFCZ7I7KDAWRqN8yitAfuMgeL0LfUscnbxCScl9n5gTfoA9hXSuXoBhys X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:1002:b0:de4:654f:9ad0 with SMTP id 3f1490d57ef6-e041b058ccbmr26281276.6.1720807959082; Fri, 12 Jul 2024 11:12:39 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:54 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-14-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 13/27] perf script: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111240_771793_9B2C13F5 X-CRM114-Status: GOOD ( 13.83 ) 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 --- 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 Fri Jul 12 18:10:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732148 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 EE742C2BD09 for ; Fri, 12 Jul 2024 18:16:26 +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=+Ae5Vk3XcnDdaj5BKYKsQnIS/haF5dLJg944D3m7A54=; b=yvX1eaUKhTwX4E0J5T0EF/M6Ew Clf0cO3kxj3NJfjyxu/XnWL1+Li1Mk+fS0/2s7YNkUnj5oOwZ48WyQnDBHj00n7bFmuq9ExdWPI/g l+I/+lCVKzOJNpgRqpjxd/lI6AeERb4imOEdyT8KTpsM8xxElyiuoffD73O/DtAIaEdYLaMeO8oZQ 7XV8uauDg1k9POkLrcTw0ZfJWcEGG+CeykEiZSKEMZplqYQh6Qjtr/Jx+dXCDYo6Ri82WOadoZsHF vIrF+SJkvUzDkorbhaZzKE8YO38zXVl0HPPxyqsXrwLDp0T83d7U6sggp7nLkLzk0DE8HosclhFlA yBlzSJlg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKoY-00000000wyE-2HfP; Fri, 12 Jul 2024 18:16:14 +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 1sSKl8-00000000vPK-3cKj for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:44 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6501bac2d6aso25817687b3.0 for ; Fri, 12 Jul 2024 11:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807961; x=1721412761; darn=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=+Ae5Vk3XcnDdaj5BKYKsQnIS/haF5dLJg944D3m7A54=; b=c2TtcBV7nNO4OHXHxW3dl4r/wKvFR5hwZqqp6cG0BkhoRprM9vNpT3NhueuvtsZLZK hVyB9Oi+UqTAcvpz3EADaBFdU2M4Gv2c6asfcwP8J7qRyrqgVD5eSLlNoKc/tftgTD3I pn27aXiU5mX8zLkWeV/4uCGH+k/YiiAVyLSYj/cMY7l+smYmiuApQ6zvy3C19ZWpp3KS 8KwolMLZI1h9O12vYJ35nVM2LXG3U4fwLEY/e3CrFLAqEc0FN4ERn4Ldf/esl2fbQ7/+ RSywxIQTCe6Pdda92WMhetNMMZiGl6rXKwyvn2ypmlfp2KEGyAIofDWXWHNmP1Mh5Y4A c2Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807961; x=1721412761; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+Ae5Vk3XcnDdaj5BKYKsQnIS/haF5dLJg944D3m7A54=; b=WWnvlMDZmAcfBxZGn7l8SNa9YYnl01zdmHkDx5G56RSrtz8UqUl2WdtLxaU1/y+wjG xn1ZS2H2b3QT5OQtOGQN21C6JPPvbaRuIyoI71FOLJ/lQc1+UMqGodVWE/KxRQmtgmSP 9vNA8oJRENhGUhHUGtT9OloOenzeryyYi+3QFrCkRxwqgqwmtjqngzHAyvECdndQgqUK zLpXXRJJUzmZyvjismbSgh3/HY8WVVW6a3NV6YpbkjJcaBUepOmXjwn8W4/uL16Z87LY Wtxzg0XUmk58i9fQ2EF5dki4hCdV0nACilWDq+DJ1/lSoLDXDEIG6j8DuKIlj1PKrJs6 ieTw== X-Forwarded-Encrypted: i=1; AJvYcCV9rhjHw4lrpWOO0/cVLn4wYwlkf36XersP0gubhhpHB+cb4WRWMmjEyq55RFaytFNWJuJnUiOcbiR4IpmNVjTZeFxxcASrbT/rFxcApEUALjUojqo= X-Gm-Message-State: AOJu0YzZmpuBtwGeZ41rvn/9HujShev8bBL+VJObvIg1E0xcHm5QfzN1 cM/wPfodwZIdLa9sQJJo8mqqMbaPnMN1qg5ma54VLSKlaDLeHHShgjMv2khhsI1upKeKU6yIszd /wTCPaw== X-Google-Smtp-Source: AGHT+IFS1r1FmLnw95nK6fekqupiE/8fso8FKO9OPR/6xFjZmjb3YizoL3Mqh3+zh+gKZgF8dAs4daXgaaxI X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a81:4404:0:b0:63c:7fa:86a7 with SMTP id 00721157ae682-65df4ae7d19mr124097b3.3.1720807961168; Fri, 12 Jul 2024 11:12:41 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:55 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-15-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 14/27] perf inject: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111242_928142_B9D0B1C0 X-CRM114-Status: GOOD ( 15.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 --- 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 Fri Jul 12 18:10:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732149 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 191B9C3DA45 for ; Fri, 12 Jul 2024 18:16:41 +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=QTSkE2wJ/0ArGbZAlv+dCStory8B9jtqpGvumW8ARXs=; b=TnSfDz0bcXgkGgCYDrruCSum1C MaAv0A5MDWZtaurR/ViABFtBGaqkq2yyLWlhLrBwIuTG6Rwz6UAwdeNdafWvgkh709NtsHzvI0m4H XcxZDnFWraccVcMpepxeZn2yr0ACI1Ggx4zC+u5e0GZOJ/rrjwZGiB/iiwcqJL+cmoYqQMVbxWHCN jUxD+tKNylxQYCeHuUjJ3O5SFIV4fylNIQ/bFlZKLhTB/AiROiJQtdT4EK/HYP/mbefA1/5kWc3fX rHzDIJXJuNNMVrOa/+couHE4CAXc8+RLbtmE1izXblq7lLFEQDjyAdfApdDKeTLWF6TQVAg+Vzef8 KY16rNAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKop-00000000x5q-3amU; Fri, 12 Jul 2024 18:16:31 +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 1sSKlB-00000000vRI-0670 for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:46 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-64c3f08ca52so34520307b3.3 for ; Fri, 12 Jul 2024 11:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807963; x=1721412763; darn=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=QTSkE2wJ/0ArGbZAlv+dCStory8B9jtqpGvumW8ARXs=; b=CribENA+4l7TX5FIf2igA/w/nGCuKnsTmv1kuTPjxxPOWXjaPUst5BBMesnIkcQ7Mp iuSC8fKr0CcAtsbvdUam3GdD82pPSgSxf/eWhdMEI17HhI6oDD+KijgwsauhF85ioIAk riUODnxxXZ011IzbghCdCRZRbkZJnFQjePg9+qI3o7zOLDyaPuZ2v/PM/z0xDdOV0GTI pWvyZEUGlpgjk1u76d1bnRjydRBfRCLhdjrf3a710fR2EBaWABpfek+zLVBdZzcd3PiY 0UTS3PMsaNtXeOsoVfMF3prvLd3iHNgFsWVml0oziQ5cohoFFzEHyS+mv6aY171+MyNZ 4HqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807963; x=1721412763; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QTSkE2wJ/0ArGbZAlv+dCStory8B9jtqpGvumW8ARXs=; b=e8hDlAGgaZ4IPQmQfsOuRne4LS51MRgqzUhZ9T8ii+a7duM0QiY98tu1KaiU7GzNmw vdZM//ClQRiKOsdnduF1Ymd+tqxpF7myg1RZA7cUxAWzEw3ZZwUW+Li11KPyuM5ufRU/ 0v81yQF5Z0IyWhuubRYV9uwl3F0Ut7bRVXG/kjmhSmsFUWJxFq3mXHGny71ssZJmVs6H wrTAS2c43EChJ8c4sBLL/Yb1vw/dlRKkUC3j6Ct8+rZK8i/7Xrhjt7hG4DR+DB9s8YV5 S+Cg9ic/LMrMnUQtj07KPyrrhBDsB65j+h9CRCQJLkJM1jxXE2N9Gdezj6Bfk4YQ+3b2 R41Q== X-Forwarded-Encrypted: i=1; AJvYcCXUb4aLeZcFoHbDNS7UgxaXtvaLRNjJYwXs10pbeSjz78XTuAYoZQiVjcFwcEaoB+Qa6XviiSiJULmRzbwFUfPEVTiyC1SrYYMAcSm5YV9rxbDgWtQ= X-Gm-Message-State: AOJu0YxV1js8UrnqgtwjdwkpKw/UZMFkPzTkZ6maSS0Xgl56N0mDyp8T cW2XcGwawjymb6eUYGsu6vwnhiwv7ZtzQjVXZI1Ia/n4YsahDlcSImSqEMZqEhcyiCGVGUiEzG5 8UyGfvw== X-Google-Smtp-Source: AGHT+IEblV+LCk1KeV8fImuRJAGAXrqJSnRd0Y2lGfb50NUegiQTWmLeQGEx7ynGu/qD8BUtkEWv8J60bYVx X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:d81:b0:64a:d9c2:42c1 with SMTP id 00721157ae682-658f000551fmr2773277b3.5.1720807963503; Fri, 12 Jul 2024 11:12:43 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:56 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-16-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 15/27] perf report: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111245_133255_53C32A6D X-CRM114-Status: GOOD ( 13.92 ) 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 --- 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 Fri Jul 12 18:10: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: 13732150 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 19607C3DA45 for ; Fri, 12 Jul 2024 18:17: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=GhKzAhRYOz6Ff/7gM3raH2p2+7D3XZwc5l/hw9g7Qeo=; b=sVIkO4SKvOmI6Q1+8GZXUggLBp obkurtv/dcBJ+bsEc0jWcdRtqzdrqOqgvW/wSS/7SCGW2EGuUrKcjXXN5ySqNO6uGCWpQQauM6nTw nXE5ABFYWr24acLkdQZHpHjIFqqV3grfp49VkRpLwA15Asd9cmVJu00huH2WZ/Z+3tzYuwCdnKZJe WztE8659PURhCbQ83lUeWFCIM7I9UeQLM8Ffx0wAds5z0xP1NTsMCe8/wkMDVujFzEXjIf/qjgXyD 8vPQfOL4Otvc0a9CBKTDrtBRuX9UE4xzgGlZW28JqYM3ZNVZtzlqCx01lpFArkriMPTB2E9aUDt3B Xr9WrXSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKp6-00000000xCj-0AfO; Fri, 12 Jul 2024 18:16: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 1sSKlD-00000000vSZ-0XhK for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:49 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e03a1ef4585so3999353276.3 for ; Fri, 12 Jul 2024 11:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807965; x=1721412765; darn=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=GhKzAhRYOz6Ff/7gM3raH2p2+7D3XZwc5l/hw9g7Qeo=; b=YTSNS2YUAtZx+hAH8qDAKucXFnyFlc92Z8Q+BapntTnLsaAYKJfZFU6D5QmmrjF8ko As5URYW7NkYXIKbq3cO1ioR2rV6oodhkSNyu59yk+t8r6Tb0SM26TV8bmmjtroAVvGsu 8EI+0AEIdEnWLoAkSqXr++UIsi0kQyHDNzubAs5RRpCpyJRGKuTgya6Q8z8PLsoxDH0W KTUBN748TZanCIrSkDJRp+0srezKlAbVzvad6PH16O7031WTWHwCCpitTx+3VhlErTox 4nhcUbZiWDLnZd0qgPfqnOBeJaN5RnmnD5aI/oWpWYBUbSPnney3MJVDdmz3nMaA+k/i zR4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807965; x=1721412765; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GhKzAhRYOz6Ff/7gM3raH2p2+7D3XZwc5l/hw9g7Qeo=; b=V4PA/Vh8xQjKEBi1JeIm0UojJ/ZbLtiiMsI6eG5Cemlo7a2D9UPh9ARs21Eycg34T3 NXQfb7oeZ90Z2F3VNI8pcutTiS3uSRuH0hCETQkV5ir+hwtDWxmS4z0pUBAUHtjrNd2d fDyrJF9NXT6eTWwvGzFR6Z+YfK2pDUIXBUAkRKXWQGs5DxrZIFVdbG+8gIz2LRk8Blfx cNIf0CRALimHNWJBbu3xZOxvVMzgGUn3/SnRrunEvqGytr1RPM4yeLN69M2qXvDzqVVB ftrAXakQj37an8ZnZErRFUoHoYGlQ03lFNvl+OFa1xgdBgCtzWZh0nCWETmZ2RiTLbxF hEjA== X-Forwarded-Encrypted: i=1; AJvYcCXSaL2khMqRkD1ZZLIvmVOtNaQnHFFsTNso4PwCu+xwM75z3btb5zwBLUNwx2I3a3hoN9uYU75AC4HDF31oZSkov/Q6GiAvSKD3dw2ub+w/RGHbMK4= X-Gm-Message-State: AOJu0YygELiB4oGVVXlplU0gEmeWKIA8Xo5XgyaPg0TyTwowqh7S/r3D qP+DOKgucBb1vFAsMWp+vlBC3uOM/W80cdpu9b0reIMSXOQWaRZXU/9gqUJKsnk9xua4o+wJzpv ZQoVmew== X-Google-Smtp-Source: AGHT+IFhYPk2jTBuMlhB8gOtTxMBnApQKnxVWvq+XTICOK0WnJmqAo1AkbwwG2wHV+rrMbesLDOHGcXiSffq X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:114b:b0:e05:74ca:70ce with SMTP id 3f1490d57ef6-e0574ca77fbmr459024276.4.1720807965562; Fri, 12 Jul 2024 11:12:45 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:57 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-17-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 16/27] perf stat: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111247_181223_C840BD13 X-CRM114-Status: GOOD ( 12.95 ) 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 --- 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 Fri Jul 12 18:10: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: 13732151 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 33C46C3DA4D for ; Fri, 12 Jul 2024 18:17: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=mHHBS2O6oNY6SeiT+OH+p80VI/Bl4EiQ8pJoP1UpZWA=; b=mUq6EIFBhQx+qVqaoh55TyzlN6 ryJCV3QCzrUahuKJHD5gm7kzt/JlFnYNoMXa/uX7haijzyO6peEAdJ2UFMFq6u9jD0dnGZEolhFqe Q5y/aVf96kk6TqvPkPn+FSiQxMVKIGBcNC01QYHQzDiUUzuGaYKlS5nimY+NN3HBwkyTgYtUfc0iV A1mRgYigbZXOrDmAS2tjv1nwDbBdCq+nYjKpeEbw92KgSBM2hYeHoeSWsT12cCUPuwynnA/kkh5i5 3+WZGkqPk+q1YU7hHJCnHtekGnSerY/XOsQ3yvI3kuPlFtzaj7+S25/94iVbZreuuS+BS8XGNtLbs o4fOU/nA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKpN-00000000xLM-2Noo; Fri, 12 Jul 2024 18:17:05 +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 1sSKlF-00000000vUQ-1APN for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:50 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e0335450936so4174646276.1 for ; Fri, 12 Jul 2024 11:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807967; x=1721412767; darn=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=mHHBS2O6oNY6SeiT+OH+p80VI/Bl4EiQ8pJoP1UpZWA=; b=ZanU+rJUMsPoxZCxe6IDQMdKqA9iW4JC1xkeXLIwMtAHF7/lB0ciBlvawiEBAeYjFn 2kXD4IRLl8AYchdEjRXYKFQKf4f0VbjjFKcBPwjlYOjdEp+KE5FAM8CGAZY5/YkL/Buc LIoNOaKkbx1fsSsdmQC0UsXiMwsJwcR2nStSzneSZrgpflyD6QZ69OLKdYL+sF7qTwbA SVmKiKdGeShGlSrNveXp1et4AdZV/J9om4BnImWamHcn/afH07IjxtvWHp4KApXR+q7H caD/fFB0dHt4ByhQ5nQ3+DH3MW436K3oHi+TnGVooS69MhJo3GlKOJ8+jXwZ5x6FeECz hq6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807967; x=1721412767; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mHHBS2O6oNY6SeiT+OH+p80VI/Bl4EiQ8pJoP1UpZWA=; b=pivMh8svCVgzYkbRjvaRuZM34Knr1UBZTybDY3cXVGPhIqvJmd7B9EjP+nW5ZALUkU HODC3oU/bJLrubn1/QNopR13Gm77hy3kCTzOQI5UTJXPdz8vHs3pxBAGpTkgoh3SOyJa Xay1XY5B8AM2el7SQIGVGBoi+KgYGSadPRrI1M6+jpX1RRi/rLA9xAPs/01dbe3ODtBt wNT+8ZuUyQH6kZf6Mo/WeNz9Ap+gQgs9zkz5Omjk/qQk0jMbipHRBIIookvAzIJ0KWE1 yo72yQ30//6JgzU/zRqiWq9oyKku+kVfDkEMO32BpDtk4TUX8Dm+qVGfS6d8tYT2MmUx dqSg== X-Forwarded-Encrypted: i=1; AJvYcCUPF71u9gfYmXxj9mAE0/P7n00LCOE67GmZ6T47b8W36G3HLEOmBt/EtP6OhFiifmttfr5C9z4/PLvR7b/ANBaN81F11LqOgLQO/gMoLsHnTWZFRt0= X-Gm-Message-State: AOJu0Yx1tDxAXz0P4fi06NnZU2CcfaOxAnZUG0EluxvnARy2CLUBNmuG 8arGVzr0Gh+HHRLAmlohwbS3fzVPVV9aTTD1RB7jmNZ9rDCghnZfDecWI7o16kkal1VKivWKXby bLSL+Lw== X-Google-Smtp-Source: AGHT+IHi0RESPy1M1p6v6upGm6fDMbixV6F9q5HB/w4IM/nxGzbjXT13DQBQQev04cZgDR3Ow3mnnlitBBVY X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:1002:b0:de4:654f:9ad0 with SMTP id 3f1490d57ef6-e041b058ccbmr26284276.6.1720807967661; Fri, 12 Jul 2024 11:12:47 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:58 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-18-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 17/27] perf annotate: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111249_345325_92C98DCD X-CRM114-Status: GOOD ( 13.41 ) 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 --- 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 Fri Jul 12 18:10:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13732152 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 65DEDC2BD09 for ; Fri, 12 Jul 2024 18:17:35 +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=ZfGB4qYIWwtakjvzGQZNS3+imagxPcgxRVJoCFymO4s=; b=VSxEh5ybQpAiPj2dvyvJUOjg7p VwjJdixESEITd2F+KXH/MnxHG4s07rh2e7zICc2TpkuwuDBrINSufTgS/IEcRJo7wxepMFN1yDE5Z m4xj8rQ4ZaRuhLk1pLb6CPnXQSTlBoscuMSHvnBrXwtsS8XdsozNvF0osXzuoR5ZwhNNWAsjxXYdT REvPp8ePILgJatRoOl8BF/eV5lKia6ygrA4ZEChckHwzPZ4BEkqO5gBXA701vKtk8WZ6zcHq5IdtC Pkz3wi4C0rFno7NweQp09b6ILMr+28jemcAqcHlVxxlTtvtOxpCllhzZRVIjGA3j/oMbifILJb6k1 W+92dCBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKpf-00000000xUt-1lIN; Fri, 12 Jul 2024 18:17:23 +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 1sSKlH-00000000vVX-0YFG for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:52 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-653306993a8so37564327b3.1 for ; Fri, 12 Jul 2024 11:12:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807970; x=1721412770; darn=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=ZfGB4qYIWwtakjvzGQZNS3+imagxPcgxRVJoCFymO4s=; b=1DmghxBYvLzTdXSwlaNJQ0CG00TATOBxwKvQBtKZW5gR1jCSqgjJ3UKic6PhQZMGUN OtK8p3Jz5bD2kgqwtCVPwEEKvU6Pd5+4gfQA4EkKZ0Sm9Yici9nGzP0seUpgfFPF1Gry MTm9gnC9McMVlANqnjRCb4sn0weP6WsWKmJLYTnBsEernt+Cp4xHxeyUci3tKpTEyGBi P26jnXzT3C0LFp5EduKj2EpG+SuFqhBJzb4cnz1kyhcOmU6dc+npU42jkX15B1nS4DF2 sLC8rBWvgt1VBrEINgACoLqm3VE0UUKV7Pt4Mei+B4aqNnBvVYq8xJ3n9guSZ16Dh88C aA9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807970; x=1721412770; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZfGB4qYIWwtakjvzGQZNS3+imagxPcgxRVJoCFymO4s=; b=aXnFogqUpNWkNCy5et4I+9A7CrWuz+SJhakEhRtSqHODkGyED7Yye/SqNGCafoeQjm 28ccDx8IR+v4fGKNPqX6ZIJ4SIS0ZZ3F3KYYC6pSu/G8KJV0l+TR8/GWZ+3FV6VwFBPr tz8nQq+aNX/TcekLtRKnd5mGjtHHHSYLoEMW7bYigHtIV1kQgOBnbMScMgjHzfuYa8Jk QYe2aeJ1x64dt2gdk06HkQ9t74GuJ5OIQlHCQYSmDtrhsrPTpic4p0pvYgGl//AkjcpL tMkaeGftdrmOwuAdZ4kASiZRdMY3+BZZMqk5Yc7U0fb99I19wpz0IJI+P7S0Yrm6cG8m NXYA== X-Forwarded-Encrypted: i=1; AJvYcCVZ7jly+Jd52qw/zS1tqhzPdrM259gzncLbN3Jg7j5+m7onSg31ThhIIAohEXPr0JFLYsHgLhbdWkvoGf7mwFJ4TqeJ6fDqiVaMMVihgtVbV6FZxhs= X-Gm-Message-State: AOJu0YxS5oUqbY+lralsiiG1U3XfiWbdGbHnZBvVRZ9peQJ/tKNseP/G Y0nUaKVjKBoxTTAiKDG1uQ90MEnUOpwDrxchgwQTqmUNoaXupt8NCyzAXXWclQsoynt0p92+aGt WQC9nYw== X-Google-Smtp-Source: AGHT+IGwm97iX/hGe03hY3o8dBT3RVSvlUNVeKVGrABZ6gQou1GSxK9awtmr+31vBv1Cj2NXc9MdjmjFPQQ1 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:fc4:b0:61b:e103:804d with SMTP id 00721157ae682-658ebbb801cmr734427b3.0.1720807969781; Fri, 12 Jul 2024 11:12:49 -0700 (PDT) Date: Fri, 12 Jul 2024 11:10:59 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-19-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 18/27] perf sched: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111251_197216_9141FB76 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 --- 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 Fri Jul 12 18:11: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: 13732153 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 A144BC3DA45 for ; Fri, 12 Jul 2024 18:17:48 +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=dI8yaROyMxBgkl/C6HStDZ1DbB4Rpu7ZnQVumFggSVU=; b=JIv1GmrVuSeJ6m9ERU6n4jWWWk 9euJGCSOQMynoB86MTA9HFG/j9wJLgLU3EL0JbjD/FplAlLZiggDdu8II98UZSuLN7z6YLI7WaSn9 u8dc8KTTNqiFTk34pnykWik5D1lte+Kv3RD4rBdXdlp9skBUiliWioQonD0yFTgG3SVHxDtvrnypK /K4fMG1IH3O3E3D1oX+5dSKxznczpWBoH5AUIgfz3og3SDYUYBBkOkrXNzZevJPsAkS6M6rvglSGd X6AB+uNN3i6/ungOsefWiQLH+xOnodu9PC+Wro9/8VccfytK3OXwh9rQrU6nhzCZTNzPN8Qoq7uTI fX42kGhw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKpv-00000000xby-39A2; Fri, 12 Jul 2024 18:17:39 +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 1sSKlJ-00000000vXB-36Zm for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:55 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dfa7a8147c3so4181799276.3 for ; Fri, 12 Jul 2024 11:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807972; x=1721412772; 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=dI8yaROyMxBgkl/C6HStDZ1DbB4Rpu7ZnQVumFggSVU=; b=CQmgPD04PdbBnYXOsKuJU8BABn1aUQu2FfBurhFrBYQzoPWFL3FWgS92QinwTgWsdb R3dXSBK7fRm/fd21MY4LLNA8xDcY6T9hS5HJRPWYpf/VoqWO78PHeeeuhCgOxwDKA5HF xkqcgE35a0pbJMEMPCE29P0EK4R32WbKtDfqN+3PZMlvlyWQ6vG27inGk4juojDlC16Q oXDgonxfFFj9B7IL/3YlFQhJJ3Gz2cjKRWjMPTI0RSOGqyGjw+9kjMhdQ7Hw27BVFG+D x2qK3409grAchV6gu5JPr8gYSh45UJAgzwUB/2fj0x8RavUPbfcIGelrLAh8eng052ep 0qJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807972; x=1721412772; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dI8yaROyMxBgkl/C6HStDZ1DbB4Rpu7ZnQVumFggSVU=; b=X9EcafHfOo6DpxXOA63ultvzz3FeJHNhcs8oqznoBKSnBW5DK+HfNPCwiuIWqJVacU 3hbUwiR9mH5kRXyHBwvwytPO43fs1XwqNR9lOKs/27CzJ/bOey9esAnPJYhJmjH0dI2+ IgPRVyY8JA/WdgBZmqg0CEn923ogbqxYJvtZvLTgw8CxhtC3fvhTb5+QdVOPzvyOWHmW IBUEb9DD9qiuhmtzN3waNVDqbTOiWRly3lWpwmhwmFj1KoBB23dtyXwgo4PbzsTL7DMl 5/60jJCOmxGPWHM9bAtK8h4uLZDXUgl5WOnFMxOoKEpToRsZq18iD8RplVgYG3WTC1E8 npRQ== X-Forwarded-Encrypted: i=1; AJvYcCW2eXDv4xdXXYkSNwJQI5SJD62AwcaVY7kk9fABhxFKVH9DFXQHsDx0tiCUJJ8L8st/br96E9+GYHOBBo8E9t0rXSmGS821siB+mreK7xmyO67jgmA= X-Gm-Message-State: AOJu0YwBIM5D/ZTZgUuAv2G6+Ialm6ZOvXa7QTj3Mc3Ny21CjSCVZBrf SqUKltIOLPZ70q4+TTZv7HHogpV9nm8CdjeyHmtXWzAzoOAFty7xVRQqX/irl534C7zTyG5262D 1HrPOTg== X-Google-Smtp-Source: AGHT+IEdjKOWNbH6lHnQ3hQD9ZpV0aONsOjoRMeD9l9g2HUs1hV6yUVjuLwzYNk5GAitqb5lFTEdkOp686G6 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:1146:b0:e03:6556:9fa1 with SMTP id 3f1490d57ef6-e041b11d3demr762464276.8.1720807972320; Fri, 12 Jul 2024 11:12:52 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:00 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-20-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 19/27] perf mem: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111253_792834_824077EE X-CRM114-Status: GOOD ( 13.41 ) 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 --- 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 Fri Jul 12 18:11: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: 13732154 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 0B60DC3DA45 for ; Fri, 12 Jul 2024 18:18: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=30wTiCp+NVIhDTuqUvYj4YUy4HL96R/Tpq22ji595AI=; b=JKok7qLExKP5A2HS2wQuNuaKN/ tXCejE3sxbMGEKcYYpaVAi5XETr7YQp27K/Qw4L72PC9Ieu62w7+cvMMPQFYVX1weuOrtuVQf1VAA gVp87un0mM/spCInNP5bLnXMfnqvVEi9G7Lo8aUSMyetJ77kQD0wqhoi/vP1cjwC9Mn+lDwoY/erw g05eNg945xMq0IQlx6r6Ihf8EKgCLKb0QONDCVgrVVtSjlzjI1tAz/vijQI2+tJP2OKkQ68CLigAG 0ZfeZpuuDhQgdWjjFrOE1q0Hw47RaFZbcyO4LBVOHGCCb8x0JRaBt4ByJmcjisUdFxIJzSnXbXSdE 88Cr6wKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKqB-00000000xjK-42jd; Fri, 12 Jul 2024 18:17: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 1sSKlL-00000000vYL-3y62 for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:57 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-652c6e92147so40538337b3.3 for ; Fri, 12 Jul 2024 11:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807974; x=1721412774; darn=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=30wTiCp+NVIhDTuqUvYj4YUy4HL96R/Tpq22ji595AI=; b=awaOTKY+iz1Os9RDhxuG0Lg0JEx+h7BP1t3jJLk7bMI8DFeAbj0xEWdSnRB/v/YCkS Xsxkzl8eqYxdwRy2QOsBQ7neTZJjr8t6vdsv8BmhNbizJd7noNU2rPXOZ+H2D77c+2RP k3u/+QPEc7DCVRlmp5UQ2V237FgLaFHwdD+WSJaewqAlxbNGBddsUrxwatr59Q6i2ILU pcIe+DY5qVHV1cwnM9yHOPcm7G9fwA32aWmvlJ7Q7y9iB/iACuf5fBqwZjkMjRRlf1M/ b6fBitGojh9UB/+3RGHu2dLLFK2dqMVIyzyr0VQol/8mE/tZox9AVHWMJhvhijApK6BD ZqRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807974; x=1721412774; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=30wTiCp+NVIhDTuqUvYj4YUy4HL96R/Tpq22ji595AI=; b=J/iOB9elD80fkg3Finy3pOp4A196Ff5X8hDiwvCQv9zv67GDyGUFeqQzuBWekr97F+ X82pC3g16IOlGB6pP9XLNz30Fy6NNOs98jC8l6qA+A8NLuGjvS/yR2jQ0vWB7j7P68cH LBYvCYEe3K45f/nL4FwKjC4loW4EFN4LyvozlK75C17g1f5lLh/AqyK7GIY2ZoTEhpLE TeUA49BV0BE2kW/R8xrcHRE5kYELzD0/DQu9aXGlv0VxnpesuTZbZFxPRBmF/3sWB0xa /Tj/CrTaPe9Ltno/NYs+JwNZzK7wqfAoOCr0JFKmy6gl1jhsB1qx2sfehtHQ7imt3Kce DKGg== X-Forwarded-Encrypted: i=1; AJvYcCV9BspJUEo4CVmJ8ARI8tF66zs7BibZZ8DRC6I9N8spVDiu33ePRFc210Qi3zByj54Cdkw3EBoYm68b9MhUeysv5Uh8Ay4Lp8YE3AV2TeQSIIdHl+g= X-Gm-Message-State: AOJu0YzqZjd+bZZwZNtrV6N+q+DfgpBlb31yfKiS8QRIvrcpFRNGMDVf csNyZDzETAPCHG0VFZD1UAgBhhXZ5WLcUGm8RoHU5aWG/nQmwgosWOk2669dnAM46PmdES5OkJu rj/ECJg== X-Google-Smtp-Source: AGHT+IGMtuukUah6sKAK0S8MwrL9axUruMElBWLKJaJXxc54g2LyjBNvkewqR7HlUBQ0L+JgA3dM6zS6xMnA X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:6404:b0:651:a724:dd0d with SMTP id 00721157ae682-658f06d9d6amr2241857b3.7.1720807974345; Fri, 12 Jul 2024 11:12:54 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:01 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-21-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 20/27] perf timechart: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111255_993512_6E7650C7 X-CRM114-Status: GOOD ( 13.43 ) 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 --- 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 Fri Jul 12 18:11: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: 13732155 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 6C98AC2BD09 for ; Fri, 12 Jul 2024 18:18: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=Yt616h8hRCivHeAdqJzIY5ztVTyVV8Crah5Wq3Zf1UM=; b=QJm0EbnzN9EO5/Vr8TviojnhGj jFbP+v9/Ljijq0VzDi77ppp5jLowXGfWq9AcNE+i3+Yo7DObiA7safST3e9Y0vt2dbtEGhN+0p24S xBTRchWKmXoZ5vhVJ2+hn2AI34VROdjkh055y514TNtEeaKUjuskMLa8aMMTbpLo+gDqOpSEmpQlU A390VusJ9QMBCyq5X1Jo9rSjSiOwcZ5TDTkUFBfRO9V/9mD8FMlieyau9fiMQQUEUwwdKLx7OFSe3 QzkBnOilF8DxO8UOo+XVRm+r1RKlPWWV/WBlr6MpbcMLgzZY9eWXCTj/OmjU1TVgOLTtjbTRModRo fL7naKsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKqS-00000000xql-0MrF; Fri, 12 Jul 2024 18:18:12 +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 1sSKlN-00000000vZL-2NGJ for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:12:59 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-650f5b28822so40228657b3.2 for ; Fri, 12 Jul 2024 11:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807976; x=1721412776; darn=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=Yt616h8hRCivHeAdqJzIY5ztVTyVV8Crah5Wq3Zf1UM=; b=AnKeFpdEbWWxzOCw6Ea+g5JNeCwmNyhjujAPSKudUpUUSYithUlHPiAAAyl1Dy8lr6 GSO4u0HsADi45TO4Dbzeo0BPxSpHOmSivEixpzi4v6K9C7EoeSIjOI4je1EK1cvSyFPZ LtdPNO3U0wWXS3kil3YWzkwCctyNodeJ93YM/Q8qjNN9kVQ015ezOh7l7in0NjOJVDW8 YKymcX+Nw4z7fZCdOx9x4xInqTSaRGAZxiMDPSVPO6T5UuMKSlPn5vckDPxK8r0dguY4 i+CjuYumn9trxCF4SuLh7X+a84oHu5SwPgFAy7EMq0LIp7CuzZj0WUIf+Qs2HczvYuLu Dkug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807976; x=1721412776; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Yt616h8hRCivHeAdqJzIY5ztVTyVV8Crah5Wq3Zf1UM=; b=xSXlzvJABpYPBYPk9dsx6VlmA6raTkv1uYKTwpWTnv1Ozgn0Lp6iNvw3DzMILLJqyc lDURaUvEOdZGsb0aW+MPJ/WYM8981w1k/DTidmdKemQXBReIHc2ckcb2DJDdBTM6gpda i+JiUqWYHzcAsg8Y7FLNHB0L6fYZdKNxyjNVxIgkimo5kSjnnWBnS85y6t/7FvTvhrJo A/k9tpnQMousQXJzN9pyoBNW2lQXVcw6/X0nJyk6HphBuP2+i4/b7qzU2XPSVj8bNGwQ DKN4gg21emm6C8t4YLzqR5wlHm84DrsskjdBUpf8GqeRjIVndhCys+Mf+MQrQGlqWk2d BnkQ== X-Forwarded-Encrypted: i=1; AJvYcCWY8mzrNWLOkGOIoscsU8yn854zhx9O6kRPyMRuFPW1NaqtaxA/7f9rKAtFqEUfZK/RtWvKWBhWphYTqVar8bsdQsMHf/gD8i9BpvMBq79x3/8v+sQ= X-Gm-Message-State: AOJu0YzQZL36u+V2hs1y8+aSLxETs4+agQ7+MT/tFRVg+39lpt0f68QH VUwjutmZpisI0Owsdu+0QsPM6bH9FgknQVyNTttknzp3PhM4WgqeCvOJ/fIS385h0/vLUve14Xy iqCE7QA== X-Google-Smtp-Source: AGHT+IEoiv7jL/sMkb1DG/QD598pjkLvo+odw5YGkLQIBl/s8wzmd3RFOvk+HEu5aaX3z2x7O3Zr1FccgHT0 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:67c5:b0:627:dad9:bf54 with SMTP id 00721157ae682-658f10b0c9emr1670067b3.10.1720807976515; Fri, 12 Jul 2024 11:12:56 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:02 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-22-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 21/27] perf diff: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111257_624498_6E3483F9 X-CRM114-Status: GOOD ( 13.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 Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-diff.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 4c0567882a7a..28c5208fcdc9 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -467,21 +467,7 @@ static int diff__process_sample_event(const struct 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 Fri Jul 12 18:11: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: 13732156 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 36089C3DA45 for ; Fri, 12 Jul 2024 18:18:39 +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=QqtdDMsD55pEoQfMNz6zeYZQAoeVSzSneBvTBBwc7VY=; b=TxtZ+vlovGCwW+CqhftZJ+bBil N8lKBFToT4PV9vh3nBYofBn5VYDh79uYrnU3Olzzy5tvrj1kN8npPEe0stAwivwFhI18iQm/AZdHQ nOyTJi6Avjw304Z+SrC/6ntS3M+35ClS4Jq1gdg8sJAY0TBc0Wu/TutLJxAqE51WGShBFyzKb46tB hofpyBeQQqq7UnUKcE9wG7ysF2AI9NPa8PsNfTPULcmVmXPGfK+VrRviuh5wKlT3H5N/xRMBjh+ym rNGucURYTsYR5sLj9LuyUw+g3ewvgW1czBMutoHPCcp2anPCQv5BSeM368qoPvu2l8pfnJFPPfntX mEnVD0Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKqi-00000000xxx-0bu5; Fri, 12 Jul 2024 18:18:28 +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 1sSKlQ-00000000vaZ-0lt0 for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:13:02 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e03a434e33cso4117668276.3 for ; Fri, 12 Jul 2024 11:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807979; x=1721412779; darn=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=QqtdDMsD55pEoQfMNz6zeYZQAoeVSzSneBvTBBwc7VY=; b=XKJTwEf3V73bO46xusGveyVG3mvJnQFmXtPVLz5FEevgw29ArXgmMj4epjdbCYbr7x tPGoWqH/n/2yjFI+lWWUfp5+6usqd94YeORVF3uivB3CQlQMEGQyXW+gV/KEhivMN7wi fTWO0fozKe9kDAFvPyrHSWcXB0LbN067kc8+ytk9dXoJaCzsc2yM9+nWPsKl64FwFJeA I4i7g2GsiUuWhttlRD4PwVT+z9PWpy9YxMlAghuFLWG2polkirwBfQx3//iXUJjpW4YL tTO3Uy6OhsydDazSy1ivfkcF48CrdVs+spSFWD9gq15xxoNgLD1UCLav/v8sG85pWBFd qivw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807979; x=1721412779; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QqtdDMsD55pEoQfMNz6zeYZQAoeVSzSneBvTBBwc7VY=; b=QDZ3wMkFIZoKJjFxVEGHDBTEegTZckV4bmiMp1JMt5cNtO51WyIYP4h95+SBj6yKQb xnAEz6klB3XzxLxFxrXaq8ahNsfxTYKh4UOAo7ngK2ncziveh9Y8LAPjMZI6YoiZ7fTI kyM8FOEvZ9SrBfaDC8xK4enA1j6HRyTLpF/LoEUhUgjbxIUUi55QIVd3n0uG0Si9en7Q RttiB0ersFShV+5pc2MP0m7miVWWG7nbo+N5zM759CsrPMGARTAGJEDdiOVtkTgWnBuQ nEN29v4G36jBf1EcrT/gUgPP9+vslcGpxzvSnSrNpTEYsHgRqRgW9/7v3munInlovSs4 CDtw== X-Forwarded-Encrypted: i=1; AJvYcCXiFwEzSZQGiRyhCrk6lwG0mZgFpeNYpaSgKqQW93LZnkSPX1PNaJy9yR/yD2FfO6ccNOlW/Q4iMnoZ2klUr4jSPSRIwbl4QGGaDAzXMrBzyih2Xl8= X-Gm-Message-State: AOJu0Yy/00pJswdd26pHbAmBJoyx2C1n879+n6CZuk9Rj7ATIEoJf6Xv WefhQpjM/qisQtPOe1C2+7kJeh6pukTVKWk6/15o5Plf/na+z2EYj3e2rcVZ2uozygr6atQSFZF 2N6wZEw== X-Google-Smtp-Source: AGHT+IEnchojDdZ76Vxn9f7h4DhTLRV8huHLPOkuO6TlwqAevAk9P1WjzXQqv38Bbw3agIDos4xIMuc27TcD X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:1208:b0:dfa:48f9:186a with SMTP id 3f1490d57ef6-e041b0370bbmr26212276.3.1720807978826; Fri, 12 Jul 2024 11:12:58 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:03 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-23-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 22/27] perf data convert json: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111300_238198_12AF8C63 X-CRM114-Status: GOOD ( 12.52 ) 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 --- 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 Fri Jul 12 18:11: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: 13732157 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 01FAAC3DA45 for ; Fri, 12 Jul 2024 18:18:53 +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=I9Nrbi73tEJWZxPfyj1GxchBACZKBze8WVP6UfEoRnc=; b=AS5rzztKh0CzVDy+QNAnHbP7jY 7T0uWmTzKJDskWcIXymAl5BXuFlj3/nSxPp6CUzxbSrW/Wvkgc9TyRA5lW5ycz1mNe8/blPCoDKk6 8lwQwNaW9Vw33UdMLe+ZH63r+wXFlQSO5U0aod6USosVu7HIWQoWUTkTXaW+kOpeHChuJWLx0MDdW w6cU3WlT3WNWPg6LH/XJtG+WCarWjAIV/le4kVLQ2LcoCWYw/9sGrkJMcwxEzSFHzbx+bvXbeGAsw bbuaxobMkJEPFLSYmzzQiVjfpSfW38UPv1oLLFvYZH3vNOq3BFitZ9RWshjSDvuZQyyvFFNfmtmhn zgobVzOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKqy-00000000y56-2Ixd; Fri, 12 Jul 2024 18:18:44 +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 1sSKlS-00000000vbs-3p63 for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:13:04 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e0353b731b8so4353059276.2 for ; Fri, 12 Jul 2024 11:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807981; x=1721412781; darn=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=I9Nrbi73tEJWZxPfyj1GxchBACZKBze8WVP6UfEoRnc=; b=sPOtuPSBfo0P5343CLFFjnWjzAJYvinuXUeXeA+/owFD67GXdEVvyh1PA7tCC6yU/5 TvQCdIloa8L9P/3qJRsPxXY0f67o3V29OtqOvhnj1w0a9YNuRYEi6bDqXoZFTm4rsr+k 4wXjvDZ/K+bGKrXKRqF1PZdgfiCRI/mvr91ecU8wf6nhzzAcje56SM/JtyGEnDryz+8H cZRnXCVdqad30eQe9FpiD5E7i/mZJMDH35Z24n1kWrM++d+DBdjRB95YF9Ve+4u5MvK1 aqkeVj/PrZJarDJ5U+F/E6btZpI1xU4k6DWJPI8Eb1uc4KlWNcdFaoFR92vrlwVeEwlB fN1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807981; x=1721412781; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=I9Nrbi73tEJWZxPfyj1GxchBACZKBze8WVP6UfEoRnc=; b=MP9efGTTiMfHUSP+HBCHh0/8KG5/0Y1dUpntNBTL0EVdzG7Eaamu/JTkoyddALqwCd /pIalEV/h7uwZx8Z6U8kayLTKcnMcZg/nh7pmZAEgqj/m+8Y6rSLFlJ+yRu73LtqSahf xdmFxUQkYIYJ2tRWW4RW++kFFU2PJfH9m/K+2C4/GL9t5fH24AAclyPe+ta9Q2HGPkzI ArgYF9DKsW5Z6ku1AUqX0r3H/v7L/M571ee0pQuf+Zeq6iFlxF+fXoiL4y4tCoB1qjJC xudbi0PgkBTpOpEoFNpixDPwQO+HkJgm+3Vn+t4e04Na3PqWQE+GCz3115oIvG69PRBb MrFQ== X-Forwarded-Encrypted: i=1; AJvYcCWWf1wG6XMdbDXDYz1NYIWB0ZXqTDBza9OnqlxQP7zYdz5YOQivXuAHTDsryzQQYyUJqEcOzISnrpGt6aTdVtxfAHsWJi31dWTBA5qjf67Gz274QS8= X-Gm-Message-State: AOJu0YwMEph3FJ3AxtI5/ikEL2lmbFGMhb4XOpeKWlUxx9Uskugilqm/ MIj5H65j6be0rnl1DwFCyRH64aaS314iUb6FLHQfZBgT3sIP79NLaKWDsr2wfuwKV04DVmxc4jH JsCBq1Q== X-Google-Smtp-Source: AGHT+IHbbwHCzdchAfHj2SPmGVg9X+8SLDnkVDWoP3VU6MRCDTDk07UDfpwPw7rKkSi8K/BWJzAXGMd4QWb8 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:2b0d:b0:dda:d7cf:5c2c with SMTP id 3f1490d57ef6-e041b17798cmr23901276.13.1720807981253; Fri, 12 Jul 2024 11:13:01 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:04 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-24-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 23/27] perf data convert ctf: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111302_961389_2DE930E5 X-CRM114-Status: GOOD ( 12.59 ) 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 --- 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 Fri Jul 12 18:11: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: 13732158 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 100D4C3DA45 for ; Fri, 12 Jul 2024 18:19:12 +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=2MNiLSniwVv1E9e5Lf2m3HZTOrICLuX9boz579z3/KM=; b=RQKpV69dGY9j3OzxApnFCc2erM J9EXTRNjAHdsLhI0jfcajOkd5BY5y6TU5cdvSADUiwba4o/7+iIA/CazlMAgEOlmdM86l6iXRiRIt JLsfBp8XOSaaVaZLr1hXTlA+dgBkllFP+5BOK2AQAwNIQ45h0wkZjsfjiTizIoGHXTOlLNQiHQKzs SuT25IcBJU9ig/h2NuXlEwyv1GkkRhsXZwtKeRtjuuT0Fm2q24eSgVPlxwkKtwfpWMSY9WHYp/gYG +9hLFRWWO1bDYMUC0KZJRAoS+RtZvlm5YAxjMPwQTrzl/00UJurigyiJ9gwWk3MNtI0EzV1Ns8JNj TFYO/DMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKrE-00000000yBW-3jGs; Fri, 12 Jul 2024 18:19:00 +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 1sSKlU-00000000vcm-2yME for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:13:05 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-64b5588bcafso39773327b3.1 for ; Fri, 12 Jul 2024 11:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807983; x=1721412783; darn=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=2MNiLSniwVv1E9e5Lf2m3HZTOrICLuX9boz579z3/KM=; b=1ge49T/wUOLlo25BbQfJU+JZpTb7NaDtrWSKJpwxJrDP9z//PaYIpEp4MhWfDvlM+H w2/mffSARriK10hnR34xZ82NaZ1TkL2do5/NZZ3je2FqRQSA5sn2hh+toDpjUD9Pteqs Jwixwinhq7FJK13ie1WfN9F9dZnI/cPYlNkogXd4DNos6SO5HMryMMneVxrZX68QaVqD qtUNn4pknGWF4ABbH8/rAinrKEYCt0mnxqka6a9h5F3QFhv8a8F+attrS41VFD1W1FUM P/QsOeJ11iXIUfMM12wxh+ajyjwT2fV+O/rSZaMJrSFXYqrfRbluDPMACDhSkfGlQR1L X+rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807983; x=1721412783; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2MNiLSniwVv1E9e5Lf2m3HZTOrICLuX9boz579z3/KM=; b=XCvy5Yfjj+WqpLjslC9a3H+iFU1tTn3+SGNgLJPQtLyFmL60JmwBCTWOv4irUmLZlk LE5E1OjP+y94mgepZfMAljQvcqjPdI6nWPASwgLJdJRxTpsjJUHk2gnHOqtFiLdZfFPZ WDyZ+eiWaEL7B3uXVI7/X4BmzAphCyzzCBMd8tdoGW+NH/Yi9XyIZFcixqHHJ4ueBrDE KaXziEmh5dZc6LZ+JRDifgFKJzi2Q3f3NlZWjFpeSKm0hPhK8SsjZqk/OZwW1qNpTMvn +Lm6Rmbjidw5+1qGD1dLGWTqmFLzfDCROZOwU8JFyZfvPQvWUdqW73XHOtHU9J/HW3Og tSHg== X-Forwarded-Encrypted: i=1; AJvYcCXWwLVhxbyBfV4XJ2yPoTHVs8KYGa5aeCzqi+Ik/ASl/iwySWYLAq8WpfHd2f8LpH9/pDV1SElomZzNTo2E31EUHK692so5Oq5hhzOcmV5jDMxunHU= X-Gm-Message-State: AOJu0YyItwlGtj7W0sQ4J64muVvUbczKHv8WzrTkVz5HxYi0hY+TwO8m I/dt7CcZLEiOjpR55RX87Mdb4NcVzthgDajIbnp18HdJxSIPf6QRamjCow1dk5NnrGyUlTU5O2b a2eYJBA== X-Google-Smtp-Source: AGHT+IHT+bmwbpCCDDBGyKMSZDJyWfQuQtb+HSakU4o5bWugocQR0tn5FoTRKGbLNL6FlQgXTAEyTtQZuZbw X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:690c:4d8a:b0:64a:d1b0:4f24 with SMTP id 00721157ae682-658f06da930mr3078967b3.7.1720807983544; Fri, 12 Jul 2024 11:13:03 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:05 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-25-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 24/27] perf test event_update: Ensure tools is initialized From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111304_752132_698C0320 X-CRM114-Status: GOOD ( 11.07 ) 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 --- 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 Fri Jul 12 18:11: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: 13732159 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 BE8E5C2BD09 for ; Fri, 12 Jul 2024 18:19:26 +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=phxqvYyYZFcsS+fO7HmN6BaHRpzOxQeFfvDLLgr+3hE=; b=kTgdILtz6QWcodrISMZybSnQL3 BTKP+0ZFzHTo6IcvgrgQFKKuL/xAka0dUSXv7u4s6/3w/JfkyMFl0AeUEbJOHAdRe0nMne6RZPLPX jzk4ZjVvboPpvCW9k9tUitqpx+dnerk+Jvw6ZI/EHIwejFbzDYHlhBTMBZrjTQK34JRz3UUEuGb8y vFQETYSdl4P9g77gDMsRNgf4ZleuOOP3Rg3rFbhsw6nlWwsmds2szl9S/cjGChpbiILoF+g+iWnen 2QmOZnYUigHHw1UPb9mnvaWf7xK2LOqbwNN4mk0lX86HlHa+i0AhyGqx3yyRJNfJilk1lmbSqUEaK zH29mLiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKrV-00000000yHs-0zId; Fri, 12 Jul 2024 18:19:17 +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 1sSKlX-00000000ve8-0w98 for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:13:08 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-653306993a8so37568287b3.1 for ; Fri, 12 Jul 2024 11:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807986; x=1721412786; darn=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=phxqvYyYZFcsS+fO7HmN6BaHRpzOxQeFfvDLLgr+3hE=; b=y/mSPUF2PJBZ/HqwuD21Pdz494wpDfm5/5aZ9KgOlnIpldGzrFBV0kwNCUI6h+rSNQ jM8LdDX+12P1eLp+zl3YTg0OrJr5xIGslLCjfiniv4eFQ9Pr0r0UVchgdbzddgZ5wsk5 9Zt9kwzZ+O33cs+Eq4FBUGzicP69smU9mxOrvLG2zU52dtSLZyWwPipd7Il+36x3tnC0 SFbnCh+xZxIqzGwvOO4l9GgEdllu6zcF/pjq2JDdkG11xdYmPDUoAMNE9loyyiVP93DC 5zRwA1pv6unjchlc7y6kROmLYrTzMlGyhtGvj0LLhAjW8w+9V/EnRTofVwKOwRqY/mIm mM1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807986; x=1721412786; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=phxqvYyYZFcsS+fO7HmN6BaHRpzOxQeFfvDLLgr+3hE=; b=brwDElvr1vZjc0LAb+RcJHyEBg1ecTEKuPraPLyd55g+DCRbq+ViiFZtYeIpZU3B2W 7F/3i8LqgEU+oQLdvHY+ADFzo//Jd3oQG2ciF70Mk13+6tBRZSKo/fKtCZzjkoc4rlOH 8VE5UJPX6KnlpRJb1HdPLDwpw3xlKt2l31aV9VDZdKsEozt14NS1Q+WBXH2pTe7bpVGA atO4AsnUpN38ERzSe01gtB+/mVuMALsVPeVivfCIm40pFtZDg+2CU4HQhga8njoLv+uj Re1vzTWFZk/52VCSIMhdRJNBG3b9DL4Ld8esK+YymWs/xBB3/Hlj8Kp2ZNhJraEnIAu4 DkXA== X-Forwarded-Encrypted: i=1; AJvYcCWqI+cub10xnhMDKWAhyAFRnyZ8mb7LWvkDs3CiNVhJmr2gnBBF4OWXSevrRjaIPHHeat09o/NxBVBdWujcuTlCUqUvrBNrpTGJESdgL10R0zxtMZU= X-Gm-Message-State: AOJu0Yz95PQiY4r4HKBCQfjvo+ozSFS9sVARrUdLBF4YRaL9ZkEScSJa i3Gw0H5A0FDr8BAN6a8Zfk7AWXQF37kpG6C8RQ8i0B8yGv6bdH1xbURb2Q4TRFg0psr822hwnbp 6MWpfWA== X-Google-Smtp-Source: AGHT+IH55ouNUARRkV/7vwiojtMsBJqnZMjnyHFWfmbeG3E2oRRjNgYMj3GXuyIvTVcz6xeK7mzL5W5Xp8yA X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:1b0c:b0:dff:396c:c457 with SMTP id 3f1490d57ef6-e041b0364b6mr21640276.3.1720807985767; Fri, 12 Jul 2024 11:13:05 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:06 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-26-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 25/27] perf kwork: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111307_284401_C9D68452 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 --- 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 Fri Jul 12 18:11: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: 13732160 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 A1651C2BD09 for ; Fri, 12 Jul 2024 18:19:45 +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=7XS/BS2tmrMYCpclJsc0ik1l+h9pEP1QMQPO1IiW0Pw=; b=jlZMvQr3kqmPTLDt/K8Pt5d0vd eNt1Kyd/6SflYSt8mh6P3+PwKM5SMPpKc2eNLddckiY9IQSEpFOF5y3Msi5g3wFtfiCDJQ7sy41CF fXyxS7u6MK22t/WnZ9LixtyzvQDkTkubOwTRk7vQCIvECZf/y52pZp0xH15BP23GTNzJbAt9tCJeP pRVcoTELWG8buCVb0BUT4iTZ/CGeOYUmlBCHR8yPgq/TjXzl0JXVg8KyJsiSAFEF/AZpcrE3J8GT5 VEfmZ5s9ufV6lIdpKTkSsE+2md7udO92hkvvU4SeaBgz3xuLUhkBwyPEH4JRT8If0/giCYBIy+PUa aZt6zjzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKrl-00000000yOa-1Qoz; Fri, 12 Jul 2024 18:19:33 +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 1sSKlZ-00000000vfQ-2WGN for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:13:11 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e035949cc4eso4316283276.1 for ; Fri, 12 Jul 2024 11:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807988; x=1721412788; darn=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=7XS/BS2tmrMYCpclJsc0ik1l+h9pEP1QMQPO1IiW0Pw=; b=zz20dcF68wH70jmTY7NN7NyUXSdKk93TR2PFSH7ALjE4+YB4VOqy/XYch0Xo987cr0 divetjYw0T5xHNr+Su56V6vN+HE++0yGny7ZY5YtGamkm9wznM9A+qJaKqm26hWaUAxO nj6Wb0hhkdzp/iv1+6CLSeQ/yX4UL2T46gP3nlK+9dAlQvDsGsUbfTd6j9gjbIzUEGep GaFr0GQ6iinqakv26aMnVtOx4GG0cKPCxFIBMe8ftsXQv30VGzGlWWSs0XjKDxzhDy2X RYyXkdbZvgTJiXY/PeVPpffu07vpL2EUwHmkORiULm6RhmnYk61hVURosYFSob1eh1lr jvvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807988; x=1721412788; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7XS/BS2tmrMYCpclJsc0ik1l+h9pEP1QMQPO1IiW0Pw=; b=q2oqSIq3XT3srlfdksbqEBKI7fHNeeunhUr4x1e2/R01u0zYlmIHlTF2GKqPL4Pisy zm0iUrwFjEZus/hZsRNh6GK8RZGOObt5pgarBs10beVdyZHWUqEmDTwpjGdpnjyWNoxR kOm9Kbt7CFM9yXedaOwuEdRi007aCwo8YeKMvcjvwzk7iwp84Qw/8COT4vGyD+qilz2o Wr12s31A3bHTJG6DPLVe6fdjJJ2AVttKiJJno1iWsBTTF8EiAsUtCpIZfTb5haP+jg50 D44ouu+1WeAOExdR5BUYDIGlZwFLxBpKGCl1P2cAPFkmfAA6Z9FFvltfrG0QzJDrP7qo Dxbw== X-Forwarded-Encrypted: i=1; AJvYcCVqser5dOpz8lZFwQh83YARipD7ICaUa67i+2bmTvdOpaCnzkRnV/+9T225EVakJP+tzvrKzkZQgCLwoBRYqPq2L1lFKze8E8rP7UvyO1EPB1gpMvk= X-Gm-Message-State: AOJu0YwlhDMtn/W7jXPZO2N1Rd8CaeUmQ/K17a5jKT4FEXD4T0TMRw8D pEe5aCPAbVxLVYqNCx1gGl/qzISTdWL0abj6K7T94eTEH7ZfyQY1KdWuy8jOmPbpKQZf5pYWKbQ xXRrdQg== X-Google-Smtp-Source: AGHT+IGRQeviKtJ7AI/SKvJvmycZj8/fIM55epBno0pPkXZ9si90TtF8Qxi1wIa6axTSZEDzMtO8YxPJZp54 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:1ac1:b0:e03:62dc:63de with SMTP id 3f1490d57ef6-e041b0593efmr961462276.6.1720807987989; Fri, 12 Jul 2024 11:13:07 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:07 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-27-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 26/27] perf tool: Remove perf_tool__fill_defaults From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111309_734892_B12BF9BA X-CRM114-Status: GOOD ( 13.49 ) 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 --- 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 Fri Jul 12 18:11: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: 13732161 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 BB271C3DA45 for ; Fri, 12 Jul 2024 18:19: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=DzgUQ0L67yHK9ZgYOmZnLIT3MZDT9EVRhOxDmj12OGQ=; b=q19mpGKuAXpV66y1CPnF7k3rg4 +6Y/nxPUmkn71FzdAN0bqpz4vqQlpVSLO66ZIrvxxJjQhCkbnvQ/FjAPA/1jEPX4L6KrmWm60cwHX HzOH7EVCY3bJFpnCN+A0AZuGu0HHxYxFPd++fCFToMVbeD/S4cYVahK88bup5dpiJBMYo1+8+dFmW e0CJI3XhSEGwmuujTVdQV0T9S8hOVY93o4wIHPhMgepyee2a02nNiEhlubyCmcs1Ew8EZPrMpP1wD cN5Ou8JpNL8TJH4NF1LEavGhnfq+JKJNALipNx4Z+6ZkFXBIEqmavkPRkNVgrDDGRb0yh6jj39yan 8CU4l99Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSKs1-00000000yVV-39TS; Fri, 12 Jul 2024 18:19:49 +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 1sSKlb-00000000vhA-2WDr for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 18:13:13 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-65ef46e8451so9274017b3.0 for ; Fri, 12 Jul 2024 11:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720807990; x=1721412790; darn=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=DzgUQ0L67yHK9ZgYOmZnLIT3MZDT9EVRhOxDmj12OGQ=; b=L7s1djB+ROYaF4TF54/ci0vl8o1Cjw6steOG1vm9nICt2IXPvG7Iid9cktDgNPPGBS GAsfITSuhq/5KcVqEXqmhw7hB9tz/vUSWU8Yg+85imf+CKB+uidIBV8ACao6GcWrDSao TV9C4QQfMS3+1IRy0xQ6bJy/jeEkAHskIoKaSSlJU+ye1EjB0mJMx3pAc5vegtBpz1mQ MOPsMhpwZS5jjCha8iGAY5t4ccWS70iETmUVcqFK2LX8gtZkPmH9gMmGkGGkqfhIAmMe 3ffD96Dq6yf8P2UYuW9z6MsZo6Y8CQfaNmEZ9MzTr+yrIXrQAtr8QU1zqwUXTjL5uEyx Ui5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720807990; x=1721412790; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DzgUQ0L67yHK9ZgYOmZnLIT3MZDT9EVRhOxDmj12OGQ=; b=sMmYw+YXOIyhS3I4cXZBk+ZN+EFjyOLDtb19L1jzHFqEK9hZBvJu6owHwuZDgw//ka dsKOuT48n+7Vj7SQ5I6VwPCFCzmWargrgNtQivyp+SkybbeOBcwTJrqMaKfWeFic3/lu 2Q8v9kPiewehC/qkEBnfwvdJcvxxsbdg6vrp5n2GOtUnBUEPAqogFGkhK103qp+Pd2cV mXwFvS46JWWbTnxmsMmeucGP3qBMv55eNS1GwpJA9ReIXuuFu4yBP3cp9bsLQCKwXcmy ArrD6pbr2OW8oGIujOVznLp9mhFG/FPh2vuWBCa6xnx2uN5PSaJyjKN5/yOURceV5W6n bBAw== X-Forwarded-Encrypted: i=1; AJvYcCW05HRnGDSu44kKoEYs4EGAQJO2wdACWBtxfUDgXXRrq+ze6r23TeyzxqUycU80ur+AvYgbdtdBsK72JBqujfjXzxTXr1criIN/WXPk1fzE7MrzP4s= X-Gm-Message-State: AOJu0YxpJx6V8zxQrRSnXZ/5sA7rF2ufs8TW2jUCCDGViFpN2A3trEk/ nte93zyaah/cCvrbzu/LcOStR3WLAq8jfWbvv2G2A9g4H4N0vcD/Bs9ACAu0qLWsrY3CHMT3XOB pj0L8Rg== X-Google-Smtp-Source: AGHT+IHiAKXzsCdcEZM+MFSDfgz1r4L7ozGy4B9BF+4puH4qqiiY89mJfDURywhS/WGVSxBcH3QuZhcuBDvg X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2e7d:d47a:a0c6:e3b1]) (user=irogers job=sendgmr) by 2002:a05:6902:188a:b0:e03:2217:3c8f with SMTP id 3f1490d57ef6-e041b035055mr23746276.2.1720807990114; Fri, 12 Jul 2024 11:13:10 -0700 (PDT) Date: Fri, 12 Jul 2024 11:11:08 -0700 In-Reply-To: <20240712181108.475336-1-irogers@google.com> Message-Id: <20240712181108.475336-28-irogers@google.com> Mime-Version: 1.0 References: <20240712181108.475336-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v5 27/27] perf session: Constify tool From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_111311_712393_EAD6A7E1 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 Make tool const now that all uses are const and perf_tool__fill_defaults won't be used. The aim is to better capture that sessions don't mutate tools. Signed-off-by: Ian Rogers --- tools/perf/util/session.c | 6 +++--- tools/perf/util/session.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index ad5da61d2330..0c7cc092887d 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1765,7 +1765,7 @@ static int __perf_session__process_decomp_events(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;