[PATCH 2/3] fs/userfaultfd.c: reorder the if check to reduce some computation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux