From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755885AbZEPJa6 (ORCPT ); Sat, 16 May 2009 05:30:58 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754035AbZEPJas (ORCPT ); Sat, 16 May 2009 05:30:48 -0400 Received: from mga03.intel.com ([143.182.124.21]:32733 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754634AbZEPJar (ORCPT ); Sat, 16 May 2009 05:30:47 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.41,204,1241420400"; d="scan'208";a="143512958" Date: Sat, 16 May 2009 17:30:05 +0800 From: Wu Fengguang To: Rik van Riel Cc: Minchan Kim , Andrew Morton , "hannes@cmpxchg.org" , "peterz@infradead.org" , "linux-kernel@vger.kernel.org" , "tytso@mit.edu" , "linux-mm@kvack.org" , "elladan@eskimo.com" , "npiggin@suse.de" , "cl@linux-foundation.org" , "kosaki.motohiro@jp.fujitsu.com" Subject: Re: [PATCH -mm] vmscan: merge duplicate code in shrink_active_list() Message-ID: <20090516093005.GB11652@localhost> References: <1241432635.7620.4732.camel@twins> <20090507121101.GB20934@localhost> <20090507151039.GA2413@cmpxchg.org> <20090507134410.0618b308.akpm@linux-foundation.org> <20090508081608.GA25117@localhost> <20090508125859.210a2a25.akpm@linux-foundation.org> <20090512025319.GD7518@localhost> <20090512162633.352313d6.minchan.kim@barrios-desktop> <20090512114807.GC5926@localhost> <4A097A80.9000502@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4A097A80.9000502@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 12, 2009 at 09:32:48PM +0800, Rik van Riel wrote: > Wu Fengguang wrote: > > On Tue, May 12, 2009 at 03:26:33PM +0800, Minchan Kim wrote: > >> On Tue, 12 May 2009 10:53:19 +0800 > >> Wu Fengguang wrote: > >> > >>> The "move pages to active list" and "move pages to inactive list" > >>> code blocks are mostly identical and can be served by a function. > >>> > >>> Thanks to Andrew Morton for pointing this out. > >>> > >>> Signed-off-by: Wu Fengguang > >>> --- > >>> mm/vmscan.c | 84 ++++++++++++++++++++------------------------------ > >>> 1 file changed, 35 insertions(+), 49 deletions(-) > >>> > >>> --- linux.orig/mm/vmscan.c > >>> +++ linux/mm/vmscan.c > >>> @@ -1225,6 +1225,36 @@ static inline void note_zone_scanning_pr > >>> * But we had to alter page->flags anyway. > >>> */ > >>> > >>> +void move_active_pages_to_lru(enum lru_list lru, struct list_head *list) > >>> +{ > >>> + unsigned long pgmoved = 0; > >>> + > >>> + while (!list_empty(&list)) { > >>> + page = lru_to_page(&list); > >>> + prefetchw_prev_lru_page(page, &list, flags); > >>> + > >>> + VM_BUG_ON(PageLRU(page)); > >>> + SetPageLRU(page); > >>> + > >>> + VM_BUG_ON(!PageActive(page)); > >>> + if (lru < LRU_ACTIVE) > >>> + ClearPageActive(page); > >> Arithmetic on the LRU list is not good code for redability, I think. > >> How about adding comment? > >> > >> if (lru < LRU_ACTIVE) /* In case of moving from active list to inactive */ > >> > >> Ignore me if you think this is trivial. > > > > Good suggestion. Or this simple one: "we are de-activating"? > > lru < LRU_ACTIVE will never be true for file pages, > either active or inactive. Thanks - that old patch version was really broken. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail137.messagelabs.com (mail137.messagelabs.com [216.82.249.19]) by kanga.kvack.org (Postfix) with SMTP id 8E10B6B0082 for ; Sat, 16 May 2009 05:30:21 -0400 (EDT) Date: Sat, 16 May 2009 17:30:05 +0800 From: Wu Fengguang Subject: Re: [PATCH -mm] vmscan: merge duplicate code in shrink_active_list() Message-ID: <20090516093005.GB11652@localhost> References: <1241432635.7620.4732.camel@twins> <20090507121101.GB20934@localhost> <20090507151039.GA2413@cmpxchg.org> <20090507134410.0618b308.akpm@linux-foundation.org> <20090508081608.GA25117@localhost> <20090508125859.210a2a25.akpm@linux-foundation.org> <20090512025319.GD7518@localhost> <20090512162633.352313d6.minchan.kim@barrios-desktop> <20090512114807.GC5926@localhost> <4A097A80.9000502@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4A097A80.9000502@redhat.com> Sender: owner-linux-mm@kvack.org To: Rik van Riel Cc: Minchan Kim , Andrew Morton , "hannes@cmpxchg.org" , "peterz@infradead.org" , "linux-kernel@vger.kernel.org" , "tytso@mit.edu" , "linux-mm@kvack.org" , "elladan@eskimo.com" , "npiggin@suse.de" , "cl@linux-foundation.org" , "kosaki.motohiro@jp.fujitsu.com" List-ID: On Tue, May 12, 2009 at 09:32:48PM +0800, Rik van Riel wrote: > Wu Fengguang wrote: > > On Tue, May 12, 2009 at 03:26:33PM +0800, Minchan Kim wrote: > >> On Tue, 12 May 2009 10:53:19 +0800 > >> Wu Fengguang wrote: > >> > >>> The "move pages to active list" and "move pages to inactive list" > >>> code blocks are mostly identical and can be served by a function. > >>> > >>> Thanks to Andrew Morton for pointing this out. > >>> > >>> Signed-off-by: Wu Fengguang > >>> --- > >>> mm/vmscan.c | 84 ++++++++++++++++++++------------------------------ > >>> 1 file changed, 35 insertions(+), 49 deletions(-) > >>> > >>> --- linux.orig/mm/vmscan.c > >>> +++ linux/mm/vmscan.c > >>> @@ -1225,6 +1225,36 @@ static inline void note_zone_scanning_pr > >>> * But we had to alter page->flags anyway. > >>> */ > >>> > >>> +void move_active_pages_to_lru(enum lru_list lru, struct list_head *list) > >>> +{ > >>> + unsigned long pgmoved = 0; > >>> + > >>> + while (!list_empty(&list)) { > >>> + page = lru_to_page(&list); > >>> + prefetchw_prev_lru_page(page, &list, flags); > >>> + > >>> + VM_BUG_ON(PageLRU(page)); > >>> + SetPageLRU(page); > >>> + > >>> + VM_BUG_ON(!PageActive(page)); > >>> + if (lru < LRU_ACTIVE) > >>> + ClearPageActive(page); > >> Arithmetic on the LRU list is not good code for redability, I think. > >> How about adding comment? > >> > >> if (lru < LRU_ACTIVE) /* In case of moving from active list to inactive */ > >> > >> Ignore me if you think this is trivial. > > > > Good suggestion. Or this simple one: "we are de-activating"? > > lru < LRU_ACTIVE will never be true for file pages, > either active or inactive. Thanks - that old patch version was really broken. -- 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: email@kvack.org