Skip to content

Commit

Permalink
mm/memcg: move penalty delay clamping out of calculate_high_delay()
Browse files Browse the repository at this point in the history
We will want to call calculate_high_delay() twice - once for memory and
once for swap, and we should apply the clamp value to sum of the
penalties.  Clamping has to be applied outside of calculate_high_delay().

Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reviewed-by: Shakeel Butt <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Cc: Chris Down <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Tejun Heo <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
kuba-moo authored and torvalds committed Jun 2, 2020
1 parent 8a5dbc6 commit ff144e6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2386,14 +2386,7 @@ static unsigned long calculate_high_delay(struct mem_cgroup *memcg,
* MEMCG_CHARGE_BATCH pages is nominal, so work out how much smaller or
* larger the current charge patch is than that.
*/
penalty_jiffies = penalty_jiffies * nr_pages / MEMCG_CHARGE_BATCH;

/*
* Clamp the max delay per usermode return so as to still keep the
* application moving forwards and also permit diagnostics, albeit
* extremely slowly.
*/
return min(penalty_jiffies, MEMCG_MAX_HIGH_DELAY_JIFFIES);
return penalty_jiffies * nr_pages / MEMCG_CHARGE_BATCH;
}

/*
Expand Down Expand Up @@ -2421,6 +2414,13 @@ void mem_cgroup_handle_over_high(void)
penalty_jiffies = calculate_high_delay(memcg, nr_pages,
mem_find_max_overage(memcg));

/*
* Clamp the max delay per usermode return so as to still keep the
* application moving forwards and also permit diagnostics, albeit
* extremely slowly.
*/
penalty_jiffies = min(penalty_jiffies, MEMCG_MAX_HIGH_DELAY_JIFFIES);

/*
* Don't sleep if the amount of jiffies this memcg owes us is so low
* that it's not even worth doing, in an attempt to be nice to those who
Expand Down

0 comments on commit ff144e6

Please sign in to comment.