This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] NUMA spinlock [BZ #23962]
- From: "马凌(彦军)" <ling dot ml at antfin dot com>
- To: kemi <kemi dot wang at intel dot com>, Ma Ling <ling dot ma dot program at gmail dot com>, <libc-alpha at sourceware dot org>
- Cc: <hongjiu dot lu at intel dot com>, Wei Xiao <wei3 dot xiao at intel dot com>
- Date: Tue, 15 Jan 2019 12:28:27 +0800
- Subject: Re: [PATCH] NUMA spinlock [BZ #23962]
- References: <20181226025019.38752-1-ling.ma@MacBook-Pro-8.local> <a820fbc4-883f-c4f2-d2e4-b55df2817dba@intel.com>
> 1. MCS spinlock
> MCS spinlock help us to reduce the useless lock movement in the
> spinning state. This paper provides a good description for this
> kind of lock:
That's not the truth.
No matter generic spinlock(or x86 version) spinlock has used the way of
test and test_and_set to reduce the useless lock movement in the spinning
state.
See
glibc/nptl/pthread_spin_lock.c
glibc/sysdeps/x86_64/nptl/pthread_spin_lock.S
What MCS-spinlock really helps is to accelerate lock release and lock acquisition
by reducing lots of cache line bouncing.
Ling:
Thanks for your comments.
1.in spinning stage current generic spinlock will read lock, then lock is stored in private cache among cores with shared state.
when one core update the lock ,those cores containing the shared cache line will be noted ,invalidated lock then response to the cache controller
the messages transmission spend much time, but they can be reduced by mcs lock
2. atomic_compare_exchange_weak_acquire cause plenty of useless lock movement because only one core can acquire lock
mcs will transmit the lock one by one with private data, so we say it reduce useless lock movement from above scenario 1 and 2.
> NUMA spinlock can greatly speed up critical section on multi-socket
> systems. It should improve spinlock performance on all multi-socket
> systems.
>
This is out-of-question that NUMA spinlock helps a lot in case of heavy lock
contention. But, we should also propose the data for non-contented case and slight
contended case.
Ling: we will also present report hashwork like adaptive-mcs patch.