linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: Rik van Riel <riel@surriel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	kernel-team@fb.com, stable@kernel.org,
	Chris Down <chris@chrisdown.name>,
	Johannes Weiner <hannes@cmpxchg.org>
Subject: Re: [PATCH] mm,vmscan: fix divide by zero in get_scan_count
Date: Mon, 30 Aug 2021 15:41:19 +0200	[thread overview]
Message-ID: <YSzf/3A6b0R3kR5v@dhcp22.suse.cz> (raw)
In-Reply-To: <d77b816458f9df3839345f0ee0144b797ec176be.camel@surriel.com>

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 <mhocko@suse.com>
-- 
Michal Hocko
SUSE Labs

  reply	other threads:[~2021-08-30 13:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27  2:01 [PATCH] mm,vmscan: fix divide by zero in get_scan_count Rik van Riel
2021-08-27 16:28 ` Roman Gushchin
2021-08-30 11:33 ` Michal Hocko
2021-08-30 13:24   ` Rik van Riel
2021-08-30 13:41     ` Michal Hocko [this message]
2021-08-30 20:48 ` Johannes Weiner
2021-08-31  9:59   ` Michal Hocko
2021-08-31 15:48     ` Rik van Riel
2021-09-01 19:40       ` Johannes Weiner
2021-08-31 12:58 ` Chris Down

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YSzf/3A6b0R3kR5v@dhcp22.suse.cz \
    --to=mhocko@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=chris@chrisdown.name \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=riel@surriel.com \
    --cc=stable@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).