Commit b2e68700 authored by Andrii Nakryiko's avatar Andrii Nakryiko

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

parent 41134b10
...@@ -306,14 +306,13 @@ StatusTuple BPFPerfBuffer::close_all_cpu() { ...@@ -306,14 +306,13 @@ StatusTuple BPFPerfBuffer::close_all_cpu() {
return StatusTuple(0); return StatusTuple(0);
} }
void BPFPerfBuffer::poll(int timeout_ms) { int BPFPerfBuffer::poll(int timeout_ms) {
if (epfd_ < 0) if (epfd_ < 0)
return; return -1;
int cnt = epoll_wait(epfd_, ep_events_.get(), cpu_readers_.size(), timeout_ms); int cnt = epoll_wait(epfd_, ep_events_.get(), cpu_readers_.size(), timeout_ms);
if (cnt <= 0)
return;
for (int i = 0; i < cnt; i++) for (int i = 0; i < cnt; i++)
perf_reader_event_read(static_cast<perf_reader*>(ep_events_[i].data.ptr)); perf_reader_event_read(static_cast<perf_reader*>(ep_events_[i].data.ptr));
return cnt;
} }
BPFPerfBuffer::~BPFPerfBuffer() { BPFPerfBuffer::~BPFPerfBuffer() {
......
...@@ -310,7 +310,7 @@ class BPFPerfBuffer : public BPFTableBase<int, int> { ...@@ -310,7 +310,7 @@ class BPFPerfBuffer : public BPFTableBase<int, int> {
StatusTuple open_all_cpu(perf_reader_raw_cb cb, perf_reader_lost_cb lost_cb, StatusTuple open_all_cpu(perf_reader_raw_cb cb, perf_reader_lost_cb lost_cb,
void* cb_cookie, int page_cnt); void* cb_cookie, int page_cnt);
StatusTuple close_all_cpu(); StatusTuple close_all_cpu();
void poll(int timeout_ms); int poll(int timeout_ms);
private: private:
StatusTuple open_on_cpu(perf_reader_raw_cb cb, perf_reader_lost_cb lost_cb, StatusTuple open_on_cpu(perf_reader_raw_cb cb, perf_reader_lost_cb lost_cb,
......
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