Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

control/server.py: support --cpumask=0xF #867

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
gbregman marked this conversation as resolved.
Show resolved Hide resolved
return True

# Check for the presence of "--cpumask="
for arg in args:
if arg.startswith('--cpumask='):
return True
gbregman marked this conversation as resolved.
Show resolved Hide resolved

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
Loading