Fortinet black logo

KVM Administration Guide

NIC queues (ring buffer size)

Copy Link
Copy Doc ID 00804af1-a935-11ec-9fd1-fa163e15d75b:886166
Download PDF

NIC queues (ring buffer size)

Maximize the receive queue/buffer on the NIC to optimize throughput. This is not expressly needed, but maximizing the transmit queue is also performed:

[root@rhel-tiger-14-6 ~]# ethtool -g ens4f0
Ring parameters for ens4f0:
Pre-set maximums:
RX:             4096
RX Mini:        n/a
RX Jumbo:       n/a
TX:             4096
Current hardware settings:
RX:             4096
RX Mini:        n/a
RX Jumbo:       n/a
TX:             4096

You must set this setting for each system restart, so persisting the changes by creating a system service is advised:

[root@rhel-tiger-14-6 ~]# touch /usr/local/bin/tiger-nic-rb-handler

[root@rhel-tiger-14-6 ~]# chown root:root /usr/local/bin/tiger-nic-rb-handler

[root@rhel-tiger-14-6 ~]# chmod 755 /usr/local/bin/tiger-nic-rb-handler

[root@rhel-tiger-14-6 ~]# cat /usr/local/bin/tiger-nic-rb-handler
#!/bin/bash

lookup() {
  if [[ -z $1 ]] ; then
    echo ""
  else
    awk -v "id=$1" 'BEGIN { FS = "=" } $1 == id { print $2 ; exit }' $2
  fi
}

start() {
  for _ethdev in ${ethlist//;/ } ; do
    ethdev=${_ethdev#*:}
    if [[ $(ethtool -g $ethdev 2>/dev/null wc -l) -gt 6 ]] ; then
      ethtool -G $ethdev $(ethtool -g $ethdev head -6 egrep [RT]X: xargs tr [:upper:] [:lower:] sed 's/://g')
    fi
  done
}

ethlist=$(lookup unmanaged-devices /etc/NetworkManager/conf.d/10-tiger.conf)

case $1 in
  start) "$1" ;;
esac

[root@rhel-tiger-14-6 ~]# touch /etc/systemd/system/tiger-nic-rb-handler.service

[root@rhel-tiger-14-6 ~]# chown root:root /etc/systemd/system/tiger-nic-rb-handler.service

[root@rhel-tiger-14-6 ~]# chmod 644 /etc/systemd/system/tiger-nic-rb-handler.service

[root@rhel-tiger-14-6 ~]# cat /etc/systemd/system/tiger-nic-rb-handler.service 
[Unit]
Description=Set NIC ring buffer

[Service]
Type=oneshot
ExecStart=/usr/local/bin/tiger-nic-rb-handler start
ExecStop=/usr/local/bin/tiger-nic-rb-handler stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

[root@rhel-tiger-14-6 ~]# systemctl enable --now tiger-nic-rb-handler
Created symlink /etc/systemd/system/multi-user.target.wants/tiger-nic-rb-handler.service → /etc/systemd/system/tiger-nic-rb-handler.service.

The script simply sources the list of unmanaged interfaces from the NetworkManager configuration created earlier and uses ethtool to find and set the ring buffers to their maximum values. The filename in the script must match the filename created earlier.

NIC queues (ring buffer size)

Maximize the receive queue/buffer on the NIC to optimize throughput. This is not expressly needed, but maximizing the transmit queue is also performed:

[root@rhel-tiger-14-6 ~]# ethtool -g ens4f0
Ring parameters for ens4f0:
Pre-set maximums:
RX:             4096
RX Mini:        n/a
RX Jumbo:       n/a
TX:             4096
Current hardware settings:
RX:             4096
RX Mini:        n/a
RX Jumbo:       n/a
TX:             4096

You must set this setting for each system restart, so persisting the changes by creating a system service is advised:

[root@rhel-tiger-14-6 ~]# touch /usr/local/bin/tiger-nic-rb-handler

[root@rhel-tiger-14-6 ~]# chown root:root /usr/local/bin/tiger-nic-rb-handler

[root@rhel-tiger-14-6 ~]# chmod 755 /usr/local/bin/tiger-nic-rb-handler

[root@rhel-tiger-14-6 ~]# cat /usr/local/bin/tiger-nic-rb-handler
#!/bin/bash

lookup() {
  if [[ -z $1 ]] ; then
    echo ""
  else
    awk -v "id=$1" 'BEGIN { FS = "=" } $1 == id { print $2 ; exit }' $2
  fi
}

start() {
  for _ethdev in ${ethlist//;/ } ; do
    ethdev=${_ethdev#*:}
    if [[ $(ethtool -g $ethdev 2>/dev/null wc -l) -gt 6 ]] ; then
      ethtool -G $ethdev $(ethtool -g $ethdev head -6 egrep [RT]X: xargs tr [:upper:] [:lower:] sed 's/://g')
    fi
  done
}

ethlist=$(lookup unmanaged-devices /etc/NetworkManager/conf.d/10-tiger.conf)

case $1 in
  start) "$1" ;;
esac

[root@rhel-tiger-14-6 ~]# touch /etc/systemd/system/tiger-nic-rb-handler.service

[root@rhel-tiger-14-6 ~]# chown root:root /etc/systemd/system/tiger-nic-rb-handler.service

[root@rhel-tiger-14-6 ~]# chmod 644 /etc/systemd/system/tiger-nic-rb-handler.service

[root@rhel-tiger-14-6 ~]# cat /etc/systemd/system/tiger-nic-rb-handler.service 
[Unit]
Description=Set NIC ring buffer

[Service]
Type=oneshot
ExecStart=/usr/local/bin/tiger-nic-rb-handler start
ExecStop=/usr/local/bin/tiger-nic-rb-handler stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

[root@rhel-tiger-14-6 ~]# systemctl enable --now tiger-nic-rb-handler
Created symlink /etc/systemd/system/multi-user.target.wants/tiger-nic-rb-handler.service → /etc/systemd/system/tiger-nic-rb-handler.service.

The script simply sources the list of unmanaged interfaces from the NetworkManager configuration created earlier and uses ethtool to find and set the ring buffers to their maximum values. The filename in the script must match the filename created earlier.