Skip to content

Commit

Permalink
control/server.py: support --cpumask=0xF / -m=0xF
Browse files Browse the repository at this point in the history
- #866

Signed-off-by: Alexander Indenbaum <[email protected]>
  • Loading branch information
Alexander Indenbaum committed Sep 12, 2024
1 parent 32b7c29 commit b040814
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion control/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spdk
Submodule spdk updated 653 files

0 comments on commit b040814

Please sign in to comment.