[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YS4nbYA61E9N2FqD@chrisdown.name>
Date: Tue, 31 Aug 2021 13:58:21 +0100
From: Chris Down <chris@...isdown.name>
To: Rik van Riel <riel@...riel.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, kernel-team@...com,
stable@...nel.org, Michal Hocko <mhocko@...e.com>,
Johannes Weiner <hannes@...xchg.org>
Subject: Re: [PATCH] mm,vmscan: fix divide by zero in get_scan_count
Rik van Riel writes:
>Changeset f56ce412a59d ("mm: memcontrol: fix occasional OOMs due to
>proportional memory.low reclaim") introduced a divide by zero corner
>case when oomd is being used in combination with cgroup memory.low
>protection.
>
>When oomd decides to kill a cgroup, it will force the cgroup memory
>to be reclaimed after killing the tasks, by writing to the memory.max
>file for that cgroup, forcing the remaining page cache and reclaimable
>slab to be reclaimed down to zero.
>
>Previously, on cgroups with some memory.low protection that would result
>in the memory being reclaimed down to the memory.low limit, or likely not
>at all, having the page cache reclaimed asynchronously later.
>
>With f56ce412a59d the oomd write to memory.max tries to reclaim all the
>way down to zero, which may race with another reclaimer, to the point of
>ending up with the divide by zero below.
>
>This patch implements the obvious fix.
>
>Fixes: f56ce412a59d ("mm: memcontrol: fix occasional OOMs due to proportional memory.low reclaim")
>Signed-off-by: Rik van Riel <riel@...riel.com>
Thanks, good catch. No strong preference on this vs. max3(), so feel free to
keep my ack either way.
Acked-by: Chris Down <chris@...isdown.name>
>
>diff --git a/mm/vmscan.c b/mm/vmscan.c
>index eeae2f6bc532..f1782b816c98 100644
>--- a/mm/vmscan.c
>+++ b/mm/vmscan.c
>@@ -2592,7 +2592,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
> cgroup_size = max(cgroup_size, protection);
>
> scan = lruvec_size - lruvec_size * protection /
>- cgroup_size;
>+ (cgroup_size + 1);
>
> /*
> * Minimally target SWAP_CLUSTER_MAX pages to keep
>
>
Powered by blists - more mailing lists