From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id B8F953858418 for ; Wed, 1 Nov 2023 03:09:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B8F953858418 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B8F953858418 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698808178; cv=none; b=L999jBs6JXCDL4LSbeI4wU+NTHytz+FBUmPBPLXD6IJXpMEAiBaOtlDO/IuNSWHt41kJJn8c19NxdJtUBPIdBMIVI6qCsj6OjquFcK203o2bWMCGIbxcbdX0ZR37d+2dCaaLh30+1VEHVn/5QA5CSjgSF//G/FqmiWM13NNpDKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698808178; c=relaxed/simple; bh=lSSs7oCEbH84uvzEs6YZNpZDAQABDRaN0KEUAuWGikI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gFmWuQC0J9f06wv80TQiYI+zUO7x9N2s8nILesv0Humoek1ci5lfn3L5FCeMiFGukYOqgsi5+WhZ134sg3DKNbvTijyLovxNRTUQTNsJkr/wsQK5iGY6SHDyk+9SLfDKIa5vcjXWkdYij98xgjuhPlN1+K+G4eJq38TAo+P4AAY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698808176; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=IuiNWkgKJrWZ0ciblyLGSrt1GW5A8gi+3NaevPGaL20=; b=I86RzCWnscDBXwyKg9jLXYltFVVyTQ4rsNUJgIQIPgWNmJuWgSsGLqmfxOj5AnULF5fHXH gys2wjyuyAONlqWLRTuFnyOxy+dc0WmdERfz27Llbv5hF9rcfmxjkhfeIXT055KSrHR+Sb iPcpfwwrYrVd199/yKjSQ4i5FQ2IFqE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-8f_lrZtEMBitC4Axm3EBdg-1; Tue, 31 Oct 2023 23:09:35 -0400 X-MC-Unique: 8f_lrZtEMBitC4Axm3EBdg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D673A80F835; Wed, 1 Nov 2023 03:09:34 +0000 (UTC) Received: from greed.delorie.com (unknown [10.22.9.226]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C14ED2166B26; Wed, 1 Nov 2023 03:09:34 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.15.2/8.15.2) with ESMTP id 3A139XBN4190910; Tue, 31 Oct 2023 23:09:33 -0400 From: DJ Delorie To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v2 7/7] elf: Add glibc.mem.decorate_maps tunable In-Reply-To: <20231028195559.390407-8-adhemerval.zanella@linaro.org> Date: Tue, 31 Oct 2023 23:09:33 -0400 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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: 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. > 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 ;-)