perf tools: Add SPE total latency as PERF_SAMPLE_WEIGHT
Subsystems (2)
Namhyung Kim
maintainerPATCH 1/1 perf tools: Add SPE total latency as PERF_SAMPLE_WEIGHT
Use total latency info in the SPE counter packet as sample weight so that we can see it in local_weight and (global) weight sort keys.
Maybe we can use PERF_SAMPLE_WEIGHT_STRUCT to support ins_lat as well but I'm not sure which latency it matches. So just adding total latency first.
--- tools/perf/util/arm-spe-decoder/arm-spe-decoder.c | 2 ++ tools/perf/util/arm-spe-decoder/arm-spe-decoder.h | 1 + tools/perf/util/arm-spe.c | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-)
tools/perf/util/arm-spe-decoder/arm-spe-decoder.c +2 -0
@@ -179,6 +179,8 @@ static int arm_spe_read_record(struct arm_spe_decoder *decoder) decoder->record.phys_addr = ip;break ;case ARM_SPE_COUNTER : +if (idx ==SPE_CNT_PKT_HDR_INDEX_TOTAL_LAT ) + decoder->record.latency = payload;break ;case ARM_SPE_CONTEXT : decoder->record.context_id = payload;
tools/perf/util/arm-spe-decoder/arm-spe-decoder.h +1 -0
@@ -33,6 +33,7 @@ struct arm_spe_record {enum arm_spe_sample_type type;int err;u32 op; +u32 latency;u64 from_ip;u64 to_ip;u64 timestamp;
tools/perf/util/arm-spe.c +3 -1
@@ -317,6 +317,7 @@ static int arm_spe__synth_mem_sample(struct arm_spe_queue *speq, sample.addr = record->virt_addr; sample.phys_addr = record->phys_addr; sample.data_src = data_src; + sample.weight = record->latency;return arm_spe_deliver_synth_event (spe, speq, event, &sample); }
@@ -980,7 +981,8 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) attr.type =PERF_TYPE_HARDWARE ; attr.sample_type = evsel->core.attr.sample_type &PERF_SAMPLE_MASK ; attr.sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID | -PERF_SAMPLE_PERIOD |PERF_SAMPLE_DATA_SRC ; +PERF_SAMPLE_PERIOD |PERF_SAMPLE_DATA_SRC | +PERF_SAMPLE_WEIGHT ;if (spe->timeless_decoding) attr.sample_type &= ~(u64 )PERF_SAMPLE_TIME ;else
Signature · 1 line
2.34.0.rc2.393.gf8c9666880-goog
Hi Namhyung,
Quoted 47 lines · Namhyung Kim
Use total latency info in the SPE counter packet as sample weight so that we can see it in
local_weightand (global) weight sort keys.Maybe we can use
PERF_SAMPLE_WEIGHT_STRUCTto supportins_latas well but I'm not sure which latency it matches. So just adding total latency first.Cc German Gomez <[email protected]>Cc Leo Yan <[email protected]>Cc Mark Rutland <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/arm-spe-decoder/arm-spe-decoder.c | 2 ++ tools/perf/util/arm-spe-decoder/arm-spe-decoder.h | 1 + tools/perf/util/arm-spe.c | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-)tools/perf/util/arm-spe-decoder/arm-spe-decoder.c +2
-0@@ -179,6 +179,8 @@ static int arm_spe_read_record(struct arm_spe_decoder *decoder) decoder->record.phys_addr = ip;break ;case ARM_SPE_COUNTER : +if (idx ==SPE_CNT_PKT_HDR_INDEX_TOTAL_LAT ) + decoder->record.latency = payload;break ;case ARM_SPE_CONTEXT : decoder->record.context_id = payload;tools/perf/util/arm-spe-decoder/arm-spe-decoder.h +1
-0@@ -33,6 +33,7 @@ struct arm_spe_record {enum arm_spe_sample_type type;int err;u32 op; +u32 latency;u64 from_ip;u64 to_ip;u64 timestamp;tools/perf/util/arm-spe.c +0
-0
tools/perf/util/arm-spe.c static int arm_spe__synth_mem_sample(struct arm_spe_queue *speq, · line 320
Quoted 4 lines
tools/perf/util/arm-spe.c +1
-0@@ -317,6 +317,7 @@ static int arm_spe__synth_mem_sample(struct arm_spe_queue *speq, sample.addr = record->virt_addr; sample.phys_addr = record->phys_addr; sample.data_src = data_src; + sample.weight = record->latency;
The latency can be used for branch operations as well, it's good to assign latency for branch samples in the function arm_spe__synth_branch_sample().
With adding latency for branch sample, the change would be good for me:
Quoted 15 lines
tools/perf/util/arm-spe.c +2
-1return arm_spe_deliver_synth_event (spe, speq, event, &sample); }@@ -980,7 +981,8 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) attr.type =PERF_TYPE_HARDWARE ; attr.sample_type = evsel->core.attr.sample_type &PERF_SAMPLE_MASK ; attr.sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID | -PERF_SAMPLE_PERIOD |PERF_SAMPLE_DATA_SRC ; +PERF_SAMPLE_PERIOD |PERF_SAMPLE_DATA_SRC | +PERF_SAMPLE_WEIGHT ;if (spe->timeless_decoding) attr.sample_type &= ~(u64 )PERF_SAMPLE_TIME ;else Signature · 1 line
2.34.0.rc2.393.gf8c9666880-goog
Namhyung Kim
maintainerHi Leo,
Quoted 51 lines · Leo Yan
Hi Namhyung,
Quoted 47 lines · Namhyung Kim
Use total latency info in the SPE counter packet as sample weight so that we can see it in
local_weightand (global) weight sort keys.Maybe we can use
PERF_SAMPLE_WEIGHT_STRUCTto supportins_latas well but I'm not sure which latency it matches. So just adding total latency first.Cc German Gomez <[email protected]>Cc Leo Yan <[email protected]>Cc Mark Rutland <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/arm-spe-decoder/arm-spe-decoder.c | 2 ++ tools/perf/util/arm-spe-decoder/arm-spe-decoder.h | 1 + tools/perf/util/arm-spe.c | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-)tools/perf/util/arm-spe-decoder/arm-spe-decoder.c +2
-0@@ -179,6 +179,8 @@ static int arm_spe_read_record(struct arm_spe_decoder *decoder) decoder->record.phys_addr = ip;break ;case ARM_SPE_COUNTER : +if (idx ==SPE_CNT_PKT_HDR_INDEX_TOTAL_LAT ) + decoder->record.latency = payload;break ;case ARM_SPE_CONTEXT : decoder->record.context_id = payload;tools/perf/util/arm-spe-decoder/arm-spe-decoder.h +1
-0@@ -33,6 +33,7 @@ struct arm_spe_record {enum arm_spe_sample_type type;int err;u32 op; +u32 latency;u64 from_ip;u64 to_ip;u64 timestamp;tools/perf/util/arm-spe.c +0
-0@@ -317,6 +317,7 @@ static int arm_spe__synth_mem_sample(struct arm_spe_queue *speq,
Quoted 8 lines
tools/perf/util/arm-spe.c static int arm_spe__synth_mem_sample(struct arm_spe_queue *speq, · line 320
Quoted 4 lines
tools/perf/util/arm-spe.c +1
-0sample.addr = record->virt_addr; sample.phys_addr = record->phys_addr; sample.data_src = data_src; + sample.weight = record->latency;The latency can be used for branch operations as well, it's good to assign latency for branch samples in the function
arm_spe__synth_branch_sample().
Yep, I'll update.
Quoted 4 lines
With adding latency for branch sample, the change would be good for me:
Reviewed-by Leo Yan <[email protected]>
Thanks for your review!
Namhyung
Quoted 16 lines
Quoted 16 lines
tools/perf/util/arm-spe.c +2
-2return arm_spe_deliver_synth_event (spe, speq, event, &sample); }@@ -980,7 +981,8 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session) attr.type =PERF_TYPE_HARDWARE ; attr.sample_type = evsel->core.attr.sample_type &PERF_SAMPLE_MASK ; attr.sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID | -PERF_SAMPLE_PERIOD |PERF_SAMPLE_DATA_SRC ; +PERF_SAMPLE_PERIOD |PERF_SAMPLE_DATA_SRC | +PERF_SAMPLE_WEIGHT ;if (spe->timeless_decoding) attr.sample_type &= ~(u64 )PERF_SAMPLE_TIME ;else --2.34.0.rc2.393.gf8c9666880-goog