workqueue: move last bits of end accounting to caller
authorJens Axboe <axboe@fb.com>
Tue, 8 Dec 2015 15:44:56 +0000 (08:44 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 8 Dec 2015 15:44:56 +0000 (08:44 -0700)
Signed-off-by: Jens Axboe <axboe@fb.com>
backend.c
workqueue.c
workqueue.h

index c208b22..c18cf20 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1492,10 +1492,14 @@ err:
 
 }
 
-static void io_workqueue_exit_worker_fn(struct submit_worker *sw)
+static void io_workqueue_exit_worker_fn(struct submit_worker *sw,
+                                       unsigned int *sum_cnt)
 {
        struct thread_data *td = sw->private;
 
+       (*sum_cnt)++;
+       sum_thread_stats(&sw->wq->td->ts, &td->ts, *sum_cnt == 1);
+
        fio_options_free(td);
        close_and_free_files(td);
        if (td->io_ops)
index 484d3a9..9fe7bec 100644 (file)
@@ -204,11 +204,11 @@ done:
        return NULL;
 }
 
-static void free_worker(struct submit_worker *sw)
+static void free_worker(struct submit_worker *sw, unsigned int *sum_cnt)
 {
        struct workqueue *wq = sw->wq;
 
-       workqueue_exit_worker(sw);
+       workqueue_exit_worker(sw, sum_cnt);
 
        pthread_cond_destroy(&sw->cond);
        pthread_mutex_destroy(&sw->lock);
@@ -219,13 +219,8 @@ static void free_worker(struct submit_worker *sw)
 
 static void shutdown_worker(struct submit_worker *sw, unsigned int *sum_cnt)
 {
-       struct thread_data *parent = sw->wq->td;
-       struct thread_data *td = sw->private;
-
        pthread_join(sw->thread, NULL);
-       (*sum_cnt)++;
-       sum_thread_stats(&parent->ts, &td->ts, *sum_cnt == 1);
-       free_worker(sw);
+       free_worker(sw, sum_cnt);
 }
 
 void workqueue_exit(struct workqueue *wq)
@@ -288,7 +283,7 @@ static int start_worker(struct workqueue *wq, unsigned int index)
                return 0;
        }
 
-       free_worker(sw);
+       free_worker(sw, NULL);
        return 1;
 }
 
index 3119ff1..c2464b2 100644 (file)
@@ -25,7 +25,7 @@ typedef void (workqueue_pre_sleep_fn)(struct submit_worker *);
 typedef int (workqueue_alloc_worker_fn)(struct submit_worker *);
 typedef void (workqueue_free_worker_fn)(struct submit_worker *);
 typedef int (workqueue_init_worker_fn)(struct submit_worker *);
-typedef void (workqueue_exit_worker_fn)(struct submit_worker *);
+typedef void (workqueue_exit_worker_fn)(struct submit_worker *, unsigned int *);
 typedef void (workqueue_update_acct_fn)(struct submit_worker *);
 
 struct workqueue_ops {
@@ -92,13 +92,18 @@ static inline int workqueue_init_worker(struct submit_worker *sw)
        return wq->ops.init_worker_fn(sw);
 }
 
-static inline void workqueue_exit_worker(struct submit_worker *sw)
+static inline void workqueue_exit_worker(struct submit_worker *sw,
+                                        unsigned int *sum_cnt)
 {
        struct workqueue *wq = sw->wq;
+       unsigned int tmp = 1;
 
        if (!wq->ops.exit_worker_fn)
                return;
 
-       wq->ops.exit_worker_fn(sw);
+       if (!sum_cnt)
+               sum_cnt = &tmp;
+
+       wq->ops.exit_worker_fn(sw, sum_cnt);
 }
 #endif