All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rik van Riel <riel@redhat.com>
To: Waiman Long <Waiman.Long@hp.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	David Howells <dhowells@redhat.com>,
	Dave Jones <davej@redhat.com>,
	Clark Williams <williams@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org, x86@kernel.org,
	linux-arch@vger.kernel.org, "Chandramouleeswaran,
	Aswin" <aswin@hp.com>, Davidlohr Bueso <davidlohr.bueso@hp.com>,
	"Norton, Scott J" <scott.norton@hp.com>
Subject: Re: [PATCH v2 1/3] mutex: Make more scalable by doing less atomic operations
Date: Mon, 15 Apr 2013 10:45:32 -0400	[thread overview]
Message-ID: <516C128C.3040302@redhat.com> (raw)
In-Reply-To: <1366036679-9702-2-git-send-email-Waiman.Long@hp.com>

On 04/15/2013 10:37 AM, Waiman Long wrote:
> In the __mutex_lock_common() function, an initial entry into
> the lock slow path will cause two atomic_xchg instructions to be
> issued. Together with the atomic decrement in the fast path, a total
> of three atomic read-modify-write instructions will be issued in
> rapid succession. This can cause a lot of cache bouncing when many
> tasks are trying to acquire the mutex at the same time.
>
> This patch will reduce the number of atomic_xchg instructions used by
> checking the counter value first before issuing the instruction. The
> atomic_read() function is just a simple memory read. The atomic_xchg()
> function, on the other hand, can be up to 2 order of magnitude or even
> more in cost when compared with atomic_read(). By using atomic_read()
> to check the value first before calling atomic_xchg(), we can avoid a
> lot of unnecessary cache coherency traffic. The only downside with this
> change is that a task on the slow path will have a tiny bit
> less chance of getting the mutex when competing with another task
> in the fast path.
>

> Signed-off-by: Waiman Long <Waiman.Long@hp.com>
> Reviewed-by: Davidlohr Bueso <davidlohr.bueso@hp.com>

Reviewed-by: Rik van Riel <riel@redhat.com>


-- 
All rights reversed

  reply	other threads:[~2013-04-15 14:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-15 14:37 [PATCH 0/3 v2] mutex: Improve mutex performance by doing less atomic-ops & better spinning Waiman Long
2013-04-15 14:37 ` [PATCH v2 1/3] mutex: Make more scalable by doing less atomic operations Waiman Long
2013-04-15 14:45   ` Rik van Riel [this message]
2013-04-15 14:37 ` [PATCH v2 2/3] mutex: Queue mutex spinners with MCS lock to reduce cacheline contention Waiman Long
2013-04-15 16:27   ` Rik van Riel
2013-04-16  4:24   ` Davidlohr Bueso
2013-04-16 12:05     ` Waiman Long
2013-04-16  9:10   ` Ingo Molnar
2013-04-16 14:26     ` Waiman Long
2013-04-17  7:50       ` Ingo Molnar
2013-04-15 14:37 ` [PATCH v2 optional 3/3] mutex: back out architecture specific check for negative mutex count Waiman Long
2013-04-16 10:05   ` Will Deacon
2013-04-16 12:10     ` Waiman Long
2013-04-16  9:12 ` [PATCH 0/3 v2] mutex: Improve mutex performance by doing less atomic-ops & better spinning Ingo Molnar
2013-04-16 11:49   ` Waiman Long
2013-04-16 13:09     ` Ingo Molnar

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=516C128C.3040302@redhat.com \
    --to=riel@redhat.com \
    --cc=Waiman.Long@hp.com \
    --cc=aswin@hp.com \
    --cc=davej@redhat.com \
    --cc=davidlohr.bueso@hp.com \
    --cc=dhowells@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=scott.norton@hp.com \
    --cc=tglx@linutronix.de \
    --cc=williams@redhat.com \
    --cc=x86@kernel.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.