[{"id":3681987,"web_url":"http://patchwork.ozlabs.org/comment/3681987/","msgid":"<63fd81e1-b789-4a82-89db-a2f868aaa541@linaro.org>","list_archive_url":null,"date":"2026-04-24T11:28:14","subject":"Re: [PATCH v4 1/8] tests: Allow tests to append tunables","submitter":{"id":66065,"url":"http://patchwork.ozlabs.org/api/people/66065/","name":"Adhemerval Zanella Netto","email":"adhemerval.zanella@linaro.org"},"content":"On 21/04/26 11:37, Yury Khrustalev wrote:\n> Many tests use Glibc tunables, and the values of the tunables are\n> provided via the GLIBC_TUNABLES env variable. Tests set it in\n> makefiles using\n> \n>   tst-foo-ENV = GLIBC_TUNABLES=tunable=value\n> \n> This overwrites environment for this test, so if another env var is\n> set elsewhere, one of these changes would be lost. The correct way\n> should be to append to test's environment:\n> \n>   tst-foo-ENV += GLIBC_TUNABLES=tunable=value\n> \n> However, if two or more tunables need to be set for the same test,\n> the 'tunable=value' part should be appended to previously defined\n> GLIBC_TUNABLES env variable, and it's not easy to achieve this via\n> existing tools available for tests.\n> \n> Additionally, there are cases when it is useful to set ambient env\n> var GLIBC_TUNABLES in order to apply it to most of the tests except\n> those that require specific tunables. The existing mechanism that\n> relies on tst-foo-ENV would always override the ambient env var\n> even when it is not desirable.\n> \n> To address all of this, in this commit we add support for using\n> constructs like\n> \n>   tst-foo-TUNABLES += tunable=value\n> \n> Using this, the test will receive appropriate GLIBC_TUNABLES contents,\n> and if there is an ambient env var GLIBC_TUNABLES, its value will be\n> prepended to the env var used by the test. Even if the ambient env var\n> contains the same tunable that is used by a test, the test's value will\n> override the ambient value, and the test will be executed correctly.\n> \n> Additionally, we support cases when tests must have specific value\n> of the GLIBC_TUNABLES env var (ignoring any ambient value):\n> \n>   tst-foo-TUNABLES-only += tunable=value\n> \n> The existing mechanism that uses tst-foo-ENV will continue to work,\n> however if the same test uses both, the new mechanism will override\n> the old one.\n> \n> Additional benefit is that the code in makefiles becomes shorter.\n> \n> We also change tunable handling for malloc tests in this commit.\n\nLGTM, thanks.\n\nReviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>\n\n> ---\n>  Rules               | 32 +++++++++++++++++++++++++-------\n>  benchtests/Makefile |  2 +-\n>  malloc/Makefile     | 10 ++++++----\n>  3 files changed, 32 insertions(+), 12 deletions(-)\n> \n> diff --git a/Rules b/Rules\n> index 9d8587a148..64a337b265 100644\n> --- a/Rules\n> +++ b/Rules\n> @@ -348,21 +348,39 @@ $(1)-malloc-check-ENV = MALLOC_CHECK_=3 \\\n>  endef\n>  $(foreach t,$(tests-malloc-check),$(eval $(call malloc-check-ENVS,$(t))))\n>  \n> +# Generate environment variable GLIBC_TUNABLES to be appended to\n> +# the test environment, appending tunables specifically added for\n> +# each test to the ambient GLIBC_TUNABLES environment variable.\n> +# The *-TUNABLES-only can be used by a test to override any ambient\n> +# tunables.\n> +define test-tun-joined\n> +$(subst $(empty) ,:,$(strip $($*-TUNABLES)))\n> +endef\n> +define test-tunables-all\n> +$(if $($*-TUNABLES),$(if $(GLIBC_TUNABLES),GLIBC_TUNABLES=$(GLIBC_TUNABLES):$(test-tun-joined),GLIBC_TUNABLES=$(test-tun-joined)),)\n> +endef\n> +define test-tunables-only\n> +GLIBC_TUNABLES=$(subst $(empty) ,:,$(strip $($*-TUNABLES-only)))\n> +endef\n> +define test-tunables\n> +$(if $($*-TUNABLES-only),$(test-tunables-only),$(test-tunables-all))\n> +endef\n> +\n>  # All malloc-hugetlb1 tests will be run with GLIBC_TUNABLES=glibc.malloc.hugetlb=1\n>  define malloc-hugetlb1-ENVS\n> -$(1)-malloc-hugetlb1-ENV += GLIBC_TUNABLES=glibc.malloc.hugetlb=1\n> +$(1)-malloc-hugetlb1-TUNABLES += glibc.malloc.hugetlb=1\n>  endef\n>  $(foreach t,$(tests-malloc-hugetlb1),$(eval $(call malloc-hugetlb1-ENVS,$(t))))\n>  \n>  # All malloc-hugetlb2 tests will be run with GLIBC_TUNABLE=glibc.malloc.hugetlb=2\n>  define malloc-hugetlb2-ENVS\n> -$(1)-malloc-hugetlb2-ENV += GLIBC_TUNABLES=glibc.malloc.hugetlb=2\n> +$(1)-malloc-hugetlb2-TUNABLES += glibc.malloc.hugetlb=2\n>  endef\n>  $(foreach t,$(tests-malloc-hugetlb2),$(eval $(call malloc-hugetlb2-ENVS,$(t))))\n>  \n>  # All malloc-largetcache tests will be run with GLIBC_TUNABLE=glibc.malloc.tcache_max=1048576\n>  define malloc-largetcache-ENVS\n> -$(1)-malloc-largetcache-ENV += GLIBC_TUNABLES=glibc.malloc.tcache_max=1048576\n> +$(1)-malloc-largetcache-TUNABLES += glibc.malloc.tcache_max=1048576\n>  endef\n>  $(foreach t,$(tests-malloc-largetcache),$(eval $(call malloc-largetcache-ENVS,$(t))))\n>  \n> @@ -373,12 +391,12 @@ endef\n>  $(foreach t,$(tests-mcheck),$(eval $(call mcheck-ENVS,$(t))))\n>  \n>  ifneq \"$(strip $(tests) $(tests-container) $(tests-internal) $(xtests) $(test-srcs))\" \"\"\n> +\n>  # These are the implicit rules for making test outputs\n>  # from the test programs and whatever input files are present.\n> -\n>  define make-test-out\n> -$(if $($*-ENV-only),$(test-wrapper-env-only) $($*-ENV-only),\\\n> -     $(test-wrapper-env) $(run-program-env) $($*-ENV)) \\\n> +$(if $($*-ENV-only),$(test-wrapper-env-only) $($*-ENV-only) $(test-tunables),\\\n> +     $(test-wrapper-env) $(run-program-env) $($*-ENV) $(test-tunables)) \\\n>  $(host-test-program-cmd) $($*-ARGS)\n>  endef\n>  $(objpfx)%.out: %.input $(objpfx)%\n> @@ -394,7 +412,7 @@ $(objpfx)%.out: /dev/null $(objpfx)%\t# Make it 2nd arg for canned sequence.\n>  # tests-container.\n>  $(tests-container:%=$(objpfx)%.out): $(objpfx)%.out : $(if $(wildcard $(objpfx)%.files),$(objpfx)%.files,/dev/null) $(objpfx)%\n>  \t$(test-wrapper-env) $(run-program-env) $(test-via-rtld-prefix) \\\n> -\t  $(common-objpfx)support/test-container env $(run-program-env) $($*-ENV) \\\n> +\t  $(common-objpfx)support/test-container env $(run-program-env) $($*-ENV) $(test-tunables) \\\n>  \t  $(host-test-program-cmd) $($*-ARGS) > $@; \\\n>  \t$(evaluate-test)\n>  \n> diff --git a/benchtests/Makefile b/benchtests/Makefile\n> index 156e308451..53f78232ff 100644\n> --- a/benchtests/Makefile\n> +++ b/benchtests/Makefile\n> @@ -447,7 +447,7 @@ bench-deps := bench-skeleton.c bench-timing.h Makefile\n>  \n>  run-bench = $(test-wrapper-env) \\\n>  \t    $(run-program-env) \\\n> -\t    $($*-ENV) $(test-via-rtld-prefix) $${run}\n> +\t    $($*-ENV) $(test-tunables) $(test-via-rtld-prefix) $${run}\n>  \n>  timing-type := $(objpfx)bench-timing-type\n>  extra-objs += bench-timing-type.o\n> diff --git a/malloc/Makefile b/malloc/Makefile\n> index fef5021298..f95bca7f8f 100644\n> --- a/malloc/Makefile\n> +++ b/malloc/Makefile\n> @@ -438,17 +438,19 @@ malloc-check-env = \\\n>    MALLOC_CHECK_=3 \\\n>    LD_PRELOAD=$(objpfx)/libc_malloc_debug.so\n>  \n> -malloc-check-tunables-env = \\\n> -  GLIBC_TUNABLES=glibc.malloc.check=3 \\\n> -  LD_PRELOAD=$(objpfx)/libc_malloc_debug.so\n> -\n>  tst-malloc-check-ENV = $(malloc-check-env)\n>  tst-malloc-usable-ENV = $(malloc-check-env)\n>  tst-malloc-usable-threaded-main-ENV = $(malloc-check-env)\n>  tst-malloc-usable-threaded-worker-ENV = $(malloc-check-env)\n> +\n> +malloc-check-tunables-env = LD_PRELOAD=$(objpfx)/libc_malloc_debug.so\n> +malloc-check-tunables-tun = glibc.malloc.check=3\n>  tst-malloc-usable-tunables-ENV = $(malloc-check-tunables-env)\n> +tst-malloc-usable-tunables-TUNABLES += $(malloc-check-tunables-tun)\n>  tst-malloc-usable-tunables-threaded-main-ENV = $(malloc-check-tunables-env)\n> +tst-malloc-usable-tunables-threaded-main-TUNABLES += $(malloc-check-tunables-tun)\n>  tst-malloc-usable-tunables-threaded-worker-ENV = $(malloc-check-tunables-env)\n> +tst-malloc-usable-tunables-threaded-worker-TUNABLES += $(malloc-check-tunables-tun)\n>  \n>  CPPFLAGS-malloc-debug.c += -DUSE_TCACHE=0\n>  CPPFLAGS-malloc.c += -DUSE_TCACHE=1","headers":{"Return-Path":"<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":["incoming@patchwork.ozlabs.org","libc-alpha@sourceware.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","libc-alpha@sourceware.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=n9F79m68;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=n9F79m68","sourceware.org;\n dmarc=pass (p=none dis=none) header.from=linaro.org","sourceware.org; spf=pass smtp.mailfrom=linaro.org","server2.sourceware.org;\n arc=none smtp.remote-ip=2607:f8b0:4864:20::1234"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g29h96mlSz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 21:28:41 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 253744BB3BEA\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 11:28:40 +0000 (GMT)","from mail-dl1-x1234.google.com (mail-dl1-x1234.google.com\n [IPv6:2607:f8b0:4864:20::1234])\n by sourceware.org (Postfix) with ESMTPS id 1BBEB4BB3BC1\n for <libc-alpha@sourceware.org>; Fri, 24 Apr 2026 11:28:19 +0000 (GMT)","by mail-dl1-x1234.google.com with SMTP id\n a92af1059eb24-12c565476d7so3281635c88.1\n for <libc-alpha@sourceware.org>; Fri, 24 Apr 2026 04:28:19 -0700 (PDT)","from ?IPV6:2804:1b3:a7c0:44cb:6d39:8695:6380:f6f4?\n ([2804:1b3:a7c0:44cb:6d39:8695:6380:f6f4])\n by smtp.gmail.com with ESMTPSA id\n 5a478bee46e88-2e53a4a7ff1sm31270369eec.9.2026.04.24.04.28.15\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Fri, 24 Apr 2026 04:28:17 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 253744BB3BEA","OpenDKIM Filter v2.11.0 sourceware.org 1BBEB4BB3BC1"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 1BBEB4BB3BC1","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 1BBEB4BB3BC1","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777030099; cv=none;\n b=Bkxowf+doWdv6VuZKXdJJ2gGI29WFtFhQLzkHzLeitEm0pa79Dc6Axfgl/JmTS1U+2xVwybfb1YqjhM6ort5veWIWV3+EbYwLw/AQCYymT21VO3uYUi7g0V9C8fhDldQ+G5pise/4o4AoFbfd5sdbegiXKq2KsBz9ZDASgS1pg8=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777030099; c=relaxed/simple;\n bh=TpNCDnCfHW7U/L6eIF0ed3tTKqLw46xxA/yfrJbqRic=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;\n b=UXWTGf7QLBV1bjdlxzO0HSWaZ1LyIiNiMmRlHRtF05TYN3xCVsrUsi9/aSbFI2+ilXAXLT7/MtMH24tp5yTbir6ZgnZXNbdN7BbVeo23Qrug72A6OhBFKX0xTY8ACwbpJCyzoD0DhZDUJDLZPLju0WSfGPA15r7L/5erb2oM5R4=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1777030098; x=1777634898; darn=sourceware.org;\n h=content-transfer-encoding:in-reply-to:organization:from\n :content-language:references:cc:to:subject:user-agent:mime-version\n :date:message-id:from:to:cc:subject:date:message-id:reply-to;\n bh=UNKVS+wXDO5oa2BETgQITqasD5ht03B7KldJ03tgwFM=;\n b=n9F79m68wrIqqr4GbKb9hzFMuZVgAtyGzqXiujbTiLh4FoyHZ6+u4S9wG/ppyxUFbZ\n UmeXfOlDMVY/lYNWDVcGrB7aBbNZbNCRhrUyBNsh+Eo13wG+/5psmesRo5jyCobfL1am\n 3eF+k+XBq40Tz0TPuih+HVzp44eBBDHc3rGY3fadlulv9N1mMavBDjmeQwcI9BAOHFOf\n +OkokY8Ot5Eq6pM5ggYqvyQK558t78eXkhA+0eW4pYq5eSPjoVKGq27ty8PQGMloc6qI\n woZzinF6TWqVGICy+4Gt7XO6QjMzlZcvigCm3sq3wFi1GjLFZSERxVk/LQWUlaolbDtz\n ybzQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777030098; x=1777634898;\n h=content-transfer-encoding:in-reply-to:organization:from\n :content-language:references:cc:to:subject:user-agent:mime-version\n :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=UNKVS+wXDO5oa2BETgQITqasD5ht03B7KldJ03tgwFM=;\n b=F4SvwSDnvB7PNfDMqRpX/9LdqSZ78g90+XNJ0FxEpL8QtxMlH9RGsyCHkxMS4cuvRL\n sSaGThRmkA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kdFfH\n BKAWR2A0awaxrp00Ww6CDZbjY7TjJcRrw4ungJzop8d","X-Received":"by 2002:a05:7300:6da1:b0:2ca:8099:ffc0 with SMTP id\n 5a478bee46e88-2e46538fb7bmr16317929eec.7.1777030097671;\n Fri, 24 Apr 2026 04:28:17 -0700 (PDT)","Message-ID":"<63fd81e1-b789-4a82-89db-a2f868aaa541@linaro.org>","Date":"Fri, 24 Apr 2026 08:28:14 -0300","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v4 1/8] tests: Allow tests to append tunables","To":"Yury Khrustalev <yury.khrustalev@arm.com>, libc-alpha@sourceware.org","Cc":"Andreas Schwab <schwab@suse.de>, Wilco Dijkstra <wilco.dijkstra@arm.com>","References":"<20260421143804.3933020-1-yury.khrustalev@arm.com>\n <20260421143804.3933020-2-yury.khrustalev@arm.com>","Content-Language":"en-US","From":"Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>","Organization":"Linaro","In-Reply-To":"<20260421143804.3933020-2-yury.khrustalev@arm.com>","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit","X-BeenThere":"libc-alpha@sourceware.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Libc-alpha mailing list <libc-alpha.sourceware.org>","List-Unsubscribe":"<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>","List-Archive":"<https://sourceware.org/pipermail/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-request@sourceware.org?subject=help>","List-Subscribe":"<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>","Errors-To":"libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org"}}]