From: Michael Ellerman <mpe@ellerman.id.au>
To: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [1/1] powerpc/perf/hv-24x7: Check support before registering
Date: Thu, 4 Jun 2015 21:40:28 +1000 (AEST) [thread overview]
Message-ID: <20150604114029.0D2AD140280@ozlabs.org> (raw)
In-Reply-To: <20150520233416.GA10270@us.ibm.com>
On Wed, 2015-20-05 at 23:34:16 UTC, Sukadev Bhattiprolu wrote:
> >From 955102eacf035b19080dc659a15d9b8fbd8fae7f Mon Sep 17 00:00:00 2001
> From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
> Date: Tue, 28 Apr 2015 18:47:58 -0400
> Subject: [PATCH 1/1] powerpc/perf/hv-24x7: Check support before registering
> PMU
>
> We currently try to register the 24x7 PMU unconditionally. Not all
> Power systems support 24x7 counters (eg: Power7). On these systems
> we get a backtrace during boot when trying to register the 24x7 PMU.
>
> Check if the hypervisor supports 24x7 counters before attempting to
> register the 24x7 PMU.
>
> Reported-by: Gustavo Luiz Duarte <gusld@br.ibm.com>
> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
> ---
>
> Changelog[v2]
> - [Michael Ellerman] Simplify check with bogus parameters.
> ---
> arch/powerpc/perf/hv-24x7.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
> index ec2eb20..c04a332 100644
> --- a/arch/powerpc/perf/hv-24x7.c
> +++ b/arch/powerpc/perf/hv-24x7.c
> @@ -1268,12 +1268,33 @@ static struct pmu h_24x7_pmu = {
> .read = h_24x7_event_read,
> };
>
> +/*
> + * Return 1 if we can access the 24x7 counter catalog from the hypervisor.
> + * Return 0 otherwise.
Comment is wrong.
> + */
> +static bool hv_has_24x7(void)
> +{
> + unsigned long hret;
ret would be fine.
> +
> + hret = h_get_24x7_catalog_page(0, 0, 0);
> +
> + if (hret != H_FUNCTION)
> + pr_err("Error %ld reading catalog, disabling 24x7 PMU\n", hret);
> +
> + return hret == 0;
I don't get what you're doing here.
You check for something other than H_FUNCTION, and print, and then you just
compare against 0. But I wouldn't ever expect that to return 0, because you
passed it bogus args.
The logic should be:
static bool is_24x7_supported(void)
{
if (h_get_24x7_catalog_page(0, 0, 0) == H_FUNCTION)
return false;
return true;
}
> static int hv_24x7_init(void)
> {
> int r;
> unsigned long hret;
> struct hv_perf_caps caps;
>
> + if (!hv_has_24x7())
> + return -ENODEV;
> +
This is no good. You're doing the check, which involves a hcall, before you
even check if you're running with a hypervisor (below).
> if (!firmware_has_feature(FW_FEATURE_LPAR)) {
> pr_debug("not a virtualized system, not enabling\n");
> return -ENODEV;
cheers
prev parent reply other threads:[~2015-06-04 11:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-20 23:34 [PATCH 1/1] powerpc/perf/hv-24x7: Check support before registering Sukadev Bhattiprolu
2015-06-04 11:40 ` Michael Ellerman [this message]
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=20150604114029.0D2AD140280@ozlabs.org \
--to=mpe@ellerman.id.au \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=sukadev@linux.vnet.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).