From 4f752e1d7579ef698a111e5d73dec33785170f16 Mon Sep 17 00:00:00 2001 From: GangCao Date: Tue, 24 Jan 2017 12:52:23 +0800 Subject: [PATCH] nvmf_tgt: assign different core for subsystems under RPC mode Change-Id: Ib751c45f916f66b682d3011397f1f8fe794b08d8 Signed-off-by: GangCao --- app/nvmf_tgt/conf.c | 8 +++++++- app/nvmf_tgt/nvmf_rpc.c | 1 + app/nvmf_tgt/nvmf_tgt.h | 2 +- scripts/rpc.py | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/nvmf_tgt/conf.c b/app/nvmf_tgt/conf.c index db24f732a..dac09ff59 100644 --- a/app/nvmf_tgt/conf.c +++ b/app/nvmf_tgt/conf.c @@ -84,6 +84,7 @@ struct spdk_nvmf_probe_ctx { #define SPDK_NVMF_CONFIG_MAX_IO_SIZE_MAX 131072 struct spdk_nvmf_tgt_conf g_spdk_nvmf_tgt_conf; +static int32_t g_last_rpc_lcore = -1; static int spdk_get_numa_node_value(char *path) @@ -659,7 +660,7 @@ spdk_nvmf_parse_conf(void) int spdk_nvmf_parse_subsystem_for_rpc(const char *name, - const char *mode_str, uint32_t lcore, + const char *mode_str, int32_t lcore, int num_listen_addresses, struct rpc_listen_address *addresses, int num_hosts, char *hosts[], const char *bdf, const char *sn, int num_devs, char *dev_list[]) @@ -685,9 +686,14 @@ spdk_nvmf_parse_subsystem_for_rpc(const char *name, return -1; } + if (lcore < 0) { + lcore = ++g_last_rpc_lcore; + } + /* Determine which core to assign to the subsystem */ mask = spdk_app_get_core_mask(); lcore = spdk_nvmf_allocate_lcore(mask, lcore); + g_last_rpc_lcore = lcore; /* Determine the mode the subsysem will operate in */ if (mode_str == NULL) { diff --git a/app/nvmf_tgt/nvmf_rpc.c b/app/nvmf_tgt/nvmf_rpc.c index 9476b2a45..eab3cf9b4 100644 --- a/app/nvmf_tgt/nvmf_rpc.c +++ b/app/nvmf_tgt/nvmf_rpc.c @@ -294,6 +294,7 @@ spdk_rpc_construct_nvmf_subsystem(struct spdk_jsonrpc_server_conn *conn, struct rpc_subsystem req = {}; struct spdk_json_write_ctx *w; int ret; + req.core = -1; /* Explicitly set the core as the uninitialized value */ if (spdk_json_decode_object(params, rpc_subsystem_decoders, sizeof(rpc_subsystem_decoders) / sizeof(*rpc_subsystem_decoders), diff --git a/app/nvmf_tgt/nvmf_tgt.h b/app/nvmf_tgt/nvmf_tgt.h index e60df7739..bfe1360ab 100644 --- a/app/nvmf_tgt/nvmf_tgt.h +++ b/app/nvmf_tgt/nvmf_tgt.h @@ -78,7 +78,7 @@ struct nvmf_tgt_subsystem *nvmf_tgt_create_subsystem(const char *name, int spdk_nvmf_parse_subsystem_for_rpc(const char *name, - const char *mode, uint32_t lcore, + const char *mode, int32_t lcore, int num_listen_addresses, struct rpc_listen_address *addresses, int num_hosts, char *hosts[], const char *bdf, const char *sn, int num_devs, char *dev_list[]); diff --git a/scripts/rpc.py b/scripts/rpc.py index a96e54830..dd9f4ac2e 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -375,7 +375,7 @@ def construct_nvmf_subsystem(args): jsonrpc_call('construct_nvmf_subsystem', params) p = subparsers.add_parser('construct_nvmf_subsystem', help='Add a nvmf subsystem') -p.add_argument("-c", "--core", help='The core Nvmf target run on', type=int, default=0) +p.add_argument("-c", "--core", help='The core Nvmf target run on', type=int, default=-1) p.add_argument('mode', help='Target mode: Virtual or Direct') p.add_argument('nqn', help='Target nqn(ASCII)') p.add_argument('listen', help="""comma-separated list of Listen pairs enclosed