{"id":2219873,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2219873/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/patch/20260405035323.558335-5-wangrui@loongson.cn/","project":{"id":41,"url":"http://patchwork.ozlabs.org/api/1.2/projects/41/?format=json","name":"GNU C Library","link_name":"glibc","list_id":"libc-alpha.sourceware.org","list_email":"libc-alpha@sourceware.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260405035323.558335-5-wangrui@loongson.cn>","list_archive_url":null,"date":"2026-04-05T03:53:20","name":"[v8,4/6] tunables: Add glibc.elf.thp tunable for THP-aware segment alignment","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"f25a5a9b8e909c0e0daf4bcfe0fc17b6f64e4f38","submitter":{"id":85150,"url":"http://patchwork.ozlabs.org/api/1.2/people/85150/?format=json","name":"WANG Rui","email":"wangrui@loongson.cn"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/glibc/patch/20260405035323.558335-5-wangrui@loongson.cn/mbox/","series":[{"id":498763,"url":"http://patchwork.ozlabs.org/api/1.2/series/498763/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/list/?series=498763","date":"2026-04-05T03:53:16","name":"elf: THP-aware load segment alignment","version":8,"mbox":"http://patchwork.ozlabs.org/series/498763/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2219873/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219873/checks/","tags":{},"related":[],"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 spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=38.145.34.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 dmarc=none (p=none dis=none) header.from=loongson.cn","sourceware.org; spf=pass smtp.mailfrom=loongson.cn","server2.sourceware.org;\n arc=none smtp.remote-ip=114.242.206.163"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 4fpJW21Y9Zz1yFs\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 05 Apr 2026 13:54:38 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 650634BA9004\n\tfor <incoming@patchwork.ozlabs.org>; Sun,  5 Apr 2026 03:54:36 +0000 (GMT)","from mail.loongson.cn (mail.loongson.cn [114.242.206.163])\n by sourceware.org (Postfix) with ESMTP id 891824BA23FE\n for <libc-alpha@sourceware.org>; Sun,  5 Apr 2026 03:54:15 +0000 (GMT)","from loongson.cn (unknown [223.64.120.66])\n by gateway (Coremail) with SMTP id _____8DxAfHi3NFpoBgiAA--.30399S3;\n Sun, 05 Apr 2026 11:54:10 +0800 (CST)","from localhost (unknown [223.64.120.66])\n by front1 (Coremail) with SMTP id qMiowJBxDOHK3NFpP1JlAA--.44692S6;\n Sun, 05 Apr 2026 11:54:06 +0800 (CST)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 650634BA9004","OpenDKIM Filter v2.11.0 sourceware.org 891824BA23FE"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 891824BA23FE","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 891824BA23FE","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775361256; cv=none;\n b=YmtC2uQb54WFnYJKNuU5KP/ByyyKsu0OtPDu0YssxDCuTI1QhhfXdV9bzPiao4QkGEHr9Qi+bxuNN84EHozQI5XgFwGV7UWQSLGu7cvkwzMwaM4xFqSKVlh5VwN6WItyUb7eHFw/IpgLdvMixwpMc7a2JK1rfxjljc4rDw2ic1U=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1775361256; c=relaxed/simple;\n bh=R6Yv29w4nzNxZJlsdjeV5hcaHovFXPv2WKsbGFl1ft0=;\n h=From:To:Subject:Date:Message-ID:MIME-Version;\n b=gpGktMyHzkNr59Wlf2WdEBxJ98XNpn84uswha8eijsLWPW9Uycxrvomhxkm3iSqQ7qGYa/uzVWMCCTHaO1ORrbCexaAj4HZx1ErWatzI7/rWzngCPD1hd8aiJkqJtq86jFlvo603QdkjbN8WgUaGiOEuwMShe75cq57Z3O1lYmE=","ARC-Authentication-Results":"i=1; server2.sourceware.org","From":"WANG Rui <wangrui@loongson.cn>","To":"libc-alpha@sourceware.org","Cc":"Adhemerval Zanella <adhemerval.zanella@linaro.org>,\n Dev Jain <dev.jain@arm.com>, Florian Weimer <fweimer@redhat.com>,\n Wilco Dijkstra <Wilco.Dijkstra@arm.com>, Xi Ruoyao <xry111@xry111.site>,\n WANG Xuerui <git@xen0n.name>, caiyinyu <caiyinyu@loongson.cn>,\n mengqinggang <mengqinggang@loongson.cn>,\n Huacai Chen <chenhuacai@kernel.org>, hjl.tools@gmail.com,\n WANG Rui <wangrui@loongson.cn>","Subject":"[PATCH v8 4/6] tunables: Add glibc.elf.thp tunable for THP-aware\n segment alignment","Date":"Sun,  5 Apr 2026 11:53:20 +0800","Message-ID":"<20260405035323.558335-5-wangrui@loongson.cn>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260405035323.558335-1-wangrui@loongson.cn>","References":"<20260405035323.558335-1-wangrui@loongson.cn>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-CM-TRANSID":"qMiowJBxDOHK3NFpP1JlAA--.44692S6","X-CM-SenderInfo":"pz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VW8JVWxJwCI42IY6xAIw20EY4\n v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AK\n xVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IUneRRtUUUUU==","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"},"content":"Introduce a new tunable, `glibc.elf.thp`, to control Transparent Huge\nPage (THP) aware alignment of ELF loadable segments.\n\nWhen set to `1`, the dynamic loader will attempt to align sufficiently\nlarge `PT_LOAD` segments to the PMD huge page size when mapping them.\nThis increases the likelihood that the kernel backs these mappings with\nTransparent Huge Pages.\n\nThe default value is `0`, which preserves the traditional page-sized\nalignment and keeps existing behavior unchanged.\n\nOn systems without THP support, or when THP is disabled in the kernel,\nenabling this tunable has no effect.\n\nReviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>\nSigned-off-by: WANG Rui <wangrui@loongson.cn>\n---\n elf/dl-tunables.list |  8 ++++++++\n manual/tunables.texi | 24 ++++++++++++++++++++++++\n 2 files changed, 32 insertions(+)","diff":"diff --git a/elf/dl-tunables.list b/elf/dl-tunables.list\nindex 040a544c0e0..1bbf70d36fa 100644\n--- a/elf/dl-tunables.list\n+++ b/elf/dl-tunables.list\n@@ -24,6 +24,14 @@\n # env_alias: An alias environment variable\n \n glibc {\n+  elf {\n+    thp {\n+      type: INT_32\n+      minval: 0\n+      maxval: 1\n+    }\n+  }\n+\n   malloc {\n     check {\n       type: INT_32\ndiff --git a/manual/tunables.texi b/manual/tunables.texi\nindex 72769428e8c..389690d840b 100644\n--- a/manual/tunables.texi\n+++ b/manual/tunables.texi\n@@ -64,6 +64,7 @@ glibc.pthread.mutex_spin_count: 100 (min: 0, max: 32767)\n glibc.rtld.optional_static_tls: 0x200 (min: 0x0, max: 0xffffffffffffffff)\n glibc.malloc.tcache_max: 0x0 (min: 0x0, max: 0xffffffffffffffff)\n glibc.malloc.check: 0 (min: 0, max: 3)\n+glibc.elf.thp: 0 (min: 0, max: 1)\n @end example\n \n @menu\n@@ -77,6 +78,8 @@ glibc.malloc.check: 0 (min: 0, max: 3)\n \t\t\t     @theglibc{}.\n * gmon Tunables::  Tunables that control the gmon profiler, used in\n                    conjunction with gprof\n+* ELF Tunables::  Tunables that control Transparent Huge Page (THP)\n+                  aware alignment of ELF loadable segments\n \n @end menu\n \n@@ -763,3 +766,24 @@ whose size exceeds the available memory; in that case, an out of memory\n error will be printed at program startup, the profiler will be\n disabled, and no @file{gmon.out} file will be generated.\n @end deftp\n+\n+@node ELF Tunables\n+@section ELF Tunables\n+@cindex elf tunables\n+\n+@deftp Tunable glibc.elf.thp\n+This tunable controls Transparent Huge Page (THP) aware alignment of\n+ELF loadable segments.\n+\n+The default value is @code{0}, which preserves the traditional page-sized\n+alignment for loadable segments.\n+\n+If set to @code{1}, glibc will attempt to align sufficiently large\n+@code{PT_LOAD} segments to the PMD huge page size when mapping them\n+with @code{mmap}.  This increases the likelihood that the kernel can\n+back these mappings with Transparent Huge Pages.\n+\n+This tunable has an effect only on systems that support Transparent\n+Huge Pages (currently Linux).  On other systems, or if THP is disabled\n+at the kernel level, enabling this tunable has no effect.\n+@end deftp\n","prefixes":["v8","4/6"]}