From: Will Deacon <will.deacon@arm.com>
To: Alexander Duyck <alexander.h.duyck@redhat.com>
Cc: "linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"mikey@neuling.org" <mikey@neuling.org>,
"tony.luck@intel.com" <tony.luck@intel.com>,
"mathieu.desnoyers@polymtl.ca" <mathieu.desnoyers@polymtl.ca>,
"donald.c.skidmore@intel.com" <donald.c.skidmore@intel.com>,
"peterz@infradead.org" <peterz@infradead.org>,
"benh@kernel.crashing.org" <benh@kernel.crashing.org>,
"heiko.carstens@de.ibm.com" <heiko.carstens@de.ibm.com>,
"oleg@redhat.com" <oleg@redhat.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"michael@ellerman.id.au" <michael@ellerman.id.au>,
"matthew.vick@intel.com" <matthew.vick@intel.com>,
"nic_swsd@realtek.com" <nic_swsd@realtek.com>,
"geert@linux-m68k.org" <geert@linux-m68k.org>,
"jeffrey.t.kirsher@intel.com" <jeffrey.t.kirsher@intel.com>,
Subject: Re: [PATCH 1/3] arch: Introduce load_acquire() and store_release()
Date: Fri, 14 Nov 2014 10:19:02 +0000 [thread overview]
Message-ID: <20141114101902.GA27963@arm.com> (raw)
In-Reply-To: <20141113192723.12579.25343.stgit@ahduyck-server>
Hi Alex,
On Thu, Nov 13, 2014 at 07:27:23PM +0000, Alexander Duyck wrote:
> It is common for device drivers to make use of acquire/release semantics
> when dealing with descriptors stored in device memory. On reviewing the
> documentation and code for smp_load_acquire() and smp_store_release() as
> well as reviewing an IBM website that goes over the use of PowerPC barriers
> at http://www.ibm.com/developerworks/systems/articles/powerpc.html it
> occurred to me that the same code could likely be applied to device drivers.
>
> As a result this patch introduces load_acquire() and store_release(). The
> load_acquire() function can be used in the place of situations where a test
> for ownership must be followed by a memory barrier. The below example is
> from ixgbe:
>
> if (!rx_desc->wb.upper.status_error)
> break;
>
> /* This memory barrier is needed to keep us from reading
> * any other fields out of the rx_desc until we know the
> * descriptor has been written back
> */
> rmb();
>
> With load_acquire() this can be changed to:
>
> if (!load_acquire(&rx_desc->wb.upper.status_error))
> break;
I still don't think this is a good idea for the specific use-case you're
highlighting.
On ARM, an mb() can be *significantly* more expensive than an rmb() (since
we may have to drain store buffers on an outer L2 cache) and on arm64 it's
not at all clear that an LDAR is more efficient than an LDR; DMB LD
sequence. I can certainly imagine implementations where the latter would
be preferred.
So, whilst I'm perfectly fine to go along with mandatory acquire/release
macros (we should probably add a check to barf on __iomem pointers), I
don't agree with using them in preference to finer-grained read/write
barriers. Doing so will have a real impact on I/O performance.
Finally, do you know of any architectures where load_acquire/store_release
aren't implemented the same way as the smp_* variants on SMP kernels?
Will
next prev parent reply other threads:[~2014-11-14 10:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-13 19:27 [PATCH 0/3] Introduce load_acquire() and store_release() Alexander Duyck
2014-11-13 19:27 ` [PATCH 1/3] arch: " Alexander Duyck
2014-11-14 10:19 ` Will Deacon [this message]
2014-11-14 16:00 ` Alexander Duyck
2014-11-14 10:45 ` David Laight
2014-11-14 16:58 ` Alexander Duyck
2014-11-13 19:27 ` [PATCH 2/3] r8169: Use load_acquire() and store_release() to reduce memory barrier overhead Alexander Duyck
2014-11-13 21:30 ` Francois Romieu
2014-11-13 23:11 ` Alexander Duyck
2014-11-15 21:13 ` Francois Romieu
2014-11-13 19:27 ` [PATCH 3/3] fm10k/igb/ixgbe: Use load_acquire on Rx descriptor Alexander Duyck
2014-11-14 17:25 ` Jeff Kirsher
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=20141114101902.GA27963@arm.com \
--to=will.deacon@arm.com \
--cc=alexander.h.duyck@redhat.com \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=donald.c.skidmore@intel.com \
--cc=geert@linux-m68k.org \
--cc=heiko.carstens@de.ibm.com \
--cc=jeffrey.t.kirsher@intel.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=matthew.vick@intel.com \
--cc=michael@ellerman.id.au \
--cc=mikey@neuling.org \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=tony.luck@intel.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;
as well as URLs for NNTP newsgroup(s).