Messages in this thread Patch in this message | | | From | Wei Yang <> | Subject | [PATCH 2/3] fs/userfaultfd.c: reorder the if check to reduce some computation | Date | Fri, 13 Sep 2019 05:31:09 +0800 |
| |
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
| |