Commit 5c782a70 authored by Jim Harris's avatar Jim Harris Committed by Konrad Sztyber
Browse files

thread: allow users to pass NULL fn_ptr when registering interrupt



There are a lot of cases where the set_interrupt_mode callback
function is not needed for callers of spdk_poller_register_interrupt().
Today, we force all callers to pass a function pointer, which in
most cases does nothing. So relax this restriction to simplify
calling code.

Signed-off-by: default avatarJim Harris <jim.harris@samsung.com>
Change-Id: Ib4064722c4dbd9366363a86a0ba7ccb5640cd1f9
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24626


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarChangpeng Liu <changpeliu@tencent.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 072f3706
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -124,6 +124,9 @@ typedef void (*spdk_poller_set_interrupt_mode_cb)(struct spdk_poller *poller, vo
 * When registering the poller set interrupt callback, the callback will get
 * executed immediately if its spdk_thread is in the interrupt mode.
 *
 * Callers may pass NULL for the cb_fn, signifying that no callback is
 * necessary when the interrupt mode changes.
 *
 * \param poller The poller to register callback function.
 * \param cb_fn Callback function called when the poller must transition into or out of interrupt mode
 * \param cb_arg Argument passed to the callback function.
+1 −6
Original line number Diff line number Diff line
@@ -249,11 +249,6 @@ nvmf_poll_group_add_transport(struct spdk_nvmf_poll_group *group,
	return 0;
}

static void
nvmf_tgt_poller_set_interrupt_mode(struct spdk_poller *poller, void *cb_arg, bool interrupt_mode)
{
}

static int
nvmf_tgt_create_poll_group(void *io_device, void *ctx_buf)
{
@@ -272,7 +267,7 @@ nvmf_tgt_create_poll_group(void *io_device, void *ctx_buf)
	pthread_mutex_init(&group->mutex, NULL);

	group->poller = SPDK_POLLER_REGISTER(nvmf_poll_group_poll, group, 0);
	spdk_poller_register_interrupt(group->poller, nvmf_tgt_poller_set_interrupt_mode, NULL);
	spdk_poller_register_interrupt(group->poller, NULL, NULL);

	SPDK_DTRACE_PROBE1_TICKS(nvmf_create_poll_group, spdk_thread_get_id(thread));

+1 −8
Original line number Diff line number Diff line
@@ -697,12 +697,6 @@ static int nvmf_tcp_accept(void *ctx);

static void nvmf_tcp_accept_cb(void *ctx, struct spdk_sock_group *group, struct spdk_sock *sock);

static void
nvmf_tcp_poller_set_interrupt_mode_nop(struct spdk_poller *poller, void *cb_arg,
				       bool interrupt_mode)
{
}

static struct spdk_nvmf_transport *
nvmf_tcp_create(struct spdk_nvmf_transport_opts *opts)
{
@@ -833,8 +827,7 @@ nvmf_tcp_create(struct spdk_nvmf_transport_opts *opts)
		return NULL;
	}

	spdk_poller_register_interrupt(ttransport->accept_poller, nvmf_tcp_poller_set_interrupt_mode_nop,
				       NULL);
	spdk_poller_register_interrupt(ttransport->accept_poller, NULL, NULL);

	ttransport->listen_sock_group = spdk_sock_group_create(NULL);
	if (ttransport->listen_sock_group == NULL) {
+1 −8
Original line number Diff line number Diff line
@@ -4258,12 +4258,6 @@ vfio_user_dev_info_fill(struct nvmf_vfio_user_transport *vu_transport,

static int nvmf_vfio_user_accept(void *ctx);

static void
set_intr_mode_noop(struct spdk_poller *poller, void *arg, bool interrupt_mode)
{
	/* Nothing for us to do here. */
}

/*
 * Register an "accept" poller: this is polling for incoming vfio-user socket
 * connections (on the listening socket).
@@ -4300,8 +4294,7 @@ vfio_user_register_accept_poller(struct nvmf_vfio_user_endpoint *endpoint)

	assert(endpoint->accept_intr != NULL);

	spdk_poller_register_interrupt(endpoint->accept_poller,
				       set_intr_mode_noop, NULL);
	spdk_poller_register_interrupt(endpoint->accept_poller, NULL, NULL);
	return 0;
}

+4 −3
Original line number Diff line number Diff line
@@ -1607,7 +1607,6 @@ spdk_poller_register_interrupt(struct spdk_poller *poller,
			       void *cb_arg)
{
	assert(poller != NULL);
	assert(cb_fn != NULL);
	assert(spdk_get_thread() == poller->thread);

	if (!spdk_interrupt_mode_is_enabled()) {
@@ -1623,7 +1622,7 @@ spdk_poller_register_interrupt(struct spdk_poller *poller,
	poller->set_intr_cb_arg = cb_arg;

	/* Set poller into interrupt mode if thread is in interrupt. */
	if (poller->thread->in_interrupt) {
	if (poller->thread->in_interrupt && poller->set_intr_cb_fn) {
		poller->set_intr_cb_fn(poller, poller->set_intr_cb_arg, true);
	}
}
@@ -2078,8 +2077,10 @@ poller_set_interrupt_mode(struct spdk_poller *poller, bool interrupt_mode)
		return;
	}

	if (poller->set_intr_cb_fn) {
		poller->set_intr_cb_fn(poller, poller->set_intr_cb_arg, interrupt_mode);
	}
}

void
spdk_thread_set_interrupt_mode(bool enable_interrupt)
Loading