[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190708170631.2130-1-lpf.vector@gmail.com>
Date: Tue, 9 Jul 2019 01:06:31 +0800
From: Pengfei Li <lpf.vector@...il.com>
To: akpm@...ux-foundation.org
Cc: urezki@...il.com, rpenyaev@...e.de, peterz@...radead.org,
guro@...com, rick.p.edgecombe@...el.com, rppt@...ux.ibm.com,
aryabinin@...tuozzo.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, Pengfei Li <lpf.vector@...il.com>
Subject: [PATCH] mm/vmalloc.c: Remove always-true conditional in vmap_init_free_space
When unsigned long variables are subtracted from one another,
the result is always non-negative.
The vmap_area_list is sorted by address.
So the following two conditions are always true.
1) if (busy->va_start - vmap_start > 0)
2) if (vmap_end - vmap_start > 0)
Just remove them.
Signed-off-by: Pengfei Li <lpf.vector@...il.com>
---
mm/vmalloc.c | 32 +++++++++++++-------------------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 0f76cca32a1c..c7bdbdc18472 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1810,31 +1810,25 @@ static void vmap_init_free_space(void)
* |<--------------------------------->|
*/
list_for_each_entry(busy, &vmap_area_list, list) {
- if (busy->va_start - vmap_start > 0) {
- free = kmem_cache_zalloc(vmap_area_cachep, GFP_NOWAIT);
- if (!WARN_ON_ONCE(!free)) {
- free->va_start = vmap_start;
- free->va_end = busy->va_start;
-
- insert_vmap_area_augment(free, NULL,
- &free_vmap_area_root,
- &free_vmap_area_list);
- }
- }
-
- vmap_start = busy->va_end;
- }
-
- if (vmap_end - vmap_start > 0) {
free = kmem_cache_zalloc(vmap_area_cachep, GFP_NOWAIT);
if (!WARN_ON_ONCE(!free)) {
free->va_start = vmap_start;
- free->va_end = vmap_end;
+ free->va_end = busy->va_start;
insert_vmap_area_augment(free, NULL,
- &free_vmap_area_root,
- &free_vmap_area_list);
+ &free_vmap_area_root, &free_vmap_area_list);
}
+
+ vmap_start = busy->va_end;
+ }
+
+ free = kmem_cache_zalloc(vmap_area_cachep, GFP_NOWAIT);
+ if (!WARN_ON_ONCE(!free)) {
+ free->va_start = vmap_start;
+ free->va_end = vmap_end;
+
+ insert_vmap_area_augment(free, NULL,
+ &free_vmap_area_root, &free_vmap_area_list);
}
}
--
2.21.0
Powered by blists - more mailing lists