diff options
author | Andrea Arcangeli <aarcange@redhat.com> | 2011-01-13 18:47:11 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-13 20:32:46 -0500 |
commit | 5a03b051ed87e72b959f32a86054e1142ac4cf55 (patch) | |
tree | 31f0e8efb86d48b0292f8a7ea4bd9cf7c930a0ab /mm/compaction.c | |
parent | 878aee7d6b5504e01b9caffce080e792b6b8d090 (diff) |
thp: use compaction in kswapd for GFP_ATOMIC order > 0
This takes advantage of memory compaction to properly generate pages of
order > 0 if regular page reclaim fails and priority level becomes more
severe and we don't reach the proper watermarks.
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/compaction.c')
-rw-r--r-- | mm/compaction.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/mm/compaction.c b/mm/compaction.c index da25b5a2e476..60d52a7298d5 100644 --- a/mm/compaction.c +++ b/mm/compaction.c | |||
@@ -42,6 +42,8 @@ struct compact_control { | |||
42 | unsigned int order; /* order a direct compactor needs */ | 42 | unsigned int order; /* order a direct compactor needs */ |
43 | int migratetype; /* MOVABLE, RECLAIMABLE etc */ | 43 | int migratetype; /* MOVABLE, RECLAIMABLE etc */ |
44 | struct zone *zone; | 44 | struct zone *zone; |
45 | |||
46 | int compact_mode; | ||
45 | }; | 47 | }; |
46 | 48 | ||
47 | static unsigned long release_freepages(struct list_head *freelist) | 49 | static unsigned long release_freepages(struct list_head *freelist) |
@@ -382,10 +384,10 @@ static void update_nr_listpages(struct compact_control *cc) | |||
382 | } | 384 | } |
383 | 385 | ||
384 | static int compact_finished(struct zone *zone, | 386 | static int compact_finished(struct zone *zone, |
385 | struct compact_control *cc) | 387 | struct compact_control *cc) |
386 | { | 388 | { |
387 | unsigned int order; | 389 | unsigned int order; |
388 | unsigned long watermark = low_wmark_pages(zone) + (1 << cc->order); | 390 | unsigned long watermark; |
389 | 391 | ||
390 | if (fatal_signal_pending(current)) | 392 | if (fatal_signal_pending(current)) |
391 | return COMPACT_PARTIAL; | 393 | return COMPACT_PARTIAL; |
@@ -395,12 +397,27 @@ static int compact_finished(struct zone *zone, | |||
395 | return COMPACT_COMPLETE; | 397 | return COMPACT_COMPLETE; |
396 | 398 | ||
397 | /* Compaction run is not finished if the watermark is not met */ | 399 | /* Compaction run is not finished if the watermark is not met */ |
400 | if (cc->compact_mode != COMPACT_MODE_KSWAPD) | ||
401 | watermark = low_wmark_pages(zone); | ||
402 | else | ||
403 | watermark = high_wmark_pages(zone); | ||
404 | watermark += (1 << cc->order); | ||
405 | |||
398 | if (!zone_watermark_ok(zone, cc->order, watermark, 0, 0)) | 406 | if (!zone_watermark_ok(zone, cc->order, watermark, 0, 0)) |
399 | return COMPACT_CONTINUE; | 407 | return COMPACT_CONTINUE; |
400 | 408 | ||
401 | if (cc->order == -1) | 409 | if (cc->order == -1) |
402 | return COMPACT_CONTINUE; | 410 | return COMPACT_CONTINUE; |
403 | 411 | ||
412 | /* | ||
413 | * Generating only one page of the right order is not enough | ||
414 | * for kswapd, we must continue until we're above the high | ||
415 | * watermark as a pool for high order GFP_ATOMIC allocations | ||
416 | * too. | ||
417 | */ | ||
418 | if (cc->compact_mode == COMPACT_MODE_KSWAPD) | ||
419 | return COMPACT_CONTINUE; | ||
420 | |||
404 | /* Direct compactor: Is a suitable page free? */ | 421 | /* Direct compactor: Is a suitable page free? */ |
405 | for (order = cc->order; order < MAX_ORDER; order++) { | 422 | for (order = cc->order; order < MAX_ORDER; order++) { |
406 | /* Job done if page is free of the right migratetype */ | 423 | /* Job done if page is free of the right migratetype */ |
@@ -514,8 +531,9 @@ static int compact_zone(struct zone *zone, struct compact_control *cc) | |||
514 | } | 531 | } |
515 | 532 | ||
516 | unsigned long compact_zone_order(struct zone *zone, | 533 | unsigned long compact_zone_order(struct zone *zone, |
517 | int order, gfp_t gfp_mask, | 534 | int order, gfp_t gfp_mask, |
518 | bool sync) | 535 | bool sync, |
536 | int compact_mode) | ||
519 | { | 537 | { |
520 | struct compact_control cc = { | 538 | struct compact_control cc = { |
521 | .nr_freepages = 0, | 539 | .nr_freepages = 0, |
@@ -524,6 +542,7 @@ unsigned long compact_zone_order(struct zone *zone, | |||
524 | .migratetype = allocflags_to_migratetype(gfp_mask), | 542 | .migratetype = allocflags_to_migratetype(gfp_mask), |
525 | .zone = zone, | 543 | .zone = zone, |
526 | .sync = sync, | 544 | .sync = sync, |
545 | .compact_mode = compact_mode, | ||
527 | }; | 546 | }; |
528 | INIT_LIST_HEAD(&cc.freepages); | 547 | INIT_LIST_HEAD(&cc.freepages); |
529 | INIT_LIST_HEAD(&cc.migratepages); | 548 | INIT_LIST_HEAD(&cc.migratepages); |
@@ -569,7 +588,8 @@ unsigned long try_to_compact_pages(struct zonelist *zonelist, | |||
569 | nodemask) { | 588 | nodemask) { |
570 | int status; | 589 | int status; |
571 | 590 | ||
572 | status = compact_zone_order(zone, order, gfp_mask, sync); | 591 | status = compact_zone_order(zone, order, gfp_mask, sync, |
592 | COMPACT_MODE_DIRECT_RECLAIM); | ||
573 | rc = max(status, rc); | 593 | rc = max(status, rc); |
574 | 594 | ||
575 | /* If a normal allocation would succeed, stop compacting */ | 595 | /* If a normal allocation would succeed, stop compacting */ |
@@ -600,6 +620,7 @@ static int compact_node(int nid) | |||
600 | .nr_freepages = 0, | 620 | .nr_freepages = 0, |
601 | .nr_migratepages = 0, | 621 | .nr_migratepages = 0, |
602 | .order = -1, | 622 | .order = -1, |
623 | .compact_mode = COMPACT_MODE_DIRECT_RECLAIM, | ||
603 | }; | 624 | }; |
604 | 625 | ||
605 | zone = &pgdat->node_zones[zoneid]; | 626 | zone = &pgdat->node_zones[zoneid]; |