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
44a513e1
Commit
44a513e1
authored
May 01, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more comments, make graph tracer and affinity optionnal
parent
5c96fd63
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
13 deletions
+35
-13
clock-res/src/clockres.c
clock-res/src/clockres.c
+29
-10
clock-res/src/tracer.c
clock-res/src/tracer.c
+5
-2
clock-res/src/tracer.h
clock-res/src/tracer.h
+1
-1
No files found.
clock-res/src/clockres.c
View file @
44a513e1
...
...
@@ -25,6 +25,7 @@ typedef struct thread_param {
int
priority
;
int
max_cycles
;
int
enable_tracing
;
int
enable_affinity
;
uint64_t
interval
;
uint64_t
latency_threshold
;
thread_stat_t
stat
;
...
...
@@ -33,6 +34,7 @@ typedef struct thread_param {
typedef
struct
main_param
{
int
refresh_rate
;
int
enable_tracing
;
int
enable_graph
;
}
main_param_t
;
static
void
process_options
(
int
argc
,
char
*
argv
[],
thread_param_t
*
param
,
...
...
@@ -53,11 +55,13 @@ static void *timerthread(void *p) {
thread_param_t
*
param
=
(
thread_param_t
*
)
p
;
thread_stat_t
*
stat
=
&
param
->
stat
;
// Set thread CPU affinity
CPU_ZERO
(
&
mask
);
CPU_SET
(
1
,
&
mask
);
if
(
sched_setaffinity
(
0
,
sizeof
(
mask
),
&
mask
))
printf
(
"Could not set CPU affinity to CPU #1
\n
"
);
if
(
param
->
enable_affinity
)
{
// Set thread CPU affinity
CPU_ZERO
(
&
mask
);
CPU_SET
(
1
,
&
mask
);
if
(
sched_setaffinity
(
0
,
sizeof
(
mask
),
&
mask
))
printf
(
"Could not set CPU affinity to CPU #1
\n
"
);
}
// Set thread priority
priority
.
sched_priority
=
param
->
priority
;
...
...
@@ -67,16 +71,20 @@ static void *timerthread(void *p) {
stat
->
max_res
=
0
;
stat
->
min_res
=
UINT64_MAX
;
// Start tracing
if
(
param
->
enable_tracing
)
tracing
(
1
);
// Measurement loop
for
(
stat
->
nb_cycles
=
0
;;
stat
->
nb_cycles
++
)
{
if
(
param
->
max_cycles
&&
(
stat
->
nb_cycles
>=
param
->
max_cycles
))
break
;
// Two successive clock measurement to determine clock_gettime latency
clock_gettime
(
CLOCK_ID
,
&
previous
);
clock_gettime
(
CLOCK_ID
,
&
current
);
diff
=
calcdiff_ns
(
current
,
previous
);
// If the latency hits the tracing threshold, stop tracing
if
(
param
->
enable_tracing
&&
(
diff
>
param
->
latency_threshold
))
{
sprintf
(
time_measured_string
,
"Diff measured: %"
PRIu64
"
\n
"
,
diff
);
tracemark
(
time_measured_string
);
...
...
@@ -88,6 +96,8 @@ static void *timerthread(void *p) {
break
;
}
// Update the thread statistics, so that the non real-time
// thread can print it
stat
->
max_res
=
max
(
stat
->
max_res
,
diff
);
stat
->
min_res
=
min
(
stat
->
min_res
,
diff
);
...
...
@@ -111,14 +121,19 @@ int main(int argc, char *argv[]) {
param
.
max_cycles
=
100000
;
param
.
priority
=
99
;
param
.
enable_tracing
=
0
;
param
.
enable_affinity
=
0
;
main_param
.
enable_tracing
=
0
;
main_param
.
enable_graph
=
0
;
main_param
.
refresh_rate
=
10000
;
// Process bash options
process_options
(
argc
,
argv
,
&
param
,
&
main_param
);
// Enable ftrace
if
(
main_param
.
enable_tracing
)
{
param
.
enable_tracing
=
1
;
setup_tracer
();
setup_tracer
(
main_param
.
enable_graph
);
}
usleep
(
10000
);
...
...
@@ -149,7 +164,7 @@ int main(int argc, char *argv[]) {
static
void
process_options
(
int
argc
,
char
*
argv
[],
thread_param_t
*
param
,
main_param_t
*
main_param
)
{
for
(;;)
{
int
c
=
getopt
(
argc
,
argv
,
"l:p:i:r:
b:f
"
);
int
c
=
getopt
(
argc
,
argv
,
"l:p:i:r:
f:ag
"
);
if
(
c
==
-
1
)
break
;
...
...
@@ -163,14 +178,18 @@ static void process_options(int argc, char *argv[], thread_param_t *param,
case
'i'
:
param
->
interval
=
atoi
(
optarg
);
break
;
case
'b'
:
param
->
latency_threshold
=
atoi
(
optarg
);
break
;
case
'r'
:
main_param
->
refresh_rate
=
atoi
(
optarg
);
break
;
case
'f'
:
main_param
->
enable_tracing
=
1
;
param
->
latency_threshold
=
atoi
(
optarg
);
break
;
case
'a'
:
param
->
enable_affinity
=
1
;
break
;
case
'g'
:
main_param
->
enable_graph
=
1
;
break
;
default:
exit
(
EXIT_FAILURE
);
...
...
clock-res/src/tracer.c
View file @
44a513e1
...
...
@@ -74,7 +74,7 @@ static void setkernvar(const char *name, char *value) {
fprintf
(
stderr
,
"could not set %s to %s
\n
"
,
name
,
value
);
}
void
setup_tracer
(
void
)
{
void
setup_tracer
(
int
enable_graph
)
{
char
trace_path
[
MAX_PATH
];
char
tracemark_path
[
MAX_PATH
];
...
...
@@ -85,7 +85,10 @@ void setup_tracer(void) {
fileprefix
=
debugfileprefix
;
// Clear old traces by setting tracer to nop first
setkernvar
(
"current_tracer"
,
"nop"
);
setkernvar
(
"current_tracer"
,
"function"
);
if
(
enable_graph
)
setkernvar
(
"current_tracer"
,
"function_graph"
);
else
setkernvar
(
"current_tracer"
,
"function"
);
// Open tracing_on file
strcpy
(
trace_path
,
fileprefix
);
...
...
clock-res/src/tracer.h
View file @
44a513e1
#ifndef TRACER_H
#define TRACER_H
void
setup_tracer
(
void
);
void
setup_tracer
(
int
enable_graph
);
void
tracing
(
int
on
);
void
tracemark
(
char
*
s
);
...
...
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