lkml.org 
[lkml]   [2019]   [Sep]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/3] fs/userfaultfd.c: reorder the if check to reduce some computation
Date
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
\
 
 \ /
  Last update: 2019-09-12 23:39    [W:0.094 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site