The patch titled Subject: mm/vmalloc.c: halve the number of comparisons performed in pcpu_get_vm_areas() has been added to the -mm tree. Its filename is mm-vmalloc-reduce-half-comparison-during-pcpu_get_vm_areas.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-vmalloc-reduce-half-comparison-during-pcpu_get_vm_areas.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-vmalloc-reduce-half-comparison-during-pcpu_get_vm_areas.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Wei Yang <richard.weiyang@xxxxxxxxx> Subject: mm/vmalloc.c: halve the number of comparisons performed in pcpu_get_vm_areas() In pcpu_get_vm_areas(), it checks each range is not overlapped. To make sure it is, only (N^2)/2 comparison is necessary, while current code does N^2 times. By starting from the next range, it achieves the goal and the continue could be removed. Also, - the overlap check of two ranges could be done with one clause - one typo in comment is fixed. Link: http://lkml.kernel.org/r/20170803063822.48702-1-richard.weiyang@xxxxxxxxx Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Tejun Heo <tj@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/vmalloc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff -puN mm/vmalloc.c~mm-vmalloc-reduce-half-comparison-during-pcpu_get_vm_areas mm/vmalloc.c --- a/mm/vmalloc.c~mm-vmalloc-reduce-half-comparison-during-pcpu_get_vm_areas +++ a/mm/vmalloc.c @@ -2479,7 +2479,7 @@ static unsigned long pvm_determine_end(s * matching slot. While scanning, if any of the areas overlaps with * existing vmap_area, the base address is pulled down to fit the * area. Scanning is repeated till all the areas fit and then all - * necessary data structres are inserted and the result is returned. + * necessary data structures are inserted and the result is returned. */ struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets, const size_t *sizes, int nr_vms, @@ -2507,15 +2507,11 @@ struct vm_struct **pcpu_get_vm_areas(con if (start > offsets[last_area]) last_area = area; - for (area2 = 0; area2 < nr_vms; area2++) { + for (area2 = area + 1; area2 < nr_vms; area2++) { unsigned long start2 = offsets[area2]; unsigned long end2 = start2 + sizes[area2]; - if (area2 == area) - continue; - - BUG_ON(start2 >= start && start2 < end); - BUG_ON(end2 <= end && end2 > start); + BUG_ON(start2 < end && start < end2); } } last_end = offsets[last_area] + sizes[last_area]; _ Patches currently in -mm which might be from richard.weiyang@xxxxxxxxx are mm-memory_hotplug-just-build-zonelist-for-new-added-node.patch mm-vmalloc-reduce-half-comparison-during-pcpu_get_vm_areas.patch mm-page_alloc-return-0-in-case-this-node-has-no-page-within-the-zone.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html