summaryrefslogtreecommitdiffstats
path: root/sbin/hastd
diff options
context:
space:
mode:
authortrociny <trociny@FreeBSD.org>2013-12-10 20:06:41 +0000
committertrociny <trociny@FreeBSD.org>2013-12-10 20:06:41 +0000
commit7a816c7150b0046af6a022ef1d7d427ac8e39c7e (patch)
tree9b30fe69420145e1da623ef70af6d1095ddfc0f1 /sbin/hastd
parentf157138bd257c4482e29f29e8ca90c29aa92ad67 (diff)
downloadFreeBSD-src-7a816c7150b0046af6a022ef1d7d427ac8e39c7e.zip
FreeBSD-src-7a816c7150b0046af6a022ef1d7d427ac8e39c7e.tar.gz
Send wakeup to threads waiting on empty queue before releasing the
lock to decrease spurious wakeups. Submitted by: davidxu MFC after: 2 weeks
Diffstat (limited to 'sbin/hastd')
-rw-r--r--sbin/hastd/primary.c16
-rw-r--r--sbin/hastd/secondary.c7
2 files changed, 7 insertions, 16 deletions
diff --git a/sbin/hastd/primary.c b/sbin/hastd/primary.c
index 629b8a4..385a52a 100644
--- a/sbin/hastd/primary.c
+++ b/sbin/hastd/primary.c
@@ -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; \
diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c
index 899ee92..5e1207a 100644
--- a/sbin/hastd/secondary.c
+++ b/sbin/hastd/secondary.c
@@ -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); \
OpenPOWER on IntegriCloud