This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/2] Initialize tunable list with the GLIBC_TUNABLES environment variable
- 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:53:12 -0700
- Subject: Re: [PATCH 2/2] Initialize tunable list with the GLIBC_TUNABLES environment variable
- Authentication-results: sourceware.org; auth=none
- References: <1467479562-11357-1-git-send-email-siddhesh at sourceware dot org> <1467479562-11357-3-git-send-email-siddhesh at sourceware dot org>
On Sat, Jul 2, 2016 at 10:12 AM, Siddhesh Poyarekar
<siddhesh@sourceware.org> wrote:
> Read tunables values from the users using the GLIBC_TUNABLES
> environment variable. The value of this variable is a colon-separated
> list of name=value pairs. So a typical string would look like this:
>
> GLIBC_TUNABLES=glibc.malloc.mmap_threshold=2048:glibc.malloc.trim_threshold=1024
>
> * elf/dl-tunables.c: Include string.h.
> (parse_tunables): New function.
> (GLIBC_TUNABLES): New macro.
> (__tunables_init): Use it.
I didn't see any tests for GLIBC_TUNABLES=glibc.malloc and I don't think
it works for static executable:
gdb) bt
#0 __tunable_set_val (id=glibc_malloc_check, valp=0x6b67d0 <check_action>,
callback=0x414460 <_dl_tunable_set_mallopt_check>) at dl-tunables.c:221
#1 0x0000000000413cda in ptmalloc_init () at arena.c:299
#2 0x0000000000414dfe in ptmalloc_init () at hooks.c:29
#3 malloc_hook_ini (sz=66, caller=<optimized out>) at hooks.c:31
#4 0x0000000000418b2a in __strdup (
s=0x7fffffffef66
"glibc.malloc.mmap_threshold=2048:glibc.malloc.trim_threshold=1024")
at strdup.c:42
#5 0x0000000000437e01 in __tunables_init (envp=0x7fffffffe088,
envp@entry=0x7fffffffdeb8) at dl-tunables.c:184
#6 0x000000000043908b in __libc_init_first (argc=argc@entry=1,
argv=argv@entry=0x7fffffffdea8, envp=0x7fffffffdeb8)
at ../csu/init-first.c:81
#7 0x00000000004012d5 in generic_start_main (main=0x400550 <main>, argc=1,
argv=argv@entry=0x7fffffffdea8,
init=init@entry=0x401b20 <__libc_csu_init>,
fini=0x401bb0 <__libc_csu_fini>, rtld_fini=0x0, stack_end=0x7fffffffde98)
at ../csu/libc-start.c:225
#8 0x00000000004015c7 in __libc_start_main (main=<optimized out>,
argc=<optimized out>, argv=0x7fffffffdea8,
init=0x401b20 <__libc_csu_init>, fini=0x401bb0 <__libc_csu_fini>,
rtld_fini=<optimized out>, stack_end=0x7fffffffde98)
at ../sysdeps/x86/libc-start.c:38
---Type <return> to continue, or q <return> to quit---
#9 0x0000000000400e1a in _start () at ../sysdeps/x86_64/start.S:120
if (is_name (GLIBC_TUNABLES, envname))
{
parse_tunables (strdup (envval));
^^^^^^^^^ Which calls malloc and
other library functions.
continue;
}
Since tunable code is called very early, it can't use any C library functions.
--
H.J.