QemuUtil lib change to work with ubuntu and centos
[csit.git] / resources / tools / disk-image-builder / nested / image-patches / 06-dpdk-support
index fb166ef..2de4ad6 100755 (executable)
@@ -34,6 +34,8 @@ fi
 
 # Set up hugepages
 echo "vm.nr_hugepages = ${NUM_HUGEPAGES}" > /etc/sysctl.conf
+echo "vm.swappiness = 0" >> /etc/sysctl.conf
+echo "kernel.randomize_va_space = 0" >> /etc/sysctl.conf
 sysctl -p
 mkdir -p /mnt/huge
 grep -q hugetlbfs /etc/fstab || echo "hugetlbfs /mnt/huge hugetlbfs mode=1770,gid=2021 0 0" >> /etc/fstab
@@ -44,16 +46,29 @@ echo 1af4 1000 > /sys/bus/pci/drivers/${TARGET_DRIVER}/new_id
 #
 for dev in $(find /sys/bus/pci/drivers/virtio-pci -type l -name '*:*:*.*' | sed -e 's/.*\///')
 do
-  echo Unbinding $dev from virtio-pci
-  echo $dev > /sys/bus/pci/drivers/virtio-pci/unbind
-  echo Binding $dev to ${TARGET_DRIVER}
-  echo $dev > /sys/bus/pci/drivers/${TARGET_DRIVER}/bind
+  class=$(cat /sys/bus/pci/drivers/virtio-pci/${dev}/class)
+  if [ "$class" = "0x020000" ]; then
+       echo Unbinding $dev from virtio-pci
+       echo $dev > /sys/bus/pci/drivers/virtio-pci/unbind
+       echo Binding $dev to ${TARGET_DRIVER}
+       echo $dev > /sys/bus/pci/drivers/${TARGET_DRIVER}/bind
+  fi
 done
 
+# RCU and IRQ affinity
 for i in $(ls /proc/irq/ | grep [0-9])
 do
   echo 1 > /proc/irq/$i/smp_affinity
 done
+echo 1 | sudo tee /sys/bus/workqueue/devices/writeback/cpumask
+
+# There is a bug causing packet loss when VM is initialized. This workaround is
+# supposed to re-initialize CPUs.
+for i in $(ls -d /sys/devices/system/cpu/cpu[1-9]/online); do
+    echo 0 | sudo tee $i
+    sleep 2
+    echo 1 | sudo tee $i
+done
 
 # Start testpmd in the background. This looks a bit convoluted; we need to redirect stdin
 # (and keep stdin active) or else testpmd will quit.