mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 20:54:03 +02:00
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 <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>
This commit is contained in:
parent
a1ddc2e825
commit
d3ec7b6e09
|
|
@ -443,11 +443,8 @@ static int allocate_file_region_entries(struct resv_map *resv,
|
||||||
|
|
||||||
spin_lock(&resv->lock);
|
spin_lock(&resv->lock);
|
||||||
|
|
||||||
list_for_each_entry_safe(rg, trg, &allocated_regions, link) {
|
list_splice(&allocated_regions, &resv->region_cache);
|
||||||
list_del(&rg->link);
|
resv->region_cache_count += to_allocate;
|
||||||
list_add(&rg->link, &resv->region_cache);
|
|
||||||
resv->region_cache_count++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user