Skip to content

Commit

Permalink
use probe_limt from env
Browse files Browse the repository at this point in the history
  • Loading branch information
woodgear authored and yonghong-song committed Dec 11, 2021
1 parent f32f772 commit 7050037
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
except NameError: # Python 3
basestring = str

_probe_limit = 1000
_default_probe_limit = 1000
_num_open_probes = 0

# for tests
Expand Down Expand Up @@ -751,9 +751,17 @@ def get_kprobe_functions(event_re):

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:
Expand Down
2 changes: 1 addition & 1 deletion tools/funccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
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))
Expand Down

0 comments on commit 7050037

Please sign in to comment.