lkml.org 
[lkml]   [2012]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[RFC PATCH 2/3] x86,smp: proportional backoff for ticket spinlocks
    Subject: x86,smp: proportional backoff for ticket spinlocks

    Simple fixed value proportional backoff for ticket spinlocks.
    By pounding on the cacheline with the spin lock less often,
    bus traffic is reduced. In cases of a data structure with
    embedded spinlock, the lock holder has a better chance of
    making progress.

    Signed-off-by: Rik van Riel <riel@redhat.com>
    ---
    arch/x86/kernel/smp.c | 6 ++++--
    1 files changed, 4 insertions(+), 2 deletions(-)

    diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
    index 20da354..4e44840 100644
    --- a/arch/x86/kernel/smp.c
    +++ b/arch/x86/kernel/smp.c
    @@ -118,9 +118,11 @@ static bool smp_no_nmi_ipi = false;
    void ticket_spin_lock_wait(arch_spinlock_t *lock, struct __raw_tickets inc)
    {
    for (;;) {
    - cpu_relax();
    - inc.head = ACCESS_ONCE(lock->tickets.head);
    + int loops = 50 * (__ticket_t)(inc.tail - inc.head);
    + while (loops--)
    + cpu_relax();

    + inc.head = ACCESS_ONCE(lock->tickets.head);
    if (inc.head == inc.tail)
    break;
    }


    \
     
     \ /
      Last update: 2012-12-22 01:41    [W:4.077 / U:0.380 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site