|
|
cb8e9e |
From f338f8513ec9ffbe26ba9fe4de000331dc2c2789 Mon Sep 17 00:00:00 2001
|
|
|
cb8e9e |
From: Krishnan Parthasarathi <kparthas@redhat.com>
|
|
|
cb8e9e |
Date: Thu, 13 Aug 2015 14:39:58 +0530
|
|
|
cb8e9e |
Subject: [PATCH 314/320] event-epoll: Use pollers[] to check if event_pool_dispatch was called
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Backport of http://review.gluster.org/12004
|
|
|
cb8e9e |
|
|
|
cb8e9e |
This patch allows event_pool to change the no. of worker threads handling
|
|
|
cb8e9e |
events independent of event_dispatch() being called.
|
|
|
cb8e9e |
|
|
|
cb8e9e |
NB This patch is not a straight backport of the above patch. It
|
|
|
cb8e9e |
telescopes the following patches upstream,
|
|
|
cb8e9e |
|
|
|
cb8e9e |
[1] http://review.gluster.com/11911
|
|
|
cb8e9e |
[2] http://review.gluster.com/12004
|
|
|
cb8e9e |
|
|
|
cb8e9e |
[1] - uses an extra flag to change behaviour of reconfiguring the no. of
|
|
|
cb8e9e |
worker threads. This wasn't complete.
|
|
|
cb8e9e |
|
|
|
cb8e9e |
[2] - makes event_reconfigure_threads() implementation of epoll-based
|
|
|
cb8e9e |
eventing independent of when event_dispatch() is called , without the
|
|
|
cb8e9e |
extra flag introduced in [1].
|
|
|
cb8e9e |
|
|
|
cb8e9e |
BUG: 1241336
|
|
|
cb8e9e |
Change-Id: Ia8df3c958545324472262c555ed84b71797f002e
|
|
|
cb8e9e |
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
|
|
|
cb8e9e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/56626
|
|
|
cb8e9e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
cb8e9e |
Tested-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
cb8e9e |
---
|
|
|
cb8e9e |
libglusterfs/src/event-epoll.c | 24 +++++++++++++++++++++++-
|
|
|
cb8e9e |
1 files changed, 23 insertions(+), 1 deletions(-)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
diff --git a/libglusterfs/src/event-epoll.c b/libglusterfs/src/event-epoll.c
|
|
|
cb8e9e |
index 9403217..fc3099d 100644
|
|
|
cb8e9e |
--- a/libglusterfs/src/event-epoll.c
|
|
|
cb8e9e |
+++ b/libglusterfs/src/event-epoll.c
|
|
|
cb8e9e |
@@ -770,6 +770,23 @@ event_dispatch_epoll (struct event_pool *event_pool)
|
|
|
cb8e9e |
return ret;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
+/**
|
|
|
cb8e9e |
+ * @param event_pool event_pool on which fds of interest are registered for
|
|
|
cb8e9e |
+ * events.
|
|
|
cb8e9e |
+ *
|
|
|
cb8e9e |
+ * @return 1 if at least one epoll worker thread is spawned, 0 otherwise
|
|
|
cb8e9e |
+ *
|
|
|
cb8e9e |
+ * NB This function SHOULD be called under event_pool->mutex.
|
|
|
cb8e9e |
+ */
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+static int
|
|
|
cb8e9e |
+event_pool_dispatched_unlocked (struct event_pool *event_pool)
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
+ return (event_pool->pollers[0] != 0);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
int
|
|
|
cb8e9e |
event_reconfigure_threads_epoll (struct event_pool *event_pool, int value)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
@@ -796,7 +813,12 @@ event_reconfigure_threads_epoll (struct event_pool *event_pool, int value)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
oldthreadcount = event_pool->eventthreadcount;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- if (oldthreadcount < value) {
|
|
|
cb8e9e |
+ /* Start 'worker' threads as necessary only if event_dispatch()
|
|
|
cb8e9e |
+ * was called before. If event_dispatch() was not called, there
|
|
|
cb8e9e |
+ * will be no epoll 'worker' threads running yet. */
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ if (event_pool_dispatched_unlocked(event_pool)
|
|
|
cb8e9e |
+ && (oldthreadcount < value)) {
|
|
|
cb8e9e |
/* create more poll threads */
|
|
|
cb8e9e |
for (i = oldthreadcount; i < value; i++) {
|
|
|
cb8e9e |
/* Start a thread if the index at this location
|
|
|
cb8e9e |
--
|
|
|
cb8e9e |
1.7.1
|
|
|
cb8e9e |
|