linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <richardw.yang@linux.intel.com>
To: viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Wei Yang <richardw.yang@linux.intel.com>
Subject: [PATCH 2/3] fs/userfaultfd.c: reorder the if check to reduce some computation
Date: Fri, 13 Sep 2019 05:31:09 +0800	[thread overview]
Message-ID: <20190912213110.3691-2-richardw.yang@linux.intel.com> (raw)
In-Reply-To: <20190912213110.3691-1-richardw.yang@linux.intel.com>

When there are several condition check in *if* clause, the check will
stop at the first false one.

Since the for loop iterates vma list, we are sure only the last vma
meets the condition "end <= vm_end". Reorder the check sequence to
reduce some computation.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 fs/userfaultfd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 9ce09ac619a2..70c0e0ef01d7 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -1402,7 +1402,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
 		 * If this vma contains ending address, and huge pages
 		 * check alignment.
 		 */
-		if (is_vm_hugetlb_page(cur) && end <= cur->vm_end) {
+		if (end <= cur->vm_end && is_vm_hugetlb_page(cur)) {
 			unsigned long vma_hpagesize = vma_kernel_pagesize(cur);
 
 			ret = -EINVAL;
-- 
2.17.1


  reply	other threads:[~2019-09-12 21:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-12 21:31 [PATCH 1/3] fs/userfaultfd.c: remove a redundant check on end Wei Yang
2019-09-12 21:31 ` Wei Yang [this message]
2019-09-12 21:31 ` [PATCH 3/3] fs/userfaultfd.c: wrap cheching huge page alignment into a helper Wei Yang
2019-10-12  9:16 ` [PATCH 1/3] fs/userfaultfd.c: remove a redundant check on end Wei Yang
2019-11-09  1:29 ` Wei Yang

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=20190912213110.3691-2-richardw.yang@linux.intel.com \
    --to=richardw.yang@linux.intel.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).