Commit 50295999 authored by Andrii Nakryiko's avatar Andrii Nakryiko

Return number of CPUs with data for BPFPerfBufferTable::poll()

parent b2e68700
......@@ -495,11 +495,11 @@ BPFPerfBuffer* BPF::get_perf_buffer(const std::string& name) {
return (it == perf_buffers_.end()) ? nullptr : it->second;
}
void BPF::poll_perf_buffer(const std::string& name, int timeout_ms) {
int BPF::poll_perf_buffer(const std::string& name, int timeout_ms) {
auto it = perf_buffers_.find(name);
if (it == perf_buffers_.end())
return;
it->second->poll(timeout_ms);
return -1;
return it->second->poll(timeout_ms);
}
StatusTuple BPF::load_func(const std::string& func_name, bpf_prog_type type,
......
......@@ -155,7 +155,11 @@ class BPF {
BPFPerfBuffer* get_perf_buffer(const std::string& name);
// Poll an opened Perf Buffer of given name with given timeout, using callback
// provided when opening. Do nothing if such open Perf Buffer doesn't exist.
void poll_perf_buffer(const std::string& name, int timeout_ms = -1);
// Returns:
// -1 on error or if perf buffer with such name doesn't exist;
// 0, if no data was available before timeout;
// number of CPUs that have new data, otherwise.
int poll_perf_buffer(const std::string& name, int timeout_ms = -1);
StatusTuple load_func(const std::string& func_name, enum bpf_prog_type type,
int& fd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment