From: Matt Redfearn <matt.redfearn@mips.com>
To: James Hogan <jhogan@kernel.org>,
Ralf Baechle <ralf@linux-mips.org>,
Florian Fainelli <f.fainelli@gmail.com>
Cc: <linux-mips@linux-mips.org>,
Matt Redfearn <matt.redfearn@mips.com>,
Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
<linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@redhat.com>,
Jiri Olsa <jolsa@redhat.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>
Subject: [PATCH v2 2/6] MIPS: perf: Use correct VPE ID when setting up VPE tracing
Date: Thu, 12 Apr 2018 10:36:22 +0100 [thread overview]
Message-ID: <1523525786-29153-3-git-send-email-matt.redfearn@mips.com> (raw)
In-Reply-To: <1523525786-29153-1-git-send-email-matt.redfearn@mips.com>
There are a couple of FIXME's in the perf code which state that
cpu_data[event->cpu].vpe_id reports 0 for both CPUs. This is no longer
the case, since the vpe_id is used extensively by SMP CPS.
VPE local counting gets around this by using smp_processor_id() instead.
As it happens this does work correctly to count events on the right VPE,
but relies on 2 assumptions:
a) Always having 2 VPEs / core.
b) The hardware only paying attention to the least significant bit of
the PERFCTL.VPEID field.
If either of these assumptions change then the incorrect VPEs events
will be counted.
Fix this by replacing smp_processor_id() with
cpu_vpe_id(¤t_cpu_data), in the vpe_id() macro, and pass vpe_id()
to M_PERFCTL_VPEID() when setting up PERFCTL.VPEID. The FIXME's can also
be removed since they no longer apply.
Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
---
Changes in v2: None
arch/mips/kernel/perf_event_mipsxx.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c
index f3ec4a36921d..239c4ca89fb0 100644
--- a/arch/mips/kernel/perf_event_mipsxx.c
+++ b/arch/mips/kernel/perf_event_mipsxx.c
@@ -137,12 +137,8 @@ static DEFINE_RWLOCK(pmuint_rwlock);
#define vpe_id() (cpu_has_mipsmt_pertccounters ? \
0 : (smp_processor_id() & MIPS_CPUID_TO_COUNTER_MASK))
#else
-/*
- * FIXME: For VSMP, vpe_id() is redefined for Perf-events, because
- * cpu_data[cpuid].vpe_id reports 0 for _both_ CPUs.
- */
#define vpe_id() (cpu_has_mipsmt_pertccounters ? \
- 0 : smp_processor_id())
+ 0 : cpu_vpe_id(¤t_cpu_data))
#endif
/* Copied from op_model_mipsxx.c */
@@ -1279,11 +1275,7 @@ static void check_and_calc_range(struct perf_event *event,
*/
hwc->config_base |= M_TC_EN_ALL;
} else {
- /*
- * FIXME: cpu_data[event->cpu].vpe_id reports 0
- * for both CPUs.
- */
- hwc->config_base |= M_PERFCTL_VPEID(event->cpu);
+ hwc->config_base |= M_PERFCTL_VPEID(vpe_id());
hwc->config_base |= M_TC_EN_VPE;
}
} else
--
2.7.4
next prev parent reply other threads:[~2018-04-12 9:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-12 9:36 [PATCH v2 0/6] MIPS: perf: MT fixes and improvements Matt Redfearn
2018-04-12 9:36 ` [PATCH v2 1/6] MIPS: perf: More robustly probe for the presence of per-tc counters Matt Redfearn
2018-04-18 21:46 ` James Hogan
2018-04-12 9:36 ` Matt Redfearn [this message]
2018-04-12 9:36 ` [PATCH v2 3/6] MIPS: perf: Fix perf with MT counting other threads Matt Redfearn
2018-04-12 9:36 ` [PATCH v2 4/6] MIPS: perf: Allocate per-core counters on demand Matt Redfearn
2018-04-12 9:36 ` [PATCH v2 5/6] MIPS: perf: Fold vpe_id() macro into it's one last usage Matt Redfearn
2018-04-12 9:36 ` [PATCH v2 6/6] MIPS: perf: Fix BMIPS5000 system mode counting Matt Redfearn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1523525786-29153-3-git-send-email-matt.redfearn@mips.com \
--to=matt.redfearn@mips.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=f.fainelli@gmail.com \
--cc=jhogan@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox