From: Eric Dumazet <eric.dumazet@gmail.com>
To: Michel Lespinasse <walken@google.com>
Cc: Rik van Riel <riel@redhat.com>,
linux-kernel@vger.kernel.org, aquini@redhat.com,
lwoodman@redhat.com, jeremy@goop.org,
Jan Beulich <JBeulich@novell.com>,
Thomas Gleixner <tglx@linutronix.de>,
knoel@redhat.com
Subject: Re: [RFC PATCH 4/5] x86,smp: keep spinlock delay values per hashed spinlock address
Date: Thu, 03 Jan 2013 05:05:43 -0800 [thread overview]
Message-ID: <1357218343.21409.24347.camel@edumazet-glaptop> (raw)
In-Reply-To: <CANN689FQK0c4VCPvT-Zg0vFLApOCMed7BwEEaR_ixFjO3gwBGQ@mail.gmail.com>
On Thu, 2013-01-03 at 04:48 -0800, Michel Lespinasse wrote:
> On Wed, Jan 2, 2013 at 9:24 PM, Rik van Riel <riel@redhat.com> wrote:
> > From: Eric Dumazet <eric.dumazet@gmail.com>
> >
> > Eric Dumazet found a regression with the spinlock backoff code,
> > in workloads where multiple spinlocks were contended, each having
> > a different wait time.
>
> I think you should really clarify that the regression was observed
> with version 1 of your proposal. At that time,
>
> 1- the autotune code tended to use too long delays for long held locks, and
>
> 2- there was no exponential backoff, which meant that sharing stats
> between a long held and a short held spinlock could really hurt
> throughput on the short held spinlock
>
>
> I believe that with autotune v2, this really shouldnt be a problem and
> stats sharing should result in just using a delay that's appropriate
> for the shorter of the two lock hold times - which is not the optimal
> value, but is actually close enough performance wise and, most
> importantly, should not cause any regression when compared to current
> mainline.
>
> (it's important to point that out because otherwise, you might trick
> Linus into thinking your patches are risky, which I think they
> shouldn't be after you implemented exponential backoff)
>
> > void ticket_spin_lock_wait(arch_spinlock_t *lock, struct __raw_tickets inc)
> > {
> > __ticket_t head = inc.head, ticket = inc.tail;
> > __ticket_t waiters_ahead;
> > - int delay = __this_cpu_read(spinlock_delay);
> > + u32 hash = hash32_ptr(lock);
> > + u32 slot = hash_32(hash, DELAY_HASH_SHIFT);
> > + struct delay_entry *ent = &__get_cpu_var(spinlock_delay[slot]);
> > + u32 delay = (ent->hash == hash) ? ent->delay : MIN_SPINLOCK_DELAY;
>
> IMO we want to avoid MIN_SPINLOCK_DELAY here. The exponential backoff
> autotune should make us resilient to collisions (if they happen we'll
> just end up with something very close to the min of the delays that
> would have been appropriate for either locks), so it should be better
> to just let collisions happen rather than force the use of
> MIN_SPINLOCK_DELAY.
>
exponential backoff wont help, I tried this idea last week and found
that its better to detect hash collision and safely use
MIN_SPINLOCK_DELAY in this case.
Its better to not overestimate the delay and spin much longer than
needed.
On a hash collision, we dont know at all the contention history of this
lock, unless we store the EWMA delay inside the lock.
(On x86 and NR_CPUS <= 256, we have a 16 bit hole in the spinlock that
we could use for this)
next prev parent reply other threads:[~2013-01-03 13:05 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-03 5:15 [RFC PATCH 0/5] x86,smp: make ticket spinlock proportional backoff w/ auto tuning Rik van Riel
2013-01-03 5:18 ` [RFC PATCH 1/5] x86,smp: move waiting on contended ticket lock out of line Rik van Riel
2013-01-03 10:47 ` Michel Lespinasse
2013-01-03 5:22 ` [RFC PATCH 2/5] x86,smp: proportional backoff for ticket spinlocks Rik van Riel
2013-01-03 11:35 ` Raghavendra KT
2013-01-03 11:42 ` Michel Lespinasse
2013-01-03 18:19 ` Raghavendra K T
2013-01-03 5:23 ` [RFC PATCH 3/5] x86,smp: auto tune spinlock backoff delay factor Rik van Riel
2013-01-03 12:31 ` Michel Lespinasse
2013-01-03 17:17 ` Rik van Riel
2013-01-05 0:45 ` Rik van Riel
2013-01-03 5:24 ` [RFC PATCH 4/5] x86,smp: keep spinlock delay values per hashed spinlock address Rik van Riel
2013-01-03 12:48 ` Michel Lespinasse
2013-01-03 13:05 ` Eric Dumazet [this message]
2013-01-03 5:25 ` [RFC PATCH 5/5] x86,smp: add debugging code to track spinlock delay value Rik van Riel
2013-01-03 10:46 ` [RFC PATCH 0/5] x86,smp: make ticket spinlock proportional backoff w/ auto tuning Michel Lespinasse
2013-01-03 11:29 ` Raghavendra KT
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=1357218343.21409.24347.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=JBeulich@novell.com \
--cc=aquini@redhat.com \
--cc=jeremy@goop.org \
--cc=knoel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lwoodman@redhat.com \
--cc=riel@redhat.com \
--cc=tglx@linutronix.de \
--cc=walken@google.com \
/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
all inboxes | Powered by JetHome®