From a22b37dc551d40a12e90280822718f46002d8327 Mon Sep 17 00:00:00 2001 From: Alexander Indenbaum Date: Thu, 12 Sep 2024 13:39:06 +0000 Subject: [PATCH] control/server.py: support --cpumask=0xF - https://github.com/ceph/ceph-nvmeof/issues/866 Signed-off-by: Alexander Indenbaum --- control/server.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/control/server.py b/control/server.py index e7b8df29..332cbcd4 100644 --- a/control/server.py +++ b/control/server.py @@ -58,6 +58,20 @@ def int_to_bitmask(n): """Converts an integer n to a bitmask string""" return f"0x{hex((1 << n) - 1)[2:].upper()}" +def cpumask_set(args): + """Check if reactor cpu mask is set in command line args""" + + # Check if "-m" or "--cpumask" is in the arguments + if "-m" in args or "--cpumask" in args: + return True + + # Check for the presence of "--cpumask=" + for arg in args: + if arg.startswith('--cpumask='): + return True + + return False + class GatewayServer: """Runs SPDK and receives client requests for the gateway service. @@ -384,7 +398,7 @@ def _start_spdk(self, omap_state): # If not provided in configuration, # calculate cpu mask available for spdk reactors - if '-m' not in cmd and '--cpumask' not in cmd: + if not cpumask_set(cmd): cpu_mask = f"-m {int_to_bitmask(min(4, os.cpu_count()))}" self.logger.info(f"SPDK autodetecting cpu_mask: {cpu_mask}") cmd += shlex.split(cpu_mask)