* [PATCH] x86/apic: Implement set_state_oneshot_stopped() callback
@ 2016-12-29 16:45 Frederic Weisbecker
2016-12-30 1:28 ` Wanpeng Li
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Frederic Weisbecker @ 2016-12-29 16:45 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, Frederic Weisbecker, Borislav Petkov, Wanpeng Li,
Ingo Molnar, Viresh Kumar
When clock_event_device::set_state_oneshot_stopped() is not implemented,
hrtimer_cancel() can't stop the clock when there is no more timer in
the queue. So the ghost of the freshly cancelled hrtimer haunts us back
later with an extra interrupt:
<idle>-0 [002] d..2 2248.557659: hrtimer_cancel: hrtimer=ffff88021fa92d80
<idle>-0 [002] d.h1 2249.303659: local_timer_entry: vector=239
So let's implement this missing callback for the lapic clock. This
consist in calling its set_state_shutdown() callback. There don't seem
to be a lighter way to stop the clock. Simply writing 0 to APIC_TMICT
won't be enough to stop the clock and avoid the extra interrupt, as
opposed to what is specified in the specs. We must also mask the
timer interrupt in the device.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Wanpeng Li <wanpeng.li@hotmail.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
arch/x86/kernel/apic/apic.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 5b7e43e..a8e90db 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -529,18 +529,19 @@ static void lapic_timer_broadcast(const struct cpumask *mask)
* The local apic timer can be used for any function which is CPU local.
*/
static struct clock_event_device lapic_clockevent = {
- .name = "lapic",
- .features = CLOCK_EVT_FEAT_PERIODIC |
- CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP
- | CLOCK_EVT_FEAT_DUMMY,
- .shift = 32,
- .set_state_shutdown = lapic_timer_shutdown,
- .set_state_periodic = lapic_timer_set_periodic,
- .set_state_oneshot = lapic_timer_set_oneshot,
- .set_next_event = lapic_next_event,
- .broadcast = lapic_timer_broadcast,
- .rating = 100,
- .irq = -1,
+ .name = "lapic",
+ .features = CLOCK_EVT_FEAT_PERIODIC |
+ CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP
+ | CLOCK_EVT_FEAT_DUMMY,
+ .shift = 32,
+ .set_state_shutdown = lapic_timer_shutdown,
+ .set_state_periodic = lapic_timer_set_periodic,
+ .set_state_oneshot = lapic_timer_set_oneshot,
+ .set_state_oneshot_stopped = lapic_timer_shutdown,
+ .set_next_event = lapic_next_event,
+ .broadcast = lapic_timer_broadcast,
+ .rating = 100,
+ .irq = -1,
};
static DEFINE_PER_CPU(struct clock_event_device, lapic_events);
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] x86/apic: Implement set_state_oneshot_stopped() callback
2016-12-29 16:45 [PATCH] x86/apic: Implement set_state_oneshot_stopped() callback Frederic Weisbecker
@ 2016-12-30 1:28 ` Wanpeng Li
2017-01-02 7:31 ` Viresh Kumar
2017-01-09 10:55 ` [tip:x86/apic] " tip-bot for Frederic Weisbecker
2 siblings, 0 replies; 4+ messages in thread
From: Wanpeng Li @ 2016-12-30 1:28 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: Thomas Gleixner, LKML, Borislav Petkov, Wanpeng Li, Ingo Molnar,
Viresh Kumar
2016-12-30 0:45 GMT+08:00 Frederic Weisbecker <fweisbec@gmail.com>:
> When clock_event_device::set_state_oneshot_stopped() is not implemented,
> hrtimer_cancel() can't stop the clock when there is no more timer in
> the queue. So the ghost of the freshly cancelled hrtimer haunts us back
> later with an extra interrupt:
>
> <idle>-0 [002] d..2 2248.557659: hrtimer_cancel: hrtimer=ffff88021fa92d80
> <idle>-0 [002] d.h1 2249.303659: local_timer_entry: vector=239
>
> So let's implement this missing callback for the lapic clock. This
> consist in calling its set_state_shutdown() callback. There don't seem
> to be a lighter way to stop the clock. Simply writing 0 to APIC_TMICT
> won't be enough to stop the clock and avoid the extra interrupt, as
> opposed to what is specified in the specs. We must also mask the
> timer interrupt in the device.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Wanpeng Li <wanpeng.li@hotmail.com>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> ---
Reviewed-by: Wanpeng Li <wanpeng.li@hotmail.com>
> arch/x86/kernel/apic/apic.c | 25 +++++++++++++------------
> 1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
> index 5b7e43e..a8e90db 100644
> --- a/arch/x86/kernel/apic/apic.c
> +++ b/arch/x86/kernel/apic/apic.c
> @@ -529,18 +529,19 @@ static void lapic_timer_broadcast(const struct cpumask *mask)
> * The local apic timer can be used for any function which is CPU local.
> */
> static struct clock_event_device lapic_clockevent = {
> - .name = "lapic",
> - .features = CLOCK_EVT_FEAT_PERIODIC |
> - CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP
> - | CLOCK_EVT_FEAT_DUMMY,
> - .shift = 32,
> - .set_state_shutdown = lapic_timer_shutdown,
> - .set_state_periodic = lapic_timer_set_periodic,
> - .set_state_oneshot = lapic_timer_set_oneshot,
> - .set_next_event = lapic_next_event,
> - .broadcast = lapic_timer_broadcast,
> - .rating = 100,
> - .irq = -1,
> + .name = "lapic",
> + .features = CLOCK_EVT_FEAT_PERIODIC |
> + CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP
> + | CLOCK_EVT_FEAT_DUMMY,
> + .shift = 32,
> + .set_state_shutdown = lapic_timer_shutdown,
> + .set_state_periodic = lapic_timer_set_periodic,
> + .set_state_oneshot = lapic_timer_set_oneshot,
> + .set_state_oneshot_stopped = lapic_timer_shutdown,
> + .set_next_event = lapic_next_event,
> + .broadcast = lapic_timer_broadcast,
> + .rating = 100,
> + .irq = -1,
> };
> static DEFINE_PER_CPU(struct clock_event_device, lapic_events);
>
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] x86/apic: Implement set_state_oneshot_stopped() callback
2016-12-29 16:45 [PATCH] x86/apic: Implement set_state_oneshot_stopped() callback Frederic Weisbecker
2016-12-30 1:28 ` Wanpeng Li
@ 2017-01-02 7:31 ` Viresh Kumar
2017-01-09 10:55 ` [tip:x86/apic] " tip-bot for Frederic Weisbecker
2 siblings, 0 replies; 4+ messages in thread
From: Viresh Kumar @ 2017-01-02 7:31 UTC (permalink / raw)
To: Frederic Weisbecker
Cc: Thomas Gleixner, LKML, Borislav Petkov, Wanpeng Li, Ingo Molnar
On 29-12-16, 17:45, Frederic Weisbecker wrote:
> When clock_event_device::set_state_oneshot_stopped() is not implemented,
> hrtimer_cancel() can't stop the clock when there is no more timer in
> the queue. So the ghost of the freshly cancelled hrtimer haunts us back
> later with an extra interrupt:
>
> <idle>-0 [002] d..2 2248.557659: hrtimer_cancel: hrtimer=ffff88021fa92d80
> <idle>-0 [002] d.h1 2249.303659: local_timer_entry: vector=239
>
> So let's implement this missing callback for the lapic clock. This
> consist in calling its set_state_shutdown() callback. There don't seem
> to be a lighter way to stop the clock. Simply writing 0 to APIC_TMICT
> won't be enough to stop the clock and avoid the extra interrupt, as
> opposed to what is specified in the specs. We must also mask the
> timer interrupt in the device.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Wanpeng Li <wanpeng.li@hotmail.com>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> ---
> arch/x86/kernel/apic/apic.c | 25 +++++++++++++------------
> 1 file changed, 13 insertions(+), 12 deletions(-)
I didn't try updating anything other than the ARM subsystem as I was afraid of
getting crushed by Thomas :)
Though, I do remember from one of the email (from Thomas), where he mentioned
that disabling the timer on some platforms may have bigger penalties. Perhaps
its fast enough for apic..
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip:x86/apic] x86/apic: Implement set_state_oneshot_stopped() callback
2016-12-29 16:45 [PATCH] x86/apic: Implement set_state_oneshot_stopped() callback Frederic Weisbecker
2016-12-30 1:28 ` Wanpeng Li
2017-01-02 7:31 ` Viresh Kumar
@ 2017-01-09 10:55 ` tip-bot for Frederic Weisbecker
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Frederic Weisbecker @ 2017-01-09 10:55 UTC (permalink / raw)
To: linux-tip-commits
Cc: mingo, fweisbec, linux-kernel, bp, wanpeng.li, viresh.kumar, hpa, tglx
Commit-ID: 914122c389d091a02f7b5476209af715e77ccb73
Gitweb: http://git.kernel.org/tip/914122c389d091a02f7b5476209af715e77ccb73
Author: Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Thu, 29 Dec 2016 17:45:49 +0100
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 9 Jan 2017 11:48:42 +0100
x86/apic: Implement set_state_oneshot_stopped() callback
When clock_event_device::set_state_oneshot_stopped() is not implemented,
hrtimer_cancel() can't stop the clock when there is no more timer in
the queue. So the ghost of the freshly cancelled hrtimer haunts us back
later with an extra interrupt:
<idle>-0 [002] d..2 2248.557659: hrtimer_cancel: hrtimer=ffff88021fa92d80
<idle>-0 [002] d.h1 2249.303659: local_timer_entry: vector=239
So let's implement this missing callback for the lapic clock. This
consist in calling its set_state_shutdown() callback. There don't seem
to be a lighter way to stop the clock. Simply writing 0 to APIC_TMICT
won't be enough to stop the clock and avoid the extra interrupt, as
opposed to what is specified in the specs. We must also mask the
timer interrupt in the device.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>
Reviewed-by: Wanpeng Li <wanpeng.li@hotmail.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: http://lkml.kernel.org/r/1483029949-6925-1-git-send-email-fweisbec@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/kernel/apic/apic.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 5c4fdcf..fdb9c46 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -529,18 +529,19 @@ static void lapic_timer_broadcast(const struct cpumask *mask)
* The local apic timer can be used for any function which is CPU local.
*/
static struct clock_event_device lapic_clockevent = {
- .name = "lapic",
- .features = CLOCK_EVT_FEAT_PERIODIC |
- CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP
- | CLOCK_EVT_FEAT_DUMMY,
- .shift = 32,
- .set_state_shutdown = lapic_timer_shutdown,
- .set_state_periodic = lapic_timer_set_periodic,
- .set_state_oneshot = lapic_timer_set_oneshot,
- .set_next_event = lapic_next_event,
- .broadcast = lapic_timer_broadcast,
- .rating = 100,
- .irq = -1,
+ .name = "lapic",
+ .features = CLOCK_EVT_FEAT_PERIODIC |
+ CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP
+ | CLOCK_EVT_FEAT_DUMMY,
+ .shift = 32,
+ .set_state_shutdown = lapic_timer_shutdown,
+ .set_state_periodic = lapic_timer_set_periodic,
+ .set_state_oneshot = lapic_timer_set_oneshot,
+ .set_state_oneshot_stopped = lapic_timer_shutdown,
+ .set_next_event = lapic_next_event,
+ .broadcast = lapic_timer_broadcast,
+ .rating = 100,
+ .irq = -1,
};
static DEFINE_PER_CPU(struct clock_event_device, lapic_events);
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-09 10:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-29 16:45 [PATCH] x86/apic: Implement set_state_oneshot_stopped() callback Frederic Weisbecker
2016-12-30 1:28 ` Wanpeng Li
2017-01-02 7:31 ` Viresh Kumar
2017-01-09 10:55 ` [tip:x86/apic] " tip-bot for Frederic Weisbecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®