From patchwork Mon Aug 12 20:46: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: 13761019 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 3DC9CC52D7C for ; Mon, 12 Aug 2024 20:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Mw1x/ougsScnxtmBY2VbMZ2aub7Y5/45PLbXjDqPAw4=; b=1R/f7jR5n+3p+v4IwpvbDWzcaK FxPESgS8OYKIXHyMt3oTPGEvQ+zDM09CCqehCLIsfP1IyebivIEe6uIG4NPTCDklZM9X8AKsz5Q7C 5GjgC+tpdZks+8gLlQ/NPacYzvUVGathLooIGXNYInMQWhGmAn/vOE7/AsQW+iSvnLgv+M0TdpY5U dtLRiI/twynkdBHGakz3I/xFhuz1vEKrDrDCNbzLuhDLO5lm817j+d5AlYaV7biz5vNAue1bfGbPw 4ITadh3xRBR+vl3MEtpouEBKj1c6fRIRDTKeu15G92jC/j9SLPJtxe2Cuvj3uXgWWD4/WNefAyLFZ di3AdY1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdby9-00000001Uz6-2mJR; Mon, 12 Aug 2024 20:48: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 1sdbwu-00000001UQr-2URb for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:47:30 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e0e78047c98so7749848276.3 for ; Mon, 12 Aug 2024 13:47:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495647; x=1724100447; darn=lists.infradead.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Mw1x/ougsScnxtmBY2VbMZ2aub7Y5/45PLbXjDqPAw4=; b=Oo5xCgGzRHtUe9iiZgGQVBocRYKMV3ZKYs7FiObNexLR9mxTgjMcPpjeJw8eRTp3Lh IOgOapjuKu6q6UFFiTySA/4ATXKMr8tSHMzY1/BK9gEH6tHqHKFta5dtIVcATKtJS05r 4QOqachpoG7/1i0Pak/lh2I9Cua3XRhvNvmycnFNqyD9kaB29Lxm3qwTUdCy7E6NMw/Q LJMrtsvA3eOg0lg5pkx0stokq3TFqLDXoM0TUjhDH0xJwyYle6FtPaZi9DchEZq0THPZ EAAHpjVDafhz6J/Vu+MnY9wRwSVf8TgvIiGtS273Nm1pLXCyQWjRv4thXe8jvl/DjqAs b8lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495647; x=1724100447; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Mw1x/ougsScnxtmBY2VbMZ2aub7Y5/45PLbXjDqPAw4=; b=hdtoGLWu7dU7SWFzCQ6O4AtWNVrcne9jIT7mDOAosKv6lJ3ILGMSvXNs/jNZ9nTiXT mfXjwxM7+COMZZXGbf7MBU6lz3Fu8g5kABH13kOo8iotBya/DTmru0ZkyLgxpTThE6l4 0G90T7oQsiiqVifY8r1JgTexlR55D/5FGAny47mPpyiAVjKdwaEj2syOAFkkDWe3JIbh 8lhveSy0rFVMBeXa5DFEdLCBKm3xox97CSsWVxT4NNAhcUzFUIjTNoPqZwlNj5sswr8I mCWgP7JN1s0luW/FoUD4c1d4nDDtKOo42ryJSDyweWIxvRfNIZVVvdWb9M6eLOGA6OMo mdAg== X-Forwarded-Encrypted: i=1; AJvYcCUX9L6zJk2LSJVWLisN5JErybYNddkSiWdmVe9BonMJ4PFMpCvS2ivLm/dsvoxVelxHp5i8ksjlv6nvRbINP+qu4umTTlz+HCLZH/Y6983Pzrz0OGw= X-Gm-Message-State: AOJu0Yx87pjIHQlHi/MgBHx7lQ8w4dsurVwssj2/4OkZywI3i4nCjMAj MAsR0lPV2a/SeL2SrB3xnZZl/KNB9JUImi7HNO+kqMMUWn2nM8UnMCbY8neGfshIrfaQpjscchd IGMtNbw== X-Google-Smtp-Source: AGHT+IEVqPro506CNZ07tYZEqURExLs5d8yDbdjWX0R4F2l+/9Y8O6vVryWtIZgEVrLN1SrI5G9Ley3NMLEs X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:6405:0:b0:e0b:edb:143c with SMTP id 3f1490d57ef6-e113c9082cfmr53315276.0.1723495646824; Mon, 12 Aug 2024 13:47:26 -0700 (PDT) Date: Mon, 12 Aug 2024 13:46:53 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-2-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 01/27] perf auxtrace: Remove dummy tools From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134728_663888_60E68FCC X-CRM114-Status: GOOD ( 17.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 Add perf_session__deliver_synth_attr_event that synthesizes a perf_record_header_attr event with one id. Remove use of perf_event__synthesize_attr that necessitates the use of the dummy tool in order to pass the session. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter Tested-by: Adrian Hunter Tested-by: Leo Yan --- tools/perf/util/arm-spe.c | 49 ++++++++----------------------------- tools/perf/util/cs-etm.c | 33 ++----------------------- tools/perf/util/intel-bts.c | 31 +---------------------- tools/perf/util/intel-pt.c | 24 +----------------- tools/perf/util/session.c | 24 ++++++++++++++++++ tools/perf/util/session.h | 3 +++ 6 files changed, 41 insertions(+), 123 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index afbd5869f6bf..fa40f3cb6266 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -1073,35 +1073,6 @@ static void arm_spe_print_info(__u64 *arr) fprintf(stdout, arm_spe_info_fmts[ARM_SPE_PMU_TYPE], arr[ARM_SPE_PMU_TYPE]); } -struct arm_spe_synth { - struct perf_tool dummy_tool; - struct perf_session *session; -}; - -static int arm_spe_event_synth(struct perf_tool *tool, - union perf_event *event, - struct perf_sample *sample __maybe_unused, - struct machine *machine __maybe_unused) -{ - struct arm_spe_synth *arm_spe_synth = - container_of(tool, struct arm_spe_synth, dummy_tool); - - return perf_session__deliver_synth_event(arm_spe_synth->session, - event, NULL); -} - -static int arm_spe_synth_event(struct perf_session *session, - struct perf_event_attr *attr, u64 id) -{ - struct arm_spe_synth arm_spe_synth; - - memset(&arm_spe_synth, 0, sizeof(struct arm_spe_synth)); - arm_spe_synth.session = session; - - return perf_event__synthesize_attr(&arm_spe_synth.dummy_tool, attr, 1, - &id, arm_spe_event_synth); -} - static void arm_spe_set_event_name(struct evlist *evlist, u64 id, const char *name) { @@ -1172,7 +1143,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) spe->sample_flc = true; /* Level 1 data cache miss */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->l1d_miss_id = id; @@ -1180,7 +1151,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) id += 1; /* Level 1 data cache access */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->l1d_access_id = id; @@ -1192,7 +1163,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) spe->sample_llc = true; /* Last level cache miss */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->llc_miss_id = id; @@ -1200,7 +1171,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) id += 1; /* Last level cache access */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->llc_access_id = id; @@ -1212,7 +1183,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) spe->sample_tlb = true; /* TLB miss */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->tlb_miss_id = id; @@ -1220,7 +1191,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) id += 1; /* TLB access */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->tlb_access_id = id; @@ -1232,7 +1203,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) spe->sample_branch = true; /* Branch miss */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->branch_miss_id = id; @@ -1244,7 +1215,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) spe->sample_remote_access = true; /* Remote access */ - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->remote_access_id = id; @@ -1255,7 +1226,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) if (spe->synth_opts.mem) { spe->sample_memory = true; - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->memory_id = id; @@ -1276,7 +1247,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) attr.config = PERF_COUNT_HW_INSTRUCTIONS; attr.sample_period = spe->synth_opts.period; spe->instructions_sample_period = attr.sample_period; - err = arm_spe_synth_event(session, &attr, id); + err = perf_session__deliver_synth_attr_event(session, &attr, id); if (err) return err; spe->instructions_id = id; diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index d3e9c64d17d4..566498ebc694 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -1599,35 +1599,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) { @@ -1679,7 +1650,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; @@ -1702,7 +1673,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 453ca0297c80..aa02c1d7b1f9 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1769,6 +1769,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 Mon Aug 12 20:46: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: 13761020 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 A7605C52D7C for ; Mon, 12 Aug 2024 20:49:30 +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=3OP9aiQs3LSZ3NoWhBifFY5k1xgj0LP87bCzLwLOVCg=; b=vRkPazIiewVLgcyYpiRisiWosn LpOj8LsTcl/8Oj+BiG+QniID3ka7rh4k1r+bnoQgdLBQJ09lV8Z8Kbwt2IKYEymdZn5IpnLrwkJzX 21JPhVWRHsy/EjtKRiaZ6P8ABBruUojJ/OL/z3bvV6E+vdhKTp0F7MGRZe9w1tWFtvropqVHOEmC9 hvFsOoYx/jO06cOQQGtklUNY57koYhWezGNPM3TkV5xjI6DBWN01KfN/xPeZh76li1p2iyi/QOgFO R3F3dWQvHNOslxhlduoIyI1oP/paO8kIsG4yak9zTVGzHQI3ex46Rav6LibhavCuCTDscYNxwNPAL Q4BcXcjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdbyj-00000001V9n-1HpG; Mon, 12 Aug 2024 20:49:21 +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 1sdbww-00000001URT-1ME1 for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:47:31 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e0872023b7dso7659447276.2 for ; Mon, 12 Aug 2024 13:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495649; x=1724100449; 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=3OP9aiQs3LSZ3NoWhBifFY5k1xgj0LP87bCzLwLOVCg=; b=3b8UrHVc2KBLUl72flrU4YsjOXvDwkvcM8epm//YlG1Xfsn8ebVWUL5Bw79oB70nkM ANBo3kVqxNdii/c5rH/C3S9xC9PYpWA84AqWyKVDjNyYkRFMq1uobpm3BH05nvIC451G 4P8A4EB5t0+402nqnfk5GXsVAzRn43AvSA4fu1+6Ww5UqD+lYZCOBDkVkMOvWG13MuH/ ArvSQfwXW7UaAJ33YpOJniBvrCJJy0FJAzVtMcNAyPppjqRso2RjoSndTNSFm4jbyEAZ IgNNnT/GNdjHgqIlUnSMKc8I3s7E6obpFsbJvrTyNDsENbz1y2ctCEuQ5leNOZW4ro8J 5SdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495649; x=1724100449; 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=3OP9aiQs3LSZ3NoWhBifFY5k1xgj0LP87bCzLwLOVCg=; b=YlZjszZ0zH1y66OuTxHx8kdikdiqWJKBXIYmATOXyL0a+xuYN2zJ39nq8+FQzT8n6S XqEVb27rA1pftxys8gD3cZ5cBkzTiY6Gy6HJYNwaKrNxqH0NUfbX3KFXxFa6IGp8FgNi ZCt9Ds776LmKKEaGah59W4zIDgC3vEZxDSauv9ii/Jm/kwcNlhZ1t0MnAqeTRV6isirt AMzlJ81lySS+IBJUk0RSyErwZBk8BqPzazxDUXlo6C71uDRoehTl5u1FwIIZyo7Z+1wE WhhpjS5N3QfLko/lx8ZGuGr/s/007gwbkmSkVBpu91lClctvAWE2yAwOnqrZILn4x7ft sN5Q== X-Forwarded-Encrypted: i=1; AJvYcCVNjBF8fw5Hr5bxauWVjXLKkINN6nDWKkH6TrrE794HWTJeHnInvOCA+I6MpzjcUAxUJ5qZS4nQ3qIDWboopLBTfa4iMMha1xg5aTtAF76CiacMenQ= X-Gm-Message-State: AOJu0Yw7s02AXc1Xj2iA7kcni/q0IF8XMtZmnQo2CCxnq5ctvLefZ6Pr uZP8MNnepMRytLPzxzNBzn80pms1T5J/gVJ+g3mPrDUwA+kgScdBsVMe54mIUNk3rbvoRdWvjox KkffYyw== X-Google-Smtp-Source: AGHT+IF6KGsif2kcc/WLiE8m4uQ1YeulYGefZc5LJwWTscJn9uh205dobOwh2Y783hd/EsBConXuVHwlLeeL X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:abe9:0:b0:e03:5b06:6db2 with SMTP id 3f1490d57ef6-e113cd4619fmr2756276.3.1723495649104; Mon, 12 Aug 2024 13:47:29 -0700 (PDT) Date: Mon, 12 Aug 2024 13:46:54 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-3-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 02/27] perf s390-cpumsf: Remove unused struct From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134730_386361_7BC29E1C X-CRM114-Status: GOOD ( 10.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org struct s390_cpumsf_synth was likely cargo culted from other auxtrace examples. It has no users, so remove. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/perf/util/s390-cpumsf.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c index 6fe478b0b61b..4ec583e511af 100644 --- a/tools/perf/util/s390-cpumsf.c +++ b/tools/perf/util/s390-cpumsf.c @@ -952,11 +952,6 @@ s390_cpumsf_process_event(struct perf_session *session, return err; } -struct s390_cpumsf_synth { - struct perf_tool cpumsf_tool; - struct perf_session *session; -}; - static int s390_cpumsf_process_auxtrace_event(struct perf_session *session, union perf_event *event __maybe_unused, From patchwork Mon Aug 12 20:46: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: 13761021 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 76AA9C52D7C for ; Mon, 12 Aug 2024 20:50: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=8TGuri9nBMC47iHZhke1R0JD1+kLnq3qQztmb3CkPbc=; b=Aast0HgKmuW2U7I1vqPzhw4yiH axgFyZ6lPYe+Vy6Tf05e292miwNdAkL+7yR9VY6HNTPGQj/kC2z+rOJA5Qxa9j/p+d7EM203aZZBb d7Na17a40Uky4oHU9YsjyfLwxXaMm15zpXzJKPuj94Ld7XhdMd53OSh+QksqLGQQUBNj7iLHOdva2 TuKHJDpehy/ZHeO73JPEiLwTUVVEL0a+72ImWzp/D33x7Tj3+/U+VPIfR5s+MyYZ2Y4zYxxrzpUeB Mjl/OVK4QGKZo+7EoWWgpaVS0AsuMTzG+bRitrEZzJC9MdOH708sRE0CIQf3xVM36v1BlL2ZF2ouS mowPPAdQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdbzK-00000001VLU-1A8g; Mon, 12 Aug 2024 20:49:58 +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 1sdbx1-00000001USq-0dZ4 for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:47:39 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e114387d27aso215252276.1 for ; Mon, 12 Aug 2024 13:47:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495654; x=1724100454; 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=8TGuri9nBMC47iHZhke1R0JD1+kLnq3qQztmb3CkPbc=; b=gsbWw9v5DB7i2CXz4t+r+mNhdUArE2I2e+QgIpLziSbxilvQ5Kchz3H9FbO9a20WCP H0qyh+CnSNeBYnjRaWGkzqBYcZ9mfisPMLuyv3iRCl927U5GNB6mklgGN/aATii5XwaF CxpW56YvsvPixSTPCl/g8U1hHxLq7HWyOwRRLwUC5ZsU66uKBxNh4ANBXfWxJTynx3Te 6ibhmZM7tOZiiqVPFh1nM7z/2TG7wmdM7NIVWD4zDU1FrCaZES5go51Rt8Tn4pX1fTVU KvLzYwX5h1caL1HJ3tT3n1PGxexibpUreZOtZL+ALwUEmE2QMdYahztQF+sNBYBHOdeK Xxsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495654; x=1724100454; 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=8TGuri9nBMC47iHZhke1R0JD1+kLnq3qQztmb3CkPbc=; b=C/XwrEAR5vYda8KsD00JNMHDdGnWDwHTzFmPDUbVV5q6anghZuAb1lfKn6SEs1ksLQ SgsBTKJT8N5HoGRSsuV0DXeuIEtiAS1GgcBelKUiFR1h6nGcT+A17NCrZ7WuaH5ivJrf Fy4oQWQ+bEUtDe5qANqKL7Kf8LBgxNh8W9Veb/tlGixfAtJCtsH4XyTbCVXy8mVJnlsf qYsSIJ7GesCC53A3SxqJkUxoInm4EEaiJZ9ueC47aKkE/z+Yn5fB6qIpkUB/HHZvU47S ymRGFnftPyPuUKu6CrhbU8ZsSssOGigZma8iUNhaf1lusDjlUb4vo9FddJzXZz7mVbqO HCfQ== X-Forwarded-Encrypted: i=1; AJvYcCWjmdf4OVrvxugFRA483Ki6RPnsqgjoRb3MqTA8KBOm8wY9/7AtUVumcWBqmLzilcormYFpFsPwpw58vsDKsNyCLaLz4bWY4cm7/fg8S4c5THspA3o= X-Gm-Message-State: AOJu0YwziwAkiJtCxnkI15ya0RigKi9Bma5qyX6dURpUfiuwWbzpcfW/ CvaKde9LeuDJ/4Ft22fEtR7+veJ+tbtRLwDxY/UGTHFZ4KME1sZPDb8V/oGl5qb7xUgR101Y90h QjOkW0w== X-Google-Smtp-Source: AGHT+IE4g7j/2do25VGEQ24B9T20Enwcfkgf0RMklTJd09AwUgfn57nK+3xJyv4ddIn6lQleV/FCUMZnw/xh X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:fb06:0:b0:e0b:f6aa:8088 with SMTP id 3f1490d57ef6-e1140b63320mr2197276.1.1723495653799; Mon, 12 Aug 2024 13:47:33 -0700 (PDT) Date: Mon, 12 Aug 2024 13:46:56 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-5-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 04/27] perf tool: Move fill defaults into tool.c From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134735_250183_AE355987 X-CRM114-Status: GOOD ( 20.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 b24360c04aae..f6f18b4228bb 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -66,6 +66,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 41beebd0913c..5c0e0341d39e 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -39,68 +39,6 @@ #include "annotate.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, @@ -321,251 +259,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; @@ -1677,8 +1370,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 2b12c674768f..b917b1fa6204 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -89,4 +89,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 Mon Aug 12 20:46: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: 13761022 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 D2E26C52D7C for ; Mon, 12 Aug 2024 20:50:46 +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=E5QskrwEwgJh1SEHBPySv+b4dUG/k47lipRxRjevwjg=; b=3KiFII+8tYHtQ7rG30HzIRZ5DN ZJ/+fwdhRltrzoQpRiT3qniYyGyl2OYlHuueGf/SpK/5KTCGpd0Znnh9nKN43LgjdRBFUaJSpQdas VxCCxRXTC/boQGZlUD7gstcJAD4qTcs1nRUOkFX87oXzjfkUD64H4dYvUs9Lh1kxIAnLEgyNCso3U XMWnP0crBujPCbpvnbAZ4rmKdPDNLf3ZZ9Xqs40AcEFGWtCpdtNR9LxmOxVXV6hm2QfBvX7XhhSn4 zzVjg79i5tLdHdCe5NJTWoSaGtgAfR95V8/ZtbmgI22YvdB+GVVuzvenVu2quEa8T5IihWy49B7ga Jk3rOmsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdbzt-00000001VWK-42NR; Mon, 12 Aug 2024 20:50:34 +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 1sdbx3-00000001UTK-2f18 for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:47:40 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-64c3f08ca52so101326587b3.3 for ; Mon, 12 Aug 2024 13:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495656; x=1724100456; 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=E5QskrwEwgJh1SEHBPySv+b4dUG/k47lipRxRjevwjg=; b=sKUg/5ZCFKJA7v3sKryX2Wi8EDEv4mRcu7K9iRoiURsWqbg/B5sFI/S2zUt7p3P2yf J6atgfVYw0wPy8FJieMHhKsZCdPs3y/ZsnxknvYZrg4A2HTjqWmz0f01X/NZIyUkgOfg e5+MOVjVQR+ktt9xPkNIieDaOrtqfKUVfhAvWufb9xjiARBE0Hlqpo4scLtgU1jSpltL 5YCXsCMysJBPk6UHjpjmcMTU0sxM/erm5S0AbSoZU11rJpSEd3EE6M1/AWGfYRsXJmxp LnRtAevVc42EaBcWbp/W6pj4ZktY7E6urexr0dKZeGE5qMkgmywxIdXtLA6zABFKYSLe UM9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495656; x=1724100456; 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=E5QskrwEwgJh1SEHBPySv+b4dUG/k47lipRxRjevwjg=; b=rWrvhKZTzvB8xYcXJV13D/0sRhAkqTmK0vfuZLpz3jsu3Swt7A6ma4iHec3TqG5lpQ 9wQVLrlKbAKTQvjhGgjrQ5+h3Znot8TCyHTVHTAt6zqThzNxUMT5jIhX5/Ayf4sogT4G IMFm5Q4RYfMSjb96PMOTk1QqTx/F+gXMaURjTVVpIR1WLuov8TjqxAQWSckWcSI/WvAG O87JY7W4wxz5FB0fx6xTJ3YcVNIaLJc1nGGWtL5P7tcOL4GRm7HI9sxVOq/xLKcd41fq ZwWMabiIRsVUbnzRW8kBzs7MFzLsM9DxRsObYJWMm+eoKxSTVIQyD9lOlSl94WE2ifg+ RP6w== X-Forwarded-Encrypted: i=1; AJvYcCVSohXmuEro39iQC/vYyLe0dxtzrkPZgXnASf0Y+yJcCGCqIjvrEc9Y+KgLYQgHCTgabOOM+b5WnLuAbTU7gyWSkNu59hq7OM1JOTz5+5gFwq1be04= X-Gm-Message-State: AOJu0YxgR3zu6ouVYYn3vZakfUiTif+EAzAtouKORkwor/rxrLOKZNjF xnLBWY2SdvHBmt7bnUcfNLUUQJ3JWJ+he7aPdB19veX50SkYCh8zfOcDBaJEf+LfQJ0XyPjZ9uJ /eLjASw== X-Google-Smtp-Source: AGHT+IGYzX4ib/mbR9sRiEgZk4S2Ro0LhXD3PEY8JFZJzNim6QhGI9Yre46z0AplBbBDzJBKz1DXJDGI2in6 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a0d:e4c1:0:b0:615:32e1:d82c with SMTP id 00721157ae682-6a97732c587mr106997b3.6.1723495656210; Mon, 12 Aug 2024 13:47:36 -0700 (PDT) Date: Mon, 12 Aug 2024 13:46:57 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-6-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 05/27] perf tool: Add perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134737_748845_43307233 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 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 b917b1fa6204..7c7ce395e573 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -89,6 +89,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 Mon Aug 12 20:46: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: 13761023 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 76028C52D7C for ; Mon, 12 Aug 2024 20:51:20 +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=GSnhy3Vr2qERdCmMnBMzUq3MwYF2csqFbHWhPN6IO30=; b=PNezMlO+UUBJggF4ABz2kHNNjh AW0ptO4cUieGq41L6KTrxM+ZlMqcg2iXJs14GYO1SBwH/khCYDxT9ZWUOuedPedGL0QR5tzWjAPFG PEczsfZoXIETyv/0c+848NBNvWbaqcUBtpI3tK+jp4+DsGxuyVWE7uYiSTD0Ng+FaU1Wr93CYROuL Qr1ygAs8qbglO51/HD7/KEzl+T+Cj6Hm9gKNqVtnuMZGoEIwIJEAAF6mONKlHBSs1BOHFtDz1tqi6 l+niJ3TkXjCFth0A7odl0r2ThdYmooXbWOMKjYn7XNG2PKhjfhJKVIv8DfOIllHpyUTGz6WRlk8xh Zf6JNVUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc0U-00000001Vi3-1Ln3; Mon, 12 Aug 2024 20:51:10 +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 1sdbx6-00000001UUR-2KWQ for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:47:41 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-66a8ce9eecfso77884637b3.1 for ; Mon, 12 Aug 2024 13:47:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495659; x=1724100459; 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=GSnhy3Vr2qERdCmMnBMzUq3MwYF2csqFbHWhPN6IO30=; b=X+RfK+qT+ZTEKxWJa4+ILWRWDpjecd6PTGi11DjuJYEjQJBT8j2XMKpIcRx+6lVHSs kTVhg6M4jYhFtVjpOfkw7UfpKzVgT3r9nahlvPOccAvG0nzZWleOJ5FX4NwpSGR6OQUL uG5pRyIrDIp/AYRyJEuS5O9+f4749lY6zDuum5NX5a7KepYaiB+WeyrAvg233yzBNxxN T20WRRF1sFIfUOs/lasexNe1tR/JoFJeegMdaEycVqr3n5DMZ/29QK+nOg8urRnh8vbw BedQVBOvDcZtSwMMwOxB2UvdUBCw7c5Jf7pLa2XRH7BKOHoGvnZpGyehWS0NdQJE396s eSPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495659; x=1724100459; 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=GSnhy3Vr2qERdCmMnBMzUq3MwYF2csqFbHWhPN6IO30=; b=uFBny9A87cnzpoZxDgOYCD8YhfL/X8OdD50eHn8EnP+T9O8I8UcV0pTYVQFaDwmM9m Ii2vimBYnsnqtwexPMt2W1tpfiwlGQrhKzGsuCyiSYU5PEMvS8WYzWfEtlbwBFYdZ+44 Ped98l7YWZOsdlwBgGkYTp3GDO3YGJ9gqQNahtIAL658KI0+6EwsLCPhKXEQVWRQGxR1 xxLBPBKPvbddhdBcqSqNOJJwfSEX6aX1m8VWplz3PylJuVhoRRRrS4/OjYGa+P53o4Ae jVECi5bPs8MsMTpF4w3rRrggP9EE41Bw+G7n08G2qfld97RqEr2i2ZoX2Itu+F7EpbMz 2gYg== X-Forwarded-Encrypted: i=1; AJvYcCUGzhEu/mOGvU1NdkoN4TvK0r3WeqpZSUF5X/FMvHnTh+r4riwOKiVvHSku/rN4k3gSh55q/F1d6HDxf1rPsUJR799YtLZDnBapjCWGhyOBrtFr3Nw= X-Gm-Message-State: AOJu0YyzJqb8tej56zWlBzpXKao2d56Ze/OGjQtGRAdzS6IkJ4FDXUgr gLfz/c+FJWPe6oMzHTIc+ykUII5z+m3upU+VuOkt2j0VAaFx+wSWaKnhiqWCc+Y8F+geFkayZUW Qn+AThA== X-Google-Smtp-Source: AGHT+IEblpJwdl6278PFoZ+5cEGAgnioMooSJ+8EN/KwaqJevyVV+yvBEdMZq1rxI0gSMePlMu8pFsWGn/7c X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a0d:ce01:0:b0:6a1:741b:b723 with SMTP id 00721157ae682-6a9ea8e5238mr117867b3.5.1723495658586; Mon, 12 Aug 2024 13:47:38 -0700 (PDT) Date: Mon, 12 Aug 2024 13:46:58 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-7-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 06/27] perf kmem: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134740_646711_B0678780 X-CRM114-Status: GOOD ( 15.60 ) 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 Mon Aug 12 20:46: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: 13761024 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 9BF2EC3DA7F for ; Mon, 12 Aug 2024 20:51:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=v61QA+B40h4EB/AYC1TQM7xPmAjFKFUMVcOfqbmd56g=; b=RJA0hMmCwRgesuh/YbGaf6tW9n lFXaYIk02OmiuZESaD73zSGPFU74m2rXD45LglNqhnu7l5nHUcy+sIAu6XbCTzEj4NBiW/9HGarOd NgHDplUq0EV+4GZT/plQOqXhOi7LfvwZWAV0kVyhSuvE5xEOyShFn5Ymf3CW0j9ZYHz3aoQhJmJvz uKlipLBNVu2g8v6PqH3jtkOWXQnVa7L/Pap5obylZArF8bx/3OjOBZbFAvgCS+JdBIPjqEEzFlUBR N6DSY1BpOeO7J7AedcyjnYcqIS1q/JV89BlVQzVBxzCrb/RMa46Go3NJmH0xxY30POLcU/wLEIwYU 50RthaVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc12-00000001VsQ-3vom; Mon, 12 Aug 2024 20:51:45 +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 1sdbx8-00000001UVH-0pw4 for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:47:44 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-664fc7c4e51so99140827b3.3 for ; Mon, 12 Aug 2024 13:47:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495661; x=1724100461; 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=v61QA+B40h4EB/AYC1TQM7xPmAjFKFUMVcOfqbmd56g=; b=PDkUsgCkyfYDyzmJEhk+hy38FftYmMEiLWPjfHQ/0Vy58RQjDIeHJ/z/dmoBQZYVkI 5lP1Eqi5utEfLdzWDVmzrey3ZOnfoQH6iqSek0HHhKB4NCL11bamIxux3JqwSuiK0Dh5 GOH9ue5qu9zgd5Djfu0WVnXoWiCPnLzF3zeGd3mWM+4olJlTGAZuRCKiIZaPCbquZo9Z 3tyzUMFW77cYacd7NuT6n5m05C/99QnAzmQCuxYo+nMwFDd0YybdwQqSI4Q2/hfgCSwa qK+9+gW9L77Y55ckExa1Nd8oo7bdtNcY1MeQSYPePt2pJfR2mV5cRnyLN7Vl7K2zP7sV WSFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495661; x=1724100461; 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=v61QA+B40h4EB/AYC1TQM7xPmAjFKFUMVcOfqbmd56g=; b=Cg+0SHAFMoJg+VNHrRxB/CuiEElLJ8dDMs1KhmF4/u/DAC2xj1RFDxkPPpwtihS8Vm +lUrOwytx2w4B3b+iPuWnosmlZSDPh/1Cq7KvkIbr3GXAEEmw1ygs9+vnRRNptuQ8XUA S/WVf5Cs0pbLutM1LR1vw1GCh/K46FfkYKSbFPgQHBb1X0qAYyrHtkGA/TvDdW9GevtC Q/APUpJN4QNfyltEtXjweCsElJNWhP/M0/qhremcqta67MKxVh5CXgcD8pxUGd6F4ERU 7gkhMlpi+N8vq3Mcd6hANF5VSA3boFZ7Ngx2xg7tfDdMzbeLaY0Hr8v4WpoX+lI9s+WF StTg== X-Forwarded-Encrypted: i=1; AJvYcCVHMbtZSfKDo5Yor2wtqumkAK6MMtM2Fz1vsJSbwLAHd9ci2OqTezEy1zY8WK0qxE3267p/tB8KBekOwMj8/obe@lists.infradead.org X-Gm-Message-State: AOJu0YyTlv64pODh7l9zsoFEWYnsl5BUJQiy7J6iOg3QXevkgSE45U7d 0OrfHKM7jBioF5HN4FUsvcCzCjBZj+lfwaeMQriagYBBr8UJd5jScS4yOQ2PVprwtQ8S5m3WcSN mfLjWlg== X-Google-Smtp-Source: AGHT+IEITAC4glbaWo+rDcNbbdxTZMr/2iHGOGSRmojml4G3PiALa4ESNz8qcPjFfsws9FZ2DMfRfYURndma X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a0d:ee84:0:b0:64a:8aec:617c with SMTP id 00721157ae682-6a96c0410d3mr708277b3.0.1723495660960; Mon, 12 Aug 2024 13:47:40 -0700 (PDT) Date: Mon, 12 Aug 2024 13:46:59 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-8-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 07/27] perf buildid-list: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134742_364186_78B75F7E X-CRM114-Status: GOOD ( 17.94 ) 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 Mon Aug 12 20:47: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: 13761025 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 735D5C52D7C for ; Mon, 12 Aug 2024 20:52: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=q+ZE4hGaGGR3pP4ZqeWSlnNcqmSzC0PMM/ghgc3Fa7Q=; b=YkjJsEPqVlPBJ+QMGKbeIKJVwc oF4KGqg6nEKJiO/NcAFLjeeUEWhOHocBb5BTKcHW+nok9aOaWLMrVPxDim2esTyvom4NtX21d0gBL Nv5d/zbfl2kA+CW5bT4GrzJjBm0sf1ek7yZBCHcLiYElzCXcyFCVn9EEtkxjyuTh1ITvlK1hMOjG/ uqdRH935vzENs0bzayh8avB2lAAPxe4JV381XwzmEdSxmE78LlKywkit7H5zW6YuTSo/wYOLUFa7W hg/ZvAsx6uyOvNkQDdJ1Zl1ITUh92ivXgluf+6jcSE26Qf3nwmcB1GyFRhigvMBq7rnTaMtL7dPhz muPDwJlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc1c-00000001W34-1dlZ; Mon, 12 Aug 2024 20:52:20 +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 1sdbxA-00000001UWp-2OTv for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:47:45 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-672bea19c63so116320417b3.2 for ; Mon, 12 Aug 2024 13:47:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495663; x=1724100463; 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=q+ZE4hGaGGR3pP4ZqeWSlnNcqmSzC0PMM/ghgc3Fa7Q=; b=aCCWzpL7Q4Y4edo7IP7qX8pnqUjIa7ndy95vxu4up5QvbF6ol1v2VJJ/V6mjancH6Z wTKiyNFpOyJY73okWIpOVqNf374uE2VjZhBUIDOJGOtNpTVcrkp3vfeNNOrEmCvvjNS6 y0cZD5W1rkvnKLR/+gVMn3FXI1lUzHd5xfi4VQYigULJHLHvHHdMNVIdigx8hwC1Ig0W yOV+sc8fMqDzK9rGI0jdV9i+cCTwAoFm62kef8VbeagEYWbOgEwmARCwkRixLXxlzwEi lGNxtrDmFrxZCWlojRfkAMUN0dfvhfU8HtFv5ASzDQpxU0v9ugOMcEypRuaQUW5Nx7/4 U8XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495663; x=1724100463; 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=q+ZE4hGaGGR3pP4ZqeWSlnNcqmSzC0PMM/ghgc3Fa7Q=; b=gs8qXUGMOIW+TpwR5lDTEwvJ5tUWuKm1FVGHteoUUEsdlZn0eZHGmPhLSZAxsLAbv3 eRaYiG1P4uU4SrDD6dJolArWk1SPcOaC3P/CMzvPbTMiZyG69lwu/sf4b11Xhv0iKovV 0MOne7+/ntcs/5xgJ7oeNysmJwUHiZG65gr8EvOFe7ho+ykLv0ODG6LLAksM5q4XD6jo JsW2ZNVuOApC1cf7bKIERJ1qlBYzKjyo/4z6aThLRUQGX+/E7Bz0zGhgAPJMTIlfDon4 g7/j2D28e8DO8yb2FpP3hcbKoCnyw64wexsI9iCHXpL41pjIhALftXuaAwnVfsyA9TDj 6HmA== X-Forwarded-Encrypted: i=1; AJvYcCUkgM2ug6wMjp2QDoocCz8MPmSH5cy+A5w27XJx3qInn7/isdjR2ATU5f2FSrsUiXMBenfsdiM4Ik28XVJi7BjXzxXJXFYRGf5OeKYinDNdDfm1jfA= X-Gm-Message-State: AOJu0Yxi01aRt8RqDOch9J74SxXbnuL56NVmKrEJ9dt7Jkrd6HMhDeq5 TCF3Ft6Ns2ppba30taT5As9Neh/nYp6hUNm1AaKBCR3zuA4mwT+x3noq8Kr5YnRAyhrBl1vWtBG M24d1Nw== X-Google-Smtp-Source: AGHT+IEerIYYJMTu/WL1AAclxKU7AxacYY9i7Q1kNURomiSUM/HLMAaiSiuWQSgOAjqMtefBIzHzejkjQcGm X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a0d:fc03:0:b0:646:3ef4:6ad2 with SMTP id 00721157ae682-6a978785122mr109817b3.9.1723495663340; Mon, 12 Aug 2024 13:47:43 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:00 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-9-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 08/27] perf kvm: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134744_652207_B9DA7964 X-CRM114-Status: GOOD ( 13.64 ) 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 Mon Aug 12 20:47: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: 13761026 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 0EA58C52D7C for ; Mon, 12 Aug 2024 20:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gibdVPBI4QwODB2QVabO7wcogY6JGDVcaHEIkpe2Azo=; b=mZ2PdtgMTffN3YvHHkEQ9XUdTo 1dmnB4hh5cK9nSDXA7XyNu97WJaB9T0DN0QenDNDV/C9yOA0ourfjB4uLG6J6nuxqLP0JFte0KKoZ Vm2cuvM45zfoFcx68XwnZtUhKn5uE8PrtZya0hrbaavEnKtw/GWvM6Wungb+aX+Q5Gh07k7fWXN7C vJVeAQ8U98tN/6f7RvKC+GVfoomP2wP+cUhYtOwGYyHkxnbctqukFrjlXV5GXI15agRfYcmPOEdRD I5qVaavF/9enJu9p/YBnbVrzg/VGjZniFThtz5Ifc2+WnMYwPOG6hcwPKiA8auK4jcXSFhmz0QKtQ eOaDkXbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc2C-00000001WFU-1FXi; Mon, 12 Aug 2024 20:52:56 +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 1sdbxC-00000001UYA-3y17 for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:47:49 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-68fd6ccd4c8so110125827b3.0 for ; Mon, 12 Aug 2024 13:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495665; x=1724100465; 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=gibdVPBI4QwODB2QVabO7wcogY6JGDVcaHEIkpe2Azo=; b=xM6v88axOnhY95A3sUTZ7j8Ks4qYSoau24nuucevwXQUtbtUjWIcv3oDFQM0iA8QMO yPHQrwUOgrJLNet9TyYeMla65U86q75sMXIK2w5rO8hfV9fdzMoDxV/HviJeIswNGR1B KJ2LGehBSSxKOCZFY1z3nCSbhcGKyRtwPoMSqaUMgJprri2/XwkZV7WyFTloDGw52XyS mLpHezEBtgdd7EVFQA4mn2d04i+KPAC/GcGDhpR91ZY8Tc5vxOYB/0ZeM1EEjPUUCzQk Y3nbMApPF9JoTOOoqYJpc5uQpjlWMZeO6O4vbBf6+Zxgaayek8ZjY5UV3usFVir6lpr5 lwrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495665; x=1724100465; 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=gibdVPBI4QwODB2QVabO7wcogY6JGDVcaHEIkpe2Azo=; b=Yfj+46oGOCkTnWSjxradrZMAe7Dp6P/TuZtt2tSsUGpnIMddtJaR7vJhjPQMduV/ip WIk6Wl2YH2v0GZzoH/mXOG1JM1QrPI3/0ZTm+GbRtm8hmwlIqgbTZcMgfT2ZlzDLBLO/ d+9zrdy/gvdc7Pwu3kNm78yHGucoz2hOg9rRXLapq3AUMnGc1CIC2ookQLC73xwa7DAa dfg13VPflHxqrwm7UEfiBLJLJzoUfZ67aFbzaFr6cY0tGzO8O2QZySXTj3WBa8LaJJfF 6SDbv1EATER44n/eB9g529LLzYYGhCqthjV1aMnVMLdjpRGJJsLD7PN/ePP9wzaEMq2T qnqw== X-Forwarded-Encrypted: i=1; AJvYcCVVphJVKWRa2fOnIsSuPCMwJFnQnNThSGCqEmDkV8SBDBvea469N37JSMUXstiPuxlTssqqcdh1kJ4IN7KdMt7HAXNfZU8GIu4IoOGuMWpNDoYsTFM= X-Gm-Message-State: AOJu0YyqeU9Y4Ss13Olmdz3W8r6jrumd7CHPnlTCZhnnZaIG0zjICjob /DABiVdUWOlDRnlcZ3ry+AWOpk8qgAGoEQbbJ2yWLtrhHIeogDQUjPOcbswzBif0p9I2Yi+1RRt lqcWxyw== X-Google-Smtp-Source: AGHT+IGcoDxlV6ReTDwa/pGeVDkEANIGIX3sSvxNGP6KX8/qg5oXdLKJGk56Ow4wd4MdzjIcDYZvPHQNsid+ X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a0d:c303:0:b0:61c:89a4:dd5f with SMTP id 00721157ae682-6a96c6090efmr432737b3.0.1723495665556; Mon, 12 Aug 2024 13:47:45 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:01 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-10-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 09/27] perf lock: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134747_011290_F4A938CA X-CRM114-Status: GOOD ( 14.24 ) 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 Mon Aug 12 20:47: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: 13761027 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 7FA0CC3DA7F for ; Mon, 12 Aug 2024 20:53: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=3DV11m8aSPlwhVbL5UDuJIqeFel/OEDD4+3PWN8l4CY=; b=PLrN91bIvNjTNUbgGHQSxgsb6u TkY470FjA7757Df/U6/Hyu077p889rdc3wuTzOeNOPZj/PnITGG1w81X+SngYoEcGHPBo88RL7lDb nYOKa1QzhnPJiMYfCij2IBS+Q9YqjGdFI/4abt+QPwxrnGOvdW4Fs917Pgg8Ig87h3+a7e+YZ1+1/ nMVg9WjvZ+3ciIGD3HrY3zCog4XyY0O8mYYEdlHPMIHCWblOXt9dWfVXpW/7j+MjraSi+1vZsqQWL /2naIZVWx9O7eIa77Iq3G+DcSHzhiWZGwQw3mtxjK1krO2ez2DWmJV5ISBmJb/4ASdTYDF5dcpIop QEAXIhdQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc2m-00000001WR2-0p5W; Mon, 12 Aug 2024 20:53:32 +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 1sdbxF-00000001UZ9-0Nmw for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:47:50 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6886cd07673so111800937b3.3 for ; Mon, 12 Aug 2024 13:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495668; x=1724100468; 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=3DV11m8aSPlwhVbL5UDuJIqeFel/OEDD4+3PWN8l4CY=; b=4awzg/Ka60Nhq/LF9zs+i4gMlnX+s6F0MvRw5tgXFNnkfLufFTcHrU75RCtAYeLY5r lPvzet2yA2plegO/qQrxLoEHo1wJlG2WNwsHoGdxtwzZcFgDdVDBcK9YzJXNI2r6IpWR +iDfO1J0WAMX7YhFk19MgVJQsGtDpxdXgAYpc1fCqS9LxEbeoKMkEtsRm3mQA095fvoE IdqrW5+YaOmy+jfxT0mQFJ5+vLmO+tlL/BYzLQYTPbCgaEj/xVHf9tmWY0Ogyr9ZbPqj 65g0lO9g2Hww7BugPXmC437q1hu3NBx4APRtrdrjVsbj9j90p729s5M1KjnKIp6Lptm+ +2gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495668; x=1724100468; 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=3DV11m8aSPlwhVbL5UDuJIqeFel/OEDD4+3PWN8l4CY=; b=pGXvf/ccE59zLm/T/84btFisWyhEreCtILVRiFdX32Yx0o7qSGVn3ZjPkobT3gRbU5 ovBO232BQYdIMuCWk+3OiUg+QnknoPsqLjAtH4Pev017ZO0PHoPUJ2kQRTwbhz3oTWOS ulWPQ5mUuBdDpFGNJ+We+j/kYET7TlZ/ykZDpF+90Mbow04aP6v5TS3JQ6BZbOt7wJwo ftn6DUdMQxgbGV7BjSwGObIargYGsiTIn7w42Xn1oanGY8Rd8iUK6KntCFeDwer9cru8 dCIbJ9GXApAuhe0q9yYN9l00dHZLrzy3E5ZcCjdS3qlDmQrhGWtvhYb3S5FMNDdKwwLi HKiQ== X-Forwarded-Encrypted: i=1; AJvYcCWlNeCJjGF8ZrF5CVSnqktudif3edx7cF6JEhyhb7TaMwO0zKcqE9I7Sl5zo2zX//lMBsiuB6mhqfqzXAWxH15AsVHga9TJ06IYuIrRc4X+LoWtyxs= X-Gm-Message-State: AOJu0YwRmS/YMmiv27uG2mHt7U5GL6SQ4woW7EF6hvBOTDDzG8CKFYOF xYQoFGdLZ6AtAGvvnLj7xn6CifGA927ZlscZTU3SOZqoq9EpMlQrEMJtiHZENm2YpDpN2NY1PfZ ToOm+eg== X-Google-Smtp-Source: AGHT+IFcMvZcg5ZEAFVSHmNQ3m5FSJyneWq44MKK+WXcjN+tqvmi661PGCnO5YGW6UXfSarvChqY24R3j8Qy X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a81:be08:0:b0:62d:a29:53a0 with SMTP id 00721157ae682-6a975f92448mr366107b3.7.1723495667983; Mon, 12 Aug 2024 13:47:47 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:02 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-11-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 10/27] perf evlist: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134749_164306_F22FB284 X-CRM114-Status: GOOD ( 15.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-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 Mon Aug 12 20:47: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: 13761028 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 16972C3DA7F for ; Mon, 12 Aug 2024 20:54:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=J3jqi17epiT5W5NpHtjXH0dEG9gj5/vhoZ4ouw58D8Y=; b=uLrVhDgxLWIivYjLwtUaRhaF8v IkN5vd24mY6BHm63tWb3HhBxD9/0SeA8+0hhe0tqosRQRsCY5rfitDuEwtvUca/L4VAA1rNojgG36 Ms7FfRr1lcNrZXC4j+KvoObB3TSezlzgBphx6pXzbzE3edatrb5PQautKeQapqnjzEuv1n8TfH005 hmlF+0xVh2+bYCOgYGvPo0CWRYRxLnnnZz8A+UY7GYjRq5FmOHt9zW8WGSm4zUfyZEJhHI8KERrLM bYN54mb1+lxwwmamb3Lnk9plla+vVxILzhyC17TYGuZQZfl4kiQdv1/FO7vJYkLXyU256WeQPegoV KB32rZ5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc3L-00000001Wbs-07Ey; Mon, 12 Aug 2024 20:54:07 +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 1sdbxH-00000001UZx-1xNM for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:47:53 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-664916e5b40so68394547b3.1 for ; Mon, 12 Aug 2024 13:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495670; x=1724100470; 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=J3jqi17epiT5W5NpHtjXH0dEG9gj5/vhoZ4ouw58D8Y=; b=hvx+UFgmmmAEVbocvL4Z54qCICV2VKyJdoj0ySdemKCa3wnt03f4+50KmHuosKb+vW bG4Pv2FSaJJfkfXe2iQrDnhxevE03s4m3pHGNLwyzy1s7ZNIEB6BsooqZrz7WU6uq3sZ D8zwkbfU4O9bbxR+jI3E/d6HLnppwC0X4JFXv9LvTSV3kkCJX/dMS1HMrLaMhsgE/abC tqUsRBeV3OaoXxsn00KQRiG9sLLNAEM8lRqbBwLh5mC8r/fLJYJJffUvszWu4fbc60CN 3NXx0LNDfSQRVvAt0bbAQWn7MePBzC32+COQIylmmRKEWOdyDw0vh7FiT+KVzBzrGuXT sDuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495670; x=1724100470; 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=J3jqi17epiT5W5NpHtjXH0dEG9gj5/vhoZ4ouw58D8Y=; b=njvk5DbbHPtTOTIXL3VfaZm0bocWoo3M2cKIRAhxHo6Li2NMWklBF/yuDJdBmhmkC+ V6bWGl7PCZwMoHH1ioe2m50uKzLQNhiTjsZeU/uq4BvmwxdIDKkXokZaqqjDy40aY9Oj 6XD++Slcxw7OWrDxdxG5VamJj0Be2VaqwMGJ2UhqnpoxmGO/eovfN9o35LzXWuA1hSwp wUDlGrJ50/w9RI6o5s7ojjRzs6PzLFhlmXSqewvi/POEKOCQzoyWsFLMQ86xrfK7dPbY ZE5Ha7/+oTfghOtbK9XxVEcFIbvjiuyvkBPKS9BenykS7zKXgsFYuhls60swxW0mquZL J+ow== X-Forwarded-Encrypted: i=1; AJvYcCU71tRniSgr3sHXVwWEh699VznE9u6oWmArXRFvESJ46QPa2BcxGuBRrSABTbd0IfhUmbIHxi458dyRqFcrXoVI3ugadVEBrvp0sn25uUIBe4wQjGg= X-Gm-Message-State: AOJu0Yw28TPT2JD0FcW/5JW/stT8CfF0xWyZcxzINq4goIKc4TTBSFeq sS0J/kixRZR0LzQ0usfUCj7Eo1e9brXA9OPg4pUMGM8gL45ijGLhB4F0ieTO4P+G2aP6nKnAAmt uVOK4fA== X-Google-Smtp-Source: AGHT+IEUTe+31u4c0XlLwpy08DjQKT6rgdB8gr9GGhJp2e2MdzhZe2ydsJffGE/8HlJ8ES1MJe7plUf+7SS6 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a0d:c6c3:0:b0:644:c4d6:add0 with SMTP id 00721157ae682-6a9e4c87a4amr142227b3.1.1723495670221; Mon, 12 Aug 2024 13:47:50 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:03 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-12-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 11/27] perf record: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134751_569254_BD973CC7 X-CRM114-Status: GOOD ( 16.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- 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 46410eb3a76b..39367709fd99 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -194,6 +194,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) { @@ -1459,7 +1468,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); } @@ -2387,6 +2396,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"); @@ -3327,18 +3346,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 7c7ce395e573..c7fea58729a5 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -94,4 +94,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 Mon Aug 12 20:47: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: 13761029 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 E480CC52D7C for ; Mon, 12 Aug 2024 20:54:50 +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=H+nsPHTHHGayzU+LXZk3pnh3l+7HMNM65zEgwyXyMdU=; b=OB4U0CCiHwZWCnO6TMRnLOljOj zV7WPT63bHqli2lAlTbVZ6AcBbvJ6V/kpE1guMJ9j5R6kLFT2wXIfrTvxKaMu9GsqhxaMfcLMFpQL Fs5LAHLJ5+d0Mr6oou3eCx89B7KnyJVyPd+9Ncgyvh++cWf36STz+VkWTb6LFqmJnxB67PSfeMiFP DLB7jx5d+ETAH112w56IUXdQH+UpUhGB6hBHhitUz/Dd+1SqudfpyBAk0dEEORRrOYhbz3rzWqHfZ +T7ZZ5cppMx1KTGmZoPkbPiN2uvM7963pojKSielLoF0aZXxnn3EWOyOtQ4t0QXO/iysouhF1SEX2 Ftaj90oA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc3u-00000001WoB-3EXn; Mon, 12 Aug 2024 20:54:42 +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 1sdbxJ-00000001Uaq-3VDO for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:47:55 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e114387d27aso215852276.1 for ; Mon, 12 Aug 2024 13:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495672; x=1724100472; 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=H+nsPHTHHGayzU+LXZk3pnh3l+7HMNM65zEgwyXyMdU=; b=WNtvvuKsYZGypf/uwn6xB9loXF3jdub8wprHK7w3cm1A1cmn4uakZ9URFFcNnyYmOA wmsdJUP9VVNPvZnqaJfHKJCGsCfQj2Upr3nAQAdcpqs730YdwGrFPKO85zbUZ8OrvtIv mL22hbwb39wpJ4qOIRP6Vs0mW5PJD4JBK89KBaTsCv6UZoijf65C7DhpPIwbOlLUvYsq hrkV4aePjIVg7DFO7q1LHkfgp1XbO8RZQsSrvO2t3pA9LQMbWyDykrhl/O9ih2rcCTGv p+QCVFOXSfgULLGdHs1I1MlL0yasym3uHihcIYsFLQu9EoggfOhen3DMOqETX6QqBkQL yvlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495672; x=1724100472; 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=H+nsPHTHHGayzU+LXZk3pnh3l+7HMNM65zEgwyXyMdU=; b=krkIizfL1+8FM2LpYSCmapT7mF3Xj2pMZV5Sv7vpvhVqU7EjlNHgH/n1mup5CicKwT w5OTzNaEOpPuyHApnXtFB/WhE3N4G8480ZQKbI3W9UcIkT1UyAH61x5v4WQVJjzt5p4Q /UKHMuu630bRYI+VAEupqOePiMglcNb75j5dyd8uYZmnypA7j9r44hyuvLyaTnjnKfi/ fN86jeZSr11qPNqyc0I8E4eMXLepe8M9J5E/f6VjWhU6Lglp9Zw3S/3EowpR2pxQ3O9E jUGh0rnys8pxFNYWMbYWudEWuHGppzL5aVv+YgYiRtzzsUiYjytHmXzT7NE/Wrd0W+WL Eu4g== X-Forwarded-Encrypted: i=1; AJvYcCWFaR7YJARV4cfrbKhdXh+MZN0Ns/YXEql42BNJeX5qnEH0DudRHG4lx+dB2LS9sPKMgoJZWzDRWOMowpRQ+bBCYxTn+4FqMYpntog16G2YfBPcPvM= X-Gm-Message-State: AOJu0YyYg9+bIKYypdvsW9e7/ds1oSctOeXJPS+dRI4q+InwDyGBFl56 FuONZCswf84uAha0JLXg08GkRb2adxCngTtDLV0zIXq6tSqeIQAtJ4rPKWITmzJ6ri6TzQ/Yybj 97qRjlQ== X-Google-Smtp-Source: AGHT+IHaVCmGUqBY7uxyQBoBTmxx2l15/jbG59J06sz/NFX3hwioeaXKnIwZ4mNQYTPD7YuKY1X5NozY0ofL X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:ce90:0:b0:e0e:ce2e:abfd with SMTP id 3f1490d57ef6-e11408842ebmr14655276.0.1723495672523; Mon, 12 Aug 2024 13:47:52 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:04 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-13-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 12/27] perf c2c: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134753_896825_B0F82B0F X-CRM114-Status: GOOD ( 13.01 ) 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 Mon Aug 12 20:47: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: 13761030 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 345A4C52D7C for ; Mon, 12 Aug 2024 20:55:30 +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=sjc2eLEDEoqOWEk7kdawEPHb3ceHGyCKWkqgoVjnHA8=; b=W/0PJwBCVvaBkLORj8hACWijs7 Xnv4jxcT/hZdzUBqmbGCv3+Q9mtPFJ0Y1/FfUmR2ZpffsSe+0wYzpcRIEHOdafr3lSQJnamt51z7w RvVXF9/BK63edJepskokFTK1zFFK1IGlqDCUwMORKa38TggV2+gn/CgOVU/q1LI/yQEMw4cOqoz7u aIG3BksgC0ttWyXY4e1JP6yKyGaFNRq05LN5S4S4qavxUw4jrGfAe7l5en0ORH26AWJzSzjt3YQ6y 4fCzGTMKkKYlxYOm7nXuXPPD3pVlJgF3/SHfAgrMobuv3kMHBi69UvIiXBZAotUwzikPUWdwY1Itw LWr2jhoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc4U-00000001Wzb-3G1S; Mon, 12 Aug 2024 20:55:18 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdbxM-00000001Ubs-3AE4 for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:47:58 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-664b7a67ad4so111398237b3.2 for ; Mon, 12 Aug 2024 13:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495675; x=1724100475; 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=sjc2eLEDEoqOWEk7kdawEPHb3ceHGyCKWkqgoVjnHA8=; b=J3M5JZYliZ0sKaUfNF1Gb1jiUQ8iAjwHg3FdmQrEIV13xfnfBm3oHWaK/0/v+oLT/V zEAR9Onc5Lar2mUJj+F51qaQkd/G+hXaQ6dPXzx7l608cFdHvMsqqqYixXsTiLUlbpFY UAEXJWNkJFSxMfq392tYO7DwIKR3Fd0nc7YfENs4SRhM2WLod3NQUahwUXLZ4LJ4lm+W MbYfp4NyDIuCcTLT8DD68fx1W8HZdBt/7cj4Nsekbq4aytePO5zke6C6YD/yZlDPkg/d a4y5zzzFrJh8pFPJrVuos7oA7vSLmsewKWnpliZAzwTvDjkN5COZsquyMJPZj+TPBDzR NmzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495675; x=1724100475; 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=sjc2eLEDEoqOWEk7kdawEPHb3ceHGyCKWkqgoVjnHA8=; b=L0wkrnCM7Y7txCPFcO4IHguMe24aTPOWJB9tIWCimZjH7h0Q2u4wAIRwuUzdM0fp+W wBHcoWzsyVcaUPXNkz47WwbsJ7CtXW88qGZLKQZeD2ENdlG5bCwXsPlmoCuQLNViMXnd 7nmYDqF6uv+U8s+pwYzTmie8n7hV9axBRpWnQRwSF18TSp0GnTDRNkFO6Oqwu/JlQc12 aNgXRFN/0QusnQ8KN3bQqO+60oydlQCv0oXNfmkVc91rJaBHUzQ1vUwdZGFyk3Nf+66i yi4AE2K1RCeZWHC2EdolLZVN1+0FCnCscg65A54E0ioeFx+y+m4DQV9LMIXlBlfVdypk G3gQ== X-Forwarded-Encrypted: i=1; AJvYcCXD6DB9Svc/teXQWAG70TfAPxMwWBhPbT1RgmVvNN39ObWupLRMXkiFXS2CEH7XKbhQ2Y53zPAO3BqS/5/30V/u@lists.infradead.org X-Gm-Message-State: AOJu0Yyl2fm0Oa9kaoLbT7paOaVVL6i10mGHtkqhZ+uj1znIhQ9lGeLu IJq5iiyQdUm4H+685bjkJFVPijBoMAsikIhrXVL7lSmiPT3CtAuB0Ht4LSC+m9Gnb6IXo6cEaex SwkcnmA== X-Google-Smtp-Source: AGHT+IFOd0OYmeV8Y9nqWsHm87cprbndwMQUuF1PkqYQQdBPP3ERK15XiwbbgvEjejpEJkcmP4DPnNKtl5rP X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a81:ab4d:0:b0:69b:c01:82a5 with SMTP id 00721157ae682-6a975e90bcfmr579667b3.7.1723495675061; Mon, 12 Aug 2024 13:47:55 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:05 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-14-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 13/27] perf script: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134757_124945_E2A084BD 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 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 Mon Aug 12 20:47: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: 13761031 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 83CD1C52D7C for ; Mon, 12 Aug 2024 20:56:02 +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=JLGoEGeBqdlZH+CzmCpwGBT1pMro9nL/vjVTf7hbTvA=; b=JgD4+uiZoZnipZjpv6eAoEX3pK PYdg7wG96oX/72F8FmeD7GKE6V0VngKKs7IQXRs/ghon3VrN4zjnmNiBp2sxYWPfaGhMn6/8mx0O7 ULqa4amdh+oXFk44Opy23hUO9lSEWgX5JMGNbNx7g0XRJ1JtvTrS+mq/UffBfqdku0GQq6pt0YV1v 3342c0hGApGVBm/kEjpXLbEZa9/azt5ckA0WYa3HnanlqpGS3659dxh3kANPA8qROATKxAHql+2GB 4WXRUcDy7VPPzNM35Ili3c4tE8QWjB+LdCL8gD0/czuKUaTEsK9/OgXasbVbRJzSdld1RHakFc47h 9KkP7roA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc53-00000001XAu-2a6T; Mon, 12 Aug 2024 20:55:53 +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 1sdbxO-00000001Ucz-2vJa for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:00 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-699c81a261eso117156377b3.2 for ; Mon, 12 Aug 2024 13:47:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495677; x=1724100477; 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=JLGoEGeBqdlZH+CzmCpwGBT1pMro9nL/vjVTf7hbTvA=; b=l9JLxEEIrUKPSzm8twGG3jvPsK1D/q5X9cok7MZzcg5CiVS57xHprssrWAgd0mDJZy FlWfAABQl95jI6Ev6uZkAUwbKWA4RtLH6PjgTS8JIxaQ10WsRudSa4mBHgCyew6NGEHg xGYHsefcMvAiPYY3OaVeKd1RvgdcqVktviHU+rsPpEIAZzigicgrvjU8CZsA7ALzVLUY YWnUEd/cVGiswCpWslV8gVVukehUeAuAGxCWhuYvqDYh2+OWUm/NDlXFvlHj44ODmYeB gilJHybyfi9ahctn6iPFfNh+OTFI+ra0JzT1dqlcPSLREHHFuhk10vtk8zwTjsaiMkpR ol0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495677; x=1724100477; 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=JLGoEGeBqdlZH+CzmCpwGBT1pMro9nL/vjVTf7hbTvA=; b=fYkyMny2ybOZPmlqk4ht9qAWLVcLZb6tX8U0Pv+t+bIIOOUWqH7JPQ7fWtmeffF9Wm 7/W1RaY8ZkxGxDI8BVbU5qSPlDqzUDTe0mkCjXHo9ooG5ugVVv7JAJ2B+zvHrM1rJpwz XVGbb4hjgJt/FfnYs0eGL+lKHuaWG9rtFU5FVK3CXd8Cv7lqyp6D+XDYfIpVAnqh8427 I/kVZ2w44ncnEdmo6njekVTbUP+g/RM6PlYXKvUm8XfFBamm1SYOsfCgdoC0axfL2G0d OPTbdkOju82YrKtA4ORBrGPvOGqqfuN97s3eZVG53l8x5obQNW4B5lJwLglWAX3MscKP X0Aw== X-Forwarded-Encrypted: i=1; AJvYcCXmYwZb9t9KuJ9YmP4XzC1Km/0322zOqqTZqrnZTdPwLbuqyF7eKrwbXqBKRE1Kfli79hzuYsCkZCnmM9e+wTqoEW0/2PJORBV76k4ksOSwjGm2JWg= X-Gm-Message-State: AOJu0Yy/6mbNfrO21YQjKMBnMHuGMkVI/rVDgrvCSyLllP3rfAWcCSP+ OHa94brL4PprHR0vIKDQQKe0F78UaFvcCoMhkyNa6S5xWxFGU/XHJ8PJbCMXjq502iOufvx1dXD QkIKyHA== X-Google-Smtp-Source: AGHT+IHTOUyrEnHmyoPgJ8YR7IU1g4sZiy+xELUvMPvGchrr6f7uxmiTpmzY0G9mGLF8prFaHdZCREmlbbyW X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a05:690c:4501:b0:690:d536:27e1 with SMTP id 00721157ae682-6a9718f53d5mr264607b3.2.1723495677364; Mon, 12 Aug 2024 13:47:57 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:06 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-15-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 14/27] perf inject: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134758_760055_9CDFD984 X-CRM114-Status: GOOD ( 16.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-inject.c | 91 ++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 48 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 283429ccd034..ef9cba173dd2 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -2165,47 +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, - .dont_split_sample_group = true, - }, .input_name = "-", .samples = LIST_HEAD_INIT(inject.samples), .output = { @@ -2270,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. */ @@ -2334,7 +2294,48 @@ 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.tool.dont_split_sample_group = true; inject.session = __perf_session__new(&data, repipe, output_fd(&inject), &inject.tool); @@ -2373,7 +2374,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 = @@ -2386,15 +2386,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 Mon Aug 12 20:47: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: 13761032 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 395AFC3DA7F for ; Mon, 12 Aug 2024 20:56: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=7NdZMo6g09POfWB6a47CRgDZioDpzOqzlpd52Wjbvy4=; b=IhnmjI4ZUpoZULiwkikLsZeEmb jVqP8xN2ffzwAuw+/E7hlCooP8ryNyIeG0VhefMB9FwLPnUxe1cyv9d7NZcyxKwthJNG81Xa+JNlF sRFQ4tGUjGLZ6WwoZJRdQ7xPg2MAlu+gEesgGQC6Fc70r38fI8nljkn3qM8+oUPG7f0eyoHWf4Skh /b2VsXRPdaEuXtoknqo5jdmtURrlDMhCNSTMDhkS6d3b4NOgKkL+dvO39gJMH682gWESVgtY21EgF f0jMbVscv+TRCLWmXM0htWJ/CMQZ7hMYF0KHlkJgZPIOW3mbA5sldiSpJaouypSJlDhV8io/Syg0S PRgjSKOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc5d-00000001XL1-1bSt; Mon, 12 Aug 2024 20:56:29 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdbxR-00000001Udq-1DgZ for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:03 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-69a0536b23aso107675257b3.3 for ; Mon, 12 Aug 2024 13:48:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495679; x=1724100479; 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=7NdZMo6g09POfWB6a47CRgDZioDpzOqzlpd52Wjbvy4=; b=aBZv44sc77fq1HGPKXYcpYPjK8X8kvgWM6tz/HtTgXmbbtY6wX/lt2vVqDBq24TfyW dbYDIGeUYBbxg6nYguOP6t7/MSBhiwh+xYX08bfPiPkIgnV6xh7Y33x0DQxS0uNjpqOS V8XIsFT6d0h/4cKg2X4UGqwNFRx64B9M8JXWv0okB5Yce0CbPa5Pl5pSA5No0Tvt/aTU Q7pYNdjDvpFYYzMWnAUxEFTjcpLhy3ox9ynHDzutg/yVKEhAWcQGqxA7KthqgV482zdZ HRDcW39QzD4gfbsFn3N0/pcPj8OCI3G6dDAkNZ8+uwbYHW8/4d3vIZaCn6GI/9hIvqPH ChrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495679; x=1724100479; 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=7NdZMo6g09POfWB6a47CRgDZioDpzOqzlpd52Wjbvy4=; b=q8Hct6LZJBgyxP9vPsfk7GYz2ZXZE3fjU6Kr45SYlH13XE3GFbPYqMRKoclZND4ki7 FDf8SXAP07ei7QNXJpk+ch8SU92Gww3yysPt0E+wtGCUgk/u5afFsCtpae5G6cw0iveh 4CXyk/bnNXpYpvlttOLVjPKTZflLHz+faNaUN8h7L9ISkknqlnHYGUyjJZwCbkG7z1eV 6AzEQHb/5x6XpD8U4vpn+y3l/+B/csa4/HQWtIkSV0g9sUUXdlQkCNw+1HVie1w/kkMM mVQbys1Oa+0tqYsHT6sbhLq/ysuKRm/UqCq7xtCTZUBGNRk/XWNmZQyWUso7ghTrMHwq yj9A== X-Forwarded-Encrypted: i=1; AJvYcCUkxc7kUHs92wRO1Sflz4CjE6+ZSwgdk1KuZC45/NfCPR9OQxEJulSnT6utqIC+KXfCbPBt3BLzpM1ksyKYSqAZvdJMxxBBXI1d8LxAxTIz8aiAyGg= X-Gm-Message-State: AOJu0Yyq7M/EGQIzWJhfnwWcwCXV2I2x0VkX2ejQXHJSEEHE3mqru761 2ETyfdauVYcw0yuWrILa2TeFzL0gSnf2dosA+j8fWyJve/uYrRAl+4RhVfx69Achxqj6sDugmuA 5tC0qkg== X-Google-Smtp-Source: AGHT+IFLRCJIhWvPJSHjOHmMfdHtiQHnRoYSTMp/a6ol78xUAn1ejpME245xEtPgzqIaNdDEPkgMc8SAGVRM X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a0d:e347:0:b0:648:afcb:a7ce with SMTP id 00721157ae682-6a97266deabmr35017b3.3.1723495679604; Mon, 12 Aug 2024 13:47:59 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:07 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-16-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 15/27] perf report: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134802_168668_C2CC25FD X-CRM114-Status: GOOD ( 14.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/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 5f609a7791ea..dfb47fa85e5c 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 Mon Aug 12 20:47: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: 13761033 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 0CD88C3DA7F for ; Mon, 12 Aug 2024 20:57: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=KSz3KLOdrMthwKDpYtohwO+EbRwfCbBekFhX3ull1Hw=; b=oB+rkViuxJIuPx/v1pjZrydVmn 5D12OaF3a4aNuVEksAeW+j9HA7q51YFVJ4qcYzkYQCxuAP/yQJzK7Qu1nRgnfYF5PH44nObGfX5Kv GAJO9gyMEIaI7sXgJkO+Md32SCxllVFwxpMxf9U2+66jh0S2nPfJhCk5c+UuXyXMuy7TrZqZWug8O 8bYzw6km9LO9xdztmZYjyTDz/jYhuwaRcmUcaW7L9FJJ01+UWdQO26Y5vVRecvdwuNRTXJ1R+tbfP Oi/DzNmlE+uYIzQ/ZioUGkWP4W1UulV1AxPatNYEkgezS4gpWdlVE3h+/AjUsZFINGdcWlN/mQrVt ckCpG9pQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc6D-00000001XWl-0ox2; Mon, 12 Aug 2024 20:57:05 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdbxT-00000001Uep-11sX for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:04 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e0b6584bbdcso7638752276.1 for ; Mon, 12 Aug 2024 13:48:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495682; x=1724100482; 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=KSz3KLOdrMthwKDpYtohwO+EbRwfCbBekFhX3ull1Hw=; b=lmjN9ctHr4buMCMAuJtY7zQx3cWkBRp0AVNVL2a/lBXKknmyVP3coRGrU3UPZqAbNF 6Gzwz5ilAUM6ZikOMHoL3M6M4R1IpGGvc3Uh0it1plTUJgQ6xD4M/SOJEWCTLQBZmYYo H78BZyRZfFgOvQ9AI0cTRH8WFX0aEHLwVRCmZ5sJoRa/+UFNWgtgRlPq+AeMhGUBt+UN hgoyCTJAbQT4o5b1S2U01FZzZ4ZwefAKnyG/vCJ0OTSP9INb3jlqDejDWZKXz97sCLSM Tt2E6V4e2b3mjjIJovBvsYf0hx2/rTROroIFinh7ZICVm3vq7z5lbtHja2a/k9nFInj3 swJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495682; x=1724100482; 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=KSz3KLOdrMthwKDpYtohwO+EbRwfCbBekFhX3ull1Hw=; b=rxNzsN6rR4Mh5Pf3NDH58vXMT/b3rm5kNpjWVaDt1WEUJQIyUdlYvlJrkuZ9P0t1iO lU/ex+vQMHc+XGE8vqgkWLlrLTtnAniM7/36+cb+StI+YZKPF6Md3jUkGzVMXlCt8O0l SKllnEqfdCQ1PsqWgTRi69/v7kTnwMVfHYLesS526j4tYqEiaFfIYsKUSPmgvtVIhViy xmL4fLkM4a8qEJUtAiEedPmDBWfP0lpzHN0X9Xri81LF0uCm739DNXlr7F9o8TTlARbG 8532byf3S37mY3acdm2gKedLjGz2f++7J8w8Hf8bfMwGqRGgDNhqwFLukFiqkoXWqs11 o/vA== X-Forwarded-Encrypted: i=1; AJvYcCXN7Fmculga8W0IPKrDknkMPwZzPZZZlT5k1xFxL466L5kG2BpkvMinGoXaGtQBBkV8L5n0w5dG4IV0Vf8+D9YxhJzXYrlbOj2iQvVVtI7IPDEPTYs= X-Gm-Message-State: AOJu0YwMWX+iWhIu+m3CtlCfpCEojo3PVeD95GCBfyyU+nqPnq282INA Lx8v027KG+j/veABFcgHcig4Jn6GrzTRAftq/C1Iiz/5oFj6SY2JJfH3ETdBB5tkwAO9V2p9qnB TNJ896g== X-Google-Smtp-Source: AGHT+IHuR7xHxfAp/zgJIBrSuShCMuj6OT04czAqkESnYImrj7+2RFVRHK/QMzpEWRcnE8XzpfcpAWdR/JcN X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:8407:0:b0:e05:faf5:a19e with SMTP id 3f1490d57ef6-e113ce7249fmr2863276.6.1723495681908; Mon, 12 Aug 2024 13:48:01 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:08 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-17-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 16/27] perf stat: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134803_308658_AE26698A X-CRM114-Status: GOOD ( 13.46 ) 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 d44e708f8a44..487eff9a8582 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 Mon Aug 12 20:47:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761034 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 BE9D4C52D7C for ; Mon, 12 Aug 2024 20:57:52 +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=h4IuJMX0YASP6mDRB5sblKvDCNi7GxHX4wO+9+ISAHw=; b=EPkOetvrGWigrfZeb8zYJ3s4Wo OevTiv0iTgA67U7urfXJyGyi0o3ozb49CL8yYA5j+fjjQ07+qiBv8+V/sB08QiKiS1BVkeqm7rdzu CAwdDYnqSZJidxXVxGB9nRxe+7AhIn/BFbTb6fL+5iwfuRX0bspmVfhabAnyMrTQuWmgpgle+s0n6 96XmBJS31yKYPGaB8l961YhS0TtDnW21zzks5jBA0eFXTc6EL4isHFgX0whJdulFL5qjdkr34NQPd rWC+Qi9zVtWSpqe5ixaAoYfOuvVSoOe2pIwMgZj6B6lx6dmnrD6EFjEL9WVu/edU8sBAvRLiCIj33 KKriDHJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc6n-00000001XjU-49VY; Mon, 12 Aug 2024 20:57:41 +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 1sdbxV-00000001UgJ-30eH for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:07 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-66a2aee82a0so94407877b3.0 for ; Mon, 12 Aug 2024 13:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495684; x=1724100484; 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=h4IuJMX0YASP6mDRB5sblKvDCNi7GxHX4wO+9+ISAHw=; b=oA7yrdGHnf1/zttX5+qIDKw/ZMVBKKLldz6lzWdpKHcIs+byuzgGH6avFlPIzgMebs l4nPmvwdC37sZirLEujWpCbcpDGw2F0LdlGcA3lhlwjKuPZYO0e27bJNbK7/EB3DJVzX Rd7AlmoQd6IN1yqGj6CBQdDsbBVLhfxqyD1Rzy4osFLS+cVvOOnqG+OqyI00+M4Pa+FW sKoVGyCNbQ5nkujR2gVC15Wtzr96Zplnxoa8nIa5Ovn8s/SrXgwZt9LeNfFLtGbE7rmH DYe/hQloN4qDaN1OepPpmaaawNy+ScK5vB5o6naevNypUuLlo9psMDMdXOtsqT2lsMJ2 S7AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495684; x=1724100484; 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=h4IuJMX0YASP6mDRB5sblKvDCNi7GxHX4wO+9+ISAHw=; b=HbeQboIciSmeODcHA9z+exGwmzn6fSkC72JmkLMS2hiQgG2hA+W3g9iywAkd0fnK4T V61dn0Db0n8S/6QAGEXa2CJ2W+xktUpHH5TVXE+FuQ71529jX4K8rVxcvh7ePSp0lfew cukj6eYsRdTf9zXzLD3QPeuHFNFXH4vRLqe9MmGGkhU0kOe6Y0Pqf10hYX+5ypC/rLV5 6ehDTeOCCZqQiHVQI+7LOLQ8FZNaP6H+QBRJQ4C/v/2dIAamLHV0EGzd+TaXKWUR/FqH qedDT+g0PUGUCgQwrsqNxJ8SG/f7CIiVtVqBfm+8sHYXsumpFZxfzNat3Ztdn4bKHsvs k0Rg== X-Forwarded-Encrypted: i=1; AJvYcCXXNFMysTi1tp80t2pPdkLHMHEt61qAIsXebsXcCfJ1iLYvDjIcjiGO1nVqN99iWY4555i5ERtadJ4mYxYRW7TnqOt6p7X4m8mBOhf0PqAmkOfKgx8= X-Gm-Message-State: AOJu0YwEJXSiHEd5oUt22GNf27ysP+uTEPCL0hNC4AijqDfFJv+AqTXS 4LSV2LQmn3AyCepooJ1WjMCxtm4LHxRTZTqcljY3Nilu+qTZ5ba+5bD4X2vdcuiXhkpDbwGGlwR AMzrOyg== X-Google-Smtp-Source: AGHT+IENcikM/2xpbAI0+iXGHI86bo1OAG2rCZ1wxfc4b5c0Ca8mqN3x5IE3uLmAUHqZLRaOz95pxfCbyXVD X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:cec7:0:b0:e11:44fb:af26 with SMTP id 3f1490d57ef6-e1144fbbcb1mr64276.2.1723495683936; Mon, 12 Aug 2024 13:48:03 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:09 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-18-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 17/27] perf annotate: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134805_807302_C585329D X-CRM114-Status: GOOD ( 13.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-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 cc65e6f8f4da..d6f6ba5a569d 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -696,28 +696,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, }; @@ -876,6 +855,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 Mon Aug 12 20:47:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761035 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 EE3C8C3DA7F for ; Mon, 12 Aug 2024 20:58:25 +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=Kpr+cu9QRMpy3TlpvKDVPMxM+YZp/esLhrg70XBtQYY=; b=E4i8b1ci4jF1dY1hLTqGg477kc ERfWTUM3Pk/f9tPadfeH5LQZvqpMUHVEHqVS0nhtycr8hLg5F/QR/0YA5t3bcg9gRsivOcTBD7IBD b4Hf1BQNWAsI0kOzmGQPhNDJKSm9oDSHVnG+Quxhwv7ZvVdPrUoTTwDK/VxVrjgdyvZX4yM42zFKb 7Vuk99yo7Ns0OjLV+u7DmklaeOu+KHbHIzVu6JyHIEiqC5sSrlHaw1/i5bk6POf4VpOQQV9BM9a8M JgGEFvdRYdqkpip52MlFUVFhcXjhK6wq0SobiwrW5skBmC5olYuyIXew0CQceOf6RERG70iISQjer O2rfvgIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc7N-00000001Xw9-2ogU; Mon, 12 Aug 2024 20:58:17 +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 1sdbxX-00000001UiS-2TbW for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:09 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e0b7922ed63so8809631276.0 for ; Mon, 12 Aug 2024 13:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495686; x=1724100486; 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=Kpr+cu9QRMpy3TlpvKDVPMxM+YZp/esLhrg70XBtQYY=; b=KA2wijpKUi/tVRDW7azQ3IoubFemvFkcTerFQrUfEHugCUOptjecQFcYcAvdaEVJPL DJaaZjIQfUP9PdCg7HOGgElwti1HsRqc/iH13dosk1hPFtlhFfFhTgg427xLeOQIRicT kH39hRIivi88QSucwpCnxsMOP7H69KhMftEsfHJR3fFKftjxx/uIvNMGIsdQT7zgVh8c oVp9LGS5KPRqUFPK5wjlr4RtkZlr1NxbVrm+2RINFLJa0rXtUzHLJ7KlCFHr1xFOs/mT qT0Mon8uyJwSPyOxt42Sm+Yx+Q5ynnYAWrFug5omt320m8aK8EJjGWANQPzkDJFM77oq 9Lkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495686; x=1724100486; 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=Kpr+cu9QRMpy3TlpvKDVPMxM+YZp/esLhrg70XBtQYY=; b=BN2Zk7ixj7Gp3+WaWU3j7rQ0NK57bBmfVVKoW1E0RjDgiFCZcNmJtVdEzvvSmsCKpV agYYDJea/FQ2Zl9ELARmxLeRM7JEkXiNDHKlkSfbzKrj5f/S9jX/roR0tN9RjZueoUVn 26JZWEquoJ7vqIzqBw9XecZgoaie8pRqHjvQhsG9/hE+eZReXPdD3XRxsgM2I9Ax0H6v TSjt3bbhGsLnPlFv/Z32HTSPOEoyMMKbW/8EU8uTwdSYG7Jeyn2noxy/Tv0c675dRzRy Z5Kvi6qHR9vVviXma3uFcOwE6NhA49YI0Oul+720YriIBhzRN4e61pVLRtBa63J0GM5F Dm5w== X-Forwarded-Encrypted: i=1; AJvYcCXe62bZ48DmOM8e2WrdR7MJ9TGKAOqaZMyEmlkif6Q/b8r510zbLSOnJreV6oWbISsCQ+MgynTUEPYy+I1rfm3rjB0K/eaU/mxV67x4Upp8Pt1ILK8= X-Gm-Message-State: AOJu0Yx71Xp/YQVtxJ3D5KU9AKYweh/sxguzEb8ndOcySoaJX1CkCYGc qGJOMH17x97q6TZ08KpsVz1Je89xS4W/B3lz3fLohGMLRFLivpdpopYcOYWtMKwLuARTVCjxzH4 wnTjBXg== X-Google-Smtp-Source: AGHT+IEbmaQbF7ylO1nyDJgivkzHHy3Dhc+dF+2T8SKBziKDX+/728BYpHWLDYabb5WwkODPfpNU22Bg1vcQ X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:abe9:0:b0:e03:5b06:6db2 with SMTP id 3f1490d57ef6-e113cd4619fmr2763276.3.1723495686242; Mon, 12 Aug 2024 13:48:06 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:10 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-19-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 18/27] perf sched: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134807_680606_0BF2E25B X-CRM114-Status: GOOD ( 12.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-sched.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 2c60bd3a8149..34fe8e540c43 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -3100,7 +3100,6 @@ static int perf_sched__timehist(struct perf_sched *sched) sched->tool.tracing_data = perf_event__process_tracing_data; sched->tool.build_id = perf_event__process_build_id; - sched->tool.ordered_events = true; sched->tool.ordering_requires_timestamps = true; symbol_conf.use_callchain = sched->show_callchain; @@ -3605,14 +3604,6 @@ int cmd_sched(int argc, const char **argv) { static const char default_sort_order[] = "avg, max, switch, runtime"; struct perf_sched sched = { - .tool = { - .sample = perf_sched__process_tracepoint_sample, - .comm = perf_sched__process_comm, - .namespaces = perf_event__process_namespaces, - .lost = perf_event__process_lost, - .fork = perf_sched__process_fork_event, - .ordered_events = true, - }, .cmp_pid = LIST_HEAD_INIT(sched.cmp_pid), .sort_list = LIST_HEAD_INIT(sched.sort_list), .sort_order = default_sort_order, @@ -3733,6 +3724,13 @@ int cmd_sched(int argc, const char **argv) }; int ret; + perf_tool__init(&sched.tool, /*ordered_events=*/true); + sched.tool.sample = perf_sched__process_tracepoint_sample; + sched.tool.comm = perf_sched__process_comm; + sched.tool.namespaces = perf_event__process_namespaces; + sched.tool.lost = perf_event__process_lost; + sched.tool.fork = perf_sched__process_fork_event; + argc = parse_options_subcommand(argc, argv, sched_options, sched_subcommands, sched_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (!argc) From patchwork Mon Aug 12 20:47:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761036 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 B2C29C3DA7F for ; Mon, 12 Aug 2024 20:59: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=s0Iqy/44loZSDwT/r8c2v4LhcCsuhaAB0dsDAg6CBI4=; b=T40EQLU/iyA1X4mh+EwUbnfWZW OL3JWcsAKcHfUKJuXmAYhizjLm3AL8Pp4r6KEuTGZRkg/GtWj0Hn0IBIKInWO/zUqXFuElLpFVsDZ 7q4UfFCiFl78id565rgGg+ZnQ3OFCeeM01GYZfXg6Fb/rfEIYGalenB+ZIx6/NvELoxVOHD2iQ6he n8RvlAHG6MzS26B+b2aTu/5rT3mPnh5PlIgwCpFvlL3+cSylqXUrWLQw8OuJ1t5sBeECRJiUnzEqP 3gl4C4ZzGxDhb0m+1V2LL+Kk7actbeAjYvA9o46CIc5GYFbDq2R59MTS7S38Lv8uHNZIqD9qY1mnn RCJbjqZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc7x-00000001Y6O-1Ojl; Mon, 12 Aug 2024 20:58:53 +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 1sdbxa-00000001Uja-03SC for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:11 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-672bea19bedso114674137b3.3 for ; Mon, 12 Aug 2024 13:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495688; x=1724100488; 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=s0Iqy/44loZSDwT/r8c2v4LhcCsuhaAB0dsDAg6CBI4=; b=tNNzj2rgrtepEHURkGlq04xqM+xWMO9LI6h+8Yz6F1wUxe/qjnEm+QIaypOM4IDety OQ6toKsA0y/2qNYFe8zS+PI+yEtWke8Agb9fsedGlVpqsUOBRChrHlOrBwqitIX2zAHe ZGncBOQLXwaJJiGxbHUNxDEgMOA6mv0qO6Fc9E6+fhPsjpbxG0kshyt9BhoM+GhqkNfe OMR5fB0TugDW0g7x+evyOx9Uy7krHp31NyL+zNAM/N3969/8+RBey5h6UHQdqHy/TQck KUI4ngAlr+Tl/Ii6oTzuvQk/aNQW6fGR86MxAHKBZRrD9uuyuo+VOrC12DMJi+mvjpJR 1CeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495688; x=1724100488; 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=s0Iqy/44loZSDwT/r8c2v4LhcCsuhaAB0dsDAg6CBI4=; b=TzTy82axn/sCXWXWEArxzvXoKeB7L8Q2cOz9Ocy5qnKLI9QnVQ8X2bBhdYpWyvLu+K Cwf7y5TSsrSWfx32PuFfJF86phfI4d/ySYWcbm4vBJ438dYJiqdl5n433eX0n0BIIJIr o8zrSjVUY6IEhNe9HFzIJfwfHpVXJr4fK7RVIdFpDXKn6/SYQJhTrGZJlagTBDJZ8v+2 6ExwPS0KfLjL05lSVy0P1tlrOVmoYRw8njdg/dD9na67e5vHdAVGAzjkCJYUqYB0iMpe hDOu0rW9IWGyIJ6V0fc5bd+AWShSuwhX5bd53HQG9uhRY8K3AfFjZydo95d5x/9e1qmm HQcw== X-Forwarded-Encrypted: i=1; AJvYcCW/JuPypg+YO2KdAx/ihtxxj99r99SqsHictNRlOgE+x6yQQ6PDKi2XcD7UhlYXqVwtcgImh6cFZdogLWkQRztX@lists.infradead.org X-Gm-Message-State: AOJu0Yzt+wu3uEIf2RQOi8OyKPbOQLcciPDrAF0BUunOIs824+zTx5iG HDTqez1WJR+rvUI6lWcynxueRhessbiLveY3x180T+qzWmQ9n1eafJq8exSH3Zd/7nAD0GJ28xz UJsYauA== X-Google-Smtp-Source: AGHT+IG/7kJRP8j4jNVxK+WTTnpF6wR6SbG8no+zediDqWUX8ohQa7y85641LKDUVIohBUMZwU7EgY1/qeBy X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:3002:0:b0:e05:6e45:84b6 with SMTP id 3f1490d57ef6-e113d176384mr2038276.8.1723495688336; Mon, 12 Aug 2024 13:48:08 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:11 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-20-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 19/27] perf mem: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134810_108140_6010F806 X-CRM114-Status: GOOD ( 13.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- tools/perf/builtin-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 0fb4d75ab959..18e5f9a0ddc2 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -276,7 +276,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); @@ -458,21 +474,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 Mon Aug 12 20:47:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761037 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 8EFAEC52D7C for ; Mon, 12 Aug 2024 20:59:37 +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=TBLmjv6eSiS+LVg3S2PV1+TUybOzhv0kGBRJg6B19ug=; b=DVlS3fED0Caz5QiYrUFfTeAboa DcfwZxAn7zVvAVVN+ZbGsIKEgLEdJB5UvSykl4GXf0vmnNYKdT004VzOxgYKwy0cEqQ/J2/j6YZGU Pg77GqxiSznEDa63Xww0tTuCL6fZuyuEYzOcK5ecqGHcci9vh0mqSJ1klqMwpWdZwShM4Wv0D2EQW LzMtT4591A5HlZn4thJDMQEJ0l7qGYlcxGXiQNgPoU91OILPby17myWbev7olRmWfTeSn3vM5J2Rs 1lr3OYVS/xiyiTZBRRkdKAh2vBHlyqhXMSvr6S1EYqa5p++AceGWNDLBb9DV7avVjfR6c0N/roh10 o44EdkYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc8V-00000001YGP-48Id; Mon, 12 Aug 2024 20:59:27 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdbxc-00000001UlN-0xMz for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:13 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-664916e5b40so68397837b3.1 for ; Mon, 12 Aug 2024 13:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495691; x=1724100491; 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=TBLmjv6eSiS+LVg3S2PV1+TUybOzhv0kGBRJg6B19ug=; b=WRno6HV+9bvC9B+ygWaDbo/dpIS8+MDRCqCVcS8iPnDsbeb1GDq+lcSlqA5F/8Hkfz zMgQEGsqhyVtqPRZPiioUI8zIG+8zPqWSt68ib40Q0ULEXF0GXy4fNVlS7zcV9kMF7x8 Rk91pnT5tqMd1qJZuyrNrr+vTjxHlN2KuGpb+kaqHK593fa7x5WOf/kfTJ2Lo8PxDi64 ukwuP6TKH0tBkSca+iasmqo6V7xsNJ/4F8xqNnITbqxC5LbXA10brSqciw0meKv8Ndkv n8E1GdpFjUKzwbiVtglgKa8Nkfx6vat/3tPlKvAYp9fIDb+cF0nPqOduF+s7qXxpEFmU KVbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495691; x=1724100491; 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=TBLmjv6eSiS+LVg3S2PV1+TUybOzhv0kGBRJg6B19ug=; b=nUJ/ljHFydQ+oWZ8m/Kd7f/tpUE7revrJs0yBCx6yAkxIey6vDEAduy6YtfHV4zXob Tne1MKJ2YPA9q+BtWF5P2LnatXE83A4xecoK7HSsfs8if37Z1bbMOG64H/GOGn1xmORB sSQ79B3vfFnvSQ6UQIHoXuKYBaDiaTIB9wZFMYQdBCEt/2pb8z7Zg2SEPzYKpunSOcQY 5qdJ+zqKbMbCY9B/Qg3G2Hy3gRIulGGKon0bizMZ9YYhDdxVMf7OyqgoQ2DSzZinvZhU swCOn8AY293uzbMWSf3dVmxTI+iBCt2jPeurKObeQrrwHUm0fc4f5L5GyZdOrWATo7es UF6g== X-Forwarded-Encrypted: i=1; AJvYcCXWkgYhKIROSWOeSZN5bqQl8DzXSU1y8L9Mv+3by0vRpByzA37GNJ8rsBGGGZmCs5EUWo0qZpXJ/k386a+a6TXE@lists.infradead.org X-Gm-Message-State: AOJu0YzD2tmsAd7S8pxYmW7wpHeoLXICMcEjatWMOGaM6zPW2pbCuKuv xso9+g/GwzWZJ4jaRhP1NNqdr+LInBW5qSJHnJgiCAJGyV71ekijHTgmBf7Z4uj/lKLtAgoTnzw vTEZaGA== X-Google-Smtp-Source: AGHT+IEascsmAbLnMnqwNwXuztrEwJNeZPYC78oqAvFDGFQpaT3AICojo24NJLf0dEcSdbHI+4hFkDNL2o4u X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a0d:d006:0:b0:665:7b0d:ed27 with SMTP id 00721157ae682-6a9e565a222mr104757b3.2.1723495690833; Mon, 12 Aug 2024 13:48:10 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:12 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-21-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 20/27] perf timechart: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134812_290616_82656601 X-CRM114-Status: GOOD ( 13.94 ) 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 Mon Aug 12 20:47:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761038 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 C5770C3DA7F for ; Mon, 12 Aug 2024 21:00: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=MRgA1lihGvLTddTTZqgJ/lO6lNaMhGJCMkfVsAIf/yU=; b=uyJhS1e/qknWKe/kVZQrOtHZKr 8vH/HrycJoXHNh6+mWlCYjqd4QqM+7PuyXDv7/YQQ2tx01AMwzmmeVtZfGUMHIuIgME9WbWqjoBa9 rCs7CEAJVwpG8r3dj9ktsA+L5k4EE+PrfX4zT5gQidDdLBYZzsDOwgHNj95Figh1lkaVxbCk9NDhm WiRoqCpgwnJ17b/KWWER4Qcv0VtM6ioqX+7VUoVfBoDsoGJbvOJvYl8IpuwMOGpMZsDZmO0s9nKOM p9fQzQNXfofnedCD88lzXdQT11q1vkZlUKX5M0Cz8wgRCMG54ZMw/3zabmAJ/gTUa3+Si6gqcvpBK tArYNG1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc94-00000001YNy-3kdS; Mon, 12 Aug 2024 21:00: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 1sdbxe-00000001Um5-1BGn for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:15 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-68d1d966ef7so105648787b3.1 for ; Mon, 12 Aug 2024 13:48:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495693; x=1724100493; 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=MRgA1lihGvLTddTTZqgJ/lO6lNaMhGJCMkfVsAIf/yU=; b=vzEAMbtLoP7lLnUvDhnPAx2zBll1k8dVsPL+iZSVZ/tP98GuPe8OWZKfrCfHXjToAX 5eTQcJzwkZM1TABki0UB5F+Zrw5/uWSRDq93cEcHBAmlruHjOoRtxxQe//EuixC2w+vK aktiDyTbuy1FhEL494XzIrHDKH1EeQjacPosGEqtwy0/JrFB0wM1KmK6aDn0rA8zRkCR kjwK+6BY4q1L3LWqMnvdFEXoxJZHAFMoE3Hv5X+ycSlVayDGW21hQe0gs5etpqvlni/O YAc9PaH0fPkABEx4BhJ1qezDSCJhSbTqPggW1dmVsn/bYm4SVUX50gE6OITiaZLfnxUn 51ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495693; x=1724100493; 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=MRgA1lihGvLTddTTZqgJ/lO6lNaMhGJCMkfVsAIf/yU=; b=Yze4NWNLcfSWgZ9Xxz44IOmoAUuskpKgoISW56VMsm/aiSo5qjlx7zjopEm0JsMzZm tmH+J6cMAp3VPCqdP5Q8TCLmz9Q9cZuB0jx5rzEWiaK8yDXn4vHXa1rYxFE/PMfCUvvg T1FxOnxNdobcc1dyX4E0CDE8qRob/Q6xzOwbgiYOXyRebfT7WZRKfYdzkGeIJpxtl1lR uRWRXJuLskEo/c69ab3Q2QmK04EJRtDltCE7C3/peHlinlbRZN66sZ1UcMA74wPWV9+R jlUL/wPdR6yyE1556Esmo5na2yBIvPPpV4FB0jeKsl3P3LJzYC0+q2BHB4HZpfHR1wyc bnug== X-Forwarded-Encrypted: i=1; AJvYcCVGZjR1OUFPvFKzQeH7dvCx3CKtcdVCYKmd6UvoVcec5ca8M7ab6xxBmazTHONyPJ+fXtnKmM5H1utrYQjPL8xBesChc/5jLsIkOnJQUyHaFrL0zZg= X-Gm-Message-State: AOJu0YxanWqvCxIjHQ++D+FfXVt2ny/uZAcGlvR+t3WCkTTQC9bIVh9M 0jNiWu7bxlNokRR+jEikRudxGElfc6pMNa6Xf9kAd97O+iK8Z3vovvnbgt/HZ5qkWDmKPcOFtg1 oUKc4Vg== X-Google-Smtp-Source: AGHT+IEjWqSzzD91sKJHefl74i8oWqMBx/tc3sJORhlRuDuK0H0B0q25A5wWaABqAWkAEbCkS0GPuVGqJKBv X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a05:690c:2fc4:b0:673:b39a:9291 with SMTP id 00721157ae682-6a9720a3717mr260267b3.3.1723495693016; Mon, 12 Aug 2024 13:48:13 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:13 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-22-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 21/27] perf diff: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134814_346443_40FA00FE X-CRM114-Status: GOOD ( 13.66 ) 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 Mon Aug 12 20:47:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761039 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 9B333C52D7C for ; Mon, 12 Aug 2024 21:00: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=GbSuls1koziHCu+Zgk0ioXEnPdjQxeNgIBorrGo8zG0=; b=SLQ4nmRiv3rTIMQuSIjA7eMnLp EzmJ+WBatVDQy5MBhEqqg/IH+ose5bf/jd4ScmDkuxyYQjfAW5Q+MfwIHFscwZcc67q/oTow33slT +QICfaWfaPRN9hQbjEsKuG1yX9/NrJdSMRXNNG9YpIczczkuE8c6sfEH+Hj9ik3Goq83DgSvkJAKy y0dVkEmgQ25LGmpwA+omprFTNwcvYxXpol8PR6Z2Jw6UkO91/S4G9uDaxIFbO60isLXY1lvgiumX3 Pyo4VThTXEaKfTqFMY5yg4Hma7JVKK16XK1WkzJoGB32DSJUIdsbpINN9faNI7rtmTeSARH1dN6ir PU0VqEWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdc9d-00000001YXZ-2UiR; Mon, 12 Aug 2024 21:00:37 +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 1sdbxg-00000001Umy-3Gn3 for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:18 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e0be1808a36so7073387276.1 for ; Mon, 12 Aug 2024 13:48:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495695; x=1724100495; 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=GbSuls1koziHCu+Zgk0ioXEnPdjQxeNgIBorrGo8zG0=; b=IDuk5/ABo+j8sYRyoaAy1IcUEsdl2X+zaor0kLVwhbm4HRZPbgolyLxr3jEyaOPEdE nFDHaiCzQo7Zs+hfpAyuD4SFtV3Rx8bBpRDMZn6VWUJoZUD2tXlvHRITFG3I5EiTIP2K 98zdGFCTfIqpd4saK372kCUMG5gWJyRdGpCOmI175Zl4DCcbWWsCvGxkaW4ZHf6sySIl 53/M0Yzvcn/tbYsFa+tscVFLLEXIYAsLL7XowbuXHQxYNWUzJbctIHle/wVAh7xwPXAk ikasz5+Dq23jaSTwib3KS+/rSHE7OXIO36zRzXenmba0WLgqjpPSV02Gfy9zZRQkCl1u k+qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495695; x=1724100495; 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=GbSuls1koziHCu+Zgk0ioXEnPdjQxeNgIBorrGo8zG0=; b=uZbJWRJ2m1ktn8agmVRCe/v3QpTat47SLYzxP99JSjTkN7hoHBn56MkS6YUxOk/hNQ XV7/Xs1T9urZRsPW9YF7e2IY1U6b3RyO3/7B9NtHq9+irQnsNjTuUGi5QgTZ+txpFJOZ b28ntH6S5i0WOZqXqvFlr6vSPQnvSzABoT5yuWVXbjinfiMx1m5n+hJoGpgG1T96pLcq I3sogIPHObc8/TzH19aIHv7emBBx1698vLa+Nvu96WxcmyrrG7vGKrrVjx7pz3TDsYda qiHZ0xDKS0eoDGak1KPVpYK4v5pwJ/7vGMfWjf3ZbIf1PR27YyFDmBGoIyN3CKwRGHUz 9Rhw== X-Forwarded-Encrypted: i=1; AJvYcCXctXzwkf6nNM4abZb/QS6oakSZLF9wU+6QHxMMBCYXQ4zy+hxMEZL37CGAzR1TWwsdv6gatiOZgOfrj6f9k3lB@lists.infradead.org X-Gm-Message-State: AOJu0YwiQEpxxgG2QCX/z+9tD2+ox/qKI3zAZI/SaLNtux+/c1Jd/txX 62F0Go5cIj145QRcN/E+dPAhgDsB2Z9RBPjWpG07F7ZIeOes/Z2YgqjHxmLnXf1S24+iMR8EMDR 3ILOorQ== X-Google-Smtp-Source: AGHT+IGKJ+9oWMNqxHbfR8xASqbD92WuYLWcfVYrMvX7Qri5bDa2vpoBKzYqnCKUn0C5AVvaDA3aVfY+pTnG X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:eb09:0:b0:e0e:3f14:c29d with SMTP id 3f1490d57ef6-e113ce83143mr78677276.4.1723495695218; Mon, 12 Aug 2024 13:48:15 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:14 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-23-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 22/27] perf data convert json: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134816_848607_DA1267E5 X-CRM114-Status: GOOD ( 13.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Mon Aug 12 20:47:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761040 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 D8F2AC3DA7F for ; Mon, 12 Aug 2024 21:01: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=uJSUXUdYfftsnAfnEFDlpk8Nwh4UnwypAJ8imZ20tFs=; b=b4FuyBDusqeOU1hurSP8IpTaKS fO+pyFSqmRN48AGmQ2FHlGNL/BpUpt6p0NPdBd1hIA9jy/cGLUFqJ/XabXhqzl8vyp+1zkAxVZPvN WuwqdKwExxvYrpQoEmlHnyFTC9YhDGyeIM4bMThjb9C/kv6/UKWEtzwVVhmMfpn8dxZVegxLbgV3+ YDox2NrEbiH9k2TyH1NVGymmdIPTz2jG9Hwabo9u/wfFb9bBLoXziCqcRoRMw535u/jc3JpiHXj+j vx1eh3e5CdL7M9ALHBSZBbI15XwBZRMdJN555vXD1Qzw+QLhqFDz/GLCKBHUohl2oIZfPD0Fm/0Zf iCx/V6hQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdcAD-00000001YgH-1JeO; Mon, 12 Aug 2024 21:01:13 +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 1sdbxi-00000001Uno-3WKd for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:20 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e0ebbee58a8so5393282276.0 for ; Mon, 12 Aug 2024 13:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495697; x=1724100497; 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=uJSUXUdYfftsnAfnEFDlpk8Nwh4UnwypAJ8imZ20tFs=; b=ZtPO4L+L9xjkV2oKFKvoDBQubaqaGJy9XPWTIazdp14267TVIrg6QCJIy5KoimHnGP H2zXYX3VAaZERlkal8+vJFpqveHyiTPltrUdEevgfwwWEnf+tEuBuMY3+LCAvM8ohpc0 RWlLMkQCkBAqxk6Hhqv23Br4oBv+HudtG7FbTbGTvznRAoUuQkuDHAAhmlk6F5iez53U paOrZvxGCSNKYgU7C7b5PdxwoWpfmSxKfxucEDnbj8gfQeDamoQcagFDKhiNpGJQUb72 d/YDeszksPRHajFQDdpVGbo19phnea1oHY/B6VTh9TSid87LatTwOi2Bh6X/6znwAQqW yq+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495697; x=1724100497; 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=uJSUXUdYfftsnAfnEFDlpk8Nwh4UnwypAJ8imZ20tFs=; b=pnjzLZza+qTrEBX7UsdYcc+nZpTp6EMHgPttZJhzaBXjCxwbRV7fmrvlvkbWpQinNU EzGksgxL+uTlcF46XnlunDyz670sF7VWGSQ6KXqYySiNQ4L37FrJ1DHbsexVZ6O1BNJv mx7U6xge0EpnMmwJYnZg4f//KQ2W+lhUHNdaqY+K8Sr5a3M+aNbZuN09U4YzOw0nuPzk jaXXFUsHB32XjsYQu3X/1EqRNz0/AB+dSR6g09mfS386WcR03SAjbKBXXbEGT70z1Shc GnaWNmydXy6v4zJo/agNlt0VX7pNe4KbIvVT896NqQHXXcUwtRJh6B2cQFjXLvLU5Cen ebZw== X-Forwarded-Encrypted: i=1; AJvYcCUQHjrJT0OxWYfOq2Xt40cLSmaYrcccbXLK6EVLC3K0sOdosCh9LvYgKm34qmymvRsPnPZI2hDoFifIH3OuTl8UQjws6EJchUpvpBwJt2vFS/UI2is= X-Gm-Message-State: AOJu0YyJeSAv20Uuey+StUZXNIYhTnD4P4YSpC4lyEdo3nrATnqEDK7X ltMAruervF37r8JAeMhw1emkbQU6oiczuYxQQmAfWNg70B50rAhF5vd8K1rXpTlsOhQGBV0huX8 YQzDs9g== X-Google-Smtp-Source: AGHT+IE2pK0wYfiv8oc0VZSUE7OVPqkqcX9EbQm/feBFKAubLZ6JT4aH+pOipQ5xDduOtnnesoVffuXHgpL+ X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:8d89:0:b0:e0b:c0a5:71e2 with SMTP id 3f1490d57ef6-e113d2c1aa5mr27234276.11.1723495697319; Mon, 12 Aug 2024 13:48:17 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:15 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-24-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 23/27] perf data convert ctf: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134818_904297_3C59565D X-CRM114-Status: GOOD ( 13.10 ) 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 Mon Aug 12 20:47:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761041 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 56FBFC52D7C for ; Mon, 12 Aug 2024 21:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kiqQs713NS2cwu9IGmflyeUpCc5+2eIUysSxdZONVB4=; b=rrF6t9MCwMovcW9YRKNTQqX5km NNhRNyOye9XoxDy7EBrc41+AAN5WCjaZtj13FWOrL29iaEU8gXeqnn+pYOWuINtgyidLlmU92v6Si o2EgnymcvhHJqMUScAGFJKGNgtM3BdEefQejvnrYkYss+3Kj4CHmLlVqnkShVy/vAkdBYTPW6zJiu 3FZHsx//22+ky0R2IaF6pzcd0CVcXEmNmt7HVbpo4H0xZXX3KhUydtl20KfApDdbVJm9AOreD2iNi z2CCQ0F3Wnn/YpFmnCmg1CYS6HQBqAt/ppkQrXvdDipjtggB8Jc/FCLov5JB7DytQBh1PM5bnqRJ4 UAOGzkgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdcAm-00000001Yl7-0x72; Mon, 12 Aug 2024 21:01:48 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdbxl-00000001Uok-0jaD for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:22 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e08bc29c584so7664508276.0 for ; Mon, 12 Aug 2024 13:48:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495700; x=1724100500; 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=kiqQs713NS2cwu9IGmflyeUpCc5+2eIUysSxdZONVB4=; b=UY1RMZgpPQBNzdqCS271OlqXbvTraV/YwzYPRgtCxjmnSeYNnlqCLZIKlfbpDfqZjR mDDly91HtwvyJ14NISBugfO1lo26oDTXwdbOM31fGiHb5JCe7vevjVLkyAZw1hG/CDdC gTVgPtsykR8KsnipJSX3wkDE33YVI+F11DWmm69ODHakAck+BU/V0ZsTuMaAP8o1bDdG Tnp7UL0oZVA/Dgyez8awJIMLQwKTWX5YbRYLHCIGsik5+q7hrYEK1UWMMssKN+ACve39 oWwL+30g7PhA5wnqH6j95/I5PugEmOwVepq5o579N0qo//5Af9B5lHAdYCXqlz1wIrO1 Ew/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495700; x=1724100500; 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=kiqQs713NS2cwu9IGmflyeUpCc5+2eIUysSxdZONVB4=; b=XZvwmabyOvyNeEgHBrNHXEpwUzlgkT/tlSNr3JSnM6VGKiuvvT/EbWY1kADOC+lzmO AaS0K+kPVCpf3VIQfi5VWjt8uMPWSyyjmT9rgy8Yp1T4t4/As2BwRC2diEnGT4noAbis dBz2kI2nv9WVI4QBZOtOjswXGdA8w4gKcx/oJWAsqFd2/dzZRVoNrOr1Nqh+i5g9S5B4 GrqcDMb/1Mxwmabk0d9rZA1CA0HtO/SlYht/JMCUVbGFi7bEVZ2aYkZkYJrZmQOJseC/ Gkb6A3+Qe9fVLyKtrUqBgs8WaSQqjZ0lIXb1nxkCQUm3Nz54QZWAy7dcxOteZX8mS+GR mLQg== X-Forwarded-Encrypted: i=1; AJvYcCXbcj06No0Jqjdz9xr1u0SxGHpfCxvYBsJF9iwY9A2G44uQXdZ/2LbFvhSPvi8bBqAxuuHto1QV2w8VK678Te8N4Co3teLeVbQZT1B4C0w1mivqJSo= X-Gm-Message-State: AOJu0YxecF8rqk5vvB4LZmE3fX7TqOBlyhWBZE43GUwhdhwnGOKvbA0h cGDZ561TzYTFXBl9SG2EWgFK7SITRQ9JMl04cB/qz3rrXZpnrZ77tGSr358EyMt6DQJIKewgjHv QRbcVQg== X-Google-Smtp-Source: AGHT+IH3KiTk750Irbjnomg6Lm7uXV9YcitFsOtYH/VB3qZCzlTL/MIwOsfRWnRrXOwHrMNRY7pbWgYokw0z X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:3002:0:b0:e05:6e45:84b6 with SMTP id 3f1490d57ef6-e113d176384mr2040276.8.1723495699659; Mon, 12 Aug 2024 13:48:19 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:16 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-25-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 24/27] perf test event_update: Ensure tools is initialized From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134821_243839_182034E3 X-CRM114-Status: GOOD ( 11.48 ) 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 Mon Aug 12 20:47:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761042 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 706D5C52D7C for ; Mon, 12 Aug 2024 21:02:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EG3+lgGDXwaf2Ajxqw2qZsx+igBWdkgUMhQ+ezR45jQ=; b=r6awRuZ3ndDfCS/eUqFGUQdGGO zoJNwmrQJDa2b0m7wAFlUA/J/QnFhLiMXNyw7Bu0UPf2cFT0Ivk9f/se6q6N5rFbsSLmxyz8x2pfH FCBWai1ORsjQQyupXJ9mtKis275CJMreosrkepHHIAqwDE4gyqXhQwOxCahvPnkJ3bNhTvhBwwj6Q 8iIobXvumyMstyYirJP/I/G7XWBQhmv1KLcqcdiqwyawpte54tXoRz488VvbST3pGMVU0Hm61d4rE 03zRjtYoe5w/+SInDQyGkgyFOXNGHr6sp109UvAzVEdWjkBmc0ZfUVYNQeaOsRop3gqtjeD5ZrcKb jqJgth4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdcBJ-00000001Yq2-45Aa; Mon, 12 Aug 2024 21:02:21 +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 1sdbxn-00000001UpX-1Ky7 for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:24 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e02a4de4f4eso8545273276.1 for ; Mon, 12 Aug 2024 13:48:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495702; x=1724100502; 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=EG3+lgGDXwaf2Ajxqw2qZsx+igBWdkgUMhQ+ezR45jQ=; b=XPoSyuLSeqpe+1smOgr8YJckadnlAyKKmh7dnsE2WgcpUs/znLVHnZuQ6Q1WNlv2EH CvjUYlOs+Efvx7/lNkaFPddG1Z+ikc+P7s1tMI4ll8V9J6qslWwN7tC50/6grxe7DgEs e4tDhbxTGZEKvqcJx/dcqlkKRpxG6PKS40cOuNABLOsE6L/w6LEvfFpH45v85ZiJD8P2 CBQwNsU9AQ+ims6uEzkHcLmPh6Xg+qauhmtK8B4pLDLmKCoUU0SNI+MIkMOrKmZXKqNy 9yN55oVCY72iA+mpbnvEWbKvnc3alMge8Or1hnoSKYkzoDdw75fgsMloeQK+oWLCzwJc QGGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495702; x=1724100502; 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=EG3+lgGDXwaf2Ajxqw2qZsx+igBWdkgUMhQ+ezR45jQ=; b=XcKLetnXK1nHdrruuYQ5u78bOr4nnQOsp3KcoIfiaa3cTVTwU3YXWvgw/rhfouQctJ V5XX4AwNuNBBx2w7Q70jIy46Lak3fs/CCRttQgReyvVlbkuKqqtvIeaOrUWQxh4bvowC cFvcB4g87QlX7171gy9OgyhCMCCyfjXq38SbXwGSdAW1szxJAa5G/S1aDiqxd9FneX7/ v3nShPb0GCbP3soY6Aak4hsWzuPV5EH2c1bfn7UQ01/e5lPCXRHQbhwQIK9g3ngIONlk bQN5gVUvl9icFtphadEKZKBh6IhdEgpM1FZ8sdPcMxGCfYydLm6GicXpB21NZSDwQ1dI A3ag== X-Forwarded-Encrypted: i=1; AJvYcCWV66o9OR2oE8BOVU7uOkHNSbDnRNOjq5zX8EHjFKx9F2FT7/dQLhnrOvdSpapbeuPb4w5TU7y21VRfwDkhyZ329h7Tnw7WWb8WEEq4hQhkXmLrjqc= X-Gm-Message-State: AOJu0Yx3ZBMgd6tOM1StOb1XVrwXpVA05nnWX3YULcy+62ZSso8v9Pwh AGXpjXREwRnGiWvs2oQZL9a766pRI6K4GICqfg14bDw9wREfy9ws7TWEK/eiYw8C4svOml68IIV r9LNPvA== X-Google-Smtp-Source: AGHT+IGZn6iEjUKcrQKI/ImnhvzHRsCJ2piQaoANKaHrQYq3pioz3Dhmz7+UNU8tS+gq5ZENrkMtgqBdNl6C X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a5b:485:0:b0:e0e:445b:606 with SMTP id 3f1490d57ef6-e113c918693mr3653276.0.1723495701802; Mon, 12 Aug 2024 13:48:21 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:17 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-26-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 25/27] perf kwork: Use perf_tool__init From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134823_378119_4040FA51 X-CRM114-Status: GOOD ( 13.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_tool__init so that more uses of struct perf_tool can be const and not relying on perf_tool__fill_defaults. Signed-off-by: Ian Rogers --- 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 Mon Aug 12 20:47:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761043 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 3CC5BC3DA7F for ; Mon, 12 Aug 2024 21: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=0/PW497Hbxz+K6ERVzgwnz8NGkRpB4aRXVX3N8aWF4E=; b=dCM83pKdTjZR9Rt/OpSkx9m0Yh HCiZfEY4m4/tjkKnGzJ47LmMemtHaT188hKcyRnAIaQuIxr9wYQfbmqBPRraQ+nyu+M2H02+pyYPh jcQ3GmMc+XiAlldcWlBjp7srvp00jz2TbfkQwhlCYZWRPjBVV5ASKtZo8V0Aw0xQZStAlh7/ab95k sNX+me3QbqrfoWZ0nfjnp14At+RE5IvE4sesos3SX+bTrpSbCVPJh8bMzn83W73bNBgnG/lCTvtu3 L00EO5DIb5lpPfVPTjt5DCB4CbPW8MPzoPRfFz6IreaQ2j06YoAxnbEFB7/E21+x8m4OAF6gTra9B 9yzhf2MQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdcBs-00000001YvM-2wyh; Mon, 12 Aug 2024 21:02:56 +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 1sdbxp-00000001Ur0-1LeO for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:27 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e0879957a99so7668041276.1 for ; Mon, 12 Aug 2024 13:48:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495704; x=1724100504; 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=0/PW497Hbxz+K6ERVzgwnz8NGkRpB4aRXVX3N8aWF4E=; b=nwMqQmEe0vXRuRDbM5ToqB0Nr5BgofAM15e12I7ZiYMTJ6Gq1xtUhr+59X7/RCETjM sAiyctbu4gNz45u+GkTCjtn0UqVrXhiTkfAfOWi1XBRELE88f/386eZNoQJM5CHfjHg3 UnyQYeiwY3gkUgtQrHkCFIbdw6w8ei8xmafZVPLHI/9xwUh0IEyRoFRNAlAuLNiSFCI7 jWk6nT7CGP7avq5fkUR6dhRPOxESwI+WcYaoiMw9bhNy3M05XUBXhp680FI8VZk5afS3 Ia6SA1F7rYTKQsD13VVFIMu/0J7izX9PVmVAJyQz9Y2Jr6hCkPnSLUtAI16wSgyIGh/v 2WVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495704; x=1724100504; 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=0/PW497Hbxz+K6ERVzgwnz8NGkRpB4aRXVX3N8aWF4E=; b=D2E/SZJIt1xQZ30c9bjkYIYIOVFvP1FlVBIN1JHZPP3Seg3fZu8KhAxSNRl0tdXfxx TyT0TIxt3IROu+8ooZ2Tc2R/aHSD0ron8WgWKm/CdOTqb/6SNQpXdDzYY2Ny1Yv/0cdG UTeH20ENMCIu8XkZj9+O3YGUPt/XjbgvFrjQ9h6Tmysrefzsf6nbxSw9Hr7mY2ep3oSi H2h8D/muhRiIyFPZTFhUFMsp3MjfOZua3ksvL9x8C1efvzWK02jtWtmqpfphzFNGzToD 1UTZLUKmOtKFwLtsiTM/A6bbt5LvegJwpBvogVslBLsh1g5lCFRACqvjRLE/XXLdyXGn xpzQ== X-Forwarded-Encrypted: i=1; AJvYcCXVu3GeDp9qcQ/gQ1U9wyDEAF+K1yx1vfB0RBqPbAejbsoUCM34rsQd/EaJmXk/R+SeD4bMP9MBIiJPcHwRATo4PgxMxpgAhGdQq0H/ytSzKQXvCwI= X-Gm-Message-State: AOJu0YyW8bwsBkikJE+GbCpGW3BU59wwZbHaSvCITWx2gYkJZQhz9NV+ PPn7Z840em2oY9D8oEf7Z8RCVsvF+6WiW9g8oqNy9ifSlbow6QioD+OftHeKBEYOp84cyD86/Pl h0LOZBA== X-Google-Smtp-Source: AGHT+IHz+OIR3uPEMJrYUYVFCp+CEdR1jvMSTlm/KPD5+ygMtWmiw1Qa9JNuPjCJbkE3PhW6bzE9s9yYXJ4I X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:6fc5:0:b0:e0b:ab63:b9c7 with SMTP id 3f1490d57ef6-e113cf5e921mr2109276.7.1723495704095; Mon, 12 Aug 2024 13:48:24 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:18 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-27-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 26/27] perf tool: Remove perf_tool__fill_defaults From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134825_407447_9E7E535A X-CRM114-Status: GOOD ( 14.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 5c0e0341d39e..a8404cc99cfc 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1781,8 +1781,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 @@ -2206,8 +2204,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; @@ -2260,8 +2256,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 c7fea58729a5..db1c7642b0d1 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -90,7 +90,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 Mon Aug 12 20:47:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13761044 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 6E02DC52D7C for ; Mon, 12 Aug 2024 21:03:43 +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=4wczZj/G5PmxA13DCbaUvl0QUyy3P1R91oRL5UB3198=; b=njJL8slsPdCmnDHdhK7BscgRV3 Hi4pjmWyXrDcjn3cuwQA5Z3sWJy6/dWc3sX0XA2i9242GGV24FFKUBj+wnrHnqtN70pm4FasqVbNo lX55EcQ4bpnotdc6MC8CuxvvvdVrLu48QaFlBAxcM20W7DJxV5W4slLJMZ3qmTFkK3t9OmU+AOt95 bGuhbhZNU15KXr9Vkpaiygr+sHXQ9abq4z2gJkW+v52yxmIj/ZmnLFnzjK6URRsyStr9oGEBBt2S1 OfVd9q9HDSpN3ekXff2rND6PrHBW8Zua3l5xGiTXIxNccwMaZ62ukFvPQzoCg4IGoy2YsC5Gx29fz Atwpo+dw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdcCR-00000001Z2Q-2JDB; Mon, 12 Aug 2024 21:03:31 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdbxr-00000001UsI-3kBm for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 20:48:29 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-665a6dd38c8so103051447b3.1 for ; Mon, 12 Aug 2024 13:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723495706; x=1724100506; 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=4wczZj/G5PmxA13DCbaUvl0QUyy3P1R91oRL5UB3198=; b=hSwolQ0vu/gQgtw4dxlHLU58yly+DwEKjHZKnD0xBobPUVqxgnl9IIrTTYWQxmOwXG IMzVOMjGZhVWKLkqGzomioZeRvzZ8R3GTVDUGSippSd0LRLpdlGsQOjf8m55tU9pq5CP K/4t5x1er8xvtnMUbCEl9SR06JjXDx/2nzgZUXNlpZ0bwdZUKPB6G7j9fjQxsTSyY+Ru vaM0semJKOy7KMoGub+dGrSD+IhNjCx5FmAyM/fGAqoVZk79lWo7Xr2jfLgpLd+yudn7 pvCbV+8LsybZgg4C5eQd8gg+wFwf9r597GsdReAsHxE62RnTSxb2x5l4UqxPjS7Wrq3W kQXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723495706; x=1724100506; 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=4wczZj/G5PmxA13DCbaUvl0QUyy3P1R91oRL5UB3198=; b=lpdcX/QzHA6dnG2/pBswbfmE3uO0iwW6VyosqUqO8xVNSzHf9OEgZcGHNttEldlQ0J ARc6L3OSN4oZ+nuJwCUIVPVIooKXno0JMztOT+UJvDYbdOY+A+2Ala7G69IHlW8T7sOL AncUHQrRFrqvkaOV6nM3B80rCJ1qG3K85F0FuhXPkRTJwtbFcNlFusU11jIHaAULvvq+ sNBaj4pLwwuCKV+0JeploJVpjNveeiy98hT6pOnfWg8I4TRB4VNwN8kFoaEKU/Vrirua 9sQ9YV4Ls7MmP24Wh5YKWEVcc89VWi0dZqm8AfASFkbpmYGwShHvYCFXdb2Capy+CvAg rcIg== X-Forwarded-Encrypted: i=1; AJvYcCVcYyjs/vbIN/560qyh88qA0HjWhvD1DNqgPs1pXwgFp+nr06wViG7w6liArePuo0AO+s4BE+oxVU7ofOyzW1NROP65fzgLfsXFX9aF2qAdMuUMjJY= X-Gm-Message-State: AOJu0Yz6vjcyHJu0+7XAOdluRrQ6qyO7KU/8mzf4TuKy81pD0TjnY5XT zBXdrqbxODfH7OX01ExGfH0V8PY045iv+e1M55JTG21Vv1BXW0rWCExNaGPuTS4nldoyhdgIe2Y YknjTEg== X-Google-Smtp-Source: AGHT+IEEkdfVbmMdg47zJ1xwMISs3qxpK2W4sG4GNErhBkvDAcSIFEm9nvYqC0j8/UjSL/PUOvwkYvjYDWoT X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e7f1:b90:720c:35bf]) (user=irogers job=sendgmr) by 2002:a25:f30d:0:b0:e03:59e2:e82 with SMTP id 3f1490d57ef6-e113d27c9a9mr2472276.10.1723495706163; Mon, 12 Aug 2024 13:48:26 -0700 (PDT) Date: Mon, 12 Aug 2024 13:47:19 -0700 In-Reply-To: <20240812204720.631678-1-irogers@google.com> Message-Id: <20240812204720.631678-28-irogers@google.com> Mime-Version: 1.0 References: <20240812204720.631678-1-irogers@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Subject: [PATCH v7 27/27] perf session: Constify tool From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Suzuki K Poulose , Yicong Yang , Jonathan Cameron , Nick Terrell , Nick Desaulniers , Oliver Upton , Anshuman Khandual , Song Liu , Ilkka Koskinen , Athira Rajeev , Huacai Chen , Yanteng Si , Sun Haiyong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240812_134828_051931_A6982212 X-CRM114-Status: GOOD ( 15.24 ) 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 a8404cc99cfc..d2bd563119bc 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1770,7 +1770,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; @@ -2200,7 +2200,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; @@ -2250,7 +2250,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;