about summary refs log tree commit homepage
path: root/ioq.c
diff options
context:
space:
mode:
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));