thread: extract send_msg_notification func
Change-Id: Ib83c53b138614ba9889969c1f98e1a5bdf7fee42 Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7153 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
fbd6c30b8b
commit
8c4c8c3967
@ -887,6 +887,23 @@ spdk_thread_get_last_tsc(struct spdk_thread *thread)
|
||||
return thread->tsc_last;
|
||||
}
|
||||
|
||||
static inline int
|
||||
thread_send_msg_notification(const struct spdk_thread *target_thread)
|
||||
{
|
||||
uint64_t notify = 1;
|
||||
int rc;
|
||||
|
||||
if (target_thread->interrupt_mode) {
|
||||
rc = write(target_thread->msg_fd, ¬ify, sizeof(notify));
|
||||
if (rc < 0) {
|
||||
SPDK_ERRLOG("failed to notify msg_queue: %s.\n", spdk_strerror(errno));
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_thread_send_msg(const struct spdk_thread *thread, spdk_msg_fn fn, void *ctx)
|
||||
{
|
||||
@ -931,17 +948,7 @@ spdk_thread_send_msg(const struct spdk_thread *thread, spdk_msg_fn fn, void *ctx
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (thread->interrupt_mode) {
|
||||
uint64_t notify = 1;
|
||||
|
||||
rc = write(thread->msg_fd, ¬ify, sizeof(notify));
|
||||
if (rc < 0) {
|
||||
SPDK_ERRLOG("failed to notify msg_queue: %s.\n", spdk_strerror(errno));
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return thread_send_msg_notification(thread);
|
||||
}
|
||||
|
||||
int
|
||||
@ -949,23 +956,12 @@ spdk_thread_send_critical_msg(struct spdk_thread *thread, spdk_msg_fn fn)
|
||||
{
|
||||
spdk_msg_fn expected = NULL;
|
||||
|
||||
if (__atomic_compare_exchange_n(&thread->critical_msg, &expected, fn, false, __ATOMIC_SEQ_CST,
|
||||
__ATOMIC_SEQ_CST)) {
|
||||
if (thread->interrupt_mode) {
|
||||
uint64_t notify = 1;
|
||||
int rc;
|
||||
|
||||
rc = write(thread->msg_fd, ¬ify, sizeof(notify));
|
||||
if (rc < 0) {
|
||||
SPDK_ERRLOG("failed to notify msg_queue: %s.\n", spdk_strerror(errno));
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
if (!__atomic_compare_exchange_n(&thread->critical_msg, &expected, fn, false, __ATOMIC_SEQ_CST,
|
||||
__ATOMIC_SEQ_CST)) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return -EIO;
|
||||
return thread_send_msg_notification(thread);
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
|
Loading…
Reference in New Issue
Block a user