mm: memcontrol: clarify the uncharge_list() loop
authorJohannes Weiner <[email protected]>
Thu, 17 Mar 2016 21:20:31 +0000 (14:20 -0700)
committerLinus Torvalds <[email protected]>
Thu, 17 Mar 2016 22:09:34 +0000 (15:09 -0700)
uncharge_list() does an unusual list walk because the function can take
regular lists with dedicated list_heads as well as singleton lists where
a single page is passed via the page->lru list node.

This can sometimes lead to confusion as well as suggestions to replace
the loop with a list_for_each_entry(), which wouldn't work.

Signed-off-by: Johannes Weiner <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Cc: Vladimir Davydov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/memcontrol.c

index 8614e0d750e54d8ac884f05871f486e1fad786ee..fa7bf354ae3204a789ac8868707dff811055508c 100644 (file)
@@ -5420,6 +5420,10 @@ static void uncharge_list(struct list_head *page_list)
        struct list_head *next;
        struct page *page;
 
+       /*
+        * Note that the list can be a single page->lru; hence the
+        * do-while loop instead of a simple list_for_each_entry().
+        */
        next = page_list->next;
        do {
                unsigned int nr_pages = 1;