Linux-mm Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/2] mm, memcg: Fix corruption on 64-bit divisor in memory.high throttling
@ 2020-03-12 18:02 Chris Down
  2020-03-12 18:03 ` [PATCH 2/2] mm, memcg: Throttle allocators based on ancestral memory.high Chris Down
  2020-03-16 16:19 ` [PATCH 1/2] mm, memcg: Fix corruption on 64-bit divisor in memory.high throttling Johannes Weiner
  0 siblings, 2 replies; 4+ messages in thread
From: Chris Down @ 2020-03-12 18:02 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Johannes Weiner, Tejun Heo, linux-mm, cgroups, linux-kernel, kernel-team

0e4b01df8659 had a bunch of fixups to use the right division method.
However, it seems that after all that it still wasn't right -- div_u64
takes a 32-bit divisor.

The headroom is still large (2^32 pages), so on mundane systems you
won't hit this, but this should definitely be fixed.

Fixes: 0e4b01df8659 ("mm, memcg: throttle allocators when failing reclaim over memory.high")
Reported-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Chris Down <chris@chrisdown.name>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: linux-mm@kvack.org
Cc: cgroups@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: kernel-team@fb.com
Cc: stable@vger.kernel.org # 5.4.x
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 63bb6a2aab81..a70206e516fe 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2339,7 +2339,7 @@ void mem_cgroup_handle_over_high(void)
 	 */
 	clamped_high = max(high, 1UL);
 
-	overage = div_u64((u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT,
+	overage = div64_u64((u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT,
 			  clamped_high);
 
 	penalty_jiffies = ((u64)overage * overage * HZ)
-- 
2.25.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-12 18:02 [PATCH 1/2] mm, memcg: Fix corruption on 64-bit divisor in memory.high throttling Chris Down
2020-03-12 18:03 ` [PATCH 2/2] mm, memcg: Throttle allocators based on ancestral memory.high Chris Down
2020-03-16 16:21   ` Johannes Weiner
2020-03-16 16:19 ` [PATCH 1/2] mm, memcg: Fix corruption on 64-bit divisor in memory.high throttling Johannes Weiner

Linux-mm Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mm/0 linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ https://lore.kernel.org/linux-mm \
		linux-mm@kvack.org
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kvack.linux-mm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git