]>
git.proxmox.com Git - ceph.git/blob - ceph/src/seastar/scripts/run_with_dpdk.sh
3 # ! Usage: ./prepare_dpdk_env.sh <NIC to use> <number of huge pages per NUMA Node> <command to execute> [command parameters]
5 # ! Prepares the DPDK environment (binds a given NIC to UIO, allocates the required
6 # ! number of huge pages) and executes the given command in it.
7 # ! After the command terminates the original environment is restored apart from
8 # ! huge pages, that remain allocated.
13 cat $0 |
grep ^
"# !" | cut
-d"!" -f2-
17 # check_stat_and_exit <error message>
21 if [[ $?
-ne 0 ]]; then
29 echo "Binding $NIC($BDF) back to $DRIVER..."
30 $SCRIPTS_DIR/dpdk_nic_bind.py
-u $BDF
31 $SCRIPTS_DIR/dpdk_nic_bind.py
-b $DRIVER $BDF
34 check_stat_and_rollback
()
36 if [[ $?
-ne 0 ]]; then
43 # Check number of parameters
44 if [[ $# -lt 3 ]]; then
51 NUM_HUGE_PAGES_PER_NODE
=$1
53 SCRIPTS_DIR
=`dirname $0`
57 check_stat_and_exit
"Failed to shut down $NIC. Is $NIC present? Are your permissions sufficient?"
59 DRIVER
=`ethtool -i $NIC | grep driver | cut -d":" -f2- | tr -d ' '`
60 BDF
=`ethtool -i $NIC | grep bus-info | cut -d":" -f2- | tr -d ' '`
65 echo "Binding $NIC($BDF) to uio_pci_generic..."
66 $SCRIPTS_DIR/dpdk_nic_bind.py
-u $BDF
68 $SCRIPTS_DIR/dpdk_nic_bind.py
-b uio_pci_generic
$BDF
69 check_stat_and_rollback
71 echo "Allocating $NUM_HUGE_PAGES_PER_NODE 2MB huge pages on each NUMA Node:"
72 for d
in /sys
/devices
/system
/node
/node?
; do
73 echo $NUM_HUGE_PAGES_PER_NODE > $d/hugepages
/hugepages-2048kB
/nr_hugepages
74 check_stat_and_rollback
75 cur_node
=`basename $d`
76 echo "...$cur_node done..."
80 check_stat_and_rollback
82 grep -s '/mnt/huge' /proc
/mounts
> /dev
/null
83 if [[ $?
-ne 0 ]] ; then
84 echo "Mounting hugetlbfs at /mnt/huge..."
85 mount
-t hugetlbfs nodev
/mnt
/huge
86 check_stat_and_rollback
94 # Revert the NIC binding