Skip to content

Commit

Permalink
T6917: fix RPS ethernet settings for CPUs with more than 32 cores
Browse files Browse the repository at this point in the history
The maximun value theat could be written for the 'rpc_cpu'
is 4294967295 or 0xffffffff

Ensure that the bitmask size doesn't exceed 32 bits, even if
the system has more CPUs.
  • Loading branch information
sever-sever committed Dec 2, 2024
1 parent 29cc3d7 commit f89d613
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion python/vyos/ifconfig/ethernet.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,19 @@ def set_rps(self, state):
rps_cpus = 0
queues = len(glob(f'/sys/class/net/{self.ifname}/queues/rx-*'))
if state:
# Maximum integer value that could be written for the 'rps_cpu'
# is 4294967295 or 0xffffffff
# Ensure that the bitmask size doesn't exceed 32 bits, even if
# the system has more CPUs.
max_supported_cpus = 32

# Enable RPS on all available CPUs except CPU0 which we will not
# utilize so the system has one spare core when it's under high
# preasure to server other means. Linux sysfs excepts a bitmask
# representation of the CPUs which should participate on RPS, we
# can enable more CPUs that are physically present on the system,
# Linux will clip that internally!
rps_cpus = (1 << os.cpu_count()) -1
rps_cpus = (1 << min(os.cpu_count(), max_supported_cpus)) - 1

# XXX: we should probably reserve one core when the system is under
# high preasure so we can still have a core left for housekeeping.
Expand Down

0 comments on commit f89d613

Please sign in to comment.