* [PATCH] mm: memcontrol: clarify the uncharge_list() loop
@ 2016-03-10 20:50 Johannes Weiner
2016-03-10 21:30 ` Andrew Morton
2016-03-11 8:19 ` Michal Hocko
0 siblings, 2 replies; 4+ messages in thread
From: Johannes Weiner @ 2016-03-10 20:50 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, Vladimir Davydov, linux-mm, cgroups, linux-kernel,
kernel-team
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
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: memcontrol: clarify the uncharge_list() loop
2016-03-10 20:50 [PATCH] mm: memcontrol: clarify the uncharge_list() loop Johannes Weiner
@ 2016-03-10 21:30 ` Andrew Morton
2016-03-10 22:16 ` Johannes Weiner
2016-03-11 8:19 ` Michal Hocko
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2016-03-10 21:30 UTC (permalink / raw)
To: Johannes Weiner
Cc: Michal Hocko, Vladimir Davydov, linux-mm, cgroups, linux-kernel,
kernel-team
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.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: memcontrol: clarify the uncharge_list() loop
2016-03-10 21:30 ` Andrew Morton
@ 2016-03-10 22:16 ` Johannes Weiner
0 siblings, 0 replies; 4+ messages in thread
From: Johannes Weiner @ 2016-03-10 22:16 UTC (permalink / raw)
To: Andrew Morton
Cc: Michal Hocko, Vladimir Davydov, linux-mm, cgroups, linux-kernel,
kernel-team
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.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: memcontrol: clarify the uncharge_list() loop
2016-03-10 20:50 [PATCH] mm: memcontrol: clarify the uncharge_list() loop Johannes Weiner
2016-03-10 21:30 ` Andrew Morton
@ 2016-03-11 8:19 ` Michal Hocko
1 sibling, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2016-03-11 8:19 UTC (permalink / raw)
To: Johannes Weiner
Cc: Andrew Morton, Vladimir Davydov, linux-mm, cgroups, linux-kernel,
kernel-team
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
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-03-11 8:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-10 20:50 [PATCH] mm: memcontrol: clarify the uncharge_list() loop Johannes Weiner
2016-03-10 21:30 ` Andrew Morton
2016-03-10 22:16 ` Johannes Weiner
2016-03-11 8:19 ` Michal Hocko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).