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 07:30:30 -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.
>
> diff --git a/csu/init-first.c b/csu/init-first.c
> index 77c6e1c..7427121 100644
> --- a/csu/init-first.c
> +++ b/csu/init-first.c
> @@ -28,6 +28,9 @@
> #include <libc-internal.h>
>
> #include <ldsodefs.h>
> +#if BUILD_TUNABLES
> +# include <elf/dl-tunables.h>
> +#endif
>
> /* Set nonzero if we have to be prepared for more than one libc being
> used in the process. Safe assumption if initializer never runs. */
> @@ -74,6 +77,10 @@ _init (int argc, char **argv, char **envp)
> #ifndef SHARED
> __libc_init_secure ();
>
> +#if BUILD_TUNABLES
> + __tunables_init (envp);
> +#endif
> +
> /* First the initialization which normally would be done by the
> dynamic linker. */
> _dl_non_dynamic_init ();
Shouldn't __tunables_init be called from _dl_non_dynamic_init?
> diff --git a/elf/rtld.c b/elf/rtld.c
> index 647661c..263723a 100644
> --- a/elf/rtld.c
> +++ b/elf/rtld.c
> @@ -44,6 +44,10 @@
>
> #include <assert.h>
>
> +#if BUILD_TUNABLES
> +# include <dl-tunables.h>
> +#endif
> +
> /* Avoid PLT use for our local calls at startup. */
> extern __typeof (__mempcpy) __mempcpy attribute_hidden;
>
> @@ -2346,6 +2350,10 @@ process_envvars (enum mode *modep)
> enum mode mode = normal;
> char *debug_output = NULL;
>
> +#if BUILD_TUNABLES
> + __tunables_init (_environ);
> +#endif
> +
Shouldn't __tunables_init be called from _dl_sysdep_start?
> /* This is the default place for profiling data file. */
> GLRO(dl_profile_output)
> = &"/var/tmp\0/var/profile"[__libc_enable_secure ? 9 : 0];
I
--
H.J.