Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752574AbbKJBkv (ORCPT ); Mon, 9 Nov 2015 20:40:51 -0500 Received: from TYO202.gate.nec.co.jp ([210.143.35.52]:63405 "EHLO tyo202.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752233AbbKJBku convert rfc822-to-8bit (ORCPT ); Mon, 9 Nov 2015 20:40:50 -0500 From: Naoya Horiguchi To: Chen Gang CC: Andrew Morton , "oleg@redhat.com" , "kirill.shutemov@linux.intel.com" , "dave@stgolabs.net" , "aarcange@redhat.com" , Linux Memory , kernel mailing list Subject: Re: [PATCH] mm/mmap.c: Remove redundant local variables for may_expand_vm() Thread-Topic: [PATCH] mm/mmap.c: Remove redundant local variables for may_expand_vm() Thread-Index: AQHRG1itU05GQO51/0WJCGbVD5Fjnw== Date: Tue, 10 Nov 2015 01:39:46 +0000 Message-ID: <20151110013945.GA24497@hori1.linux.bs1.fc.nec.co.jp> References: In-Reply-To: Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.128.101.3] Content-Type: text/plain; charset="iso-2022-jp" Content-ID: Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1684 Lines: 56 On Tue, Nov 10, 2015 at 05:41:08AM +0800, Chen Gang wrote: > From 7050c267d8dda220226067039d815593d2f9a874 Mon Sep 17 00:00:00 2001 > From: Chen Gang > Date: Tue, 10 Nov 2015 05:32:38 +0800 > Subject: [PATCH] mm/mmap.c: Remove redundant local variables for may_expand_vm() > > After merge the related code into one line, the code is still simple and > meaningful enough. > > Signed-off-by: Chen Gang I agree that this function can be cleaned up. > --- > mm/mmap.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/mm/mmap.c b/mm/mmap.c > index 2ce04a6..a515260 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -2988,12 +2988,7 @@ out: > */ > int may_expand_vm(struct mm_struct *mm, unsigned long npages) marking inline? > { > - unsigned long cur = mm->total_vm; /* pages */ > - unsigned long lim; > - > - lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT; > - > - if (cur + npages > lim) > + if (mm->total_vm + npages > (rlimit(RLIMIT_AS) >> PAGE_SHIFT)) > return 0; > return 1; How about doing simply return mm->total_vm + npages <= (rlimit(RLIMIT_AS) >> PAGE_SHIFT); ? These changes save some bytes :) text data bss dec hex filename 20566 2250 40 22856 5948 mm/mmap.o (before) text data bss dec hex filename 20542 2250 40 22832 5930 mm/mmap.o (after) Thanks, Naoya Horiguchi-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/