From 0686f0381b02e35678f9572786a8000fe5514ee4 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Mon, 25 Dec 2017 08:26:52 +0900 Subject: [PATCH] vhost: Remove DPDK dependency and simplify load balancing The latest patch for the iSCSI connection is applied to the vhost too. RTE_MAX_LCORE in the for loop is removed and the for loop is replaced by SPDK_ENV_FOREACH_CORE(). When the cpumask is unexpectedly 0, not 0 but the first core is returned. Change-Id: I39cfc2219a3532eccc8c0ce59712102b947a76d7 Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/392588 Tested-by: SPDK Automated Test System Reviewed-by: Ziye Yang Reviewed-by: Daniel Verkamp Reviewed-by: Ben Walker Reviewed-by: Dariusz Stojaczyk --- lib/vhost/vhost.c | 10 ++-------- test/unit/lib/vhost/vhost.c/vhost_ut.c | 2 ++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index a949f5c4d..16e8c69de 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -677,16 +677,10 @@ spdk_vhost_allocate_reactor(uint64_t cpumask) uint32_t i, selected_core; uint32_t min_ctrlrs; - cpumask &= spdk_app_get_core_mask(); - - if (cpumask == 0) { - return 0; - } - min_ctrlrs = INT_MAX; - selected_core = 0; + selected_core = spdk_env_get_first_core(); - for (i = 0; i < RTE_MAX_LCORE && i < 64; i++) { + SPDK_ENV_FOREACH_CORE(i) { if (!((1ULL << i) & cpumask)) { continue; } diff --git a/test/unit/lib/vhost/vhost.c/vhost_ut.c b/test/unit/lib/vhost/vhost.c/vhost_ut.c index ec63b37a2..bf69d5feb 100644 --- a/test/unit/lib/vhost/vhost.c/vhost_ut.c +++ b/test/unit/lib/vhost/vhost.c/vhost_ut.c @@ -48,6 +48,8 @@ DEFINE_STUB(spdk_mem_register, int, (void *vaddr, size_t len), 0); DEFINE_STUB(spdk_mem_unregister, int, (void *vaddr, size_t len), 0); DEFINE_STUB(spdk_app_get_core_mask, uint64_t, (void), 0); DEFINE_STUB(spdk_app_parse_core_mask, int, (const char *mask, uint64_t *cpumask), 0); +DEFINE_STUB(spdk_env_get_first_core, uint32_t, (void), 0); +DEFINE_STUB(spdk_env_get_next_core, uint32_t, (uint32_t prev_core), 0); DEFINE_STUB_V(spdk_app_stop, (int rc)); DEFINE_STUB_V(spdk_event_call, (struct spdk_event *event)); DEFINE_STUB(spdk_poller_register, struct spdk_poller *, (spdk_poller_fn fn, void *arg,