diff mbox series

[2/5] mm/vmalloc: remove the redundant boundary check

Message ID 20220606083909.363350-3-bhe@redhat.com (mailing list archive)
State New
Headers show
Series Cleanup patches of vmalloc | expand

Commit Message

Baoquan He June 6, 2022, 8:39 a.m. UTC
In function find_va_links(), when traversing the vmap_area tree, the
comparing to check if the passed in 'va' is above or below 'tmp_va'
is redundant, assuming both 'va' and 'tmp_va' has ->va_start <= ->va_end.

Here, to simplify the checking as code change.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
 mm/vmalloc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Uladzislau Rezki June 6, 2022, 8:46 p.m. UTC | #1
On Mon, Jun 06, 2022 at 04:39:06PM +0800, Baoquan He wrote:
> In function find_va_links(), when traversing the vmap_area tree, the
> comparing to check if the passed in 'va' is above or below 'tmp_va'
> is redundant, assuming both 'va' and 'tmp_va' has ->va_start <= ->va_end.
> 
> Here, to simplify the checking as code change.
> 
> Signed-off-by: Baoquan He <bhe@redhat.com>
> ---
>  mm/vmalloc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index b7a138ab7b79..c7e1634ff2b9 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -874,11 +874,9 @@ find_va_links(struct vmap_area *va,
>  		 * Trigger the BUG() if there are sides(left/right)
>  		 * or full overlaps.
>  		 */
> -		if (va->va_start < tmp_va->va_end &&
> -				va->va_end <= tmp_va->va_start)
> +		if (va->va_end <= tmp_va->va_start)
>  			link = &(*link)->rb_left;
> -		else if (va->va_end > tmp_va->va_start &&
> -				va->va_start >= tmp_va->va_end)
> +		else if (va->va_start >= tmp_va->va_end)
>  			link = &(*link)->rb_right;
>  		else {
>  			WARN(1, "vmalloc bug: 0x%lx-0x%lx overlaps with 0x%lx-0x%lx\n",
> -- 
> 2.34.1
> 
Make sense to me: Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

--
Uladzislau Rezki
diff mbox series

Patch

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index b7a138ab7b79..c7e1634ff2b9 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -874,11 +874,9 @@  find_va_links(struct vmap_area *va,
 		 * Trigger the BUG() if there are sides(left/right)
 		 * or full overlaps.
 		 */
-		if (va->va_start < tmp_va->va_end &&
-				va->va_end <= tmp_va->va_start)
+		if (va->va_end <= tmp_va->va_start)
 			link = &(*link)->rb_left;
-		else if (va->va_end > tmp_va->va_start &&
-				va->va_start >= tmp_va->va_end)
+		else if (va->va_start >= tmp_va->va_end)
 			link = &(*link)->rb_right;
 		else {
 			WARN(1, "vmalloc bug: 0x%lx-0x%lx overlaps with 0x%lx-0x%lx\n",