From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by sourceware.org (Postfix) with ESMTPS id 532583858C60 for ; Wed, 1 Nov 2023 12:53:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 532583858C60 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 532583858C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698843216; cv=none; b=C0GkgXvjNNt8mR4JRwOjjbjQqlcrslEWeq7HM2gmXRcaV+zAD9PFCLR+/Xe0xmC27w7HieHCBUAFbAN+TWwuPmF20QgVW2fgZsqu1BWzbYcm8DIPTtmaA7ElkleVSChO/RO/Et8OpDZcYBWoJ8HyEY6o9Q6N7mSiqSzdPfMjZ2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698843216; c=relaxed/simple; bh=vlmNF2Sz5NVt9hraQ+6fOAFqhe4BOU2GPPPVRv8ruyI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=VvAodgVm1R45ZHV8bC5v8Y1h6MI93wmGet3k9XgWILzn4+JrjoVby5OeJe3RM67weyjR3HxE+BPG/sm9wNhgX63u2T4Aj3jelvpcjLgxoObpUhw+taXaJl4cpOrQqJNAPiH+VIvotcEnTMzL1HVjgzN4yfpJVx58HcpeB1Ynaj0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-5a7eef0b931so67184047b3.0 for ; Wed, 01 Nov 2023 05:53:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698843205; x=1699448005; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=7KE5iUmGrpT1NV/1ZzS3EJkKZm5pC8T84JKJX02EoXA=; b=uAFt87oKfKb4MKDtE7oQn4C2vH7A/IBST45yaQre3XSLcp7wP4SvPoylqMsbtLIlwF 7EySm6VuBiGABsWrFp3Ii4KVEz3ucaQO96zaxWiHyP69ilaZWKS6B1RxFJfdC4we/arg bANuByhH9USagJYF883vsjL6Q0xado9Fhrx6gAyglBm06hjZ9yN6GpROpDbzC7P1gGNV lsJdZauvEkoanyhOsF3RgXgDQfOBkyAmS4Xlumhq/MTID6WDPAx/1quSmTuiPxbZGF5d VYhEA/EsIMGGjG7Dr4dd0GsG0NoGcC5XhXruTxSsrYEXcc7Rn29lxLj44Y32ojUfzqYO Q02A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698843205; x=1699448005; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7KE5iUmGrpT1NV/1ZzS3EJkKZm5pC8T84JKJX02EoXA=; b=uof6ga3Du7ppgwiyCxqq4XqIPDkRfQxbruy9pBF2J/dJhCerOEHHHDklDHJv37IgMQ 9r3953TPzbRNaFn36JitllFCtzxQSja8Cgf6g0ud3QVmeKx6wWZ2aRwRSAhdkFWT/DSV vcrwmHcuDzx3eySuLbD8Mptu3u67vwbd+j83iC22JN61f0vJ2Zb+oyQKlmjw7+G8meP8 9jjKeqFm4oOOQsddmHpf9QsoxcMEW3HSwWRly0hslFxlbBAVAOAN5JCFUamR9Edk1bsk wFwfyd1SEcYUM7OIjlU8v/7lnSsh3RKjbOHS+oRoeWQJ/66Ps3FqLCQO5KXHvJK+OCjT 6G4g== X-Gm-Message-State: AOJu0YxOl4DKLajwX6yEhOt9l5r0P+UzlgF+Xl+Rzgc9FToj+ka8HOfU uZd3WzVXvqq30rk/tjy8UpiBsg== X-Google-Smtp-Source: AGHT+IFOn5dE/cstMvT9tO7dv+gjv/Nh04DTM8Ac7og9HqoZXWZU+2Qoss70rNOcJsVJ0NNdFZ/4Fw== X-Received: by 2002:a81:9ad2:0:b0:5a7:f002:4fe4 with SMTP id r201-20020a819ad2000000b005a7f0024fe4mr15916498ywg.23.1698843205493; Wed, 01 Nov 2023 05:53:25 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c0:a715:846f:dda1:e5d1:3146? ([2804:1b3:a7c0:a715:846f:dda1:e5d1:3146]) by smtp.gmail.com with ESMTPSA id d14-20020a81ab4e000000b005925765aa30sm2054272ywk.135.2023.11.01.05.53.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Nov 2023 05:53:24 -0700 (PDT) Message-ID: <1eec745e-d17e-4f95-aa78-7aefa18b8688@linaro.org> Date: Wed, 1 Nov 2023 09:53:22 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 7/7] elf: Add glibc.mem.decorate_maps tunable Content-Language: en-US To: DJ Delorie Cc: libc-alpha@sourceware.org References: From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 01/11/23 00:09, DJ Delorie wrote: > > LGTM with a few optional suggestions > Reviewed-by: DJ Delorie > > Adhemerval Zanella writes: >> diff --git a/NEWS b/NEWS >> index 9432564444..67f6e63b14 100644 >> --- a/NEWS >> +++ b/NEWS >> @@ -38,6 +38,11 @@ Major new features: >> and the wfN format length modifiers for arguments pointing to types >> int_fastN_t or uint_fastN_t, as specified in draft ISO C2X. >> >> +* A new tunable, glibc.mem.decorate_maps, can be used to add additional >> + information on underlying memory allocated by the glibc (for instance, >> + on thread stack created by pthread_create or memory allocated by >> + malloc). >> + > > Ok. Could mention /proc/*/maps > >> diff --git a/elf/Makefile b/elf/Makefile >> index c3cf63a443..2603b90961 100644 >> --- a/elf/Makefile >> +++ b/elf/Makefile >> @@ -3023,5 +3023,5 @@ $(objpfx)tst-dlclose-lazy.out: \ >> $(objpfx)tst-decorate-maps: $(shared-thread-library) >> >> tst-decorate-maps-ENV = \ >> - GLIBC_TUNABLES=glibc.malloc.arena_max=8:glibc.malloc.mmap_threshold=1024 >> + GLIBC_TUNABLES=glibc.malloc.arena_max=8:glibc.malloc.mmap_threshold=1024:glibc.mem.decorate_maps=1 >> tst-decorate-maps-ARGS = 8 > > Ok. > >> diff --git a/elf/dl-tunables.list b/elf/dl-tunables.list >> index 695ba7192e..888d2ede04 100644 >> --- a/elf/dl-tunables.list >> +++ b/elf/dl-tunables.list >> @@ -160,6 +160,11 @@ glibc { >> maxval: 255 >> security_level: SXID_IGNORE >> } >> + decorate_maps { >> + type: INT_32 >> + minval: 0 >> + maxval: 1 >> + } >> } > > Ok. > >> diff --git a/manual/tunables.texi b/manual/tunables.texi >> index 776fd93fd9..2a5ad73e9d 100644 >> --- a/manual/tunables.texi >> +++ b/manual/tunables.texi >> @@ -653,6 +653,18 @@ support in the kernel if this tunable has any non-zero value. >> The default value is @samp{0}, which disables all memory tagging. >> @end deftp >> >> +@deftp Tunable glibc.mem.decorate_maps >> +If the kernel supports naming anonymous virtual memory areas (since >> +Linux version 5.17), this tunable can be used to control whether >> +@theglibc{} decorates the underlying memory obtained from operating >> +system with a string describing its usage (for instance, on the thread >> +stack created by @code{ptthread_create} or memory allocated by >> +@code{malloc}). >> + >> +This tunable takes a value of 0 and 1, where 1 enables the feature. >> +The default value is @samp{0}, which disables the decoration. >> +@end deftp >> + > > Ok. Again, could mention /proc/*/maps. Could mention that the kernel > might be built without such support by choice, too. Ack, I will extend it. > >> diff --git a/sysdeps/unix/sysv/linux/setvmaname.c b/sysdeps/unix/sysv/linux/setvmaname.c >> index 9960ab5917..62237fcf7c 100644 >> --- a/sysdeps/unix/sysv/linux/setvmaname.c >> +++ b/sysdeps/unix/sysv/linux/setvmaname.c >> @@ -20,6 +20,7 @@ >> #include >> #include >> #include >> +#include >> >> /* If PR_SET_VMA_ANON_NAME is not supported by the kernel, prctl returns >> EINVAL. However, it also returns the same error for invalid argument. >> @@ -30,6 +31,9 @@ >> void >> __set_vma_name (void *start, size_t len, const char *name) >> { >> + if (TUNABLE_GET (glibc, mem, decorate_maps, int32_t, NULL) == 0) >> + return; >> + >> static int prctl_supported = 1; >> if (atomic_load_relaxed (&prctl_supported) == 0) >> return; > > Ok, but would be better to check the tunable after the prctl_supported > flag (and set the flag) to avoid calling __tunable_get_val for every > call. Unless the intention was to allow changing the tunable during > runtime, in which case, ignore this comment ;-) > Indeed you are right, we don't have the tunable runtime support and I am not sure if adding this would make sense for this tunable.