|
|
c41d59 |
This patch adds the required @order directives to preserve the
|
|
|
c41d59 |
GLIBC_PRIVATE ABI.
|
|
|
c41d59 |
|
|
|
c41d59 |
commit 31be941e4367c001b2009308839db5c67bf9dcbc
|
|
|
c41d59 |
Author: Simon Kissane <skissane@gmail.com>
|
|
|
c41d59 |
Date: Sat Feb 11 20:12:13 2023 +1100
|
|
|
c41d59 |
|
|
|
c41d59 |
gmon: improve mcount overflow handling [BZ# 27576]
|
|
|
c41d59 |
|
|
|
c41d59 |
When mcount overflows, no gmon.out file is generated, but no message is printed
|
|
|
c41d59 |
to the user, leaving the user with no idea why, and thinking maybe there is
|
|
|
c41d59 |
some bug - which is how BZ 27576 ended up being logged. Print a message to
|
|
|
c41d59 |
stderr in this case so the user knows what is going on.
|
|
|
c41d59 |
|
|
|
c41d59 |
As a comment in sys/gmon.h acknowledges, the hardcoded MAXARCS value is too
|
|
|
c41d59 |
small for some large applications, including the test case in that BZ. Rather
|
|
|
c41d59 |
than increase it, add tunables to enable MINARCS and MAXARCS to be overridden
|
|
|
c41d59 |
at runtime (glibc.gmon.minarcs and glibc.gmon.maxarcs). So if a user gets the
|
|
|
c41d59 |
mcount overflow error, they can try increasing maxarcs (they might need to
|
|
|
c41d59 |
increase minarcs too if the heuristic is wrong in their case.)
|
|
|
c41d59 |
|
|
|
c41d59 |
Note setting minarcs/maxarcs too large can cause monstartup to fail with an
|
|
|
c41d59 |
out of memory error. If you set them large enough, it can cause an integer
|
|
|
c41d59 |
overflow in calculating the buffer size. I haven't done anything to defend
|
|
|
c41d59 |
against that - it would not generally be a security vulnerability, since these
|
|
|
c41d59 |
tunables will be ignored in suid/sgid programs (due to the SXID_ERASE default),
|
|
|
c41d59 |
and if you can set GLIBC_TUNABLES in the environment of a process, you can take
|
|
|
c41d59 |
it over anyway (LD_PRELOAD, LD_LIBRARY_PATH, etc). I thought about modifying
|
|
|
c41d59 |
the code of monstartup to defend against integer overflows, but doing so is
|
|
|
c41d59 |
complicated, and I realise the existing code is susceptible to them even prior
|
|
|
c41d59 |
to this change (e.g. try passing a pathologically large highpc argument to
|
|
|
c41d59 |
monstartup), so I decided just to leave that possibility in-place.
|
|
|
c41d59 |
|
|
|
c41d59 |
Add a test case which demonstrates mcount overflow and the tunables.
|
|
|
c41d59 |
|
|
|
c41d59 |
Document the new tunables in the manual.
|
|
|
c41d59 |
|
|
|
c41d59 |
Signed-off-by: Simon Kissane <skissane@gmail.com>
|
|
|
c41d59 |
Reviewed-by: DJ Delorie <dj@redhat.com>
|
|
|
c41d59 |
|
|
|
c41d59 |
Conflicts:
|
|
|
c41d59 |
manual/tunables.texi
|
|
|
c41d59 |
(missing tunables downstream)
|
|
|
c41d59 |
|
|
|
c41d59 |
diff --git a/elf/dl-tunables.list b/elf/dl-tunables.list
|
|
|
c41d59 |
index f11ca5b3e8b09b43..dc2999796042dbaf 100644
|
|
|
c41d59 |
--- a/elf/dl-tunables.list
|
|
|
c41d59 |
+++ b/elf/dl-tunables.list
|
|
|
c41d59 |
@@ -149,4 +149,17 @@ glibc {
|
|
|
c41d59 |
default: 2
|
|
|
c41d59 |
}
|
|
|
c41d59 |
}
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+ gmon {
|
|
|
c41d59 |
+ minarcs {
|
|
|
c41d59 |
+ type: INT_32
|
|
|
c41d59 |
+ minval: 50
|
|
|
c41d59 |
+ default: 50
|
|
|
c41d59 |
+ }
|
|
|
c41d59 |
+ maxarcs {
|
|
|
c41d59 |
+ type: INT_32
|
|
|
c41d59 |
+ minval: 50
|
|
|
c41d59 |
+ default: 1048576
|
|
|
c41d59 |
+ }
|
|
|
c41d59 |
+ }
|
|
|
c41d59 |
}
|
|
|
c41d59 |
diff --git a/gmon/Makefile b/gmon/Makefile
|
|
|
c41d59 |
index d94593c9d8a882eb..54f05894d4dd8c4a 100644
|
|
|
c41d59 |
--- a/gmon/Makefile
|
|
|
c41d59 |
+++ b/gmon/Makefile
|
|
|
c41d59 |
@@ -25,7 +25,7 @@ include ../Makeconfig
|
|
|
c41d59 |
headers := sys/gmon.h sys/gmon_out.h sys/profil.h
|
|
|
c41d59 |
routines := gmon mcount profil sprofil prof-freq
|
|
|
c41d59 |
|
|
|
c41d59 |
-tests = tst-sprofil tst-gmon
|
|
|
c41d59 |
+tests = tst-sprofil tst-gmon tst-mcount-overflow
|
|
|
c41d59 |
ifeq ($(build-profile),yes)
|
|
|
c41d59 |
tests += tst-profile-static
|
|
|
c41d59 |
tests-static += tst-profile-static
|
|
|
c41d59 |
@@ -56,6 +56,18 @@ ifeq ($(run-built-tests),yes)
|
|
|
c41d59 |
tests-special += $(objpfx)tst-gmon-gprof.out
|
|
|
c41d59 |
endif
|
|
|
c41d59 |
|
|
|
c41d59 |
+CFLAGS-tst-mcount-overflow.c := -fno-omit-frame-pointer -pg
|
|
|
c41d59 |
+tst-mcount-overflow-no-pie = yes
|
|
|
c41d59 |
+CRT-tst-mcount-overflow := $(csu-objpfx)g$(start-installed-name)
|
|
|
c41d59 |
+# Intentionally use invalid config where maxarcs
|
|
|
c41d59 |
+tst-mcount-overflow-ENV := GMON_OUT_PREFIX=$(objpfx)tst-mcount-overflow.data \
|
|
|
c41d59 |
+ GLIBC_TUNABLES=glibc.gmon.minarcs=51:glibc.gmon.maxarcs=50
|
|
|
c41d59 |
+# Send stderr into output file because we make sure expected messages are printed
|
|
|
c41d59 |
+tst-mcount-overflow-ARGS := 2>&1 1>/dev/null | cat
|
|
|
c41d59 |
+ifeq ($(run-built-tests),yes)
|
|
|
c41d59 |
+tests-special += $(objpfx)tst-mcount-overflow-check.out
|
|
|
c41d59 |
+endif
|
|
|
c41d59 |
+
|
|
|
c41d59 |
CFLAGS-tst-gmon-static.c := $(PIE-ccflag) -fno-omit-frame-pointer -pg
|
|
|
c41d59 |
CRT-tst-gmon-static := $(csu-objpfx)gcrt1.o
|
|
|
c41d59 |
tst-gmon-static-no-pie = yes
|
|
|
c41d59 |
@@ -103,6 +115,14 @@ $(objpfx)tst-gmon.out: clean-tst-gmon-data
|
|
|
c41d59 |
clean-tst-gmon-data:
|
|
|
c41d59 |
rm -f $(objpfx)tst-gmon.data.*
|
|
|
c41d59 |
|
|
|
c41d59 |
+$(objpfx)tst-mcount-overflow.o: clean-tst-mcount-overflow-data
|
|
|
c41d59 |
+clean-tst-mcount-overflow-data:
|
|
|
c41d59 |
+ rm -f $(objpfx)tst-mcount-overflow.data.*
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+$(objpfx)tst-mcount-overflow-check.out: tst-mcount-overflow-check.sh $(objpfx)tst-mcount-overflow.out
|
|
|
c41d59 |
+ $(SHELL) $< $(objpfx)tst-mcount-overflow > $@; \
|
|
|
c41d59 |
+ $(evaluate-test)
|
|
|
c41d59 |
+
|
|
|
c41d59 |
$(objpfx)tst-gmon-gprof.out: tst-gmon-gprof.sh $(objpfx)tst-gmon.out
|
|
|
c41d59 |
$(SHELL) $< $(GPROF) $(objpfx)tst-gmon $(objpfx)tst-gmon.data.* > $@; \
|
|
|
c41d59 |
$(evaluate-test)
|
|
|
c41d59 |
diff --git a/gmon/gmon.c b/gmon/gmon.c
|
|
|
c41d59 |
index bf76358d5b1aa2da..689bf80141e559ca 100644
|
|
|
c41d59 |
--- a/gmon/gmon.c
|
|
|
c41d59 |
+++ b/gmon/gmon.c
|
|
|
c41d59 |
@@ -46,6 +46,11 @@
|
|
|
c41d59 |
#include <libc-internal.h>
|
|
|
c41d59 |
#include <not-cancel.h>
|
|
|
c41d59 |
|
|
|
c41d59 |
+#if HAVE_TUNABLES
|
|
|
c41d59 |
+# define TUNABLE_NAMESPACE gmon
|
|
|
c41d59 |
+# include <elf/dl-tunables.h>
|
|
|
c41d59 |
+#endif
|
|
|
c41d59 |
+
|
|
|
c41d59 |
#ifdef PIC
|
|
|
c41d59 |
# include <link.h>
|
|
|
c41d59 |
|
|
|
c41d59 |
@@ -124,6 +129,22 @@ __monstartup (u_long lowpc, u_long highpc)
|
|
|
c41d59 |
int o;
|
|
|
c41d59 |
char *cp;
|
|
|
c41d59 |
struct gmonparam *p = &_gmonparam;
|
|
|
c41d59 |
+ long int minarcs, maxarcs;
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+#if HAVE_TUNABLES
|
|
|
c41d59 |
+ /* Read minarcs/maxarcs tunables. */
|
|
|
c41d59 |
+ minarcs = TUNABLE_GET (minarcs, int32_t, NULL);
|
|
|
c41d59 |
+ maxarcs = TUNABLE_GET (maxarcs, int32_t, NULL);
|
|
|
c41d59 |
+ if (maxarcs < minarcs)
|
|
|
c41d59 |
+ {
|
|
|
c41d59 |
+ ERR("monstartup: maxarcs < minarcs, setting maxarcs = minarcs\n");
|
|
|
c41d59 |
+ maxarcs = minarcs;
|
|
|
c41d59 |
+ }
|
|
|
c41d59 |
+#else
|
|
|
c41d59 |
+ /* No tunables, we use hardcoded defaults */
|
|
|
c41d59 |
+ minarcs = MINARCS;
|
|
|
c41d59 |
+ maxarcs = MAXARCS;
|
|
|
c41d59 |
+#endif
|
|
|
c41d59 |
|
|
|
c41d59 |
/*
|
|
|
c41d59 |
* round lowpc and highpc to multiples of the density we're using
|
|
|
c41d59 |
@@ -146,10 +167,10 @@ __monstartup (u_long lowpc, u_long highpc)
|
|
|
c41d59 |
}
|
|
|
c41d59 |
p->fromssize = ROUNDUP(p->textsize / HASHFRACTION, sizeof(*p->froms));
|
|
|
c41d59 |
p->tolimit = p->textsize * ARCDENSITY / 100;
|
|
|
c41d59 |
- if (p->tolimit < MINARCS)
|
|
|
c41d59 |
- p->tolimit = MINARCS;
|
|
|
c41d59 |
- else if (p->tolimit > MAXARCS)
|
|
|
c41d59 |
- p->tolimit = MAXARCS;
|
|
|
c41d59 |
+ if (p->tolimit < minarcs)
|
|
|
c41d59 |
+ p->tolimit = minarcs;
|
|
|
c41d59 |
+ else if (p->tolimit > maxarcs)
|
|
|
c41d59 |
+ p->tolimit = maxarcs;
|
|
|
c41d59 |
p->tossize = p->tolimit * sizeof(struct tostruct);
|
|
|
c41d59 |
|
|
|
c41d59 |
cp = calloc (p->kcountsize + p->fromssize + p->tossize, 1);
|
|
|
c41d59 |
diff --git a/gmon/mcount.c b/gmon/mcount.c
|
|
|
c41d59 |
index 9d4a1a50fa6ab21a..f7180fdb83399a14 100644
|
|
|
c41d59 |
--- a/gmon/mcount.c
|
|
|
c41d59 |
+++ b/gmon/mcount.c
|
|
|
c41d59 |
@@ -41,6 +41,10 @@ static char sccsid[] = "@(#)mcount.c 8.1 (Berkeley) 6/4/93";
|
|
|
c41d59 |
|
|
|
c41d59 |
#include <atomic.h>
|
|
|
c41d59 |
|
|
|
c41d59 |
+#include <not-cancel.h>
|
|
|
c41d59 |
+#include <unistd.h>
|
|
|
c41d59 |
+#define ERR(s) __write_nocancel (STDERR_FILENO, s, sizeof (s) - 1)
|
|
|
c41d59 |
+
|
|
|
c41d59 |
/*
|
|
|
c41d59 |
* mcount is called on entry to each function compiled with the profiling
|
|
|
c41d59 |
* switch set. _mcount(), which is declared in a machine-dependent way
|
|
|
c41d59 |
@@ -170,6 +174,7 @@ done:
|
|
|
c41d59 |
return;
|
|
|
c41d59 |
overflow:
|
|
|
c41d59 |
p->state = GMON_PROF_ERROR;
|
|
|
c41d59 |
+ ERR("mcount: call graph buffer size limit exceeded, gmon.out will not be generated\n");
|
|
|
c41d59 |
return;
|
|
|
c41d59 |
}
|
|
|
c41d59 |
|
|
|
c41d59 |
diff --git a/gmon/sys/gmon.h b/gmon/sys/gmon.h
|
|
|
c41d59 |
index b4cc3b043a2aec77..af0582a3717085b5 100644
|
|
|
c41d59 |
--- a/gmon/sys/gmon.h
|
|
|
c41d59 |
+++ b/gmon/sys/gmon.h
|
|
|
c41d59 |
@@ -111,6 +111,8 @@ extern struct __bb *__bb_head;
|
|
|
c41d59 |
* Always allocate at least this many tostructs. This
|
|
|
c41d59 |
* hides the inadequacy of the ARCDENSITY heuristic, at least
|
|
|
c41d59 |
* for small programs.
|
|
|
c41d59 |
+ *
|
|
|
c41d59 |
+ * Value can be overridden at runtime by glibc.gmon.minarcs tunable.
|
|
|
c41d59 |
*/
|
|
|
c41d59 |
#define MINARCS 50
|
|
|
c41d59 |
|
|
|
c41d59 |
@@ -124,8 +126,8 @@ extern struct __bb *__bb_head;
|
|
|
c41d59 |
* Used to be max representable value of ARCINDEX minus 2, but now
|
|
|
c41d59 |
* that ARCINDEX is a long, that's too large; we don't really want
|
|
|
c41d59 |
* to allow a 48 gigabyte table.
|
|
|
c41d59 |
- * The old value of 1<<16 wasn't high enough in practice for large C++
|
|
|
c41d59 |
- * programs; will 1<<20 be adequate for long? FIXME
|
|
|
c41d59 |
+ *
|
|
|
c41d59 |
+ * Value can be overridden at runtime by glibc.gmon.maxarcs tunable.
|
|
|
c41d59 |
*/
|
|
|
c41d59 |
#define MAXARCS (1 << 20)
|
|
|
c41d59 |
|
|
|
c41d59 |
diff --git a/gmon/tst-mcount-overflow-check.sh b/gmon/tst-mcount-overflow-check.sh
|
|
|
c41d59 |
new file mode 100644
|
|
|
c41d59 |
index 0000000000000000..27eb5538fd573a6e
|
|
|
c41d59 |
--- /dev/null
|
|
|
c41d59 |
+++ b/gmon/tst-mcount-overflow-check.sh
|
|
|
c41d59 |
@@ -0,0 +1,45 @@
|
|
|
c41d59 |
+#!/bin/sh
|
|
|
c41d59 |
+# Test expected messages generated when mcount overflows
|
|
|
c41d59 |
+# Copyright (C) 2017-2023 Free Software Foundation, Inc.
|
|
|
c41d59 |
+# Copyright The GNU Toolchain Authors.
|
|
|
c41d59 |
+# This file is part of the GNU C Library.
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+# The GNU C Library is free software; you can redistribute it and/or
|
|
|
c41d59 |
+# modify it under the terms of the GNU Lesser General Public
|
|
|
c41d59 |
+# License as published by the Free Software Foundation; either
|
|
|
c41d59 |
+# version 2.1 of the License, or (at your option) any later version.
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+# The GNU C Library is distributed in the hope that it will be useful,
|
|
|
c41d59 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c41d59 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c41d59 |
+# Lesser General Public License for more details.
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+# You should have received a copy of the GNU Lesser General Public
|
|
|
c41d59 |
+# License along with the GNU C Library; if not, see
|
|
|
c41d59 |
+# <https://www.gnu.org/licenses/>.
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+LC_ALL=C
|
|
|
c41d59 |
+export LC_ALL
|
|
|
c41d59 |
+set -e
|
|
|
c41d59 |
+exec 2>&1
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+program="$1"
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+check_msg() {
|
|
|
c41d59 |
+ if ! grep -q "$1" "$program.out"; then
|
|
|
c41d59 |
+ echo "FAIL: expected message not in output: $1"
|
|
|
c41d59 |
+ exit 1
|
|
|
c41d59 |
+ fi
|
|
|
c41d59 |
+}
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+check_msg 'monstartup: maxarcs < minarcs, setting maxarcs = minarcs'
|
|
|
c41d59 |
+check_msg 'mcount: call graph buffer size limit exceeded, gmon.out will not be generated'
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+for data_file in $1.data.*; do
|
|
|
c41d59 |
+ if [ -f "$data_file" ]; then
|
|
|
c41d59 |
+ echo "FAIL: expected no data files, but found $data_file"
|
|
|
c41d59 |
+ exit 1
|
|
|
c41d59 |
+ fi
|
|
|
c41d59 |
+done
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+echo PASS
|
|
|
c41d59 |
diff --git a/gmon/tst-mcount-overflow.c b/gmon/tst-mcount-overflow.c
|
|
|
c41d59 |
new file mode 100644
|
|
|
c41d59 |
index 0000000000000000..06cc93ef872eb7c1
|
|
|
c41d59 |
--- /dev/null
|
|
|
c41d59 |
+++ b/gmon/tst-mcount-overflow.c
|
|
|
c41d59 |
@@ -0,0 +1,72 @@
|
|
|
c41d59 |
+/* Test program to trigger mcount overflow in profiling collection.
|
|
|
c41d59 |
+ Copyright (C) 2017-2023 Free Software Foundation, Inc.
|
|
|
c41d59 |
+ This file is part of the GNU C Library.
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
c41d59 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
c41d59 |
+ License as published by the Free Software Foundation; either
|
|
|
c41d59 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
c41d59 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c41d59 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c41d59 |
+ Lesser General Public License for more details.
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
c41d59 |
+ License along with the GNU C Library; if not, see
|
|
|
c41d59 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+/* Program with sufficiently complex, yet pointless, call graph
|
|
|
c41d59 |
+ that it will trigger an mcount overflow, when you set the
|
|
|
c41d59 |
+ minarcs/maxarcs tunables to very low values. */
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+#define PREVENT_TAIL_CALL asm volatile ("")
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+/* Calls REP(n) macro 16 times, for n=0..15.
|
|
|
c41d59 |
+ * You need to define REP(n) before using this.
|
|
|
c41d59 |
+ */
|
|
|
c41d59 |
+#define REPS \
|
|
|
c41d59 |
+ REP(0) REP(1) REP(2) REP(3) REP(4) REP(5) REP(6) REP(7) \
|
|
|
c41d59 |
+ REP(8) REP(9) REP(10) REP(11) REP(12) REP(13) REP(14) REP(15)
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+/* Defines 16 leaf functions named f1_0 to f1_15 */
|
|
|
c41d59 |
+#define REP(n) \
|
|
|
c41d59 |
+ __attribute__ ((noinline, noclone, weak)) void f1_##n (void) {};
|
|
|
c41d59 |
+REPS
|
|
|
c41d59 |
+#undef REP
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+/* Calls all 16 leaf functions f1_* in succession */
|
|
|
c41d59 |
+__attribute__ ((noinline, noclone, weak)) void
|
|
|
c41d59 |
+f2 (void)
|
|
|
c41d59 |
+{
|
|
|
c41d59 |
+# define REP(n) f1_##n();
|
|
|
c41d59 |
+ REPS
|
|
|
c41d59 |
+# undef REP
|
|
|
c41d59 |
+ PREVENT_TAIL_CALL;
|
|
|
c41d59 |
+}
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+/* Defines 16 functions named f2_0 to f2_15, which all just call f2 */
|
|
|
c41d59 |
+#define REP(n) \
|
|
|
c41d59 |
+ __attribute__ ((noinline, noclone, weak)) void \
|
|
|
c41d59 |
+ f2_##n (void) { f2(); PREVENT_TAIL_CALL; };
|
|
|
c41d59 |
+REPS
|
|
|
c41d59 |
+#undef REP
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+__attribute__ ((noinline, noclone, weak)) void
|
|
|
c41d59 |
+f3 (int count)
|
|
|
c41d59 |
+{
|
|
|
c41d59 |
+ for (int i = 0; i < count; ++i)
|
|
|
c41d59 |
+ {
|
|
|
c41d59 |
+ /* Calls f1_0(), f2_0(), f1_1(), f2_1(), f3_0(), etc */
|
|
|
c41d59 |
+# define REP(n) f1_##n(); f2_##n();
|
|
|
c41d59 |
+ REPS
|
|
|
c41d59 |
+# undef REP
|
|
|
c41d59 |
+ }
|
|
|
c41d59 |
+}
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+int
|
|
|
c41d59 |
+main (void)
|
|
|
c41d59 |
+{
|
|
|
c41d59 |
+ f3 (1000);
|
|
|
c41d59 |
+ return 0;
|
|
|
c41d59 |
+}
|
|
|
c41d59 |
diff --git a/manual/tunables.texi b/manual/tunables.texi
|
|
|
c41d59 |
index 7b70e80391ee87f7..00eafcf44b562b9e 100644
|
|
|
c41d59 |
--- a/manual/tunables.texi
|
|
|
c41d59 |
+++ b/manual/tunables.texi
|
|
|
c41d59 |
@@ -73,6 +73,9 @@ glibc.malloc.check: 0 (min: 0, max: 3)
|
|
|
c41d59 |
* Elision Tunables:: Tunables in elision subsystem
|
|
|
c41d59 |
* Hardware Capability Tunables:: Tunables that modify the hardware
|
|
|
c41d59 |
capabilities seen by @theglibc{}
|
|
|
c41d59 |
+* gmon Tunables:: Tunables that control the gmon profiler, used in
|
|
|
c41d59 |
+ conjunction with gprof
|
|
|
c41d59 |
+
|
|
|
c41d59 |
@end menu
|
|
|
c41d59 |
|
|
|
c41d59 |
@node Tunable names
|
|
|
c41d59 |
@@ -506,3 +509,59 @@ instead.
|
|
|
c41d59 |
|
|
|
c41d59 |
This tunable is specific to i386 and x86-64.
|
|
|
c41d59 |
@end deftp
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+@node gmon Tunables
|
|
|
c41d59 |
+@section gmon Tunables
|
|
|
c41d59 |
+@cindex gmon tunables
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+@deftp {Tunable namespace} glibc.gmon
|
|
|
c41d59 |
+This tunable namespace affects the behaviour of the gmon profiler.
|
|
|
c41d59 |
+gmon is a component of @theglibc{} which is normally used in
|
|
|
c41d59 |
+conjunction with gprof.
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+When GCC compiles a program with the @code{-pg} option, it instruments
|
|
|
c41d59 |
+the program with calls to the @code{mcount} function, to record the
|
|
|
c41d59 |
+program's call graph. At program startup, a memory buffer is allocated
|
|
|
c41d59 |
+to store this call graph; the size of the buffer is calculated using a
|
|
|
c41d59 |
+heuristic based on code size. If during execution, the buffer is found
|
|
|
c41d59 |
+to be too small, profiling will be aborted and no @file{gmon.out} file
|
|
|
c41d59 |
+will be produced. In that case, you will see the following message
|
|
|
c41d59 |
+printed to standard error:
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+@example
|
|
|
c41d59 |
+mcount: call graph buffer size limit exceeded, gmon.out will not be generated
|
|
|
c41d59 |
+@end example
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+Most of the symbols discussed in this section are defined in the header
|
|
|
c41d59 |
+@code{sys/gmon.h}. However, some symbols (for example @code{mcount})
|
|
|
c41d59 |
+are not defined in any header file, since they are only intended to be
|
|
|
c41d59 |
+called from code generated by the compiler.
|
|
|
c41d59 |
+@end deftp
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+@deftp Tunable glibc.mem.minarcs
|
|
|
c41d59 |
+The heuristic for sizing the call graph buffer is known to be
|
|
|
c41d59 |
+insufficient for small programs; hence, the calculated value is clamped
|
|
|
c41d59 |
+to be at least a minimum size. The default minimum (in units of
|
|
|
c41d59 |
+call graph entries, @code{struct tostruct}), is given by the macro
|
|
|
c41d59 |
+@code{MINARCS}. If you have some program with an unusually complex
|
|
|
c41d59 |
+call graph, for which the heuristic fails to allocate enough space,
|
|
|
c41d59 |
+you can use this tunable to increase the minimum to a larger value.
|
|
|
c41d59 |
+@end deftp
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+@deftp Tunable glibc.mem.maxarcs
|
|
|
c41d59 |
+To prevent excessive memory consumption when profiling very large
|
|
|
c41d59 |
+programs, the call graph buffer is allowed to have a maximum of
|
|
|
c41d59 |
+@code{MAXARCS} entries. For some very large programs, the default
|
|
|
c41d59 |
+value of @code{MAXARCS} defined in @file{sys/gmon.h} is too small; in
|
|
|
c41d59 |
+that case, you can use this tunable to increase it.
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+Note the value of the @code{maxarcs} tunable must be greater or equal
|
|
|
c41d59 |
+to that of the @code{minarcs} tunable; if this constraint is violated,
|
|
|
c41d59 |
+a warning will printed to standard error at program startup, and
|
|
|
c41d59 |
+the @code{minarcs} value will be used as the maximum as well.
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+Setting either tunable too high may result in a call graph buffer
|
|
|
c41d59 |
+whose size exceeds the available memory; in that case, an out of memory
|
|
|
c41d59 |
+error will be printed at program startup, the profiler will be
|
|
|
c41d59 |
+disabled, and no @file{gmon.out} file will be generated.
|
|
|
c41d59 |
+@end deftp
|
|
|
c41d59 |
diff --git a/sysdeps/unix/sysv/linux/aarch64/dl-tunables.list b/sysdeps/unix/sysv/linux/aarch64/dl-tunables.list
|
|
|
c41d59 |
index 5c3c5292025607a1..265f82ef2be42fd0 100644
|
|
|
c41d59 |
--- a/sysdeps/unix/sysv/linux/aarch64/dl-tunables.list
|
|
|
c41d59 |
+++ b/sysdeps/unix/sysv/linux/aarch64/dl-tunables.list
|
|
|
c41d59 |
@@ -24,3 +24,7 @@
|
|
|
c41d59 |
|
|
|
c41d59 |
# Tunables added in RHEL 8.8.0
|
|
|
c41d59 |
@order glibc.rtld.dynamic_sort
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+# Tunables added in RHEL 8.9.0
|
|
|
c41d59 |
+@order glibc.gmon.minarcs
|
|
|
c41d59 |
+@order glibc.gmon.maxarcs
|
|
|
c41d59 |
diff --git a/sysdeps/unix/sysv/linux/i386/dl-tunables.list b/sysdeps/unix/sysv/linux/i386/dl-tunables.list
|
|
|
c41d59 |
index b9cad4af62d9f2e5..9c1ccb86501c61e7 100644
|
|
|
c41d59 |
--- a/sysdeps/unix/sysv/linux/i386/dl-tunables.list
|
|
|
c41d59 |
+++ b/sysdeps/unix/sysv/linux/i386/dl-tunables.list
|
|
|
c41d59 |
@@ -31,3 +31,7 @@
|
|
|
c41d59 |
|
|
|
c41d59 |
# Tunables added in RHEL 8.8.0
|
|
|
c41d59 |
@order glibc.rtld.dynamic_sort
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+# Tunables added in RHEL 8.9.0
|
|
|
c41d59 |
+@order glibc.gmon.minarcs
|
|
|
c41d59 |
+@order glibc.gmon.maxarcs
|
|
|
c41d59 |
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/dl-tunables.list b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/dl-tunables.list
|
|
|
c41d59 |
index ee1e6fca95e1f2da..c8bb1a8ec0283ac8 100644
|
|
|
c41d59 |
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/dl-tunables.list
|
|
|
c41d59 |
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/dl-tunables.list
|
|
|
c41d59 |
@@ -24,3 +24,7 @@
|
|
|
c41d59 |
|
|
|
c41d59 |
# Tunables added in RHEL 8.8.0
|
|
|
c41d59 |
@order glibc.rtld.dynamic_sort
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+# Tunables added in RHEL 8.9.0
|
|
|
c41d59 |
+@order glibc.gmon.minarcs
|
|
|
c41d59 |
+@order glibc.gmon.maxarcs
|
|
|
c41d59 |
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/dl-tunables.list b/sysdeps/unix/sysv/linux/s390/s390-64/dl-tunables.list
|
|
|
c41d59 |
index 099e28d8f8e67944..85b3a014ffcadc45 100644
|
|
|
c41d59 |
--- a/sysdeps/unix/sysv/linux/s390/s390-64/dl-tunables.list
|
|
|
c41d59 |
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/dl-tunables.list
|
|
|
c41d59 |
@@ -23,3 +23,7 @@
|
|
|
c41d59 |
|
|
|
c41d59 |
# Tunables added in RHEL 8.8.0
|
|
|
c41d59 |
@order glibc.rtld.dynamic_sort
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+# Tunables added in RHEL 8.9.0
|
|
|
c41d59 |
+@order glibc.gmon.minarcs
|
|
|
c41d59 |
+@order glibc.gmon.maxarcs
|
|
|
c41d59 |
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/dl-tunables.list b/sysdeps/unix/sysv/linux/x86_64/64/dl-tunables.list
|
|
|
c41d59 |
index b9cad4af62d9f2e5..9c1ccb86501c61e7 100644
|
|
|
c41d59 |
--- a/sysdeps/unix/sysv/linux/x86_64/64/dl-tunables.list
|
|
|
c41d59 |
+++ b/sysdeps/unix/sysv/linux/x86_64/64/dl-tunables.list
|
|
|
c41d59 |
@@ -31,3 +31,7 @@
|
|
|
c41d59 |
|
|
|
c41d59 |
# Tunables added in RHEL 8.8.0
|
|
|
c41d59 |
@order glibc.rtld.dynamic_sort
|
|
|
c41d59 |
+
|
|
|
c41d59 |
+# Tunables added in RHEL 8.9.0
|
|
|
c41d59 |
+@order glibc.gmon.minarcs
|
|
|
c41d59 |
+@order glibc.gmon.maxarcs
|