CLEANUP: tasks: remove the long-unused work_lists

Work lists were a mechanism introduced in 1.8 to asynchronously delegate
some work to be performed on another thread via a dedicated task.
The only user was the listeners, to deal with the queue. Nowadays
the tasklets have made this much more convenient, and have replaced
work_lists in the listeners. It seems there will be no valid use case
of work lists anymore, so better get rid of them entirely and keep the
scheduler code cleaner.
This commit is contained in:
Willy Tarreau 2021-10-01 18:30:14 +02:00
parent f542941f71
commit 6a2a912cb8
3 changed files with 0 additions and 73 deletions

View File

@ -162,22 +162,6 @@ struct tasklet {
*/
/* A work_list is a thread-safe way to enqueue some work to be run on another
* thread. It consists of a list, a task and a general-purpose argument.
* A work is appended to the list by atomically adding a list element to the
* list and waking up the associated task, which is done using work_add(). The
* caller must be careful about how operations are run as it will definitely
* happen that the element being enqueued is processed by the other thread
* before the call returns. Some locking conventions between the caller and the
* callee might sometimes be necessary. The task is always woken up with reason
* TASK_WOKEN_OTHER and a context pointing to the work_list entry.
*/
struct work_list {
struct mt_list head;
struct task *task;
void *arg;
};
#endif /* _HAPROXY_TASK_T_H */
/*

View File

@ -110,11 +110,6 @@ void task_kill(struct task *t);
void tasklet_kill(struct tasklet *t);
void __task_wakeup(struct task *t);
void __task_queue(struct task *task, struct eb_root *wq);
struct work_list *work_list_create(int nbthread,
struct task *(*fct)(struct task *, void *, unsigned int),
void *arg);
void work_list_destroy(struct work_list *work, int nbthread);
unsigned int run_tasks_from_lists(unsigned int budgets[]);
/*
@ -684,13 +679,6 @@ static inline int notification_registered(struct list *wake)
return !LIST_ISEMPTY(wake);
}
/* adds list item <item> to work list <work> and wake up the associated task */
static inline void work_list_add(struct work_list *work, struct mt_list *item)
{
MT_LIST_TRY_APPEND(&work->head, item);
task_wakeup(work->task, TASK_WOKEN_OTHER);
}
#endif /* _HAPROXY_TASK_H */
/*

View File

@ -859,51 +859,6 @@ void process_runnable_tasks()
activity[tid].long_rq++;
}
/* create a work list array for <nbthread> threads, using tasks made of
* function <fct>. The context passed to the function will be the pointer to
* the thread's work list, which will contain a copy of argument <arg>. The
* wake up reason will be TASK_WOKEN_OTHER. The pointer to the work_list array
* is returned on success, otherwise NULL on failure.
*/
struct work_list *work_list_create(int nbthread,
struct task *(*fct)(struct task *, void *, unsigned int),
void *arg)
{
struct work_list *wl;
int i;
wl = calloc(nbthread, sizeof(*wl));
if (!wl)
goto fail;
for (i = 0; i < nbthread; i++) {
MT_LIST_INIT(&wl[i].head);
wl[i].task = task_new(1UL << i);
if (!wl[i].task)
goto fail;
wl[i].task->process = fct;
wl[i].task->context = &wl[i];
wl[i].arg = arg;
}
return wl;
fail:
work_list_destroy(wl, nbthread);
return NULL;
}
/* destroy work list <work> */
void work_list_destroy(struct work_list *work, int nbthread)
{
int t;
if (!work)
return;
for (t = 0; t < nbthread; t++)
task_destroy(work[t].task);
free(work);
}
/*
* Delete every tasks before running the master polling loop
*/