This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 1/2] Add framework for tunables
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Siddhesh Poyarekar <siddhesh at sourceware dot org>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Sun, 3 Jul 2016 08:13:24 -0700
- Subject: Re: [PATCH 1/2] Add framework for tunables
- Authentication-results: sourceware.org; auth=none
- References: <1467479562-11357-1-git-send-email-siddhesh at sourceware dot org> <1467479562-11357-2-git-send-email-siddhesh at sourceware dot org>
On Sat, Jul 2, 2016 at 10:12 AM, Siddhesh Poyarekar
<siddhesh@sourceware.org> wrote:
> The tunables framework allows us to uniformly manage and expose global
> variables inside glibc as switches to users. README.tunables has
> instructions for glibc developers to add new tunables.
>
> Tunables support can be enabled by passing the --enable-tunables
> configure flag to the configure script. This patch only adds a
> framework and does not pose any limitations on how tunable values are
> read from the user. It also adds environment variables used in malloc
> behaviour tweaking to the tunables framework as a PoC of the
> compatibility interface.
>
> * manual/install.texi: Add --enable-tunables option.
> * INSTALL: Regenerate.
> * Makeconfig (CPPFLAGS): Define TOP_NAMESPACE.
> (before-compile): Generate dl-tunable-list.h early.
> * config.h.in: Add BUILD_TUNABLES.
> * config.make.in: Add build-tunables.
> * configure.ac: Add --enable-tunables option.
> * configure: Regenerate.
> * malloc/arena.c [BUILD_TUNABLES]: Include dl-tunables.h.
> Define TUNABLE_NAMESPACE.
> (DL_TUNABLE_CALLBACK(set_mallopt_check)): New function.
> (ptmalloc_init): Set tunable values.
> * malloc/tst-malloc-usable-static.c: New test case.
> * csu/init-first.c [BUILD_TUNABLES]: Include dl-tunables.h.
> (__libc_init_first) [!SHARED]: Initialize tunables for static
> binaries.
> * scripts/gen-tunables.awk: New file.
> * README.tunables: New file.
> * elf/Versions (ld): Add __tunable_set_val to GLIBC_PRIVATE
> namespace.
> * elf/dl-tunable-list.h: New auto-generated file.
> * elf/dl-tunables.c: New file.
> * elf/dl-tunables.h: New file.
> * elf/dl-tunables.list: New file.
> * elf/dl-tunable-types.h: New file.
> * elf/rtld.c [BUILD_TUNABLES]: Include dl-tunables.h
> (process_envvars): Call __tunables_init.
> ---
> INSTALL | 6 ++
> Makeconfig | 16 ++++
> README.tunables | 74 ++++++++++++++++
> config.h.in | 3 +
> config.make.in | 1 +
> configure | 16 ++++
> configure.ac | 10 +++
> csu/init-first.c | 7 ++
> elf/Makefile | 5 ++
> elf/Versions | 3 +
> elf/dl-tunable-types.h | 45 ++++++++++
> elf/dl-tunables.c | 172 ++++++++++++++++++++++++++++++++++++++
> elf/dl-tunables.h | 76 +++++++++++++++++
> elf/dl-tunables.list | 50 +++++++++++
> elf/rtld.c | 8 ++
> malloc/Makefile | 3 +
> malloc/arena.c | 35 ++++++++
> malloc/tst-malloc-usable-static.c | 1 +
> manual/install.texi | 5 ++
> scripts/gen-tunables.awk | 157 ++++++++++++++++++++++++++++++++++
> 20 files changed, 693 insertions(+)
> create mode 100644 README.tunables
> create mode 100644 elf/dl-tunable-types.h
> create mode 100644 elf/dl-tunables.c
> create mode 100644 elf/dl-tunables.h
> create mode 100644 elf/dl-tunables.list
> create mode 100644 malloc/tst-malloc-usable-static.c
> create mode 100644 scripts/gen-tunables.awk
>
> +/* Same as TUNABLE_SET_VAL, but also set the callback function to __CB and call
> + it. */
> +# define TUNABLE_SET_VAL_WITH_CALLBACK(__id,__val,__cb) \
> +({ \
> + __tunable_set_val \
> + (TUNABLE_ENUM_NAME (TOP_NAMESPACE, TUNABLE_NAMESPACE, __id), (__val), \
> + DL_TUNABLE_CALLBACK (__cb)); \
> +})
> +
> +/* Namespace sanity for callback functions. Use this macro to keep the
> + namespace of the modules clean. */
> +#define DL_TUNABLE_CALLBACK(__name) _dl_tunable_ ## __name
> +#endif
For IFUNC, or any processor specific tunables, a different callback is
needed:
void
ifunc_callback (const char *p)
{
...
}
where p is the string after "GLIBC_IFUNC=".
H.J.