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
0d5bcea9
Commit
0d5bcea9
authored
Sep 15, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tracemark options to server
parent
bba18f1b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
26 deletions
+77
-26
packet-exchange/src/recv_packet.c
packet-exchange/src/recv_packet.c
+32
-22
packet-exchange/src/recv_packet.h
packet-exchange/src/recv_packet.h
+1
-0
packet-exchange/src/server.c
packet-exchange/src/server.c
+19
-1
scripts/run-server
scripts/run-server
+25
-3
No files found.
packet-exchange/src/recv_packet.c
View file @
0d5bcea9
...
...
@@ -33,6 +33,7 @@
#include <unistd.h>
#include "common.h"
#include "tracer.h"
#ifdef WITH_XDP
#include <bpf/bpf.h>
...
...
@@ -56,7 +57,9 @@ static ingress_stat_t *stats;
static
uint64_t
*
kernel_latency_hist
;
static
int
use_histogram
;
uint64_t
post_kernel_timestamp
;
static
uint64_t
post_kernel_timestamp
;
static
char
ts_tracemark_buf
[
64
];
// Sets the interface
static
int
set_if
(
void
)
{
...
...
@@ -176,27 +179,34 @@ void recv_udp_packet() {
struct
timespec
*
stamp
=
(
struct
timespec
*
)
CMSG_DATA
(
cmsg
);
uint64_t
kernel_latency
=
post_kernel_timestamp
-
ts_to_uint
(
*
stamp
);
kernel_latency
/=
1000u
;
stats
->
min_kernel_latency
=
_min_
(
kernel_latency
,
stats
->
min_kernel_latency
);
stats
->
max_kernel_latency
=
_max_
(
kernel_latency
,
stats
->
max_kernel_latency
);
stats
->
avg_kernel_latency
=
(
stats
->
max_kernel_latency
*
(
stats
->
packets_received
)
+
kernel_latency
)
/
(
stats
->
packets_received
+
1
);
if
(
use_histogram
)
{
if
(
kernel_latency
>
MAX_KERNEL_LATENCY
)
stats
->
high_kernel_latency
++
;
else
kernel_latency_hist
[
kernel_latency
]
++
;
}
if
(
params
->
enable_ts_tracemark
)
{
sprintf
(
ts_tracemark_buf
,
"%"
PRIu64
,
ts_to_uint
(
*
stamp
));
tracemark
(
ts_tracemark_buf
);
}
else
{
uint64_t
kernel_latency
=
post_kernel_timestamp
-
ts_to_uint
(
*
stamp
);
kernel_latency
/=
1000u
;
stats
->
min_kernel_latency
=
_min_
(
kernel_latency
,
stats
->
min_kernel_latency
);
stats
->
max_kernel_latency
=
_max_
(
kernel_latency
,
stats
->
max_kernel_latency
);
stats
->
avg_kernel_latency
=
(
stats
->
max_kernel_latency
*
(
stats
->
packets_received
)
+
kernel_latency
)
/
(
stats
->
packets_received
+
1
);
if
(
use_histogram
)
{
if
(
kernel_latency
>
MAX_KERNEL_LATENCY
)
stats
->
high_kernel_latency
++
;
else
kernel_latency_hist
[
kernel_latency
]
++
;
}
}
}
}
}
...
...
packet-exchange/src/recv_packet.h
View file @
0d5bcea9
...
...
@@ -7,6 +7,7 @@ typedef struct ingress_param {
char
network_if
[
16
];
int
use_timestamps
;
int
enable_ts_tracemark
;
int
xdp_polling_mode
;
uint64_t
interval
;
...
...
packet-exchange/src/server.c
View file @
0d5bcea9
...
...
@@ -42,6 +42,7 @@ typedef struct thread_param {
int
emit_signal
;
int
enable_diff_ts
;
int
enable_receive_tracemark
;
}
thread_param_t
;
...
...
@@ -80,6 +81,8 @@ static int64_t min_diff_ts = INT_MAX;
static
int64_t
max_diff_ts
=
0
;
static
int64_t
avg_diff_ts
=
0
;
static
char
ts_tracemark_buf
[
64
];
static
void
help
(
char
*
argv
[])
{
printf
(
"Usage: %s [-f IF -a CPU -p PRIO -i USEC -r USEC] [-b CLIENT_IP] [-d "
...
...
@@ -100,6 +103,8 @@ static void help(char *argv[]) {
" POLL_MODE: 0 for polling, 1 for combination of both
\n
"
" -X Trace during XDP packet reception
\n
"
" -T THRESHOLD Enable tracing until THRESHOLD is reached
\n
"
" -M Send tracemark when packet is received
\n
"
" -S Send tracemark containing RX SO_TIMESTAMP timestamp
\n
"
" -v Verbose
\n
"
"
\n
"
,
argv
[
0
]);
...
...
@@ -174,6 +179,11 @@ static void *tsn_thread(void *p) {
clock_gettime
(
CLOCK_REALTIME
,
&
current
);
recv_xdp_cleanup
();
if
(
thread_params
.
enable_receive_tracemark
)
{
sprintf
(
ts_tracemark_buf
,
"%"
PRIu64
,
ts_to_uint
(
current
));
tracemark
(
ts_tracemark_buf
);
}
if
(
thread_params
.
enable_diff_ts
)
{
uint64_t
send_ts
=
decode
(
ingress_stats
.
data
);
int64_t
diff_us
=
(((
int64_t
)
ts_to_uint
(
current
))
-
((
int64_t
)
send_ts
))
/
1000
;
...
...
@@ -293,6 +303,7 @@ int main(int argc, char *argv[]) {
thread_params
.
emit_signal
=
0
;
thread_params
.
affinity_cpu
=
0
;
thread_params
.
enable_diff_ts
=
0
;
thread_params
.
enable_receive_tracemark
=
0
;
main_params
.
refresh_rate
=
50000
;
main_params
.
verbose
=
0
;
main_params
.
enable_tracing
=
0
;
...
...
@@ -300,6 +311,7 @@ int main(int argc, char *argv[]) {
enable_histograms
=
0
;
tsn_task
=
RECV_PACKET_TASK
;
ingress_params
.
tx_buffer_len
=
1024
;
ingress_params
.
enable_ts_tracemark
=
0
;
// Process bash options
process_options
(
argc
,
argv
);
...
...
@@ -449,7 +461,7 @@ static void process_options(int argc, char *argv[]) {
int
network_if_specified
=
0
;
for
(;;)
{
int
c
=
getopt
(
argc
,
argv
,
"a:b:cCd:f:ghi:p:r:tvx:XT:G"
);
int
c
=
getopt
(
argc
,
argv
,
"a:b:cCd:f:ghi:p:r:tvx:XT:G
MS
"
);
if
(
c
==
-
1
)
break
;
...
...
@@ -511,6 +523,12 @@ static void process_options(int argc, char *argv[]) {
main_params
.
enable_tracing
=
1
;
thread_params
.
latency_threshold
=
atoi
(
optarg
);
break
;
case
'M'
:
thread_params
.
enable_receive_tracemark
=
1
;
break
;
case
'S'
:
ingress_params
.
enable_ts_tracemark
=
1
;
break
;
}
}
...
...
scripts/run-server
View file @
0d5bcea9
...
...
@@ -32,11 +32,14 @@ Usage: $0 [-h] [-I if] [SERVER] | TCPDUMP [TRACE_OPTS]
TRACE_OPTS: -T LATENCY_THRESHOLD [-P TRACER -E XDP_EVENTS]
Trace until latency threshold is met
-T USEC Enable tracing until threshold is met
-Q Enable eth0 IRQ tracing only
-P TRACER Which trace to use when tracing: function, function_graph, wakeup etc...
Default: function
-E EVENTS Specify which events to trace (e.g: "-E "-e net -e irq")
Default: irq, sched, net, napi
-B SIZE Size of the buffer for each CPU in kilobytes
-M Send tracemark when packet is received
\n
"
-S Send tracemark containing RX SO_TIMESTAMP timestamp
\n
"
ENDUSAGE
1>&2
;
...
...
@@ -53,7 +56,7 @@ tracecmd_events="-e irq -e sched -e net -e napi"
tracecmd_opts
=
""
cpu
=
1
while
getopts
"a:b:cChtx:X:d:i:g:I:T:E:P:B:"
opt
;
do
while
getopts
"a:b:cChtx:X:d:i:g:I:T:E:P:B:
MSQ
"
opt
;
do
case
"
${
opt
}
"
in
a
)
cpu
=
${
OPTARG
}
...
...
@@ -111,6 +114,18 @@ while getopts "a:b:cChtx:X:d:i:g:I:T:E:P:B:" opt; do
use_tracer
=
1
server_options+
=
" -T
${
OPTARG
}
"
;;
M
)
server_options+
=
" -M "
;;
S
)
server_options+
=
" -S "
;;
Q
)
use_tracer
=
1
server_options+
=
" -T 999999"
tracecmd_events
=
" -e irq_handler_entry "
tracecmd_filter
=
"irq == 56"
;;
*
)
usage
;;
...
...
@@ -148,8 +163,15 @@ else
cd
$script_dir
/../packet-exchange/build
;
make
$make_opts
server
;
cd
$script_dir
if
[
-n
"
${
use_tracer
}
"
]
;
then
echo
"trace-cmd record
$tracecmd_opts
$tracecmd_events
$script_dir
/../packet-exchange/build/server
$server_options
"
;
trace-cmd record
$tracecmd_opts
$tracecmd_events
$script_dir
/../packet-exchange/build/server
$server_options
;
if
[
-n
"
${
tracecmd_filter
}
"
]
;
then
echo
"trace-cmd record
$tracecmd_opts
$tracecmd_events
-f
\"
$tracecmd_filter
\"
$script_dir
/../packet-exchange/build/server
$server_options
"
;
trace-cmd record
$tracecmd_opts
$tracecmd_events
-f
"
$tracecmd_filter
"
$script_dir
/../packet-exchange/build/server
$server_options
;
else
echo
"trace-cmd record
$tracecmd_opts
$tracecmd_events
$script_dir
/../packet-exchange/build/server
$server_options
"
;
trace-cmd record
$tracecmd_opts
$tracecmd_events
$script_dir
/../packet-exchange/build/server
$server_options
;
fi
elif
[
-z
"
${
use_histogram
}
"
]
;
then
echo
"server
$server_options
"
;
$script_dir
/../packet-exchange/build/server
$server_options
;
...
...
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