From aaf7ffe85f54349200ffb60aff628fb9fe68be75 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 21 Aug 2009 17:16:13 -0400 Subject: [PATCH] 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. --- tapsets.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tapsets.cxx b/tapsets.cxx index ddb5696d9..76c93a98c 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -47,6 +47,7 @@ extern "C" { #include #include #include +#include #define __STDC_FORMAT_MACROS #include @@ -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; -- 2.43.5