perf auxtrace: Refactor with evsel__is_aux_event()
Subsystems (4)
Leo Yan
reviewercover perf auxtrace: Refactor with evsel__is_aux_event()
As the evsel__is_aux_event() function can be used to detect AUX event, it is not necessary for every AUX module to maintain a 'pmu_type' field and compare it for detecting AUX event.
This patch series refactors auxtrace with using evsel__is_aux_event(), and remove unused the 'pmu_type' field from every AXU module's structure.
This series has been tested on Arm SPE and Intel PT.
Leo Yan (9):
perf auxtrace: Use evsel__is_aux_event() for checking AUX event perf auxtrace: Remove unused 'pmu' pointer from struct auxtrace_record perf auxtrace: Refactor auxtrace__evsel_is_auxtrace()
perf arm-spe: Remove the 'pmu_type' field
perf cs-etm: Remove the 'pmu_type' field
perf hisi-ptt: Remove the unused 'pmu_type' field
perf intel-bts: Remove the 'pmu_type' field
perf intel-pt: Remove the 'pmu_type' field
perf s390-cpumsf: Remove the unused 'pmu_type' field
tools/perf/arch/arm/util/cs-etm.c | 1 - tools/perf/arch/arm64/util/arm-spe.c | 1 - tools/perf/arch/arm64/util/hisi-ptt.c | 1 - tools/perf/arch/x86/util/intel-bts.c | 1 - tools/perf/arch/x86/util/intel-pt.c | 1 - tools/perf/util/arm-spe.c | 13 +------- tools/perf/util/auxtrace.c | 8 ++--- tools/perf/util/auxtrace.h | 3 -- tools/perf/util/cs-etm.c | 17 ++-------- tools/perf/util/hisi-ptt.c | 11 ------- tools/perf/util/intel-bts.c | 14 +------- tools/perf/util/intel-pt.c | 46 ++++++++++----------------- tools/perf/util/s390-cpumsf.c | 11 ------- 13 files changed, 25 insertions(+), 103 deletions(-)
Signature · 1 line
2.34.1
Leo Yan
reviewerPATCH 1/9 perf auxtrace: Use evsel__is_aux_event() for checking AUX event
Use evsel__is_aux_event() to decide if an event is a AUX event, this is a refactoring to replace comparing the PMU type.
--- tools/perf/util/auxtrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/auxtrace.c +2 -2
@@ -671,11 +671,11 @@ int auxtrace_record__read_finish(struct auxtrace_record *itr, int idx) {struct evsel *evsel; -if (!itr->evlist || !itr->pmu) +if (!itr->evlist)return -EINVAL ;evlist__for_each_entry (itr->evlist, evsel) { -if (evsel->core.attr.type == itr->pmu->type) { +if (evsel__is_aux_event (evsel)) {if (evsel->disabled)return 0 ;return evlist__enable_event_idx (itr->evlist, evsel, idx);
Signature · 1 line
2.34.1
Re: [PATCH v1 1/9] perf auxtrace: Use evsel__is_aux_event() for checking AUX event
Quoted 4 lines · Leo Yan
Use
evsel__is_aux_event()to decide if an event is a AUX event, this is a refactoring to replace comparing the PMU type.Signed-off-by Leo Yan <[email protected]>
Quoted 22 lines
--- tools/perf/util/auxtrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/util/auxtrace.c +2
-2@@ -671,11 +671,11 @@ int auxtrace_record__read_finish(struct auxtrace_record *itr, int idx) {struct evsel *evsel; -if (!itr->evlist || !itr->pmu) +if (!itr->evlist)return -EINVAL ;evlist__for_each_entry (itr->evlist, evsel) { -if (evsel->core.attr.type == itr->pmu->type) { +if (evsel__is_aux_event (evsel)) {if (evsel->disabled)return 0 ;return evlist__enable_event_idx (itr->evlist, evsel, idx);
Leo Yan
reviewerPATCH 2/9 perf auxtrace: Remove unused 'pmu' pointer from struct auxtrace_record
In reply to Leo YanThe 'pmu' pointer in the auxtrace_record structure is not used after support multiple AUX events, remove it.
--- tools/perf/arch/arm/util/cs-etm.c | 1 - tools/perf/arch/arm64/util/arm-spe.c | 1 - tools/perf/arch/arm64/util/hisi-ptt.c | 1 - tools/perf/arch/x86/util/intel-bts.c | 1 - tools/perf/arch/x86/util/intel-pt.c | 1 - tools/perf/util/auxtrace.h | 1 - 6 files changed, 6 deletions(-)
tools/perf/arch/arm/util/cs-etm.c +0 -1
@@ -888,7 +888,6 @@ struct auxtrace_record *cs_etm_record_init(int *err) } ptr->cs_etm_pmu = cs_etm_pmu; - ptr->itr.pmu = cs_etm_pmu; ptr->itr.parse_snapshot_options = cs_etm_parse_snapshot_options; ptr->itr.recording_options = cs_etm_recording_options; ptr->itr.info_priv_size = cs_etm_info_priv_size;
tools/perf/arch/arm64/util/arm-spe.c +0 -1
@@ -514,7 +514,6 @@ struct auxtrace_record *arm_spe_recording_init(int *err, } sper->arm_spe_pmu = arm_spe_pmu; - sper->itr.pmu = arm_spe_pmu; sper->itr.snapshot_start = arm_spe_snapshot_start; sper->itr.snapshot_finish = arm_spe_snapshot_finish; sper->itr.find_snapshot = arm_spe_find_snapshot;
tools/perf/arch/arm64/util/hisi-ptt.c +0 -1
@@ -174,7 +174,6 @@ struct auxtrace_record *hisi_ptt_recording_init(int *err, } pttr->hisi_ptt_pmu = hisi_ptt_pmu; - pttr->itr.pmu = hisi_ptt_pmu; pttr->itr.recording_options = hisi_ptt_recording_options; pttr->itr.info_priv_size = hisi_ptt_info_priv_size; pttr->itr.info_fill = hisi_ptt_info_fill;
tools/perf/arch/x86/util/intel-bts.c +0 -1
@@ -434,7 +434,6 @@ struct auxtrace_record *intel_bts_recording_init(int *err) } btsr->intel_bts_pmu = intel_bts_pmu; - btsr->itr.pmu = intel_bts_pmu; btsr->itr.recording_options = intel_bts_recording_options; btsr->itr.info_priv_size = intel_bts_info_priv_size; btsr->itr.info_fill = intel_bts_info_fill;
tools/perf/arch/x86/util/intel-pt.c +0 -1
@@ -1197,7 +1197,6 @@ struct auxtrace_record *intel_pt_recording_init(int *err) } ptr->intel_pt_pmu = intel_pt_pmu; - ptr->itr.pmu = intel_pt_pmu; ptr->itr.recording_options = intel_pt_recording_options; ptr->itr.info_priv_size = intel_pt_info_priv_size; ptr->itr.info_fill = intel_pt_info_fill;
tools/perf/util/auxtrace.h +0 -1
@@ -411,7 +411,6 @@ struct auxtrace_record {int (*read_finish)(struct auxtrace_record *itr,int idx);unsigned int alignment;unsigned int default_aux_sample_size; -struct perf_pmu *pmu;struct evlist *evlist; };
Signature · 1 line
2.34.1
Re: [PATCH v1 2/9] perf auxtrace: Remove unused 'pmu' pointer from struct auxtrace_record
Quoted 4 lines · Leo Yan
The 'pmu' pointer in the
auxtrace_recordstructure is not used after support multiple AUX events, remove it.Signed-off-by Leo Yan <[email protected]>
Quoted 81 lines
--- tools/perf/arch/arm/util/cs-etm.c | 1 - tools/perf/arch/arm64/util/arm-spe.c | 1 - tools/perf/arch/arm64/util/hisi-ptt.c | 1 - tools/perf/arch/x86/util/intel-bts.c | 1 - tools/perf/arch/x86/util/intel-pt.c | 1 - tools/perf/util/auxtrace.h | 1 - 6 files changed, 6 deletions(-)tools/perf/arch/arm/util/cs-etm.c +0
-1@@ -888,7 +888,6 @@ struct auxtrace_record *cs_etm_record_init(int *err) } ptr->cs_etm_pmu = cs_etm_pmu; - ptr->itr.pmu = cs_etm_pmu; ptr->itr.parse_snapshot_options = cs_etm_parse_snapshot_options; ptr->itr.recording_options = cs_etm_recording_options; ptr->itr.info_priv_size = cs_etm_info_priv_size;tools/perf/arch/arm64/util/arm-spe.c +0
-1@@ -514,7 +514,6 @@ struct auxtrace_record *arm_spe_recording_init(int *err, } sper->arm_spe_pmu = arm_spe_pmu; - sper->itr.pmu = arm_spe_pmu; sper->itr.snapshot_start = arm_spe_snapshot_start; sper->itr.snapshot_finish = arm_spe_snapshot_finish; sper->itr.find_snapshot = arm_spe_find_snapshot;tools/perf/arch/arm64/util/hisi-ptt.c +0
-1@@ -174,7 +174,6 @@ struct auxtrace_record *hisi_ptt_recording_init(int *err, } pttr->hisi_ptt_pmu = hisi_ptt_pmu; - pttr->itr.pmu = hisi_ptt_pmu; pttr->itr.recording_options = hisi_ptt_recording_options; pttr->itr.info_priv_size = hisi_ptt_info_priv_size; pttr->itr.info_fill = hisi_ptt_info_fill;tools/perf/arch/x86/util/intel-bts.c +0
-1@@ -434,7 +434,6 @@ struct auxtrace_record *intel_bts_recording_init(int *err) } btsr->intel_bts_pmu = intel_bts_pmu; - btsr->itr.pmu = intel_bts_pmu; btsr->itr.recording_options = intel_bts_recording_options; btsr->itr.info_priv_size = intel_bts_info_priv_size; btsr->itr.info_fill = intel_bts_info_fill;tools/perf/arch/x86/util/intel-pt.c +0
-1@@ -1197,7 +1197,6 @@ struct auxtrace_record *intel_pt_recording_init(int *err) } ptr->intel_pt_pmu = intel_pt_pmu; - ptr->itr.pmu = intel_pt_pmu; ptr->itr.recording_options = intel_pt_recording_options; ptr->itr.info_priv_size = intel_pt_info_priv_size; ptr->itr.info_fill = intel_pt_info_fill;tools/perf/util/auxtrace.h +0
-1@@ -411,7 +411,6 @@ struct auxtrace_record {int (*read_finish)(struct auxtrace_record *itr,int idx);unsigned int alignment;unsigned int default_aux_sample_size; -struct perf_pmu *pmu;struct evlist *evlist; };
Arnaldo Carvalho de Melo
maintainerRe: [PATCH v1 2/9] perf auxtrace: Remove unused 'pmu' pointer from struct auxtrace_record
Quoted 7 lines · Adrian Hunter
Quoted 4 lines · Leo Yan
The 'pmu' pointer in the
auxtrace_recordstructure is not used after support multiple AUX events, remove it.Signed-off-by Leo Yan <[email protected]>Reviewed-by Adrian Hunter <[email protected]>
Applied the first reviewed two patches.
- Arnaldo
Quoted 81 lines
Quoted 81 lines
--- tools/perf/arch/arm/util/cs-etm.c | 1 - tools/perf/arch/arm64/util/arm-spe.c | 1 - tools/perf/arch/arm64/util/hisi-ptt.c | 1 - tools/perf/arch/x86/util/intel-bts.c | 1 - tools/perf/arch/x86/util/intel-pt.c | 1 - tools/perf/util/auxtrace.h | 1 - 6 files changed, 6 deletions(-)tools/perf/arch/arm/util/cs-etm.c +0
-1@@ -888,7 +888,6 @@ struct auxtrace_record *cs_etm_record_init(int *err) } ptr->cs_etm_pmu = cs_etm_pmu; - ptr->itr.pmu = cs_etm_pmu; ptr->itr.parse_snapshot_options = cs_etm_parse_snapshot_options; ptr->itr.recording_options = cs_etm_recording_options; ptr->itr.info_priv_size = cs_etm_info_priv_size;tools/perf/arch/arm64/util/arm-spe.c +0
-1@@ -514,7 +514,6 @@ struct auxtrace_record *arm_spe_recording_init(int *err, } sper->arm_spe_pmu = arm_spe_pmu; - sper->itr.pmu = arm_spe_pmu; sper->itr.snapshot_start = arm_spe_snapshot_start; sper->itr.snapshot_finish = arm_spe_snapshot_finish; sper->itr.find_snapshot = arm_spe_find_snapshot;tools/perf/arch/arm64/util/hisi-ptt.c +0
-1@@ -174,7 +174,6 @@ struct auxtrace_record *hisi_ptt_recording_init(int *err, } pttr->hisi_ptt_pmu = hisi_ptt_pmu; - pttr->itr.pmu = hisi_ptt_pmu; pttr->itr.recording_options = hisi_ptt_recording_options; pttr->itr.info_priv_size = hisi_ptt_info_priv_size; pttr->itr.info_fill = hisi_ptt_info_fill;tools/perf/arch/x86/util/intel-bts.c +0
-1@@ -434,7 +434,6 @@ struct auxtrace_record *intel_bts_recording_init(int *err) } btsr->intel_bts_pmu = intel_bts_pmu; - btsr->itr.pmu = intel_bts_pmu; btsr->itr.recording_options = intel_bts_recording_options; btsr->itr.info_priv_size = intel_bts_info_priv_size; btsr->itr.info_fill = intel_bts_info_fill;tools/perf/arch/x86/util/intel-pt.c +0
-1@@ -1197,7 +1197,6 @@ struct auxtrace_record *intel_pt_recording_init(int *err) } ptr->intel_pt_pmu = intel_pt_pmu; - ptr->itr.pmu = intel_pt_pmu; ptr->itr.recording_options = intel_pt_recording_options; ptr->itr.info_priv_size = intel_pt_info_priv_size; ptr->itr.info_fill = intel_pt_info_fill;tools/perf/util/auxtrace.h +0
-1@@ -411,7 +411,6 @@ struct auxtrace_record {int (*read_finish)(struct auxtrace_record *itr,int idx);unsigned int alignment;unsigned int default_aux_sample_size; -struct perf_pmu *pmu;struct evlist *evlist; };
Leo Yan
reviewerRe: [PATCH v1 2/9] perf auxtrace: Remove unused 'pmu' pointer from struct auxtrace_record
Hi Arnaldo,
Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 7 lines · Adrian Hunter
Quoted 4 lines · Leo Yan
The 'pmu' pointer in the
auxtrace_recordstructure is not used after support multiple AUX events, remove it.Signed-off-by Leo Yan <[email protected]>Reviewed-by Adrian Hunter <[email protected]>Applied the first reviewed two patches.
I confirmed it is fine to picking up these two patches.
Just note, I combined these two patches into the multiple AUX event series [1]. Once I receive response for that series, I will drop the picked two patches and send new series.
Thanks,
Leo
[1] https://lore.kernel.org/linux-perf-users/[email protected]/
Leo Yan
reviewerPATCH 3/9 perf auxtrace: Refactor auxtrace__evsel_is_auxtrace()
In reply to Leo YanThe auxtrace__evsel_is_auxtrace() function invokes the callback .evsel_is_auxtrace() to check if an event is an AUX trace. In the low-level code, every AUX trace module provides its callback to compare the PMU type.
This commit refactors auxtrace__evsel_is_auxtrace() by simply calling evsel__is_aux_event() rather than using the callback function. As a result, the callback .evsel_is_auxtrace() is no longer needed, so the definition and implementations are removed.
--- tools/perf/util/arm-spe.c | 9 --------- tools/perf/util/auxtrace.c | 4 ++-- tools/perf/util/auxtrace.h | 2 -- tools/perf/util/cs-etm.c | 13 +------------ tools/perf/util/hisi-ptt.c | 9 --------- tools/perf/util/intel-bts.c | 10 ---------- tools/perf/util/intel-pt.c | 10 ---------- tools/perf/util/s390-cpumsf.c | 9 --------- 8 files changed, 3 insertions(+), 63 deletions(-)
tools/perf/util/arm-spe.c +0 -9
@@ -1053,14 +1053,6 @@ static void arm_spe_free(struct perf_session *session)free (spe); } -static bool arm_spe_evsel_is_auxtrace (struct perf_session *session, -struct evsel *evsel) -{ - struct arm_spe *spe = container_of(session->auxtrace, struct arm_spe, auxtrace); - -return evsel->core.attr.type == spe->pmu_type; -} -static const char *const arm_spe_info_fmts[] = { [ARM_SPE_PMU_TYPE ] =" PMU Type %" PRId64"\n" , };
@@ -1344,7 +1336,6 @@ int arm_spe_process_auxtrace_info(union perf_event *event, spe->auxtrace.flush_events = arm_spe_flush; spe->auxtrace.free_events = arm_spe_free_events; spe->auxtrace.free = arm_spe_free; - spe->auxtrace.evsel_is_auxtrace = arm_spe_evsel_is_auxtrace; session->auxtrace = &spe->auxtrace;arm_spe_print_info (&auxtrace_info->priv[0 ]);
tools/perf/util/auxtrace.c +2 -2
@@ -2874,8 +2874,8 @@ void auxtrace__free(struct perf_session *session)bool auxtrace__evsel_is_auxtrace (struct perf_session *session,struct evsel *evsel) { -if (!session->auxtrace || !session->auxtrace->evsel_is_auxtrace) +if (!session->auxtrace)return false; -return session->auxtrace->evsel_is_auxtrace (session, evsel); +return evsel__is_aux_event (evsel); }
tools/perf/util/auxtrace.h +0 -2
@@ -221,8 +221,6 @@ struct auxtrace { struct perf_tool *tool);void (*free_events)(struct perf_session *session);void (*free)(struct perf_session *session); -bool (*evsel_is_auxtrace)(struct perf_session *session, -struct evsel *evsel); };/**
tools/perf/util/cs-etm.c +1 -12
@@ -899,16 +899,6 @@ static void cs_etm__free(struct perf_session *session)zfree (&aux); } -static bool cs_etm__evsel_is_auxtrace (struct perf_session *session, -struct evsel *evsel) -{ -struct cs_etm_auxtrace *aux =container_of (session->auxtrace, - struct cs_etm_auxtrace, - auxtrace); - -return evsel->core.attr.type == aux->pmu_type; -} -static struct machine *cs_etm__get_machine (struct cs_etm_queue *etmq,ocsd_ex_level el) {
@@ -2877,7 +2867,7 @@ static int cs_etm__setup_timeless_decoding(struct cs_etm_auxtrace *etm)* Find the cs_etm evsel and look at what its timestamp setting was */ evlist__for_each_entry (evlist, evsel) -if (cs_etm__evsel_is_auxtrace (etm->session, evsel)) { +if (evsel__is_aux_event (evsel)) { etm->timeless_decoding = !(evsel->core.attr.config &BIT (ETM_OPT_TS ));return 0 ;
@@ -3380,7 +3370,6 @@ int cs_etm__process_auxtrace_info_full(union perf_event *event, etm->auxtrace.flush_events = cs_etm__flush_events; etm->auxtrace.free_events = cs_etm__free_events; etm->auxtrace.free = cs_etm__free; - etm->auxtrace.evsel_is_auxtrace = cs_etm__evsel_is_auxtrace; session->auxtrace = &etm->auxtrace; err =cs_etm__setup_timeless_decoding (etm);
tools/perf/util/hisi-ptt.c +0 -9
@@ -141,14 +141,6 @@ static void hisi_ptt_free(struct perf_session *session)free (ptt); } -static bool hisi_ptt_evsel_is_auxtrace (struct perf_session *session, -struct evsel *evsel) -{ - struct hisi_ptt *ptt = container_of(session->auxtrace, struct hisi_ptt, auxtrace); - -return evsel->core.attr.type == ptt->pmu_type; -} -static void hisi_ptt_print_info (__u64 type) {if (!dump_trace)
@@ -181,7 +173,6 @@ int hisi_ptt_process_auxtrace_info(union perf_event *event, ptt->auxtrace.flush_events = hisi_ptt_flush; ptt->auxtrace.free_events = hisi_ptt_free_events; ptt->auxtrace.free = hisi_ptt_free; - ptt->auxtrace.evsel_is_auxtrace = hisi_ptt_evsel_is_auxtrace; session->auxtrace = &ptt->auxtrace;hisi_ptt_print_info (auxtrace_info->priv[0 ]);
tools/perf/util/intel-bts.c +0 -10
@@ -728,15 +728,6 @@ static void intel_bts_free(struct perf_session *session)free (bts); } -static bool intel_bts_evsel_is_auxtrace (struct perf_session *session, -struct evsel *evsel) -{ - struct intel_bts *bts = container_of(session->auxtrace, struct intel_bts, - auxtrace); - -return evsel->core.attr.type == bts->pmu_type; -} -struct intel_bts_synth {struct perf_tool dummy_tool;struct perf_session *session;
@@ -892,7 +883,6 @@ int intel_bts_process_auxtrace_info(union perf_event *event, bts->auxtrace.flush_events = intel_bts_flush; bts->auxtrace.free_events = intel_bts_free_events; bts->auxtrace.free = intel_bts_free; - bts->auxtrace.evsel_is_auxtrace = intel_bts_evsel_is_auxtrace; session->auxtrace = &bts->auxtrace; intel_bts_print_info(&auxtrace_info->priv[0], INTEL_BTS_PMU_TYPE,
tools/perf/util/intel-pt.c +0 -10
@@ -3589,15 +3589,6 @@ static void intel_pt_free(struct perf_session *session)free (pt); } -static bool intel_pt_evsel_is_auxtrace (struct perf_session *session, -struct evsel *evsel) -{ - struct intel_pt *pt = container_of(session->auxtrace, struct intel_pt, - auxtrace); - -return evsel->core.attr.type == pt->pmu_type; -} -static int intel_pt_process_auxtrace_event (struct perf_session *session,union perf_event *event,struct perf_tool *tool__maybe_unused )
@@ -4356,7 +4347,6 @@ int intel_pt_process_auxtrace_info(union perf_event *event, pt->auxtrace.flush_events = intel_pt_flush; pt->auxtrace.free_events = intel_pt_free_events; pt->auxtrace.free = intel_pt_free; - pt->auxtrace.evsel_is_auxtrace = intel_pt_evsel_is_auxtrace; session->auxtrace = &pt->auxtrace;if (dump_trace)
tools/perf/util/s390-cpumsf.c +0 -9
@@ -1048,14 +1048,6 @@ static void s390_cpumsf_free(struct perf_session *session)free (sf); } -static bool -s390_cpumsf_evsel_is_auxtrace (struct perf_session *session__maybe_unused , -struct evsel *evsel) -{ -return evsel->core.attr.type ==PERF_TYPE_RAW && - evsel->core.attr.config ==PERF_EVENT_CPUM_SF_DIAG ; -} -static int s390_cpumsf_get_type (const char *cpuid) {int ret, family =0 ;
@@ -1152,7 +1144,6 @@ int s390_cpumsf_process_auxtrace_info(union perf_event *event, sf->auxtrace.flush_events = s390_cpumsf_flush; sf->auxtrace.free_events = s390_cpumsf_free_events; sf->auxtrace.free = s390_cpumsf_free; - sf->auxtrace.evsel_is_auxtrace = s390_cpumsf_evsel_is_auxtrace; session->auxtrace = &sf->auxtrace;if (dump_trace)
Signature · 1 line
2.34.1
Adrian Hunter
reviewerRe: [PATCH v1 3/9] perf auxtrace: Refactor auxtrace__evsel_is_auxtrace()
Quoted 9 lines · Leo Yan
The
auxtrace__evsel_is_auxtrace()function invokes the callback .evsel_is_auxtrace() to check if an event is an AUX trace. In the low-level code, every AUX trace module provides its callback to compare the PMU type.This commit refactors
auxtrace__evsel_is_auxtrace()by simply callingevsel__is_aux_event()rather than using the callback function. As a result, the callback .evsel_is_auxtrace() is no longer needed, so the definition and implementations are removed.
evsel__is_aux_event() assumes it is on the target machine e.g. being called from perf record. It indirectly reads from sysfs to find PMUs, which will not necessarily be the same a different machine.
For example, what happens if a perf data file from one arch is being processed on a machine from another arch.
James Clark
reviewerRe: [PATCH v1 3/9] perf auxtrace: Refactor auxtrace__evsel_is_auxtrace()
Quoted 11 lines · Adrian Hunter
Quoted 9 lines · Leo Yan
The
auxtrace__evsel_is_auxtrace()function invokes the callback .evsel_is_auxtrace() to check if an event is an AUX trace. In the low-level code, every AUX trace module provides its callback to compare the PMU type.This commit refactors
auxtrace__evsel_is_auxtrace()by simply callingevsel__is_aux_event()rather than using the callback function. As a result, the callback .evsel_is_auxtrace() is no longer needed, so the definition and implementations are removed.
Quoted 8 lines
evsel__is_aux_event()assumes it is on the target machine e.g. being called from perf record. It indirectly reads from sysfs to find PMUs, which will not necessarily be the same a different machine.For example, what happens if a perf data file from one arch is being processed on a machine from another arch.
I think this does go a bit wrong. If I open an SPE file on x86 it finds the intel_pt PMU which both have the same type number. But because that's also an auxtrace one it appears to work.
Leo Yan
reviewerRe: [PATCH v1 3/9] perf auxtrace: Refactor auxtrace__evsel_is_auxtrace()
On 8/9/24 11:08, James Clark wrote:
[...]
Quoted 17 lines · Adrian Hunter
Quoted 16 lines · Leo Yan
Quoted 9 lines
The
auxtrace__evsel_is_auxtrace()function invokes the callback .evsel_is_auxtrace() to check if an event is an AUX trace. In the low-level code, every AUX trace module provides its callback to compare the PMU type.This commit refactors
auxtrace__evsel_is_auxtrace()by simply callingevsel__is_aux_event()rather than using the callback function. As a result, the callback .evsel_is_auxtrace() is no longer needed, so the definition and implementations are removed.
evsel__is_aux_event()assumes it is on the target machine e.g. being called from perf record. It indirectly reads from sysfs to find PMUs, which will not necessarily be the same a different machine.
Quoted 6 lines
Quoted 2 lines
For example, what happens if a perf data file from one arch is being processed on a machine from another arch.
I think this does go a bit wrong. If I open an SPE file on x86 it finds the
intel_ptPMU which both have the same type number. But because that's also an auxtrace one it appears to work.
Yes, anyway, I missed the cross report case and this patch will break it.
A event attribute should contain info to indicate the event is an AUX event. This would be better than inquiry every AUX module. I checked the attribute, there have no attribute field can be use to indicate a event is AUX event. A relevant field 'aux_output' is used to generate AUX trace rather than events, which is not set for AUX events.
Can we add a new field 'auxtrace' into the structure perf_event_attr? By using this way, the event will track the state rather than stored in PMU.
For next step, I will pick the first two patches in this series and merge them into the multiple AUX events support patch set. This can allow us to firstly resolve the multiple AUX event issue.
If we agree the refactoring for 'auxtrace' attribute, then I will use a separate patch set to address it.
Thanks,
Leo
Leo Yan
reviewerPATCH 4/9 perf arm-spe: Remove the 'pmu_type' field
In reply to Leo YanUse the evsel__is_aux_event() function in the Arm SPE layer to detected the enabled AUX events. It is safe for this change as it is no chance for mixing AUX events and only the same kind of AUX events are enabled during the initialization.
After the refactoring, the 'pmu_type' field is not used, so remove it.
--- tools/perf/util/arm-spe.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tools/perf/util/arm-spe.c +1 -3
@@ -45,7 +45,6 @@ struct arm_spe {u32 auxtrace_type;struct perf_session *session;struct machine *machine; -u32 pmu_type;u64 midr;struct perf_tsc_conversion tc;
@@ -1120,7 +1119,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session)int err;evlist__for_each_entry (evlist, evsel) { -if (evsel->core.attr.type == spe->pmu_type) { +if (evsel__is_aux_event (evsel)) { found = true;break ; }
@@ -1305,7 +1304,6 @@ int arm_spe_process_auxtrace_info(union perf_event *event, spe->session = session; spe->machine = &session->machines.host;/* No kvm support */ spe->auxtrace_type = auxtrace_info->type; - spe->pmu_type = auxtrace_info->priv[ARM_SPE_PMU_TYPE ]; spe->midr = midr; spe->timeless_decoding =arm_spe__is_timeless_decoding (spe);
Signature · 1 line
2.34.1
Leo Yan
reviewerPATCH 5/9 perf cs-etm: Remove the 'pmu_type' field
In reply to Leo YanUse the evsel__is_aux_event() function in the Arm CoreSight layer to detect the enabled AUX events. So the 'pmu_type' field is not used, remove it.
--- tools/perf/util/cs-etm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tools/perf/util/cs-etm.c +1 -3
@@ -77,7 +77,6 @@ struct cs_etm_auxtrace {u64 instructions_sample_period;u64 instructions_id;u64 **metadata; -unsigned int pmu_type;enum cs_etm_pid_fmt pid_fmt; };
@@ -1629,7 +1628,7 @@ static int cs_etm__synth_events(struct cs_etm_auxtrace *etm,int err;evlist__for_each_entry (evlist, evsel) { -if (evsel->core.attr.type == etm->pmu_type) { +if (evsel__is_aux_event (evsel)) { found = true;break ; }
@@ -3338,7 +3337,6 @@ int cs_etm__process_auxtrace_info_full(union perf_event *event, etm->session = session; etm->num_cpu = num_cpu; - etm->pmu_type = (unsigned int ) ((ptr[CS_PMU_TYPE_CPUS ] >>32 ) &0xffffffff ); etm->snapshot_mode = (ptr[CS_ETM_SNAPSHOT ] !=0 ); etm->metadata = metadata; etm->auxtrace_type = auxtrace_info->type;
Signature · 1 line
2.34.1
Leo Yan
reviewerPATCH 6/9 perf hisi-ptt: Remove the unused 'pmu_type' field
In reply to Leo YanThe 'pmu_type' field is not used, remove it.
--- tools/perf/util/hisi-ptt.c | 2 -- 1 file changed, 2 deletions(-)
tools/perf/util/hisi-ptt.c +0 -2
@@ -32,7 +32,6 @@ struct hisi_ptt {u32 auxtrace_type;struct perf_session *session;struct machine *machine; -u32 pmu_type; };static enum hisi_ptt_pkt_type hisi_ptt_check_packet_type (unsigned char *buf)
@@ -166,7 +165,6 @@ int hisi_ptt_process_auxtrace_info(union perf_event *event, ptt->session = session; ptt->machine = &session->machines.host;/* No kvm support */ ptt->auxtrace_type = auxtrace_info->type; - ptt->pmu_type = auxtrace_info->priv[0 ]; ptt->auxtrace.process_event = hisi_ptt_process_event; ptt->auxtrace.process_auxtrace_event = hisi_ptt_process_auxtrace_event;
Signature · 1 line
2.34.1
Leo Yan
reviewerPATCH 7/9 perf intel-bts: Remove the 'pmu_type' field
In reply to Leo YanUse the evsel__is_aux_event() function to detect the enabled AUX events. The 'pmu_type' field is not used, remove it.
--- tools/perf/util/intel-bts.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tools/perf/util/intel-bts.c +1 -3
@@ -51,7 +51,6 @@ struct intel_bts {bool sampling_mode;bool snapshot_mode;bool data_queued; -u32 pmu_type;struct perf_tsc_conversion tc;bool cap_user_time_zero;struct itrace_synth_opts synth_opts;
@@ -768,7 +767,7 @@ static int intel_bts_synth_events(struct intel_bts *bts,int err;evlist__for_each_entry (evlist, evsel) { -if (evsel->core.attr.type == bts->pmu_type && evsel->core.ids) { +if (evsel__is_aux_event (evsel) && evsel->core.ids) { found = true;break ; }
@@ -868,7 +867,6 @@ int intel_bts_process_auxtrace_info(union perf_event *event, bts->session = session; bts->machine = &session->machines.host;/* No kvm support */ bts->auxtrace_type = auxtrace_info->type; - bts->pmu_type = auxtrace_info->priv[INTEL_BTS_PMU_TYPE ]; bts->tc.time_shift = auxtrace_info->priv[INTEL_BTS_TIME_SHIFT ]; bts->tc.time_mult = auxtrace_info->priv[INTEL_BTS_TIME_MULT ]; bts->tc.time_zero = auxtrace_info->priv[INTEL_BTS_TIME_ZERO ];
Signature · 1 line
2.34.1
Leo Yan
reviewerPATCH 8/9 perf intel-pt: Remove the 'pmu_type' field
In reply to Leo YanUse the evsel__is_aux_event() function to detect the enabled AUX events. The 'pmu_type' field is not used, remove it.
--- tools/perf/util/intel-pt.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-)
tools/perf/util/intel-pt.c +17 -19
@@ -84,7 +84,6 @@ struct intel_pt {unsigned int br_stack_sz;unsigned int br_stack_sz_plus;int have_sched_switch; -u32 pmu_type;u64 kernel_start;u64 switch_ip;u64 ptss_ip;
@@ -1020,10 +1019,11 @@ static bool intel_pt_pgd_ip(uint64_t ip, void *data)return __intel_pt_pgd_ip (ip, data) >0 ; } -static bool intel_pt_get_config (struct intel_pt *pt, -struct perf_event_attr *attr,u64 *config) +static bool intel_pt_get_config (struct evsel *evsel,u64 *config) { -if (attr->type == pt->pmu_type) { +struct perf_event_attr *attr = &evsel->core.attr; + +if (evsel__is_aux_event (evsel)) {if (config) *config = attr->config;return true;
@@ -1037,7 +1037,7 @@ static bool intel_pt_exclude_kernel(struct intel_pt *pt)struct evsel *evsel;evlist__for_each_entry (pt->session->evlist, evsel) { -if (intel_pt_get_config (pt, &evsel->core.attr,NULL ) && +if (intel_pt_get_config (evsel,NULL ) && !evsel->core.attr.exclude_kernel)return false; }
@@ -1053,7 +1053,7 @@ static bool intel_pt_return_compression(struct intel_pt *pt)return true;evlist__for_each_entry (pt->session->evlist, evsel) { -if (intel_pt_get_config (pt, &evsel->core.attr, &config) && +if (intel_pt_get_config (evsel, &config) && (config & pt->noretcomp_bit))return false; }
@@ -1066,7 +1066,7 @@ static bool intel_pt_branch_enable(struct intel_pt *pt)u64 config;evlist__for_each_entry (pt->session->evlist, evsel) { -if (intel_pt_get_config (pt, &evsel->core.attr, &config) && +if (intel_pt_get_config (evsel, &config) && (config &INTEL_PT_CFG_PASS_THRU ) && !(config &INTEL_PT_CFG_BRANCH_EN ))return false;
@@ -1080,7 +1080,7 @@ static bool intel_pt_disabled_tnt(struct intel_pt *pt)u64 config;evlist__for_each_entry (pt->session->evlist, evsel) { -if (intel_pt_get_config (pt, &evsel->core.attr, &config) && +if (intel_pt_get_config (evsel, &config) && config &INTEL_PT_CFG_TNT_DIS )return true; }
@@ -1100,7 +1100,7 @@ static unsigned int intel_pt_mtc_period(struct intel_pt *pt) config >>=1 ;evlist__for_each_entry (pt->session->evlist, evsel) { -if (intel_pt_get_config (pt, &evsel->core.attr, &config)) +if (intel_pt_get_config (evsel, &config))return (config & pt->mtc_freq_bits) >> shift; }return 0 ;
@@ -1118,7 +1118,7 @@ static bool intel_pt_timeless_decoding(struct intel_pt *pt)evlist__for_each_entry (pt->session->evlist, evsel) {if (!(evsel->core.attr.sample_type &PERF_SAMPLE_TIME ))return true; -if (intel_pt_get_config (pt, &evsel->core.attr, &config)) { +if (intel_pt_get_config (evsel, &config)) {if (config & pt->tsc_bit) timeless_decoding = false;else
@@ -1133,7 +1133,7 @@ static bool intel_pt_tracing_kernel(struct intel_pt *pt)struct evsel *evsel;evlist__for_each_entry (pt->session->evlist, evsel) { -if (intel_pt_get_config (pt, &evsel->core.attr,NULL ) && +if (intel_pt_get_config (evsel,NULL ) && !evsel->core.attr.exclude_kernel)return true; }
@@ -1150,7 +1150,7 @@ static bool intel_pt_have_tsc(struct intel_pt *pt)return false;evlist__for_each_entry (pt->session->evlist, evsel) { -if (intel_pt_get_config (pt, &evsel->core.attr, &config)) { +if (intel_pt_get_config (evsel, &config)) {if (config & pt->tsc_bit) have_tsc = true;else
@@ -1166,7 +1166,7 @@ static bool intel_pt_have_mtc(struct intel_pt *pt)u64 config;evlist__for_each_entry (pt->session->evlist, evsel) { -if (intel_pt_get_config (pt, &evsel->core.attr, &config) && +if (intel_pt_get_config (evsel, &config) && (config & pt->mtc_bit))return true; }
@@ -1191,7 +1191,7 @@ static u64 intel_pt_ctl(struct intel_pt *pt)u64 config;evlist__for_each_entry (pt->session->evlist, evsel) { -if (intel_pt_get_config (pt, &evsel->core.attr, &config)) +if (intel_pt_get_config (evsel, &config))return config; }return 0 ;
@@ -3703,13 +3703,12 @@ static void intel_pt_set_event_name(struct evlist *evlist, u64 id, } } -static struct evsel *intel_pt_evsel (struct intel_pt *pt, -struct evlist *evlist) +static struct evsel *intel_pt_evsel (struct evlist *evlist) {struct evsel *evsel;evlist__for_each_entry (evlist, evsel) { -if (evsel->core.attr.type == pt->pmu_type && evsel->core.ids) +if (evsel__is_aux_event (evsel) && evsel->core.ids)return evsel; }
@@ -3720,7 +3719,7 @@ static int intel_pt_synth_events(struct intel_pt *pt, struct perf_session *session) {struct evlist *evlist = session->evlist; -struct evsel *evsel =intel_pt_evsel (pt, evlist); +struct evsel *evsel =intel_pt_evsel (evlist);struct perf_event_attr attr;u64 id;int err;
@@ -4219,7 +4218,6 @@ int intel_pt_process_auxtrace_info(union perf_event *event, pt->session = session; pt->machine = &session->machines.host;/* No kvm support */ pt->auxtrace_type = auxtrace_info->type; - pt->pmu_type = auxtrace_info->priv[INTEL_PT_PMU_TYPE ]; pt->tc.time_shift = auxtrace_info->priv[INTEL_PT_TIME_SHIFT ]; pt->tc.time_mult = auxtrace_info->priv[INTEL_PT_TIME_MULT ]; pt->tc.time_zero = auxtrace_info->priv[INTEL_PT_TIME_ZERO ];
Signature · 1 line
2.34.1
Leo Yan
reviewerPATCH 9/9 perf s390-cpumsf: Remove the unused 'pmu_type' field
In reply to Leo YanThe 'pmu_type' field is not used, remove it.
--- tools/perf/util/s390-cpumsf.c | 2 -- 1 file changed, 2 deletions(-)
tools/perf/util/s390-cpumsf.c +0 -2
@@ -172,7 +172,6 @@ struct s390_cpumsf {struct perf_session *session;struct machine *machine;u32 auxtrace_type; -u32 pmu_type;u16 machine_type;bool data_queued;bool use_logfile;
@@ -1136,7 +1135,6 @@ int s390_cpumsf_process_auxtrace_info(union perf_event *event, sf->session = session; sf->machine = &session->machines.host;/* No kvm support */ sf->auxtrace_type = auxtrace_info->type; - sf->pmu_type =PERF_TYPE_RAW ; sf->machine_type =s390_cpumsf_get_type (session->evlist->env->cpuid); sf->auxtrace.process_event = s390_cpumsf_process_event;
Signature · 1 line
2.34.1