From: Wei Yang Date: Tue, 13 Oct 2020 23:56:27 +0000 (-0700) Subject: mm/hugetlb: use list_splice to merge two list at once X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d3ec7b6e09e512ba902b86bcca2c512fb06d492f;p=uclinux-h8%2Flinux.git mm/hugetlb: use list_splice to merge two list at once Instead of add allocated file_region one by one to region_cache, we could use list_splice to merge two list at once. Also we know the number of entries in the list, increase the number directly. Signed-off-by: Wei Yang Signed-off-by: Andrew Morton Reviewed-by: Baoquan He Reviewed-by: Mike Kravetz Cc: Vlastimil Babka Link: https://lkml.kernel.org/r/20200831022351.20916-4-richard.weiyang@linux.alibaba.com Signed-off-by: Linus Torvalds --- diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 39f86bbcb07e..13dc0a455400 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -443,11 +443,8 @@ static int allocate_file_region_entries(struct resv_map *resv, spin_lock(&resv->lock); - list_for_each_entry_safe(rg, trg, &allocated_regions, link) { - list_del(&rg->link); - list_add(&rg->link, &resv->region_cache); - resv->region_cache_count++; - } + list_splice(&allocated_regions, &resv->region_cache); + resv->region_cache_count += to_allocate; } return 0;