summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/systemtap
diff options
context:
space:
mode:
authorRoss Burton <ross@burtonini.com>2022-01-31 13:54:07 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-02-01 07:31:18 +0000
commit80bddd7c36412f758f1d43036c3f4845cbc87b6c (patch)
treee21008115c8ef01b6fd428b14ee8bc727a70e221 /meta/recipes-kernel/systemtap
parent440a5f6ee682a9ab17a3da00178733b39749bdcf (diff)
downloadpoky-80bddd7c36412f758f1d43036c3f4845cbc87b6c.tar.gz
systemtap: backport buffer size tuning patches
Backport a nunber of patches from upstream to tune the buffer size on machines with a "small amount" of memory, which appears to mean less than 4GB. (From OE-Core rev: d1e1c8698a5143a1e5d80d172105b76c57b85dd6) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-kernel/systemtap')
-rw-r--r--meta/recipes-kernel/systemtap/systemtap/0001-PR28804-tune-default-stap-s-buffer-size-on-small-RAM.patch84
-rw-r--r--meta/recipes-kernel/systemtap/systemtap_git.inc1
2 files changed, 85 insertions, 0 deletions
diff --git a/meta/recipes-kernel/systemtap/systemtap/0001-PR28804-tune-default-stap-s-buffer-size-on-small-RAM.patch b/meta/recipes-kernel/systemtap/systemtap/0001-PR28804-tune-default-stap-s-buffer-size-on-small-RAM.patch
new file mode 100644
index 0000000000..931310db53
--- /dev/null
+++ b/meta/recipes-kernel/systemtap/systemtap/0001-PR28804-tune-default-stap-s-buffer-size-on-small-RAM.patch
@@ -0,0 +1,84 @@
1Upstream-Status: Backport
2Signed-off-by: Ross Burton <ross.burton@arm.com>
3
4PR28804: tune default stap -s ## buffer size on small RAM machines
5
6Insert a forgotten division by num_online_cpu() to adjust downward the
7calculated bufsize. Tweak normal defaults back to 128 * 2 * 64K
8(16MB) per CPU, as the stap man page indicates. This may need further
9tweaking when balancing against staprun consumption performance, but
10at least we have the docs lined up with the code at the moment.
11
12PR28804: tune default stap -s ## buffer size on small RAM machines
13
14Use si_meminfo to limit default buffer size. Note in the man page
15that the "-s ##" parameter is per-CPU.
16
17diff --git a/man/stap.1.in b/man/stap.1.in
18index 55dbc2c93..285a27b34 100644
19--- a/man/stap.1.in
20+++ b/man/stap.1.in
21@@ -239,8 +239,8 @@ and average amount of time spent in each probe-point. Also shows
22 the derivation for each probe-point.
23 .TP
24 .BI \-s " NUM"
25-Use NUM megabyte buffers for kernel-to-user data transfer. On a
26-multiprocessor in bulk mode, this is a per-processor amount.
27+Use NUM megabyte buffers for kernel-to-user data transfer per processor.
28+The default is 16MB, or less on smaller memory machines.
29 .TP
30 .BI \-I " DIR"
31 Add the given directory to the tapset search directory. See the
32diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c
33index 18ecccea2..44afff814 100644
34--- a/runtime/transport/transport.c
35+++ b/runtime/transport/transport.c
36@@ -72,8 +72,11 @@ static inline void _stp_unlock_inode(struct inode *inode);
37 #include "procfs.c"
38 #include "control.c"
39
40-static unsigned _stp_nsubbufs = 256;
41-static unsigned _stp_subbuf_size = 8 * STP_BUFFER_SIZE; /* 64K */
42+/* set default buffer parameters. User may override these via stap -s #, and
43+ the runtime may auto-shrink it on low memory machines too. */
44+/* NB: Note default in man/stap.1.in */
45+static unsigned _stp_nsubbufs = 128;
46+static unsigned _stp_subbuf_size = 2 * STP_BUFFER_SIZE; /* 2 * 64K */
47
48 /* module parameters */
49 static int _stp_bufsize;
50@@ -602,17 +605,30 @@ static int _stp_transport_init(void)
51 _stp_need_kallsyms_stext = 0;
52 #endif
53
54- if (_stp_bufsize) {
55- unsigned size = _stp_bufsize * 1024 * 1024;
56+ if (_stp_bufsize == 0) { // option not specified?
57+ struct sysinfo si;
58+ long _stp_bufsize_avail;
59+ si_meminfo(&si);
60+ _stp_bufsize_avail = (long)((si.freeram + si.bufferram) / 4 / num_online_cpus())
61+ << PAGE_SHIFT; // limit to quarter of free ram total
62+ if ((_stp_nsubbufs * _stp_subbuf_size * num_online_cpus()) > _stp_bufsize_avail) {
63+ _stp_bufsize = max_t (int, 1, _stp_bufsize_avail / 1024 / 1024);
64+ dbug_trans(1, "Shrinking default _stp_bufsize to %d MB/cpu due to low free memory\n", _stp_bufsize);
65+ }
66+ }
67+
68+ if (_stp_bufsize) { // overridden by user or by si_meminfo heuristic?
69+ long size = _stp_bufsize * 1024 * 1024;
70 _stp_subbuf_size = 65536;
71+ // bump up subbuf size from 64K to 1M to keep _stp_nsubbufs not too large
72 while (size / _stp_subbuf_size > 64 &&
73 _stp_subbuf_size < 1024 * 1024) {
74 _stp_subbuf_size <<= 1;
75 }
76 _stp_nsubbufs = size / _stp_subbuf_size;
77- dbug_trans(1, "Using %d subbufs of size %d\n", _stp_nsubbufs, _stp_subbuf_size);
78 }
79-
80+ dbug_trans(1, "Using %d subbufs of size %d\n", _stp_nsubbufs, _stp_subbuf_size);
81+
82 ret = _stp_transport_fs_init(THIS_MODULE->name);
83 if (ret)
84 goto err0;
diff --git a/meta/recipes-kernel/systemtap/systemtap_git.inc b/meta/recipes-kernel/systemtap/systemtap_git.inc
index 36c934c2fa..a7c8bbc589 100644
--- a/meta/recipes-kernel/systemtap/systemtap_git.inc
+++ b/meta/recipes-kernel/systemtap/systemtap_git.inc
@@ -8,6 +8,7 @@ SRC_URI = "git://sourceware.org/git/systemtap.git;branch=master \
8 file://0001-Install-python-modules-to-correct-library-dir.patch \ 8 file://0001-Install-python-modules-to-correct-library-dir.patch \
9 file://0001-staprun-stapbpf-don-t-support-installing-a-non-root.patch \ 9 file://0001-staprun-stapbpf-don-t-support-installing-a-non-root.patch \
10 file://0001-PR28778-gcc-warning-tweak-for-sprintf-precision-para.patch \ 10 file://0001-PR28778-gcc-warning-tweak-for-sprintf-precision-para.patch \
11 file://0001-PR28804-tune-default-stap-s-buffer-size-on-small-RAM.patch \
11 " 12 "
12 13
13COMPATIBLE_HOST = '(x86_64|i.86|powerpc|arm|aarch64|microblazeel|mips).*-linux' 14COMPATIBLE_HOST = '(x86_64|i.86|powerpc|arm|aarch64|microblazeel|mips).*-linux'