diff mbox series

[1/3] fs/userfaultfd.c: remove a redundant check on end

Message ID 20190912213110.3691-1-richardw.yang@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [1/3] fs/userfaultfd.c: remove a redundant check on end | expand

Commit Message

Wei Yang Sept. 12, 2019, 9:31 p.m. UTC
For the ending vma, there is a check to make sure the end is huge page
aligned.

The *if* check makes sure vm_start < end <= vm_end. While the first half
is not necessary, because the *for* clause makes sure vm_start < end.

This patch just removes it.

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

Comments

Wei Yang Oct. 12, 2019, 9:16 a.m. UTC | #1
Ping for comment :-)

On Fri, Sep 13, 2019 at 05:31:08AM +0800, Wei Yang wrote:
>For the ending vma, there is a check to make sure the end is huge page
>aligned.
>
>The *if* check makes sure vm_start < end <= vm_end. While the first half
>is not necessary, because the *for* clause makes sure vm_start < end.
>
>This patch just removes it.
>
>Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>---
> fs/userfaultfd.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
>diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
>index 653d8f7c453c..9ce09ac619a2 100644
>--- a/fs/userfaultfd.c
>+++ b/fs/userfaultfd.c
>@@ -1402,8 +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 &&
>-		    end > cur->vm_start) {
>+		if (is_vm_hugetlb_page(cur) && end <= cur->vm_end) {
> 			unsigned long vma_hpagesize = vma_kernel_pagesize(cur);
> 
> 			ret = -EINVAL;
>-- 
>2.17.1
Wei Yang Nov. 9, 2019, 1:29 a.m. UTC | #2
On Fri, Sep 13, 2019 at 05:31:08AM +0800, Wei Yang wrote:
>For the ending vma, there is a check to make sure the end is huge page
>aligned.
>
>The *if* check makes sure vm_start < end <= vm_end. While the first half
>is not necessary, because the *for* clause makes sure vm_start < end.
>
>This patch just removes it.
>

Does this one look good?

>Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>---
> fs/userfaultfd.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
>diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
>index 653d8f7c453c..9ce09ac619a2 100644
>--- a/fs/userfaultfd.c
>+++ b/fs/userfaultfd.c
>@@ -1402,8 +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 &&
>-		    end > cur->vm_start) {
>+		if (is_vm_hugetlb_page(cur) && end <= cur->vm_end) {
> 			unsigned long vma_hpagesize = vma_kernel_pagesize(cur);
> 
> 			ret = -EINVAL;
>-- 
>2.17.1
diff mbox series

Patch

diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 653d8f7c453c..9ce09ac619a2 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -1402,8 +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 &&
-		    end > cur->vm_start) {
+		if (is_vm_hugetlb_page(cur) && end <= cur->vm_end) {
 			unsigned long vma_hpagesize = vma_kernel_pagesize(cur);
 
 			ret = -EINVAL;