[PATCH v8] Mutex: Add pthread mutex tunables

H.J. Lu hjl.tools@gmail.com
Tue Jul 17 11:21:00 GMT 2018


On Mon, Jul 9, 2018 at 6:17 PM, Kemi Wang <kemi.wang@intel.com> wrote:
> This patch does not have any functionality change, we only provide a spin
> count tunes for pthread adaptive spin mutex. The tunable
> glibc.pthread.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.
>
>    * sysdeps/nptl/dl-tunables.list: Add glibc.pthread.mutex_spin_count entry.
>    * manual/tunables.texi: Add glibc.pthread.mutex_spin_count description.
>    * sysdeps/nptl/pthread_mutex_conf.h: New file.
>    * nptl/pthread_mutex_conf.c: New file.
>    * nptl/Makefile: Add pthread_mutex_conf.c for compilation.
>    * nptl/nptl-init.c: Put pthread mutex tunable initialization in pthread
>      initialization.
>    * nptl/pthreadP.h: Move MAX_ADAPTIVE_COUNT macro definition to
>      pthread_mutex_conf.h
>
> I would extend my appreciation sincerely to H.J.Lu for his help to refine
> this patch series.
>
> ChangeLog:
>         V7->V8:
>         a) Refine the pthread tunables description in manual/tunables.texi
>         accordingly to Carlos O'Donell and Rical Jason.
>
>     V6->V7:
>     a) Patch is refined by H.J.Lu
>
>     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)
>
> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
> Suggested-by: Andi Kleen <andi.kleen@intel.com>
> Signed-off-by: Kemi.wang <kemi.wang@intel.com>

LGTM.

Thanks.

-- 
H.J.



More information about the Libc-alpha mailing list