From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 2/2] arm64: use WFE for long delays
Date: Thu, 12 Oct 2017 09:52:13 +0100 [thread overview]
Message-ID: <20171012085213.GC6171@arm.com> (raw)
In-Reply-To: <e4206f9a-4ba6-550c-fa2a-92d89b5fbc8b@arm.com>
On Thu, Oct 12, 2017 at 09:47:26AM +0100, Julien Thierry wrote:
> Hi Will,
>
> On 11/10/17 16:13, Will Deacon wrote:
> >Hi Julien,
> >
> >On Fri, Sep 29, 2017 at 11:52:30AM +0100, Julien Thierry wrote:
> >>The current delay implementation uses the yield instruction, which is a
> >>hint that it is beneficial to schedule another thread. As this is a hint,
> >>it may be implemented as a NOP, causing all delays to be busy loops. This
> >>is the case for many existing CPUs.
> >>
> >>Taking advantage of the generic timer sending periodic events to all
> >>cores, we can use WFE during delays to reduce power consumption. This is
> >>beneficial only for delays longer than the period of the timer event
> >>stream.
> >>
> >>If timer event stream is not enabled, delays will behave as yield/busy
> >>loops.
> >>
> >>Signed-off-by: Julien Thierry <julien.thierry@arm.com>
> >>Cc: Catalin Marinas <catalin.marinas@arm.com>
> >>Cc: Will Deacon <will.deacon@arm.com>
> >>Cc: Mark Rutland <mark.rutland@arm.com>
> >>---
> >> arch/arm64/lib/delay.c | 23 +++++++++++++++++++----
> >> include/clocksource/arm_arch_timer.h | 4 +++-
> >> 2 files changed, 22 insertions(+), 5 deletions(-)
> >>
> >>diff --git a/arch/arm64/lib/delay.c b/arch/arm64/lib/delay.c
> >>index dad4ec9..4dc27f3 100644
> >>--- a/arch/arm64/lib/delay.c
> >>+++ b/arch/arm64/lib/delay.c
> >>@@ -24,10 +24,28 @@
> >> #include <linux/module.h>
> >> #include <linux/timex.h>
> >>
> >>+#include <clocksource/arm_arch_timer.h>
> >>+
> >>+#define USECS_TO_CYCLES(TIME_USECS) \
> >>+ xloops_to_cycles((TIME_USECS) * 0x10C7UL)
> >
> >The macro parameter can be lower-case here.
> >
>
> Noted, I'll change it.
>
> >>+static inline unsigned long xloops_to_cycles(unsigned long xloops)
> >>+{
> >>+ return (xloops * loops_per_jiffy * HZ) >> 32;
> >>+}
> >>+
> >> void __delay(unsigned long cycles)
> >> {
> >> cycles_t start = get_cycles();
> >>
> >>+ if (arch_timer_evtstrm_available()) {
> >
> >Hmm, is this never called in a context where preemption is enabled?
> >Maybe arch_timer_evtstrm_available should be using raw_smp_processor_id()
> >under the hood.
> >
>
> This can be called from a preemptible context. But when it is, the event
> stream is either enabled both on the preemptible context and on the context
> where a preempted context can be resumed, or the event stream is just
> disabled in the whole system.
>
> Does using raw_smp_processor_id solve an issue here?
I thought that DEBUG_PREEMPT would splat if you called smp_processor_id()
from preemptible context?
Will
next prev parent reply other threads:[~2017-10-12 8:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-29 10:52 [PATCH v3 0/2] WFE for long delays Julien Thierry
2017-09-29 10:52 ` [PATCH v3 1/2] arm_arch_timer: Expose event stream status Julien Thierry
2017-10-11 15:14 ` Will Deacon
2017-10-12 8:38 ` Julien Thierry
2017-10-12 8:58 ` Julien Thierry
2017-10-12 9:27 ` Suzuki K Poulose
2017-10-12 9:30 ` Will Deacon
2017-10-12 9:40 ` Julien Thierry
2017-10-12 10:26 ` Will Deacon
2017-10-12 12:28 ` Julien Thierry
2017-09-29 10:52 ` [PATCH v3 2/2] arm64: use WFE for long delays Julien Thierry
2017-10-11 15:13 ` Will Deacon
2017-10-12 8:47 ` Julien Thierry
2017-10-12 8:52 ` Will Deacon [this message]
2017-10-12 8:54 ` Julien Thierry
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=20171012085213.GC6171@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).