Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3616388pxb; Mon, 30 Aug 2021 06:42:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZRjIYcVCZogbmvD6j1cUjsXtjlxSlj8djzbxF1soAU7rY/CSJ/efmGjoxRnOYBp9Za1KA X-Received: by 2002:a02:c055:: with SMTP id u21mr20237868jam.113.1630330937147; Mon, 30 Aug 2021 06:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630330937; cv=none; d=google.com; s=arc-20160816; b=Y9umoRKUb8Jplfrxx0ASAY69cVZSLrevcCRV14EgPoqQgRNHkDyNPgkq2pyWAZBGPr TFmwGelgEmRmgJBiZYZYbLggKosbpdh8gsDSNoVxNtEt2lW/rnFMUGHuvAY7x8qg0Q9g nerWr9XcykKzGeXHOW9Fciqq57hTRLSIyLA+iE/UAIib4280SbvZ86uIiNgqND91rOeg fIcaw6fT4CVR3IhQpSBxfZ70RirQ/GYEep30+oniQCmInuY4P/6dX6GRfBz6KSspr9Wd GTVtOeCs+1feCsYmu4XItPR7pcNHSWfAl+wMNdS59ov6WVtOs5ZdI3IfY/Gfj16I9GyE 9HtA== 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=109F1UpxBnRDw6BB5dtv3umGWR8nbJ7IetSDHkmh+sY=; b=lQULfUNswNDFJmmJj0fz8iZ6P9bT94dR+uzeggUvZ9gvMf8VJgHbUe980IyOpEGBQW V1oPGIBMH1DMmXA10oH+EPyKKtCypLkaeNA3LjmDDyFzd4zo0onnNBxR6ptgIOX9Zfm7 KOH8CB3vTBD1tAod32yMcGIUcpPX6zyjt5XQZ1UI0XpYsUR7PAU6hi8GQIRi+T/tna7X W8x4xLxePdeYWfWE2DtEDGAWrkm+pVIHPa9Tk4VSb3lSWxAayujz09MGuAAFbGCISHlA 29E7QFCpFO3inEnlhh+TnmwXpYpcnuEdVpoi85bE2743ZX6falD6u7igem8VRa1fWG4k zE8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=c1374K6Z; 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 l8si13539966ioj.7.2021.08.30.06.42.05; Mon, 30 Aug 2021 06:42:17 -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=c1374K6Z; 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 S236775AbhH3NmP (ORCPT + 99 others); Mon, 30 Aug 2021 09:42:15 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:45344 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231669AbhH3NmO (ORCPT ); Mon, 30 Aug 2021 09:42:14 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id F39DB200AB; Mon, 30 Aug 2021 13:41:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1630330880; 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=109F1UpxBnRDw6BB5dtv3umGWR8nbJ7IetSDHkmh+sY=; b=c1374K6ZFzZAeuxLeaVJI0XeyCa9vtN8JjP9Bh1wuCxnEiPRHlJiFmwXLMXl9A5tg6dYR7 VW7Awb5Q4nXcqZe4GcBbH1IvKe6o/Mq5Oi0ecs8FuiU8fPrQiChf8+A1N28XrcbwO1oLCg fYMfdDxyCG1CqxrXU7wu+49dFMajrPQ= 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 C3002A3BA1; Mon, 30 Aug 2021 13:41:19 +0000 (UTC) Date: Mon, 30 Aug 2021 15:41:19 +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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 30-08-21 09:24:22, Rik van Riel wrote: > On Mon, 2021-08-30 at 13:33 +0200, Michal Hocko wrote: [...] > > I must be missing something but how can cgroup_size be ever 0 when it > > is > > max(cgroup_size, protection) and protection != 0? > > Going into the condition we use if (low || min), where > it is possible for low > 0 && min == 0. > > Inside the conditional, we can end up testing against > min. Dang, I was looking at the tree without f56ce412a59d7 applied. My bad! Personally I would consider the following slightly easier to follow scan = lruvec_size - lruvec_size * protection / max(cgroup_size, 1); The code is quite tricky already and if you asked me what kind of effect cgroup_size + 1 have there I would just shrug shoulders... Anyway your fix will prevent the reported problem and I cannot see any obvious problem with it either so Acked-by: Michal Hocko -- Michal Hocko SUSE Labs