Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3522010pxb; Mon, 30 Aug 2021 04:34:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoESitxTfS+Fj6oZrMoFIGSJDhHOdTr9i84ttDQ2YlbntczZXlcAaPpkj39SwdlrgkdVn9 X-Received: by 2002:a5d:9653:: with SMTP id d19mr17631800ios.74.1630323255341; Mon, 30 Aug 2021 04:34:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630323255; cv=none; d=google.com; s=arc-20160816; b=yCiy1kFU/gPZvjRb5ByPLTNRbS+yjAEAfRfSUqKTwfJAPWQrCmdb1OGEUekxmYQQiV bx5Qi1rDkAUjh/q9nmf08RH1BbZitTpHafX1QS+ap5hCg+n2DSA/ceRxT78Ac16lAtaS GqPE+MW9/NFovPzMJbOoiS/9DM98fOiIKjA40Zt810E19giR/v2nB1v+NLkfOzVQXCIL Hl+MUT1RE/n+hEbIOCCMdqJup6UElgGlJYlyxqKKOZXqNoWh01sRCNlcaqY+nc/Ln4Sk huP//isHvfgF8F6/oP+aY4nQF8p0hmsEmqGpxSjoGSiH/T/hW6BC0IQYtwiJXwz2NV7+ oYHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qbtIM/v0tAoR2oZYjGEg40bXhpo80BebKdAbqKmN8do=; b=IogkAHZccRRl356egHzhSLkmhlJILckxqqa0wVHDCPFbwne/O3kPAv2PPVmlIJsEUq wXl+ZA+D9TgVzc5LvEmFrwuQ5Z5K1JhzpM9XBbDY40qSIIQq/1cJNz5Sg/a63IWumcqr NuObuT/1cSEjBCbOBLOCh04yKcJMLmmqn00+641cNFKOxNgwqOpzxLFmXUkh92Des2E4 Z3H3mYH9QNzWXKMk2A/e3FZw9/V8iTpeozbWk0A3pYWMPpDOtXFVrokstNEtY9cQBvIU 0C+Ssyd6G/lQfJ/XEktfY8iOFt2vUKl3jAOAKYLBIVtsRRrZpI0KnWgdOQamU/MymyMG xV9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Lp5XNbGd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k10si11028926iof.8.2021.08.30.04.34.04; Mon, 30 Aug 2021 04:34:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Lp5XNbGd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236434AbhH3LeJ (ORCPT + 99 others); Mon, 30 Aug 2021 07:34:09 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:38584 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232579AbhH3LeJ (ORCPT ); Mon, 30 Aug 2021 07:34:09 -0400 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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