malloc: Use __get_nprocs on arena_get2 (BZ 30945)
[glibc.git] / manual / tunables.texi
blobb31f16da8426d2a9729a03f971756744c47e3a93
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.malloc.tcache_unsorted_limit: 0x0 (min: 0x0, max: 0xffffffffffffffff)
61 glibc.cpu.x86_ibt:
62 glibc.cpu.hwcaps:
63 glibc.elision.skip_lock_internal_abort: 3 (min: 0, max: 2147483647)
64 glibc.malloc.arena_max: 0x0 (min: 0x1, max: 0xffffffffffffffff)
65 glibc.malloc.mmap_threshold: 0x0 (min: 0x0, max: 0xffffffffffffffff)
66 glibc.cpu.x86_data_cache_size: 0x8000 (min: 0x0, max: 0xffffffffffffffff)
67 glibc.malloc.tcache_count: 0x0 (min: 0x0, max: 0xffffffffffffffff)
68 glibc.malloc.arena_test: 0x0 (min: 0x1, max: 0xffffffffffffffff)
69 glibc.pthread.mutex_spin_count: 100 (min: 0, max: 32767)
70 glibc.rtld.optional_static_tls: 0x200 (min: 0x0, max: 0xffffffffffffffff)
71 glibc.malloc.tcache_max: 0x0 (min: 0x0, max: 0xffffffffffffffff)
72 glibc.malloc.check: 0 (min: 0, max: 3)
73 @end example
75 @menu
76 * Tunable names::  The structure of a tunable name
77 * Memory Allocation Tunables::  Tunables in the memory allocation subsystem
78 * Dynamic Linking Tunables:: Tunables in the dynamic linking subsystem
79 * Elision Tunables::  Tunables in elision subsystem
80 * POSIX Thread Tunables:: Tunables in the POSIX thread subsystem
81 * Hardware Capability Tunables::  Tunables that modify the hardware
82                                   capabilities seen by @theglibc{}
83 * Memory Related Tunables::  Tunables that control the use of memory by
84                              @theglibc{}.
85 * gmon Tunables::  Tunables that control the gmon profiler, used in
86                    conjunction with gprof
88 @end menu
90 @node Tunable names
91 @section Tunable names
92 @cindex Tunable names
93 @cindex Tunable namespaces
95 A tunable name is split into three components, a top namespace, a tunable
96 namespace and the tunable name. The top namespace for tunables implemented in
97 @theglibc{} is @code{glibc}. Distributions that choose to add custom tunables
98 in their maintained versions of @theglibc{} may choose to do so under their own
99 top namespace.
101 The tunable namespace is a logical grouping of tunables in a single
102 module. This currently holds no special significance, although that may
103 change in the future.
105 The tunable name is the actual name of the tunable. It is possible that
106 different tunable namespaces may have tunables within them that have the
107 same name, likewise for top namespaces. Hence, we only support
108 identification of tunables by their full name, i.e. with the top
109 namespace, tunable namespace and tunable name, separated by periods.
111 @node Memory Allocation Tunables
112 @section Memory Allocation Tunables
113 @cindex memory allocation tunables
114 @cindex malloc tunables
115 @cindex tunables, malloc
117 @deftp {Tunable namespace} glibc.malloc
118 Memory allocation behavior can be modified by setting any of the
119 following tunables in the @code{malloc} namespace:
120 @end deftp
122 @deftp Tunable glibc.malloc.check
123 This tunable supersedes the @env{MALLOC_CHECK_} environment variable and is
124 identical in features. This tunable has no effect by default and needs the
125 debug library @file{libc_malloc_debug} to be preloaded using the
126 @code{LD_PRELOAD} environment variable.
128 Setting this tunable to a non-zero value less than 4 enables a special (less
129 efficient) memory allocator for the @code{malloc} family of functions that is
130 designed to be tolerant against simple errors such as double calls of
131 free with the same argument, or overruns of a single byte (off-by-one
132 bugs). Not all such errors can be protected against, however, and memory
133 leaks can result.  Any detected heap corruption results in immediate
134 termination of the process.
136 Like @env{MALLOC_CHECK_}, @code{glibc.malloc.check} has a problem in that it
137 diverges from normal program behavior by writing to @code{stderr}, which could
138 by exploited in SUID and SGID binaries.  Therefore, @code{glibc.malloc.check}
139 is disabled by default for SUID and SGID binaries.
140 @end deftp
142 @deftp Tunable glibc.malloc.top_pad
143 This tunable supersedes the @env{MALLOC_TOP_PAD_} environment variable and is
144 identical in features.
146 This tunable determines the amount of extra memory in bytes to obtain from the
147 system when any of the arenas need to be extended.  It also specifies the
148 number of bytes to retain when shrinking any of the arenas.  This provides the
149 necessary hysteresis in heap size such that excessive amounts of system calls
150 can be avoided.
152 The default value of this tunable is @samp{131072} (128 KB).
153 @end deftp
155 @deftp Tunable glibc.malloc.perturb
156 This tunable supersedes the @env{MALLOC_PERTURB_} environment variable and is
157 identical in features.
159 If set to a non-zero value, memory blocks are initialized with values depending
160 on some low order bits of this tunable when they are allocated (except when
161 allocated by @code{calloc}) and freed.  This can be used to debug the use of
162 uninitialized or freed heap memory. Note that this option does not guarantee
163 that the freed block will have any specific values. It only guarantees that the
164 content the block had before it was freed will be overwritten.
166 The default value of this tunable is @samp{0}.
167 @end deftp
169 @deftp Tunable glibc.malloc.mmap_threshold
170 This tunable supersedes the @env{MALLOC_MMAP_THRESHOLD_} environment variable
171 and is identical in features.
173 When this tunable is set, all chunks larger than this value in bytes are
174 allocated outside the normal heap, using the @code{mmap} system call. This way
175 it is guaranteed that the memory for these chunks can be returned to the system
176 on @code{free}. Note that requests smaller than this threshold might still be
177 allocated via @code{mmap}.
179 If this tunable is not set, the default value is set to @samp{131072} bytes and
180 the threshold is adjusted dynamically to suit the allocation patterns of the
181 program.  If the tunable is set, the dynamic adjustment is disabled and the
182 value is set as static.
183 @end deftp
185 @deftp Tunable glibc.malloc.trim_threshold
186 This tunable supersedes the @env{MALLOC_TRIM_THRESHOLD_} environment variable
187 and is identical in features.
189 The value of this tunable is the minimum size (in bytes) of the top-most,
190 releasable chunk in an arena that will trigger a system call in order to return
191 memory to the system from that arena.
193 If this tunable is not set, the default value is set as 128 KB and the
194 threshold is adjusted dynamically to suit the allocation patterns of the
195 program.  If the tunable is set, the dynamic adjustment is disabled and the
196 value is set as static.
197 @end deftp
199 @deftp Tunable glibc.malloc.mmap_max
200 This tunable supersedes the @env{MALLOC_MMAP_MAX_} environment variable and is
201 identical in features.
203 The value of this tunable is maximum number of chunks to allocate with
204 @code{mmap}.  Setting this to zero disables all use of @code{mmap}.
206 The default value of this tunable is @samp{65536}.
207 @end deftp
209 @deftp Tunable glibc.malloc.arena_test
210 This tunable supersedes the @env{MALLOC_ARENA_TEST} environment variable and is
211 identical in features.
213 The @code{glibc.malloc.arena_test} tunable specifies the number of arenas that
214 can be created before the test on the limit to the number of arenas is
215 conducted.  The value is ignored if @code{glibc.malloc.arena_max} is set.
217 The default value of this tunable is 2 for 32-bit systems and 8 for 64-bit
218 systems.
219 @end deftp
221 @deftp Tunable glibc.malloc.arena_max
222 This tunable supersedes the @env{MALLOC_ARENA_MAX} environment variable and is
223 identical in features.
225 This tunable sets the number of arenas to use in a process regardless of the
226 number of cores in the system.
228 The default value of this tunable is @code{0}, meaning that the limit on the
229 number of arenas is determined by the number of CPU cores online.  For 32-bit
230 systems the limit is twice the number of cores online and on 64-bit systems, it
231 is 8 times the number of cores online.
232 @end deftp
234 @deftp Tunable glibc.malloc.tcache_max
235 The maximum size of a request (in bytes) which may be met via the
236 per-thread cache.  The default (and maximum) value is 1032 bytes on
237 64-bit systems and 516 bytes on 32-bit systems.
238 @end deftp
240 @deftp Tunable glibc.malloc.tcache_count
241 The maximum number of chunks of each size to cache. The default is 7.
242 The upper limit is 65535.  If set to zero, the per-thread cache is effectively
243 disabled.
245 The approximate maximum overhead of the per-thread cache is thus equal
246 to the number of bins times the chunk count in each bin times the size
247 of each chunk.  With defaults, the approximate maximum overhead of the
248 per-thread cache is approximately 236 KB on 64-bit systems and 118 KB
249 on 32-bit systems.
250 @end deftp
252 @deftp Tunable glibc.malloc.tcache_unsorted_limit
253 When the user requests memory and the request cannot be met via the
254 per-thread cache, the arenas are used to meet the request.  At this
255 time, additional chunks will be moved from existing arena lists to
256 pre-fill the corresponding cache.  While copies from the fastbins,
257 smallbins, and regular bins are bounded and predictable due to the bin
258 sizes, copies from the unsorted bin are not bounded, and incur
259 additional time penalties as they need to be sorted as they're
260 scanned.  To make scanning the unsorted list more predictable and
261 bounded, the user may set this tunable to limit the number of chunks
262 that are scanned from the unsorted list while searching for chunks to
263 pre-fill the per-thread cache with.  The default, or when set to zero,
264 is no limit.
265 @end deftp
267 @deftp Tunable glibc.malloc.mxfast
268 One of the optimizations @code{malloc} uses is to maintain a series of ``fast
269 bins'' that hold chunks up to a specific size.  The default and
270 maximum size which may be held this way is 80 bytes on 32-bit systems
271 or 160 bytes on 64-bit systems.  Applications which value size over
272 speed may choose to reduce the size of requests which are serviced
273 from fast bins with this tunable.  Note that the value specified
274 includes @code{malloc}'s internal overhead, which is normally the size of one
275 pointer, so add 4 on 32-bit systems or 8 on 64-bit systems to the size
276 passed to @code{malloc} for the largest bin size to enable.
277 @end deftp
279 @deftp Tunable glibc.malloc.hugetlb
280 This tunable controls the usage of Huge Pages on @code{malloc} calls.  The
281 default value is @code{0}, which disables any additional support on
282 @code{malloc}.
284 Setting its value to @code{1} enables the use of @code{madvise} with
285 @code{MADV_HUGEPAGE} after memory allocation with @code{mmap}.  It is enabled
286 only if the system supports Transparent Huge Page (currently only on Linux).
288 Setting its value to @code{2} enables the use of Huge Page directly with
289 @code{mmap} with the use of @code{MAP_HUGETLB} flag.  The huge page size
290 to use will be the default one provided by the system.  A value larger than
291 @code{2} specifies huge page size, which will be matched against the system
292 supported ones.  If provided value is invalid, @code{MAP_HUGETLB} will not
293 be used.
294 @end deftp
296 @node Dynamic Linking Tunables
297 @section Dynamic Linking Tunables
298 @cindex dynamic linking tunables
299 @cindex rtld tunables
301 @deftp {Tunable namespace} glibc.rtld
302 Dynamic linker behavior can be modified by setting the
303 following tunables in the @code{rtld} namespace:
304 @end deftp
306 @deftp Tunable glibc.rtld.nns
307 Sets the number of supported dynamic link namespaces (see @code{dlmopen}).
308 Currently this limit can be set between 1 and 16 inclusive, the default is 4.
309 Each link namespace consumes some memory in all thread, and thus raising the
310 limit will increase the amount of memory each thread uses. Raising the limit
311 is useful when your application uses more than 4 dynamic link namespaces as
312 created by @code{dlmopen} with an lmid argument of @code{LM_ID_NEWLM}.
313 Dynamic linker audit modules are loaded in their own dynamic link namespaces,
314 but they are not accounted for in @code{glibc.rtld.nns}.  They implicitly
315 increase the per-thread memory usage as necessary, so this tunable does
316 not need to be changed to allow many audit modules e.g. via @env{LD_AUDIT}.
317 @end deftp
319 @deftp Tunable glibc.rtld.optional_static_tls
320 Sets the amount of surplus static TLS in bytes to allocate at program
321 startup.  Every thread created allocates this amount of specified surplus
322 static TLS. This is a minimum value and additional space may be allocated
323 for internal purposes including alignment.  Optional static TLS is used for
324 optimizing dynamic TLS access for platforms that support such optimizations
325 e.g. TLS descriptors or optimized TLS access for POWER (@code{DT_PPC64_OPT}
326 and @code{DT_PPC_OPT}).  In order to make the best use of such optimizations
327 the value should be as many bytes as would be required to hold all TLS
328 variables in all dynamic loaded shared libraries.  The value cannot be known
329 by the dynamic loader because it doesn't know the expected set of shared
330 libraries which will be loaded.  The existing static TLS space cannot be
331 changed once allocated at process startup.  The default allocation of
332 optional static TLS is 512 bytes and is allocated in every thread.
333 @end deftp
335 @deftp Tunable glibc.rtld.dynamic_sort
336 Sets the algorithm to use for DSO sorting, valid values are @samp{1} and
337 @samp{2}.  For value of @samp{1}, an older O(n^3) algorithm is used, which is
338 long time tested, but may have performance issues when dependencies between
339 shared objects contain cycles due to circular dependencies.  When set to the
340 value of @samp{2}, a different algorithm is used, which implements a
341 topological sort through depth-first search, and does not exhibit the
342 performance issues of @samp{1}.
344 The default value of this tunable is @samp{2}.
345 @end deftp
347 @node Elision Tunables
348 @section Elision Tunables
349 @cindex elision tunables
350 @cindex tunables, elision
352 @deftp {Tunable namespace} glibc.elision
353 Contended locks are usually slow and can lead to performance and scalability
354 issues in multithread code. Lock elision will use memory transactions to under
355 certain conditions, to elide locks and improve performance.
356 Elision behavior can be modified by setting the following tunables in
357 the @code{elision} namespace:
358 @end deftp
360 @deftp Tunable glibc.elision.enable
361 The @code{glibc.elision.enable} tunable enables lock elision if the feature is
362 supported by the hardware.  If elision is not supported by the hardware this
363 tunable has no effect.
365 Elision tunables are supported for 64-bit Intel, IBM POWER, and z System
366 architectures.
367 @end deftp
369 @deftp Tunable glibc.elision.skip_lock_busy
370 The @code{glibc.elision.skip_lock_busy} tunable sets how many times to use a
371 non-transactional lock after a transactional failure has occurred because the
372 lock is already acquired.  Expressed in number of lock acquisition attempts.
374 The default value of this tunable is @samp{3}.
375 @end deftp
377 @deftp Tunable glibc.elision.skip_lock_internal_abort
378 The @code{glibc.elision.skip_lock_internal_abort} tunable sets how many times
379 the thread should avoid using elision if a transaction aborted for any reason
380 other than a different thread's memory accesses.  Expressed in number of lock
381 acquisition attempts.
383 The default value of this tunable is @samp{3}.
384 @end deftp
386 @deftp Tunable glibc.elision.skip_lock_after_retries
387 The @code{glibc.elision.skip_lock_after_retries} tunable sets how many times
388 to try to elide a lock with transactions, that only failed due to a different
389 thread's memory accesses, before falling back to regular lock.
390 Expressed in number of lock elision attempts.
392 This tunable is supported only on IBM POWER, and z System architectures.
394 The default value of this tunable is @samp{3}.
395 @end deftp
397 @deftp Tunable glibc.elision.tries
398 The @code{glibc.elision.tries} sets how many times to retry elision if there is
399 chance for the transaction to finish execution e.g., it wasn't
400 aborted due to the lock being already acquired.  If elision is not supported
401 by the hardware this tunable is set to @samp{0} to avoid retries.
403 The default value of this tunable is @samp{3}.
404 @end deftp
406 @deftp Tunable glibc.elision.skip_trylock_internal_abort
407 The @code{glibc.elision.skip_trylock_internal_abort} tunable sets how many
408 times the thread should avoid trying the lock if a transaction aborted due to
409 reasons other than a different thread's memory accesses.  Expressed in number
410 of try lock attempts.
412 The default value of this tunable is @samp{3}.
413 @end deftp
415 @node POSIX Thread Tunables
416 @section POSIX Thread Tunables
417 @cindex pthread mutex tunables
418 @cindex thread mutex tunables
419 @cindex mutex tunables
420 @cindex tunables thread mutex
422 @deftp {Tunable namespace} glibc.pthread
423 The behavior of POSIX threads can be tuned to gain performance improvements
424 according to specific hardware capabilities and workload characteristics by
425 setting the following tunables in the @code{pthread} namespace:
426 @end deftp
428 @deftp Tunable glibc.pthread.mutex_spin_count
429 The @code{glibc.pthread.mutex_spin_count} tunable sets the maximum number of times
430 a thread should spin on the lock before calling into the kernel to block.
431 Adaptive spin is used for mutexes initialized with the
432 @code{PTHREAD_MUTEX_ADAPTIVE_NP} GNU extension.  It affects both
433 @code{pthread_mutex_lock} and @code{pthread_mutex_timedlock}.
435 The thread spins until either the maximum spin count is reached or the lock
436 is acquired.
438 The default value of this tunable is @samp{100}.
439 @end deftp
441 @deftp Tunable glibc.pthread.stack_cache_size
442 This tunable configures the maximum size of the stack cache.  Once the
443 stack cache exceeds this size, unused thread stacks are returned to
444 the kernel, to bring the cache size below this limit.
446 The value is measured in bytes.  The default is @samp{41943040}
447 (forty mibibytes).
448 @end deftp
450 @deftp Tunable glibc.pthread.rseq
451 The @code{glibc.pthread.rseq} tunable can be set to @samp{0}, to disable
452 restartable sequences support in @theglibc{}.  This enables applications
453 to perform direct restartable sequence registration with the kernel.
454 The default is @samp{1}, which means that @theglibc{} performs
455 registration on behalf of the application.
457 Restartable sequences are a Linux-specific extension.
458 @end deftp
460 @deftp Tunable glibc.pthread.stack_hugetlb
461 This tunable controls whether to use Huge Pages in the stacks created by
462 @code{pthread_create}.  This tunable only affects the stacks created by
463 @theglibc{}, it has no effect on stack assigned with
464 @code{pthread_attr_setstack}.
466 The default is @samp{1} where the system default value is used.  Setting
467 its value to @code{0} enables the use of @code{madvise} with
468 @code{MADV_NOHUGEPAGE} after stack creation with @code{mmap}.
470 This is a memory utilization optimization, since internal glibc setup of either
471 the thread descriptor and the guard page might force the kernel to move the
472 thread stack originally backup by Huge Pages to default pages.
473 @end deftp
475 @node Hardware Capability Tunables
476 @section Hardware Capability Tunables
477 @cindex hardware capability tunables
478 @cindex hwcap tunables
479 @cindex tunables, hwcap
480 @cindex hwcaps tunables
481 @cindex tunables, hwcaps
482 @cindex data_cache_size tunables
483 @cindex tunables, data_cache_size
484 @cindex shared_cache_size tunables
485 @cindex tunables, shared_cache_size
486 @cindex non_temporal_threshold tunables
487 @cindex tunables, non_temporal_threshold
489 @deftp {Tunable namespace} glibc.cpu
490 Behavior of @theglibc{} can be tuned to assume specific hardware capabilities
491 by setting the following tunables in the @code{cpu} namespace:
492 @end deftp
494 @deftp Tunable glibc.cpu.hwcap_mask
495 This tunable supersedes the @env{LD_HWCAP_MASK} environment variable and is
496 identical in features.
498 The @code{AT_HWCAP} key in the Auxiliary Vector specifies instruction set
499 extensions available in the processor at runtime for some architectures.  The
500 @code{glibc.cpu.hwcap_mask} tunable allows the user to mask out those
501 capabilities at runtime, thus disabling use of those extensions.
502 @end deftp
504 @deftp Tunable glibc.cpu.hwcaps
505 The @code{glibc.cpu.hwcaps=-xxx,yyy,-zzz...} tunable allows the user to
506 enable CPU/ARCH feature @code{yyy}, disable CPU/ARCH feature @code{xxx}
507 and @code{zzz} where the feature name is case-sensitive and has to match
508 the ones in @code{sysdeps/x86/include/cpu-features.h}.
510 On s390x, the supported HWCAP and STFLE features can be found in
511 @code{sysdeps/s390/cpu-features.c}.  In addition the user can also set
512 a CPU arch-level like @code{z13} instead of single HWCAP and STFLE features.
514 On powerpc, the supported HWCAP and HWCAP2 features can be found in
515 @code{sysdeps/powerpc/dl-procinfo.c}.
517 This tunable is specific to i386, x86-64, s390x and powerpc.
518 @end deftp
520 @deftp Tunable glibc.cpu.cached_memopt
521 The @code{glibc.cpu.cached_memopt=[0|1]} tunable allows the user to
522 enable optimizations recommended for cacheable memory.  If set to
523 @code{1}, @theglibc{} assumes that the process memory image consists
524 of cacheable (non-device) memory only.  The default, @code{0},
525 indicates that the process may use device memory.
527 This tunable is specific to powerpc, powerpc64 and powerpc64le.
528 @end deftp
530 @deftp Tunable glibc.cpu.name
531 The @code{glibc.cpu.name=xxx} tunable allows the user to tell @theglibc{} to
532 assume that the CPU is @code{xxx} where xxx may have one of these values:
533 @code{generic}, @code{thunderxt88}, @code{thunderx2t99},
534 @code{thunderx2t99p1}, @code{ares}, @code{emag}, @code{kunpeng},
535 @code{a64fx}.
537 This tunable is specific to aarch64.
538 @end deftp
540 @deftp Tunable glibc.cpu.x86_data_cache_size
541 The @code{glibc.cpu.x86_data_cache_size} tunable allows the user to set
542 data cache size in bytes for use in memory and string routines.
544 This tunable is specific to i386 and x86-64.
545 @end deftp
547 @deftp Tunable glibc.cpu.x86_shared_cache_size
548 The @code{glibc.cpu.x86_shared_cache_size} tunable allows the user to
549 set shared cache size in bytes for use in memory and string routines.
550 @end deftp
552 @deftp Tunable glibc.cpu.x86_non_temporal_threshold
553 The @code{glibc.cpu.x86_non_temporal_threshold} tunable allows the user
554 to set threshold in bytes for non temporal store. Non temporal stores
555 give a hint to the hardware to move data directly to memory without
556 displacing other data from the cache. This tunable is used by some
557 platforms to determine when to use non temporal stores in operations
558 like memmove and memcpy.
560 This tunable is specific to i386 and x86-64.
561 @end deftp
563 @deftp Tunable glibc.cpu.x86_rep_movsb_threshold
564 The @code{glibc.cpu.x86_rep_movsb_threshold} tunable allows the user to
565 set threshold in bytes to start using "rep movsb".  The value must be
566 greater than zero, and currently defaults to 2048 bytes.
568 This tunable is specific to i386 and x86-64.
569 @end deftp
571 @deftp Tunable glibc.cpu.x86_rep_stosb_threshold
572 The @code{glibc.cpu.x86_rep_stosb_threshold} tunable allows the user to
573 set threshold in bytes to start using "rep stosb".  The value must be
574 greater than zero, and currently defaults to 2048 bytes.
576 This tunable is specific to i386 and x86-64.
577 @end deftp
579 @deftp Tunable glibc.cpu.x86_ibt
580 The @code{glibc.cpu.x86_ibt} tunable allows the user to control how
581 indirect branch tracking (IBT) should be enabled.  Accepted values are
582 @code{on}, @code{off}, and @code{permissive}.  @code{on} always turns
583 on IBT regardless of whether IBT is enabled in the executable and its
584 dependent shared libraries.  @code{off} always turns off IBT regardless
585 of whether IBT is enabled in the executable and its dependent shared
586 libraries.  @code{permissive} is the same as the default which disables
587 IBT on non-CET executables and shared libraries.
589 This tunable is specific to i386 and x86-64.
590 @end deftp
592 @deftp Tunable glibc.cpu.x86_shstk
593 The @code{glibc.cpu.x86_shstk} tunable allows the user to control how
594 the shadow stack (SHSTK) should be enabled.  Accepted values are
595 @code{on}, @code{off}, and @code{permissive}.  @code{on} always turns on
596 SHSTK regardless of whether SHSTK is enabled in the executable and its
597 dependent shared libraries.  @code{off} always turns off SHSTK regardless
598 of whether SHSTK is enabled in the executable and its dependent shared
599 libraries.  @code{permissive} changes how dlopen works on non-CET shared
600 libraries.  By default, when SHSTK is enabled, dlopening a non-CET shared
601 library returns an error.  With @code{permissive}, it turns off SHSTK
602 instead.
604 This tunable is specific to i386 and x86-64.
605 @end deftp
607 @deftp Tunable glibc.cpu.prefer_map_32bit_exec
608 When this tunable is set to @code{1}, shared libraries of non-setuid
609 programs will be loaded below 2GB with MAP_32BIT.
611 Note that the @env{LD_PREFER_MAP_32BIT_EXEC} environment is an alias of
612 this tunable.
614 This tunable is specific to 64-bit x86-64.
615 @end deftp
617 @node Memory Related Tunables
618 @section Memory Related Tunables
619 @cindex memory related tunables
621 @deftp {Tunable namespace} glibc.mem
622 This tunable namespace supports operations that affect the way @theglibc{}
623 and the process manage memory.
624 @end deftp
626 @deftp Tunable glibc.mem.tagging
627 If the hardware supports memory tagging, this tunable can be used to
628 control the way @theglibc{} uses this feature.  At present this is only
629 supported on AArch64 systems with the MTE extension; it is ignored for
630 all other systems.
632 This tunable takes a value between 0 and 255 and acts as a bitmask
633 that enables various capabilities.
635 Bit 0 (the least significant bit) causes the @code{malloc}
636 subsystem to allocate
637 tagged memory, with each allocation being assigned a random tag.
639 Bit 1 enables precise faulting mode for tag violations on systems that
640 support deferred tag violation reporting.  This may cause programs
641 to run more slowly.
643 Bit 2 enables either precise or deferred faulting mode for tag violations
644 whichever is preferred by the system.
646 Other bits are currently reserved.
648 @Theglibc{} startup code will automatically enable memory tagging
649 support in the kernel if this tunable has any non-zero value.
651 The default value is @samp{0}, which disables all memory tagging.
652 @end deftp
654 @deftp Tunable glibc.mem.decorate_maps
655 If the kernel supports naming anonymous virtual memory areas (since
656 Linux version 5.17, although not always enabled by some kernel
657 configurations), this tunable can be used to control whether
658 @theglibc{} decorates the underlying memory obtained from operating
659 system with a string describing its usage (for instance, on the thread
660 stack created by @code{ptthread_create} or memory allocated by
661 @code{malloc}).
663 The process mappings can be obtained by reading the @code{/proc/<pid>maps}
664 (with @code{pid} being either the @dfn{process ID} or @code{self} for the
665 process own mapping).
667 This tunable takes a value of 0 and 1, where 1 enables the feature.
668 The default value is @samp{0}, which disables the decoration.
669 @end deftp
671 @node gmon Tunables
672 @section gmon Tunables
673 @cindex gmon tunables
675 @deftp {Tunable namespace} glibc.gmon
676 This tunable namespace affects the behaviour of the gmon profiler.
677 gmon is a component of @theglibc{} which is normally used in
678 conjunction with gprof.
680 When GCC compiles a program with the @code{-pg} option, it instruments
681 the program with calls to the @code{mcount} function, to record the
682 program's call graph. At program startup, a memory buffer is allocated
683 to store this call graph; the size of the buffer is calculated using a
684 heuristic based on code size. If during execution, the buffer is found
685 to be too small, profiling will be aborted and no @file{gmon.out} file
686 will be produced. In that case, you will see the following message
687 printed to standard error:
689 @example
690 mcount: call graph buffer size limit exceeded, gmon.out will not be generated
691 @end example
693 Most of the symbols discussed in this section are defined in the header
694 @code{sys/gmon.h}. However, some symbols (for example @code{mcount})
695 are not defined in any header file, since they are only intended to be
696 called from code generated by the compiler.
697 @end deftp
699 @deftp Tunable glibc.mem.minarcs
700 The heuristic for sizing the call graph buffer is known to be
701 insufficient for small programs; hence, the calculated value is clamped
702 to be at least a minimum size. The default minimum (in units of
703 call graph entries, @code{struct tostruct}), is given by the macro
704 @code{MINARCS}. If you have some program with an unusually complex
705 call graph, for which the heuristic fails to allocate enough space,
706 you can use this tunable to increase the minimum to a larger value.
707 @end deftp
709 @deftp Tunable glibc.mem.maxarcs
710 To prevent excessive memory consumption when profiling very large
711 programs, the call graph buffer is allowed to have a maximum of
712 @code{MAXARCS} entries. For some very large programs, the default
713 value of @code{MAXARCS} defined in @file{sys/gmon.h} is too small; in
714 that case, you can use this tunable to increase it.
716 Note the value of the @code{maxarcs} tunable must be greater or equal
717 to that of the @code{minarcs} tunable; if this constraint is violated,
718 a warning will printed to standard error at program startup, and
719 the @code{minarcs} value will be used as the maximum as well.
721 Setting either tunable too high may result in a call graph buffer
722 whose size exceeds the available memory; in that case, an out of memory
723 error will be printed at program startup, the profiler will be
724 disabled, and no @file{gmon.out} file will be generated.
725 @end deftp