DPDK patches and discussions
 help / color / mirror / Atom feed
From: "François-Frédéric Ozog" <ff@ozog.com>
To: "'Thomas Monjalon'" <thomas.monjalon@6wind.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] Bit spinlocks in DPDK
Date: Fri, 20 Dec 2013 17:00:43 +0100	[thread overview]
Message-ID: <04be01cefd9c$a3c36460$eb4a2d20$@com> (raw)
In-Reply-To: <201312201639.05277.thomas.monjalon@6wind.com>



> -----Message d'origine-----
> De : Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Envoyé : vendredi 20 décembre 2013 16:39
> À : François-Frédéric Ozog
> Cc : dev@dpdk.org
> Objet : Re: [dpdk-dev] Bit spinlocks in DPDK
> 
> Hello,
> 
> 07/12/2013 18:54, François-Frédéric Ozog :
> > 1) If the critical section deals with weakly ordered loads then
> > explicit fencing MUST be used: if not, out of order execution will
> > just kill your idea of critical section.
> [...]
> > So use rte_mb() or rte_wmb() or rte_rmb() where appropriate. I
> > recommend the rte_unlock code and documentation explains the out of
> > order execution issues and the conditions they have to be mitigated
> > with rte*mb(). I wonder if having an explicit mfence in
> > rte_sinlock_unlock wouldn't be just necessary to avoid "hairy" bugs.
> > In addition, we would have rte_sinlock_unlock_no_mb used internally
> > for performance reasons, and usable externally by advanced users.
> 
> Using lock prefix is lighter than using memory barrier and have the same
> effects.

Well, in general yes BUT Intel states "../.. locked operations serialize all
outstanding load and store operations ../.. with one exception. Load
operations that reference weakly ordered memory types (such as the WC memory
type) may *not* be serialized" in 8.1.2.2 Software Controlled Bus Locking;
particularly if streaming loads are used (may happen on certain devices
memory mapped I/O accesses and the compiler generating streaming loads).

So this comment is essentially for the PMD writers: use the fencing where
appropriate, even if the lock prefix is there. As I will be the one
forgetting the rule, I like to have that in the documentation/comments as
reminders to keep things neat.

François-Frédéric

> But you're right about the bug in spinlocks.
> I am going to send a patch for this.
> 
> --
> Thomas

  reply	other threads:[~2013-12-20 16:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-06 21:04 Pashupati Kumar
2013-12-06 22:02 ` Thomas Monjalon
2013-12-06 22:12   ` Pashupati Kumar
2013-12-06 22:24     ` Thomas Monjalon
2013-12-06 22:54       ` Pashupati Kumar
2013-12-07 17:54       ` François-Frédéric Ozog
2013-12-19 16:41         ` Thomas Monjalon
2013-12-20 15:39         ` Thomas Monjalon
2013-12-20 16:00           ` François-Frédéric Ozog [this message]
2013-12-20 16:36             ` Stephen Hemminger

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='04be01cefd9c$a3c36460$eb4a2d20$@com' \
    --to=ff@ozog.com \
    --cc=dev@dpdk.org \
    --cc=thomas.monjalon@6wind.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).