From patchwork Thu Jul 11 17:59:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730956 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 46879C3DA49 for ; Thu, 11 Jul 2024 18:01: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=EMOmsjjbfRL4hNLPYFWbLSO5w8t6s+E/XHk9xV0Hop4=; b=VoiGieRK6V0Ur3IL8uevoKUqEk 023LdWcEhBgsB0I7qxK8bYj9IcHACIrNtMphD+dFJEPb71AETir1QgRQSbmmYK2xVj0sQdxy8EoYn l6F56iN+qbzQ5Yzf1MCbuJih+n0mHjONtis2BPmu6W9XBGODrr7aEQryNIVPYMwAkMm/dZaTs4azJ dVInNAN9iWDLd7ysllz3gZLzK5WOkTCOts9XG/AAWogOlo+etMPVdrXn+5E13tKN9tpSJM7LRsFPg B9iHpeLRmvE80o5N7BQcsx7dcmcTb2FWKt0WOpAlX0g3sMAfatK+Pje+CNtoqEj2O8pVgCJHIRIa1 ldMZHaow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy66-0000000EwLb-3zMq; Thu, 11 Jul 2024 18:00:50 +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 1sRy5Z-0000000Ew4Q-1ani for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:18 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e036440617fso2146384276.1 for ; Thu, 11 Jul 2024 11:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720816; x=1721325616; darn=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=EMOmsjjbfRL4hNLPYFWbLSO5w8t6s+E/XHk9xV0Hop4=; b=fBsYmRtPOPrAfDumGCqvrfvqwWProsLU/tXrGejD7JEdpt+Xms6kDchZCGjZ9+7ULj s6TEnUS9bGtFLLs8Nul5sBWn7pxxhzQObhhRpcgPApMs5sU1BonpjJ2GEZenpnyUNzcW Xuc3eg7s3jgeRCLQyH46y3Y4DKdzCre/Sh71LvzVsew+r1aDCNIN96M8BncTfYVS3TEj akXr+sz1PhEnRQULBIl8ZdCss7PcrzMMg6QHaYMQkbOX9P9s+PvWLD11QWRboMlN8Hcz vYZz7YxQoaxYLt6NiNwkPqFCaUrxMiJxOGlh3Z3FIYdFB/QfsGvXoGGO75sdZJiWRjQp ZDuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720816; x=1721325616; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EMOmsjjbfRL4hNLPYFWbLSO5w8t6s+E/XHk9xV0Hop4=; b=Ht1QewmPt+NmB6uSjfIEVHdvTnZ2j5mt8XaBgKfFYLLDYIGX64NgCpC6PTS5qfDtrG GHN+E6lKiFPM5+jVcZ8mdAZmcvNih+smQjq2GUbog5fnY/SaSNE4jmC1bosE/mPKC5or vvMy0zZwdxNcWPAUMsPvrB8if+CHPL2aEJZpn1U20yEEP/uCK+eOqzzgKQzCmW+nSZlD aJM+QtAVxqTEp73t8lOaiLVEDbZI+vCsQIB88CR6vvKTbsMV8C/vpRIQ6/PCOwX5DIwq z82dpu80Zs3Qm88T8+/V7D7+3yapYZ0CqPtBGJ0NkzRDxIzVFV1qb8zdbnU87y7sTE5x ApgQ== X-Forwarded-Encrypted: i=1; AJvYcCWKpRpHJD3oAAZc/FW4DZQRLWnB6KlSdOSX42suGjEI5ozJf+eq+BRKgfzTH6Tx8hIf61AmWoosAzZUjvCKlMuGIhQAYIB77ZyLW9MSBLDkikk569w= X-Gm-Message-State: AOJu0YxWyC3YCNAkV1qMeOXgkhxM/LH/IY1o34Rs45CCoGjqcksko4J2 5ddB3dczyi3G8aCDvGXYOZbhpp++qpd6sgJ/qaLyPqv8fqooDBPdV7lh92VEnAGEBL+52naW7nc j7kKpYg== X-Google-Smtp-Source: AGHT+IGOU/jkyqa8KF9IeY0lS+BXQshpKVVzBAK7j+pR5Ms6PbYBjWcy+MJQoCU8MzleeGZ+ePXJBV2b9ql1 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1106:b0:e03:3c8c:e82c with SMTP id 3f1490d57ef6-e041b17e019mr569632276.9.1720720815591; Thu, 11 Jul 2024 11:00:15 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:41 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-2-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 01/28] perf auxtrace: Remove dummy tools From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110017_455246_C34C6314 X-CRM114-Status: GOOD ( 16.78 ) 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 --- 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 32818bd7cd17..c53812f343e9 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1595,35 +1595,6 @@ static int cs_etm__synth_branch_sample(struct cs_etm_queue *etmq, return ret; } -struct cs_etm_synth { - struct perf_tool dummy_tool; - struct perf_session *session; -}; - -static int cs_etm__event_synth(struct perf_tool *tool, - union perf_event *event, - struct perf_sample *sample __maybe_unused, - struct machine *machine __maybe_unused) -{ - struct cs_etm_synth *cs_etm_synth = - container_of(tool, struct cs_etm_synth, dummy_tool); - - return perf_session__deliver_synth_event(cs_etm_synth->session, - event, NULL); -} - -static int cs_etm__synth_event(struct perf_session *session, - struct perf_event_attr *attr, u64 id) -{ - struct cs_etm_synth cs_etm_synth; - - memset(&cs_etm_synth, 0, sizeof(struct cs_etm_synth)); - cs_etm_synth.session = session; - - return perf_event__synthesize_attr(&cs_etm_synth.dummy_tool, attr, 1, - &id, cs_etm__event_synth); -} - static int cs_etm__synth_events(struct cs_etm_auxtrace *etm, struct perf_session *session) { @@ -1675,7 +1646,7 @@ static int cs_etm__synth_events(struct cs_etm_auxtrace *etm, attr.config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS; attr.sample_period = 1; attr.sample_type |= PERF_SAMPLE_ADDR; - err = cs_etm__synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; etm->branches_sample_type = attr.sample_type; @@ -1698,7 +1669,7 @@ static int cs_etm__synth_events(struct cs_etm_auxtrace *etm, attr.config = PERF_COUNT_HW_INSTRUCTIONS; attr.sample_period = etm->synth_opts.period; etm->instructions_sample_period = attr.sample_period; - err = cs_etm__synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; etm->instructions_sample_type = attr.sample_type; diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index ec1b3bd9f530..160d346cb450 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -737,35 +737,6 @@ static bool intel_bts_evsel_is_auxtrace(struct perf_session *session, return evsel->core.attr.type == bts->pmu_type; } -struct intel_bts_synth { - struct perf_tool dummy_tool; - struct perf_session *session; -}; - -static int intel_bts_event_synth(struct perf_tool *tool, - union perf_event *event, - struct perf_sample *sample __maybe_unused, - struct machine *machine __maybe_unused) -{ - struct intel_bts_synth *intel_bts_synth = - container_of(tool, struct intel_bts_synth, dummy_tool); - - return perf_session__deliver_synth_event(intel_bts_synth->session, - event, NULL); -} - -static int intel_bts_synth_event(struct perf_session *session, - struct perf_event_attr *attr, u64 id) -{ - struct intel_bts_synth intel_bts_synth; - - memset(&intel_bts_synth, 0, sizeof(struct intel_bts_synth)); - intel_bts_synth.session = session; - - return perf_event__synthesize_attr(&intel_bts_synth.dummy_tool, attr, 1, - &id, intel_bts_event_synth); -} - static int intel_bts_synth_events(struct intel_bts *bts, struct perf_session *session) { @@ -814,7 +785,7 @@ static int intel_bts_synth_events(struct intel_bts *bts, attr.sample_type |= PERF_SAMPLE_ADDR; pr_debug("Synthesizing 'branches' event with id %" PRIu64 " sample type %#" PRIx64 "\n", id, (u64)attr.sample_type); - err = intel_bts_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) { pr_err("%s: failed to synthesize 'branches' event type\n", __func__); diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index d6d7b7512505..1fc03bfd14c3 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -3659,37 +3659,15 @@ static int intel_pt_queue_data(struct perf_session *session, data_offset, timestamp); } -struct intel_pt_synth { - struct perf_tool dummy_tool; - struct perf_session *session; -}; - -static int intel_pt_event_synth(struct perf_tool *tool, - union perf_event *event, - struct perf_sample *sample __maybe_unused, - struct machine *machine __maybe_unused) -{ - struct intel_pt_synth *intel_pt_synth = - container_of(tool, struct intel_pt_synth, dummy_tool); - - return perf_session__deliver_synth_event(intel_pt_synth->session, event, - NULL); -} - static int intel_pt_synth_event(struct perf_session *session, const char *name, struct perf_event_attr *attr, u64 id) { - struct intel_pt_synth intel_pt_synth; int err; pr_debug("Synthesizing '%s' event with id %" PRIu64 " sample type %#" PRIx64 "\n", name, id, (u64)attr->sample_type); - memset(&intel_pt_synth, 0, sizeof(struct intel_pt_synth)); - intel_pt_synth.session = session; - - err = perf_event__synthesize_attr(&intel_pt_synth.dummy_tool, attr, 1, - &id, intel_pt_event_synth); + err = perf_session__deliver_synth_attr_event(session, attr, id); if (err) pr_err("%s: failed to synthesize '%s' event type\n", __func__, name); diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 5596bed1b8c8..18a8f4a84045 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1764,6 +1764,30 @@ int perf_session__deliver_synth_event(struct perf_session *session, return machines__deliver_event(&session->machines, evlist, event, sample, tool, 0, NULL); } +int perf_session__deliver_synth_attr_event(struct perf_session *session, + const struct perf_event_attr *attr, + u64 id) +{ + union { + struct { + struct perf_record_header_attr attr; + u64 ids[1]; + } attr_id; + union perf_event ev; + } ev = { + .attr_id.attr.header.type = PERF_RECORD_HEADER_ATTR, + .attr_id.attr.header.size = sizeof(ev.attr_id), + .attr_id.ids[0] = id, + }; + + if (attr->size != sizeof(ev.attr_id.attr.attr)) { + pr_debug("Unexpected perf_event_attr size\n"); + return -EINVAL; + } + ev.attr_id.attr.attr = *attr; + return perf_session__deliver_synth_event(session, &ev.ev, NULL); +} + static void event_swap(union perf_event *event, bool sample_id_all) { perf_event__swap_op swap; diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 4c29dc86956f..cc28976bb00e 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -154,6 +154,9 @@ extern volatile int session_done; int perf_session__deliver_synth_event(struct perf_session *session, union perf_event *event, struct perf_sample *sample); +int perf_session__deliver_synth_attr_event(struct perf_session *session, + const struct perf_event_attr *attr, + u64 id); int perf_session__dsos_hit_all(struct perf_session *session); From patchwork Thu Jul 11 17:59: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: 13730957 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 7C1B8C3DA49 for ; Thu, 11 Jul 2024 18:01: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=AbSFIAjgELn8En/ODTzECP6YTzi/bZUaiF8JxVDqD4U=; b=xhGcH8RQD8Msj2oXpwXX/vjxRt Mqksh6nP4hb5kn6tFICP4MJv6PCu72gaRQXYiIwUcpm5qb+K/kwqFYuE6FAAq6zNLUA7peOLq95tC sQMcWQJDBLjRs7aJ/Qv2/8U9B0FMyfqjJmB31aA1OgLwBohscqsDInm8DdxoTlQy/LY6r5UFu6dnP sc/eqyT2r8ROH06nCAORRudDYaPkcZw6rXsVQ4ESDHutY5oRuA+pTOZ/XpZLVv1r1w5jIjFoPOZvm VNF9eJnbDhnX2KHHVGw2/mF12O/PPdbTzz4zsUfZHF6Yx9EZjVw+5vGgMTKnnzQeRcPEr5tgNzgEe KfjfeHEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy6S-0000000EwaJ-0RSZ; Thu, 11 Jul 2024 18:01:12 +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 1sRy5b-0000000Ew54-14KD for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:20 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e035949cc4eso2126555276.1 for ; Thu, 11 Jul 2024 11:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720818; x=1721325618; darn=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=jjLB0+MPBXn3HdpDPvJifUa+sePWRrFWi7SmRTA4QIlMua8HEA05tbeYu1oqlNZaBd 6QTmQ1mgkZ/niVyds2+RC6A2Qi62q2lM59vDzjkRhUQ5zMBVSyYAR8Iy579sDYxPReZJ Uz95hbkfmGHrwaXGSggKGSaf1q5riLF6wBsmReeQ4vQ2ZBk6pKC+1bAmQsidfOZiyVyR UFLtvCGNC4xLfYhpIO4XVLAnmRlVnJTjAU41xzSO7LRi/4dtfIa6023yGhQknnMttH86 flT6aBEDtxnu6ywZwQbBMjsGwprbN09lWZPAyrKDEvqGV7Nca5nmkkupsG7EnGl7NS2r xfkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720818; x=1721325618; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AbSFIAjgELn8En/ODTzECP6YTzi/bZUaiF8JxVDqD4U=; b=AuQzDNJYKA7WOUV0N4s5KhFYpIBc20SzYFfK7B5x28X+W/Ul2yqKTlycc3nI5iqIDy zEZaZNMKwNtw/A7Wf8CFhNb15WOGA8ga38PIx5BND2+LRDQBkr8sOegPqBCs7oPLzFFw sFcv5gsGfw4FzH9z6reBfPKFo16iO/SaT4rn5XWVeHu7U7bN25MydG1TjvKspL6xDrI9 lsMMgprgv9uKto+vVIDvwNyHNMiAtYq/qxzZoHCq+Src8phLZwL5Mz9AV8aBwp57i8zF akdu5NayzKcIo7R86q6fUhcg/B51OrK3k311kD+HkAHIGRM069Xc2CgucMZlftifvlo7 Sb2A== X-Forwarded-Encrypted: i=1; AJvYcCVyyXQ5V4/ox4WUDcfWQRoSsFr9Znps7wy7EKrQ+9J/jS9pMkC1gMGVoCFLef51Ho1ux82HQsuuWjMeHZ0T1CvAaITgT1ux7IPtre78mXZeh4VeSmM= X-Gm-Message-State: AOJu0Yy+NihdQT9z77x00LqWhB87Fn6dLKLhkW3LKj2WUhcsPRCqorqi q2hBS8VulfiiIwTXQTUSW2v36mSBkhWgAG2TyJjpnPgumoR9Jci35n3UWJo6YLQfBcmERzinyGI lpgPmOw== X-Google-Smtp-Source: AGHT+IGeXhaeoNjn7pRRBMER91nAV7MjXLe7mlhn6vY1im3CgeEvPZqQsZteJ+XWeT5joa2vWOBK1cIwB1BE X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1025:b0:e03:5a51:382f with SMTP id 3f1490d57ef6-e041b1153f4mr804588276.8.1720720817740; Thu, 11 Jul 2024 11:00:17 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:42 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-3-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 02/28] perf s390-cpumsf: Remove unused struct From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110019_319875_CC08C701 X-CRM114-Status: GOOD ( 10.17 ) 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 Thu Jul 11 17:59: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: 13730959 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 E32D9C3DA45 for ; Thu, 11 Jul 2024 18:01: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=EzUK4p38UkhKDsbfF93yQRR2GPAzqU4EO+HGDDPIb8o=; b=yKU9SM9skYU4+twz6qoITGFZXU BztX2xIpbjPQluFKCTMoUeB+wVbltxks+uaUYD1ivFI5v4Z/zzPRfAy3OKhVL77RwCaGjunYVudF3 PEnju2BxPcea4grPmAdnaIMPfSzl+PM4q062wfq6lk6IXL9Vr6YFGtMPjvfYwl6ZBhfCi3qByCCjZ P6ZfbfOUB70pRtabeoKXv8uCh30XXP6vfLjJRXT1ODowP5pNp/TNblK930GWk71wfqP0IY8tnw5WO 4fVS/EXH0TeF4iaaWBimk/GrA1qQ8T+1S4OXxe6omlJS7Sfm8eTFs58yoIUVkj+aVKS+AHOW8Q6pz 4pr4RrEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy6z-0000000Ewr7-2MSO; Thu, 11 Jul 2024 18:01:45 +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 1sRy5d-0000000Ew6A-1EYF for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:23 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e032d4cf26aso2023998276.3 for ; Thu, 11 Jul 2024 11:00:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720820; x=1721325620; darn=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=EzUK4p38UkhKDsbfF93yQRR2GPAzqU4EO+HGDDPIb8o=; b=uhKGXx+beMmuPfnYNEaQu2P5oQVfCE+xhx2jVz/RcGz+JGxOfSJThCTeWo9r2SzcIK ileFMQcHfc3jMfkKy8o4awb1p3WiT2NU7klP9I6p/CC1JdOBBK+56uHwqJ9BnayBt/az MO6q1fVaQ4iLOSAUQNRJmQcZgogyvrB+M/ZDQ3O5VD2ZTXhJvhhH95EIsW5/IINp3MNS F4QzHQ9tvTiIYUG5ZSazXPQ0KvEtYmG188/OsccZfF1mAGjKrwxHraKbCO7o0qXbqeHW vppOmBLTuYHtuOuRGLhG7LVdUEsPHsWaZ90T0QAz0tbluRjb5yE3ACedfKxmx1Jk+3Po HBng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720820; x=1721325620; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EzUK4p38UkhKDsbfF93yQRR2GPAzqU4EO+HGDDPIb8o=; b=fJ+LcEHDb3TBxfguoTUYcKd6mXKDvAq/0TMU68lKXt/D5bTgBcdkxuxdgSRdx6EBQf gIQ4bTCuyt+ywrHKDdB1WSX9lM2lk9/uK3XuUtZipALT+402s+cYhL4kN+hyMhdHCQCI Cq8CjP4tILNNpR/MTS82tw/KY2EtZVWU8RvkMpWILXn3+RBPUimdhWWsTUzIwsoY4Fy/ RuIhiih6+Tb5igzbjxXxpWyHdjj9TsBgi+BHnpw8NmX5n9V7USXAdgqw2rVkoF99BFLg 7x4juvSmMEGdNrpeK7DNP6y/e7foJh1buco+OXMCjauKyc1RRQNA2X/cSSGerisqr24i J+5w== X-Forwarded-Encrypted: i=1; AJvYcCWB0eNjsBD6qmZgQaoCkVxATNEaU5swDrRpFdXuHE3fw6JT7DjyT1jxTnha9oiNwq5+m0Hw/6Id2RuFUfbLlAVUmcYqlys7ECRkOGBMfmxt/37TXoA= X-Gm-Message-State: AOJu0YzLMWGmrkk2bQcHUpksecmiqa2HdZvcVFtkhNCmubpOOjzvstpD 2rZVvvuM9ZczcbxJi2Ll5fd+MphXEZKZOReUrrrNU8amblhcgYtH1XqsJXqQyX32sFNcaUXRntr QMLW4GA== X-Google-Smtp-Source: AGHT+IGk7HjCBqWpD+d/XmopT/Hsmtv7wH1IyWS+4QZ4y11/DDN/Lx4J0Msqdj8IwaEOMsdGEitrp70cKoog X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:a07:b0:e03:b5d0:2aa2 with SMTP id 3f1490d57ef6-e041b1e255amr599255276.13.1720720820135; Thu, 11 Jul 2024 11:00:20 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:43 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-4-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 03/28] perf cs-etm: Fix address sanitizer dso build failure From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110021_504429_E2765126 X-CRM114-Status: GOOD ( 15.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org cs-etm.c had been missed from having accessor functions added for the sake of reference count checking. Add the function calls and missing dso accessor functions. Fixes: ee756ef7491e ("perf dso: Add reference count checking and accessor functions") Signed-off-by: Ian Rogers --- tools/perf/util/cs-etm.c | 10 +++++----- tools/perf/util/dso.h | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index c53812f343e9..7fd976ea954b 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1013,7 +1013,7 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u8 trace_chan_id, if (!dso) goto out; - if (dso->data.status == DSO_DATA_STATUS_ERROR && + if (dso__data(dso)->status == DSO_DATA_STATUS_ERROR && dso__data_status_seen(dso, DSO_DATA_STATUS_SEEN_ITRACE)) goto out; @@ -1027,11 +1027,11 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u8 trace_chan_id, if (len <= 0) { ui__warning_once("CS ETM Trace: Missing DSO. Use 'perf archive' or debuginfod to export data from the traced system.\n" " Enable CONFIG_PROC_KCORE or use option '-k /path/to/vmlinux' for kernel symbols.\n"); - if (!dso->auxtrace_warned) { + if (!dso__auxtrace_warned(dso)) { pr_err("CS ETM Trace: Debug data not found for address %#"PRIx64" in %s\n", - address, - dso->long_name ? dso->long_name : "Unknown"); - dso->auxtrace_warned = true; + address, + dso__long_name(dso) ? dso__long_name(dso) : "Unknown"); + dso__set_auxtrace_warned(dso); } goto out; } diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index d72f3b8c37f6..878c1f441868 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -280,6 +280,16 @@ static inline void dso__set_annotate_warned(struct dso *dso) RC_CHK_ACCESS(dso)->annotate_warned = 1; } +static inline bool dso__auxtrace_warned(const struct dso *dso) +{ + return RC_CHK_ACCESS(dso)->auxtrace_warned; +} + +static inline void dso__set_auxtrace_warned(struct dso *dso) +{ + RC_CHK_ACCESS(dso)->auxtrace_warned = 1; +} + static inline struct auxtrace_cache *dso__auxtrace_cache(struct dso *dso) { return RC_CHK_ACCESS(dso)->auxtrace_cache; From patchwork Thu Jul 11 17:59: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: 13730960 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 E78EAC3DA49 for ; Thu, 11 Jul 2024 18:02:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7irtahaUgZZ2kadtdQTAIVJwXhey7Hso05gQMGn03JQ=; b=emdI4NcI773wfevYCGYNLMBMSw 9WIqEvY5V9zivnslMOTOBIGUjaHDBDVtRLtgKhSzAFX0tyiTc6NDRJvpM6Hi0DD/WWBjCQZU9XHLQ aGuC1ZA6QVxucWvTxyWUhNv3je5hLPt+Px7tj4zANvLoE2YA+oDkSdUx5VwpS3/ZClfQUzG11tw9y DMvOTicmy5pBtHtfF8nOzrZT250NFphfY/M8RxW1hPd4wxwohVgH9pHJA04l2Kwh6tnLaUdeEGr64 0n7bQ89QGIMjhNZsc1YKAWbQRiD2eGwRUyyyKOlrupb/VHnVaoX3vosCt6EhkuXY4WZ7bC5gFRLXI JcKcqeCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy7I-0000000EwzJ-0e9w; Thu, 11 Jul 2024 18:02:04 +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 1sRy5h-0000000Ew7u-3b2W for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:29 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e033e353528so1595577276.0 for ; Thu, 11 Jul 2024 11:00:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720825; x=1721325625; darn=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=hGmwoXdeQQ9FsGlCudHdiV9KhqemTVrw583XImefSXiD0lQLzOOMAqxTPaFHsJ02B/ 2WELp0322ANe1yRay9dKnOUzVMgfW0I2kw0UJSCaPreLupJYyMJ98Q1McgP7bhTpeJjq ssBqANSxjt8n21hhFZlZ6BNKczTdOiSGpukVvR55MGg5ye7T26B4YdGQ7bHEfNaJaVD4 Bs55HVZIX6oTS7RpKVmZBXvlvs/9KvoF55hM7M50aI+tyhzG9evO+jGpNYz32882tWUT +IQ6pSr9NAb0TmJza2g/zDgFaR1pl9Wmx40ufbRusNNL0lfsPTxHAibBn1+tt8CFJMEe MWwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720825; x=1721325625; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7irtahaUgZZ2kadtdQTAIVJwXhey7Hso05gQMGn03JQ=; b=EzGDxb/ZSdjS6rkCrKhNcsoQqU4WaRH0UP2no3oGy1oEsEHDh/ZZ2Ekj17o5wseJDP 3AvQYaPmx9qS42YJIcx5tNnXFlMmeU0k5tDwSa9q5p4+OLjYYOvSfNgeJthvKsdvuSGZ 4NJnZ1/QY2JTcbNfORVC5PcLMq+BfJakV0OpkKedWncB3trW7DI/I/r3R1g+GVLbYBml TQEXj0j1Rg4hXB60hbhYSoJTQoiM51wTEiMMQcuOvYLQOyPyY1jsMKgveOsuD37jBaTZ p4Sx87Pya24+BaPh2H3JhyHNS9olBCZrFECyRLRYOyNKaHfdH0+Sb/ezzUqaPSG7Svjb zVPA== X-Forwarded-Encrypted: i=1; AJvYcCWbjgdIPZxmspGLx4J8ng60SFwza2H7t0r98lZymkIQAJdwjKgggyFu096Aq3plT0NyWVdoO4TkoIO5RsIrLCN2D3wxpZLk9UGBRR9LhLai8rJzVJE= X-Gm-Message-State: AOJu0Yxe5C/IN5VEG9CyrOyB7KASB+WWQkEDsc+fj2Z+eDbW+MrbeHw0 15i6Jer2uJk4nG9NMKYjxQF/221N8lxyhFITKaIbuUm/8bx7NRGrLcOIaFxxDHRPSePt0AUoeno LkkrXpA== X-Google-Smtp-Source: AGHT+IGMj2daCCdfqUIMVyxFiaBOl2uNvUMGL0sEZfXJ00x70OsfOTwTplPhBU9/aZ/vlnQv3brgWNx7JDSm X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:248e:b0:e03:3cfa:1aa7 with SMTP id 3f1490d57ef6-e041b03709dmr19480276.1.1720720824552; Thu, 11 Jul 2024 11:00:24 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:45 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-6-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 05/28] perf tool: Move fill defaults into tool.c From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110025_949618_F08A4127 X-CRM114-Status: GOOD ( 19.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 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 Thu Jul 11 17:59: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: 13730961 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 B8828C3DA45 for ; Thu, 11 Jul 2024 18:02:33 +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=PV4lXX4iwcFCrdWdTRC0gdlcjS CwDue4tu6Moh+doWaL03HpTAQdIZRvwBKjxqGbrEBIwvQseYEkAhOOpmPQz1chu8S+wsCD7GKrAJR 1389iy87FuMfpWGbGkGmwuHi2gh/oP7RRE7k+CajYp+GiolCNy5FXznUEpnh48Y9utnXBu7lK0wEE 1BM3gp+mM8yoPDAhnCYBgV7lowIHEc0vpQ6SqfcN+3NOsn92rxQ2TcyqRgeu/xTHSCMxmzoE7psn1 3Z4n6v0lK1RX/DFTZ4gGqg2IeIk0ggqpGrdf0UWyedJidvbKdX7WfW84IUmEYFxDm+vRJIR7M6cUi 7OrtaVfw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy7Y-0000000Ex6u-2kPw; Thu, 11 Jul 2024 18:02:20 +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 1sRy5k-0000000Ew8Y-3DSM for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:30 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-64a5503e253so19837317b3.0 for ; Thu, 11 Jul 2024 11:00:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720827; x=1721325627; darn=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=UpfxZxaL1TAvoa7EahsUSRk1dE0Pi9tQBj8qBN+G7+zHYGdhmTHWh+1wW3NVnCRNCj M1nGsmGh9kPacKI6d8v+252j2E2IfCC/nqqSopLvX9Xyc2PIzOuZHfdCJqbO5340PmVO Hl+u6w7XWes8GriNeN1orzvffdFiWEkUKaICc02vQNN/ZgFkkZSJca7NZhrVcFVw66nb OrIEsjEk8qHfM9e+e274RYLytBmRkqeZ3oBIC2y+xHs/ldRb5G79mIvMBtfkSWM+16vM J/KKQ/ejuaXKtwNtocL+JCKxMTLtAAqbVToepFb52AQNgPuCtvXCCgIPGsdSUBmi54WX X3ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720827; x=1721325627; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PUbNGHbJusTOA2CgJOpkojrr3Ag9eG/HXr7a91E5F44=; b=HQ04YpjOXsiBGSDj82PowSeO8r3Dk7O6mPnr4EW3VjXAiELGLjDPeby8YMHyQM4dhZ F/joFi8myvEpFJMUkP0ICZEk+QwnIjDUC9BZv+fTYtZDDkx2hNYZW04BlCWxbMr+aJX6 bcjm5OU2X+WumdI5RC9f9u73ueopK5mbl5nx1L/oynf+GjS7TnZUNYdctkFq6s3v1/YQ +OkoLeepHEyO/CeRoogJDD47dj6R9vC0DxWSKwoEulUoYAcS91osW8bliMAvXC9i3WH5 M37Eg5suPF+8RZ9hKvfqU+yVdAKh60iqsBJSxbePV/Ee1tPciJ2ZIt6/PGxpa2oyVkDG ZVbQ== X-Forwarded-Encrypted: i=1; AJvYcCVmdIojtM8eiHi6ZkD/UPt9PeDqpbN5wU2E1VHUL4JwXWTWiaydwT6QvaN7tnlNqn46VCIEVMTt2C0C0f//EfVRyGsB0nmpT3nq0lxN/7RBX5Pv+TY= X-Gm-Message-State: AOJu0Yxb9PHtoMUJcYWadYK4JAJyCRphF6LfqLo/jGbxf55adbgxV9vA +0OXL37K0ON2lMghgXEUXl8jNZbbZjf+cD8HdYibiPuWonRT0LI8VwauZ3IaNZgXvb7dtk/pH7H 3l0FO/w== X-Google-Smtp-Source: AGHT+IGpjmXnPZG6ET95BcM0LX++X4FSpZehPMsvXd/XHk3OIv4vX9bTses9QahK6eBa9XlUvUAYslXgj71k X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:360d:b0:631:d4ea:3749 with SMTP id 00721157ae682-658eeb6e079mr421397b3.4.1720720826737; Thu, 11 Jul 2024 11:00:26 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:46 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-7-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 06/28] perf tool: Add perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110028_864793_678AB4C7 X-CRM114-Status: GOOD ( 12.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Thu Jul 11 17:59: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: 13730962 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 53343C3DA45 for ; Thu, 11 Jul 2024 18:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yTWyT8gKTKays8rE64DnYrzhErijM5o6wos0PD63SLQ=; b=m77cfb19c2ToTGmfm0XZAqcqKN aP4+EED+aamVwUXCtCmBbqWYwnHR+rv0vVrRF99mdC18Psl1qZCr21s8aP+gH7g6N9n3BuPgUmPHD nh4zXLDFdPDgKzT8lhVg6nnY1uDwO1QPuIi+HrbIM2z5f+AScnjLUKsydOFoRuiXVcycpP0EiO5FG mc1tDgxddCwtpeqwsej0mIFU47CCMF8vuOZpYjFUrsjuKBLjdcZyvPUUcW4Et5TTraD6dseP/fEv0 qfeDToBgNFRL38zvPsIxS6EVFsGHO8n25Xkzvm4GWnRr8FmMJfIkAPMUI56pmdL7C7UGXC05bt2+X QAvvAovw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy7n-0000000ExCf-3KNH; Thu, 11 Jul 2024 18:02: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 1sRy5m-0000000Ew9Z-1rlG for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:32 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e03a694ba5aso1728163276.3 for ; Thu, 11 Jul 2024 11:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720829; x=1721325629; darn=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=WonyABaazvgMQBNPj2TEPZP8bR7DlVrm6f5gxqYlXtoapmb3+7dewj5Y0P+gQ85wEl bWOah8aLG6ot97vitgwBFPvIpngn3YpUHMJX4FeR2KNqUrTJT9IoPh9/Kbiuz5498cAs UEdrXyhV0GSF5pcVhyGGQDH9BpNuuYIUG71/JtLUBNZ6NpG5/Upu8MJ6FAaEdIRx49qD RRVzgm5W8Q1VdXF1c1paNbIVkG7AOz5TJzm1wR2rdTgU2OjnpULCV95bPUyl6rVbSd6R uMi4oqHHq2CNV8Voi45kmBjpKYKH7NkJEQ7cjdsaWAh2gAzFZuamCpCzU0peAKE+SMuA veUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720829; x=1721325629; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yTWyT8gKTKays8rE64DnYrzhErijM5o6wos0PD63SLQ=; b=KDzVuveCweNv0cJ/HFaPPtVCdfB5LCIeYSOLowFk000lBEAmLHxFC0KQzR0pZewDMO GqP2yK3hz2ADKu4DtOvnuzgULgiNN9re+rRBAvdO2sX1/c8gcZzmlw77zfdajPg6r1zA zWfkbH4NT2pgzq1Fpn16kzoWNN5ceFN25QsSHnSR20dlod9NBK9NV2FeG6RwEl7HlOCu RY5eUdttR8Aduut9AZNazL0n2qaJ3QZYlJheiYr5fHbH53uYvyv+L8J114v0BmW0l/qQ JJYsMCu2OQk14WIxmA6SNHz4xP11jMVznYz+RGJUvHON8UiQgbLpOJIylNIFzGPJYPbq dqbg== X-Forwarded-Encrypted: i=1; AJvYcCV/F2pbj+gsdhXL3cZz50ppQljzbulvWqT0FPLpMhWwujsgY6GJkmKO/ARLrPrwaNkxka8ZrxYwZXh8IISMkMmzj83/0q2W8j7JZ6BzamOoMsDTaK4= X-Gm-Message-State: AOJu0YyF2ejUjPwxKKUxCvYNFU7hIsq6zJaDFyoCCDoiGJHrwJApw92G XFTOoxJzd/IDLnjVzQzUjpEu5KOJHsmtSaGfaXgVkclmo1+eAVmNWD8OaA33wJoPe2ckjvxB1ko /gHuU1Q== X-Google-Smtp-Source: AGHT+IHHvO9Dhy0kBlcS6+TF6u533W13vm3/nzwkXeSVQqKTUfz4Z3LP7tKCWbiDOEGivVzU7ZTCq/u5C+Mt X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:2b0d:b0:e03:3cfa:1aa9 with SMTP id 3f1490d57ef6-e041b1134afmr21767276.8.1720720828932; Thu, 11 Jul 2024 11:00:28 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:47 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-8-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 07/28] perf kmem: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110030_575160_4C47CEEB X-CRM114-Status: GOOD ( 14.62 ) 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 Thu Jul 11 17:59: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: 13730963 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 E0CA0C3DA45 for ; Thu, 11 Jul 2024 18:03: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=FzYClsD3sREquZ0ApOheKgsIb1ZvzAHTtY7Hmf1CzXE=; b=HlIUg6i/RMr6TZdz38Hfhkt9li 8aHp6Q55JIMqNLfcgYlzsCYjnHiD+16PjqcXEUWmgtoOREdYOS0CJHwyDnM2eUGkgXgRjFrXYC5kr fLvcMkU319XWwamlDpD511XSiJGgHbfmcxUlD5ZreG8LwSwiHW7xXt6cHSyzAYA5yeTrvceOIn5YA OX2dPkwAO2sJABgOEeGnI+e5UeFbPlwqaJp7Jv5U0yoACvR1uAfglKDiqVHdgtCHZFM4AqNQ6h3VC hc2wnV9Td2vEgdZt36DyID+mNTJBHIFhWPQrodIhC1B7noG7SeIAIjcJRjOSQXxkrgEmU5K/vZtG+ v9WEfG8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy84-0000000ExKL-16hc; Thu, 11 Jul 2024 18:02:52 +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 1sRy5o-0000000EwAv-1X7K for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:34 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e035949cc4eso2127305276.1 for ; Thu, 11 Jul 2024 11:00:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720831; x=1721325631; darn=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=Qimo+eOmYlRY+MrypA2AONR8OmKYUyvUrkz7KhKrmgNzcmsQ7iJwJVsepiuA1z5ww5 OP0XedHOxa/CRGqtVTcKVCGMlKXMMKEzLOEK778UrjvpxizSR+e2fu1H0vyB9GdvShOo lKPCOK1PhK6slNXUCWQN0ntvVrqsJZQL1qcxvJAPzu34OE6Utr4tKpf1zeAWxWyfwrGG t6fw4kjQ0X+bJLAevNsJinwgGAyrvhqBbCtQE0RhrDlVzLd3rIgN0LZ2tv6PNEQcajAq f+MTm0byE6IVvSM12R4MDYu+pSGHAPiTRoueHcUoyp4Z2GBORSipMb696LxJEVCyakhs AsIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720831; x=1721325631; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FzYClsD3sREquZ0ApOheKgsIb1ZvzAHTtY7Hmf1CzXE=; b=fMsfgqlIUd93TXchxIPT8sLooz9BE/73gUZsaL+KSc4PPBObaGcZDZATc56PJmwvl5 jk1r7W/HJ2fWGus3ZqFpegQBAVQJUFWeoj5FNnroHubSOHY1AlCk8eoQd/r8katmaQCz FdQTLQByVvfhi23m3LzvZn4IWXScG6Vxd713M4bLliHuilyT+bYU4GgFKlYYn8d5XzCh SkhjCxnZymSFEKhYpcfL7KrfAjgcVmIlGmoAvdM794HHWpbQ22T345CNjPGU/cuN6MnJ YBlwsvbVQI9SjbCBVidrcWW0bTDdBsB45Soy+PfSMlFc9FCVpBN9rxYwa+vndnEnq9Ku khEg== X-Forwarded-Encrypted: i=1; AJvYcCV2kIHqnHzYROlmgi761DOXrqmgT0QkbulIlYKYu+jtrcwarZAa1IOQU8k87aijr+muFj63/hjZeg3Ih67d6JQvzyas4rKuHlhtC1+BltQfUWSWf2M= X-Gm-Message-State: AOJu0Yy8VkjLUf6dDMGoEhdTwC6ovMTpqpZ2UYIjzvtiRe9gx2aM075S RM4KsDVU4KkoFRhEykC7bjdKZp8Hy9TPxmaJLIYhovhGSQW5NJbNZKDbmpGvYDZivLVsKihia9U H19VILA== X-Google-Smtp-Source: AGHT+IEoRhLEoKiYyvi7r4ABe+97oJFK6E4DcbiXpAicbuYG+DrIdJXbjZPDGV9iy39BHmd5HC8B0tefOmQD X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1146:b0:e03:bbaf:94 with SMTP id 3f1490d57ef6-e041b185a52mr799592276.13.1720720831039; Thu, 11 Jul 2024 11:00:31 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:48 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-9-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 08/28] perf buildid-list: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110032_459900_904AE8A4 X-CRM114-Status: GOOD ( 17.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 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 Thu Jul 11 17:59: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: 13730964 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 9F3F7C3DA4B for ; Thu, 11 Jul 2024 18:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=byfF1KS0n4MzwFOMTsFSRoLAA/Zhxt2Mi8AKEzVn+O0=; b=A3PMA/VnYhO/mcSCi+SLNFroP8 mulNYmMaCx7fe5V8zWljkVkPUW3CmNqj5dnVy7gT87pqr58VdWk7WOjsmEFT+DJAUT+gKIvre6PwS zoIIkIvdo5qDtLXOKuPFqnXCWEOIUffwvbXWCKhC0nqUPb/q2pnIGZKWgtQtIaVhlclZIbxxC3nLP xzedQW7vxGZfTCFHR1fv+d7jk1X7fBt96frTqaPrjf0qI9xW2rij/7YQ/hEmCf8lZG80BVVI25yCi EqVnFe9CuLyW/x/mF0GfvynybhPxMbodojaTrwHF0mMkMTF6ySPF5Neuq/133dJwmVQOk/XgxcGNe 5u+F4W5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy8J-0000000ExQK-2930; Thu, 11 Jul 2024 18:03:07 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy5q-0000000EwCB-2GlA for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:36 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-64b9800b377so28065857b3.0 for ; Thu, 11 Jul 2024 11:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720833; x=1721325633; 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=xp2s4AaM7kUJR1G+hEr+NtZcGVYHZiJ3rGsL7tujDj/A9JUl+hxrK440pA91NWvAdp Pk9skDMoLufUhbjRMcK9l5sxMEUYgI3jvxID8cJ1Z4DCK3lLAjK55lE/uDy7AyzXWbFg aP/7UDkqoKq2Ckr0KT8t9aCX5zvV24g+7MNzVpfGdbz2CH7NKjU4nYVc5jfr+YhZOWai 644oqGMrmlfSyNdV9ys05RS7kD1M4BwCpiGavLxKUlVcY9uRE537i5fJ6QwpG3i3quVt TdeoM1e5iIvQrn9+UxypgpZo5Cu3DfU6L22Pc2A26igmAQ2QbUqbYLufJIxDGPeyALus yFIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720833; x=1721325633; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=byfF1KS0n4MzwFOMTsFSRoLAA/Zhxt2Mi8AKEzVn+O0=; b=YPwRCrASSdCvDSwKGV4XJMIZSmAWIj8Mp5RD/sCOkWqUqb+9UIRfMReihEBE2sFtDK VOntaUdncqoJaEU8k/747BU7fX9ko58D3ztOF82CbuTDLGzm7Xhl/jmDi7dpQCw54vsO oESxVnsCN/B+njKryx4WSripnYLZYYODpwOPJzrdwfnaMI1DbTWaTktYoFMd9qTBiZd2 uWga1G+Wl2GQ7yPwcf0QBsEClxoYh0B+snruW+DDMd3NnySqxLsYEUeOut/WTaPEYyLI pVKDumkjm4lHf4iK9smSs4qzjKxB7yApVW025xFl+h/KJenHCGNFnuoe16H1CxiBdDBU uD2A== X-Forwarded-Encrypted: i=1; AJvYcCWrIh92/6McU7KFJ7AZpgLYbhZbQWCu4yt1gCor/MsaVXoBvCqlDhY15roJuhiXxqRyyrcyMxtgpAqqoz0SZ7tKmxPad9OeNGaEmNs265Fp3zrM5AU= X-Gm-Message-State: AOJu0Yz4lZDNvi+0FVhkBhxKa6g9jotRaQ2Uv11jbOCyDZYmRtVFzfVx BQo5LscTFbWRy74kDV5TNfSF+m4t65vUtKWAlnvAtYg8PcIv8m9Booq6znNxhtqY0JWpJmZcqxJ brHXWIQ== X-Google-Smtp-Source: AGHT+IHr46EqKsmYnSPwqHtEtQqAbJbduJBfkql3qcbWmp+qi69+FUgSATsZrC/sYGw83ur4i+SBO0yT6dWE X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1389:b0:e02:f35c:d398 with SMTP id 3f1490d57ef6-e058a707db8mr1062276.0.1720720833194; Thu, 11 Jul 2024 11:00:33 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:49 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-10-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 09/28] perf kvm: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110034_611132_91F8CF8B X-CRM114-Status: GOOD ( 12.85 ) 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 Thu Jul 11 17:59: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: 13730965 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 1DF8EC3DA45 for ; Thu, 11 Jul 2024 18:03: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=jf/366lvU4AUPtbGBpn9zhF7c/C+EcohgCe44YuCQ7Y=; b=Mnlx8gzsi8qUuHc5/62M1ERlYV 5TzHigfv9nGaksJALnxphvvdBlASAKGBNcWcJUpUBni2S2Y8jtD6skCM3RclXBUIAsujEtq7KC5gH tFb+0pEio83Nqg6dNbDDUItzNO+itFwI1Fd73Ppfe1j49o+xa2lSAhw3ifTrWhVPIHE6SI+eWTlwH 4RB0P5shLDuLgkHQ8ZNRZ7wkrY0g7ig3cOMqzO8oBNM7Gnmx1dRrDtlYhMy/6uEoZTu0wQvVrYuEK jIJMR7qq+LcK+rr+HcHd+NMqW8Y7EaVGIvBf4V/FtC8Bo+47/xNRuJv5WqVe0wGZ2TM5LomO82SYn ICJWnIWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy8Z-0000000ExXf-2PPL; Thu, 11 Jul 2024 18:03: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 1sRy5s-0000000EwDF-2lcK for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:38 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-65be82a3241so19001837b3.0 for ; Thu, 11 Jul 2024 11:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720835; x=1721325635; darn=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=qGH+0FEPRirPrmMZqovIy5PsQGpS4xxe6D2MWoFH1UuL2nnsVZoK2B3bvPTIZxira3 WZQ/NoiUchIXJkvrAAR0uOvgIg9V+EmRjOQVj3gzHJrqU5B9vofWM5xYNX4Z3MIZY6VV c5zQtDGbYFaLaV5LPH522YG4BFYDloj4Rm/+clnyhGG5RFrBM5bj21fVhGpQbBouFcQB T2nc8RDIitdh7LESUJsMjWkPWZoQY8vW2ecOYHv26Et9GBuJ5XYryKa7rTYCJiS3a0UT 0bYw+KgSAm4WfHsVsreGwn2anlgtU/wCq1AC5ylMIPiJ4qmevDCYcHAKsSn2y6O2cqA0 yIzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720835; x=1721325635; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jf/366lvU4AUPtbGBpn9zhF7c/C+EcohgCe44YuCQ7Y=; b=NFyviQxhps7kzUJNlw5KdDycw/SYLI7sSytg3BK3SJN4HednjPV9lADH76B/hqGUAx 9cS/URcbRtjSPqiMJljwoH6z8krf+O6holMvp31fxTtDCi5vYdp2iu8d+AjIShgWbIpV aPNlPSzNUZhZUhsUbnlKXKGS7ApwmxblJndRajts7TGjGPRa2DDS3cLIb/iI20eHtUrL +v78Y97E9P6LIq40EemDCZfWhJZOKeU8ZNROcJnUTgoeOF0nT5mLEupZKcdEVPpVgQQG vJwHCI4QSqMpe+l++36CHFdSTXfEO0SqtPZhNqrLDASa7gQyUUcBz+RM3Uk31n/29c7v lY/g== X-Forwarded-Encrypted: i=1; AJvYcCU06mvov3FbagYQ3Ws8KFp0dBpJM3YlQOS1N1E8LlzPuC5mJVOi1pqu54FqdDC1FYnNIvVfoaN7MpqW8n8iDu7uvTzx+KsH639LS00YCyQdt9AeJNk= X-Gm-Message-State: AOJu0YwvCZtafE7vrtkfPG1hTtd4Pi32ciR2pRgggtPjZn/xtvdLG/e3 NJ7Ptmdt97bfP+257ujHcZmIHiQwt3qSwsHfRNneaRSm9gbVHlsyHfLLxrfZ508LvCHCISSV/nL 6SmrWZA== X-Google-Smtp-Source: AGHT+IHgRRHzENtJjdaIKJzPMb2H1HDZVK/Rf4u2rJiQyfph07pK93KyOLIPHnJjFuZcvCLU340y0vsp3u3Z X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:3510:b0:64b:5dc3:e4fe with SMTP id 00721157ae682-658ee699c87mr1323597b3.1.1720720835320; Thu, 11 Jul 2024 11:00:35 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:50 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-11-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 10/28] perf lock: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110036_813750_4D382C9B X-CRM114-Status: GOOD ( 13.44 ) 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 Thu Jul 11 17:59: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: 13730966 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 27754C3DA45 for ; Thu, 11 Jul 2024 18:03: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=h8vxN+BliJztZySzkr/g5CS+2PgB0g7RSTmLzIMrgEM=; b=S4NiwY1KqeOgNezojYiQRBBHM8 +mF3gVhT4Gd6dXrfXNG2JhB0wm+tkm9DUN6cwCKv0f0e2m9R7iEoYrTUOW29qdwJ6y0r02yZqwIda QWXJG/5CPjZxQOyWwOJyi3ez+SzJcu3MI8vgseB70B2dtWFm7Un823J+Z5GrQYSzjwxNL7PXqtSZU lll2vUObp0Petn7iEMYpNzhSXyWcx7BLaP61gTbxJA4yX/COfW4hiwUQVDVjvLFuLuukJAWA0K9sw ISatuqR8I6Viv718eHYDvgMSgW8mBf/RuhNumRrZgVkIdE9AovzqWYXAjUn3K4sK1MXZSMOEZ/VXb uknVuyFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy8r-0000000ExfM-03Il; Thu, 11 Jul 2024 18:03:41 +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 1sRy5u-0000000EwES-2k0G for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:39 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e056166e0a6so1757964276.2 for ; Thu, 11 Jul 2024 11:00:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720837; x=1721325637; 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=wR54QtpssHt5eK6ldLWeo6JWctJIhVixV/Eq1gwK0BYpVD8hO+7ucCOmrfPkJtDoZv Hwcg8QDrRB4J/TPeEbswuGBXHVAyk0pS7NXdT3lnQwMfrwc3WdzQRokIluaBOBOJvtdV VyEN+NyjYeS2rJspfI/YybUGpjcc+rxUNW4DRPJ4LnBs4vHOYTNk1zZASSMzQAD3sItZ Fd9jxQS4IHnrCrwNClB7HLfg8n69NpyKAOhOzYbbkDoYk+Ub51ifP0VFP/bb14dakcad EBIlZT/24Rxr7NT2jPCys7K1WetvcB0hLWoaMacPeWpNiQg2B33h/tiYV5XsrOXkOJXW r0dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720837; x=1721325637; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h8vxN+BliJztZySzkr/g5CS+2PgB0g7RSTmLzIMrgEM=; b=duPiEua+oehhlHU+9rEF6iFwaAMSIw7qVIG9ItiDlc2q8YtEkyYFdRNyuMIUS7Tqf8 HbPF9s9/9p7jIW37AX1zx1tKST2+HXT9RYs7EL+gcZLZ/FetNP64/FJVqWCW1QDRisBj Ux7jCutku/qhQVyuWX2flvfwTIH0LlvVsLDeWqtUvGXHrUGdk41PbVE4pwhjnlwqIZEb Hv8XegG+IYPUkAD0JjRPOJBuzzGr5029OswPNFHyqCuN+r/y/TGBR8kqBQlgHh6hEUTA 0PkpXOf1BAxPWyjMLQBRReHUv35sQqUTI6llZkCvfHQ1IVKGu4GbZcU3qXT/hDDofvEZ JVZw== X-Forwarded-Encrypted: i=1; AJvYcCUK+LXKvkDgSw0WhTl5cDKQF8uTaqwFJcltFFa0pqe6C0jWL1Uh7CC8HSTM3NYtPkdrR37j5rYbZ12uSISP707+e+ugw4/6TVKxe99bSDTMpqW0Hjs= X-Gm-Message-State: AOJu0Yx3ljLFCepDTy875pJgwOrZF2Yi62uzCWVv5Th/CksubtHjxvDa e7eTGfk5ORJEa3sMFPWKBZ6XkZ/UMfdxZxmuNb0Vszksk5RTsg7HgwVh2YkVXz+Mwa5BA2SB2pZ aTMuUHQ== X-Google-Smtp-Source: AGHT+IHI3dipL7Tp3GQH7MxH3mucgQeoKyx/ymoTPxvLOSdOaV57AwCmKrqrRNCKs1TjxRfG+nIlfE0jSUsa X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:2089:b0:e03:2bfe:40c9 with SMTP id 3f1490d57ef6-e041b032f48mr17980276.3.1720720837264; Thu, 11 Jul 2024 11:00:37 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:51 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-12-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 11/28] perf evlist: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110038_721995_575B95A1 X-CRM114-Status: GOOD ( 14.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-evlist.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c index 7117656939e7..818ab21c3f73 100644 --- a/tools/perf/builtin-evlist.c +++ b/tools/perf/builtin-evlist.c @@ -35,13 +35,13 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details .mode = PERF_DATA_MODE_READ, .force = details->force, }; - struct perf_tool tool = { - /* only needed for pipe mode */ - .attr = perf_event__process_attr, - .feature = process_header_feature, - }; + struct perf_tool tool; bool has_tracepoint = false; + perf_tool__init(&tool, /*ordered_events=*/false); + /* only needed for pipe mode */ + tool.attr = perf_event__process_attr; + tool.feature = process_header_feature; session = perf_session__new(&data, &tool); if (IS_ERR(session)) return PTR_ERR(session); From patchwork Thu Jul 11 17:59: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: 13730976 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 7A8ECC3DA4B for ; Thu, 11 Jul 2024 18:04:06 +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=5Ff/gAGDG2aAEbUu/hDCKYzzmvI/uHVZRadY3JBl8Rs=; b=s0Ca9NTFsZDJ3JQ5wA+TmqyG6Q bHZ96qlVK6i3ON0c20K+NCuHXFbpaHx5mSF3VLqgIfcXktg2Lc6p7Awq+hTa0pOcqmiFwoaNG5Wp7 sO9h0owAALf2LfS5GEK5Q6ZguXPJRx111LlVEO4MU4mY8yFroVDlrUoMFmFiE1fbXKiKQclWYlA81 oSAdQPtLg1rSnpAhdfUGT8RMMJQpGRArmiC21aoNCooi8xRf1s/jmbVipGLW3wHnYz12WKB2iwxoV Mi/4VBKiAQOoW3az+HHfgr2SdlOWO6uYxxyLPe3+dYaxGca/Egw3KvrGr//2TTyIpPj8/9/LQZqn+ YFoyR7/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy97-0000000ExmG-0ICk; Thu, 11 Jul 2024 18:03:57 +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 1sRy5x-0000000EwFc-0KxR for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:43 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6502e4c5aafso13248377b3.1 for ; Thu, 11 Jul 2024 11:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720839; x=1721325639; darn=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=5Ff/gAGDG2aAEbUu/hDCKYzzmvI/uHVZRadY3JBl8Rs=; b=fsABz7hG9J90sJyWIrgJeCzifGHFDRi54xWCXB84J2IhN/C8elJuqZJtZEv2iGbBXn 5B7MsQzQMl8NACxNuicz5+nC9dm3q8T9pIrXYYwbnUZ8Lw1036UzYCmbzxq/T2853fhb d+yiZUxgTW/UBP68XO/BA2o2L5ekSoxm6ln5tTjJgVb/6hLBjmzb5lYLYcFCVc7GGLQT AnviihMkZHpF+cuxj+8ZZ0AtHW+5oUF+be35ecvyJOORKYwEdbBov+iPoegawUMik9iF v5EY4AuGibhEdgjyaRRhnYxGELC4lbr8cWFHsYI44FTqVzvmvjzoLy+dMIllWHQRezyr qYaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720839; x=1721325639; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5Ff/gAGDG2aAEbUu/hDCKYzzmvI/uHVZRadY3JBl8Rs=; b=hEuqoNY6QY/mtpnXQeimS+y1/FC5WLluu/kkvvJB996seif0GOyTTTBU2YvMlfRjgU i11/ky60ckvICBXqhFhIoqn15rv11QmRKeLqsj3Ebnic1R8HQ1OGasJhytzNab7aM0c0 R6GjzO0DfFj1YnKFhhZ60ckh1Glab3ZceygZB+UP7PAV2yt1i/fq0rqawLAVRUsjPuAY 5OSlyxIs457Fb1H2FhHVmSBQP3q1gSXZlNkVvHB0Qby2w5i8VpDncCNPmqfECWKAnQOA xqe9cDUoqrhza5h0L1/rGkWW4DkAQP1oMa3979nX9N04c6VfjnIEXV8olJl1kxzbNWRu fDfA== X-Forwarded-Encrypted: i=1; AJvYcCW7UysnqCw08ZzGUBZLhunU86JaVu/XiQny71j0X+fuD3Ynrj6pAWfZ5avtf6PyPIRds5n0L7JynjKDnCn9Zk6+gazSPoUzOf7mOE1ORkxzTSAyinw= X-Gm-Message-State: AOJu0YzasVijaIlKblELECwl4gNYlj6IHzyq/vg1v+FVnEtEfpceKiEX 8GBEIZLJn04Gml7R0ggN4a+/ZYsbJOhc3ZMBZuXbjeoiB/KNdoRWTJ+F0npcBCUhCpJPE2BQgxF pzwBfsA== X-Google-Smtp-Source: AGHT+IFj9eydv65A7J7SzzeWQzPfBnQ3Mr87UOA0hqpnZkLQstHLPEsb9+ha7vzF8KoEQHxSj3FAFxPIHkwL X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a0d:ea49:0:b0:64b:a38:31d0 with SMTP id 00721157ae682-65df50b328amr15277b3.4.1720720839402; Thu, 11 Jul 2024 11:00:39 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:52 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-13-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 12/28] perf record: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110041_195978_61CD5E0E X-CRM114-Status: GOOD ( 15.85 ) 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 e8677f9e1ccb..4b9309b4c07e 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -193,6 +193,15 @@ static const char *affinity_tags[PERF_AFFINITY_MAX] = { "SYS", "NODE", "CPU" }; +static int build_id__process_mmap(const struct perf_tool *tool, union perf_event *event, + struct perf_sample *sample, struct machine *machine); +static int build_id__process_mmap2(const struct perf_tool *tool, union perf_event *event, + struct perf_sample *sample, struct machine *machine); +static int process_timestamp_boundary(const struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine); + #ifndef HAVE_GETTID static inline pid_t gettid(void) { @@ -1458,7 +1467,7 @@ static int process_buildids(struct record *rec) * first/last samples. */ if (rec->buildid_all && !rec->timestamp_boundary) - rec->tool.sample = NULL; + rec->tool.sample = process_event_sample_stub; return perf_session__process_events(session); } @@ -2386,6 +2395,16 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) signal(SIGUSR2, SIG_IGN); } + perf_tool__init(tool, /*ordered_events=*/true); + tool->sample = process_sample_event; + tool->fork = perf_event__process_fork; + tool->exit = perf_event__process_exit; + tool->comm = perf_event__process_comm; + tool->namespaces = perf_event__process_namespaces; + tool->mmap = build_id__process_mmap; + tool->mmap2 = build_id__process_mmap2; + tool->itrace_start = process_timestamp_boundary; + tool->aux = process_timestamp_boundary; session = perf_session__new(data, tool); if (IS_ERR(session)) { pr_err("Perf session creation failed.\n"); @@ -3326,18 +3345,6 @@ static struct record record = { .ctl_fd_ack = -1, .synth = PERF_SYNTH_ALL, }, - .tool = { - .sample = process_sample_event, - .fork = perf_event__process_fork, - .exit = perf_event__process_exit, - .comm = perf_event__process_comm, - .namespaces = perf_event__process_namespaces, - .mmap = build_id__process_mmap, - .mmap2 = build_id__process_mmap2, - .itrace_start = process_timestamp_boundary, - .aux = process_timestamp_boundary, - .ordered_events = true, - }, }; const char record_callchain_help[] = CALLCHAIN_RECORD_HELP diff --git a/tools/perf/util/tool.c b/tools/perf/util/tool.c index cbd9b888bd73..a4ca16e5eefe 100644 --- a/tools/perf/util/tool.c +++ b/tools/perf/util/tool.c @@ -99,11 +99,11 @@ static int process_event_synth_event_update_stub(const struct perf_tool *tool __ return 0; } -static int process_event_sample_stub(const struct perf_tool *tool __maybe_unused, - union perf_event *event __maybe_unused, - struct perf_sample *sample __maybe_unused, - struct evsel *evsel __maybe_unused, - struct machine *machine __maybe_unused) +int process_event_sample_stub(const struct perf_tool *tool __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_sample *sample __maybe_unused, + struct evsel *evsel __maybe_unused, + struct machine *machine __maybe_unused) { dump_printf(": unhandled!\n"); return 0; diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index 897c6c44b6b2..fb7e32d98dda 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -93,4 +93,10 @@ void perf_tool__fill_defaults(struct perf_tool *tool); bool perf_tool__compressed_is_stub(const struct perf_tool *tool); +int process_event_sample_stub(const struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample, + struct evsel *evsel, + struct machine *machine); + #endif /* __PERF_TOOL_H */ From patchwork Thu Jul 11 17:59: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: 13730977 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 21D84C3DA4B for ; Thu, 11 Jul 2024 18:04:24 +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=K3H0o0Q+TT/GdpJKoV5RhG7N+I ifUXrfrNAkOJYJhLdcxRrqLnFyXbxN4G4bozo0vo20vTb8z5JEaK7q6QT9w6P4PqFPLlq3OK9ArpE pmRgeJq0taVZ8gZS7zvwxxYjfHz6uQ3P6zScdPM/Wysr24TNslDgF78QVOc0zC6cb8h4LNNgnjftz 7KplrpsC5klUpZWpgRozG0zNXRGnZsdxp+Ejlv0jeM3PmKiI/eUoy7WoOJqkTBSwwS6GkOAM+qdkA UxnL64ttCvfLfcigCkggUaoLmCTEP7OKQyj0oUQo1P5n28rSYEn29vhBC28uoJatS3ZIqXnbxkHNn zLGG425A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy9M-0000000ExsQ-0vf6; Thu, 11 Jul 2024 18:04:12 +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 1sRy5y-0000000EwH2-3UIA for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:44 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-650f766a1c6so19020067b3.0 for ; Thu, 11 Jul 2024 11:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720842; x=1721325642; darn=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=u7+66I1WMF967nzYVxEJyNKsB8u82cz27G8Y+t1v1SK1yHpy1qhmcB4UpfArVtk67X FgEXcUDNcmrk3MobVV0VwE5C+GEVAJgveZ07plLsGhZW+Rqf/LTFR0EGgUQEqtEElYQf /SWDgeKFwzw1OrAIWkG7a6WjJ9kb0fJwxzNJuDYdWF0ct4AY7/maFK2xy+CgioThI4ut x+ub27bMrn3NENbktX4JK9Zw/N8GyFM3LMjTQInHc+9l5XkeZ+zkyq15nZFrl/F1wiE4 0X8dwjt75nolbV6fQZ3NTB80GhCxcxHkOR5D2AZifDiWr8H7L1brv5LwDjvE6cWSpHZJ DClQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720842; x=1721325642; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GLiukIuXpfj1RuwI+7tVJ3j4buaKUCfjcNd2gIIAnuE=; b=WEORZwKZN6zU4XlAU3XhQO/OXch6Fvh5zX2Mnumg+YSQEUv+JOmBOT21el4OrhRC6J a1h91xteybjMdRSEEKcyhPbQRNNJUHDhHX/7oGkF1AlZ9pCEF+RfdjtIUrx1oAraTmqq HtjYLrY+D0V5JfpbjB3J3X5yiz30NtvjtOsZCWMYoHgLTHaZABOkmFbsjmVcpRJcgTs4 fQSFN7YTKJCnsKwRBUGAcFLowlSpEKI4gleG76xgjy4tdivqCkJTAW+7Q7QaDAefh6R+ ecJEqgIlRIWfKIpL8bPLI/RRfPESuAcsPlu5tGQ6tqyC+ipoOuHGJP5aIm0v5czOn3Z7 1JDQ== X-Forwarded-Encrypted: i=1; AJvYcCVNlWzGMAIEQde4QhyFNeQCUbWpiXhKu9yijFRRXhYexehseOVTHccsm0vI8VMhJfzY1iKt1r1TgqsFp4QtFD6mYpIeocg/LyLttf7FZ+yUMPA2C9s= X-Gm-Message-State: AOJu0YybjZA2Ih20aaFBfnIutHKIgg1mjhkrxWMAd+X+igr/Ax06Nh/V WSdOvAddar3LJbJtNB5tZp+3Oz1C7ih2x4pKk9gswY1GQ3VHA2oVCKIT2OsQstYJr++J/1Lz2FK MR0Foqg== X-Google-Smtp-Source: AGHT+IEXF5wj8ayTVT9jirmz9sHwimvl3fY+5kUcaEScOacOHrr5WKsgjJfB+7NPgApJ3Zze2HXsuC0tMBh0 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1002:b0:e02:b51f:ceac with SMTP id 3f1490d57ef6-e041b1415d3mr391043276.9.1720720841581; Thu, 11 Jul 2024 11:00:41 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:53 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-14-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 13/28] perf c2c: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110042_953103_482D8EDB X-CRM114-Status: GOOD ( 12.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Thu Jul 11 17:59: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: 13730978 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 6A1B3C3DA45 for ; Thu, 11 Jul 2024 18:04:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: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=Q5+OwzhYBvpB+olZDuQtSh9InN ko4BLGckBbBgUQFJHKeH+m9E7fWkVve0cupvU2hPl1/2mdkYWquG6LhnFYoks7S5UZj/IJQhoNXSp ToLm3nm36f0kR0dEFqkAb+zXodenA7YEDbStC/YH1Atc5PmxPaWRpbh2mMYGsioMOzsM7mP8UYlY7 ubfc+18xW9+iQ/MNM0HHOn4UVFc5jeajhE3Pdpo4Rzb8yGbqAAGY13NzOiJezaeOGDvGuj74Ak1JU WgfwJu8NkYgufyE+/WEJwrLAGO6gl7fTFozl2mYont7Eicnj4Cq38T68q2VNtVkBhga1FuzFFWwjk qU8AwILw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy9d-0000000Exzb-2Exc; Thu, 11 Jul 2024 18:04:29 +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 1sRy61-0000000EwHz-07Fc for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:46 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e035949cc4eso2128150276.1 for ; Thu, 11 Jul 2024 11:00:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720843; x=1721325643; darn=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=4Oo7GfWeEx6v6BZreLSwpbSxrww1SdR+zJTzijvovpTqFMJHtwsBMyuKsNuP/u+Crh rgnaWhuaetaKruSxJ/OxwbEtk7B4+xkyIJ3AnLyYE5KYYI3CG75crgYbLuNaVs7oAdvF t6MMMFm4Y9MBdM0X3dFaltY6K3Ltb5jYo3IYHBZJmpG4Tr8hozwGJjy5UfXmlg9TAwNa 7IAqM05OTxm21ICMCKke37IYBBFLYsSDtTnTvQTdJ9WM5Ky8G3Cn6SeF74Sz1KaFjZYo lIIOZUh2eGqy1GddeDTaluN8OLVNDzjFHqdJ0vQAnRgxShnZKpwafGt0CATbuKHGd/MQ 5R5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720843; x=1721325643; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BgJSCF9yLnG02WKUg8SfX7odmyVBKa2lGRMN+iopItY=; b=XPrIhchJ48ll6M2qTi9LoXk9e/6fVoYv2CRPavD0F2pTQIyPqphKEhxoBdWTWHWKuG R+F9LVpvAQDsh6YAW5B1E3gEiMUUrem8QiY8QnoF+9oColoOzkfrtmuWMo1oxR/sz9M5 GUHI8px6CKNmMJZsZcMhwSzIAAlPZR/CbiPRe++PdDiFIolWm+lL1zmH1w6/LbDj7dq1 Yt5XUV9GvJJVKE5rekSJ+Pi4o09nTorOMLJezSkBYoMk0UjfXO74YoHtQoneGuCHsgNo AHtOBXO1RvL5Ut3mV/YTUoDuuo0TaC01KBK/wTo3sUcCLGkdX7h/3U2kdT28d1bTNmB4 Anbg== X-Forwarded-Encrypted: i=1; AJvYcCXxyiVQ+NpBuaVGVZM8xN32xRCALx2rC2VRFGVQ64CdtPZFqN+WS+1pCMk11KaEJ11X+lIsyzlev/YXz0ItBVzagef2ERK+AhEIl659JFFSOoFnr+k= X-Gm-Message-State: AOJu0YzoqBubq7aDs19rOwOEQ/pWrSKXfbqpz6ab4N9BP0/1GVwFxfau nZH8UB8wVnrcujauxg0MdUN5Z5k9ws3NNfABmlox31MXg5Dgttcy13r6SOZ1JQHB8QzINQs6bgo 5fDPquA== X-Google-Smtp-Source: AGHT+IGUZPma1/UNbVlFLgQNB3aw1ju3QFq7+jgs3bRCoCKdY1pYTS0J6J1QQ1ukZSK8z62+IBuYguGU+ptP X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:2386:b0:e03:9d57:57ee with SMTP id 3f1490d57ef6-e041b0545c2mr460225276.4.1720720843539; Thu, 11 Jul 2024 11:00:43 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:54 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-15-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 14/28] perf script: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110045_096452_B230BFDA X-CRM114-Status: GOOD ( 13.45 ) 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 Thu Jul 11 17:59: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: 13730979 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 8DF00C3DA4B for ; Thu, 11 Jul 2024 18:04:58 +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=Wumahog1wwUaohnQ+3K5jIphWr tJVQEj0bVzC6UOJpp03yc7f0IczxhLd+Ho3CV9d7flpy/vRAR/03nBUrFhRUx/s+HLerieQzPWLIG qRFFi1pMEvMZlAYH9RtOlxZrUyJpgB5hiPdW2p6SciuupQhv+xnLYeJD04UJ+f+C9mVPim+8LtNlT n3/oW4tLPCzQaVy8BTRdAWBv6r6NhN426XJyCOqlqAwlRoaT2yQ7prM9bYTCG0cl9V+jOidq1Zqi+ 7fPukS5XcGKYAkKPJfkA5ulI7O/Ju88BPB6vjL0plXkVNKxztADeg9E+sTWOuvdtK6xJbMVjB1Ivg 7agnJvhw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRy9u-0000000Ey8r-3MTt; Thu, 11 Jul 2024 18:04:46 +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 1sRy63-0000000EwJ3-0WrD for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:48 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e035949cc4eso2128270276.1 for ; Thu, 11 Jul 2024 11:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720846; x=1721325646; darn=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=Nt0IiVwFRjVutvWLR0BkvC9JYAzNgWpGYXSXFWINAo4Af4oqaTzjvzCHwRnXCv6pOh d6cT92x/9LW7a1QmctSq9l0wFkoAKz2kfl+wsNzvEg+BZ/O1HbemLVF3TRubqMTRlejL cfOMSbGAH5uk+ugGWRQphZx2X/tUr+2w5d0cLqkBA0uc6cObur2bgchvgzULNVywKKQR 0JsU5oaKb4dJkhtKgv0424Q5M4JEgntUrv0BCHdzvyJtCBwJ7RZahlYLUSGefCMQWJV0 CvKuzu2sRmy9NIdjWQRNNPJZ+bXk0LWRgO6xlMvRQCc+pdvpnvQ5uLPI5Hc6ktmD3tRy HfYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720846; x=1721325646; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+Ae5Vk3XcnDdaj5BKYKsQnIS/haF5dLJg944D3m7A54=; b=nVkIszbWcHKg68KEvorQK/DVxmFa9zWQ7q4aMKIb1+NbFCEGUCWqjH7tqniDVZGaV4 qewTifi5d7d+AnVHxyGUm2JAeyfrv33J9NRGjWQYyFVc4kjc/EInH2Y3cipWjlUKBBvm RdaX009C++SYtyiTBoVXsVXuVZdiEEBn21dM/T4n38FXR7xPbjeFqwQfk+eZ3P3/XLtH azP6sfhtg351AILdrCPWffbyHHcFPuRRPicHUHekqbMPxb2zch0yM7tlajVzKQWsGEev lPFGLaLIMGl0HJCvm6IwWXRaJpYWO/kshjH+m73S+Vrwh85LBNNqmTW4D5y64mfNVCiz 00OQ== X-Forwarded-Encrypted: i=1; AJvYcCUCaVo03+lYVPCqPevjs5vRWu0uGPSai7+NPBLs4hp4Kx9+D4y2dJKOtmihzz6lhtLLZ/DKeGwII8/c3awFIRoxMME8iicqzZZZQBDDqFVDBwtOr1c= X-Gm-Message-State: AOJu0YyFGl0kiV5ZjCv7pmd2mDG1QhdwxH9rz6cj6JWoedkZgjEt5c8o 7AxWrI1uSPvMeVIlD6u2E82RZlmhrG6NyNiYas9zEueyZVoTa1I7Hm+I9KVzntpyoo8xDaMfrcR jcii7BA== X-Google-Smtp-Source: AGHT+IHVhenVRnd5F5tnfG6kCLAubJrvmicfzrrx2Otspjm5CzZecpN6HNk6oOjRDCkpD1S2I42nDbp5QdCI X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1247:b0:e05:6840:178a with SMTP id 3f1490d57ef6-e0568401c6amr349237276.2.1720720845858; Thu, 11 Jul 2024 11:00:45 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:55 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-16-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 15/28] perf inject: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110047_196278_1EC11DEC X-CRM114-Status: GOOD ( 15.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-inject.c | 89 +++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 47 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index be74e2bf1f00..2866756d5060 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -2165,46 +2165,6 @@ static int __cmd_inject(struct perf_inject *inject) int cmd_inject(int argc, const char **argv) { struct perf_inject inject = { - .tool = { - .sample = perf_event__repipe_sample, - .read = perf_event__repipe_sample, - .mmap = perf_event__repipe, - .mmap2 = perf_event__repipe, - .comm = perf_event__repipe, - .namespaces = perf_event__repipe, - .cgroup = perf_event__repipe, - .fork = perf_event__repipe, - .exit = perf_event__repipe, - .lost = perf_event__repipe, - .lost_samples = perf_event__repipe, - .aux = perf_event__repipe, - .itrace_start = perf_event__repipe, - .aux_output_hw_id = perf_event__repipe, - .context_switch = perf_event__repipe, - .throttle = perf_event__repipe, - .unthrottle = perf_event__repipe, - .ksymbol = perf_event__repipe, - .bpf = perf_event__repipe, - .text_poke = perf_event__repipe, - .attr = perf_event__repipe_attr, - .event_update = perf_event__repipe_event_update, - .tracing_data = perf_event__repipe_op2_synth, - .finished_round = perf_event__repipe_oe_synth, - .build_id = perf_event__repipe_op2_synth, - .id_index = perf_event__repipe_op2_synth, - .auxtrace_info = perf_event__repipe_op2_synth, - .auxtrace_error = perf_event__repipe_op2_synth, - .time_conv = perf_event__repipe_op2_synth, - .thread_map = perf_event__repipe_op2_synth, - .cpu_map = perf_event__repipe_op2_synth, - .stat_config = perf_event__repipe_op2_synth, - .stat = perf_event__repipe_op2_synth, - .stat_round = perf_event__repipe_op2_synth, - .feature = perf_event__repipe_op2_synth, - .finished_init = perf_event__repipe_op2_synth, - .compressed = perf_event__repipe_op4_synth, - .auxtrace = perf_event__repipe_auxtrace, - }, .input_name = "-", .samples = LIST_HEAD_INIT(inject.samples), .output = { @@ -2269,6 +2229,7 @@ int cmd_inject(int argc, const char **argv) "perf inject []", NULL }; + bool ordered_events; if (!inject.itrace_synth_opts.set) { /* Disable eager loading of kernel symbols that adds overhead to perf inject. */ @@ -2333,7 +2294,47 @@ int cmd_inject(int argc, const char **argv) if (strcmp(inject.input_name, "-")) repipe = false; } - + ordered_events = inject.jit_mode || inject.sched_stat || + (inject.build_ids && !inject.build_id_all); + perf_tool__init(&inject.tool, ordered_events); + inject.tool.sample = perf_event__repipe_sample; + inject.tool.read = perf_event__repipe_sample; + inject.tool.mmap = perf_event__repipe; + inject.tool.mmap2 = perf_event__repipe; + inject.tool.comm = perf_event__repipe; + inject.tool.namespaces = perf_event__repipe; + inject.tool.cgroup = perf_event__repipe; + inject.tool.fork = perf_event__repipe; + inject.tool.exit = perf_event__repipe; + inject.tool.lost = perf_event__repipe; + inject.tool.lost_samples = perf_event__repipe; + inject.tool.aux = perf_event__repipe; + inject.tool.itrace_start = perf_event__repipe; + inject.tool.aux_output_hw_id = perf_event__repipe; + inject.tool.context_switch = perf_event__repipe; + inject.tool.throttle = perf_event__repipe; + inject.tool.unthrottle = perf_event__repipe; + inject.tool.ksymbol = perf_event__repipe; + inject.tool.bpf = perf_event__repipe; + inject.tool.text_poke = perf_event__repipe; + inject.tool.attr = perf_event__repipe_attr; + inject.tool.event_update = perf_event__repipe_event_update; + inject.tool.tracing_data = perf_event__repipe_op2_synth; + inject.tool.finished_round = perf_event__repipe_oe_synth; + inject.tool.build_id = perf_event__repipe_op2_synth; + inject.tool.id_index = perf_event__repipe_op2_synth; + inject.tool.auxtrace_info = perf_event__repipe_op2_synth; + inject.tool.auxtrace_error = perf_event__repipe_op2_synth; + inject.tool.time_conv = perf_event__repipe_op2_synth; + inject.tool.thread_map = perf_event__repipe_op2_synth; + inject.tool.cpu_map = perf_event__repipe_op2_synth; + inject.tool.stat_config = perf_event__repipe_op2_synth; + inject.tool.stat = perf_event__repipe_op2_synth; + inject.tool.stat_round = perf_event__repipe_op2_synth; + inject.tool.feature = perf_event__repipe_op2_synth; + inject.tool.finished_init = perf_event__repipe_op2_synth; + inject.tool.compressed = perf_event__repipe_op4_synth; + inject.tool.auxtrace = perf_event__repipe_auxtrace; inject.session = __perf_session__new(&data, repipe, output_fd(&inject), &inject.tool); @@ -2372,7 +2373,6 @@ int cmd_inject(int argc, const char **argv) * mmaps. We cannot generate the buildid hit list and * inject the jit mmaps at the same time for now. */ - inject.tool.ordered_events = true; inject.tool.ordering_requires_timestamps = true; if (known_build_ids != NULL) { inject.known_build_ids = @@ -2385,15 +2385,10 @@ int cmd_inject(int argc, const char **argv) } } - if (inject.sched_stat) { - inject.tool.ordered_events = true; - } - #ifdef HAVE_JITDUMP if (inject.jit_mode) { inject.tool.mmap2 = perf_event__jit_repipe_mmap2; inject.tool.mmap = perf_event__jit_repipe_mmap; - inject.tool.ordered_events = true; inject.tool.ordering_requires_timestamps = true; /* * JIT MMAP injection injects all MMAP events in one go, so it From patchwork Thu Jul 11 17:59: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: 13730980 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 DC48BC3DA4B for ; Thu, 11 Jul 2024 18:05: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=QTSkE2wJ/0ArGbZAlv+dCStory8B9jtqpGvumW8ARXs=; b=oYWCd6VP4wCQvTy2vMUo9KaiOS dSFD1bDZX1fiL452BxoxWpcmTV/UEtsyy6bf9zbd4ViGecOnKqpl1iGYrXVIa0FQFK7doWeNnGGWh UfSPWM69IuLR7nKEUm6sOw3B05rf38WgfkIESlOKLs9RWb/baE4hB+hZ2r7ZYzqPVpsHcBpplyLqA fqBbr/L4cfPNISnawJI08CRd1GZLjptI53LNMj+BR0lmymKib8yOELPweaHIUJX7HxAWCs1SxQ2Nz ZIQYJdGCN/1pMy+MvLrSrNVNY3cV+m9xnDF+9XxtqquFtli3x3Mqn6bSwx4GtUgZqpgFrZYbacZW8 JinX/f5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyAA-0000000EyEs-0tm9; Thu, 11 Jul 2024 18:05:02 +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 1sRy65-0000000EwK0-2cVL for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:51 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6501bac2d6aso13425537b3.0 for ; Thu, 11 Jul 2024 11:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720848; x=1721325648; darn=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=0zjsKZbjrnwkVasmt+wTP1TATyDoh0We0Wsn/O64ub2gX1MZcYaJZN5lg7idWKFmck k0svgNjZM1Khb+5Q3fvXaWR+XL6RHDm3e2L+6MJ0TDiR4Zj9hmQVQNbXbmcygcVGEUiX cG6rNQC9AWn+ZHChiWbXGxMospc/PuniA3TWMkzlCZuGCPmOfq3rlmdh5/BCX9WI0fK6 VTtLp+73skpT7sv2/SmthjuK6D5+Q9FL4Hvu6yOp3jnyRlpiMovfi3Dngw7qbApTjLZa CfPJhGPKMYJVOZEjnPmfaiNe5fxHrfLBfKjDIgt/pLaqzR+pTUZZf0KMqwvOjbSm+j2p Pt/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720848; x=1721325648; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QTSkE2wJ/0ArGbZAlv+dCStory8B9jtqpGvumW8ARXs=; b=d4daJq/alrpzhIoz8djDYuhZniTbHViLq1ROGEwHY1jdJxJue+kpV35wr83bMuij0m kpyEyJyeLougI2tQA1Zqqp+RvFiI4y+AVmcnXBgas/zdLlTD60mCjhF8r5e3INBN4LpE bCnlIkQaUd2ga1oSv/4NCs6G4yPThHFRpldq7HtI3gnbolrwWZlt9ACiMPUVZLGSd6pc uh38dgqdjIJwzS6gy1Fqy09mr6RXaZR6hD9mxAJ3GchclOtHjRKBb12hCg3cIIUlpcNC jdGJpeIBXKU72vZ61y8jNr6cn1aO4r43GG5sCnaU1kF4IG3Cj1IZHqVM6SuvYq1a1dLf FykA== X-Forwarded-Encrypted: i=1; AJvYcCVa5O89dU64rPcVCfxfS899omG3ECFxYlKDXQE18UaTFUu7aDo62eH2XP3SUinPzVtorNu8LaxQW5kBEMz96BbYlbXW6mEz2prcjsy+KmfPcONqpVw= X-Gm-Message-State: AOJu0YzAz7w4AvruKxdGUMsgs8a+yDuKPkveOrCtBfqMm3WYv5zQ+y9D i4YXBMs6beG/tvaxQsvSPiZhtrpKm578C9csdFV6vkz4DRzXYlSBWQb4JuuB+OzO1XMvgbuDWvb xA9WwYw== X-Google-Smtp-Source: AGHT+IGlt20vZYur011SdPu6+QS+oJZqOUoXE1o+BRrQgv2s0bzDCcgJLzE/EenlRtLxPWLHv7UOmrxEaNS4 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a25:7d42:0:b0:e03:61bb:6032 with SMTP id 3f1490d57ef6-e058a47ba0emr1176276.1.1720720848062; Thu, 11 Jul 2024 11:00:48 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:56 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-17-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 16/28] perf report: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110049_705488_0A497D15 X-CRM114-Status: GOOD ( 13.62 ) 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 Thu Jul 11 17:59:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730981 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 87152C3DA4B for ; Thu, 11 Jul 2024 18:05:31 +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=TIcZVwstcI18/K/pURo+MEBa88 vy/4tnTAcc2HeUmUCOHeb+CW7TGf5NURIVX7aR8dzRSp3263glTUlYpY4I1amD+MlgE3b7VUXVbXy Lv80uw9ildY0VCZUKI4iZPM9U/v/7TzXvCvhmMXxZw3ZhIdXlpPy4KT8NeHyPusAKUFBSWQ+2x5rV yfC/Q7dgfVvvaEx521ydrpdBwuNyMYNRLubTnWolJgZveS9WEq/WPBoAUs7bMhWN9AptgilHepZNt 3TVaQpIywi4R6ahJUVH05fgH65z2fTQVf1BdEDaGiENzY93VWMGh1oluBQS3eL6QCzxrQQqJyMZx7 9PWFN+rA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyAR-0000000EyMq-2jYD; Thu, 11 Jul 2024 18:05:19 +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 1sRy67-0000000EwLi-1jfi for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:53 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e037c3d20a6so2006028276.0 for ; Thu, 11 Jul 2024 11:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720850; x=1721325650; 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=IzfFwgn5m0kjeGBeueMjwglU7LSPOWC/YEgldx1iHXjNOX258jUdlY2Iq8AneY8T/B wMr9QF7EFLi4OMtIL6IDiFjDqw/ESXIZsi6XgBBUr9Xsa9iSDPSAw8tyuOjmqY8mDngA Og0miaSj0kaMOA+yRFLBzMNFPz8ZDdCjmRG8xzXgk2mFqMYaYukH34OwNcFpwuoH+32F LupugIgLju7gaxWdOrwYep07/7FycrKc+IDX5n+wJM/7IgbdEe1xQu3yzQAfMD6HQPJY irVRV0A4JHLVtBuaEBJazVipxo6MLwvX9k+JuQYiD96g9IK5BEs5RCu8casJrHwJyBw+ A2dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720850; x=1721325650; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GhKzAhRYOz6Ff/7gM3raH2p2+7D3XZwc5l/hw9g7Qeo=; b=QOFmVw1Wtv01/jPD4Jyg2Eyai/lKBptJRaM8oPGNDsZh2tox3RyDESRq0kpOv4DtaI XGcJSVxT0HYLTI2VJKpoFYUSlZZTvgIr43pbr6SVwV3Ts8johBwMQzfAp4nCgCY44ngJ i9spS39bZPDFEC5zZh71JqLhLi9cwqtI8iGfhxe5NPS/QnP0qxG6SayZjeS4zSmUiPMr zzD4VBMLGtbYt81HL0qCFaLCa/ycR6cTWPzpHxq6QPIVEsCtpacmdXxtLGkMT2yMoO5B GgIr6/05HzZ6QPxAjJG1d16ptP07YSY5bqfSynWfT/DMkaXnspIGdxyS1KSf6HVu//Ry NjWA== X-Forwarded-Encrypted: i=1; AJvYcCU28pKcilxb2V+n12y/gb1I2i3r09GFpPRp9ncTGLSQHyYL0X6AiyaFgWghsZrgguVBCOJhSH68q8e9+6xhJZjo8rs9U9yoSPoKuv0fREe8bI165A4= X-Gm-Message-State: AOJu0Yw/FMYXeOnRTB2SeC4zjUjcgOmdZPOsQ+nSnodxFIXgewOHIeT1 0Sq++CA6w4jkEZsYmP0K09aXXmKBgn9Gw/q0ZTrMP5GtUWRwQPbWeRCUUnrWJjD/soUhs5UQLVV L3DsU6Q== X-Google-Smtp-Source: AGHT+IFqVvherAEk1x3Ir8n4fHhcFmi1xD/c2UbKwwjpP39A7XPMyOqoevAXhv8slX5yfHAkD3bxc1fO1Qwh X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:274a:b0:e03:2f8e:9d81 with SMTP id 3f1490d57ef6-e041af3b67amr47129276.0.1720720850095; Thu, 11 Jul 2024 11:00:50 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:57 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-18-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 17/28] perf stat: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110051_643512_D2CB4A83 X-CRM114-Status: GOOD ( 12.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Thu Jul 11 17:59:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730982 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 4E594C3DA4B for ; Thu, 11 Jul 2024 18:05: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=mHHBS2O6oNY6SeiT+OH+p80VI/Bl4EiQ8pJoP1UpZWA=; b=Qz3WTY5NKAZF4SqIdMKYrdR9k7 w0hLUu6QmxdKwiu3oLGaz+t/VFqvaz71PaL56QX2bmATuh0teKyhER7Tad3gdb3Zbzv4TYlIbx8ac knpFzbYRpfgmvoSGTVWGH/L7lby+UDp9NZ90PelAnDQWgkTH9ZolhcnoeyeQbvmZjgp0W7eJjKLmH 43yEWAJ98LkTeJC6HSGKZNpq5bc9V6ao0RUo57isf220l0Is8apFwjIMpghIrn47LUtOHOzLLkyjv aZ9b397GprgaQAKWJRxWdudsgcPkndJu8ZnIWSnGjZFYzcspVSjK1IByGGQBnqZybJzvsAp/ouHwz Hx8amG/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyAg-0000000EyTU-3NL0; Thu, 11 Jul 2024 18:05:34 +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 1sRy69-0000000EwNc-45nx for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:55 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e0335450936so2118943276.1 for ; Thu, 11 Jul 2024 11:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720852; x=1721325652; darn=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=i2n8K0WPdHWGLrWciN/3mTL4pxdbtOqyygW5EkL/tjTERyYpSIJKJbjSbrTIs2KX/H ggD4TSF5H1RF/NmmXhaaknwngHNDwbVIf1fOtoq8Oj5asOdTopwZAXRMMahVibiIBX+J Gyz5DJ0GmzBS330DU2tNOT/PGLX+VRMHsLE3NiDJz4HommoJgaMnHwN7uRnGaLFcK1qs du2wD0ym1i3nUsfRmMxjmhd+5tg2sCUacarTZNZTHaBFt8c0+dw3YylXQ4S0l01eMt+C ORtuJY1MC/P7bF9Q4xOPPU8jWRGHvexJVi5KYK3+ly6Q/N0JDDZd6nDqdanbHZ2JgXyG rt6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720852; x=1721325652; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mHHBS2O6oNY6SeiT+OH+p80VI/Bl4EiQ8pJoP1UpZWA=; b=azy1jPB3itNxKOpBPF5gO5loBUphXcS4iZSlysUl3DGcdLLm7reqB05O4D67WCrHsG n0Q2ig8Zs3gx/euDjAxBIiknYrE8Z0feX+bpCCx9PI6WMqaWadRhSljF3j1RUveJhP1F 7sJ4UbjW98UL+w+dCLF92zroxiGu16Yqgkk2u/p4aDntVi8NrYPqigFJ1xYGouTF4qHq XZj3jqZlIeyS/qmWheYuTm+fKLMWMb5/KgVhXi2hitVby8ydndRxjhA1NsZ8X6r6zs+s HcT8EQ1Vhe3TnfHyVLOf13zdiBCBytP4ExHfsWM4ePX3PLnEYupkBj7tEs1VJGKGPLiW FjXg== X-Forwarded-Encrypted: i=1; AJvYcCXio3qpaD0RMM1y/o79o7CPyz8d3mlrS9Wr6HYCfrfdOtjzw/zyDcEcWI630Evv4XRJyI6s/qVHlcSNCcKFpw1MIAUj5w9zL3IB/Vsm9plW1UGl1M0= X-Gm-Message-State: AOJu0YyedYNuPV6Gn1exfgABss/1ooyy9GT0vG4omAmXLLA7mGyHSVdx sCgTr8AGNDraePX4kCawo37QU6G4s/kYJJhO15Gn3glooEtzmS/0p2aXF/BF2rUI3Glt6hG9nY2 luN6SSA== X-Google-Smtp-Source: AGHT+IGqpkWSNHuIk6znTjQKp37a4qhNUCcyhSSKbaeHKidGnzOJPe4kpolhyZ0aaZjRKcwzNmoatuj2V+U4 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1507:b0:e03:5b06:6db2 with SMTP id 3f1490d57ef6-e041b0347b7mr21103276.3.1720720852509; Thu, 11 Jul 2024 11:00:52 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:58 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-19-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 18/28] perf annotate: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110054_140606_AE9351FD X-CRM114-Status: GOOD ( 13.33 ) 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 Thu Jul 11 17:59: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: 13730983 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 59FC5C3DA45 for ; Thu, 11 Jul 2024 18:06:04 +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=C2p7tcOr0jm/PV9j5iKk7FyAUNGqEU9AzkGnAwI7vp8=; b=L3WVnmx06GwLCTEgxcdtaQQLRI 9pSxVurzDKKXZXqOpYxYwdn2rlw/7JZJ+ZY/tdmWZZFVAKkuCQdSwwBJGtElr+NW04iX+RbnXEwpT HRstosrOh9BDT4RWhNHjJ5hw5K9cA5Ag6+njMI408pFx6deldMP1pfmmbOlkzLXSHluYW1Yw1o6Ua FGJv33wGotJ0yl2kNy/WSliOBthpD34RUO0pDmKnBgAQz8Gtf2cjRXk+bGe9jClaSXEEgDvyiDh8+ GN8NTYAFEkCmzabcf+AFvaemgKvtR8F1TMKanx/cBJYRKvTQj5emrzdxYTKGg4uZE5Iqd3KtBrRJX M98nsGjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyAw-0000000EyZz-3IOX; Thu, 11 Jul 2024 18:05:50 +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 1sRy6C-0000000EwPe-1jFd for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:00:57 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-650ab31aabdso19218927b3.3 for ; Thu, 11 Jul 2024 11:00:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720855; x=1721325655; darn=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=C2p7tcOr0jm/PV9j5iKk7FyAUNGqEU9AzkGnAwI7vp8=; b=SvtxMzSlnocIoyf7D9y9ymRgoKOZOHoliqwWodhysj75lRKaQPyGpqPQb36fIQyPEe Jf/ZICGGWZJvPESFATwHta9uMRAPDuK4bPaLXsoqy5MCxxrHr31Cp9iXSrRIq7g7KKeb KhFeVfcqDJzXuopl9GgcCNX5RlKhAI8Dr/Mwy5HR4SYy8z0D8zEB7F2LJt4o/ZpbdKa3 AqNg3NcvZU21I12jlitB8gOj2Ejc6HRd6GcyJefv0pS4z+thAaAFVO9ZAYiq8zsM13yw FKIqEvVjcWmwrjCszFyvhYZAAtekQEeRdIqILY3HXUdnprZqO2ubY0kqHIncd+f6qAcQ tbVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720855; x=1721325655; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=C2p7tcOr0jm/PV9j5iKk7FyAUNGqEU9AzkGnAwI7vp8=; b=NVIyRBaleeVfOVfsX8iy0OjUv27Mp3aBEpJkyQmzEFdMzhO7xrnWXZCr0EQn1eRWhm 81o+eRTIHIim4awTY8ceCwYb/HJoZ2BxA0pQoBC+Le+aUlXXN/wCTiGxgWTI5ozPQ/2+ vOZinHrnG/la4RxMaWMjHmUjypHSpY2frYJYg3PPw/GDYcilrHI7RWS5K0WrkSouAW9H 3lCqNnkDTxw2mvR9D9lG3I9WD1/71FUTvCsKxtwkps4PBj0RjYvNE5RGwqwaR28Z9v/A 9XU0VdSSt7fBaOym1HENV5VC7fVD1GDvlwbIQjTJKPwZg7W2E1kJ7xbEMqZ9vDSqNLy2 0B1A== X-Forwarded-Encrypted: i=1; AJvYcCU82+tC6Kd37s5x4kRz+rs6/Ak1Z1kN1eoXPlGS427LNfVDCeUwvBz4/7BoSu8XizNlGrO3vSJYe+ppgHIaLhxqg73sgTFyZl/m01FejgUoRzFvOJg= X-Gm-Message-State: AOJu0YwOCXtkqcsT3zonsUycG+5BF6VuH6TeMkujCnhmvuF8VpZJ2TQ3 PSUNmM2V1/nxM8DV8LIm+3Wo8clCY1rFRehn+a8zooPfcNe9szuT1B35QQ/S6gXjiuRnYoEwvTB Nz93K0Q== X-Google-Smtp-Source: AGHT+IErKn7vIcO/EMczv8pt4H8ZLfTYCzTGeuAeHkDtRqbCFgVHP61ZAZdJy2vh7qsOzMlOjPpLcCM9CM6N X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:60c8:b0:630:28e3:2568 with SMTP id 00721157ae682-658eeb6df10mr472117b3.3.1720720854737; Thu, 11 Jul 2024 11:00:54 -0700 (PDT) Date: Thu, 11 Jul 2024 10:59:59 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-20-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 19/28] perf sched: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110056_478442_3659BAC9 X-CRM114-Status: GOOD ( 11.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 Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-sched.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 2ad28c49d31f..fe2bddd63d96 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -3013,7 +3013,6 @@ static int perf_sched__timehist(struct perf_sched *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; @@ -3514,14 +3513,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, @@ -3638,6 +3629,13 @@ int cmd_sched(int argc, const char **argv) }; int ret; + perf_tool__init(&sched.tool, /*ordered_events=*/true); + sched.tool.sample = perf_sched__process_tracepoint_sample; + sched.tool.comm = perf_sched__process_comm; + sched.tool.namespaces = perf_event__process_namespaces; + sched.tool.lost = perf_event__process_lost; + sched.tool.fork = perf_sched__process_fork_event; + argc = parse_options_subcommand(argc, argv, sched_options, sched_subcommands, sched_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (!argc) From patchwork Thu Jul 11 18:00:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730984 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 1BC37C3DA4B for ; Thu, 11 Jul 2024 18:06: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=dI8yaROyMxBgkl/C6HStDZ1DbB4Rpu7ZnQVumFggSVU=; b=KdWSctUdkzyB+1EdswACPmd82m EVKYRKtUdCCGABbhl+5i8tOtZ/ruSuqOUFznHw+v33JbCXYFbEKjDiXxKLOrb1bn7tm4PLoWxNbB9 T7mHl1laFVyYNQZyQV9zZLGYqsLj3n+CYRvvr7U7dkB2JOsght7+LK47TieELa0YN4kW+xL0YAZPz ruB8G9Jq45T5izCfjLadErn72e2tSzmYEZSx/mNaTZZZsxrZ6FrUgClpARGkuqCQ6kP1oSmyg0+a+ vXTWEoyu7m7JJJMdEM28A4116dwqHjc3DETD8HfF6ArQ+iCZsoM5qsj7WSJRdn20agFpZUsJMK4vt C1B4uB4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyBE-0000000EylG-2vkE; Thu, 11 Jul 2024 18:06:08 +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 1sRy6E-0000000EwRf-3ehJ for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:01:01 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-650f5b28822so20060257b3.2 for ; Thu, 11 Jul 2024 11:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720857; x=1721325657; 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=z4zhb/+i6oaHbL9NilcRZA3J7qsQm04V6Eb7sacxEzudJjxlDVonxgF7wMvbOKc/MH AJTl4q4DdSdhOzu7aXIKYGMUzHU1fQArZFvKOgu6iyYJDQuRV0iVQB/xpvBNXuV8xi4U zsoMD7AEYTJ9y8IqYpYaB4BGPErb6FD7yDenwol6gCPcKZFY12ker3FkF0aNhmx4WLA4 rE2kcCl2CPnaPm7OH2DGmRvyodirQi1inaTMSXgZZz4xA9bgH1t9LlEfd5SQSsF4cFlC hTFQRVRU0RJLjvB1eMARDEtChNuNg0W2FtCw+YAGThk7JPP++5bNWRgGN7FRnuPhpyma 8QuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720857; x=1721325657; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dI8yaROyMxBgkl/C6HStDZ1DbB4Rpu7ZnQVumFggSVU=; b=KhIurlYmnyYDYmixHaDz6Yfim280CYPXs5zzEFWvfxahBkq8K3Xl0rLIlyi1MVwysn JbPeOdf3T/+XHAMSHjONlspjGugIur0paTcqBAydjdjRDde872o3qaNxvo8mviVM5/iB fduNNuHtKQ9tCCiwVgNntfmBNUHM2hu7wg3B+BT2o0sycKDgy8bYo/2QbiMSOQeK+m/C OjjdNImKwCIj0hYjNbjInfQTDTRF1cK5l9PyxMb/a98+bEliG+5QS7xbDH/WZnnelfir a4iIXGRMEupbzFf/KGJAIe6VDZIrR6oWXT9vfG1DoA17qLsssdxyTkArWYuY3BNOAlUx c9oA== X-Forwarded-Encrypted: i=1; AJvYcCWwZ/OS6kTd8omuf3q5iORqEJ+3/E8trHYq/XYNMwETrN0k2SThWEE39bm1MnWQIkQBJ1uZwcxSSCwG8phECAqbo3Xq9Ts2aDV26i9T+fPbcgxQF1o= X-Gm-Message-State: AOJu0Ywf45SSGqZK6z8hDnmZGCRNQfX5ToUgViVXU2G95UPju1ZriE9s wQB3HJr+FHMBBAad9HOwArFyRjvdC25LtbLT3ZEaiZH4stJGBBq0xQ+5zmX2cEs8OiisMOUqNa1 e0ScZVA== X-Google-Smtp-Source: AGHT+IGlvSq0w61dchsRb8EQOsbrRTrATl43/YP+LZQ7kANYJWmfCN5j/cK30JXClPJuEw9Y52zfl0N/IRks X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:124a:b0:dff:4c99:915 with SMTP id 3f1490d57ef6-e041b1134a3mr494223276.10.1720720857211; Thu, 11 Jul 2024 11:00:57 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:00 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-21-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 20/28] perf mem: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110059_078661_54A415AF X-CRM114-Status: GOOD ( 13.03 ) 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 Thu Jul 11 18:00:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730985 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 D683AC3DA4D for ; Thu, 11 Jul 2024 18:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=30wTiCp+NVIhDTuqUvYj4YUy4HL96R/Tpq22ji595AI=; b=HfyUIOUayORUPUBAht7Wcr1PAS hVbzLgdwU9/xYekXw7zqEmIhgEj2awHEAwcTgAe4Kd7fLYALZKbuvkB+krYILQHL+78NNfh38A2xE 7WbwgvqSllODmLugTZsLRW3892r4mHs06aHu9L1R7meqInRuQJMUfWRqYSFu0taFVidyyhta8sktP ZdUCmm1MZpO80yN1TUXK9bPSc5+ssAEqduJtqNAk9KZd09vR3atKeObCfvnMubrBgy7IMNonXd9Li mrkE1ygWtCsRMFUBfaSvkHnEbEtzB6HSgbREL7roLRwQ2ggdHdmnZD99YNFn8lOJ+8yVd7xpsO+wo kI+wsFpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyBV-0000000Eytz-0Cbf; Thu, 11 Jul 2024 18:06: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 1sRy6H-0000000EwTs-05DI for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:01:05 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6502e4c5aafso13255597b3.1 for ; Thu, 11 Jul 2024 11:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720859; x=1721325659; darn=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=hfbSIHTOyfvMTE3T4sx3s7AdWa4gusy2PEY80Ij2gvgd3XF82RoQE3nYiBZKg95sQe CJBluD8H2gmHvzA8MrRgPydMqG1JfFw6x6dJne2Jxt6EdC1DIAONaGcD+V8PMFiAYtXF RFPs9pxcm/I/FZFD26EwRlUfZscM4YL3shiQYZZp2nveb+AqQxAM2ffWUhO/iX5kQZ8P +EzpBgoKNSncPrmlfSxvmTAQJmPaPHs8rAdr9QRvuFjJtJ41Xt8MT/KdM7yby15Cde+d oRt6n8IPuhVMRoRtLSueJq5GZ2WaeQ3l3G/i1c2PiB2HRcPxvkXNKMTpsSZQZgJnWFx9 eRPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720859; x=1721325659; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=30wTiCp+NVIhDTuqUvYj4YUy4HL96R/Tpq22ji595AI=; b=IwobfkWcN9ap1pdev83MNQfUYKAVrt8iM+L21znSHiV2rsJW31f01dJSGDLmk7B+xP NzXecDxpzXniCSwvZI0JVwpel/5Y6yd31BRWTa25c9Mfd4lBB8tLkeqgz0uBzcq7lPK0 d91GPi095SUGTJAwKoa4uo6huUlZbl5MyH/oYvi+AE/9IwpEE1gjdeRa3SntzktjKCJz 2qulQeHe24yN1JAHMdG1lOJtpXXdM18rFFPHDIWDP1NVjpHmO/2BYfV6SqDpAch+KMPW utLkqW13qyupUdI0rN3jw4rPPehJTLnmaClenWGDaG5WjMVf6zb8OcMkcE3gaeTWCLKU SFQA== X-Forwarded-Encrypted: i=1; AJvYcCW6jzsTe/7QpK0HJMQReFNc2PsAQcoBxGlAIhpEt0+q0K9pdm/PWZCfUH5vhf0G/JgdBjMm7qP64GUIlkt1DjpYId5tgyNRmx0hcoOwriSz2rqMuuQ= X-Gm-Message-State: AOJu0YwNoZrN6LINFvTUIpQTrOl5+a0x7iJujZF9UsfAF5OwtVJXlGYN 4dvhGhcdWdpNbChK6Xa9adqzPondh5QE9m+y9fhiJZzx0AEy67vtiaXHpFd2pH2aUbsMBQ1e1dw rNSd5cg== X-Google-Smtp-Source: AGHT+IFZpTMg4BQB94SCXas1IM8Xhd/IszdibFEMqZP5+uba0vWSTxmY0iKOvfL8EAF9shV0sCKOMUKx0Nvd X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a0d:ea49:0:b0:64b:a38:31d0 with SMTP id 00721157ae682-65df50b328amr15297b3.4.1720720859459; Thu, 11 Jul 2024 11:00:59 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:01 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-22-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 21/28] perf timechart: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110101_127212_F7858107 X-CRM114-Status: GOOD ( 13.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-timechart.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 5bf818baa662..218c8b44d7be 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c @@ -1606,10 +1606,16 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name) .mode = PERF_DATA_MODE_READ, .force = tchart->force, }; - - struct perf_session *session = perf_session__new(&data, &tchart->tool); + struct perf_session *session; int ret = -EINVAL; + perf_tool__init(&tchart->tool, /*ordered_events=*/true); + tchart->tool.comm = process_comm_event; + tchart->tool.fork = process_fork_event; + tchart->tool.exit = process_exit_event; + tchart->tool.sample = process_sample_event; + + session = perf_session__new(&data, &tchart->tool); if (IS_ERR(session)) return PTR_ERR(session); @@ -1924,13 +1930,6 @@ parse_time(const struct option *opt, const char *arg, int __maybe_unused unset) int cmd_timechart(int argc, const char **argv) { struct timechart tchart = { - .tool = { - .comm = process_comm_event, - .fork = process_fork_event, - .exit = process_exit_event, - .sample = process_sample_event, - .ordered_events = true, - }, .proc_num = 15, .min_time = NSEC_PER_MSEC, .merge_dist = 1000, From patchwork Thu Jul 11 18:00:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730986 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 7BFC1C3DA4B for ; Thu, 11 Jul 2024 18:06:51 +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=oKkL13HhALSa5VLScWA9XEZ/jR /gJjf0DIbD4KPNgR3f9Ir85liVTmsbVEb9uWY7mwxWNotEhRd0oKRZmWDiZaBiSHGBOeAZUNBgqZw 4u8YB1p/u1kc6TevoTUD2IpPxR0XuqpxptbTMfx0n2KGBIJ9/1C/0NFbf9HQMbAUylziQ48XAMycg Ojjkgibn+ozIS0R9gGsMTfGgSbe4H6RzMQWpL8n1X6cMekHB4oVwAlQiXw20CVjfMGbbPrOVSsLFO /UDVWvRbAbLz2sIJrF5rAhuqoLo4WJxr4wvSkN5GCSVTlvzmtRogn8BY7Up4JYDPrZVRKDT6ceVQY PHDQx7QQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyBl-0000000Ez1y-1nED; Thu, 11 Jul 2024 18:06:41 +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 1sRy6L-0000000EwV7-3ocT for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:01:07 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-651a0aa7463so18944937b3.2 for ; Thu, 11 Jul 2024 11:01:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720862; x=1721325662; darn=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=cQL3wiVPRqnlHsqESz0vDiBoUhrVhSTNrK4i+NpBAU2BT2/q/GZbSOJh34eGtkXFRE tjqiEflEE3pbW0WEIACXN9ySLGoBYiidrqJaev43ZazY2m3aR849RDzprlNqEApounLG zbe7x9etcCHkyt06fXLH3U2xlV1mLc8tRJRYvOMhiZQu3a4QCwehfzLWpInu18rQHENI 8JLlcR/aIqQLaZq6Z4aSAuMi0o+q6dY14QtLMKy3u41CjxJSAirYHQnrd/r5zYh4xJK7 fgwcOd7PTLKG+jLpRlpHUzrIPwdeAWwMVIHs1XZP/FmlZE7LqRM/Q28chaU8IXENHr0r Fy0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720862; x=1721325662; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Yt616h8hRCivHeAdqJzIY5ztVTyVV8Crah5Wq3Zf1UM=; b=nY6J3giuUXGvfnYuhD8pyorF6unbdWFAfnc6LFyh2GAD7sMHd0Y/4fxv3P6zbRqzXU qK0uWMQWBhQGlMy6wPc37aK1J3ECeB4C0nct7SKLLzhenrzkRi7Ns2YMUIkiiM4beT31 2pbS1mHrYXLG3vTRkHzbAXirz8gtnf1PU1oQx17nufI4hRygranVAtn14qs2r8HLKTgz l2JwHZBQeSgS2MSDooPOBG2ysV+AgNlO8YyytAyqNCP6wZyDcOIcEUCfvQiGQZCLMnnf lrHo4E7rYTsyUnll/wFn3oa8lafk5JKBkcnqPGj0r5Xl2p0XxHb4QisGyhuWnvOVa/7M BPMA== X-Forwarded-Encrypted: i=1; AJvYcCU+2h9OCHjv/RDTpf0rs2NsFzQWjIlX9cELvZeVhp+kzwWKKiONvDakcUJNmh5paQVxqhaLNMbZb4Eq1BqVMEiG4H34UXp4H32niaMH2150FGhKFBg= X-Gm-Message-State: AOJu0YzXvdOvJic/TbR4WVHHATTUarfJNq74+v+oeBCR/Zidq/s9AUiy OPuT/8AzvVsHw8x20EFPlWQtKhlqq0uIZqkJWwqg1R4op8JTer39H2+xh1WDLHFLBH7g5mlsHNK XunvfoQ== X-Google-Smtp-Source: AGHT+IEX9oO7/QxRJKOh3p4hGI/yZCLEqpz98Pi8rexdVxqsNShjq1Lvluub4NnTvVJr1wr4NjxC6/p3kgg0 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:d17:b0:627:dd6a:134 with SMTP id 00721157ae682-658eeb6d6demr1963327b3.3.1720720861856; Thu, 11 Jul 2024 11:01:01 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:02 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-23-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 22/28] perf diff: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110106_028646_208FA229 X-CRM114-Status: GOOD ( 12.77 ) 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 Thu Jul 11 18:00:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730987 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 B7F6FC3DA45 for ; Thu, 11 Jul 2024 18:07: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=QqtdDMsD55pEoQfMNz6zeYZQAoeVSzSneBvTBBwc7VY=; b=GT85KjIKjpZ7cm4/eoXGHvgATU wrUW/bjRRycuOLXene5/mruZgUtZ4WG0rlN0U39gCT7iZ56cs/20y1NbaoJUAWuaXRsVEH3HM3gGk /UoHpMYYqzTxibFssTc8vQ0JtQ2HDX971rO9jWNv3bvv76lkS84fnQnmZUHNmlXgJErWGOm0j58TK w70ri5uZsxXn0QrkEhL8s9TYNWTFkh47IvxFx7yhypoD6kZV3UxDaBOWs9T4ymsZaJRY4PA7ZwZys l4pBYv07CVJzuUanNWC3i+EnfyDkRZXikc6bY0xI47q2vgKFKg7f3wVjJ3SGG/7XFyWKSUPUjO2Pl FqeDIdKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyC1-0000000EzB1-2Lpr; Thu, 11 Jul 2024 18:06:57 +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 1sRy6M-0000000EwVW-0GBY for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:01:08 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-64a5503e253so19855137b3.0 for ; Thu, 11 Jul 2024 11:01:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720864; x=1721325664; darn=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=h3kabjbCzCaLPfXXTrlsNLdut2C6bbv8bneysr7IfKL9cnUrmnflBGAmX3UNGwvTHh wIpJ7FGtqJe7yIbgGta+Hbc+vc76NGZ7dxvs9R7tdq4rzleWugZppFgJ4HryO+NQT/SJ C55z+tb61M1mCkFGCFBgaQWyuq6VnHwOpjt22KmYnhJz0pHite0KKZTy5Dxw4s7xBj6x 7st/fGy6URbwJ5KW1VmEawi0eN1g1kpI0sJKy3nCIR+f8RTA3tSrmQJfYRauX1Xqf+GN O9RrG0akNQ9z+KEUqXaxEYKnr43yI8dVOWBWAXNbn7MYgH8ZjAs/1Ve5brGDDFbVZscv ggkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720864; x=1721325664; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QqtdDMsD55pEoQfMNz6zeYZQAoeVSzSneBvTBBwc7VY=; b=nG4u9Nc4vt6VbDpqLbiqfygcOmi4aawzS98s8AlYAjgjrF6aKWaH3QyuvTpc6q7+5/ a5uMWMDEOlGZ+JYGJoBl4ovIjlbRUjgffD+9pbmkqNi6BSrC87HA1UfiNKmVegonVWE4 WCtGPAH5JV6Pe1SkITVtpNfAJNBT/QhkhLAVjN+eoh55naRoJFKrMJqy+bGlLifWB6zq iwFCPYBd7Zw5k9MoJi99ruDHsR61TnN/ojBUoCcdRE4S8HGPRwlYTngOoxxrIQV3FZuM 1KwU/CNZFRnDu37XDai/7vzVlpRrptoz9sRyziMnOsl9AbOPFAMWMyHFcAResk5hGUA5 VgPg== X-Forwarded-Encrypted: i=1; AJvYcCWM3Hb17n7pCOoG6xuaGPsl5sf5aODkFN9VvG/Qhc2QyxL9slag91HKmHlX8ZT41CTa17Nl9KKXqSnqVMGVDtBrMz+mkz9L9PyTI53Ba+hfwXdpUf0= X-Gm-Message-State: AOJu0YzpWdOvoFZPCyVYqZK/M4hR55g+4Tfq78Tnt+LnnorqAn+SNY58 nnbBa3rsDwDpnKaaGsa8PkeqeR226XGF0lggsFzqx8zVct4C8curCMUPwChK8bdtJ+y+eCrwhSb 0Mfb/+Q== X-Google-Smtp-Source: AGHT+IFm7iteUqTnpFU/9RIErlfRTtg3oqwxjOCKfDaCl4dOg8omYu/CwVrqY1dpL402Zc1R9QmK5RmuQget X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:6b0c:b0:648:afcb:a7d0 with SMTP id 00721157ae682-658f06d9ecdmr530397b3.8.1720720863879; Thu, 11 Jul 2024 11:01:03 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:03 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-24-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 23/28] perf data convert json: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110106_159963_9D05FCA1 X-CRM114-Status: GOOD ( 12.14 ) 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 Thu Jul 11 18:00:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730988 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 1040EC3DA45 for ; Thu, 11 Jul 2024 18:07:24 +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=R676DsofN93dLUGhUKxLYBeE4N h4QEhfW5mB8Atq7d0Txj3i298O4OFSYiE8HrKBq3y9gvzTqFPYUvoia4rS+ddajEUJBwKVR1d+qSW 9iqLZpyuV5AHkBsPilIGbJhoUZY/bCJQgOqtjo9zmmyW9/iO1Z7TJsmpJ7733bXddOmbvFUodEGlz d+t5nKKlFgBvJjk2cvQDirYZDaxoFsqgvKhg911YNHdwmVizczhHdSpUCJjHwa2+vk2dP43vk7Vxd Ibjw6/6KfhOTVQQJx4VT98eQTvAb4/7IYy74cDhtDwuI2/EYpK5lA0R2f0MxczwKp3Oby1zv9QlX5 Zngn895w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyCH-0000000EzHl-36Tw; Thu, 11 Jul 2024 18:07:13 +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 1sRy6O-0000000EwX9-0QBK for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:01:09 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-65194ea3d4dso19262177b3.0 for ; Thu, 11 Jul 2024 11:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720866; x=1721325666; darn=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=OGQDtydVYp0FbOKejzqKwfzijcTdZR/HumYbjSoxC5OZTCSA5my/sTXseKzl5sMRXJ 7b46W9QfKtprcLC7ekypuq4FJyn2828GCfrZbmVqMT0aOzag+NN7QxCvClVrDq85t8Oi oXa0yfOrdUSUPK0B/xd9d7RYZySDKN7fsrQ9hjkxmP/Mh/us84lBqC4pVwwBBxQn1K0e +RZirN9SwuSAYQN7forH4bImyTCNMihySN4kKkjrhlnbMZdSmA4JQOU4we0C2IqrtSzI 5f+WOHz/jOsZd96VukDo2Ell3Zgz/2O6HaHyYFviKbTbmsx7UItGwUCu1yxy5fYKcE2Q /PSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720866; x=1721325666; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=I9Nrbi73tEJWZxPfyj1GxchBACZKBze8WVP6UfEoRnc=; b=rZmAg8uG3zv8RDsdj/BE23iq2EYL+pgi+v0NP9S8pdocTfbvSxAxAdbdUdrVJn6J5u sZ9Y6C3g6mvu9Chg3ahk4GwjRriBwC9kLxS2eknhysBykqd/Cmqeku8+N/2j5xSZ2sQD Mtk2AcczIUXYHNlF8tZLDFWR1E7QleNIKeGIl3UvDFhIQwjKI7OE8ftfQvBZBpQVaNFQ OHQaEs1SGFrOZMHs+4v9852pMGAi46E9MblCrRuuRknsYfASG4PnL+/9LzAs+dFMLiA+ 5jiRCRCKj6EXoL78Ku1I5dnM/0QoNn0394Vlpi6EJ9BDn1whQnoTOchILHLwL8DdBgJi 3t/Q== X-Forwarded-Encrypted: i=1; AJvYcCWYbq6DZghc7e44B/qOgobIDLj4nhCOppTOrhCMBxgwDlsckXb2yBZ/kHu75I/hdART+S1I+toKz6B4ONvf2yrVaMpyoKKm6XIQW1eitU7jIJx6+RA= X-Gm-Message-State: AOJu0Yw5INAmbY4XEdd2FKsg44VVa4VrN7X/YRclEFkBkhMlz7nCNYAo XRyucN8X86aKcxZK+WMEkN2cdOzcNpK6U0HxmGG/oTNGFsgAwg5+6uh7rTlCjf0/QN+FWqmiRlI I+qHsLw== X-Google-Smtp-Source: AGHT+IGhziChfBYedmxyjnMHcf3Bobknr15gAzBmJdGEG+V/V+Zw+9Pj/8QUbWISbMzVlIJAKmFQYf39s2q6 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:690c:d0b:b0:61b:ed85:5d3f with SMTP id 00721157ae682-658f0cc859amr2392417b3.10.1720720866335; Thu, 11 Jul 2024 11:01:06 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:04 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-25-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 24/28] perf data convert ctf: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110108_248515_A8AA02F0 X-CRM114-Status: GOOD ( 12.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/util/data-convert-bt.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index 9e2170604b66..021e9b1d5cc5 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -1607,25 +1607,23 @@ int bt_convert__perf2ctf(const char *input, const char *path, .mode = PERF_DATA_MODE_READ, .force = opts->force, }; - struct convert c = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .lost = perf_event__process_lost, - .tracing_data = perf_event__process_tracing_data, - .build_id = perf_event__process_build_id, - .namespaces = perf_event__process_namespaces, - .ordered_events = true, - .ordering_requires_timestamps = true, - }, - }; + struct convert c = {}; struct ctf_writer *cw = &c.writer; int err; + perf_tool__init(&c.tool, /*ordered_events=*/true); + c.tool.sample = process_sample_event; + c.tool.mmap = perf_event__process_mmap; + c.tool.mmap2 = perf_event__process_mmap2; + c.tool.comm = perf_event__process_comm; + c.tool.exit = perf_event__process_exit; + c.tool.fork = perf_event__process_fork; + c.tool.lost = perf_event__process_lost; + c.tool.tracing_data = perf_event__process_tracing_data; + c.tool.build_id = perf_event__process_build_id; + c.tool.namespaces = perf_event__process_namespaces; + c.tool.ordering_requires_timestamps = true; + if (opts->all) { c.tool.comm = process_comm_event; c.tool.exit = process_exit_event; From patchwork Thu Jul 11 18:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730989 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 3DCFAC3DA45 for ; Thu, 11 Jul 2024 18:07: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=2MNiLSniwVv1E9e5Lf2m3HZTOrICLuX9boz579z3/KM=; b=c7gBXm1p21j3mZTC2XWA4s++dX AQD9JZF1KKkcWzLhh/vVfl2IZAmPU9Rpe6XjZSGQMNH+kit0H8RcUtt07DQGW3IAEH0l8br/yES6B EMvBtz1POPtnTtiiRMZ7bAYcc28cVvv2K1oOW+feG/9Wk29CejRiGWRlD0KqszX02Nur9cnp+yKRD T+GmCYJGWIQa/NCPhulXQLuv6wy9YDxNPWhLvarYskq6KFv+bC2euA8k55Hd9Xn2COLx89RXZlY11 P5EeG9/32dX2md/3LHuzAQgDC2fLrM0maO5FsZziuwV9YiqOdvBPS2zY5/VQ0zuocDdaSs0jhTEK3 UBKYYA5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyCY-0000000EzRH-0faM; Thu, 11 Jul 2024 18:07:30 +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 1sRy6P-0000000EwYw-3u4j for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:01:11 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-654d96c2bb5so18877257b3.2 for ; Thu, 11 Jul 2024 11:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720869; x=1721325669; darn=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=oxGbGPzldwt5NUt9hNEU69uDwA+oWo0wBmvt4adcicpHDwwH6YssRLJyAbvQrUpq6d NtvEA/WgiSj3mMoxg0VIPyvpQ/StcDs9rSZfF7DtSj1+eFjtbUPjVKqZt+q8YRpCDF+j zxkvt7nDkCVk31NMwfoBHus+aBxKAZhEnccZXVMbnn/x5rZBcIJuag9utWq46CEsbX3C WdJiMntZouXhPIzWdzXeRt0uWdEycRzPSRIcNtzvtXQqZjDyupkMDat7vfDcrxmqGCBB un58mVhXPcm9U6JHVmbCUmd+daeTwhDZ2MQGtB3kibhKs2AO5plE3Ds3BNcEgl2WO1bK SjMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720869; x=1721325669; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2MNiLSniwVv1E9e5Lf2m3HZTOrICLuX9boz579z3/KM=; b=Z5rGAoH6XJxzyxpj3ysWXbYyKx6llXKO8snyfxZugf+YgqnT3ODjMt1zZPz3PsPWsD Wt0ALSV5ZDHuEjMvN7Lzct/Eae9yqq9kzHfaZiNUakkq+VeIKNuUFywMMEhc0ITK6C+Z 9l5gR9EoD2digfn3OoWh9RVjMESLHrf0rhAm+n4zzlbwnuJu8DS6u5KUK0yEK/Pn4RtJ S51fe+svyemZ5dYwOt1YnV1aGSCoX3eIQkUQKfbU7ersuMpBLmdDX/T86o+tzx6bnmG7 iU7U/sRnCTK01y6Tnz4MB2dgVkfxfo9rTuqqizi4gB3spvONadebCRixHsYpO0A+6PlU aCuw== X-Forwarded-Encrypted: i=1; AJvYcCVkz1fJBmPJAw1qOpFglicVpqLOGTkUuV2RVFTkODabNgg5ih4IOBjLCUiPoVugifZxL4egg1spyxkRMeSYIUHNqkMjA7IKN1kUxCZacpIZMkYuNLY= X-Gm-Message-State: AOJu0YwYMXpO8kiZ+mVxZtzVIrg3o5KIt+SToYdCcFSZDfPUzLuw7kdr ry4BsuMvm1JZIsQ+939zRaoYkQEfFxhBDaqF9RdvFkRNLzy98Ws9S2urv38H3GruF41Q88R8IWW FISHsmA== X-Google-Smtp-Source: AGHT+IGM2xQme0Hs8QJpMwRrl0GnjElIf4QWIdg7meyT8+jpTN98FNf8secObYryk9mDw0GyqbyaX812usu1 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1206:b0:e03:59e2:e82 with SMTP id 3f1490d57ef6-e041b134afbmr16523276.10.1720720868643; Thu, 11 Jul 2024 11:01:08 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:05 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-26-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 25/28] perf test event_update: Ensure tools is initialized From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110110_056692_2F70989B X-CRM114-Status: GOOD ( 10.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 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 Thu Jul 11 18:00:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730990 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 604F5C3DA4B for ; Thu, 11 Jul 2024 18:07:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=phxqvYyYZFcsS+fO7HmN6BaHRpzOxQeFfvDLLgr+3hE=; b=lVVTk0ORZks4z/PNnOB7FEE+9c FZh+Zh8q1MXqjGNTyHYsZVgX+FJQJl6oxgnWKo+MmopEucyr8OxazEvzokj2vKS/oWQpo4F6h1hXe ZZNOYHCgKq3R+jY1IaxdcaxI7onOMz8XQn2jNJumvaM4ZtfqLAGZ2Nd4ZhKkNhTZ6oC3cb5kC12qI xo5C5bjd6Y+tPScFE8exdOVWxnafFBp2MN15NoloMPlk4yaG4Du8+qQ2E4/Vw2CWq/JvizOCVMWbK 5NzaP+WlKMGgdWLDkNudw5KmXEYZOqJE2QoJUzQumcB1IseIVi6iVff2Qd9mYhJ2dCwVxfOIZrajX O7zO4Wjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyCo-0000000EzY9-1SFA; Thu, 11 Jul 2024 18:07:46 +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 1sRy6S-0000000Ewa5-0CGx for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:01:13 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e05600ade22so2355452276.1 for ; Thu, 11 Jul 2024 11:01:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720871; x=1721325671; darn=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=Sen4rqIu4SgDeUyxiSneDwIuZCxFD1VHkYXV1uhTZM08rAuHwpHMMpw1vLlDAbaxct 10SHnEPL92VSkTGPazqM88ckxsMbtloi+r5Vmpcuw2ty7TGg6NgkA1t4UaEA6izToq5a eLYy5QpmKeUDSzuVdbr9t1f5McF3dzicp0jr2voVinFkLJx1C0HvPzQREE3i9Fhvqnpr 6QLRUiy1GYn7TpBOHZEuxvN+2lVHzsWFqtkBpf3E6npPOv3DHQDL+xue8CgPWaZxDJd8 Hft7xm2/sKIH45B/4tOSdRGdt0CgYTupuHpeUoVZqBw05LZiWEU1AV3abHoiHho952ZV qrFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720871; x=1721325671; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=phxqvYyYZFcsS+fO7HmN6BaHRpzOxQeFfvDLLgr+3hE=; b=OVAUQl44jTiPmSVKmNB7QHRHMOBoQ0tKq5W11BQQVGYx4KKq1xc3HgviKsiVfP9LhE lImYATyjP5eWCJP9SKj317ScpwflNzFsNyN6j6n/ZssZ0AfPyns1TjKC6u2SMY2zGYGy NT7F0RUBGXToHQbRDG3t8ZFpDgnt5NQmG+CDSCW+YC0Ne/JjowlY1CDkmdMu+6tvUGJK 6BUT7WkeBTn/TbyB6eSXm9x+zpRGBSn2l8gN9LffR9artsbrC1VjHeyMz66dZqzrXvlm Cw6wcf1n1AEQo5ee8ATF0Xnx2oCrGY/BmGtAJQceypNaq9FhiCkJ6BEF8Ao415ojCVbM tMtg== X-Forwarded-Encrypted: i=1; AJvYcCWDQg0LERNmdJaUTRUomf6ovvC0HFcYtkESPEqAtShBSNQ/IrRNm8G0QXo8wVhZZ/ViSUpaPxSekVNHxyAPo/RR4TuohAS6IkvpLTCR0lHeJV4vwto= X-Gm-Message-State: AOJu0Yz0BczGQrybiFHDD1tvimIYPcyZmAdMJl6FMAwBuJLQG1ZzCYRq 3oEqR++czDRK1p/kkezTVkteR7DOBYSvkPN6n11dSHIoSU4oo3FaZXZozeSBmvrBVuQpQ1ab0x3 1l3Lwyw== X-Google-Smtp-Source: AGHT+IHZsWRlk2KFoxmTrNHpb3twRLUr9YEReI+JPWVj//rgcz8mi631WHmc5+OCJP04cre0HLmnLn54Z7fH X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:1389:b0:e02:f35c:d398 with SMTP id 3f1490d57ef6-e058a707db8mr1072276.0.1720720870908; Thu, 11 Jul 2024 11:01:10 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:06 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-27-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 26/28] perf kwork: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110112_235923_6BDBC2C6 X-CRM114-Status: GOOD ( 12.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-kwork.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 8ffaa80a2d1d..6a4281b8fd10 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -2322,12 +2322,6 @@ int cmd_kwork(int argc, const char **argv) { static struct perf_kwork kwork = { .class_list = LIST_HEAD_INIT(kwork.class_list), - .tool = { - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .sample = perf_kwork__process_tracepoint_sample, - .ordered_events = true, - }, .atom_page_list = LIST_HEAD_INIT(kwork.atom_page_list), .sort_list = LIST_HEAD_INIT(kwork.sort_list), .cmp_id = LIST_HEAD_INIT(kwork.cmp_id), @@ -2462,6 +2456,11 @@ int cmd_kwork(int argc, const char **argv) "record", "report", "latency", "timehist", "top", NULL }; + perf_tool__init(&kwork.tool, /*ordered_events=*/true); + kwork.tool.mmap = perf_event__process_mmap; + kwork.tool.mmap2 = perf_event__process_mmap2; + kwork.tool.sample = perf_kwork__process_tracepoint_sample; + argc = parse_options_subcommand(argc, argv, kwork_options, kwork_subcommands, kwork_usage, PARSE_OPT_STOP_AT_NON_OPTION); From patchwork Thu Jul 11 18:00:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730991 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 D07D1C3DA4B for ; Thu, 11 Jul 2024 18:08: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=7XS/BS2tmrMYCpclJsc0ik1l+h9pEP1QMQPO1IiW0Pw=; b=FbC4i9gL0GGl7bWJkXkesT70dN xY6GyGbZ49DmZetuUBJwAiuEaI7dLWh+12H9NyUrLVi7kAizvfaG3gBlMhYocgDzd9yeZTxFwD+q0 sxB8O6Z5vHdv3Yv13tkRwizii47C5gIUH3l9zNGXKNNJUZiXl9rsCfre6peNvrDAOcCWN+bf9srhn 2Ulwxqnzvfijhw9RQpP3XJ80XsrKC4r3J5VicsZfrzDhCQF+FcvbsiZGkaNsOtBYDEdqAoHw5i05i x7rhBipHT7uGCAC7Lm5wndyUdOxOfkxE0sShcWqIfFwxDYVlcjxNArhzasOYCX21WhvgWlvATKcsY 4fjPZrdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyD3-0000000Ezer-1gQu; Thu, 11 Jul 2024 18:08:01 +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 1sRy6U-0000000EwbL-2IhH for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:01:17 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-650fccfd1dfso18682067b3.0 for ; Thu, 11 Jul 2024 11:01:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720873; x=1721325673; darn=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=VeY8l7wy19bIbmBPE4tYZkN2dyklWRcuZeGC131VIk8xOPN9COCQShPHcvmTUW84CA 6ohManMS7FiE4NOZmqrAwuRMStcXxBzIWFrMvo/d1z30vOBqC0H6Z/aGDvG9jGcSJb/r l4dq/gQYnOcXHP2xrpXZHSFTUv6IF1bZ2MgZ7b/c4xBdvoRPSWBRTW6DgixgqG62+n7r UThz5CLGawQWU4oLgbnGsjIG6FkHbwXsGFlUCPcqJnu8QFX7JjHwvkYEK+5jimSeuh/N AxnI2OJ5pkokP+o9CVvtf+pj8h70RjU0/cG3HBGKl9CyfrDkHYWcddSpywhVntEnexdj PmpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720873; x=1721325673; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7XS/BS2tmrMYCpclJsc0ik1l+h9pEP1QMQPO1IiW0Pw=; b=KjaHViENIGd7GanJTzf272fNcwJ68aQKYcPnUzKa3EnG/fRZGceEWJvyKVnGf7lsjs iSn8ig08jYN5l6f4SUZu29IEqs4iJICLxe0V0dkky0TbHWW+6xPVTl13vt/uYT3tbxvz 24eQMlJzGSX6TDmFBdjpom/+ouOIKXoWviMdYO439Pl2hRJiaYMJSayCbnesRuDkAc27 fs9Tyv6bSh0qVo8sNK7jtxHKhhzv/PmLxTZ5YL35A3kT6UwoZWjub/xv8vVeCSHQZUqJ cL+lkdA6q8rehxcrQyfpnIA6SbTNGN2SUzTCI/EmG/RSHPid+ogORi/wZA0cMJQELAOK 3yNg== X-Forwarded-Encrypted: i=1; AJvYcCXAiqT2ZaNiX2yy7pmmDHxcyVbgBnHacS6v2OrXQucw5ycqflzrCZ7L754wQcbiUYOtfgxY35j0CatmpZdl1wrGfGif0FLRsW0cw7U1diR/D3+By0Y= X-Gm-Message-State: AOJu0YyXCylyElzFqvdZHhmDqYJ4U9V7FWzCrCzDwArXIYkLaEIHiEOt ejVcIsSBXpoo+reP8uM8lyK2v/s9J4AkdR3ohbI0lvEidY1MyCSZhj1TtHbn4QF5VZJOM8ooVms 9oMBh4w== X-Google-Smtp-Source: AGHT+IFkKG3IgwMxEt/Bk8goVcLqtdaHlpvAh6+KBMB2W8t4X5lnBMdhP8W48LriLi67E/9Scm+C0af9WkpB X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:2403:b0:e03:554e:f396 with SMTP id 3f1490d57ef6-e041b05b915mr366236276.6.1720720873191; Thu, 11 Jul 2024 11:01:13 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:07 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-28-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 27/28] perf tool: Remove perf_tool__fill_defaults From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110114_672615_ECB92C7A X-CRM114-Status: GOOD ( 13.51 ) 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 Thu Jul 11 18:00:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13730992 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 79AA5C3DA4B for ; Thu, 11 Jul 2024 18:08:28 +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=XwC7LCE56PMXk89ni/gAtmkho6 1qpA7UueaGOMA9HALKbs7couiv+DU97mhJiR8yOHn6f5o85PklPFRCjLaK6hpKUzIgYGFKqKE3Fy5 5qnLCphn0qNu08EOEAdRI+QC+oXrY12cwJ7I9IRDHwEwIdiUqcH+pPvzzMVN0mdvm/XFvaSSUxh+N Ckf7+Qmk/OydFvq+QtZh1teBz4cDnIw/SulIqtBlnm/hE9FWUQUALUq3Ee9Uf4IAsTohJ0uatsxXc V5nPsNExmi9GVa5zvfr/W1Gbe9cu0bdXaLajZdEeX4G7U/06xaWeJy44pOpI3x7ShHiNHss/ErZR9 WL5dj2og==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRyDJ-0000000EzmD-3pax; Thu, 11 Jul 2024 18:08: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 1sRy6W-0000000EwdL-44b9 for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2024 18:01:19 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-64f30b1f8ecso16925857b3.3 for ; Thu, 11 Jul 2024 11:01:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720720875; x=1721325675; darn=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=SW32oz1lEPVS6SNMToyuofB2f/FKivAt6yq0ZtoAPTC6Kxi5UUnK/vgS7ujhjPWmRK 6a9Mcr/kdldp6DsFdmW/EHxw1AJxQ3MDebl4k+g4mccUM8CzfNHo4TcXFjlHy6f/URCi d9OFjjksRtPfEbpyB6uJQy54VVO9jkRUafKAUnF9+Bxchl5ctT++jSunbHH7sftBMx7v vr/mO5KxxRgSLdPDJHtKTb0nffIt+SvIUt7QeJ0fULW35cJMK7eU2MQrVIcOiOkFv+/z 7TFivLeReFbni6h0iRk8V0bmuwhJW0OYvIAz9nDbWOOsXsT49OOVZa+ixwzJYZYu05LM Af6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720720875; x=1721325675; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DzgUQ0L67yHK9ZgYOmZnLIT3MZDT9EVRhOxDmj12OGQ=; b=w5ST4y4NlQ/T3AYveuNb7I89UqR3L0uvICDE35H+Nj3Qk9YluOC629/8CiDCEglYbf hukyoi3fydimHveaM9CnhxE0aXF3C8gC7pjRh9tyeCKpnCiR5jKmndEp+7uMf3l8GFJQ c0QTq9s4hye2c7D8+c0y6lOnjSf5WPquh5hgwxPLZPzhYzJdtRYvKD6TZE91XNBg70RL BEhljuxGLMqdAqTMPFl7Nong51e+03qbiV3zdhAFOtsl6lWX11Er1UT8LJa7MGZBiBvp uimSQxGXKeGb44YswUJ4PLq6wBxKQzlXNTh2F/xkT3zGJI1q4RZzkBbTM26phk+hg2k3 WYMw== X-Forwarded-Encrypted: i=1; AJvYcCVNtVlqZdtiAZiAxM9oLoTn36mbqsp+1Hc7oYM6ag6jheJz59lbOeyFETPuTjH8V2kPerQvhWABd1REddLvCNOK44KyG/7+0++AQEd/iREj0gsa8Ts= X-Gm-Message-State: AOJu0Yzx4SyiFMd6NRAkQwytzD1PyRMUXYb2RigOfyzn3TG+hXQi8Vhv ai9ovrM+0iZfsTeyg/wUvbwag1HZA0s85i4hbgi8Pq4hFQHOamPDjyy820Ck/qYmYurXW3Xkynt Z7GjEyQ== X-Google-Smtp-Source: AGHT+IF6ZsAvtsfjEpCo3Gdjx73peL+tpHFo6fSjhaKLM0gD5zmtULo0VxwhlOW9Ohb+tLATOGzcVSe0U1oD X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bd08:a1e0:c497:32db]) (user=irogers job=sendgmr) by 2002:a05:6902:2403:b0:e03:554e:f396 with SMTP id 3f1490d57ef6-e041b05b915mr366242276.6.1720720875256; Thu, 11 Jul 2024 11:01:15 -0700 (PDT) Date: Thu, 11 Jul 2024 11:00:08 -0700 In-Reply-To: <20240711180008.188906-1-irogers@google.com> Message-Id: <20240711180008.188906-29-irogers@google.com> Mime-Version: 1.0 References: <20240711180008.188906-1-irogers@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Subject: [PATCH v4 28/28] perf session: Constify tool From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240711_110117_176160_E0063107 X-CRM114-Status: GOOD ( 14.35 ) 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;