* [PATCH 1/2] perf: fix PERF_EVENT_IOC_PERIOD to force-reset the period
@ 2013-11-27 13:54 Will Deacon
2013-11-27 13:54 ` [PATCH 2/2] Revert "ARM: 7556/1: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD" Will Deacon
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Will Deacon @ 2013-11-27 13:54 UTC (permalink / raw)
To: linux-kernel; +Cc: Peter Zijlstra, Vince Weaver, Will Deacon
From: Peter Zijlstra <peterz@infradead.org>
Vince Weaver reports that, on all architectures apart from ARM,
PERF_EVENT_IOC_PERIOD doesn't actually update the period until the next
event fires. This is counter-intuitive behaviour and is better dealt
with in the core code.
This patch ensures that the period is forcefully reset when dealing with
such a request in the core code. A subsequent patch removes the
equivalent hack from the ARM back-end.
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
Peter -- I didn't want this to get lost, so I picked it up, fixed a typo
and wrote a commit message. Could I add your SoB please?
Cheers,
Will
kernel/events/core.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index d724e7757cd1..1c626b923ddf 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3527,7 +3527,7 @@ static void perf_event_for_each(struct perf_event *event,
static int perf_event_period(struct perf_event *event, u64 __user *arg)
{
struct perf_event_context *ctx = event->ctx;
- int ret = 0;
+ int ret = 0, active;
u64 value;
if (!is_sampling_event(event))
@@ -3551,6 +3551,20 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg)
event->attr.sample_period = value;
event->hw.sample_period = value;
}
+
+ active = (event->state == PERF_EVENT_STATE_ACTIVE);
+ if (active) {
+ perf_pmu_disable(ctx->pmu);
+ event->pmu->stop(event, PERF_EF_UPDATE);
+ }
+
+ local64_set(&event->hw.period_left, 0);
+
+ if (active) {
+ event->pmu->start(event, PERF_EF_RELOAD);
+ perf_pmu_enable(ctx->pmu);
+ }
+
unlock:
raw_spin_unlock_irq(&ctx->lock);
--
1.8.2.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] Revert "ARM: 7556/1: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD"
2013-11-27 13:54 [PATCH 1/2] perf: fix PERF_EVENT_IOC_PERIOD to force-reset the period Will Deacon
@ 2013-11-27 13:54 ` Will Deacon
2013-12-18 10:32 ` [tip:perf/core] " tip-bot for Will Deacon
2013-11-27 15:15 ` [PATCH 1/2] perf: fix PERF_EVENT_IOC_PERIOD to force-reset the period Vince Weaver
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Will Deacon @ 2013-11-27 13:54 UTC (permalink / raw)
To: linux-kernel; +Cc: Will Deacon, Peter Zijlstra
This reverts commit 3581fe0ef37ce12ac7a4f74831168352ae848edc.
Updates to the handling of PERF_EVENT_IOC_PERIOD in the core code mean
we no longer have to play this horrible game.
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
arch/arm/kernel/perf_event.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index bc3f2efa0d86..789d846a9184 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -99,10 +99,6 @@ int armpmu_event_set_period(struct perf_event *event)
s64 period = hwc->sample_period;
int ret = 0;
- /* The period may have been changed by PERF_EVENT_IOC_PERIOD */
- if (unlikely(period != hwc->last_period))
- left = period - (hwc->last_period - left);
-
if (unlikely(left <= -period)) {
left = period;
local64_set(&hwc->period_left, left);
--
1.8.2.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] perf: fix PERF_EVENT_IOC_PERIOD to force-reset the period
2013-11-27 13:54 [PATCH 1/2] perf: fix PERF_EVENT_IOC_PERIOD to force-reset the period Will Deacon
2013-11-27 13:54 ` [PATCH 2/2] Revert "ARM: 7556/1: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD" Will Deacon
@ 2013-11-27 15:15 ` Vince Weaver
2013-12-12 18:27 ` Will Deacon
2013-12-18 10:32 ` [tip:perf/core] perf: Fix " tip-bot for Peter Zijlstra
3 siblings, 0 replies; 7+ messages in thread
From: Vince Weaver @ 2013-11-27 15:15 UTC (permalink / raw)
To: Will Deacon; +Cc: linux-kernel, Peter Zijlstra
On Wed, 27 Nov 2013, Will Deacon wrote:
> Vince Weaver reports that, on all architectures apart from ARM,
> PERF_EVENT_IOC_PERIOD doesn't actually update the period until the next
> event fires. This is counter-intuitive behaviour and is better dealt
> with in the core code.
To be fair, it was Andreas Sandberg <andreas.sandberg@it.uu.se>
who noticed this issue and reported it to me (in the context of
the manpage being wrong). I just passed it on to the linux-kernel list.
Vince
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] perf: fix PERF_EVENT_IOC_PERIOD to force-reset the period
2013-11-27 13:54 [PATCH 1/2] perf: fix PERF_EVENT_IOC_PERIOD to force-reset the period Will Deacon
2013-11-27 13:54 ` [PATCH 2/2] Revert "ARM: 7556/1: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD" Will Deacon
2013-11-27 15:15 ` [PATCH 1/2] perf: fix PERF_EVENT_IOC_PERIOD to force-reset the period Vince Weaver
@ 2013-12-12 18:27 ` Will Deacon
2013-12-13 15:13 ` Peter Zijlstra
2013-12-18 10:32 ` [tip:perf/core] perf: Fix " tip-bot for Peter Zijlstra
3 siblings, 1 reply; 7+ messages in thread
From: Will Deacon @ 2013-12-12 18:27 UTC (permalink / raw)
To: linux-kernel; +Cc: Peter Zijlstra, Vince Weaver
Hi Peter,
Do you have any thoughts on the below? It would be good to add your
signed-off to the patch, since you wrote it originally.
Cheers,
Will
On Wed, Nov 27, 2013 at 01:54:38PM +0000, Will Deacon wrote:
> From: Peter Zijlstra <peterz@infradead.org>
>
> Vince Weaver reports that, on all architectures apart from ARM,
> PERF_EVENT_IOC_PERIOD doesn't actually update the period until the next
> event fires. This is counter-intuitive behaviour and is better dealt
> with in the core code.
>
> This patch ensures that the period is forcefully reset when dealing with
> such a request in the core code. A subsequent patch removes the
> equivalent hack from the ARM back-end.
>
> Cc: Vince Weaver <vincent.weaver@maine.edu>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
>
> Peter -- I didn't want this to get lost, so I picked it up, fixed a typo
> and wrote a commit message. Could I add your SoB please?
>
> Cheers,
> Will
>
> kernel/events/core.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index d724e7757cd1..1c626b923ddf 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -3527,7 +3527,7 @@ static void perf_event_for_each(struct perf_event *event,
> static int perf_event_period(struct perf_event *event, u64 __user *arg)
> {
> struct perf_event_context *ctx = event->ctx;
> - int ret = 0;
> + int ret = 0, active;
> u64 value;
>
> if (!is_sampling_event(event))
> @@ -3551,6 +3551,20 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg)
> event->attr.sample_period = value;
> event->hw.sample_period = value;
> }
> +
> + active = (event->state == PERF_EVENT_STATE_ACTIVE);
> + if (active) {
> + perf_pmu_disable(ctx->pmu);
> + event->pmu->stop(event, PERF_EF_UPDATE);
> + }
> +
> + local64_set(&event->hw.period_left, 0);
> +
> + if (active) {
> + event->pmu->start(event, PERF_EF_RELOAD);
> + perf_pmu_enable(ctx->pmu);
> + }
> +
> unlock:
> raw_spin_unlock_irq(&ctx->lock);
>
> --
> 1.8.2.2
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] perf: fix PERF_EVENT_IOC_PERIOD to force-reset the period
2013-12-12 18:27 ` Will Deacon
@ 2013-12-13 15:13 ` Peter Zijlstra
0 siblings, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2013-12-13 15:13 UTC (permalink / raw)
To: Will Deacon; +Cc: linux-kernel, Vince Weaver
On Thu, Dec 12, 2013 at 06:27:47PM +0000, Will Deacon wrote:
> Hi Peter,
>
> Do you have any thoughts on the below? It would be good to add your
> signed-off to the patch, since you wrote it originally.
>
Picked them up, thanks will!
^ permalink raw reply [flat|nested] 7+ messages in thread
* [tip:perf/core] perf: Fix PERF_EVENT_IOC_PERIOD to force-reset the period
2013-11-27 13:54 [PATCH 1/2] perf: fix PERF_EVENT_IOC_PERIOD to force-reset the period Will Deacon
` (2 preceding siblings ...)
2013-12-12 18:27 ` Will Deacon
@ 2013-12-18 10:32 ` tip-bot for Peter Zijlstra
3 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Peter Zijlstra @ 2013-12-18 10:32 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, vincent.weaver, will.deacon, peterz, tglx
Commit-ID: bad7192b842c83e580747ca57104dd51fe08c223
Gitweb: http://git.kernel.org/tip/bad7192b842c83e580747ca57104dd51fe08c223
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Wed, 27 Nov 2013 13:54:38 +0000
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 17 Dec 2013 15:21:33 +0100
perf: Fix PERF_EVENT_IOC_PERIOD to force-reset the period
Vince Weaver reports that, on all architectures apart from ARM,
PERF_EVENT_IOC_PERIOD doesn't actually update the period until the next
event fires. This is counter-intuitive behaviour and is better dealt
with in the core code.
This patch ensures that the period is forcefully reset when dealing with
such a request in the core code. A subsequent patch removes the
equivalent hack from the ARM back-end.
Reported-by: Vince Weaver <vincent.weaver@maine.edu>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Link: http://lkml.kernel.org/r/1385560479-11014-1-git-send-email-will.deacon@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/events/core.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 403b781..89d34f9 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3527,7 +3527,7 @@ static void perf_event_for_each(struct perf_event *event,
static int perf_event_period(struct perf_event *event, u64 __user *arg)
{
struct perf_event_context *ctx = event->ctx;
- int ret = 0;
+ int ret = 0, active;
u64 value;
if (!is_sampling_event(event))
@@ -3551,6 +3551,20 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg)
event->attr.sample_period = value;
event->hw.sample_period = value;
}
+
+ active = (event->state == PERF_EVENT_STATE_ACTIVE);
+ if (active) {
+ perf_pmu_disable(ctx->pmu);
+ event->pmu->stop(event, PERF_EF_UPDATE);
+ }
+
+ local64_set(&event->hw.period_left, 0);
+
+ if (active) {
+ event->pmu->start(event, PERF_EF_RELOAD);
+ perf_pmu_enable(ctx->pmu);
+ }
+
unlock:
raw_spin_unlock_irq(&ctx->lock);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [tip:perf/core] Revert "ARM: 7556/1: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD"
2013-11-27 13:54 ` [PATCH 2/2] Revert "ARM: 7556/1: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD" Will Deacon
@ 2013-12-18 10:32 ` tip-bot for Will Deacon
0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Will Deacon @ 2013-12-18 10:32 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, will.deacon, peterz, tglx
Commit-ID: 9450d14fb959336803e5209119eb422b667b96aa
Gitweb: http://git.kernel.org/tip/9450d14fb959336803e5209119eb422b667b96aa
Author: Will Deacon <will.deacon@arm.com>
AuthorDate: Wed, 27 Nov 2013 13:54:39 +0000
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 17 Dec 2013 15:21:35 +0100
Revert "ARM: 7556/1: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD"
This reverts commit 3581fe0ef37ce12ac7a4f74831168352ae848edc.
Fixes to the handling of PERF_EVENT_IOC_PERIOD in the core code mean
we no longer have to play this horrible game.
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1385560479-11014-2-git-send-email-will.deacon@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/arm/kernel/perf_event.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index bc3f2ef..789d846 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -99,10 +99,6 @@ int armpmu_event_set_period(struct perf_event *event)
s64 period = hwc->sample_period;
int ret = 0;
- /* The period may have been changed by PERF_EVENT_IOC_PERIOD */
- if (unlikely(period != hwc->last_period))
- left = period - (hwc->last_period - left);
-
if (unlikely(left <= -period)) {
left = period;
local64_set(&hwc->period_left, left);
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-12-18 10:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-27 13:54 [PATCH 1/2] perf: fix PERF_EVENT_IOC_PERIOD to force-reset the period Will Deacon
2013-11-27 13:54 ` [PATCH 2/2] Revert "ARM: 7556/1: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD" Will Deacon
2013-12-18 10:32 ` [tip:perf/core] " tip-bot for Will Deacon
2013-11-27 15:15 ` [PATCH 1/2] perf: fix PERF_EVENT_IOC_PERIOD to force-reset the period Vince Weaver
2013-12-12 18:27 ` Will Deacon
2013-12-13 15:13 ` Peter Zijlstra
2013-12-18 10:32 ` [tip:perf/core] perf: Fix " tip-bot for Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome