Re: [PATCH] atomic: add atomic_inc_not_zero_hint()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric Dumazet
Date: Monday, November 15, 2010 - 7:17 am

Le lundi 15 novembre 2010 à 07:57 -0600, Christoph Lameter a écrit :

Exclusive access ? As soon as another cpu takes it again, you lose.

Its not really the same thing... Maybe you miss the 'hint' intention at
all. We know the probable value of the counter, we dont want to read it.

In fact, prefetchw() is useful when you can assert it many cycles before
the memory read you are going to perform [before the write]. On
contended cache lines, its a waste, because by the time your cpu is
going to read memory, then perform the atomic compare_and_exchange(), an
other cpu might have dirtied the location again. This is what we noticed
during Netfilter Workshop 2010 : A high performance cost at both
atomic_read() and atomic_cmpxchg(). We tried prefetchw() and it was a
performance drop. It was with only 16 cpus contending on neighbour
refcnt, and 5 millions frames per second (5 millions atomic increments,
5 millions atomic decrements)

prefetchw() should be used on very specific spots, when a cpu is going
to write into a private area (not potentially accessed by other cpus).
We use it for example in __alloc_skb(), a bit before memset().

By the way, atomic_inc_not_zero_hint() is less code than 
[prefetchw(), atomic_inc_not_zero()]. Using one instruction [cmpxchg]
with the memory pointer is better than three.  [prefetchw(), read(),
cmpxchg()], particularly if you have high contention on cache line.



--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] atomic: add atomic_inc_not_zero_hint(), Eric Dumazet, (Fri Nov 5, 9:53 am)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Andrew Morton, (Fri Nov 5, 10:20 am)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Eric Dumazet, (Fri Nov 5, 11:00 am)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Andrew Morton, (Fri Nov 5, 11:08 am)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Eric Dumazet, (Fri Nov 5, 11:20 am)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Andrew Morton, (Fri Nov 5, 11:28 am)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Paul E. McKenney, (Fri Nov 5, 11:40 am)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Eric Dumazet, (Fri Nov 5, 12:12 pm)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Eric Dumazet, (Fri Nov 5, 12:20 pm)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Andrew Morton, (Fri Nov 5, 12:39 pm)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Eric Dumazet, (Fri Nov 5, 12:46 pm)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Paul E. McKenney, (Fri Nov 5, 12:51 pm)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Christoph Lameter, (Fri Nov 12, 12:14 pm)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Paul E. McKenney, (Sat Nov 13, 3:26 pm)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Christoph Lameter, (Mon Nov 15, 6:57 am)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Andi Kleen, (Mon Nov 15, 7:07 am)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Christoph Lameter, (Mon Nov 15, 7:16 am)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Eric Dumazet, (Mon Nov 15, 7:17 am)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Christoph Lameter, (Mon Nov 15, 7:25 am)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Andi Kleen, (Mon Nov 15, 7:39 am)
Re: [PATCH] atomic: add atomic_inc_not_zero_hint(), Eric Dumazet, (Mon Nov 15, 7:47 am)