BACKPORT: mm: page_alloc: optimize free_unref_folios()
Move direct freeing of isolated pages to the lock-breaking block in the second loop. This saves an unnecessary migratetype reassessment. Minor comment and local variable scoping cleanups. Link: https://lkml.kernel.org/r/20240320180429.678181-3-hannes@cmpxchg.org Change-Id: I9a9dedfa7f0a0a9f18e8da11b5b6b6940fbf0fb2 Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Suggested-by: Vlastimil Babka <vbabka@suse.cz> Tested-by: "Huang, Ying" <ying.huang@intel.com> Reviewed-by: Vlastimil Babka <vbabka@suse.cz> Tested-by: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: David Hildenbrand <david@redhat.com> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Zi Yan <ziy@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit 9cbe97bad5cd75b5b493734bd2695febb8e95281) Bug: 420700629 [ Remove duplicated code for freeing migratetype_isolate; Drop !pcp_allowes_order() block, order is always 0 - Kalesh Singh ] Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
This commit is contained in:
committed by
Kalesh Singh
parent
9f62a273a8
commit
ab0ad8d198
@@ -2802,22 +2802,10 @@ void free_unref_page_list(struct list_head *list)
|
||||
|
||||
/* Prepare pages for freeing */
|
||||
list_for_each_entry_safe(page, next, list, lru) {
|
||||
unsigned long pfn = page_to_pfn(page);
|
||||
if (!free_pages_prepare(page, 0, FPI_NONE)) {
|
||||
list_del(&page->lru);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free isolated pages directly to the allocator, see
|
||||
* comment in free_unref_page.
|
||||
*/
|
||||
migratetype = get_pfnblock_migratetype(page, pfn);
|
||||
if (unlikely(is_migrate_isolate(migratetype))) {
|
||||
list_del(&page->lru);
|
||||
free_one_page(page_zone(page), page, pfn, 0, FPI_NONE);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
trace_android_vh_free_unref_page_list_bypass(list, &skip_free);
|
||||
@@ -2836,10 +2824,13 @@ void free_unref_page_list(struct list_head *list)
|
||||
* excessive lock hold times when freeing a large list of
|
||||
* pages.
|
||||
*/
|
||||
if (zone != locked_zone || batch_count == SWAP_CLUSTER_MAX) {
|
||||
if (zone != locked_zone || batch_count == SWAP_CLUSTER_MAX ||
|
||||
is_migrate_isolate(migratetype)) {
|
||||
if (pcp) {
|
||||
pcp_spin_unlock(pcp);
|
||||
pcp_trylock_finish(UP_flags);
|
||||
locked_zone = NULL;
|
||||
pcp = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user