Skip to content

Commit 75cade1

Browse files
committed
ipfixprobed - introduce DPDK_INPUT_WORKER_CPUS and OUTPUT_WORKER_CPU parameters to set workers affinity
1 parent d5c8d04 commit 75cade1

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

init/ipfixprobed

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@ if [ -e "$CONFFILE" ]; then
1313
exit 1
1414
fi
1515

16+
# create array with input workers affinities
17+
if [ ! -z "$DPDK_INPUT_WORKER_CPUS" ]; then
18+
if `declare -p DPDK_INPUT_WORKER_CPUS > /dev/null 2>/dev/null`; then
19+
if [ "${#DPDK_INPUT_WORKER_CPUS[@]}" -ne "$DPDK_QUEUES_COUNT" ]; then
20+
echo "DPDK_INPUT_WORKER_CPUS length must be the same as queues count."
21+
exit 1
22+
fi
23+
fi
24+
fi
25+
for ((i = 0; i < DPDK_QUEUES_COUNT; i++)); do
26+
if [ ! -z "$DPDK_INPUT_WORKER_CPUS" ]; then
27+
affinities[i]="@${DPDK_INPUT_WORKER_CPUS[$i]}"
28+
else
29+
affinities[i]=""
30+
fi
31+
done
32+
1633
# set up DPDK interface(s)
1734
if [ "$DPDK_RING" = "1" ]; then
1835
# checks
@@ -24,19 +41,22 @@ if [ -e "$CONFFILE" ]; then
2441
echo "Missing DPDK_RING_STARTIDX in configuration of DPDK_RING mode, using 0."
2542
DPDK_RING_STARTIDX=0
2643
fi
44+
2745
# mring interfaces
28-
dpdkinput=("-i" "dpdk-ring;r=$(printf "$DPDK_RING_PATTERN" "$DPDK_RING_STARTIDX");e=--lcores $DPDK_LCORES $DPDK_EXTRA_EAL")
46+
dpdkinput=("-i" "dpdk-ring${affinities[0]};r=$(printf "$DPDK_RING_PATTERN" "$DPDK_RING_STARTIDX");e=--lcores $DPDK_LCORES $DPDK_EXTRA_EAL")
47+
plugin_idx=1
2948
for ((ifc=($DPDK_RING_STARTIDX+1); ifc<($DPDK_RING_STARTIDX + $DPDK_QUEUES_COUNT);ifc++)); do
30-
dpdkinput+=("-i" "dpdk-ring;r=$(printf "$DPDK_RING_PATTERN" "$ifc")")
49+
dpdkinput+=("-i" "dpdk-ring${affinities[$plugin_idx]};r=$(printf "$DPDK_RING_PATTERN" "$ifc")")
50+
((plugin_idx++))
3151
done
3252
else
3353
# DPDK port interface
3454
if [ -n "$DPDK_PORTOPTS" -a "${DPDK_PORTOPTS:0:1}" != ";" ]; then
3555
DPDK_PORTOPTS=";$DPDK_PORTOPTS"
3656
fi
37-
dpdkinput=("-i" "dpdk;p=${DPDK_PORT}${DPDK_PORTOPTS};q=$DPDK_QUEUES_COUNT;e=--lcores $DPDK_LCORES $DPDK_EXTRA_EAL -a $DPDK_DEVICE")
57+
dpdkinput=("-i" "dpdk${affinities[0]};p=${DPDK_PORT}${DPDK_PORTOPTS};q=$DPDK_QUEUES_COUNT;e=--lcores $DPDK_LCORES $DPDK_EXTRA_EAL -a $DPDK_DEVICE")
3858
for ((ifc=1; ifc<$DPDK_QUEUES_COUNT;ifc++)); do
39-
dpdkinput+=("-i" "dpdk")
59+
dpdkinput+=("-i" "dpdk${affinities[$ifc]}")
4060
done
4161
fi
4262
fi
@@ -88,7 +108,12 @@ if [ -e "$CONFFILE" ]; then
88108
NON_BLOCKING_TCP_PARAM="non-blocking-tcp";
89109
fi
90110

91-
output="-o ipfix;host=${HOST:-127.0.0.1};port=${PORT:-4739};id=${LINK:-0};dir=${DIR:-0};${UDP_PARAM};${NON_BLOCKING_TCP_PARAM};template=${TEMPLATE_REFRESH_RATE:-300}"
111+
output_affinity=""
112+
if [ ! -z "$OUTPUT_WORKER_CPU" ]; then
113+
output_affinity="@$OUTPUT_WORKER_CPU"
114+
fi
115+
116+
output="-o ipfix$output_affinity;host=${HOST:-127.0.0.1};port=${PORT:-4739};id=${LINK:-0};dir=${DIR:-0};${UDP_PARAM};${NON_BLOCKING_TCP_PARAM};template=${TEMPLATE_REFRESH_RATE:-300}"
92117

93118
telemetry=""
94119
if [ "$USE_FUSE" = "1" ]; then

init/link0.conf.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@
6464
# Set mapping of DPDK lcores to threads:
6565
#DPDK_LCORES="(0-7)@(0,2,4,6,8,10,12,14)"
6666

67+
# Set input workers CPU affinity, each worker is mapped on single core
68+
# array must have the same size as DPDK_QUEUES_COUNT
69+
# when DPDK_INPUT_WORKER_CPUS is specified, DPDK_LCORES does not affect input workers
70+
#DPDK_INPUT_WORKER_CPUS=(0 2 4 6 8 10 12 14)
71+
6772
# Extra options for DPDK EAL, passed to e= option of `dpdk` or `dpdk-ring` plugin.
6873
# * Use --file-prefix to separate DPDK application into new namespace.
6974
# * Use --proc-type=secondary for Option B) to receive packets via mrings created
@@ -189,6 +194,9 @@ NON_BLOCKING_TCP=no
189194
# Export ipfix template every N seconds (UDP)
190195
TEMPLATE_REFRESH_RATE=300
191196

197+
# Define output worker (thread) affinity, e.g. CPU core isolated from the scheduler
198+
#OUTPUT_WORKER_CPU=12
199+
192200
####### Fuse telemetry
193201

194202
USE_FUSE=0

0 commit comments

Comments
 (0)