From: Hui Zhu calculate_high_delay() stores max_overage * max_overage * HZ, computed as u64, into an unsigned long before shifting it right by 34 bits in total. On 32-bit kernels the store truncates the value to its low 32 bits, so the shift always yields zero: memory.high and memory.swap.high throttling is completely inert there. And since the caller reads "penalty_jiffies <= HZ / 100" as "nothing to do", the MAX_RECLAIM_RETRIES reclaim loop is skipped as well. Keep the intermediate in u64 so the shifts see the full width. Also make the function return u64, and the caller's penalty_jiffies u64, so the value is narrowed only after the caller has clamped it to MEMCG_MAX_HIGH_DELAY_JIFFIES. Nothing changes on 64-bit kernels, where unsigned long is already 64 bits wide. Fixes: e26733e0d0ec ("mm, memcg: throttle allocators based on ancestral memory.high") Cc: stable@vger.kernel.org Signed-off-by: Hui Zhu --- mm/memcontrol.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 84f4a8fd4d16..2625107a1096 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2573,10 +2573,10 @@ static u64 swap_find_max_overage(struct mem_cgroup *memcg) * Get the number of jiffies that we should penalise a mischievous cgroup which * is exceeding its memory.high by checking both it and its ancestors. */ -static unsigned long calculate_high_delay(unsigned int nr_pages, - u64 max_overage) +static u64 calculate_high_delay(unsigned int nr_pages, + u64 max_overage) { - unsigned long penalty_jiffies; + u64 penalty_jiffies; if (!max_overage) return 0; @@ -2611,7 +2611,7 @@ static unsigned long calculate_high_delay(unsigned int nr_pages, */ void __mem_cgroup_handle_over_high(gfp_t gfp_mask) { - unsigned long penalty_jiffies; + u64 penalty_jiffies; unsigned long pflags; unsigned long nr_reclaimed; unsigned int nr_pages = current->memcg_nr_pages_over_high; -- 2.53.0