From: James Hogan <jhogan@kernel.org>
To: Matt Redfearn <matt.redfearn@mips.com>
Cc: Ralf Baechle <ralf@linux-mips.org>,
Florian Fainelli <f.fainelli@gmail.com>,
linux-mips@linux-mips.org, Namhyung Kim <namhyung@kernel.org>,
"Maciej W. Rozycki" <macro@mips.com>,
Peter Zijlstra <peterz@infradead.org>,
linux-kernel@vger.kernel.org, Paul Burton <paul.burton@mips.com>,
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: Re: [PATCH v2 1/6] MIPS: perf: More robustly probe for the presence of per-tc counters
Date: Wed, 18 Apr 2018 22:46:38 +0100 [thread overview]
Message-ID: <20180418214637.GB16439@saruman> (raw)
In-Reply-To: <1523525786-29153-2-git-send-email-matt.redfearn@mips.com>
[-- Attachment #1: Type: text/plain, Size: 3783 bytes --]
On Thu, Apr 12, 2018 at 10:36:21AM +0100, Matt Redfearn wrote:
> Processors implementing the MIPS MT ASE may have performance counters
> implemented per core or per TC. Processors implemented by MIPS
> Technologies signify presence per TC through a bit in the implementation
> specific Config7 register. Currently the code which probes for their
> presence blindly reads a magic number corresponding to this bit, despite
> it potentially having a different meaning in the CPU implementation.
>
> The test of Config7.PTC was previously enabled when CONFIG_BMIPS5000 was
> enabled. However, according to [florian], the BMIPS5000 manual does not
> define this bit, so we can assume it is 0 and the feature is not
> supported.
>
> Introduce probe_mipsmt_pertccounters() to probe for the presence of per
> TC counters. This detects the ases implemented in the CPU, and reads any
> implementation specific bit flagging their presence. In the case of MIPS
> implementations, this bit is Config7.PTC. A definition of this bit is
> added in mipsregs.h for MIPS Technologies. No other implementations
> support this feature.
>
> Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
> ---
>
> Changes in v2: None
>
> arch/mips/include/asm/mipsregs.h | 5 +++++
> arch/mips/kernel/perf_event_mipsxx.c | 29 ++++++++++++++++++++++++++++-
> 2 files changed, 33 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
> index 858752dac337..a4baaaa02bc8 100644
> --- a/arch/mips/include/asm/mipsregs.h
> +++ b/arch/mips/include/asm/mipsregs.h
> @@ -684,6 +684,11 @@
> #define MIPS_CONF7_IAR (_ULCAST_(1) << 10)
> #define MIPS_CONF7_AR (_ULCAST_(1) << 16)
>
> +/* Config7 Bits specific to MIPS Technologies. */
> +
> +/* Performance counters implemented Per TC */
> +#define MTI_CONF7_PTC (_ULCAST_(1) << 19)
> +
> /* WatchLo* register definitions */
> #define MIPS_WATCHLO_IRW (_ULCAST_(0x7) << 0)
>
> diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c
> index 6668f67a61c3..f3ec4a36921d 100644
> --- a/arch/mips/kernel/perf_event_mipsxx.c
> +++ b/arch/mips/kernel/perf_event_mipsxx.c
> @@ -1708,6 +1708,33 @@ static const struct mips_perf_event *xlp_pmu_map_raw_event(u64 config)
> return &raw_event;
> }
>
> +#ifdef CONFIG_MIPS_PERF_SHARED_TC_COUNTERS
> +/*
> + * The MIPS MT ASE specifies that performance counters may be implemented
> + * per core or per TC. If implemented per TC then all Linux CPUs have their
> + * own unique counters. If implemented per core, then VPEs in the core must
> + * treat the counters as a shared resource.
> + * Probe for the presence of per-TC counters
> + */
> +static int probe_mipsmt_pertccounters(void)
> +{
> + struct cpuinfo_mips *c = ¤t_cpu_data;
> +
> + /* Non-MT cores by definition cannot implement per-TC counters */
> + if (!cpu_has_mipsmt)
> + return 0;
> +
> + switch (c->processor_id & PRID_COMP_MASK) {
> + case PRID_COMP_MIPS:
> + /* MTI implementations use CONFIG7.PTC to signify presence */
> + return read_c0_config7() & MTI_CONF7_PTC;
> + default:
> + break;
> + }
> + return 0;
> +}
> +#endif /* CONFIG_MIPS_PERF_SHARED_TC_COUNTERS */
> +
> static int __init
> init_hw_perf_events(void)
> {
> @@ -1723,7 +1750,7 @@ init_hw_perf_events(void)
> }
>
> #ifdef CONFIG_MIPS_PERF_SHARED_TC_COUNTERS
> - cpu_has_mipsmt_pertccounters = read_c0_config7() & (1<<19);
> + cpu_has_mipsmt_pertccounters = probe_mipsmt_pertccounters();
Similar code also exists in arch/mips/oprofile/op_model_mipsxx.c.
Perhaps it is time to unify it into more standard places, i.e.
asm/cpu-features.h and cpu-probe.c.
Cheers
James
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-04-18 21:46 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 [this message]
2018-04-12 9:36 ` [PATCH v2 2/6] MIPS: perf: Use correct VPE ID when setting up VPE tracing Matt Redfearn
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=20180418214637.GB16439@saruman \
--to=jhogan@kernel.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=f.fainelli@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=macro@mips.com \
--cc=matt.redfearn@mips.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=paul.burton@mips.com \
--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