]> sourceware.org Git - systemtap.git/commitdiff
PR10507: tweak MAXUPROBES calculation to shrink table for small static number of...
authorFrank Ch. Eigler <fche@elastic.org>
Fri, 21 Aug 2009 21:16:13 +0000 (17:16 -0400)
committerFrank Ch. Eigler <fche@elastic.org>
Fri, 21 Aug 2009 21:16:13 +0000 (17:16 -0400)
* 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

index ddb5696d97c9fd4fc91caa1e3cf25071fe8afe61..76c93a98ce141d155a5f4762361b533fc5795397 100644 (file)
@@ -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;
This page took 0.04716 seconds and 5 git commands to generate.