From: Michal Hocko <mhocko@kernel.org>
To: Geliang Tang <geliangtang@163.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/memcontrol.c: use list_{first,next}_entry
Date: Thu, 3 Dec 2015 17:27:18 +0100 [thread overview]
Message-ID: <20151203162718.GK9264@dhcp22.suse.cz> (raw)
In-Reply-To: <9e62e3006561653fcbf0c49cf0b9c2b653a8ed0e.1449152124.git.geliangtang@163.com>
On Thu 03-12-15 22:16:55, Geliang Tang wrote:
> To make the intention clearer, use list_{first,next}_entry instead
> of list_entry.
Does this really help readability? This function simply uncharges the
given list of pages. Why cannot we simply use list_for_each_entry
instead...
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
> mm/memcontrol.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 79a29d5..a6301ea 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -5395,16 +5395,12 @@ static void uncharge_list(struct list_head *page_list)
> unsigned long nr_file = 0;
> unsigned long nr_huge = 0;
> unsigned long pgpgout = 0;
> - struct list_head *next;
> struct page *page;
>
> - next = page_list->next;
> + page = list_first_entry(page_list, struct page, lru);
> do {
> unsigned int nr_pages = 1;
>
> - page = list_entry(next, struct page, lru);
> - next = page->lru.next;
> -
> VM_BUG_ON_PAGE(PageLRU(page), page);
> VM_BUG_ON_PAGE(page_count(page), page);
>
> @@ -5440,7 +5436,8 @@ static void uncharge_list(struct list_head *page_list)
> page->mem_cgroup = NULL;
>
> pgpgout++;
> - } while (next != page_list);
> + } while (!list_is_last(&page->lru, page_list) &&
> + (page = list_next_entry(page, lru)));
>
> if (memcg)
> uncharge_batch(memcg, pgpgout, nr_anon, nr_file,
> --
> 2.5.0
>
--
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>
next prev parent reply other threads:[~2015-12-03 16:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-03 14:16 Geliang Tang
2015-12-03 16:27 ` Michal Hocko [this message]
2015-12-03 19:27 ` Johannes Weiner
2015-12-04 8:46 ` Michal Hocko
2015-12-05 2:55 ` Geliang Tang
2015-12-05 16:22 ` Johannes Weiner
2015-12-07 16:21 ` Michal Hocko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151203162718.GK9264@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=geliangtang@163.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox