Send wakeup to threads waiting on empty queue before releasing the
lock to decrease spurious wakeups. Submitted by: davidxu MFC after: 2 weeks
This commit is contained in:
parent
f157138bd2
commit
7a816c7150
@ -180,27 +180,21 @@ static pthread_mutex_t metadata_lock;
|
||||
((res)->hr_remotein != NULL && (res)->hr_remoteout != NULL)
|
||||
|
||||
#define QUEUE_INSERT1(hio, name, ncomp) do { \
|
||||
bool _wakeup; \
|
||||
\
|
||||
mtx_lock(&hio_##name##_list_lock[(ncomp)]); \
|
||||
_wakeup = TAILQ_EMPTY(&hio_##name##_list[(ncomp)]); \
|
||||
if (TAILQ_EMPTY(&hio_##name##_list[(ncomp)])) \
|
||||
cv_broadcast(&hio_##name##_list_cond[(ncomp)]); \
|
||||
TAILQ_INSERT_TAIL(&hio_##name##_list[(ncomp)], (hio), \
|
||||
hio_next[(ncomp)]); \
|
||||
hio_##name##_list_size[(ncomp)]++; \
|
||||
mtx_unlock(&hio_##name##_list_lock[ncomp]); \
|
||||
if (_wakeup) \
|
||||
cv_broadcast(&hio_##name##_list_cond[(ncomp)]); \
|
||||
mtx_unlock(&hio_##name##_list_lock[(ncomp)]); \
|
||||
} while (0)
|
||||
#define QUEUE_INSERT2(hio, name) do { \
|
||||
bool _wakeup; \
|
||||
\
|
||||
mtx_lock(&hio_##name##_list_lock); \
|
||||
_wakeup = TAILQ_EMPTY(&hio_##name##_list); \
|
||||
if (TAILQ_EMPTY(&hio_##name##_list)) \
|
||||
cv_broadcast(&hio_##name##_list_cond); \
|
||||
TAILQ_INSERT_TAIL(&hio_##name##_list, (hio), hio_##name##_next);\
|
||||
hio_##name##_list_size++; \
|
||||
mtx_unlock(&hio_##name##_list_lock); \
|
||||
if (_wakeup) \
|
||||
cv_broadcast(&hio_##name##_list_cond); \
|
||||
} while (0)
|
||||
#define QUEUE_TAKE1(hio, name, ncomp, timeout) do { \
|
||||
bool _last; \
|
||||
|
@ -110,15 +110,12 @@ static void *disk_thread(void *arg);
|
||||
static void *send_thread(void *arg);
|
||||
|
||||
#define QUEUE_INSERT(name, hio) do { \
|
||||
bool _wakeup; \
|
||||
\
|
||||
mtx_lock(&hio_##name##_list_lock); \
|
||||
_wakeup = TAILQ_EMPTY(&hio_##name##_list); \
|
||||
if (TAILQ_EMPTY(&hio_##name##_list)) \
|
||||
cv_broadcast(&hio_##name##_list_cond); \
|
||||
TAILQ_INSERT_TAIL(&hio_##name##_list, (hio), hio_next); \
|
||||
hio_##name##_list_size++; \
|
||||
mtx_unlock(&hio_##name##_list_lock); \
|
||||
if (_wakeup) \
|
||||
cv_broadcast(&hio_##name##_list_cond); \
|
||||
} while (0)
|
||||
#define QUEUE_TAKE(name, hio) do { \
|
||||
mtx_lock(&hio_##name##_list_lock); \
|
||||
|
Loading…
Reference in New Issue
Block a user