use probe_limt from env
authorcongwu <congwu@alauda.io>
Sat, 4 Dec 2021 06:38:15 +0000 (14:38 +0800)
committeryonghong-song <ys114321@gmail.com>
Sat, 11 Dec 2021 18:53:19 +0000 (10:53 -0800)
src/python/bcc/__init__.py
tools/funccount.py

index 2c014c786505616ba0cbeb588d5f02918ccf6e4f..389bc8ba6b511c39141cb3733949f89ad842ee8a 100644 (file)
@@ -36,7 +36,7 @@ try:
 except NameError:  # Python 3
     basestring = str
 
-_probe_limit = 1000
+_default_probe_limit = 1000
 _num_open_probes = 0
 
 # for tests
@@ -751,9 +751,17 @@ class BPF(object):
 
     def _check_probe_quota(self, num_new_probes):
         global _num_open_probes
-        if _num_open_probes + num_new_probes > _probe_limit:
+        if _num_open_probes + num_new_probes > BPF.get_probe_limit():
             raise Exception("Number of open probes would exceed global quota")
 
+    @staticmethod
+    def get_probe_limit():
+        env_probe_limit = os.environ.get('BCC_PROBE_LIMIT')
+        if env_probe_limit and env_probe_limit.isdigit():
+            return int(env_probe_limit)
+        else:
+            return _default_probe_limit
+
     def _add_kprobe_fd(self, ev_name, fn_name, fd):
         global _num_open_probes
         if ev_name not in self.kprobe_fds:
index 24b293820a848e28bf5ede2e4978cf4ab1698703..96cfb5296ff2da1eca4f7b45b812a014051610dc 100755 (executable)
@@ -28,7 +28,7 @@ import traceback
 debug = False
 
 def verify_limit(num):
-    probe_limit = 1000
+    probe_limit = BPF.get_probe_limit()
     if num > probe_limit:
         raise Exception("maximum of %d probes allowed, attempted %d" %
                         (probe_limit, num))