summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-01-13 06:47:10 +0100
committerChristian Breunig <christian@breunig.cc>2023-01-13 06:47:10 +0100
commite7ac306c31f51c1b6d6ec2dd1aef86744f3fc794 (patch)
treeb8ad6aced298e6f82bbcc24140f8764ab44c0ca7 /python/vyos
parentc0ffb8ba4e6639254a853c18f1433d1677d7703d (diff)
downloadvyos-1x-e7ac306c31f51c1b6d6ec2dd1aef86744f3fc794.tar.gz
vyos-1x-e7ac306c31f51c1b6d6ec2dd1aef86744f3fc794.zip
ethernet: rps: T4928: adjust to Kernel ABI changes #2
Fix ValueError: Unknown format code 'x' for object of type 'str' added in commit c0ffb8ba4e663 ("ethernet: rps: T4928: adjust to Kernel ABI changes").
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/ifconfig/ethernet.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py
index b45d8ea28..5080144ff 100644
--- a/python/vyos/ifconfig/ethernet.py
+++ b/python/vyos/ifconfig/ethernet.py
@@ -239,7 +239,7 @@ class EthernetIf(Interface):
if not isinstance(state, bool):
raise ValueError('Value out of range')
- rps_cpus = '0'
+ rps_cpus = 0
queues = len(glob(f'/sys/class/net/{self.ifname}/queues/rx-*'))
if state:
# Enable RPS on all available CPUs except CPU0 which we will not
@@ -248,9 +248,13 @@ class EthernetIf(Interface):
# 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 = os.cpu_count()
- if rps_cpus > 1:
- rps_cpus -= 1
+ rps_cpus = (1 << os.cpu_count()) -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.
+ # This is done by masking out the lowst bit so CPU0 is spared from
+ # receive packet steering.
+ rps_cpus &= ~1
for i in range(0, queues):
self._write_sysfs(f'/sys/class/net/{self.ifname}/queues/rx-{i}/rps_cpus', f'{rps_cpus:x}')