]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tasks: pass the queue index to run_task_from_list()
authorWilly Tarreau <w@1wt.eu>
Wed, 24 Jun 2020 07:54:24 +0000 (09:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 24 Jun 2020 10:21:26 +0000 (12:21 +0200)
Instead of passing it a pointer to the queue, pass it the queue's index
so that it can perform all the work around current_queue and tl_class_mask.

include/haproxy/task.h
src/task.c

index 3a56acd7a50fc2e282fec8c916e76731fa2e72fc..335baf9a848cde6c079226416d4bd4ca1361f0be 100644 (file)
@@ -116,7 +116,7 @@ struct work_list *work_list_create(int nbthread,
                                    struct task *(*fct)(struct task *, void *, unsigned short),
                                    void *arg);
 void work_list_destroy(struct work_list *work, int nbthread);
-int run_tasks_from_list(struct list *list, int max);
+int run_tasks_from_list(unsigned int queue, int max);
 
 /*
  * This does 3 things :
index d6bda26d615426e17e0c7e587cc13fc0ab5fce45..65d29c33317ba151d5a9c44d11b9a191178f5c77 100644 (file)
@@ -318,20 +318,31 @@ int next_timer_expiry()
        return ret;
 }
 
-/* Walks over tasklet list <list> and run at most <max> of them. Returns
- * the number of entries effectively processed (tasks and tasklets merged).
- * The count of tasks in the list for the current thread is adjusted.
+/* Walks over tasklet list sched->tasklets[queue] and run at most <max> of
+ * them. Returns the number of entries effectively processed (tasks and
+ * tasklets merged). The count of tasks in the list for the current thread
+ * is adjusted.
  */
-int run_tasks_from_list(struct list *list, int max)
+int run_tasks_from_list(unsigned int queue, int max)
 {
        struct task *(*process)(struct task *t, void *ctx, unsigned short state);
+       struct list *tl_queues = sched->tasklets;
        struct task *t;
        unsigned short state;
        void *ctx;
        int done = 0;
 
-       while (done < max && !LIST_ISEMPTY(list)) {
-               t = (struct task *)LIST_ELEM(list->n, struct tasklet *, list);
+       sched->current_queue = queue;
+       while (1) {
+               if (LIST_ISEMPTY(&tl_queues[queue])) {
+                       sched->tl_class_mask &= ~(1 << queue);
+                       break;
+               }
+
+               if (done >= max)
+                       break;
+
+               t = (struct task *)LIST_ELEM(tl_queues[queue].n, struct tasklet *, list);
                state = (t->state & (TASK_SHARED_WQ|TASK_SELF_WAKING));
 
                ti->flags &= ~TI_FL_STUCK; // this thread is still running
@@ -400,6 +411,7 @@ int run_tasks_from_list(struct list *list, int max)
                }
                done++;
        }
+       sched->current_queue = -1;
 
        return done;
 }
@@ -553,13 +565,8 @@ void process_runnable_tasks()
 
        /* execute tasklets in each queue */
        for (queue = 0; queue < TL_CLASSES; queue++) {
-               if (max[queue] > 0) {
-                       tt->current_queue = queue;
-                       max_processed -= run_tasks_from_list(&tt->tasklets[queue], max[queue]);
-                       tt->current_queue = -1;
-                       if (LIST_ISEMPTY(&tt->tasklets[queue]))
-                               tt->tl_class_mask &= ~(1 << queue);
-               }
+               if (max[queue] > 0)
+                       max_processed -= run_tasks_from_list(queue, max[queue]);
        }
 
        /* some tasks may have woken other ones up */