Re: [PATCH] mm/memcontrol.c: use list_{first,next}_entry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <geliangtang@xxxxxxx>
> > ---
> >  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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]