From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932122Ab1GJXIs (ORCPT ); Sun, 10 Jul 2011 19:08:48 -0400 Received: from mail-qy0-f181.google.com ([209.85.216.181]:54877 "EHLO mail-qy0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756802Ab1GJXIr convert rfc822-to-8bit (ORCPT ); Sun, 10 Jul 2011 19:08:47 -0400 MIME-Version: 1.0 In-Reply-To: <1310244907-10144-1-git-send-email-dmitry.fink@palm.com> References: <1310244149-9885-1-git-send-email-dmitry.fink@palm.com> <1310244907-10144-1-git-send-email-dmitry.fink@palm.com> Date: Mon, 11 Jul 2011 08:08:46 +0900 Message-ID: Subject: Re: [PATCH] mmap: Fix and tidy up overcommit page arithmetic From: Minchan Kim To: Dmitry Fink Cc: Hugh Dickins , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jul 10, 2011 at 5:55 AM, Dmitry Fink wrote: > - shmem pages are not immediately available, but they are not > potentially available either, even if we swap them out, they will > just relocate from memory into swap, total amount of immediate and > potentially available memory is not going to be affected, so we > shouldn't count them as potentially free in the first place. > > - nr_free_pages() is not an expensive operation anymore, there is > no need to split the decision making in two halves and repeat code. > > Signed-off-by: Dmitry Fink > Reviewed-by: Minchan Kim > Acked-by: Hugh Dickins > --- >  mm/mmap.c  |   33 ++++++++++++--------------------- >  mm/nommu.c |   33 ++++++++++++--------------------- >  2 files changed, 24 insertions(+), 42 deletions(-) > > diff --git a/mm/mmap.c b/mm/mmap.c > index d49736f..b6ed22e 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -122,9 +122,16 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin) >                return 0; > >        if (sysctl_overcommit_memory == OVERCOMMIT_GUESS) { > -               unsigned long n; > +               free = global_page_state(NR_FREE_PAGES); > +               free += global_page_state(NR_FILE_PAGES); > + > +               /* shmem pages shouldn't be counted as free in this Nitpick. You didn't correct comment style. It's not a linux kernel coding style. -- Kind regards, Minchan Kim 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 ESMTP id 5D93A6B004A for ; Sun, 10 Jul 2011 19:08:48 -0400 (EDT) Received: by qwa26 with SMTP id 26so2299279qwa.14 for ; Sun, 10 Jul 2011 16:08:46 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1310244907-10144-1-git-send-email-dmitry.fink@palm.com> References: <1310244149-9885-1-git-send-email-dmitry.fink@palm.com> <1310244907-10144-1-git-send-email-dmitry.fink@palm.com> Date: Mon, 11 Jul 2011 08:08:46 +0900 Message-ID: Subject: Re: [PATCH] mmap: Fix and tidy up overcommit page arithmetic From: Minchan Kim Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: Dmitry Fink Cc: Hugh Dickins , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" On Sun, Jul 10, 2011 at 5:55 AM, Dmitry Fink wrote: > - shmem pages are not immediately available, but they are not > potentially available either, even if we swap them out, they will > just relocate from memory into swap, total amount of immediate and > potentially available memory is not going to be affected, so we > shouldn't count them as potentially free in the first place. > > - nr_free_pages() is not an expensive operation anymore, there is > no need to split the decision making in two halves and repeat code. > > Signed-off-by: Dmitry Fink > Reviewed-by: Minchan Kim > Acked-by: Hugh Dickins > --- > =C2=A0mm/mmap.c =C2=A0| =C2=A0 33 ++++++++++++--------------------- > =C2=A0mm/nommu.c | =C2=A0 33 ++++++++++++--------------------- > =C2=A02 files changed, 24 insertions(+), 42 deletions(-) > > diff --git a/mm/mmap.c b/mm/mmap.c > index d49736f..b6ed22e 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -122,9 +122,16 @@ int __vm_enough_memory(struct mm_struct *mm, long pa= ges, int cap_sys_admin) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return 0; > > =C2=A0 =C2=A0 =C2=A0 =C2=A0if (sysctl_overcommit_memory =3D=3D OVERCOMMIT= _GUESS) { > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned long n; > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 free =3D global_page_s= tate(NR_FREE_PAGES); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 free +=3D global_page_= state(NR_FILE_PAGES); > + > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* shmem pages shouldn= 't be counted as free in this Nitpick. You didn't correct comment style. It's not a linux kernel coding style. --=20 Kind regards, Minchan Kim -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org