Skip to content

Commit

Permalink
mm: vmscan: do not keep kswapd looping forever due to individual unco…
Browse files Browse the repository at this point in the history
…mpactable zones

When a zone meets its high watermark and is compactable in case of
higher order allocations, it contributes to the percentage of the node's
memory that is considered balanced.

This requirement, that a node be only partially balanced, came about
when kswapd was desparately trying to balance tiny zones when all bigger
zones in the node had plenty of free memory.  Arguably, the same should
apply to compaction: if a significant part of the node is balanced
enough to run compaction, do not get hung up on that tiny zone that
might never get in shape.

When the compaction logic in kswapd is reached, we know that at least
25% of the node's memory is balanced properly for compaction (see
zone_balanced and pgdat_balanced).  Remove the individual zone checks
that restart the kswapd cycle.

Otherwise, we may observe more endless looping in kswapd where the
compaction code loops back to reclaim because of a single zone and
reclaim does nothing because the node is considered balanced overall.

See for example

  https://bugzilla.redhat.com/show_bug.cgi?id=866988

Signed-off-by: Johannes Weiner <[email protected]>
Reported-and-tested-by: Thorsten Leemhuis <[email protected]>
Reported-by: Jiri Slaby <[email protected]>
Tested-by: John Ellson <[email protected]>
Tested-by: Zdenek Kabelac <[email protected]>
Tested-by: Bruno Wolff III <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
hnaz authored and torvalds committed Dec 6, 2012
1 parent 60177d3 commit c702418
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2823,22 +2823,6 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order,
if (!populated_zone(zone))
continue;

if (zone->all_unreclaimable &&
sc.priority != DEF_PRIORITY)
continue;

/* Would compaction fail due to lack of free memory? */
if (COMPACTION_BUILD &&
compaction_suitable(zone, order) == COMPACT_SKIPPED)
goto loop_again;

/* Confirm the zone is balanced for order-0 */
if (!zone_watermark_ok(zone, 0,
high_wmark_pages(zone), 0, 0)) {
order = sc.order = 0;
goto loop_again;
}

/* Check if the memory needs to be defragmented. */
if (zone_watermark_ok(zone, order,
low_wmark_pages(zone), *classzone_idx, 0))
Expand Down

0 comments on commit c702418

Please sign in to comment.