Re: [RFC][PATCH 1/7] Resource counters



Pavel Emelianov <xemul@xxxxx> writes:

Srivatsa Vaddagiri wrote:
On Tue, Mar 13, 2007 at 06:41:05PM +0300, Pavel Emelianov wrote:
right, but atomic ops have much less impact on most
architectures than locks :)
Right. But atomic_add_unless() is slower as it is
essentially a loop. See my previous letter in this sub-thread.

If I am not mistaken, you shouldn't loop in normal cases, which means
it boils down to a atomic_read() + atomic_cmpxch()



So does the lock - in a normal case (when it's not
heavily contented) it will boil down to atomic_dec_and_test().

Nevertheless, making charge like in this patchset
requires two atomic ops with atomic_xxx and only
one with spin_lock().

To be very clear. If you care about optimization cache lines
and lock hold times (to keep contention down) are the important
things.

With spin locks you have to be a little more careful to put them
on the same cache line as your data and to keep should hold times
short. With atomic ops you get that automatically.

There is really no significant advantage in either approach.
The number of atomic ops doesn't matter. You bring in
the cache line and manipulate it. The expensive part is
acquiring the cache line exclusively. This is expensive even if
things are never contended but there are many users.

Sorry for the rant, but I just wanted to set the record straight.
spin_locks vs atomic ops is a largely meaningless debate.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: 2.6.16-rc6-rt1
    ... includes releasing _all_ locks at each ... Or a higher priority task change the structures along the way... ... The basic loop is: ...
    (Linux-Kernel)
  • Re: [patch] Real-Time Preemption, -RT-2.6.12-rc1-V0.7.43-00
    ... > serial, to do sysrq. ... The console is using X which locks (even all the ... That was a BUG where as this has something in a spinning loop somewhere. ... Probably for kjournald to run, ...
    (Linux-Kernel)
  • Re: Populate an ImageList from another thread
    ... Now, as for what happens when I run the code you posted: I do not find that the application locks up, nor do I get an hourglass cursor and no repainting. ... The other thing about the code is that it's in a fairly tight loop. ... Because this is timing related, it's possible that if your hardware is significantly different from mine, that could explain a perceived difference in responsiveness. ...
    (microsoft.public.dotnet.languages.csharp)
  • bad karma with loop?
    ... I use this Count Occurrences public sub with modifications ... in several VBA macros I've written. ... it or it locks up if I try to run any macro (including the ... basic one, below) containing the loop. ...
    (microsoft.public.word.vba.general)
  • Re: spinaphore conceptual draft
    ... >>I suspect any attempt to use time stamps in locks is a bad ... >>CPU will always snoop cache accesses for all cache lines ... > The idea behind these locks is for bigger systems for ... and a lock such as this should be able to send several CPUs to ...
    (Linux-Kernel)