From 7d46a51f0045df26ec8e0527173b3376066d6318 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Wed, 26 Jan 2022 14:10:38 -0500 Subject: [PATCH] PR28804: tune default stap -s ## buffer size on small RAM machines Insert a forgotten division by num_online_cpu() to adjust downward the calculated bufsize. Tweak normal defaults back to 128 * 2 * 64K (16MB) per CPU, as the stap man page indicates. This may need further tweaking when balancing against staprun consumption performance, but at least we have the docs lined up with the code at the moment. --- runtime/transport/transport.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index e9795cc6d..44afff814 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -75,8 +75,8 @@ static inline void _stp_unlock_inode(struct inode *inode); /* set default buffer parameters. User may override these via stap -s #, and the runtime may auto-shrink it on low memory machines too. */ /* NB: Note default in man/stap.1.in */ -static unsigned _stp_nsubbufs = 256; -static unsigned _stp_subbuf_size = 8 * STP_BUFFER_SIZE; /* 64K */ +static unsigned _stp_nsubbufs = 128; +static unsigned _stp_subbuf_size = 2 * STP_BUFFER_SIZE; /* 2 * 64K */ /* module parameters */ static int _stp_bufsize; @@ -609,10 +609,11 @@ static int _stp_transport_init(void) struct sysinfo si; long _stp_bufsize_avail; si_meminfo(&si); - _stp_bufsize_avail = (long)((si.freeram + si.bufferram) / 4) << PAGE_SHIFT; // limit to quarter of free ram + _stp_bufsize_avail = (long)((si.freeram + si.bufferram) / 4 / num_online_cpus()) + << PAGE_SHIFT; // limit to quarter of free ram total if ((_stp_nsubbufs * _stp_subbuf_size * num_online_cpus()) > _stp_bufsize_avail) { _stp_bufsize = max_t (int, 1, _stp_bufsize_avail / 1024 / 1024); - dbug_trans(1, "Shrinking default _stp_bufsize to %d MB due to low free memory\n", _stp_bufsize); + dbug_trans(1, "Shrinking default _stp_bufsize to %d MB/cpu due to low free memory\n", _stp_bufsize); } } -- 2.43.5