Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1266167 > unrolled thread

Re: [PATCH] mm/mmap.c: Remove redundant local variables for may_expand_vm()

Started byNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
First post2015-11-10 02:50 +0100
Last post2015-11-10 02:50 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] mm/mmap.c: Remove redundant local variables for  may_expand_vm() Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> - 2015-11-10 02:50 +0100

#1266167 — Re: [PATCH] mm/mmap.c: Remove redundant local variables for may_expand_vm()

FromNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Date2015-11-10 02:50 +0100
SubjectRe: [PATCH] mm/mmap.c: Remove redundant local variables for may_expand_vm()
Message-ID<qt6el-6Rb-1@gated-at.bofh.it>
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 <gang.chen.5i5j@gmail.com>
> 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 <gang.chen.5i5j@gmail.com>

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/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web