public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Seigh <jseigh_02@xemaps.com>
To: linux-kernel@vger.kernel.org
Subject: Re: Volatile vs Non-Volatile Spin Locks on SMP.
Date: Sun, 17 Jul 2005 08:51:54 -0400	[thread overview]
Message-ID: <dbdk3i$8si$1@sea.gmane.org> (raw)
In-Reply-To: <BAY108-DAV714C888634D31F28B5A5D93D00@phx.gbl>

multisyncfe991@hotmail.com wrote:
> Hello,
> 
> By using volatile keyword for spin lock defined by in spinlock_t, it 
> seems Linux choose to always
> reload the value of spin locks from cache instead of using the content 
> from registers. This may be
> helpful for synchronization between multithreads in a single CPU.
> 
> I use two Xeon cpus with HyperThreading being disabled on both cpus. I 
> think the MESI
> protocol will enforce the cache coherency and update the spin lock value 
> automatically between
> these two cpus. So maybe we don't need to use the volatile any more, right?
> 
> Based on this, I rebuilt the Intel e1000 Gigabit network card driver 
> with volatile being removed,
> but I didn't notice any performance improvement.
> 
> Any idea about this,
> 

Volatile is meaningless as far as threading is concerned.  Technically, its
meaning is implementation defined and since for Linux we're talking about
gcc, I suppose someone could claim it has some meaning although most of us
will have no way of verifying those claims.  You might see some usage
of volatile in the Linux kernel which makes it appear as though it
has some meaning but you might want to be careful in depending on that
since there's no way of knowing if your interpretation of the meaning
is the same as what the authors of that code have in mind.

For synchronization you need memory barriers in most cases and the only
way to get these is using assembler since there are no C or gcc intrinsics
for these yet.  For inline assembler, the convention seems to be to use
the volatile attribute, which I take as meaning no code movement across
the inline assembler code.  It if doesn't mean that then a lot of stuff
is broken AFAICT.

Assuming you're doing this in assembler, using volatile on the C declaration
will have no effect on performance in this case.  You're seeing the most
"recent" value due to the cache implementation.

--
Joe Seigh


  reply	other threads:[~2005-07-17 12:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-14  2:20 About a change to the implementation of spin lock in 2.6.12 kernel multisyncfe991
2005-07-14  5:16 ` Willy Tarreau
2005-07-14 16:21   ` multisyncfe991
2005-07-14 16:26     ` Brandon Niemczyk
2005-11-09 17:57       ` Does Printk() block another CPU in dual cpu platforms? John Smith
2005-11-10  3:31         ` Fawad Lateef
2005-07-15 19:22     ` Volatile vs Non-Volatile Spin Locks on SMP multisyncfe991
2005-07-17 12:51       ` Joe Seigh [this message]
2005-07-18 13:40         ` Joe Seigh
     [not found] <4q1Ec-5KI-9@gated-at.bofh.it>
     [not found] ` <4q4sq-7HQ-15@gated-at.bofh.it>
     [not found]   ` <4qeLl-7lW-11@gated-at.bofh.it>
     [not found]     ` <4qEcy-1CX-21@gated-at.bofh.it>
2005-07-16 18:58       ` Robert Hancock

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='dbdk3i$8si$1@sea.gmane.org' \
    --to=jseigh_02@xemaps.com \
    --cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox