linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] arm64: perf: Use only exclude_kernel attribute when kernel is running in HYP
Date: Tue, 25 Apr 2017 17:53:00 +0100	[thread overview]
Message-ID: <20170425165259.GS24484@arm.com> (raw)
In-Reply-To: <CAFpQJXWX=0GQ5hse4E_OSdnYhMOA7CvqeoHe9AdMsyoZJmrPQQ@mail.gmail.com>

On Tue, Apr 25, 2017 at 09:13:40AM +0530, Ganapatrao Kulkarni wrote:
> On Mon, Apr 24, 2017 at 9:15 PM, Will Deacon <will.deacon@arm.com> wrote:
> > On Thu, Apr 20, 2017 at 02:56:50PM +0530, Ganapatrao Kulkarni wrote:
> >> On Thu, Apr 20, 2017 at 2:19 PM, Mark Rutland <mark.rutland@arm.com> wrote:
> >> > On Wed, Apr 19, 2017 at 11:14:06PM +0530, Ganapatrao Kulkarni wrote:
> >> >> commit d98ecda (arm64: perf: Count EL2 events if the kernel is running in HYP)
> >> >> is returning error for perf syscall with mixed attribute set for exclude_kernel
> >> >> and exclude_hv. This change is breaking some applications (observed with hhvm)
> >> >> when ran on VHE enabled platforms.
> >> >>
> >> >> Adding fix to consider only exclude_kernel attribute when kernel is
> >> >> running in HYP. Also adding sysfs file to notify the bhehaviour
> >> >> of attribute exclude_hv.
> >> >>
> >> >> Signed-off-by: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
> >> >> ---
> >> >>
> >> >> Changelog:
> >> >>
> >> >> V2:
> >> >>  - Changes as per Will Deacon's suggestion.
> >> >>
> >> >> V1: Initial patch
> >> >>
> >> >>  arch/arm64/kernel/perf_event.c | 28 ++++++++++++++++++++++++----
> >> >>  include/linux/perf/arm_pmu.h   |  1 +
> >> >>  2 files changed, 25 insertions(+), 4 deletions(-)
> >> >>
> >> >> @@ -871,14 +890,13 @@ static int armv8pmu_set_event_filter(struct hw_perf_event *event,
> >> >>
> >> >>       if (attr->exclude_idle)
> >> >>               return -EPERM;
> >> >> -     if (is_kernel_in_hyp_mode() &&
> >> >> -         attr->exclude_kernel != attr->exclude_hv)
> >> >> -             return -EINVAL;
> >> >> +     if (is_kernel_in_hyp_mode() && !attr->exclude_kernel)
> >> >> +             config_base |= ARMV8_PMU_INCLUDE_EL2;
> >> >>       if (attr->exclude_user)
> >> >>               config_base |= ARMV8_PMU_EXCLUDE_EL0;
> >> >>       if (!is_kernel_in_hyp_mode() && attr->exclude_kernel)
> >> >>               config_base |= ARMV8_PMU_EXCLUDE_EL1;
> >> >> -     if (!attr->exclude_hv)
> >> >> +     if (!is_kernel_in_hyp_mode() && !attr->exclude_hv)
> >> >>               config_base |= ARMV8_PMU_INCLUDE_EL2;
> >> >
> >> > This isn't quite what Will suggested.
> >> >
> >> > The idea was that userspace would read sysfs, then use that to determine
> >> > the correct exclusion parameters [1,2]. This logic was not expected to
> >> > change; it correctly validates whether we can provide what the user
> >> > requests.
> >>
> >> OK, if you are ok with sysfs part, i can send next version with that
> >> change only?.
> >
> > I think the sysfs part is still a little dodgy, since you still expose the
> > "exclude_hv" file with a value of 0 when not running at EL2, which would
> > imply that exclude_hv is forced to zero. I don't think that's correct.
> 
> okay, i can make exclude_hv visible only when kernel booted in EL2.
> is it ok to have empty directory "attr" when kernel booted to EL1?
> attr can be place holder for any other miscellaneous attributes, that
> can be added in future.

Sounds good to me, although I'll seek comment from the other perf folks
before merging anything with ABI implications.

Will

  reply	other threads:[~2017-04-25 16:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-19 17:44 [PATCH v2] arm64: perf: Use only exclude_kernel attribute when kernel is running in HYP Ganapatrao Kulkarni
2017-04-20  8:49 ` Mark Rutland
2017-04-20  9:26   ` Ganapatrao Kulkarni
2017-04-24 15:45     ` Will Deacon
2017-04-25  3:43       ` Ganapatrao Kulkarni
2017-04-25 16:53         ` Will Deacon [this message]
2017-04-26  6:53           ` Jayachandran C.
2017-04-26  7:22             ` Pinski, Andrew
2017-04-26 10:10               ` Will Deacon
2017-04-26 13:41                 ` Jayachandran C
2017-04-27 17:37                   ` Will Deacon
2017-04-28 13:46                     ` Jayachandran C
2017-04-28 16:38                       ` Will Deacon
2017-05-01 16:10                         ` Jayachandran C

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=20170425165259.GS24484@arm.com \
    --to=will.deacon@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).