From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763620AbZEHS3u (ORCPT ); Fri, 8 May 2009 14:29:50 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754518AbZEHS3l (ORCPT ); Fri, 8 May 2009 14:29:41 -0400 Received: from waste.org ([66.93.16.53]:46197 "EHLO waste.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754285AbZEHS3l (ORCPT ); Fri, 8 May 2009 14:29:41 -0400 Date: Fri, 8 May 2009 13:28:46 -0500 From: Matt Mackall To: Wu Fengguang Cc: Andrew Morton , LKML , KOSAKI Motohiro , Andi Kleen , linux-mm@kvack.org Subject: Re: [PATCH 3/7] proc: kpagecount/kpageflags code cleanup Message-ID: <20090508182845.GX31071@waste.org> References: <20090507012116.996644836@intel.com> <20090507014914.244032831@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090507014914.244032831@intel.com> User-Agent: Mutt/1.5.13 (2006-08-11) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 07, 2009 at 09:21:20AM +0800, Wu Fengguang wrote: > Move increments of pfn/out to bottom of the loop. > > Signed-off-by: Wu Fengguang Acked-by: Matt Mackall > --- > fs/proc/page.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > --- linux.orig/fs/proc/page.c > +++ linux/fs/proc/page.c > @@ -11,6 +11,7 @@ > > #define KPMSIZE sizeof(u64) > #define KPMMASK (KPMSIZE - 1) > + > /* /proc/kpagecount - an array exposing page counts > * > * Each entry is a u64 representing the corresponding > @@ -32,20 +33,22 @@ static ssize_t kpagecount_read(struct fi > return -EINVAL; > > while (count > 0) { > - ppage = NULL; > if (pfn_valid(pfn)) > ppage = pfn_to_page(pfn); > - pfn++; > + else > + ppage = NULL; > if (!ppage) > pcount = 0; > else > pcount = page_mapcount(ppage); > > - if (put_user(pcount, out++)) { > + if (put_user(pcount, out)) { > ret = -EFAULT; > break; > } > > + pfn++; > + out++; > count -= KPMSIZE; > } > > @@ -98,10 +101,10 @@ static ssize_t kpageflags_read(struct fi > return -EINVAL; > > while (count > 0) { > - ppage = NULL; > if (pfn_valid(pfn)) > ppage = pfn_to_page(pfn); > - pfn++; > + else > + ppage = NULL; > if (!ppage) > kflags = 0; > else > @@ -119,11 +122,13 @@ static ssize_t kpageflags_read(struct fi > kpf_copy_bit(kflags, KPF_RECLAIM, PG_reclaim) | > kpf_copy_bit(kflags, KPF_BUDDY, PG_buddy); > > - if (put_user(uflags, out++)) { > + if (put_user(uflags, out)) { > ret = -EFAULT; > break; > } > > + pfn++; > + out++; > count -= KPMSIZE; > } > > > -- -- Mathematics is the supreme nostalgia of our time.