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
cab4d7c6
Commit
cab4d7c6
authored
Feb 27, 2018
by
4ast
Committed by
GitHub
Feb 27, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1595 from iovisor/yhs_dev
fix hang with "trace.py --max-events #"
parents
6044643c
a7554fc4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
src/cc/perf_reader.c
src/cc/perf_reader.c
+12
-1
No files found.
src/cc/perf_reader.c
View file @
cab4d7c6
...
...
@@ -20,8 +20,10 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <syscall.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/perf_event.h>
...
...
@@ -43,6 +45,7 @@ struct perf_reader {
size_t
buf_size
;
void
*
base
;
int
rb_use_state
;
pid_t
rb_read_tid
;
int
page_size
;
int
page_cnt
;
int
fd
;
...
...
@@ -70,7 +73,12 @@ struct perf_reader * perf_reader_new(perf_reader_cb cb,
void
perf_reader_free
(
void
*
ptr
)
{
if
(
ptr
)
{
struct
perf_reader
*
reader
=
ptr
;
while
(
!
__sync_bool_compare_and_swap
(
&
reader
->
rb_use_state
,
RB_NOT_USED
,
RB_USED_IN_MUNMAP
));
pid_t
tid
=
syscall
(
__NR_gettid
);
while
(
!
__sync_bool_compare_and_swap
(
&
reader
->
rb_use_state
,
RB_NOT_USED
,
RB_USED_IN_MUNMAP
))
{
// If the same thread, it is called from call back handler, no locking needed
if
(
tid
==
reader
->
rb_read_tid
)
break
;
}
munmap
(
reader
->
base
,
reader
->
page_size
*
(
reader
->
page_cnt
+
1
));
if
(
reader
->
fd
>=
0
)
{
ioctl
(
reader
->
fd
,
PERF_EVENT_IOC_DISABLE
,
0
);
...
...
@@ -228,6 +236,7 @@ void perf_reader_event_read(struct perf_reader *reader) {
uint8_t
*
sentinel
=
(
uint8_t
*
)
reader
->
base
+
buffer_size
+
reader
->
page_size
;
uint8_t
*
begin
,
*
end
;
reader
->
rb_read_tid
=
syscall
(
__NR_gettid
);
if
(
!
__sync_bool_compare_and_swap
(
&
reader
->
rb_use_state
,
RB_NOT_USED
,
RB_USED_IN_READ
))
return
;
...
...
@@ -280,6 +289,8 @@ void perf_reader_event_read(struct perf_reader *reader) {
write_data_tail
(
perf_header
,
perf_header
->
data_tail
+
e
->
size
);
}
reader
->
rb_use_state
=
RB_NOT_USED
;
__sync_synchronize
();
reader
->
rb_read_tid
=
0
;
}
int
perf_reader_poll
(
int
num_readers
,
struct
perf_reader
**
readers
,
int
timeout
)
{
...
...
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