get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.2/patches/2219875/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2219875,
    "url": "http://patchwork.ozlabs.org/api/1.2/patches/2219875/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/20260405035555.558396-1-wangrui@loongson.cn/",
    "project": {
        "id": 41,
        "url": "http://patchwork.ozlabs.org/api/1.2/projects/41/?format=api",
        "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": "<20260405035555.558396-1-wangrui@loongson.cn>",
    "list_archive_url": null,
    "date": "2026-04-05T03:55:54",
    "name": "[v8,5/6] elf: Align large load segments to PMD huge page size for THP",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "9deaf621339c280b149b9cee4530ad6d9f5123c7",
    "submitter": {
        "id": 85150,
        "url": "http://patchwork.ozlabs.org/api/1.2/people/85150/?format=api",
        "name": "WANG Rui",
        "email": "wangrui@loongson.cn"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/glibc/patch/20260405035555.558396-1-wangrui@loongson.cn/mbox/",
    "series": [
        {
            "id": 498763,
            "url": "http://patchwork.ozlabs.org/api/1.2/series/498763/?format=api",
            "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/2219875/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2219875/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=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 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\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 4fpJYd3Ck3z1yD3\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 05 Apr 2026 13:56:53 +1000 (AEST)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 981F94BA23FC\n\tfor <incoming@patchwork.ozlabs.org>; Sun,  5 Apr 2026 03:56:51 +0000 (GMT)",
            "from mail.loongson.cn (mail.loongson.cn [114.242.206.163])\n by sourceware.org (Postfix) with ESMTP id 531674BA2E20\n for <libc-alpha@sourceware.org>; Sun,  5 Apr 2026 03:56:30 +0000 (GMT)",
            "from loongson.cn (unknown [223.64.120.66])\n by gateway (Coremail) with SMTP id _____8DxssBs3dFpxBgiAA--.36586S3;\n Sun, 05 Apr 2026 11:56:28 +0800 (CST)",
            "from localhost (unknown [223.64.120.66])\n by front1 (Coremail) with SMTP id qMiowJBxrsJo3dFpj1JlAA--.45307S2;\n Sun, 05 Apr 2026 11:56:27 +0800 (CST)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org 981F94BA23FC",
            "OpenDKIM Filter v2.11.0 sourceware.org 531674BA2E20"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 531674BA2E20",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 531674BA2E20",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775361391; cv=none;\n b=Qt6tIBplJMZ8Yw3h8rGAOVy+RqACkCPnPIkzBS2QNvEGvNQGZqUElPvc6BCJRleOcEqHDqZzG07FiaQT5dwECZ9A9JPJpVsAFCylhQsnXWZOmSNNO3ymDBzysF1laYFN7yYFmURZdRZw9i+UnxHpdlqdxCbTu3FpnoqpotgHkBY=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1775361391; c=relaxed/simple;\n bh=otQ7k8tq/Qy+oOHD5v0Tac2pXLQ2dHOPyzIBNPy3LcE=;\n h=From:To:Subject:Date:Message-ID:MIME-Version;\n b=P7SS1yevHnMNqPO4PetJ7HfQK0Fl0e/LJNIimWPphuyVQLO2C+JLWUffk9kn5/N6YRKY4yhBMCUDCiFOWJ1nU5bt8ZhfiZz+m52p7Cp3alKjCHRRF6FZIUKQwcQFnqF3dQnuWcLllqs4xMdRbaTeWf4EW0gOnBZmph5W8MU+Y68=",
        "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 5/6] elf: Align large load segments to PMD huge page size\n for THP",
        "Date": "Sun,  5 Apr 2026 11:55:54 +0800",
        "Message-ID": "<20260405035555.558396-1-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": "qMiowJBxrsJo3dFpj1JlAA--.45307S2",
        "X-CM-SenderInfo": "pzdqw2txl6z05rqj20fqof0/",
        "X-Coremail-Antispam": "1Uk129KBj93XoW3GryrKryfJryUuF4rKw4xXwc_yoW7uw1fpF\n WFkF4FkF48JFyjkFWfK3Wjyr1SgF1rGF1jkr13uF9xAw1DGFyIgFZFka43JryxGrWfCa1r\n ZrsFqF98Cr1rZagCm3ZEXasCq-sJn29KB7ZKAUJUUUU7529EdanIXcx71UUUUU7KY7ZEXa\n sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU\n 0xBIdaVrnRJUUUBIb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2\n IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v\n e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI\n 0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v2\n 6r4j6r4UJwAaw2AFwI0_Jrv_JF1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0c\n Ia020Ex4CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Wrv_\n ZF1lYx0Ex4A2jsIE14v26F4j6r4UJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64\n vIr41lc7CjxVAaw2AFwI0_JF0_Jw1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_\n Jr0_Gr1l4IxYO2xFxVAFwI0_Jrv_JF1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8Gjc\n xK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0\n cI8IcVAFwI0_Ar0_tr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwCI42IY6xAIw2\n 0EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x02\n 67AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU0fhLUUUUUU==",
        "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": "Mapping segments that are at least the size of a PMD huge page to\nhuge-page-aligned addresses helps make them eligible for Transparent\nHuge Pages (THP).\n\nThis patch introduces a Linux-specific helper, `_dl_map_segment_align`,\nto determine an appropriate maximum alignment for ELF load segments based\non the system THP policy. The optimization is enabled only when the glibc\ntunable `glibc.elf.thp=1` is set and THP is configured to be used\nunconditionally.\n\nThe optimization depends on Linux kernel support for file-backed THP,\nspecifically:\n\n* `CONFIG_READ_ONLY_THP_FOR_FS` (available since Linux kernel 5.4), and\n* `CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS`.\n\nWhen enabled, the helper queries the default THP page size and uses it\nto align sufficiently large load segments that are already properly\naligned in both virtual address and file offset (e.g., zero).\n\nFor eligible segments, the alignment is bumped to the THP page size,\nwhich improves THP eligibility, reduces TLB pressure, and improves\nperformance for large objects. To avoid excessive address space padding\non systems with very large THP sizes, the alignment is capped at 32MB.\nThe optimization is applied only to non-writable segments, matching\ntypical THP usage.\n\nSigned-off-by: WANG Rui <wangrui@loongson.cn>\n---\n sysdeps/unix/sysv/linux/Makefile              |  1 +\n .../unix/sysv/linux/dl-map-segment-align.c    | 53 +++++++++++++++++++\n .../unix/sysv/linux/dl-map-segment-align.h    | 27 ++++++++++\n 3 files changed, 81 insertions(+)\n create mode 100644 sysdeps/unix/sysv/linux/dl-map-segment-align.c\n create mode 100644 sysdeps/unix/sysv/linux/dl-map-segment-align.h",
    "diff": "diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile\nindex c6bd97abf1a..9879fec9a93 100644\n--- a/sysdeps/unix/sysv/linux/Makefile\n+++ b/sysdeps/unix/sysv/linux/Makefile\n@@ -673,6 +673,7 @@ endif\n \n ifeq ($(subdir),elf)\n dl-routines += \\\n+  dl-map-segment-align \\\n   dl-rseq-symbols \\\n   # dl-routines\n \ndiff --git a/sysdeps/unix/sysv/linux/dl-map-segment-align.c b/sysdeps/unix/sysv/linux/dl-map-segment-align.c\nnew file mode 100644\nindex 00000000000..75fb0496730\n--- /dev/null\n+++ b/sysdeps/unix/sysv/linux/dl-map-segment-align.c\n@@ -0,0 +1,53 @@\n+/* _dl_map_segment_align.  Linux version.\n+   Copyright (C) 2026 Free Software Foundation, Inc.\n+   Copyright The GNU Toolchain Authors.\n+   This file is part of the GNU C Library.\n+\n+   The GNU C Library is free software; you can redistribute it and/or\n+   modify it under the terms of the GNU Lesser General Public\n+   License as published by the Free Software Foundation; either\n+   version 2.1 of the License, or (at your option) any later version.\n+\n+   The GNU C Library is distributed in the hope that it will be useful,\n+   but WITHOUT ANY WARRANTY; without even the implied warranty of\n+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+   Lesser General Public License for more details.\n+\n+   You should have received a copy of the GNU Lesser General Public\n+   License along with the GNU C Library; if not, see\n+   <https://www.gnu.org/licenses/>.  */\n+\n+#include <dl-map-segment-align.h>\n+#include <dl-tunables.h>\n+#include <hugepages.h>\n+\n+ElfW (Addr)\n+_dl_map_segment_align (const struct loadcmd *c, ElfW (Addr) p_align_max)\n+{\n+  static enum thp_mode_t thp_mode = thp_mode_not_supported;\n+  static unsigned long int thp_pagesize;\n+\n+  if (TUNABLE_GET (glibc, elf, thp, int32_t, NULL) == 0)\n+    return p_align_max;\n+\n+  if (__glibc_unlikely (thp_mode == thp_mode_not_supported\n+\t\t\t|| thp_pagesize == 0))\n+    {\n+      unsigned long int default_thp_pagesize = DL_MAP_DEFAULT_THP_PAGESIZE;\n+      thp_mode = default_thp_pagesize ? thp_mode_always : __get_thp_mode ();\n+      thp_pagesize = default_thp_pagesize ? : __get_thp_size ();\n+    }\n+\n+  /* Aligning load segments that are large enough to the PMD size helps\n+     improve THP eligibility and reduces TLB pressure.\n+     We cap the huge page size at MAX_THP_PAGESIZE to avoid over-aligning\n+     on systems with very large normal pages (like 64K pages with 512M\n+     huge pages). */\n+  if (thp_mode == thp_mode_always && thp_pagesize <= MAX_THP_PAGESIZE\n+      && ((c->mapstart | c->mapoff) & (thp_pagesize - 1)) == 0\n+      && (c->mapend - c->mapstart) >= thp_pagesize\n+      && p_align_max < thp_pagesize && (c->prot & PROT_WRITE) == 0)\n+    return thp_pagesize;\n+\n+  return p_align_max;\n+}\ndiff --git a/sysdeps/unix/sysv/linux/dl-map-segment-align.h b/sysdeps/unix/sysv/linux/dl-map-segment-align.h\nnew file mode 100644\nindex 00000000000..83794a03986\n--- /dev/null\n+++ b/sysdeps/unix/sysv/linux/dl-map-segment-align.h\n@@ -0,0 +1,27 @@\n+/* _dl_map_segment_align.  Linux version.\n+   Copyright (C) 2026 Free Software Foundation, Inc.\n+   Copyright The GNU Toolchain Authors.\n+   This file is part of the GNU C Library.\n+\n+   The GNU C Library is free software; you can redistribute it and/or\n+   modify it under the terms of the GNU Lesser General Public\n+   License as published by the Free Software Foundation; either\n+   version 2.1 of the License, or (at your option) any later version.\n+\n+   The GNU C Library is distributed in the hope that it will be useful,\n+   but WITHOUT ANY WARRANTY; without even the implied warranty of\n+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+   Lesser General Public License for more details.\n+\n+   You should have received a copy of the GNU Lesser General Public\n+   License along with the GNU C Library; if not, see\n+   <https://www.gnu.org/licenses/>.  */\n+\n+#include <dl-load.h>\n+\n+#ifndef DL_MAP_DEFAULT_THP_PAGESIZE\n+# define DL_MAP_DEFAULT_THP_PAGESIZE\t0\n+#endif\n+\n+ElfW (Addr)\n+    _dl_map_segment_align (const struct loadcmd *c, ElfW (Addr) p_align_max);\n",
    "prefixes": [
        "v8",
        "5/6"
    ]
}