Thread (38 messages) 38 messages, 6 authors, 2021-11-01

Re: [RFC 1/8] mm: add overflow and underflow checks for page->_refcount

From: Muchun Song <hidden>
Date: 2021-10-28 04:09:05
Also in: linux-m68k, lkml

On Thu, Oct 28, 2021 at 2:22 AM Pasha Tatashin
[off-list ref] wrote:
quoted
I found some atomic_add/dec are replaced with atomic_add/dec_return,
I am going to replace -return variants with -fetch variants, potentially -fetch
quoted
those helpers with return value imply a full memory barrier around it, but
others without return value do not. Do you have any numbers to show
the impact? Maybe atomic_add/dec_return_relaxed can help this.
The generic variant uses  arch_cmpxchg() for all atomic variants
without any extra barriers. Therefore, on platforms that use generic
implementations there won't be performance differences except for an
extra branch that checks results when VM_BUG_ON is enabled.

On x86 the difference between the two is the following

atomic_add:
   lock add %eax,(%rsi)

atomic_fetch_add:
   lock xadd %eax,(%rsi)

atomic_fetch_add_relaxed:
   lock xadd %eax,(%rsi)

No differences between relaxed and non relaxed variants. However, we
Right. There is no difference on x86. Maybe there are differences in
other architectures.
used lock xadd instead of lock add. I am not sure if the performance
difference is going to be different.

Pasha
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help