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
b8fccc5f
Commit
b8fccc5f
authored
May 17, 2018
by
yonghong-song
Committed by
GitHub
May 17, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1765 from palmtenor/extraflag
Add extra_flag option to bpf_attach_perf_event_raw
parents
683c19a8
bf2513df
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
7 deletions
+10
-7
src/cc/api/BPF.cc
src/cc/api/BPF.cc
+4
-2
src/cc/api/BPF.h
src/cc/api/BPF.h
+2
-1
src/cc/libbpf.c
src/cc/libbpf.c
+3
-3
src/cc/libbpf.h
src/cc/libbpf.h
+1
-1
No files found.
src/cc/api/BPF.cc
View file @
b8fccc5f
...
...
@@ -324,7 +324,8 @@ StatusTuple BPF::attach_perf_event(uint32_t ev_type, uint32_t ev_config,
StatusTuple
BPF
::
attach_perf_event_raw
(
void
*
perf_event_attr
,
const
std
::
string
&
probe_func
,
pid_t
pid
,
int
cpu
,
int
group_fd
)
{
int
cpu
,
int
group_fd
,
unsigned
long
extra_flags
)
{
auto
attr
=
static_cast
<
struct
perf_event_attr
*>
(
perf_event_attr
);
auto
ev_pair
=
std
::
make_pair
(
attr
->
type
,
attr
->
config
);
if
(
perf_events_
.
find
(
ev_pair
)
!=
perf_events_
.
end
())
...
...
@@ -342,7 +343,8 @@ StatusTuple BPF::attach_perf_event_raw(void* perf_event_attr,
auto
fds
=
new
std
::
vector
<
std
::
pair
<
int
,
int
>>
();
fds
->
reserve
(
cpus
.
size
());
for
(
int
i
:
cpus
)
{
int
fd
=
bpf_attach_perf_event_raw
(
probe_fd
,
attr
,
pid
,
i
,
group_fd
);
int
fd
=
bpf_attach_perf_event_raw
(
probe_fd
,
attr
,
pid
,
i
,
group_fd
,
extra_flags
);
if
(
fd
<
0
)
{
for
(
const
auto
&
it
:
*
fds
)
close
(
it
.
second
);
...
...
src/cc/api/BPF.h
View file @
b8fccc5f
...
...
@@ -88,7 +88,8 @@ class BPF {
StatusTuple
attach_perf_event_raw
(
void
*
perf_event_attr
,
const
std
::
string
&
probe_func
,
pid_t
pid
=
-
1
,
int
cpu
=
-
1
,
int
group_fd
=
-
1
);
int
group_fd
=
-
1
,
unsigned
long
extra_flags
=
0
);
StatusTuple
detach_perf_event
(
uint32_t
ev_type
,
uint32_t
ev_config
);
StatusTuple
detach_perf_event_raw
(
void
*
perf_event_attr
);
std
::
string
get_syscall_fnname
(
const
std
::
string
&
name
);
...
...
src/cc/libbpf.c
View file @
b8fccc5f
...
...
@@ -1305,9 +1305,9 @@ cleanup:
}
int
bpf_attach_perf_event_raw
(
int
progfd
,
void
*
perf_event_attr
,
pid_t
pid
,
int
cpu
,
int
group_fd
)
{
int
cpu
,
int
group_fd
,
unsigned
long
extra_flags
)
{
int
fd
=
syscall
(
__NR_perf_event_open
,
perf_event_attr
,
pid
,
cpu
,
group_fd
,
PERF_FLAG_FD_CLOEXEC
);
PERF_FLAG_FD_CLOEXEC
|
extra_flags
);
if
(
fd
<
0
)
{
perror
(
"perf_event_open failed"
);
return
-
1
;
...
...
@@ -1351,7 +1351,7 @@ int bpf_attach_perf_event(int progfd, uint32_t ev_type, uint32_t ev_config,
attr
.
sample_period
=
sample_period
;
}
return
bpf_attach_perf_event_raw
(
progfd
,
&
attr
,
pid
,
cpu
,
group_fd
);
return
bpf_attach_perf_event_raw
(
progfd
,
&
attr
,
pid
,
cpu
,
group_fd
,
0
);
}
int
bpf_close_perf_event_fd
(
int
fd
)
{
...
...
src/cc/libbpf.h
View file @
b8fccc5f
...
...
@@ -93,7 +93,7 @@ int bpf_attach_xdp(const char *dev_name, int progfd, uint32_t flags);
// attach a prog expressed by progfd to run on a specific perf event. The perf
// event will be created using the perf_event_attr pointer provided.
int
bpf_attach_perf_event_raw
(
int
progfd
,
void
*
perf_event_attr
,
pid_t
pid
,
int
cpu
,
int
group_fd
);
int
cpu
,
int
group_fd
,
unsigned
long
extra_flags
);
// attach a prog expressed by progfd to run on a specific perf event, with
// certain sample period or sample frequency
int
bpf_attach_perf_event
(
int
progfd
,
uint32_t
ev_type
,
uint32_t
ev_config
,
...
...
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