Skip to content

Commit

Permalink
mm/compaction: remove unnecessary cursor page in isolate_freepages_block
Browse files Browse the repository at this point in the history
The cursor is only used for page forward currently.  We can simply move
page forward directly to remove unnecessary cursor.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Kemeng Shi <[email protected]>
Reviewed-by: Baolin Wang <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Kemeng Shi <[email protected]>
Cc: Mel Gorman <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Kemeng Shi authored and akpm00 committed Aug 21, 2023
1 parent a2864a6 commit dc13292
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions mm/compaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
bool strict)
{
int nr_scanned = 0, total_isolated = 0;
struct page *cursor;
struct page *page;
unsigned long flags = 0;
bool locked = false;
unsigned long blockpfn = *start_pfn;
Expand All @@ -599,12 +599,11 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
if (strict)
stride = 1;

cursor = pfn_to_page(blockpfn);
page = pfn_to_page(blockpfn);

/* Isolate free pages. */
for (; blockpfn < end_pfn; blockpfn += stride, cursor += stride) {
for (; blockpfn < end_pfn; blockpfn += stride, page += stride) {
int isolated;
struct page *page = cursor;

/*
* Periodically drop the lock (if held) regardless of its
Expand All @@ -629,7 +628,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,

if (likely(order <= MAX_ORDER)) {
blockpfn += (1UL << order) - 1;
cursor += (1UL << order) - 1;
page += (1UL << order) - 1;
nr_scanned += (1UL << order) - 1;
}
goto isolate_fail;
Expand Down Expand Up @@ -666,7 +665,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
}
/* Advance to the end of split page */
blockpfn += isolated - 1;
cursor += isolated - 1;
page += isolated - 1;
continue;

isolate_fail:
Expand Down

0 comments on commit dc13292

Please sign in to comment.