Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932163AbbLEC4i (ORCPT ); Fri, 4 Dec 2015 21:56:38 -0500 Received: from m50-138.163.com ([123.125.50.138]:39953 "EHLO m50-138.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750798AbbLEC4g (ORCPT ); Fri, 4 Dec 2015 21:56:36 -0500 Date: Sat, 5 Dec 2015 10:55:42 +0800 From: Geliang Tang To: Michal Hocko , Johannes Weiner Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Geliang Tang Subject: Re: [PATCH] mm/memcontrol.c: use list_{first,next}_entry Message-ID: <20151205025542.GB9812@bogon> References: <9e62e3006561653fcbf0c49cf0b9c2b653a8ed0e.1449152124.git.geliangtang@163.com> <20151203162718.GK9264@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151203162718.GK9264@dhcp22.suse.cz> User-Agent: Mutt/1.5.24 (2015-08-30) X-CM-TRANSID: C9GowAB3wzguUmJWmwFGAQ--.65184S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7WryfuFyfCw47Ww47Gw4kJFb_yoW8Ww1fpF ZYk3Wjkr4kJr1FgF47X3Wq9r1SvanF9ws2y348Cw1kX3W2yr48W3W7tr1ru395GrW8WrnI vFs0gF9rAr4UAa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRQTmgUUUUU= X-Originating-IP: [116.77.147.85] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbivxDHmVWBOxNVzAAAsU Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1980 Lines: 62 On Thu, Dec 03, 2015 at 05:27:18PM +0100, Michal Hocko wrote: > 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... I have tested it, list_for_each_entry can't work. Dose it mean that my patch is OK? Or please give me some other advices. Thanks. - Geliang > > Signed-off-by: Geliang Tang > > --- > > 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 > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/