Skip to contentSkip to conversation

kswapd skips compaction if reclaim order drops to zero?

PATCH In review Hillf Danton 4 participants 9 messages Aug 15, 2013 – Aug 16, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

If the allocation order is not high, direct compaction does nothing. Can we skip compaction here if order drops to zero?

mm/vmscan.c Thu Aug 15 17:48:58 2013 renamed from mm/vmscan.c Thu Aug 15 17:47:26 2013 +1 -1
@@ -3034,7 +3034,7 @@ static unsigned long balance_pgdat(pg_da
  * Compact if necessary and kswapd is reclaiming at least the
  * high watermark number of pages as requsted
  */
- if (pgdat_needs_compaction && sc.nr_reclaimed > nr_attempted)
+ if (pgdat_needs_compaction && sc.nr_reclaimed > nr_attempted && order)
  compact_pgdat(pgdat, order);
 
  /*

--

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 3 lines · Hillf Danton

If the allocation order is not high, direct compaction does nothing. Can we skip compaction here if order drops to zero?

If the allocation order is not high then

pgdat_needs_compaction == (order > 0) == false == no calling compact_pdatt

In the case where order is reset to 0 due to fragmentation then it does call compact_pgdat but it does no work due to the cc->order check in __compact_pgdat.

Signature · 8 lines
Mel Gorman
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw

Hey Mel,

Quoted 5 lines · Mel Gorman
Quoted 3 lines · Hillf Danton

If the allocation order is not high, direct compaction does nothing. Can we skip compaction here if order drops to zero?

Quoted 8 lines

If the allocation order is not high then

pgdat_needs_compaction == (order > 0) == false == no calling compact_pdatt

In the case where order is reset to 0 due to fragmentation then it does call compact_pgdat but it does no work due to the cc->order check in __compact_pgdat.

I am looking at mmotm-2013-08-07-16-55 but couldn't find cc->order check right before compact_zone in __comact_pgdat. Could you pinpoint code piece?

Quoted 9 lines
Signature · 8 lines
Mel Gorman
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 8 lines
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw
Quoted 12 lines · Minchan Kim

Hey Mel,

Quoted 9 lines · Mel Gorman
Quoted 3 lines · Hillf Danton

If the allocation order is not high, direct compaction does nothing. Can we skip compaction here if order drops to zero?

If the allocation order is not high then

pgdat_needs_compaction == (order > 0) == false == no calling compact_pdatt

Quoted 9 lines
Quoted 4 lines

In the case where order is reset to 0 due to fragmentation then it does call compact_pgdat but it does no work due to the cc->order check in __compact_pgdat.

I am looking at mmotm-2013-08-07-16-55 but couldn't find cc->order check right before compact_zone in __comact_pgdat. Could you pinpoint code piece?

Thanks, I screwed up as that check happens too late. However, it still ends up not mattering because it does this

compact_pgdat
-> __compact_pgdat

    -> compact_zone
      -> compaction_suitable

For order == 0, compaction_suitable will return either COMPACT_SKIPPED (if the watermarks are not met) and COMPACT_PARTIAL otherwise. Either way, compaction doesn't run.

Signature · 8 lines
Mel Gorman
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#4 lore raw
Quoted 26 lines · Mel Gorman
Quoted 12 lines · Minchan Kim

Hey Mel,

Quoted 9 lines · Mel Gorman
Quoted 3 lines · Hillf Danton

If the allocation order is not high, direct compaction does nothing. Can we skip compaction here if order drops to zero?

If the allocation order is not high then

pgdat_needs_compaction == (order > 0) == false == no calling compact_pdatt

Quoted 9 lines
Quoted 4 lines

In the case where order is reset to 0 due to fragmentation then it does call compact_pgdat but it does no work due to the cc->order check in __compact_pgdat.

I am looking at mmotm-2013-08-07-16-55 but couldn't find cc->order check right before compact_zone in __comact_pgdat. Could you pinpoint code piece?

Thanks, I screwed up as that check happens too late. However, it still ends up not mattering because it does this

Quoted 8 lines

compact_pgdat
-> __compact_pgdat

    -> compact_zone
      -> compaction_suitable

For order == 0, compaction_suitable will return either COMPACT_SKIPPED (if the watermarks are not met) and COMPACT_PARTIAL otherwise. Either way, compaction doesn't run.

In compaction_suitable, it could pass first zone_watermark_ok but failed second zone_watermark_ok while fragindex is -1000 so compaction could run.

And we shouldn't depend on such coincidence.

Quoted 10 lines
Signature · 9 lines
-- 
Mel Gorman
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 8 lines
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#5 lore raw

PATCH 1/1 mm: compaction: Do not compact pgdat for order-0

If kswapd was reclaiming for a high order and resets it to 0 due to fragmentation it will still call compact_pgdat. For the most part, this will fail a compaction_suitable() test and not compact but it is unnecessarily sloppy. It could be fixed in the caller but fix it in the API instead.

[[email protected]: Pointed out that it was a potential problem]
---
 mm/compaction.c | 3 +++
 1 file changed, 3 insertions(+)
mm/compaction.c +3 -0
index 05ccb4c..c437893 100644
@@ -1131,6 +1131,9 @@ void compact_pgdat(pg_data_t *pgdat, int order)
 		.sync = false,
 	};
 
+	if (!order)
+		return;
+
 	__compact_pgdat(pgdat, &cc);
 }
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Acked-by on v1 1/1
#6 lore raw

Re: [PATCH] mm: compaction: Do not compact pgdat for order-0

Quoted 7 lines · Mel Gorman

If kswapd was reclaiming for a high order and resets it to 0 due to fragmentation it will still call compact_pgdat. For the most part, this will fail a compaction_suitable() test and not compact but it is unnecessarily sloppy. It could be fixed in the caller but fix it in the API instead.

[[email protected]: Pointed out that it was a potential problem]
Signature · 8 lines
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#7 lore raw
In reply to Minchan Kim

Hi Minchan,

Quoted 32 lines · Minchan Kim
Quoted 31 lines · Mel Gorman
Quoted 12 lines · Minchan Kim

Hey Mel,

Quoted 9 lines · Mel Gorman
Quoted 3 lines · Hillf Danton

If the allocation order is not high, direct compaction does nothing. Can we skip compaction here if order drops to zero?

If the allocation order is not high then

pgdat_needs_compaction == (order > 0) == false == no calling compact_pdatt

Quoted 9 lines
Quoted 4 lines

In the case where order is reset to 0 due to fragmentation then it does call compact_pgdat but it does no work due to the cc->order check in __compact_pgdat.

I am looking at mmotm-2013-08-07-16-55 but couldn't find cc->order check right before compact_zone in __comact_pgdat. Could you pinpoint code piece?

Thanks, I screwed up as that check happens too late. However, it still ends up not mattering because it does this

compact_pgdat
-> __compact_pgdat

    -> compact_zone
      -> compaction_suitable
Quoted 8 lines
Quoted 3 lines

For order == 0, compaction_suitable will return either COMPACT_SKIPPED (if the watermarks are not met) and COMPACT_PARTIAL otherwise. Either way, compaction doesn't run.

In compaction_suitable, it could pass first zone_watermark_ok but failed second zone_watermark_ok while fragindex is -1000 so compaction could run.

I'm not sure why you said that second zone_watermark_ok failed while fragindex is -1000, actually they are the same check against order 0.

First:
watermark = low_wmark_pages(zone) + (2UL << order); zone_watermark_ok(zone, 0, watermark, 0, 0);

Second:
fragindex == -1000 && zone_watermark_ok(zone, order, watermark, 0, 0)

Both COMPACT_SKIPPED and COMPACT_PARTIAL will fail compaction.

Regards,
Wanpeng Li

Quoted 8 lines

And we shouldn't depend on such coincidence.

Quoted 5 lines
Signature · 3 lines
-- 
Mel Gorman
SUSE Labs
Quoted 15 lines
Quoted 5 lines

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Signature · 8 lines
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw
In reply to Minchan Kim

Hi Minchan,

Quoted 32 lines · Minchan Kim
Quoted 31 lines · Mel Gorman
Quoted 12 lines · Minchan Kim

Hey Mel,

Quoted 9 lines · Mel Gorman
Quoted 3 lines · Hillf Danton

If the allocation order is not high, direct compaction does nothing. Can we skip compaction here if order drops to zero?

If the allocation order is not high then

pgdat_needs_compaction == (order > 0) == false == no calling compact_pdatt

Quoted 9 lines
Quoted 4 lines

In the case where order is reset to 0 due to fragmentation then it does call compact_pgdat but it does no work due to the cc->order check in __compact_pgdat.

I am looking at mmotm-2013-08-07-16-55 but couldn't find cc->order check right before compact_zone in __comact_pgdat. Could you pinpoint code piece?

Thanks, I screwed up as that check happens too late. However, it still ends up not mattering because it does this

compact_pgdat
-> __compact_pgdat

    -> compact_zone
      -> compaction_suitable
Quoted 8 lines
Quoted 3 lines

For order == 0, compaction_suitable will return either COMPACT_SKIPPED (if the watermarks are not met) and COMPACT_PARTIAL otherwise. Either way, compaction doesn't run.

In compaction_suitable, it could pass first zone_watermark_ok but failed second zone_watermark_ok while fragindex is -1000 so compaction could run.

I'm not sure why you said that second zone_watermark_ok failed while fragindex is -1000, actually they are the same check against order 0.

First:
watermark = low_wmark_pages(zone) + (2UL << order); zone_watermark_ok(zone, 0, watermark, 0, 0);

Second:
fragindex == -1000 && zone_watermark_ok(zone, order, watermark, 0, 0)

Both COMPACT_SKIPPED and COMPACT_PARTIAL will fail compaction.

Regards,
Wanpeng Li

Quoted 8 lines

And we shouldn't depend on such coincidence.

Quoted 5 lines
Signature · 3 lines
-- 
Mel Gorman
SUSE Labs
Quoted 15 lines
Quoted 5 lines

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Signature · 8 lines
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>