about summary refs log tree commit homepage
path: root/ioq.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-07-11 22:15:56 +0000
committerEric Wong <normalperson@yhbt.net>2013-07-12 00:21:06 +0000
commite50365f275ada4afcd5f25f2ac3328e341a79d71 (patch)
tree0e0d1b5ee52424ab2c0fa125b4f31fedbd83e2a4 /ioq.c
parentf83d0466afc32542f3f4ff962105c817a1be2c96 (diff)
downloadcmogstored-e50365f275ada4afcd5f25f2ac3328e341a79d71.tar.gz
Users reducing or increasing thread counts should increase
ioq capacity, otherwise there's no point in having more or
less threads if they are synched to the ioq capacity.
Diffstat (limited to 'ioq.c')
-rw-r--r--ioq.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/ioq.c b/ioq.c
index 829e00d..0a32c71 100644
--- a/ioq.c
+++ b/ioq.c
@@ -90,6 +90,7 @@ void mog_ioq_next(struct mog_ioq *check_ioq)
         } else {
                 /* mog_ioq_adjust was called and lowered our capacity */
                 mog_ioq_current->cur--;
+                ioq_set_contended(mog_ioq_current);
         }
         CHECK(int, 0, pthread_mutex_unlock(&mog_ioq_current->mtx));
 
@@ -121,6 +122,23 @@ bool mog_ioq_contended(void)
         return __sync_bool_compare_and_swap(&cur->contended, true, false);
 }
 
+/*
+ * called by the main/notify thread if the user has ever set
+ * "server aio_threads = XX" via sidechannel.
+ */
+void mog_ioq_adjust(struct mog_ioq *ioq, unsigned value)
+{
+        assert(value > 0 && "mog_ioq_adjust value must be non-zero");
+        CHECK(int, 0, pthread_mutex_lock(&ioq->mtx));
+        ioq->max = value;
+
+        /* capacity reduced, get some threads to yield themselves */
+        if (ioq->cur > ioq->max)
+                ioq_set_contended(ioq);
+
+        CHECK(int, 0, pthread_mutex_unlock(&ioq->mtx));
+}
+
 void mog_ioq_destroy(struct mog_ioq *ioq)
 {
         CHECK(int, 0, pthread_mutex_destroy(&ioq->mtx));