Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tsn-measures
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
tsn-measures
Commits
99e580f0
Commit
99e580f0
authored
Apr 30, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add trace marking
parent
02829888
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
11 deletions
+33
-11
clock-res/src/clockres.c
clock-res/src/clockres.c
+12
-3
clock-res/src/tracer.c
clock-res/src/tracer.c
+20
-8
clock-res/src/tracer.h
clock-res/src/tracer.h
+1
-0
No files found.
clock-res/src/clockres.c
View file @
99e580f0
...
...
@@ -59,17 +59,20 @@ static void *timerthread(void *p) {
stat
->
max_res
=
0
;
stat
->
min_res
=
UINT64_MAX
;
if
(
param
->
enable_tracing
)
tracing
(
1
);
for
(
stat
->
nb_cycles
=
0
;;
stat
->
nb_cycles
++
)
{
if
(
param
->
max_cycles
&&
(
stat
->
nb_cycles
>=
param
->
max_cycles
))
break
;
if
(
param
->
enable_tracing
)
trac
ing
(
1
);
trac
emark
(
"Time measure start
\n
"
);
clock_gettime
(
CLOCK_ID
,
&
previous
);
clock_gettime
(
CLOCK_ID
,
&
current
);
if
(
param
->
enable_tracing
)
trac
ing
(
0
);
trac
emark
(
"Time measure end
\n
"
);
diff
=
calcdiff_ns
(
current
,
previous
);
...
...
@@ -81,6 +84,10 @@ static void *timerthread(void *p) {
usleep
(
param
->
interval
);
}
if
(
param
->
enable_tracing
)
tracing
(
0
);
return
NULL
;
}
...
...
@@ -123,6 +130,8 @@ int main(int argc, char *argv[]) {
if
(
main_param
.
enable_tracing
&&
(
param
.
stat
.
max_res
>=
param
.
latency_threshold
))
break
;
}
// Just in case main exists before the thread
if
(
main_param
.
enable_tracing
)
tracing
(
0
);
exit
(
EXIT_SUCCESS
);
...
...
clock-res/src/tracer.c
View file @
99e580f0
...
...
@@ -39,7 +39,9 @@
static
char
*
fileprefix
;
static
char
*
procfileprefix
=
"/proc/sys/kernel/"
;
static
char
*
debugfileprefix
=
"/sys/kernel/debug/tracing/"
;
static
int
trace_fd
=
-
1
;
static
int
tracemark_fd
=
-
1
;
static
int
kernvar
(
int
mode
,
const
char
*
name
,
char
*
value
,
size_t
sizeofvalue
)
{
...
...
@@ -74,6 +76,9 @@ static void setkernvar(const char *name, char *value) {
void
setup_tracer
(
void
)
{
char
trace_path
[
MAX_PATH
];
char
tracemark_path
[
MAX_PATH
];
fileprefix
=
procfileprefix
;
setkernvar
(
"ftrace_enabled"
,
"1"
);
...
...
@@ -82,14 +87,17 @@ void setup_tracer(void) {
setkernvar
(
"current_tracer"
,
"nop"
);
setkernvar
(
"current_tracer"
,
"function"
);
/* open the tracing on file descriptor */
if
(
trace_fd
==
-
1
)
{
char
path
[
MAX_PATH
];
strcpy
(
path
,
fileprefix
);
strcat
(
path
,
"tracing_on"
);
if
((
trace_fd
=
open
(
path
,
O_WRONLY
))
==
-
1
)
printf
(
"unable to open %s for tracing"
,
path
);
}
// Open tracing_on file
strcpy
(
trace_path
,
fileprefix
);
strcat
(
trace_path
,
"tracing_on"
);
if
((
trace_fd
=
open
(
trace_path
,
O_WRONLY
))
==
-
1
)
printf
(
"unable to open %s for tracing"
,
trace_path
);
// Open trace mark file
strcpy
(
tracemark_path
,
fileprefix
);
strcat
(
tracemark_path
,
"trace_marker"
);
if
((
tracemark_fd
=
open
(
tracemark_path
,
O_WRONLY
))
==
-
1
)
printf
(
"unable to open %s for tracing"
,
tracemark_path
);
tracing
(
0
);
}
...
...
@@ -100,3 +108,7 @@ void tracing(int on) {
else
write
(
trace_fd
,
"0"
,
1
);
}
void
tracemark
(
char
*
s
)
{
write
(
tracemark_fd
,
s
,
strlen
(
s
));
}
clock-res/src/tracer.h
View file @
99e580f0
...
...
@@ -3,5 +3,6 @@
void
setup_tracer
(
void
);
void
tracing
(
int
on
);
void
tracemark
(
char
*
s
);
#endif
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