Commit 7219bd1a authored by Ankit Kumar's avatar Ankit Kumar Committed by Jim Harris
Browse files

thread: use extended version of fd group add



As the message file descriptor of thread is of type eventfd, we can set
fd type in the event handler opts and use SPDK_FD_GROUP_ADD_EXT.
This way we don't need to read the msg fd, which will be done during
the fd group wait.

Set msg_fd to -1 if fd group creation fails, to prevent wrong cleaup
during thread_interrupt_destroy call.

Change-Id: I2b64ad09bb368484a81781e4805ecbf8fc8cb02c
Signed-off-by: default avatarAnkit Kumar <ankit.kumar@samsung.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/25432


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Community-CI: Mellanox Build Bot
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 1a5bdab3
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -2769,15 +2769,6 @@ thread_interrupt_msg_process(void *arg)
	orig_thread = spdk_get_thread();
	spdk_set_thread(thread);

	/* There may be race between msg_acknowledge and another producer's msg_notify,
	 * so msg_acknowledge should be applied ahead. And then check for self's msg_notify.
	 * This can avoid msg notification missing.
	 */
	rc = read(thread->msg_fd, &notify, sizeof(notify));
	if (rc < 0 && errno != EAGAIN) {
		SPDK_ERRLOG("failed to acknowledge msg event: %s.\n", spdk_strerror(errno));
	}

	critical_msg = thread->critical_msg;
	if (spdk_unlikely(critical_msg != NULL)) {
		critical_msg(NULL);
@@ -2808,12 +2799,14 @@ thread_interrupt_msg_process(void *arg)
static int
thread_interrupt_create(struct spdk_thread *thread)
{
	struct spdk_event_handler_opts opts = {};
	int rc;

	SPDK_INFOLOG(thread, "Create fgrp for thread (%s)\n", thread->name);

	rc = spdk_fd_group_create(&thread->fgrp);
	if (rc) {
		thread->msg_fd = -1;
		return rc;
	}

@@ -2826,8 +2819,11 @@ thread_interrupt_create(struct spdk_thread *thread)
		return rc;
	}

	return SPDK_FD_GROUP_ADD(thread->fgrp, thread->msg_fd,
				 thread_interrupt_msg_process, thread);
	spdk_fd_group_get_default_event_handler_opts(&opts, sizeof(opts));
	opts.fd_type = SPDK_FD_TYPE_EVENTFD;

	return SPDK_FD_GROUP_ADD_EXT(thread->fgrp, thread->msg_fd,
				     thread_interrupt_msg_process, thread, &opts);
}
#else
static int