Skip to content

Commit

Permalink
control/server.py: auto detection of spdk reactor cpu bitmask
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Indenbaum <[email protected]>
  • Loading branch information
Alexander Indenbaum committed Sep 4, 2024
1 parent d5d1962 commit e789d3f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ceph-nvmeof.conf
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ tgt_path = /usr/local/bin/nvmf_tgt
timeout = 60.0
#log_level = WARNING

# Example value: -m 0x3 -L all
# Example value: -L all
# tgt_cmd_extra_args =

# transports = tcp
Expand Down
11 changes: 11 additions & 0 deletions control/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def sigchld_handler(signum, frame):
# GW process should exit now
raise SystemExit(f"Gateway subprocess terminated {pid=} {exit_code=}")

def int_to_bitmask(n):
"""Converts an integer n to a bitmask string"""
return f"0x{hex((1 << n) - 1)[2:].upper()}"

class GatewayServer:
"""Runs SPDK and receives client requests for the gateway service.
Expand Down Expand Up @@ -363,8 +367,15 @@ def _start_spdk(self, omap_state):
spdk_tgt_cmd_extra_args = self.config.get_with_default(
"spdk", "tgt_cmd_extra_args", "")
cmd = [spdk_tgt_path, "-u", "-r", self.spdk_rpc_socket_path]

# Calculate cpu mask available for spdk reactors
cpu_mask = f"-m {int_to_bitmask(os.cpu_count())}"
cmd += shlex.split(cpu_mask)

# Add extra args from the conf file
if spdk_tgt_cmd_extra_args:
cmd += shlex.split(spdk_tgt_cmd_extra_args)

self.logger.info(f"Starting {' '.join(cmd)}")
try:
# start spdk process
Expand Down

0 comments on commit e789d3f

Please sign in to comment.