From 71e3343b730a58f3345aeea14c41b1617a18e947 Mon Sep 17 00:00:00 2001 From: Tan Xiaojun Date: Mon, 25 Nov 2019 10:58:18 +0800 Subject: [PATCH] arm_spe: add --spe=t for true_sharing in spe-c2c hulk inclusion category: feature bugzilla: 18657 CVE: NA ------------------------------------------- Add new option --spe=t for true_sharing in spe-c2c, default is no. Signed-off-by: Tan Xiaojun Signed-off-by: Wei Li Reviewed-by: Xuefeng Wang Reviewed-by: Tan Xiaojun Signed-off-by: Yang Yingliang --- tools/perf/util/arm-spe.c | 7 +++++-- tools/perf/util/auxtrace.c | 6 +++++- tools/perf/util/auxtrace.h | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 52ba76a6fc17..f62cd5a1b9e1 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -751,8 +751,10 @@ static void arm_spe_c2c_get_samples(void *arg) struct rb_root *listB = ((struct spe_c2c_compare_lists *)arg)->listB; struct spe_c2c_sample_queues *queues = ((struct spe_c2c_compare_lists *)arg)->queues; struct spe_c2c_sample_queues *oppoqs = ((struct spe_c2c_compare_lists *)arg)->oppoqs; + struct arm_spe_queue *speq = queues->speq; struct rb_node *nodeA, *nodeB; struct spe_c2c_sample *sampleA, *sampleB; + bool tshare = speq->spe->synth_opts.c2c_tshare; uint64_t xor; for (nodeA = rb_first(listA); nodeA; nodeA = rb_next(nodeA)) { @@ -761,8 +763,9 @@ static void arm_spe_c2c_get_samples(void *arg) sampleB = rb_entry(nodeB, struct spe_c2c_sample, rb_node); xor = sampleA->state.phys_addr ^ sampleB->state.phys_addr; - if (!(xor & 0xFFFFFFFFFFFFFFC0) && (xor & 0x3F) - && sampleA->tid != sampleB->tid) { + if (!(xor & 0xFFFFFFFFFFFFFFC0) + && (tshare || (xor & 0x3F)) + && (sampleA->tid != sampleB->tid)) { pthread_mutex_lock(&mut); arm_spe_c2c_sample(queues, sampleA); arm_spe_c2c_sample(oppoqs, sampleB); diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 4a0698685659..aa6dff2083d6 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -1144,6 +1144,7 @@ void arm_spe_synth_opts__set_default(struct arm_spe_synth_opts *synth_opts) synth_opts->remote_access = true; synth_opts->c2c_remote = false; synth_opts->c2c_store = false; + synth_opts->c2c_tshare = false; } int arm_spe_parse_synth_opts(const struct option *opt, const char *str, @@ -1165,7 +1166,10 @@ int arm_spe_parse_synth_opts(const struct option *opt, const char *str, synth_opts->llc_miss = true; break; case 't': - synth_opts->tlb_miss = true; + if (synth_opts->c2c_mode) + synth_opts->c2c_tshare = true; + else + synth_opts->tlb_miss = true; break; case 'b': synth_opts->branch_miss = true; diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 615f42d8c694..70eb94251d45 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -121,6 +121,7 @@ struct arm_spe_synth_opts { bool c2c_mode; bool c2c_remote; bool c2c_store; + bool c2c_tshare; }; /** -- GitLab