summaryrefslogtreecommitdiffstats
path: root/tapsets.cxx
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2009-08-21 17:16:13 -0400
committerFrank Ch. Eigler <fche@elastic.org>2009-08-21 17:16:13 -0400
commitaaf7ffe85f54349200ffb60aff628fb9fe68be75 (patch)
tree4073892eab6390b591e911d51696df8389471d1f /tapsets.cxx
parent72bfb1fdb84ff5e17bc2a81b1ec25215db700ceb (diff)
downloadsystemtap-steved-aaf7ffe85f54349200ffb60aff628fb9fe68be75.tar.gz
systemtap-steved-aaf7ffe85f54349200ffb60aff628fb9fe68be75.tar.xz
systemtap-steved-aaf7ffe85f54349200ffb60aff628fb9fe68be75.zip
PR10507: tweak MAXUPROBES calculation to shrink table for small static number of probes
* tapsets.cxx (uprobe_derived_probe_group::emit_module_decls): Use geometric mean rather than arithmetic mean. Add a comment to explain relative harmlessness of exceeding the "minimum" or "maximum" values.
Diffstat (limited to 'tapsets.cxx')
-rw-r--r--tapsets.cxx10
1 files changed, 7 insertions, 3 deletions
diff --git a/tapsets.cxx b/tapsets.cxx
index ddb5696d..76c93a98 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -47,6 +47,7 @@ extern "C" {
#include <fnmatch.h>
#include <stdio.h>
#include <sys/types.h>
+#include <math.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
@@ -4399,9 +4400,12 @@ uprobe_derived_probe_group::emit_module_decls (systemtap_session& s)
unsigned maxuprobesmem = 10*1024*1024; // 10 MB
unsigned maxuprobes = maxuprobesmem / uprobesize;
- // Let's choose a value on the middle, but clamped on the minimum size
- unsigned default_maxuprobes =
- (minuprobes < maxuprobes) ? ((minuprobes + maxuprobes) / 2) : minuprobes;
+ // Let's choose a value on the geometric middle. This should end up
+ // between minuprobes and maxuprobes. It's OK if this number turns
+ // out to be < minuprobes or > maxuprobes. At worst, we get a
+ // run-time error of one kind (too few: missed uprobe registrations)
+ // or another (too many: vmalloc errors at module load time).
+ unsigned default_maxuprobes = (unsigned)sqrt((double)minuprobes * (double)maxuprobes);
s.op->newline() << "#ifndef MAXUPROBES";
s.op->newline() << "#define MAXUPROBES " << default_maxuprobes;