linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Geliang Tang <geliangtang@163.com>
To: Michal Hocko <mhocko@kernel.org>, Johannes Weiner <hannes@cmpxchg.org>
Cc: cgroups@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, Geliang Tang <geliangtang@163.com>
Subject: Re: [PATCH] mm/memcontrol.c: use list_{first,next}_entry
Date: Sat, 5 Dec 2015 10:55:42 +0800	[thread overview]
Message-ID: <20151205025542.GB9812@bogon> (raw)
In-Reply-To: <20151203162718.GK9264@dhcp22.suse.cz>

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@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
> > 

--
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>

  parent reply	other threads:[~2015-12-05  2:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-03 14:16 [PATCH] mm/memcontrol.c: use list_{first,next}_entry Geliang Tang
2015-12-03 16:27 ` Michal Hocko
2015-12-03 19:27   ` Johannes Weiner
2015-12-04  8:46     ` Michal Hocko
2015-12-05  2:55   ` Geliang Tang [this message]
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=20151205025542.GB9812@bogon \
    --to=geliangtang@163.com \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.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;
as well as URLs for NNTP newsgroup(s).