From: David Vrabel <david.vrabel@citrix.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Julien Grall <julien.grall@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Tim Deegan <tim@xen.org>, David Vrabel <david.vrabel@citrix.com>,
Jan Beulich <jbeulich@suse.com>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCHv1] arm: reduce power use by contented spin locks with WFE/SEV
Date: Fri, 31 Jul 2015 13:43:09 +0100 [thread overview]
Message-ID: <55BB6D5D.1010207@citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1507311216300.11337@kaball.uk.xensource.com>
On 31/07/15 12:41, Stefano Stabellini wrote:
> On Fri, 31 Jul 2015, Julien Grall wrote:
>> Hi David,
>>
>> On 31/07/15 11:52, David Vrabel wrote:
>>> On 31/07/15 11:45, David Vrabel wrote:
>>>> Instead of cpu_relax() while spinning and observing the ticket head,
>>>> introduce spin_relax() which executes a WFE instruction. After the
>>>> ticket head is changed call spin_signal() to execute an SVE
>>>> instruction to wake any spinners.
>>>>
>>>> This should improve power consumption when locks are contented and
>>>> spinning.
>>>>
>>>> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
>>>> ---
>>>> I've not tested this but it looks straight-forward...
>>>> ---
>>>> xen/common/spinlock.c | 5 +++--
>>>> xen/include/asm-arm/spinlock.h | 3 ++-
>>>> xen/include/asm-x86/spinlock.h | 3 +++
>>>> 3 files changed, 8 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c
>>>> index 29149d1..fc3e8e7 100644
>>>> --- a/xen/common/spinlock.c
>>>> +++ b/xen/common/spinlock.c
>>>> @@ -141,7 +141,7 @@ void _spin_lock(spinlock_t *lock)
>>>> while ( tickets.tail != observe_head(&lock->tickets) )
>>>> {
>>>> LOCK_PROFILE_BLOCK;
>>>> - cpu_relax();
>>>> + spin_relax();
>>>> }
>>>> LOCK_PROFILE_GOT;
>>>> preempt_disable();
>>>> @@ -170,6 +170,7 @@ void _spin_unlock(spinlock_t *lock)
>>>> preempt_enable();
>>>> LOCK_PROFILE_REL;
>>>> add_sized(&lock->tickets.head, 1);
>>>> + spin_signal();
>>>
>>> It occurs to me that perhaps there should be a barrier between the
>>> add_sized() and the spin_signal() so the update value is visible before
>>> we signal (otherwise the spinner may be woken and observe the old value
>>> and WFE again).
>>
>> sev is usually precede by dsb to ensure that all the instructions before
>> as completed before executing the sev.
>
> Yes, a dsb() is required. This being common code, we could use wmb().
You should put the barrier required for the SEV in spin_signal() so an
additional barrier is not required on other archs.
David
prev parent reply other threads:[~2015-07-31 12:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-31 10:45 [PATCHv1] arm: reduce power use by contented spin locks with WFE/SEV David Vrabel
2015-07-31 10:47 ` Andrew Cooper
2015-07-31 10:52 ` David Vrabel
2015-07-31 11:01 ` Julien Grall
2015-07-31 11:41 ` Stefano Stabellini
2015-07-31 12:39 ` Ian Campbell
2015-07-31 12:43 ` David Vrabel [this message]
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=55BB6D5D.1010207@citrix.com \
--to=david.vrabel@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.