Skip to contentSkip to conversation

mm/vmalloc.c: improve performance for pcpu_get_vm_areas()

PATCH Superseded zijun_hu 1 participant 1 message Sep 21, 2016

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

zijun_hu

author
#0 lore raw

PATCH 4/5 mm/vmalloc.c: improve performance for pcpu_get_vm_areas()

From: zijun_hu <[email protected]>

improve performance for pcpu_get_vm_areas() in below aspects
- reduce the counter of vmap_areas overlay checkup loop to half
- find the previous or next one of a vamp_area by list_head but rbtree

---
 include/linux/list.h | 11 +++++++++++
 mm/internal.h        |  6 ++++++
 mm/memblock.c        | 10 ++--------
 mm/vmalloc.c         | 55 +++++++++++++++++++++++++++++++++-------------------
 4 files changed, 54 insertions(+), 28 deletions(-)
include/linux/list.h +11 -0
index 5183138..23c3081 100644
@@ -181,6 +181,17 @@ static inline int list_is_last(const struct list_head *list,
 }
 
 /**
+ * list_is_first - tests whether @list is the first entry in list @head
+ * @list: the entry to test
+ * @head: the head of the list
+ */
+static inline int list_is_first(const struct list_head *list,
+				const struct list_head *head)
+{
+	return list->prev == head;
+}
+
+/**
  * list_empty - tests whether a list is empty
  * @head: the list to test.
  */
mm/internal.h +6 -0
index 1501304..abbff7c 100644
@@ -71,6 +71,12 @@ static inline void set_page_refcounted(struct page *page)
 	set_page_count(page, 1);
 }
 
+/**
+ * check whether range [@s0, @e0) has intersection with [@s1, @e1)
+ */
+#define is_range_overlay(s0, e0, s1, e1) \
+	(((s1) >= (e0) || (s0) >= (e1)) ? false : true)
+
 extern unsigned long highest_memmap_pfn;
 
 /*
mm/memblock.c +2 -8
index 483197e..b4c7d7c 100644
@@ -85,20 +85,14 @@ static inline phys_addr_t memblock_cap_size(phys_addr_t base, phys_addr_t *size)
 /*
  * Address comparison utilities
  */
-static unsigned long __init_memblock memblock_addrs_overlap(phys_addr_t base1, phys_addr_t size1,
-				       phys_addr_t base2, phys_addr_t size2)
-{
-	return ((base1 < (base2 + size2)) && (base2 < (base1 + size1)));
-}
-
 bool __init_memblock memblock_overlaps_region(struct memblock_type *type,
 					phys_addr_t base, phys_addr_t size)
 {
 	unsigned long i;
 
 	for (i = 0; i < type->cnt; i++)
-		if (memblock_addrs_overlap(base, size, type->regions[i].base,
-					   type->regions[i].size))
+		if (is_range_overlay(base, base + size, type->regions[i].base,
+				type->regions[i].base + type->regions[i].size))
 			break;
 	return i < type->cnt;
 }
mm/vmalloc.c +35 -20

113 lines not on this page · raw message

Signature · 1 line
1.9.1