Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1355375 > unrolled thread

[PATCH] mm: memcontrol: clarify the uncharge_list() loop

Started byJohannes Weiner <hannes@cmpxchg.org>
First post2016-03-10 22:00 +0100
Last post2016-03-11 09:30 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mm: memcontrol: clarify the uncharge_list() loop Johannes Weiner <hannes@cmpxchg.org> - 2016-03-10 22:00 +0100
    Re: [PATCH] mm: memcontrol: clarify the uncharge_list() loop Andrew Morton <akpm@linux-foundation.org> - 2016-03-10 22:40 +0100
      Re: [PATCH] mm: memcontrol: clarify the uncharge_list() loop Johannes Weiner <hannes@cmpxchg.org> - 2016-03-10 23:20 +0100
    Re: [PATCH] mm: memcontrol: clarify the uncharge_list() loop Michal Hocko <mhocko@kernel.org> - 2016-03-11 09:30 +0100

#1355375 — [PATCH] mm: memcontrol: clarify the uncharge_list() loop

FromJohannes Weiner <hannes@cmpxchg.org>
Date2016-03-10 22:00 +0100
Subject[PATCH] mm: memcontrol: clarify the uncharge_list() loop
Message-ID<rbfQC-3PQ-11@gated-at.bofh.it>
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 <hannes@cmpxchg.org>
---
 mm/memcontrol.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 8614e0d750e5..fa7bf354ae32 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -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;
-- 
2.7.2

[toc] | [next] | [standalone]


#1355415

FromAndrew Morton <akpm@linux-foundation.org>
Date2016-03-10 22:40 +0100
Message-ID<rbgtk-4rm-7@gated-at.bofh.it>
In reply to#1355375
LGTM.  It's very late in the cycle so I'll queue all three for 4.6-rc1
and I tagged the first two patches (not this one) for -stable
backporting.

[toc] | [prev] | [next] | [standalone]


#1355428

FromJohannes Weiner <hannes@cmpxchg.org>
Date2016-03-10 23:20 +0100
Message-ID<rbh62-4Y2-9@gated-at.bofh.it>
In reply to#1355415
On Thu, Mar 10, 2016 at 01:30:34PM -0800, Andrew Morton wrote:
> 
> LGTM.  It's very late in the cycle so I'll queue all three for 4.6-rc1
> and I tagged the first two patches (not this one) for -stable
> backporting.

Sounds good, thank you.

[toc] | [prev] | [next] | [standalone]


#1355685

FromMichal Hocko <mhocko@kernel.org>
Date2016-03-11 09:30 +0100
Message-ID<rbqCm-3mu-3@gated-at.bofh.it>
In reply to#1355375
On Thu 10-03-16 15:50:15, Johannes Weiner wrote:
> 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.

Yes this confused at least me 2 times AFAIR.

> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Michal Hocko <mhocko@suse.com>

Thanks!

> ---
>  mm/memcontrol.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 8614e0d750e5..fa7bf354ae32 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -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;
> -- 
> 2.7.2

-- 
Michal Hocko
SUSE Labs

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web