elf: Make glibc.rtld.enable_secure ignore alias environment variables
[glibc.git] / manual / tunables.texi
blobbaaf751721f71bccd2629fdef8f42fe818440c8f
1 @node Tunables
2 @c @node Tunables, , Internal Probes, Top
3 @c %MENU% Tunable switches to alter libc internal behavior
4 @chapter Tunables
5 @cindex tunables
7 @dfn{Tunables} are a feature in @theglibc{} that allows application authors and
8 distribution maintainers to alter the runtime library behavior to match
9 their workload. These are implemented as a set of switches that may be
10 modified in different ways. The current default method to do this is via
11 the @env{GLIBC_TUNABLES} environment variable by setting it to a string
12 of colon-separated @var{name}=@var{value} pairs.  For example, the following
13 example enables @code{malloc} checking and sets the @code{malloc}
14 trim threshold to 128
15 bytes:
17 @example
18 GLIBC_TUNABLES=glibc.malloc.trim_threshold=128:glibc.malloc.check=3
19 export GLIBC_TUNABLES
20 @end example
22 Tunables are not part of the @glibcadj{} stable ABI, and they are
23 subject to change or removal across releases.  Additionally, the method to
24 modify tunable values may change between releases and across distributions.
25 It is possible to implement multiple `frontends' for the tunables allowing
26 distributions to choose their preferred method at build time.
28 Finally, the set of tunables available may vary between distributions as
29 the tunables feature allows distributions to add their own tunables under
30 their own namespace.
32 Passing @option{--list-tunables} to the dynamic loader to print all
33 tunables with minimum and maximum values:
35 @example
36 $ /lib64/ld-linux-x86-64.so.2 --list-tunables
37 glibc.rtld.nns: 0x4 (min: 0x1, max: 0x10)
38 glibc.elision.skip_lock_after_retries: 3 (min: 0, max: 2147483647)
39 glibc.malloc.trim_threshold: 0x0 (min: 0x0, max: 0xffffffffffffffff)
40 glibc.malloc.perturb: 0 (min: 0, max: 255)
41 glibc.cpu.x86_shared_cache_size: 0x100000 (min: 0x0, max: 0xffffffffffffffff)
42 glibc.pthread.rseq: 1 (min: 0, max: 1)
43 glibc.cpu.prefer_map_32bit_exec: 0 (min: 0, max: 1)
44 glibc.mem.tagging: 0 (min: 0, max: 255)
45 glibc.elision.tries: 3 (min: 0, max: 2147483647)
46 glibc.elision.enable: 0 (min: 0, max: 1)
47 glibc.malloc.hugetlb: 0x0 (min: 0x0, max: 0xffffffffffffffff)
48 glibc.cpu.x86_rep_movsb_threshold: 0x2000 (min: 0x100, max: 0xffffffffffffffff)
49 glibc.malloc.mxfast: 0x0 (min: 0x0, max: 0xffffffffffffffff)
50 glibc.rtld.dynamic_sort: 2 (min: 1, max: 2)
51 glibc.elision.skip_lock_busy: 3 (min: 0, max: 2147483647)
52 glibc.malloc.top_pad: 0x20000 (min: 0x0, max: 0xffffffffffffffff)
53 glibc.cpu.x86_rep_stosb_threshold: 0x800 (min: 0x1, max: 0xffffffffffffffff)
54 glibc.cpu.x86_non_temporal_threshold: 0xc0000 (min: 0x4040, max: 0xfffffffffffffff)
55 glibc.cpu.x86_shstk:
56 glibc.pthread.stack_cache_size: 0x2800000 (min: 0x0, max: 0xffffffffffffffff)
57 glibc.cpu.hwcap_mask: 0x6 (min: 0x0, max: 0xffffffffffffffff)
58 glibc.malloc.mmap_max: 0 (min: 0, max: 2147483647)
59 glibc.elision.skip_trylock_internal_abort: 3 (min: 0, max: 2147483647)
60 glibc.cpu.plt_rewrite: 0 (min: 0, max: 2)
61 glibc.malloc.tcache_unsorted_limit: 0x0 (min: 0x0, max: 0xffffffffffffffff)
62 glibc.cpu.x86_ibt:
63 glibc.cpu.hwcaps:
64 glibc.elision.skip_lock_internal_abort: 3 (min: 0, max: 2147483647)
65 glibc.malloc.arena_max: 0x0 (min: 0x1, max: 0xffffffffffffffff)
66 glibc.malloc.mmap_threshold: 0x0 (min: 0x0, max: 0xffffffffffffffff)
67 glibc.cpu.x86_data_cache_size: 0x8000 (min: 0x0, max: 0xffffffffffffffff)
68 glibc.malloc.tcache_count: 0x0 (min: 0x0, max: 0xffffffffffffffff)
69 glibc.malloc.arena_test: 0x0 (min: 0x1, max: 0xffffffffffffffff)
70 glibc.pthread.mutex_spin_count: 100 (min: 0, max: 32767)
71 glibc.rtld.optional_static_tls: 0x200 (min: 0x0, max: 0xffffffffffffffff)
72 glibc.malloc.tcache_max: 0x0 (min: 0x0, max: 0xffffffffffffffff)
73 glibc.malloc.check: 0 (min: 0, max: 3)
74 @end example
76 @menu
77 * Tunable names::  The structure of a tunable name
78 * Memory Allocation Tunables::  Tunables in the memory allocation subsystem
79 * Dynamic Linking Tunables:: Tunables in the dynamic linking subsystem
80 * Elision Tunables::  Tunables in elision subsystem
81 * POSIX Thread Tunables:: Tunables in the POSIX thread subsystem
82 * Hardware Capability Tunables::  Tunables that modify the hardware
83                                   capabilities seen by @theglibc{}
84 * Memory Related Tunables::  Tunables that control the use of memory by
85                              @theglibc{}.
86 * gmon Tunables::  Tunables that control the gmon profiler, used in
87                    conjunction with gprof
89 @end menu
91 @node Tunable names
92 @section Tunable names
93 @cindex Tunable names
94 @cindex Tunable namespaces
96 A tunable name is split into three components, a top namespace, a tunable
97 namespace and the tunable name. The top namespace for tunables implemented in
98 @theglibc{} is @code{glibc}. Distributions that choose to add custom tunables
99 in their maintained versions of @theglibc{} may choose to do so under their own
100 top namespace.
102 The tunable namespace is a logical grouping of tunables in a single
103 module. This currently holds no special significance, although that may
104 change in the future.
106 The tunable name is the actual name of the tunable. It is possible that
107 different tunable namespaces may have tunables within them that have the
108 same name, likewise for top namespaces. Hence, we only support
109 identification of tunables by their full name, i.e. with the top
110 namespace, tunable namespace and tunable name, separated by periods.
112 @node Memory Allocation Tunables
113 @section Memory Allocation Tunables
114 @cindex memory allocation tunables
115 @cindex malloc tunables
116 @cindex tunables, malloc
118 @deftp {Tunable namespace} glibc.malloc
119 Memory allocation behavior can be modified by setting any of the
120 following tunables in the @code{malloc} namespace:
121 @end deftp
123 @deftp Tunable glibc.malloc.check
124 This tunable supersedes the @env{MALLOC_CHECK_} environment variable and is
125 identical in features. This tunable has no effect by default and needs the
126 debug library @file{libc_malloc_debug} to be preloaded using the
127 @code{LD_PRELOAD} environment variable.
129 Setting this tunable to a non-zero value less than 4 enables a special (less
130 efficient) memory allocator for the @code{malloc} family of functions that is
131 designed to be tolerant against simple errors such as double calls of
132 free with the same argument, or overruns of a single byte (off-by-one
133 bugs). Not all such errors can be protected against, however, and memory
134 leaks can result.  Any detected heap corruption results in immediate
135 termination of the process.
137 Like @env{MALLOC_CHECK_}, @code{glibc.malloc.check} has a problem in that it
138 diverges from normal program behavior by writing to @code{stderr}, which could
139 by exploited in SUID and SGID binaries.  Therefore, @code{glibc.malloc.check}
140 is disabled by default for SUID and SGID binaries.
141 @end deftp
143 @deftp Tunable glibc.malloc.top_pad
144 This tunable supersedes the @env{MALLOC_TOP_PAD_} environment variable and is
145 identical in features.
147 This tunable determines the amount of extra memory in bytes to obtain from the
148 system when any of the arenas need to be extended.  It also specifies the
149 number of bytes to retain when shrinking any of the arenas.  This provides the
150 necessary hysteresis in heap size such that excessive amounts of system calls
151 can be avoided.
153 The default value of this tunable is @samp{131072} (128 KB).
154 @end deftp
156 @deftp Tunable glibc.malloc.perturb
157 This tunable supersedes the @env{MALLOC_PERTURB_} environment variable and is
158 identical in features.
160 If set to a non-zero value, memory blocks are initialized with values depending
161 on some low order bits of this tunable when they are allocated (except when
162 allocated by @code{calloc}) and freed.  This can be used to debug the use of
163 uninitialized or freed heap memory. Note that this option does not guarantee
164 that the freed block will have any specific values. It only guarantees that the
165 content the block had before it was freed will be overwritten.
167 The default value of this tunable is @samp{0}.
168 @end deftp
170 @deftp Tunable glibc.malloc.mmap_threshold
171 This tunable supersedes the @env{MALLOC_MMAP_THRESHOLD_} environment variable
172 and is identical in features.
174 When this tunable is set, all chunks larger than this value in bytes are
175 allocated outside the normal heap, using the @code{mmap} system call. This way
176 it is guaranteed that the memory for these chunks can be returned to the system
177 on @code{free}. Note that requests smaller than this threshold might still be
178 allocated via @code{mmap}.
180 If this tunable is not set, the default value is set to @samp{131072} bytes and
181 the threshold is adjusted dynamically to suit the allocation patterns of the
182 program.  If the tunable is set, the dynamic adjustment is disabled and the
183 value is set as static.
184 @end deftp
186 @deftp Tunable glibc.malloc.trim_threshold
187 This tunable supersedes the @env{MALLOC_TRIM_THRESHOLD_} environment variable
188 and is identical in features.
190 The value of this tunable is the minimum size (in bytes) of the top-most,
191 releasable chunk in an arena that will trigger a system call in order to return
192 memory to the system from that arena.
194 If this tunable is not set, the default value is set as 128 KB and the
195 threshold is adjusted dynamically to suit the allocation patterns of the
196 program.  If the tunable is set, the dynamic adjustment is disabled and the
197 value is set as static.
198 @end deftp
200 @deftp Tunable glibc.malloc.mmap_max
201 This tunable supersedes the @env{MALLOC_MMAP_MAX_} environment variable and is
202 identical in features.
204 The value of this tunable is maximum number of chunks to allocate with
205 @code{mmap}.  Setting this to zero disables all use of @code{mmap}.
207 The default value of this tunable is @samp{65536}.
208 @end deftp
210 @deftp Tunable glibc.malloc.arena_test
211 This tunable supersedes the @env{MALLOC_ARENA_TEST} environment variable and is
212 identical in features.
214 The @code{glibc.malloc.arena_test} tunable specifies the number of arenas that
215 can be created before the test on the limit to the number of arenas is
216 conducted.  The value is ignored if @code{glibc.malloc.arena_max} is set.
218 The default value of this tunable is 2 for 32-bit systems and 8 for 64-bit
219 systems.
220 @end deftp
222 @deftp Tunable glibc.malloc.arena_max
223 This tunable supersedes the @env{MALLOC_ARENA_MAX} environment variable and is
224 identical in features.
226 This tunable sets the number of arenas to use in a process regardless of the
227 number of cores in the system.
229 The default value of this tunable is @code{0}, meaning that the limit on the
230 number of arenas is determined by the number of CPU cores online.  For 32-bit
231 systems the limit is twice the number of cores online and on 64-bit systems, it
232 is 8 times the number of cores online.
233 @end deftp
235 @deftp Tunable glibc.malloc.tcache_max
236 The maximum size of a request (in bytes) which may be met via the
237 per-thread cache.  The default (and maximum) value is 1032 bytes on
238 64-bit systems and 516 bytes on 32-bit systems.
239 @end deftp
241 @deftp Tunable glibc.malloc.tcache_count
242 The maximum number of chunks of each size to cache. The default is 7.
243 The upper limit is 65535.  If set to zero, the per-thread cache is effectively
244 disabled.
246 The approximate maximum overhead of the per-thread cache is thus equal
247 to the number of bins times the chunk count in each bin times the size
248 of each chunk.  With defaults, the approximate maximum overhead of the
249 per-thread cache is approximately 236 KB on 64-bit systems and 118 KB
250 on 32-bit systems.
251 @end deftp
253 @deftp Tunable glibc.malloc.tcache_unsorted_limit
254 When the user requests memory and the request cannot be met via the
255 per-thread cache, the arenas are used to meet the request.  At this
256 time, additional chunks will be moved from existing arena lists to
257 pre-fill the corresponding cache.  While copies from the fastbins,
258 smallbins, and regular bins are bounded and predictable due to the bin
259 sizes, copies from the unsorted bin are not bounded, and incur
260 additional time penalties as they need to be sorted as they're
261 scanned.  To make scanning the unsorted list more predictable and
262 bounded, the user may set this tunable to limit the number of chunks
263 that are scanned from the unsorted list while searching for chunks to
264 pre-fill the per-thread cache with.  The default, or when set to zero,
265 is no limit.
266 @end deftp
268 @deftp Tunable glibc.malloc.mxfast
269 One of the optimizations @code{malloc} uses is to maintain a series of ``fast
270 bins'' that hold chunks up to a specific size.  The default and
271 maximum size which may be held this way is 80 bytes on 32-bit systems
272 or 160 bytes on 64-bit systems.  Applications which value size over
273 speed may choose to reduce the size of requests which are serviced
274 from fast bins with this tunable.  Note that the value specified
275 includes @code{malloc}'s internal overhead, which is normally the size of one
276 pointer, so add 4 on 32-bit systems or 8 on 64-bit systems to the size
277 passed to @code{malloc} for the largest bin size to enable.
278 @end deftp
280 @deftp Tunable glibc.malloc.hugetlb
281 This tunable controls the usage of Huge Pages on @code{malloc} calls.  The
282 default value is @code{0}, which disables any additional support on
283 @code{malloc}.
285 Setting its value to @code{1} enables the use of @code{madvise} with
286 @code{MADV_HUGEPAGE} after memory allocation with @code{mmap}.  It is enabled
287 only if the system supports Transparent Huge Page (currently only on Linux).
289 Setting its value to @code{2} enables the use of Huge Page directly with
290 @code{mmap} with the use of @code{MAP_HUGETLB} flag.  The huge page size
291 to use will be the default one provided by the system.  A value larger than
292 @code{2} specifies huge page size, which will be matched against the system
293 supported ones.  If provided value is invalid, @code{MAP_HUGETLB} will not
294 be used.
295 @end deftp
297 @node Dynamic Linking Tunables
298 @section Dynamic Linking Tunables
299 @cindex dynamic linking tunables
300 @cindex rtld tunables
302 @deftp {Tunable namespace} glibc.rtld
303 Dynamic linker behavior can be modified by setting the
304 following tunables in the @code{rtld} namespace:
305 @end deftp
307 @deftp Tunable glibc.rtld.nns
308 Sets the number of supported dynamic link namespaces (see @code{dlmopen}).
309 Currently this limit can be set between 1 and 16 inclusive, the default is 4.
310 Each link namespace consumes some memory in all thread, and thus raising the
311 limit will increase the amount of memory each thread uses. Raising the limit
312 is useful when your application uses more than 4 dynamic link namespaces as
313 created by @code{dlmopen} with an lmid argument of @code{LM_ID_NEWLM}.
314 Dynamic linker audit modules are loaded in their own dynamic link namespaces,
315 but they are not accounted for in @code{glibc.rtld.nns}.  They implicitly
316 increase the per-thread memory usage as necessary, so this tunable does
317 not need to be changed to allow many audit modules e.g. via @env{LD_AUDIT}.
318 @end deftp
320 @deftp Tunable glibc.rtld.optional_static_tls
321 Sets the amount of surplus static TLS in bytes to allocate at program
322 startup.  Every thread created allocates this amount of specified surplus
323 static TLS. This is a minimum value and additional space may be allocated
324 for internal purposes including alignment.  Optional static TLS is used for
325 optimizing dynamic TLS access for platforms that support such optimizations
326 e.g. TLS descriptors or optimized TLS access for POWER (@code{DT_PPC64_OPT}
327 and @code{DT_PPC_OPT}).  In order to make the best use of such optimizations
328 the value should be as many bytes as would be required to hold all TLS
329 variables in all dynamic loaded shared libraries.  The value cannot be known
330 by the dynamic loader because it doesn't know the expected set of shared
331 libraries which will be loaded.  The existing static TLS space cannot be
332 changed once allocated at process startup.  The default allocation of
333 optional static TLS is 512 bytes and is allocated in every thread.
334 @end deftp
336 @deftp Tunable glibc.rtld.dynamic_sort
337 Sets the algorithm to use for DSO sorting, valid values are @samp{1} and
338 @samp{2}.  For value of @samp{1}, an older O(n^3) algorithm is used, which is
339 long time tested, but may have performance issues when dependencies between
340 shared objects contain cycles due to circular dependencies.  When set to the
341 value of @samp{2}, a different algorithm is used, which implements a
342 topological sort through depth-first search, and does not exhibit the
343 performance issues of @samp{1}.
345 The default value of this tunable is @samp{2}.
346 @end deftp
348 @deftp Tunable glibc.rtld.enable_secure
349 Used to run a program as if it were a setuid process.  The only valid value
350 is @samp{1} as this tunable can only be used to set and not unset
351 @code{enable_secure}.  Setting this tunable to @samp{1} also disables all other
352 tunables.  This tunable is intended to facilitate more extensive verification
353 tests for @code{AT_SECURE} programs and not meant to be a security feature.
355 The default value of this tunable is @samp{0}.
356 @end deftp
358 @node Elision Tunables
359 @section Elision Tunables
360 @cindex elision tunables
361 @cindex tunables, elision
363 @deftp {Tunable namespace} glibc.elision
364 Contended locks are usually slow and can lead to performance and scalability
365 issues in multithread code. Lock elision will use memory transactions to under
366 certain conditions, to elide locks and improve performance.
367 Elision behavior can be modified by setting the following tunables in
368 the @code{elision} namespace:
369 @end deftp
371 @deftp Tunable glibc.elision.enable
372 The @code{glibc.elision.enable} tunable enables lock elision if the feature is
373 supported by the hardware.  If elision is not supported by the hardware this
374 tunable has no effect.
376 Elision tunables are supported for 64-bit Intel, IBM POWER, and z System
377 architectures.
378 @end deftp
380 @deftp Tunable glibc.elision.skip_lock_busy
381 The @code{glibc.elision.skip_lock_busy} tunable sets how many times to use a
382 non-transactional lock after a transactional failure has occurred because the
383 lock is already acquired.  Expressed in number of lock acquisition attempts.
385 The default value of this tunable is @samp{3}.
386 @end deftp
388 @deftp Tunable glibc.elision.skip_lock_internal_abort
389 The @code{glibc.elision.skip_lock_internal_abort} tunable sets how many times
390 the thread should avoid using elision if a transaction aborted for any reason
391 other than a different thread's memory accesses.  Expressed in number of lock
392 acquisition attempts.
394 The default value of this tunable is @samp{3}.
395 @end deftp
397 @deftp Tunable glibc.elision.skip_lock_after_retries
398 The @code{glibc.elision.skip_lock_after_retries} tunable sets how many times
399 to try to elide a lock with transactions, that only failed due to a different
400 thread's memory accesses, before falling back to regular lock.
401 Expressed in number of lock elision attempts.
403 This tunable is supported only on IBM POWER, and z System architectures.
405 The default value of this tunable is @samp{3}.
406 @end deftp
408 @deftp Tunable glibc.elision.tries
409 The @code{glibc.elision.tries} sets how many times to retry elision if there is
410 chance for the transaction to finish execution e.g., it wasn't
411 aborted due to the lock being already acquired.  If elision is not supported
412 by the hardware this tunable is set to @samp{0} to avoid retries.
414 The default value of this tunable is @samp{3}.
415 @end deftp
417 @deftp Tunable glibc.elision.skip_trylock_internal_abort
418 The @code{glibc.elision.skip_trylock_internal_abort} tunable sets how many
419 times the thread should avoid trying the lock if a transaction aborted due to
420 reasons other than a different thread's memory accesses.  Expressed in number
421 of try lock attempts.
423 The default value of this tunable is @samp{3}.
424 @end deftp
426 @node POSIX Thread Tunables
427 @section POSIX Thread Tunables
428 @cindex pthread mutex tunables
429 @cindex thread mutex tunables
430 @cindex mutex tunables
431 @cindex tunables thread mutex
433 @deftp {Tunable namespace} glibc.pthread
434 The behavior of POSIX threads can be tuned to gain performance improvements
435 according to specific hardware capabilities and workload characteristics by
436 setting the following tunables in the @code{pthread} namespace:
437 @end deftp
439 @deftp Tunable glibc.pthread.mutex_spin_count
440 The @code{glibc.pthread.mutex_spin_count} tunable sets the maximum number of times
441 a thread should spin on the lock before calling into the kernel to block.
442 Adaptive spin is used for mutexes initialized with the
443 @code{PTHREAD_MUTEX_ADAPTIVE_NP} GNU extension.  It affects both
444 @code{pthread_mutex_lock} and @code{pthread_mutex_timedlock}.
446 The thread spins until either the maximum spin count is reached or the lock
447 is acquired.
449 The default value of this tunable is @samp{100}.
450 @end deftp
452 @deftp Tunable glibc.pthread.stack_cache_size
453 This tunable configures the maximum size of the stack cache.  Once the
454 stack cache exceeds this size, unused thread stacks are returned to
455 the kernel, to bring the cache size below this limit.
457 The value is measured in bytes.  The default is @samp{41943040}
458 (forty mibibytes).
459 @end deftp
461 @deftp Tunable glibc.pthread.rseq
462 The @code{glibc.pthread.rseq} tunable can be set to @samp{0}, to disable
463 restartable sequences support in @theglibc{}.  This enables applications
464 to perform direct restartable sequence registration with the kernel.
465 The default is @samp{1}, which means that @theglibc{} performs
466 registration on behalf of the application.
468 Restartable sequences are a Linux-specific extension.
469 @end deftp
471 @deftp Tunable glibc.pthread.stack_hugetlb
472 This tunable controls whether to use Huge Pages in the stacks created by
473 @code{pthread_create}.  This tunable only affects the stacks created by
474 @theglibc{}, it has no effect on stack assigned with
475 @code{pthread_attr_setstack}.
477 The default is @samp{1} where the system default value is used.  Setting
478 its value to @code{0} enables the use of @code{madvise} with
479 @code{MADV_NOHUGEPAGE} after stack creation with @code{mmap}.
481 This is a memory utilization optimization, since internal glibc setup of either
482 the thread descriptor and the guard page might force the kernel to move the
483 thread stack originally backup by Huge Pages to default pages.
484 @end deftp
486 @node Hardware Capability Tunables
487 @section Hardware Capability Tunables
488 @cindex hardware capability tunables
489 @cindex hwcap tunables
490 @cindex tunables, hwcap
491 @cindex hwcaps tunables
492 @cindex tunables, hwcaps
493 @cindex data_cache_size tunables
494 @cindex tunables, data_cache_size
495 @cindex shared_cache_size tunables
496 @cindex tunables, shared_cache_size
497 @cindex non_temporal_threshold tunables
498 @cindex tunables, non_temporal_threshold
500 @deftp {Tunable namespace} glibc.cpu
501 Behavior of @theglibc{} can be tuned to assume specific hardware capabilities
502 by setting the following tunables in the @code{cpu} namespace:
503 @end deftp
505 @deftp Tunable glibc.cpu.hwcap_mask
506 This tunable supersedes the @env{LD_HWCAP_MASK} environment variable and is
507 identical in features.
509 The @code{AT_HWCAP} key in the Auxiliary Vector specifies instruction set
510 extensions available in the processor at runtime for some architectures.  The
511 @code{glibc.cpu.hwcap_mask} tunable allows the user to mask out those
512 capabilities at runtime, thus disabling use of those extensions.
513 @end deftp
515 @deftp Tunable glibc.cpu.hwcaps
516 The @code{glibc.cpu.hwcaps=-xxx,yyy,-zzz...} tunable allows the user to
517 enable CPU/ARCH feature @code{yyy}, disable CPU/ARCH feature @code{xxx}
518 and @code{zzz} where the feature name is case-sensitive and has to match
519 the ones in @code{sysdeps/x86/include/cpu-features.h}.
521 On s390x, the supported HWCAP and STFLE features can be found in
522 @code{sysdeps/s390/cpu-features.c}.  In addition the user can also set
523 a CPU arch-level like @code{z13} instead of single HWCAP and STFLE features.
525 On powerpc, the supported HWCAP and HWCAP2 features can be found in
526 @code{sysdeps/powerpc/dl-procinfo.c}.
528 On loongarch, the supported HWCAP features can be found in
529 @code{sysdeps/loongarch/cpu-tunables.c}.
531 This tunable is specific to i386, x86-64, s390x, powerpc and loongarch.
532 @end deftp
534 @deftp Tunable glibc.cpu.cached_memopt
535 The @code{glibc.cpu.cached_memopt=[0|1]} tunable allows the user to
536 enable optimizations recommended for cacheable memory.  If set to
537 @code{1}, @theglibc{} assumes that the process memory image consists
538 of cacheable (non-device) memory only.  The default, @code{0},
539 indicates that the process may use device memory.
541 This tunable is specific to powerpc, powerpc64 and powerpc64le.
542 @end deftp
544 @deftp Tunable glibc.cpu.name
545 The @code{glibc.cpu.name=xxx} tunable allows the user to tell @theglibc{} to
546 assume that the CPU is @code{xxx} where xxx may have one of these values:
547 @code{generic}, @code{thunderxt88}, @code{thunderx2t99},
548 @code{thunderx2t99p1}, @code{ares}, @code{emag}, @code{kunpeng},
549 @code{a64fx}.
551 This tunable is specific to aarch64.
552 @end deftp
554 @deftp Tunable glibc.cpu.x86_data_cache_size
555 The @code{glibc.cpu.x86_data_cache_size} tunable allows the user to set
556 data cache size in bytes for use in memory and string routines.
558 This tunable is specific to i386 and x86-64.
559 @end deftp
561 @deftp Tunable glibc.cpu.x86_shared_cache_size
562 The @code{glibc.cpu.x86_shared_cache_size} tunable allows the user to
563 set shared cache size in bytes for use in memory and string routines.
564 @end deftp
566 @deftp Tunable glibc.cpu.x86_non_temporal_threshold
567 The @code{glibc.cpu.x86_non_temporal_threshold} tunable allows the user
568 to set threshold in bytes for non temporal store. Non temporal stores
569 give a hint to the hardware to move data directly to memory without
570 displacing other data from the cache. This tunable is used by some
571 platforms to determine when to use non temporal stores in operations
572 like memmove and memcpy.
574 This tunable is specific to i386 and x86-64.
575 @end deftp
577 @deftp Tunable glibc.cpu.x86_rep_movsb_threshold
578 The @code{glibc.cpu.x86_rep_movsb_threshold} tunable allows the user to
579 set threshold in bytes to start using "rep movsb".  The value must be
580 greater than zero, and currently defaults to 2048 bytes.
582 This tunable is specific to i386 and x86-64.
583 @end deftp
585 @deftp Tunable glibc.cpu.x86_rep_stosb_threshold
586 The @code{glibc.cpu.x86_rep_stosb_threshold} tunable allows the user to
587 set threshold in bytes to start using "rep stosb".  The value must be
588 greater than zero, and currently defaults to 2048 bytes.
590 This tunable is specific to i386 and x86-64.
591 @end deftp
593 @deftp Tunable glibc.cpu.x86_ibt
594 The @code{glibc.cpu.x86_ibt} tunable allows the user to control how
595 indirect branch tracking (IBT) should be enabled.  Accepted values are
596 @code{on}, @code{off}, and @code{permissive}.  @code{on} always turns
597 on IBT regardless of whether IBT is enabled in the executable and its
598 dependent shared libraries.  @code{off} always turns off IBT regardless
599 of whether IBT is enabled in the executable and its dependent shared
600 libraries.  @code{permissive} is the same as the default which disables
601 IBT on non-CET executables and shared libraries.
603 This tunable is specific to i386 and x86-64.
604 @end deftp
606 @deftp Tunable glibc.cpu.x86_shstk
607 The @code{glibc.cpu.x86_shstk} tunable allows the user to control how
608 the shadow stack (SHSTK) should be enabled.  Accepted values are
609 @code{on}, @code{off}, and @code{permissive}.  @code{on} always turns on
610 SHSTK regardless of whether SHSTK is enabled in the executable and its
611 dependent shared libraries.  @code{off} always turns off SHSTK regardless
612 of whether SHSTK is enabled in the executable and its dependent shared
613 libraries.  @code{permissive} changes how dlopen works on non-CET shared
614 libraries.  By default, when SHSTK is enabled, dlopening a non-CET shared
615 library returns an error.  With @code{permissive}, it turns off SHSTK
616 instead.
618 This tunable is specific to i386 and x86-64.
619 @end deftp
621 @deftp Tunable glibc.cpu.prefer_map_32bit_exec
622 When this tunable is set to @code{1}, shared libraries of non-setuid
623 programs will be loaded below 2GB with MAP_32BIT.
625 Note that the @env{LD_PREFER_MAP_32BIT_EXEC} environment is an alias of
626 this tunable.
628 This tunable is specific to 64-bit x86-64.
629 @end deftp
631 @deftp Tunable glibc.cpu.plt_rewrite
632 When this tunable is set to @code{1}, the dynamic linker will rewrite
633 the PLT section with 32-bit direct jump.  When it is set to @code{2},
634 the dynamic linker will rewrite the PLT section with 32-bit direct
635 jump and on APX processors with 64-bit absolute jump.
637 This tunable is specific to x86-64 and effective only when the lazy
638 binding is disabled.
639 @end deftp
641 @node Memory Related Tunables
642 @section Memory Related Tunables
643 @cindex memory related tunables
645 @deftp {Tunable namespace} glibc.mem
646 This tunable namespace supports operations that affect the way @theglibc{}
647 and the process manage memory.
648 @end deftp
650 @deftp Tunable glibc.mem.tagging
651 If the hardware supports memory tagging, this tunable can be used to
652 control the way @theglibc{} uses this feature.  At present this is only
653 supported on AArch64 systems with the MTE extension; it is ignored for
654 all other systems.
656 This tunable takes a value between 0 and 255 and acts as a bitmask
657 that enables various capabilities.
659 Bit 0 (the least significant bit) causes the @code{malloc}
660 subsystem to allocate
661 tagged memory, with each allocation being assigned a random tag.
663 Bit 1 enables precise faulting mode for tag violations on systems that
664 support deferred tag violation reporting.  This may cause programs
665 to run more slowly.
667 Bit 2 enables either precise or deferred faulting mode for tag violations
668 whichever is preferred by the system.
670 Other bits are currently reserved.
672 @Theglibc{} startup code will automatically enable memory tagging
673 support in the kernel if this tunable has any non-zero value.
675 The default value is @samp{0}, which disables all memory tagging.
676 @end deftp
678 @deftp Tunable glibc.mem.decorate_maps
679 If the kernel supports naming anonymous virtual memory areas (since
680 Linux version 5.17, although not always enabled by some kernel
681 configurations), this tunable can be used to control whether
682 @theglibc{} decorates the underlying memory obtained from operating
683 system with a string describing its usage (for instance, on the thread
684 stack created by @code{ptthread_create} or memory allocated by
685 @code{malloc}).
687 The process mappings can be obtained by reading the @code{/proc/<pid>maps}
688 (with @code{pid} being either the @dfn{process ID} or @code{self} for the
689 process own mapping).
691 This tunable takes a value of 0 and 1, where 1 enables the feature.
692 The default value is @samp{0}, which disables the decoration.
693 @end deftp
695 @node gmon Tunables
696 @section gmon Tunables
697 @cindex gmon tunables
699 @deftp {Tunable namespace} glibc.gmon
700 This tunable namespace affects the behaviour of the gmon profiler.
701 gmon is a component of @theglibc{} which is normally used in
702 conjunction with gprof.
704 When GCC compiles a program with the @code{-pg} option, it instruments
705 the program with calls to the @code{mcount} function, to record the
706 program's call graph. At program startup, a memory buffer is allocated
707 to store this call graph; the size of the buffer is calculated using a
708 heuristic based on code size. If during execution, the buffer is found
709 to be too small, profiling will be aborted and no @file{gmon.out} file
710 will be produced. In that case, you will see the following message
711 printed to standard error:
713 @example
714 mcount: call graph buffer size limit exceeded, gmon.out will not be generated
715 @end example
717 Most of the symbols discussed in this section are defined in the header
718 @code{sys/gmon.h}. However, some symbols (for example @code{mcount})
719 are not defined in any header file, since they are only intended to be
720 called from code generated by the compiler.
721 @end deftp
723 @deftp Tunable glibc.mem.minarcs
724 The heuristic for sizing the call graph buffer is known to be
725 insufficient for small programs; hence, the calculated value is clamped
726 to be at least a minimum size. The default minimum (in units of
727 call graph entries, @code{struct tostruct}), is given by the macro
728 @code{MINARCS}. If you have some program with an unusually complex
729 call graph, for which the heuristic fails to allocate enough space,
730 you can use this tunable to increase the minimum to a larger value.
731 @end deftp
733 @deftp Tunable glibc.mem.maxarcs
734 To prevent excessive memory consumption when profiling very large
735 programs, the call graph buffer is allowed to have a maximum of
736 @code{MAXARCS} entries. For some very large programs, the default
737 value of @code{MAXARCS} defined in @file{sys/gmon.h} is too small; in
738 that case, you can use this tunable to increase it.
740 Note the value of the @code{maxarcs} tunable must be greater or equal
741 to that of the @code{minarcs} tunable; if this constraint is violated,
742 a warning will printed to standard error at program startup, and
743 the @code{minarcs} value will be used as the maximum as well.
745 Setting either tunable too high may result in a call graph buffer
746 whose size exceeds the available memory; in that case, an out of memory
747 error will be printed at program startup, the profiler will be
748 disabled, and no @file{gmon.out} file will be generated.
749 @end deftp