linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: bob <bob@watson.ibm.com>
To: Manfred Spraul <manfred@colorfullife.com>
Cc: bob <bob@watson.ibm.com>, linux-kernel@vger.kernel.org
Subject: RE: [patch] printk subsystems
Date: Thu, 24 Apr 2003 15:10:09 -0400 (EDT)	[thread overview]
Message-ID: <16040.13839.811454.16308@k42.watson.ibm.com> (raw)
In-Reply-To: <3EA8336F.2000609@colorfullife.com>

Manfred Spraul writes:
 > Robert wrote:
 > 
 > >There is both a qualitative difference and quantitative difference in a
 > >lockless algorithm as described versus one that uses locking.  Most
 > >importantly for Linux, these algorithms in practice have better performance
 > >characteristics.
 > >
 > Do you have benchmark numbers that compare "lockless" and locking 
 > algorithms on large MP systems?
 > 
 > For example, how much faster is one 'lock;cmpxchg' compared to 
 > 'spin_lock();if (x==var) var = y;spin_unlock();'.
 > 
 > So far I assumed that for spinlock that are only held for a few cycles, 
 > the cacheline trashing dominates, and not the spinning.
 > I've avoided to replace spin_lock+inc+spin_unlock with atomic_inc(). 
 > (Just look at the needed memory barriers: smp_mb__after_clear_bit & friends)
 > 
 > RCU uses per-cpu queues that are really lockless and avoid the cache 
 > trashing, that is a real win.
 > 
 > --
 >     Manfred
 > 

You're right in the common case - cache thrashing is definitely dominant
(though in K42 we've tried to be very careful to design code and data so
the last acquisition is almost always on the same processor).  The problem
arises is the process ever gets interrupted after spin_lock.  Then
performance falls of a cliff because everyone backs up for the lock.
That's what I had meant by in practice it works better.  From my experience
the OS likes to interrupt you in the place you least want :-).  I certainly
could point to lots of preemption numbers (which motivated the comment),
and though I'm sure there's the other, I don't know where offhand.

In some specific places it's probably all right to go with a spin lock, for
the logging/tracing code (which started this thread) that will be used
generically throughout the kernel by many callers, lockless is the way to
go.

-bob

Robert Wisniewski
The K42 MP OS Project
Advanced Operating Systems
Scalable Parallel Systems
IBM T.J. Watson Research Center
914-945-3181
http://www.research.ibm.com/K42/
bob@watson.ibm.com

  reply	other threads:[~2003-04-24 18:58 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-24 18:56 [patch] printk subsystems Manfred Spraul
2003-04-24 19:10 ` bob [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-04-23  0:28 Perez-Gonzalez, Inaky
2003-04-22 22:53 Perez-Gonzalez, Inaky
2003-04-23  3:58 ` Tom Zanussi
2003-04-22 19:02 Perez-Gonzalez, Inaky
2003-04-22 19:03 ` H. Peter Anvin
2003-04-22 21:52 ` Tom Zanussi
2003-04-22 18:46 Perez-Gonzalez, Inaky
2003-04-22 23:28 ` Karim Yaghmour
2003-04-22  5:09 Perez-Gonzalez, Inaky
2003-04-24 18:22 ` bob
2003-04-22  4:02 Perez-Gonzalez, Inaky
2003-04-22  5:52 ` Karim Yaghmour
2003-04-22  6:04 ` Tom Zanussi
2003-04-22  3:04 Perez-Gonzalez, Inaky
2003-04-22  6:00 ` Tom Zanussi
2003-04-22  2:49 Perez-Gonzalez, Inaky
2003-04-22  4:34 ` Karim Yaghmour
2003-04-21 18:42 Perez-Gonzalez, Inaky
2003-04-21 18:23 Perez-Gonzalez, Inaky
2003-04-21 18:30 ` H. Peter Anvin
2003-04-17 19:58 Perez-Gonzalez, Inaky
2003-04-17 20:34 ` Karim Yaghmour
2003-04-17 21:03   ` Perez-Gonzalez, Inaky
2003-04-17 21:37     ` Tom Zanussi
2003-04-18  7:21     ` Tom Zanussi
2003-04-18  7:42     ` Greg KH
2003-04-21 15:56     ` Karim Yaghmour
2003-04-08 23:15 Chuck Ebbert
2003-04-07 20:13 Martin Hicks
2003-04-08 18:41 ` Pavel Machek
2003-04-08 20:02   ` Jes Sorensen
2003-04-08 21:02     ` Pavel Machek
2003-04-08 21:10       ` H. Peter Anvin
2003-04-08 21:57         ` Pavel Machek
2003-04-08 22:02           ` Jes Sorensen
2003-04-08 22:05           ` H. Peter Anvin
2003-04-08 22:55             ` Martin Hicks
2003-04-08 23:10               ` Randy.Dunlap
2003-04-14 18:33                 ` Patrick Mochel
2003-04-14 22:33                   ` Daniel Stekloff
2003-04-16 18:42                     ` Patrick Mochel
2003-04-16 12:35                       ` Daniel Stekloff
2003-04-16 19:16                       ` Martin Hicks
2003-04-16 12:43                         ` Daniel Stekloff
2003-04-17 15:56                           ` Martin Hicks
2003-04-17 13:58                             ` Karim Yaghmour
2003-04-15 13:27                   ` Martin Hicks
2003-04-15 14:40                     ` Karim Yaghmour
2003-04-08 22:00       ` Jes Sorensen
2003-04-11 19:21 ` Martin Hicks

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=16040.13839.811454.16308@k42.watson.ibm.com \
    --to=bob@watson.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.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).