OSDN Git Service

mm/hugetlb: use list_splice to merge two list at once
authorWei Yang <richard.weiyang@linux.alibaba.com>
Tue, 13 Oct 2020 23:56:27 +0000 (16:56 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 14 Oct 2020 01:38:34 +0000 (18:38 -0700)
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 <richard.weiyang@linux.alibaba.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Baoquan He <bhe@redhat.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Link: https://lkml.kernel.org/r/20200831022351.20916-4-richard.weiyang@linux.alibaba.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/hugetlb.c

index 39f86bb..13dc0a4 100644 (file)
@@ -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;