From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751798AbcFWImi (ORCPT ); Thu, 23 Jun 2016 04:42:38 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35455 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751756AbcFWImg (ORCPT ); Thu, 23 Jun 2016 04:42:36 -0400 Date: Thu, 23 Jun 2016 17:42:00 +0900 From: Sergey Senozhatsky To: Ganesh Mahendran Cc: David Rientjes , devel@driverdev.osuosl.org, gregkh@linuxfoundation.org, arve@android.com, riandrews@android.com, linux-kernel@vger.kernel.org, sergey.senozhatsky.work@gmail.com, sergey.senozhatsky@gmail.com Subject: Re: [PATCH 2/3] staging: lowmemorykiller: count anon pages only when we have swap devices Message-ID: <20160623084200.GA526@swordfish> References: <1466487018-5410-1-git-send-email-opensource.ganesh@gmail.com> <1466487018-5410-2-git-send-email-opensource.ganesh@gmail.com> <20160622032751.GB5683@leo-test> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160622032751.GB5683@leo-test> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (06/22/16 11:27), Ganesh Mahendran wrote: [..] > > > Signed-off-by: Ganesh Mahendran > > > --- > > > drivers/staging/android/lowmemorykiller.c | 12 ++++++++---- > > > 1 file changed, 8 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c > > > index 6da9260..1d8de47 100644 > > > --- a/drivers/staging/android/lowmemorykiller.c > > > +++ b/drivers/staging/android/lowmemorykiller.c > > > @@ -73,10 +73,14 @@ static unsigned long lowmem_deathpending_timeout; > > > static unsigned long lowmem_count(struct shrinker *s, > > > struct shrink_control *sc) > > > { > > > - return global_page_state(NR_ACTIVE_ANON) + > > > - global_page_state(NR_ACTIVE_FILE) + > > > - global_page_state(NR_INACTIVE_ANON) + > > > - global_page_state(NR_INACTIVE_FILE); > > > + unsigned long freeable = global_page_state(NR_ACTIVE_FILE) + > > > + global_page_state(NR_INACTIVE_FILE); > > > + > > > + if (get_nr_swap_pages() > 0) > > > + freeable += global_page_state(NR_ACTIVE_ANON) + > > > + global_page_state(NR_INACTIVE_ANON); > > > + > > > + return freeable; > > > } > > > > > > static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc) > > > > Shouldn't this be advertising the amount of memory that is freeable by > > killing the process with the highest priority oom_score_adj? It's not > > legitimate to say it can free all anon and file memory if nothing is oom > > killable, so this function is wrong both originally and with your patched > > version. > > Yes, so should we just simply return 1 to make do_shrink_slab() go ahead? > Then lowmem_scan() will do the real job to scan all the process. hm, looking at ->scan (lowmem_scan) shouldn't it return SHRINK_STOP when it has nothing to free instead of 0? -ss