This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/4] Initialize tunable list with the GLIBC_TUNABLES environment variable
- From: Siddhesh Poyarekar <siddhesh at sourceware dot org>
- To: Florian Weimer <fweimer at redhat dot com>, libc-alpha at sourceware dot org
- Cc: carlos at redhat dot com, adhemerval dot zanella at linaro dot org
- Date: Wed, 28 Dec 2016 03:05:17 +0530
- Subject: Re: [PATCH 2/4] Initialize tunable list with the GLIBC_TUNABLES environment variable
- Authentication-results: sourceware.org; auth=none
- References: <1479285306-11684-1-git-send-email-siddhesh@sourceware.org> <1479285306-11684-3-git-send-email-siddhesh@sourceware.org> <21052a79-a9ba-879c-129a-197fb584e178@redhat.com>
- Reply-to: siddhesh at sourceware dot org
On Tuesday 27 December 2016 05:11 PM, Florian Weimer wrote:
> See my initial mail. errno and __getpagesize are not available at this
> point.
Ugh, right. I'll try to come up with something that does not need an
additional allocation.
>> +static size_t
>> +min_strlen (const char *s)
>> +{
>> + size_t i = 0;
>> + while (*s++ != '\0')
>> + i++;
>> +
>> + return i;
>> +}
>
> Is there anything which ensures that GCC does not replace this
> implementation with strlen?
I think I'm missing a gcc flag here to ensure that. I'll find out and
add it.
>> /* Disable a tunable if it is set. */
>> static void
>> disable_tunable (tunable_id_t id, char **envp)
>> @@ -216,6 +318,23 @@ disable_tunable (tunable_id_t id, char **envp)
>>
>> if (env_alias)
>> tunables_unsetenv (envp, tunable_list[id].env_alias);
>> +
>> + char *tunable = getenv (GLIBC_TUNABLES);
>> + const char *cmp = tunable_list[id].name;
>> + const size_t len = min_strlen (cmp);
>> +
>> + while (tunable && *tunable != '\0' && *tunable != ':')
>> + {
>> + if (is_name (tunable, cmp))
>> + {
>> + tunable += len;
>> + /* Overwrite the = and the value with colons. */
>> + while (*tunable != '\0' && *tunable != ':')
>> + *tunable++ = ':';
>> + break;
>> + }
>> + tunable++;
>> + }
>> }
>
> This assumes that the process environment is not mapped read-only. I'm
> not sure if this is guaranteed by the ABI.
Barring tunables with string values this might be easy to work around.
Let me give this a shot too.
Siddhesh