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
82f2b9a1
Commit
82f2b9a1
authored
Jan 02, 2019
by
Alexey Ivanov
Committed by
yonghong-song
Jan 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ustat: added basic race condition protection (#2103)
added basic race condition protection for ustat.py
parent
dccc4f28
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
tools/lib/ustat.py
tools/lib/ustat.py
+11
-2
No files found.
tools/lib/ustat.py
View file @
82f2b9a1
...
@@ -20,8 +20,9 @@
...
@@ -20,8 +20,9 @@
from
__future__
import
print_function
from
__future__
import
print_function
import
argparse
import
argparse
from
bcc
import
BPF
,
USDT
from
bcc
import
BPF
,
USDT
,
USDTException
import
os
import
os
import
sys
from
subprocess
import
call
from
subprocess
import
call
from
time
import
sleep
,
strftime
from
time
import
sleep
,
strftime
...
@@ -62,7 +63,12 @@ class Probe(object):
...
@@ -62,7 +63,12 @@ class Probe(object):
def
_enable_probes
(
self
):
def
_enable_probes
(
self
):
self
.
usdts
=
[]
self
.
usdts
=
[]
for
pid
in
self
.
targets
:
for
pid
in
self
.
targets
:
usdt
=
USDT
(
pid
=
pid
)
try
:
usdt
=
USDT
(
pid
=
pid
)
except
USDTException
:
# avoid race condition on pid going away.
print
(
"failed to instrument %d"
%
pid
,
file
=
sys
.
stderr
)
continue
for
event
in
self
.
events
:
for
event
in
self
.
events
:
try
:
try
:
usdt
.
enable_probe
(
event
,
"%s_%s"
%
(
self
.
language
,
event
))
usdt
.
enable_probe
(
event
,
"%s_%s"
%
(
self
.
language
,
event
))
...
@@ -111,6 +117,9 @@ int %s_%s(void *ctx) {
...
@@ -111,6 +117,9 @@ int %s_%s(void *ctx) {
for
event
,
category
in
self
.
events
.
items
():
for
event
,
category
in
self
.
events
.
items
():
counts
=
bpf
[
"%s_%s_counts"
%
(
self
.
language
,
event
)]
counts
=
bpf
[
"%s_%s_counts"
%
(
self
.
language
,
event
)]
for
pid
,
count
in
counts
.
items
():
for
pid
,
count
in
counts
.
items
():
if
pid
.
value
not
in
result
:
print
(
"result was not found for %d"
%
pid
.
value
,
file
=
sys
.
stderr
)
continue
result
[
pid
.
value
][
category
]
=
count
.
value
result
[
pid
.
value
][
category
]
=
count
.
value
counts
.
clear
()
counts
.
clear
()
return
result
return
result
...
...
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