linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.cz>
To: Piotr Kwapulinski <kwapulinski.piotr@gmail.com>
Cc: akpm@linux-foundation.org, kirill.shutemov@linux.intel.com,
	riel@redhat.com, sasha.levin@oracle.com, dave@stgolabs.net,
	koct9i@gmail.com, pfeiner@google.com, dh.herrmann@gmail.com,
	vishnu.ps@samsung.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/mmap.c: optimization of do_mmap_pgoff function
Date: Mon, 8 Jun 2015 10:17:51 +0200	[thread overview]
Message-ID: <20150608081751.GC1380@dhcp22.suse.cz> (raw)
In-Reply-To: <1433584472-19151-1-git-send-email-kwapulinski.piotr@gmail.com>

On Sat 06-06-15 11:54:32, Piotr Kwapulinski wrote:
> The simple check for zero length memory mapping may be performed
> earlier. It causes that in case of zero length memory mapping some
> unnecessary code is not executed at all. It does not make the code less
> readable and saves some CPU cycles.
> 
> Signed-off-by: Piotr Kwapulinski <kwapulinski.piotr@gmail.com>

Acked-by: Michal Hocko <mhocko@suse.cz>

> ---
>  mm/mmap.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/mmap.c b/mm/mmap.c
> index bb50cac..aa632ad 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -1258,6 +1258,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
>  
>  	*populate = 0;
>  
> +	if (!len)
> +		return -EINVAL;
> +
>  	/*
>  	 * Does the application expect PROT_READ to imply PROT_EXEC?
>  	 *
> @@ -1268,9 +1271,6 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
>  		if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
>  			prot |= PROT_EXEC;
>  
> -	if (!len)
> -		return -EINVAL;
> -
>  	if (!(flags & MAP_FIXED))
>  		addr = round_hint_to_min(addr);
>  
> -- 
> 2.3.7
> 

-- 
Michal Hocko
SUSE Labs

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2015-06-08  8:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-06  9:54 [PATCH] mm/mmap.c: optimization of do_mmap_pgoff function Piotr Kwapulinski
2015-06-08  8:17 ` Michal Hocko [this message]
2015-06-08 15:42 ` Rik van Riel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150608081751.GC1380@dhcp22.suse.cz \
    --to=mhocko@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=dave@stgolabs.net \
    --cc=dh.herrmann@gmail.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=koct9i@gmail.com \
    --cc=kwapulinski.piotr@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pfeiner@google.com \
    --cc=riel@redhat.com \
    --cc=sasha.levin@oracle.com \
    --cc=vishnu.ps@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).