#!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # extended toeplitz test: test rxhash plus, optionally, either (1) rss mapping # from rxhash to rx queue ('-rss') or (2) rps mapping from rxhash to cpu # ('-rps <rps_map>') # # irq-pattern-prefix can be derived from /sys/kernel/irq/*/action, # which is a driver-specific encoding. # # invoke as ./toeplitz.sh (-i <iface>) -u|-t -4|-6 \ # [(-rss -irq_prefix <irq-pattern-prefix>)|(-rps <rps_map>)]
# Return the number of rxqs among which RSS is configured to spread packets. # This is determined by reading the RSS indirection table using ethtool.
get_rss_cfg_num_rxqs() { echo $(ethtool -x "${DEV}" |
grep -E [[:space:]]+[0-9]+:[[:space:]]+ |
cut -d: -f2- |
awk '{$1=$1};1' |
tr ' ''\n' |
sort -u |
wc -l)
}
# Return a list of the receive irq handler cpus. # The list is ordered by the irqs, so first rxq-0 cpu, then rxq-1 cpu, etc. # Reads /sys/kernel/irq/ in order, so algorithm depends on # irq_{rxq-0} < irq_{rxq-1}, etc.
get_rx_irq_cpus() {
CPUS="" # sort so that irq 2 is read before irq 10
SORTED_IRQS=$(for i in /sys/kernel/irq/*; doecho $i; done | sort -V) # Consider only as many queues as RSS actually uses. We assume that # if RSS_CFG_NUM_RXQS=N, then RSS uses rxqs 0-(N-1).
RSS_CFG_NUM_RXQS=$(get_rss_cfg_num_rxqs)
RXQ_COUNT=0
for i in ${SORTED_IRQS} do
[[ "${RXQ_COUNT}" -lt "${RSS_CFG_NUM_RXQS}" ]] || break # lookup relevant IRQs by action name
[[ -e "$i/actions" ]] || continue cat"$i/actions" | grep -q "${IRQ_PATTERN}" || continue
irqname=$(<"$i/actions")
# does the IRQ get called
irqcount=$(cat"$i/per_cpu_count" | tr -d '0,')
[[ -n "${irqcount}" ]] || continue
# lookup CPU
irq=$(basename "$i")
cpu=$(cat"/proc/irq/$irq/smp_affinity_list")
if [[ -z "${CPUS}" ]]; then
CPUS="${cpu}" else
CPUS="${CPUS},${cpu}" fi
RXQ_COUNT=$((RXQ_COUNT+1)) done
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.