From: Jesper Dangaard Brouer <brouer@redhat.com>
To: netdev@vger.kernel.org
Cc: Robert Olsson <robert@herjulf.se>,
Jesper Dangaard Brouer <brouer@redhat.com>,
robert.hu@intel.com, pabeni@redhat.com, kafai@fb.com,
tariqt@mellanox.com
Subject: [net-next PATCH 1/4] samples/pktgen: Add some helper functions
Date: Wed, 01 Nov 2017 11:41:09 +0100 [thread overview]
Message-ID: <150953286920.29671.11277440445060911896.stgit@firesoul> (raw)
In-Reply-To: <150953283424.29671.6809291616813585256.stgit@firesoul>
From: Robert Hoo <robert.hu@intel.com>
1. given a device, get its NUMA belongings
2. given a device, get its queues' irq numbers.
3. given a NUMA node, get its cpu id list.
Signed-off-by: Robert Hoo <robert.hu@intel.com>
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
samples/pktgen/functions.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/samples/pktgen/functions.sh b/samples/pktgen/functions.sh
index 205e4cde4601..f8bb3cd0f4ce 100644
--- a/samples/pktgen/functions.sh
+++ b/samples/pktgen/functions.sh
@@ -119,3 +119,46 @@ function root_check_run_with_sudo() {
err 4 "cannot perform sudo run of $0"
fi
}
+
+# Exact input device's NUMA node info
+function get_iface_node()
+{
+ local node=$(</sys/class/net/$1/device/numa_node)
+ if [[ $node == -1 ]]; then
+ echo 0
+ else
+ echo $node
+ fi
+}
+
+# Given an Dev/iface, get its queues' irq numbers
+function get_iface_irqs()
+{
+ local IFACE=$1
+ local queues="${IFACE}-.*TxRx"
+
+ irqs=$(grep "$queues" /proc/interrupts | cut -f1 -d:)
+ [ -z "$irqs" ] && irqs=$(grep $IFACE /proc/interrupts | cut -f1 -d:)
+ [ -z "$irqs" ] && irqs=$(for i in `ls -Ux /sys/class/net/$IFACE/device/msi_irqs` ;\
+ do grep "$i:.*TxRx" /proc/interrupts | grep -v fdir | cut -f 1 -d : ;\
+ done)
+ [ -z "$irqs" ] && err 3 "Could not find interrupts for $IFACE"
+
+ echo $irqs
+}
+
+# Given a NUMA node, return cpu ids belonging to it.
+function get_node_cpus()
+{
+ local node=$1
+ local node_cpu_list
+ local node_cpu_range_list=`cut -f1- -d, --output-delimiter=" " \
+ /sys/devices/system/node/node$node/cpulist`
+
+ for cpu_range in $node_cpu_range_list
+ do
+ node_cpu_list="$node_cpu_list "`seq -s " " ${cpu_range//-/ }`
+ done
+
+ echo $node_cpu_list
+}
next prev parent reply other threads:[~2017-11-01 10:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-01 10:41 [net-next PATCH 0/4] Updates for samples/pktgen Jesper Dangaard Brouer
2017-11-01 10:41 ` Jesper Dangaard Brouer [this message]
2017-11-01 10:41 ` [net-next PATCH 2/4] samples/pktgen: add script pktgen_sample06_numa_awared_queue_irq_affinity.sh Jesper Dangaard Brouer
2017-11-01 10:41 ` [net-next PATCH 3/4] samples/pktgen: update sample03, no need for clones when bursting Jesper Dangaard Brouer
2017-11-01 10:41 ` [net-next PATCH 4/4] samples/pktgen: remove remaining old pktgen sample scripts Jesper Dangaard Brouer
2017-11-01 16:28 ` [net-next PATCH 0/4] Updates for samples/pktgen Alexei Starovoitov
2017-11-02 5:20 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=150953286920.29671.11277440445060911896.stgit@firesoul \
--to=brouer@redhat.com \
--cc=kafai@fb.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robert.hu@intel.com \
--cc=robert@herjulf.se \
--cc=tariqt@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox