From 8eef5183d3db3a9cba8fac20444e7f583bb947ec Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 17 Oct 2017 11:21:50 -0700 Subject: [PATCH] bdev: remove spdk_bdev_poller_start() lcore option Always start bdev pollers on the calling core. This removes the lcore concept from the bdev poller abstraction and simplifies the job of spdk_bdev_initialize() callers providing their own poller and event implementations. All callers except the NVMe bdev hotplug poller already used the current core as the parameter. The NVMe HotplugPollCore option was undocumented and unused in any of the tests or example configuration files, so it should be safe to remove. Change-Id: I93b466e1e58901b8785c40cbe296fa46c157850f Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/382857 Tested-by: SPDK Automated Test System Reviewed-by: Dariusz Stojaczyk Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris --- examples/bdev/fio_plugin/fio_plugin.c | 1 - include/spdk/bdev.h | 1 - include/spdk_internal/bdev.h | 17 ++++++++++++++++- lib/bdev/aio/bdev_aio.c | 3 +-- lib/bdev/bdev.c | 3 +-- lib/bdev/nvme/bdev_nvme.c | 13 ++----------- lib/bdev/rbd/bdev_rbd.c | 3 +-- lib/bdev/virtio/bdev_virtio.c | 7 ++----- lib/event/subsystems/bdev/bdev.c | 4 ++-- 9 files changed, 25 insertions(+), 27 deletions(-) diff --git a/examples/bdev/fio_plugin/fio_plugin.c b/examples/bdev/fio_plugin/fio_plugin.c index 0569f37e2..9bcd4c8cf 100644 --- a/examples/bdev/fio_plugin/fio_plugin.c +++ b/examples/bdev/fio_plugin/fio_plugin.c @@ -129,7 +129,6 @@ static void spdk_fio_start_poller(struct spdk_bdev_poller **ppoller, spdk_bdev_poller_fn fn, void *arg, - uint32_t lcore, uint64_t period_microseconds) { struct spdk_fio_thread *fio_thread; diff --git a/include/spdk/bdev.h b/include/spdk/bdev.h index 68502018c..771cb417e 100644 --- a/include/spdk/bdev.h +++ b/include/spdk/bdev.h @@ -120,7 +120,6 @@ typedef void (*spdk_bdev_poller_fn)(void *arg); typedef void (*spdk_bdev_poller_start_cb)(struct spdk_bdev_poller **ppoller, spdk_bdev_poller_fn fn, void *arg, - uint32_t lcore, uint64_t period_microseconds); typedef void (*spdk_bdev_poller_stop_cb)(struct spdk_bdev_poller **ppoller); diff --git a/include/spdk_internal/bdev.h b/include/spdk_internal/bdev.h index 124015c65..40fb9a336 100644 --- a/include/spdk_internal/bdev.h +++ b/include/spdk_internal/bdev.h @@ -367,12 +367,27 @@ int spdk_bdev_module_claim_bdev(struct spdk_bdev *bdev, struct spdk_bdev_desc *d struct spdk_bdev_module_if *module); void spdk_bdev_module_release_bdev(struct spdk_bdev *bdev); +/** + * Start a poller on the current thread to periodically call fn. + * + * \param[out] ppoller Will be filled with initialized poller pointer. + * \param fn Function to run periodically. + * \param arg Argument to be passed to fn. + * \param period_microseconds Delay between calls of the poller function, + * or 0 to call as frequently as possible. + * + * The user must call spdk_bdev_poller_stop() to clean up the resources allocated by this function. + */ void spdk_bdev_poller_start(struct spdk_bdev_poller **ppoller, spdk_bdev_poller_fn fn, void *arg, - uint32_t lcore, uint64_t period_microseconds); +/** + * Stop a poller started by spdk_bdev_poller_start(). + * + * \param ppoller Poller to stop. + */ void spdk_bdev_poller_stop(struct spdk_bdev_poller **ppoller); /** diff --git a/lib/bdev/aio/bdev_aio.c b/lib/bdev/aio/bdev_aio.c index 0080082ba..f7fb21d7a 100644 --- a/lib/bdev/aio/bdev_aio.c +++ b/lib/bdev/aio/bdev_aio.c @@ -312,8 +312,7 @@ bdev_aio_create_cb(void *io_device, void *ctx_buf) return -1; } - spdk_bdev_poller_start(&ch->poller, bdev_aio_poll, ch, - spdk_env_get_current_core(), 0); + spdk_bdev_poller_start(&ch->poller, bdev_aio_poll, ch, 0); return 0; } diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index 7f733fddd..de9b72b84 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -451,10 +451,9 @@ void spdk_bdev_poller_start(struct spdk_bdev_poller **ppoller, spdk_bdev_poller_fn fn, void *arg, - uint32_t lcore, uint64_t period_microseconds) { - g_bdev_mgr.start_poller_fn(ppoller, fn, arg, lcore, period_microseconds); + g_bdev_mgr.start_poller_fn(ppoller, fn, arg, period_microseconds); } void diff --git a/lib/bdev/nvme/bdev_nvme.c b/lib/bdev/nvme/bdev_nvme.c index 9a7a00515..ecb1f16cd 100644 --- a/lib/bdev/nvme/bdev_nvme.c +++ b/lib/bdev/nvme/bdev_nvme.c @@ -129,7 +129,6 @@ static int g_timeout = 0; static int g_nvme_adminq_poll_timeout_us = 0; static bool g_nvme_hotplug_enabled = false; static int g_nvme_hotplug_poll_timeout_us = 0; -static int g_nvme_hotplug_poll_core = 0; static struct spdk_bdev_poller *g_hotplug_poller; static pthread_mutex_t g_bdev_nvme_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -499,8 +498,7 @@ bdev_nvme_create_cb(void *io_device, void *ctx_buf) return -1; } - spdk_bdev_poller_start(&ch->poller, bdev_nvme_poll, ch, - spdk_env_get_current_core(), 0); + spdk_bdev_poller_start(&ch->poller, bdev_nvme_poll, ch, 0); return 0; } @@ -849,7 +847,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid, } spdk_bdev_poller_start(&nvme_ctrlr->adminq_timer_poller, bdev_nvme_poll_adminq, ctrlr, - spdk_env_get_current_core(), g_nvme_adminq_poll_timeout_us); + g_nvme_adminq_poll_timeout_us); TAILQ_INSERT_TAIL(&g_nvme_ctrlrs, nvme_ctrlr, tailq); @@ -1029,12 +1027,6 @@ bdev_nvme_library_init(void) g_nvme_hotplug_poll_timeout_us = 100000; } - g_nvme_hotplug_poll_core = spdk_conf_section_get_intval(sp, "HotplugPollCore"); - if (g_nvme_hotplug_poll_core <= 0) { - g_nvme_hotplug_poll_core = spdk_env_get_current_core(); - } - - for (i = 0; i < NVME_MAX_CONTROLLERS; i++) { val = spdk_conf_section_get_nmval(sp, "TransportID", i, 0); if (val == NULL) { @@ -1084,7 +1076,6 @@ bdev_nvme_library_init(void) if (g_nvme_hotplug_enabled) { spdk_bdev_poller_start(&g_hotplug_poller, bdev_nvme_hotplug, NULL, - g_nvme_hotplug_poll_core, g_nvme_hotplug_poll_timeout_us); } diff --git a/lib/bdev/rbd/bdev_rbd.c b/lib/bdev/rbd/bdev_rbd.c index e4c44c90a..9f06be8e1 100644 --- a/lib/bdev/rbd/bdev_rbd.c +++ b/lib/bdev/rbd/bdev_rbd.c @@ -417,8 +417,7 @@ bdev_rbd_create_cb(void *io_device, void *ctx_buf) goto err; } - spdk_bdev_poller_start(&ch->poller, bdev_rbd_io_poll, ch, - spdk_env_get_current_core(), 0); + spdk_bdev_poller_start(&ch->poller, bdev_rbd_io_poll, ch, 0); return 0; diff --git a/lib/bdev/virtio/bdev_virtio.c b/lib/bdev/virtio/bdev_virtio.c index fab444b87..80427c630 100644 --- a/lib/bdev/virtio/bdev_virtio.c +++ b/lib/bdev/virtio/bdev_virtio.c @@ -453,8 +453,7 @@ bdev_virtio_create_cb(void *io_device, void *ctx_buf) ch->vdev = vdev; ch->vq = vq; - spdk_bdev_poller_start(&vq->poller, bdev_virtio_poll, ch, - vq->owner_lcore, 0); + spdk_bdev_poller_start(&vq->poller, bdev_virtio_poll, ch, 0); return 0; } @@ -876,9 +875,7 @@ bdev_virtio_initialize(void) vq = vdev->vqs[VIRTIO_SCSI_REQUESTQ]; base->vq = vq; vq->poller_ctx = base; - spdk_bdev_poller_start(&vq->poller, bdev_scan_poll, base, - vq->owner_lcore, 0); - + spdk_bdev_poller_start(&vq->poller, bdev_scan_poll, base, 0); scan_target(base); } diff --git a/lib/event/subsystems/bdev/bdev.c b/lib/event/subsystems/bdev/bdev.c index bb5424644..0a9aa3870 100644 --- a/lib/event/subsystems/bdev/bdev.c +++ b/lib/event/subsystems/bdev/bdev.c @@ -34,6 +34,7 @@ #include "spdk/stdinc.h" #include "spdk/bdev.h" +#include "spdk/env.h" #include "spdk_internal/event.h" @@ -47,13 +48,12 @@ static void spdk_bdev_subsystem_start_poller(struct spdk_bdev_poller **ppoller, spdk_bdev_poller_fn fn, void *arg, - uint32_t lcore, uint64_t period_microseconds) { spdk_poller_register((struct spdk_poller **)ppoller, fn, arg, - lcore, + spdk_env_get_current_core(), period_microseconds); }