MCPcopy Create free account
hub / github.com/iovisor/bcc / _open_perf_buffer

Method _open_perf_buffer

src/python/bcc/table.py:989–1021  ·  view source on GitHub ↗
(self, cpu, callback, page_cnt, lost_cb, wakeup_events)

Source from the content-addressed store, hash-verified

987 self._open_perf_buffer(i, callback, page_cnt, lost_cb, wakeup_events)
988
989 def _open_perf_buffer(self, cpu, callback, page_cnt, lost_cb, wakeup_events):
990 def raw_cb_(_, data, size):
991 try:
992 callback(cpu, data, size)
993 except IOError as e:
994 if e.errno == errno.EPIPE:
995 exit()
996 else:
997 raise e
998 def lost_cb_(_, lost):
999 try:
1000 lost_cb(lost)
1001 except IOError as e:
1002 if e.errno == errno.EPIPE:
1003 exit()
1004 else:
1005 raise e
1006 fn = _RAW_CB_TYPE(raw_cb_)
1007 lost_fn = _LOST_CB_TYPE(lost_cb_) if lost_cb else ct.cast(None, _LOST_CB_TYPE)
1008 opts = bcc_perf_buffer_opts()
1009 opts.pid = -1
1010 opts.cpu = cpu
1011 opts.wakeup_events = wakeup_events
1012 reader = lib.bpf_open_perf_buffer_opts(fn, lost_fn, None, page_cnt, ct.byref(opts))
1013 if not reader:
1014 raise Exception("Could not open perf buffer")
1015 fd = lib.perf_reader_fd(reader)
1016 self[self.Key(cpu)] = self.Leaf(fd)
1017 self.bpf.perf_buffers[(id(self), cpu)] = reader
1018 # keep a refcnt
1019 self._cbs[cpu] = (fn, lost_fn)
1020 # The actual fd is held by the perf reader, add to track opened keys
1021 self._open_key_fds[cpu] = -1
1022
1023 def _open_perf_event(self, cpu, typ, config, pid=-1):
1024 fd = lib.bpf_open_perf_event(typ, config, pid, cpu)

Callers 1

open_perf_bufferMethod · 0.95

Calls 1

Tested by

no test coverage detected