Author: stas
Date: Tue Dec  1 00:24:54 2015
New Revision: 291545
URL: https://svnweb.freebsd.org/changeset/base/291545

Log:
  Make the number of fasttrap probes and the size of the trace points hash table
  tunable via sysctl or kernel tunables.
  
  Illumos allows this parameters to be changed via the fasttrap.conf 
configuration
  file, but FreeBSD code hardcoded the parameters.  Expose them under
  the kern.dtrace.fasttrap sysctl tree.
  
  MFC after:    2 weeks

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c      Mon Nov 
30 23:37:09 2015        (r291544)
+++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c      Tue Dec 
 1 00:24:54 2015        (r291545)
@@ -63,6 +63,7 @@
 #ifndef illumos
 #include <sys/dtrace_bsd.h>
 #include <sys/eventhandler.h>
+#include <sys/sysctl.h>
 #include <sys/u8_textprep.h>
 #include <sys/user.h>
 #include <vm/vm.h>
@@ -172,13 +173,14 @@ static volatile uint64_t fasttrap_mod_ge
 
 /*
  * When the fasttrap provider is loaded, fasttrap_max is set to either
- * FASTTRAP_MAX_DEFAULT or the value for fasttrap-max-probes in the
- * fasttrap.conf file. Each time a probe is created, fasttrap_total is
- * incremented by the number of tracepoints that may be associated with that
- * probe; fasttrap_total is capped at fasttrap_max.
+ * FASTTRAP_MAX_DEFAULT, or the value for fasttrap-max-probes in the
+ * fasttrap.conf file (Illumos), or the value provied in the loader.conf 
(FreeBSD).
+ * Each time a probe is created, fasttrap_total is incremented by the number
+ * of tracepoints that may be associated with that probe; fasttrap_total is 
capped
+ * at fasttrap_max.
  */
 #define        FASTTRAP_MAX_DEFAULT            250000
-static uint32_t fasttrap_max;
+static uint32_t fasttrap_max = FASTTRAP_MAX_DEFAULT;
 static uint32_t fasttrap_total;
 
 /*
@@ -226,6 +228,17 @@ static kmutex_t fasttrap_cpuc_pid_lock[M
 static eventhandler_tag fasttrap_thread_dtor_tag;
 #endif
 
+static unsigned long tpoints_hash_size = FASTTRAP_TPOINTS_DEFAULT_SIZE;
+
+#ifdef __FreeBSD__
+SYSCTL_DECL(_kern_dtrace);
+SYSCTL_NODE(_kern_dtrace, OID_AUTO, fasttrap, CTLFLAG_RD, 0, "DTrace fasttrap 
parameters");
+SYSCTL_UINT(_kern_dtrace_fasttrap, OID_AUTO, max_probes, CTLFLAG_RWTUN, 
&fasttrap_max,
+    FASTTRAP_MAX_DEFAULT, "Maximum number of fasttrap probes");
+SYSCTL_ULONG(_kern_dtrace_fasttrap, OID_AUTO, tpoints_hash_size, 
CTLFLAG_RDTUN, &tpoints_hash_size,
+    FASTTRAP_TPOINTS_DEFAULT_SIZE, "Size of the tracepoint hash table");
+#endif
+
 static int
 fasttrap_highbit(ulong_t i)
 {
@@ -2480,8 +2493,6 @@ fasttrap_load(void)
 #ifdef illumos
        fasttrap_max = ddi_getprop(DDI_DEV_T_ANY, devi, DDI_PROP_DONTPASS,
            "fasttrap-max-probes", FASTTRAP_MAX_DEFAULT);
-#else
-       fasttrap_max = FASTTRAP_MAX_DEFAULT;
 #endif
        fasttrap_total = 0;
 
@@ -2492,12 +2503,14 @@ fasttrap_load(void)
        nent = ddi_getprop(DDI_DEV_T_ANY, devi, DDI_PROP_DONTPASS,
            "fasttrap-hash-size", FASTTRAP_TPOINTS_DEFAULT_SIZE);
 #else
-       nent = FASTTRAP_TPOINTS_DEFAULT_SIZE;
+       nent = tpoints_hash_size;
 #endif
 
        if (nent == 0 || nent > 0x1000000)
                nent = FASTTRAP_TPOINTS_DEFAULT_SIZE;
 
+       tpoints_hash_size = nent;
+
        if (ISP2(nent))
                fasttrap_tpoints.fth_nent = nent;
        else
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to