workqueue: Use list_last_entry() to get the last idle worker
authorLai Jiangshan <jiangshan.ljs@antgroup.com>
Fri, 8 Mar 2024 09:42:53 +0000 (17:42 +0800)
committerTejun Heo <tj@kernel.org>
Mon, 25 Mar 2024 19:12:24 +0000 (09:12 -1000)
It is clearer than open code.

Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/workqueue.c

index f03960f094fadbdeacda3cd333cfe48acd6818b8..d1ccc3d05b7a6f190b2ebfda00a61eb5771d14bf 100644 (file)
@@ -2904,7 +2904,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);
 
@@ -2946,7 +2946,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)) {