This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH v6 1/3] Tunables: Add tunables of spin count for pthread adaptive spin mutex
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Kemi Wang <kemi dot wang at intel dot com>
- Cc: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Florian Weimer <fweimer at redhat dot com>, Rical Jason <rj at 2c3t dot io>, Carlos Donell <carlos at redhat dot com>, Glibc alpha <libc-alpha at sourceware dot org>, Dave Hansen <dave dot hansen at linux dot intel dot com>, Tim Chen <tim dot c dot chen at intel dot com>, Andi Kleen <andi dot kleen at intel dot com>, Ying Huang <ying dot huang at intel dot com>, Aaron Lu <aaron dot lu at intel dot com>, Lu Aubrey <aubrey dot li at intel dot com>
- Date: Tue, 3 Jul 2018 06:40:19 -0700
- Subject: Re: [PATCH v6 1/3] Tunables: Add tunables of spin count for pthread adaptive spin mutex
- References: <firstname.lastname@example.org> <CAMe9rOopnM=io7k9z4a2LzjuYZMtwH8xUuNbRMLcTTLzHBeCYA@mail.gmail.com>
On Tue, Jul 3, 2018 at 5:32 AM, H.J. Lu <email@example.com> wrote:
> On Mon, Jul 2, 2018 at 1:27 AM, Kemi Wang <firstname.lastname@example.org> 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
>> * 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
>> a) Missing "pthread mutex tunables" entry in the menu of tunables.texi,
>> add it.
>> 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
>> a) Add comments in elf/dl-tunables.list
>> 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.
>> 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
>> 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 <email@example.com>
>> Signed-off-by: Kemi Wang <firstname.lastname@example.org>
Please take a look at