Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
570fd5e3
Commit
570fd5e3
authored
Mar 05, 2018
by
Teng Qin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow obtaining BPFPerfBuffer pointer for polling
parent
0bd29aab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
examples/cpp/FollyRequestContextSwitch.cc
examples/cpp/FollyRequestContextSwitch.cc
+5
-2
src/cc/api/BPF.cc
src/cc/api/BPF.cc
+5
-0
src/cc/api/BPF.h
src/cc/api/BPF.h
+9
-0
No files found.
examples/cpp/FollyRequestContextSwitch.cc
View file @
570fd5e3
...
...
@@ -98,8 +98,11 @@ int main(int argc, char** argv) {
signal
(
SIGINT
,
signal_handler
);
std
::
cout
<<
"Started tracing, hit Ctrl-C to terminate."
<<
std
::
endl
;
while
(
true
)
bpf
->
poll_perf_buffer
(
"events"
);
auto
perf_buffer
=
bpf
->
get_perf_buffer
(
"events"
);
if
(
perf_buffer
)
while
(
true
)
// 100ms timeout
perf_buffer
->
poll
(
100
);
return
0
;
}
src/cc/api/BPF.cc
View file @
570fd5e3
...
...
@@ -443,6 +443,11 @@ StatusTuple BPF::close_perf_buffer(const std::string& name) {
return
StatusTuple
(
0
);
}
BPFPerfBuffer
*
BPF
::
get_perf_buffer
(
const
std
::
string
&
name
)
{
auto
it
=
perf_buffers_
.
find
(
name
);
return
(
it
==
perf_buffers_
.
end
())
?
nullptr
:
it
->
second
;
}
void
BPF
::
poll_perf_buffer
(
const
std
::
string
&
name
,
int
timeout_ms
)
{
auto
it
=
perf_buffers_
.
find
(
name
);
if
(
it
==
perf_buffers_
.
end
())
...
...
src/cc/api/BPF.h
View file @
570fd5e3
...
...
@@ -136,11 +136,20 @@ class BPF {
StatusTuple
close_perf_event
(
const
std
::
string
&
name
);
// Open a Perf Buffer of given name, providing callback and callback cookie
// to use when polling. BPF class owns the opened Perf Buffer and will free
// it on-demand or on destruction.
StatusTuple
open_perf_buffer
(
const
std
::
string
&
name
,
perf_reader_raw_cb
cb
,
perf_reader_lost_cb
lost_cb
=
nullptr
,
void
*
cb_cookie
=
nullptr
,
int
page_cnt
=
DEFAULT_PERF_BUFFER_PAGE_CNT
);
// Close and free the Perf Buffer of given name.
StatusTuple
close_perf_buffer
(
const
std
::
string
&
name
);
// Obtain an pointer to the opened BPFPerfBuffer instance of given name.
// Will return nullptr if such open Perf Buffer doesn't exist.
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
);
StatusTuple
load_func
(
const
std
::
string
&
func_name
,
enum
bpf_prog_type
type
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment