GNU C Library master sources
  • C 77.1%
  • Assembly 13.2%
  • Pawn 5.7%
  • Makefile 1.2%
  • Python 1%
  • Other 1.6%
Find a file
H.J. Lu 53d909a283 elf: Support THP segment load with madvise enabled THP
The current THP segment load approach works only when THP is enabled
with always in the kernel.  If THP is enabled with madvise in the
kernel, to enable THP segment load in an application, madvise should
be called with MADV_HUGEPAGE on all THP eligible PT_LOAD segments:

1. Define DL_MAP_DEFAULT_THP_PAGESIZE in hugepages.h and default it to 0.
If DL_MAP_DEFAULT_THP_PAGESIZE is defined, assume kernel THP madvise mode.
If kernel THP mode is always or never, there is an extra madvise call
which has no impact.  DL_MAP_DEFAULT_THP_PAGESIZE is defined for x86-64
and 64-bit loongarch.
2. Update _dl_map_segment_align to support madvise THP mode.  This fixes
BZ #34079.
3. Call _dl_executable_postprocess in rtld_setup_main_map for dynamic
executables and in LIBC_START_MAIN for static executables, which calls
madvise with MADV_HUGEPAGE on all THP eligible PT_LOAD segments in
executable.  This fixes BZ #34080 for both dynamic and static executables.
4. Call _dl_postprocess_loadcmd_extra in _dl_postprocess_loadcmd, which
calls madvise with MADV_HUGEPAGE on all THP eligible PT_LOAD segments
when loading an object after they have been mapped in.  This fixes
BZ #34080 for shared objects.
5. Set the maximum page alignment on THP tests to THP page size as the
default maximum page alignment may be smaller than THP page size.
6. Add tests to verify that large executable PT_LOAD segments in
executables are mapped at addresses aligned to THP page size when the
kernel is configured to use THP in "always" mode or "madvise" mode by
inspecting /proc/self/maps to check that the mapping address is aligned
to THP page size reported by the kernel.  Also verify that madvise is
called with MADV_HUGEPAGE when the glibc tunable glibc.elf.thp=1 is used
and madvise isn't called with MADV_HUGEPAGE when the glibc tunable
glibc.elf.thp=0 is used.

Skip these tests if THP page size cannot be determined or if THP is not
enabled in "always" mode nor "madvise" mode.

Quote WANG Rui <wangrui@loongson.cn>:

From benchmarking a clang build of the Linux kernel on x86_64 with
your patch in THP madvise mode, I observed that iTLB misses were
reduced, similar to what we see in THP always mode.

NB: Some THP tests fail on arm due to limitations of arm32 kABI:

https://sourceware.org/bugzilla/show_bug.cgi?id=34096

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2026-06-20 05:35:24 +08:00
advisories advisories: Update GLIBC-SA-2026-0012 metadata 2026-06-19 16:30:41 -04:00
argp
assert test-assert-c++-variadic.cc: Disable assert_works for GCC 14.2 and 14.1 2026-03-10 13:24:50 -03:00
benchtests tests: Allow tests to append tunables 2026-04-27 10:45:20 +01:00
bits AArch64: Implement AdvSIMD and SVE powr(f) routines 2026-04-20 13:01:25 -03:00
catgets
ChangeLog.old
conform posix: Add POSIX aliases to some spawn functions 2026-04-07 13:21:13 -03:00
csu elf: Support THP segment load with madvise enabled THP 2026-06-20 05:35:24 +08:00
ctype
debug
dirent io: Use gnulib fts implementation (BZ 22944, BZ 20331) 2026-04-03 07:50:18 -03:00
dlfcn elf: Don't crash in dlsym when tail-called from a constructor [BZ #34156] 2026-05-20 17:22:07 -03:00
elf elf: Support THP segment load with madvise enabled THP 2026-06-20 05:35:24 +08:00
gmon tests: gmon: Use new tunable handling 2026-04-27 10:45:20 +01:00
gnulib
hesiod hesiod: use booleans in parser macro calls 2026-05-29 13:58:58 -03:00
htl elf: directly call dl_init_static_tls 2026-03-16 05:29:06 +00:00
hurd hurd: Fix looking up /dev/tty/ (BZ 34070) 2026-04-15 00:41:31 +02:00
iconv iconv: Suppress intermediate errors with //TRANSLIT (bug 34236) 2026-06-09 07:28:02 +02:00
iconvdata Use pending character state in IBM1390, IBM1399 character sets (CVE-2026-4046) 2026-04-16 19:13:43 +02:00
include resolv: Declare __p_class_syms, __p_type_syms for internal use 2026-06-19 18:22:20 +02:00
inet inet: Remove unused STATIC_NSS define 2026-06-15 15:00:03 +00:00
intl intl: Fix tst-gettext under inherited LC_* environment 2026-05-25 13:51:20 +00:00
io io: Consolidate ftw implementation 2026-04-20 13:01:25 -03:00
libio libio: use _IO_have_wbackup for wide streams 2026-06-08 17:01:15 +02:00
locale locale: memory leak in newlocale [BZ #25770] 2026-04-28 15:25:30 -03:00
localedata test: Fix and stabilize tst-wcsmbs-clone-overflow test 2026-05-29 11:34:20 +02:00
login
mach
malloc malloc: aarch64: Add ifuncs for malloc functions 2026-06-15 13:40:22 +01:00
manual Remove unused THREAD_SET_POINTER_GUARD and THREAD_COPY_POINTER_GUARD 2026-06-19 14:23:05 -03:00
math math: Sync acosh with CORE-MATH 887cab6f 2026-06-15 17:41:15 +00:00
mathvec
misc misc: add a new test for gethostname 2026-05-29 13:58:58 -03:00
nis
nptl Remove unused THREAD_SET_POINTER_GUARD and THREAD_COPY_POINTER_GUARD 2026-06-19 14:23:05 -03:00
nptl_db
nscd nscd: Typo in comment 2026-06-08 17:32:27 +02:00
nss nss: Remove <gnu/lib-names.h> include from nsswitch.c 2026-06-15 14:59:41 +00:00
po
posix posix: fix false regex match with backrefs and $ anchor 2026-04-24 17:38:59 -07:00
resolv resolv: Add test case tst-ns_sprintrr (bug 34033, bug 34069) 2026-06-19 18:22:20 +02:00
resource
rt resolv, rt: Change some extern inline functions to static inline 2026-05-08 19:53:24 +02:00
scripts Use Linux 7.0, MPC 1.4.1 in build-many-glibcs.py 2026-05-01 00:26:05 +00:00
setjmp
signal Fix Makefile alphabetical ordering 2026-03-05 14:28:26 +01:00
socket
soft-fp Fix -Werror=constant-logical-operand errors in soft-fp 2026-06-10 16:33:27 +00:00
stdio-common Fix -Wconstant-logical-operand error in tst-printf-format-skeleton.c 2026-06-10 14:01:34 +00:00
stdlib support: Add use_stack_min option to support_small_thread_stack_size 2026-05-20 11:49:09 -03:00
string string: Improve memchr random test 2026-06-18 19:44:31 +00:00
sunrpc sunrpc/Makefile: Split and sort tests 2026-05-27 08:15:34 -04:00
support elf: Support THP segment load with madvise enabled THP 2026-06-20 05:35:24 +08:00
sysdeps elf: Support THP segment load with madvise enabled THP 2026-06-20 05:35:24 +08:00
sysvipc
termios
time tests: time: Use new tunable handling 2026-04-27 10:45:20 +01:00
timezone Fix hurd bootstrap after 4c6f92daea 2026-05-20 14:55:00 -03:00
wcsmbs test: Fix and stabilize tst-wcsmbs-clone-overflow test 2026-05-29 11:34:20 +02:00
wctype
.b4-config
.clang-format
.gitattributes
.gitignore
abi-tags
aclocal.m4
config.h.in malloc: aarch64: Remove broken memory tagging 2026-05-31 16:11:23 +01:00
config.make.in malloc: aarch64: Remove broken memory tagging 2026-05-31 16:11:23 +01:00
configure malloc: aarch64: Remove broken memory tagging 2026-05-31 16:11:23 +01:00
configure.ac malloc: aarch64: Remove broken memory tagging 2026-05-31 16:11:23 +01:00
CONTRIBUTED-BY CONTRIBUTED-BY: Adjustments regarding s390-32, s390-64 2026-04-20 13:54:14 +02:00
COPYING.LESSERv2
COPYING.LIB
COPYINGv2
COPYINGv3
extra-lib.mk
gen-gconv-modules.mk test: Fix and stabilize tst-wcsmbs-clone-overflow test 2026-05-29 11:34:20 +02:00
gen-locales.mk
INSTALL malloc: aarch64: Remove broken memory tagging 2026-05-31 16:11:23 +01:00
libc-abis
libof-iterator.mk
LICENSES
MAINTAINERS
Makeconfig resolv: Move libanl symbols to libc on hurd too 2026-03-15 21:24:00 +01:00
Makefile Makefile: add allow-list for failures 2026-03-19 14:09:22 +01:00
Makefile.help
Makefile.in
Makerules configure: Repurpose have-cc-with-libunwind for clang support 2026-03-12 13:52:50 -03:00
NEWS news: Describe AArch64-specific changes for 2.44 2026-06-18 14:46:42 +01:00
o-iterator.mk
README README: fix stale bug-reporting URL [BZ #34094] 2026-04-28 15:15:50 -03:00
Rules support: Skip malloc hugetlb={1,2} variants when kernel cannot honor them 2026-05-27 15:51:21 -03:00
SECURITY.md Update link in SECURITY.md. 2026-04-29 19:01:13 -07:00
SHARED-FILES math: Sync acosh with CORE-MATH 887cab6f 2026-06-15 17:41:15 +00:00
shlib-versions Support loading libunwind instead of libgcc_s 2026-03-12 13:52:50 -03:00
test-skeleton.c
version.h

This directory contains the sources of the GNU C Library.
See the file "version.h" for what release version you have.

The GNU C Library is the standard system C library for all GNU systems,
and is an important part of what makes up a GNU system.  It provides the
system API for all programs written in C and C-compatible languages such
as C++ and Objective C; the runtime facilities of other programming
languages use the C library to access the underlying operating system.

In GNU/Linux systems, the C library works with the Linux kernel to
implement the operating system behavior seen by user applications.
In GNU/Hurd systems, it works with a microkernel and Hurd servers.

The GNU C Library implements much of the POSIX.1 functionality in the
GNU/Hurd system, using configurations i[4567]86-*-gnu and x86_64-gnu.

When working with Linux kernels, this version of the GNU C Library
requires Linux kernel version 3.2 or later.

Also note that the shared version of the libgcc_s library must be
installed for the pthread library to work correctly.

The GNU C Library supports these configurations for using Linux kernels:

	aarch64*-*-linux-gnu
	alpha*-*-linux-gnu
	arc*-*-linux-gnu
	arm-*-linux-gnueabi
	csky-*-linux-gnuabiv2
	hppa-*-linux-gnu
	i[4567]86-*-linux-gnu
	x86_64-*-linux-gnu	Can build either x86_64 or x32
	loongarch64-*-linux-gnu Hardware floating point, LE only.
	m68k-*-linux-gnu
	microblaze*-*-linux-gnu
	mips-*-linux-gnu
	mips64-*-linux-gnu
	or1k-*-linux-gnu
	powerpc-*-linux-gnu	Hardware or software floating point, BE only.
	powerpc64*-*-linux-gnu	Big-endian and little-endian.
	s390x-*-linux-gnu
	riscv32-*-linux-gnu
	riscv64-*-linux-gnu
	sh[34]-*-linux-gnu
	sparc*-*-linux-gnu
	sparc64*-*-linux-gnu

If you are interested in doing a port, please contact the glibc
maintainers; see https://www.gnu.org/software/libc/ for more
information.

See the file INSTALL to find out how to configure, build, and install
the GNU C Library.  You might also consider reading the WWW pages for
the C library at https://www.gnu.org/software/libc/.

The GNU C Library is (almost) completely documented by the Texinfo manual
found in the `manual/' subdirectory.  The manual is still being updated
and contains some known errors and omissions; we regret that we do not
have the resources to work on the manual as much as we would like.  For
corrections to the manual, please file a bug in the `manual' component,
following the bug-reporting instructions below.  Please be sure to check
the manual in the current development sources to see if your problem has
already been corrected.

Please see https://sourceware.org/glibc/wiki/Bugzilla%20Procedures for bug
reporting information.  We are now using the Bugzilla system to track all
bug reports.  This web page gives detailed information on how to report
bugs properly.

The GNU C Library is free software.  See the file COPYING.LIB for copying
conditions, and LICENSES for notices about a few contributions that require
these additional notices to be distributed.  License copyright years may be
listed using range notation, e.g., 1996-2015, indicating that every year in
the range, inclusive, is a copyrightable year that would otherwise be listed
individually.