This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v6 1/3] Tunables: Add tunables of spin count for pthread adaptive spin mutex

On 2018年07月03日 21:40, H.J. Lu wrote:
> On Tue, Jul 3, 2018 at 5:32 AM, H.J. Lu <> wrote:
>> On Mon, Jul 2, 2018 at 1:27 AM, Kemi Wang <> wrote:
>>> This patch does not have any functionality change, we only provide a spin
>>> count tunes for pthread adaptive spin mutex. The tunable
>>> glibc.mutex.spin_count tunes can be used by system administrator to squeeze
>>> system performance according to different hardware capabilities and
>>> workload characteristics.
>>> The maximum value of spin count is limited to 30000 to avoid the overflow
>>> of mutex->__data.__spins variable with the possible type of short in
>>> pthread_mutex_lock ().
>>> The default value of spin count is set to 100 with the reference to the
>>> previous number of times of spinning via trylock. This value would be
>>> architecture-specific and can be tuned with kinds of benchmarks to fit most
>>> cases in future.
>>> This is the preparation work for the next patch, in which the way of
>>> adaptive spin would be changed from an expensive cmpxchg to read while
>>> spinning.
>>>    * elf/dl-tunables.list: Add glibc.mutex.spin_count entry.
>>>    * manual/tunables.texi: Add glibc.mutex.spin_count description.
>>>    * nptl/Makefile: Add pthread_mutex_conf.c for compilation.
>>>    * nptl/pthread_mutex_conf.h: New file.
>>>    * nptl/pthread_mutex_conf.c: New file.
>>>    * nptl/nptl-init.c: Put mutex tunable initialization in pthread
>>>      initialization.
>>> ChangeLog:
>>>     V5->V6:
>>>     a) Missing "pthread mutex tunables" entry in the menu of tunables.texi,
>>>     add it.
>>>     V4->V5
>>>     a) Put mutex tunable (glibc.mutex.spin_count) initialization as part of
>>>     overall pthread initialization, that would avoid the extra relocation,
>>>     as suggested by Florian Weimer. Thanks for pointing it out!
>>>     b) Move the READ_ONLY_SPIN macro definition from the third patch to
>>>     this patch
>>>     V3->V4
>>>     a) Add comments in elf/dl-tunables.list
>>>     V2->V3
>>>     a) Polish the description of glibc.mutex.spin_count tunable with the
>>>     help from Rical Jasan.
>>>     b) Get rid of the TUNABLE_CALLBACK_FNDECL macros in
>>>     pthread_mutex_conf.c, as suggested by Florian Weimer.
>>>     c) Adjust the default value of spin count to 100 with the reference of
>>>     the previous spinning way via trylock.
>>>     V1->V2
>>>     a) Renamed nptl/mutex-conf.h -> nptl/pthread_mutex_conf.h
>>>     b) Renamed nptl/mutex-conf.c -> nptl/pthread_mutex_conf.c
>>>     c) Change the Makefile to compile pthread_mutex_conf.c
>>>     d) Modify the copyright "2013-2018" -> "2018" for new added files
>>>     e) Fix the indentation issue (tab -> double space) in
>>>     elf/dl-tunables.list
>>>     f) Remove the env alias LD_SPIN_COUNT in elf/dl-tunables.list
>>>     g) Fix the typo errors and refresh glibc.mutex.spin_count tunable
>>>     description in manual/tunables.texi.
>>>     h) Fix the indentation issue in nptl/pthread_mutex_conf.c
>>>     i) Fix the indentation issue for nested preprocessor (add one space for
>>>     each level)
>>> Suggested-by: Andi Kleen <>
>>> Signed-off-by: Kemi Wang <>
> Please take a look at

Reviewed. Thanks for refining, more clear!

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]