From: Waiman Long <waiman.long@hpe.com>
To: Ling Ma <ling.ma.program@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
mingo@redhat.com, linux-kernel@vger.kernel.org,
Ling <ling.ml@alibaba-inc.com>
Subject: Re: Improve spinlock performance by moving work to one core
Date: Wed, 25 Nov 2015 14:05:53 -0500 [thread overview]
Message-ID: <56560691.8000702@hpe.com> (raw)
In-Reply-To: <CAOGi=dOLCQ4BtzpsSEO-XVepFbypvj7qJ4_d2=bcp4KYRKJ5RQ@mail.gmail.com>
On 11/23/2015 04:41 AM, Ling Ma wrote:
> Hi Longman,
>
> Attachments include user space application thread.c and kernel patch
> spinlock-test.patch based on kernel 4.3.0-rc4
>
> we run thread.c with kernel patch, test original and new spinlock respectively,
> perf top -G indicates thread.c cause cache_alloc_refill and
> cache_flusharray functions to spend ~25% time on original spinlock,
> after introducing new spinlock in two functions, the cost time become ~22%.
>
> The printed data also tell us the new spinlock improves performance
> by about 15%( 93841765576 / 81036259588) on E5-2699V3
>
> Appreciate your comments.
>
>
I saw that you make the following changes in the code:
static __always_inline void queued_spin_lock(struct qspinlock *lock)
{
u32 val;
-
+repeat:
val = atomic_cmpxchg(&lock->val, 0, _Q_LOCKED_VAL);
if (likely(val == 0))
return;
- queued_spin_lock_slowpath(lock, val);
+ goto repeat;
+ //queued_spin_lock_slowpath(lock, val);
}
This effectively changes the queued spinlock into an unfair byte lock.
Without a pause to moderate the cmpxchg() call, that is especially bad
for performance. Is the performance data above refers to the unfair byte
lock versus your new spinlock?
Cheers,
Longman
next prev parent reply other threads:[~2015-11-25 19:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAOGi=dN6=iHUKyN=BcJ4dZkEyv5bA9amU1uCqD-hqaUJnY=Zug@mail.gmail.com>
2015-11-04 12:44 ` Improve spinlock performance by moving work to one core Ling Ma
[not found] ` <563B8E85.6090104@hpe.com>
2015-11-06 4:28 ` Ling Ma
2015-11-06 17:38 ` Waiman Long
2015-11-23 9:41 ` Ling Ma
2015-11-25 1:56 ` Ling Ma
2015-11-25 19:05 ` Waiman Long [this message]
2015-11-26 3:49 ` Ling Ma
2015-11-26 9:00 ` Ling Ma
2015-11-30 6:17 ` Ling Ma
2015-11-30 20:55 ` Waiman Long
2015-12-06 13:08 ` Ling Ma
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=56560691.8000702@hpe.com \
--to=waiman.long@hpe.com \
--cc=ling.ma.program@gmail.com \
--cc=ling.ml@alibaba-inc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@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