[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190912213110.3691-2-richardw.yang@linux.intel.com>
Date: Fri, 13 Sep 2019 05:31:09 +0800
From: Wei Yang <richardw.yang@...ux.intel.com>
To: viro@...iv.linux.org.uk
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
Wei Yang <richardw.yang@...ux.intel.com>
Subject: [PATCH 2/3] fs/userfaultfd.c: reorder the if check to reduce some computation
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@...ux.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
Powered by blists - more mailing lists