mm/percpu: use list_first_entry_or_null in pcpu_reclaim_populated()
authorBaoquan He <bhe@redhat.com>
Tue, 25 Oct 2022 03:11:45 +0000 (11:11 +0800)
committerDennis Zhou <dennis@kernel.org>
Tue, 8 Nov 2022 06:57:53 +0000 (22:57 -0800)
To replace list_empty()/list_first_entry() pair to simplify code.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Dennis Zhou <dennis@kernel.org>
Signed-off-by: Dennis Zhou <dennis@kernel.org>
mm/percpu.c

index 26d8cd2..841bb93 100644 (file)
@@ -2143,9 +2143,9 @@ static void pcpu_reclaim_populated(void)
         * other accessor is the free path which only returns area back to the
         * allocator not touching the populated bitmap.
         */
-       while (!list_empty(&pcpu_chunk_lists[pcpu_to_depopulate_slot])) {
-               chunk = list_first_entry(&pcpu_chunk_lists[pcpu_to_depopulate_slot],
-                                        struct pcpu_chunk, list);
+       while ((chunk = list_first_entry_or_null(
+                       &pcpu_chunk_lists[pcpu_to_depopulate_slot],
+                       struct pcpu_chunk, list))) {
                WARN_ON(chunk->immutable);
 
                /*