From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 757FFC432BE for ; Mon, 30 Aug 2021 11:33:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0778861139 for ; Mon, 30 Aug 2021 11:33:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0778861139 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 386916B006C; Mon, 30 Aug 2021 07:33:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 336386B0071; Mon, 30 Aug 2021 07:33:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 225D98D0001; Mon, 30 Aug 2021 07:33:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0079.hostedemail.com [216.40.44.79]) by kanga.kvack.org (Postfix) with ESMTP id 14B786B006C for ; Mon, 30 Aug 2021 07:33:17 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B8276231A9 for ; Mon, 30 Aug 2021 11:33:16 +0000 (UTC) X-FDA: 78531535992.12.928B763 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf25.hostedemail.com (Postfix) with ESMTP id 2E55AB00008E for ; Mon, 30 Aug 2021 11:33:16 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C4FBF220FD; Mon, 30 Aug 2021 11:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1630323194; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qbtIM/v0tAoR2oZYjGEg40bXhpo80BebKdAbqKmN8do=; b=Lp5XNbGdjWfYGvXx9OPoXj2ke48ZaSuF4sCVstvFcEQAql7EY7rBKIXyX6KCkgj5MuWvH2 N+pQsDJPwmhl0OpHeDYBDhJc3RaliARw8U4lsUcOSmfFuRrl8iQHGvX0uhSfcLe2l/fybS tTTtVLsoEJNMY1lA6UyIV2yZnYGLpz8= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 67799A3B8C; Mon, 30 Aug 2021 11:33:14 +0000 (UTC) Date: Mon, 30 Aug 2021 13:33:10 +0200 From: Michal Hocko To: Rik van Riel Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, stable@kernel.org, Chris Down , Johannes Weiner Subject: Re: [PATCH] mm,vmscan: fix divide by zero in get_scan_count Message-ID: References: <20210826220149.058089c6@imladris.surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210826220149.058089c6@imladris.surriel.com> Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=Lp5XNbGd; spf=pass (imf25.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 2E55AB00008E X-Stat-Signature: 4p6udgp9dahy8fj3br8imze4uscwzypf X-HE-Tag: 1630323196-616804 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu 26-08-21 22:01:49, Rik van Riel wrote: > 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. I must be missing something but how can cgroup_size be ever 0 when it is max(cgroup_size, protection) and protection != 0? -- Michal Hocko SUSE Labs