mm: compaction: fix the page state calculation in too_many_isolated
Subsystems (2)
PATCH 1/1 mm: compaction: fix the page state calculation in too_many_isolated
Commit "3611badc1baa" (mm: vmscan: fix the page state calculation in too_many_isolated) fixed an issue where a number of tasks were blocked in reclaim path for seconds, because of vmstat_diff not being synced in time. A similar problem can happen in isolate_migratepages_block, similar calculation is performed. This patch fixes that.
--- mm/compaction.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-)
mm/compaction.c +27 -5
@@ -537,21 +537,43 @@ static void acct_isolated(struct zone *zone, struct compact_control *cc)mod_zone_page_state (zone,NR_ISOLATED_FILE , count[1 ]); } -/* Similar to reclaim, but different enough that they don't share logic */ -static bool too_many_isolated (struct zone *zone) +static bool __too_many_isolated (struct zone *zone,int safe) {unsigned long active, inactive, isolated; - inactive =zone_page_state (zone,NR_INACTIVE_FILE ) + +if (safe) { + inactive =zone_page_state_snapshot (zone,NR_INACTIVE_FILE ) + +zone_page_state_snapshot (zone,NR_INACTIVE_ANON ); + active =zone_page_state_snapshot (zone,NR_ACTIVE_FILE ) + +zone_page_state_snapshot (zone,NR_ACTIVE_ANON ); + isolated =zone_page_state_snapshot (zone,NR_ISOLATED_FILE ) + +zone_page_state_snapshot (zone,NR_ISOLATED_ANON ); + }else { + inactive =zone_page_state (zone,NR_INACTIVE_FILE ) +zone_page_state (zone,NR_INACTIVE_ANON ); - active =zone_page_state (zone,NR_ACTIVE_FILE ) + + active =zone_page_state (zone,NR_ACTIVE_FILE ) +zone_page_state (zone,NR_ACTIVE_ANON ); - isolated =zone_page_state (zone,NR_ISOLATED_FILE ) + + isolated =zone_page_state (zone,NR_ISOLATED_FILE ) +zone_page_state (zone,NR_ISOLATED_ANON ); + }return isolated > (inactive + active) /2 ; } +/* Similar to reclaim, but different enough that they don't share logic */ +static bool too_many_isolated (struct zone *zone) +{ +/* +* __too_many_isolated(safe=0) is fast but inaccurate, because it +* doesn't account for the vm_stat_diff[] counters. So if it looks +* like too_many_isolated() is about to return true, fall back to the +* slower, more accurate zone_page_state_snapshot(). +*/ +if (unlikely (__too_many_isolated (zone,0 ))) +return __too_many_isolated (zone,1 ); +return 0 ; +} +/** * isolate_migratepages_block() - isolate all migrate-able pages within * a single pageblock
Signature · 8 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation -- 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>
Quoted 1 line · Vinayak Menon
Commit "
3611badc1baa" (mm: vmscan: fix the page state calculation in
That appears to be a -next commit ID, which won't be the same in Linus' tree, so it shouldn't be in commit message, AFAIK.
Quoted 4 lines
too_many_isolated) fixed an issue where a number of tasks were blocked in reclaim path for seconds, because ofvmstat_diffnot being synced in time. A similar problem can happen inisolate_migratepages_block, similar calculation is performed. This patch fixes that.
I guess it's not possible to fix the stats instantly and once in the safe versions, so that future readings will be correct without safe, right? So until it gets fixed, each reading will have to be safe and thus expensive?
I think in case of async compaction, we could skip the safe stuff and just terminate it - it's already done when too_many_isolated returns true, and there's no congestion waiting in that case.
So you could extend the too_many_isolated() with "safe" parameter (as you did for vmscan) and pass it "cc->mode != MIGRATE_ASYNC" value from isolate_migrate_block().
Quoted 20 lines
Signed-off-by Vinayak Menon <[email protected]>--- mm/compaction.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-)mm/compaction.c +1
-3@@ -537,21 +537,43 @@ static void acct_isolated(struct zone *zone, struct compact_control *cc)mod_zone_page_state (zone,NR_ISOLATED_FILE , count[1 ]); } -/* Similar to reclaim, but different enough that they don't share logic */ -static bool too_many_isolated (struct zone *zone) +static bool __too_many_isolated (struct zone *zone,int safe) {unsigned long active, inactive, isolated; - inactive = zone_page_state(zone, NR_INACTIVE_FILE) +
mm/compaction.c static void acct_isolated(struct zone *zone, struct compact_control *cc) · line 553
Quoted 10 lines
mm/compaction.c +9
-0+if (safe) { + inactive =zone_page_state_snapshot (zone,NR_INACTIVE_FILE ) + +zone_page_state_snapshot (zone,NR_INACTIVE_ANON ); + active =zone_page_state_snapshot (zone,NR_ACTIVE_FILE ) + +zone_page_state_snapshot (zone,NR_ACTIVE_ANON ); + isolated =zone_page_state_snapshot (zone,NR_ISOLATED_FILE ) + +zone_page_state_snapshot (zone,NR_ISOLATED_ANON ); + }else { + inactive =zone_page_state (zone,NR_INACTIVE_FILE ) +zone_page_state (zone,NR_INACTIVE_ANON );
Nit: could you ident the line above (and the other 2 below) the same way as they are in the if (safe) part?
Thanks!
Quoted 19 lines
mm/compaction.c +10
-2- active =zone_page_state (zone,NR_ACTIVE_FILE ) + + active =zone_page_state (zone,NR_ACTIVE_FILE ) +zone_page_state (zone,NR_ACTIVE_ANON ); - isolated =zone_page_state (zone,NR_ISOLATED_FILE ) + + isolated =zone_page_state (zone,NR_ISOLATED_FILE ) +zone_page_state (zone,NR_ISOLATED_ANON ); + }return isolated > (inactive + active) /2 ; } +/* Similar to reclaim, but different enough that they don't share logic */ +static bool too_many_isolated (struct zone *zone) +{ +/* +* __too_many_isolated(safe=0) is fast but inaccurate, because it +* doesn't account for the vm_stat_diff[] counters. So if it looks +* like too_many_isolated() is about to return true, fall back to the
mm/compaction.c static void acct_isolated(struct zone *zone, struct compact_control *cc) · line 579
Quoted 10 lines
mm/compaction.c +7
-0+* slower, more accurate zone_page_state_snapshot(). +*/ +if (unlikely (__too_many_isolated (zone,0 ))) +return __too_many_isolated (zone,1 ); +return 0 ; +} +/** * isolate_migratepages_block() - isolate all migrate-able pages within * a single pageblock
--
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>
Quoted 6 lines · Vlastimil Babka
Quoted 1 line · Vinayak Menon
Commit "
3611badc1baa" (mm: vmscan: fix the page state calculation inThat appears to be a -next commit ID, which won't be the same in Linus' tree, so it shouldn't be in commit message, AFAIK.
Quoted 9 lines
Quoted 4 lines
too_many_isolated) fixed an issue where a number of tasks were blocked in reclaim path for seconds, because ofvmstat_diffnot being synced in time. A similar problem can happen inisolate_migratepages_block, similar calculation is performed. This patch fixes that.I guess it's not possible to fix the stats instantly and once in the safe versions, so that future readings will be correct without safe, right? So until it gets fixed, each reading will have to be safe and thus expensive?
Yeah, this patch will actually hurt performance for the migration scanner but not as much as stalling unnecessarily when the snapshot is the same.
Quoted 8 lines
I think in case of async compaction, we could skip the safe stuff and just terminate it - it's already done when
too_many_isolatedreturns true, and there's no congestion waiting in that case.So you could extend the
too_many_isolated()with "safe" parameter (as you did for vmscan) and pass it "cc->mode!=MIGRATE_ASYNC" value fromisolate_migrate_block().
Or just pass it struct compact_control *cc and use both cc->zone and cc->mode inside this compaction-only function.
--
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>
Quoted 11 lines · David Rientjes
Quoted 8 lines
I think in case of async compaction, we could skip the safe stuff and just terminate it - it's already done when
too_many_isolatedreturns true, and there's no congestion waiting in that case.So you could extend the
too_many_isolated()with "safe" parameter (as you did for vmscan) and pass it "cc->mode!=MIGRATE_ASYNC" value fromisolate_migrate_block().Or just pass it struct
compact_control*cc and use bothcc->zoneandcc->modeinside this compaction-only function.
Yeah,
in any case, please wait until the discussion about the vmscan fix is resolved, before reposting this.
Thanks.
--
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>