Skip to content

Commit

Permalink
expose BufferSize for perf/ringbuf
Browse files Browse the repository at this point in the history
  • Loading branch information
brycekahle committed Nov 9, 2023
1 parent fd61534 commit 26ef88f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions perfmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ func (m *PerfMap) Resume() error {
return nil
}

// BufferSize is the size in bytes of each per-CPU buffer
func (m *PerfMap) BufferSize() int {
if m.perfReader == nil {
return 0
}
return m.perfReader.BufferSize()
}

func isPerfClosed(err error) bool {
return errors.Is(err, perf.ErrClosed)
}
8 changes: 8 additions & 0 deletions ringbuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ func (rb *RingBuffer) Stop(cleanup MapCleanupType) error {
return err
}

// BufferSize returns the size in bytes of the ring buffer
func (rb *RingBuffer) BufferSize() int {
if rb.ringReader == nil {
return 0
}
return rb.ringReader.BufferSize()
}

func isRingBufferClosed(err error) bool {
return errors.Is(err, ringbuf.ErrClosed)
}

0 comments on commit 26ef88f

Please sign in to comment.