[PATCH 4/4] workqueue: Use list_last_entry() to get the last idle worker

From: Lai Jiangshan
Date: Fri Mar 08 2024 - 04:41:28 EST


From: Lai Jiangshan <jiangshan.ljs@xxxxxxxxxxxx>

It is clearer than open code.

Signed-off-by: Lai Jiangshan <jiangshan.ljs@xxxxxxxxxxxx>
---
kernel/workqueue.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 3bb71cfd3e06..7a3392aab395 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2940,7 +2940,7 @@ static void idle_worker_timeout(struct timer_list *t)
unsigned long expires;

/* idle_list is kept in LIFO order, check the last one */
- worker = list_entry(pool->idle_list.prev, struct worker, entry);
+ worker = list_last_entry(&pool->idle_list, struct worker, entry);
expires = worker->last_active + IDLE_WORKER_TIMEOUT;
do_cull = !time_before(jiffies, expires);

@@ -2982,7 +2982,7 @@ static void idle_cull_fn(struct work_struct *work)
struct worker *worker;
unsigned long expires;

- worker = list_entry(pool->idle_list.prev, struct worker, entry);
+ worker = list_last_entry(&pool->idle_list, struct worker, entry);
expires = worker->last_active + IDLE_WORKER_TIMEOUT;

if (time_before(jiffies, expires)) {
--
2.19.1.6.gb485710b