Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1627218 > unrolled thread
| Started by | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| First post | 2017-04-20 11:00 +0200 |
| Last post | 2017-04-24 17:50 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v2] arm64: perf: Use only exclude_kernel attribute when kernel is running in HYP Mark Rutland <mark.rutland@arm.com> - 2017-04-20 11:00 +0200
Re: [PATCH v2] arm64: perf: Use only exclude_kernel attribute when kernel is running in HYP Ganapatrao Kulkarni <gpkulkarni@gmail.com> - 2017-04-20 11:30 +0200
Re: [PATCH v2] arm64: perf: Use only exclude_kernel attribute when kernel is running in HYP Will Deacon <will.deacon@arm.com> - 2017-04-24 17:50 +0200
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Date | 2017-04-20 11:00 +0200 |
| Subject | Re: [PATCH v2] arm64: perf: Use only exclude_kernel attribute when kernel is running in HYP |
| Message-ID | <tyg6t-6Ky-13@gated-at.bofh.it> |
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.
Thanks,
Mark.
[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2017-April/499224.html
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2017-April/499493.html
>
> /*
> @@ -1008,6 +1026,8 @@ static int armv8_pmuv3_init(struct arm_pmu *cpu_pmu)
> &armv8_pmuv3_events_attr_group;
> cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] =
> &armv8_pmuv3_format_attr_group;
> + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_ATTR] =
> + &armv8_pmuv3_attr_group;
> return armv8pmu_probe_pmu(cpu_pmu);
> }
>
> diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h
> index 8462da2..a26ffc7 100644
> --- a/include/linux/perf/arm_pmu.h
> +++ b/include/linux/perf/arm_pmu.h
> @@ -81,6 +81,7 @@ enum armpmu_attr_groups {
> ARMPMU_ATTR_GROUP_COMMON,
> ARMPMU_ATTR_GROUP_EVENTS,
> ARMPMU_ATTR_GROUP_FORMATS,
> + ARMPMU_ATTR_GROUP_ATTR,
> ARMPMU_NR_ATTR_GROUPS
> };
>
> --
> 1.8.1.4
>
[toc] | [next] | [standalone]
| From | Ganapatrao Kulkarni <gpkulkarni@gmail.com> |
|---|---|
| Date | 2017-04-20 11:30 +0200 |
| Message-ID | <tygzv-7a4-3@gated-at.bofh.it> |
| In reply to | #1627218 |
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?.
>
> Thanks,
> Mark.
>
> [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2017-April/499224.html
> [2] http://lists.infradead.org/pipermail/linux-arm-kernel/2017-April/499493.html
>
>>
>> /*
>> @@ -1008,6 +1026,8 @@ static int armv8_pmuv3_init(struct arm_pmu *cpu_pmu)
>> &armv8_pmuv3_events_attr_group;
>> cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] =
>> &armv8_pmuv3_format_attr_group;
>> + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_ATTR] =
>> + &armv8_pmuv3_attr_group;
>> return armv8pmu_probe_pmu(cpu_pmu);
>> }
>>
>> diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h
>> index 8462da2..a26ffc7 100644
>> --- a/include/linux/perf/arm_pmu.h
>> +++ b/include/linux/perf/arm_pmu.h
>> @@ -81,6 +81,7 @@ enum armpmu_attr_groups {
>> ARMPMU_ATTR_GROUP_COMMON,
>> ARMPMU_ATTR_GROUP_EVENTS,
>> ARMPMU_ATTR_GROUP_FORMATS,
>> + ARMPMU_ATTR_GROUP_ATTR,
>> ARMPMU_NR_ATTR_GROUPS
>> };
>>
>> --
>> 1.8.1.4
>>
[toc] | [prev] | [next] | [standalone]
| From | Will Deacon <will.deacon@arm.com> |
|---|---|
| Date | 2017-04-24 17:50 +0200 |
| Message-ID | <tzOpt-mK-45@gated-at.bofh.it> |
| In reply to | #1627234 |
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. Will
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web