Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4648577pxb; Tue, 31 Aug 2021 09:56:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy25b5oQxbU47zNUNUD9BgBaHud50juAbOl+WfqyIgUxwNgMF+5QhTr3bwUD4quYBpQvDBd X-Received: by 2002:a05:6e02:148c:: with SMTP id n12mr21134306ilk.36.1630428986153; Tue, 31 Aug 2021 09:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630428986; cv=none; d=google.com; s=arc-20160816; b=gZD8gAWK1wQoHvTBfzSW7gRWfcDJOw0mnKVtHr1uyYB1g6YbBI3UmlT6pEL+tiRvWr kzjlDuzxpBRqJQPlS4T0OOxhGv38lJH9DbU9ncIZdVitl7jaoX3WZ16xdq2L2/TU+7fu +PJ6tTo8HjMbVeDXb+BW43kNBurtegQ9z4y1HRDIp8aXlypQ53ZkEv1LoEYpuKckLIeB weqTuTTpLi0vF4CrGk224882TCY8R5UE4VKI/QIUijif2nHDutqksqWUucp78Pp7vRCb n/hdJbgdOyiueQJLz4zTP7BlH9GkaY6oWEHrID9yfp8HZO+j6IlZ7jEMOBUGYkX8OxDH 1YOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id; bh=nZxc/EHFYWKbkDj03iMTlJoo1p+m9VjUoOh/4BrIJ1M=; b=HCNfjoCxBj3rtX/HMAxVb97yR1N0Zg26U6Y4ZE31j2bV2yQGpPK1+4YSjd7I1Rwa50 623ph1zZKZ1EC/y/3f8z+IJ+PjT5Gsaj5qpjZUga6grLo0pQAiP84SZ4smmls/rEho7b 0/K33Yc/k15G20AGO0TZSe0eqWu9JMO40tTCOy1YHIjFBiDwKNtlqSvx4zQSIoIFyUwn PcBnh+DC/JGxN0JAcBxmzF6xP5HrpZ0qW+CX/X6jnbUo+XpyXTOvvJwcjwgLXXbCIiTU E/Uiz6yupAB8vpXsdrHrQeeERXaEjxAd4OWk1JraDglxCLuU9fT0klJ5p2ee9zsxI4qI ZxQg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m9si18969604iow.85.2021.08.31.09.56.13; Tue, 31 Aug 2021 09:56:26 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238852AbhHaPtb (ORCPT + 99 others); Tue, 31 Aug 2021 11:49:31 -0400 Received: from shelob.surriel.com ([96.67.55.147]:53146 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232770AbhHaPtb (ORCPT ); Tue, 31 Aug 2021 11:49:31 -0400 Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mL5zw-0006Gd-R1; Tue, 31 Aug 2021 11:48:28 -0400 Message-ID: Subject: Re: [PATCH] mm,vmscan: fix divide by zero in get_scan_count From: Rik van Riel To: Michal Hocko , Johannes Weiner Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, stable@kernel.org, Chris Down Date: Tue, 31 Aug 2021 11:48:28 -0400 In-Reply-To: References: <20210826220149.058089c6@imladris.surriel.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-uZQ16ZnxuqAD9cMNKUrq" User-Agent: Evolution 3.40.3 (3.40.3-1.fc34) MIME-Version: 1.0 Sender: riel@shelob.surriel.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-uZQ16ZnxuqAD9cMNKUrq Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 2021-08-31 at 11:59 +0200, Michal Hocko wrote: > On Mon 30-08-21 16:48:03, Johannes Weiner wrote: >=20 >=20 > > Or go back to not taking the branch in the first place when there > > is > > no protection in effect... > >=20 > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 6247f6f4469a..9c200bb3ae51 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -2547,7 +2547,7 @@ static void get_scan_count(struct lruvec > > *lruvec, struct scan_control *sc, > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0mem_cgroup_protection(sc->target_mem_cgroup, mem= cg, > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 &min, &low); > > =C2=A0 > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0if (min || low) { > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0if (min || (!sc->memcg_low_reclaim && low)) { > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= /* > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= * Scale a cgroup's reclaim pressure by > > proportioning > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= * its current usage to its memory.low or > > memory.min >=20 > This is slightly more complex to read but it is also better than +1 > trick. We could also fold it into the helper function, with mem_cgroup_protection deciding whether to use low or min for the protection limit, and then we key the rest of our decisions off that. Wait a minute, that's pretty much what mem_cgroup_protection looked like before f56ce412a59d ("mm: memcontrol: fix occasional OOMs due to proportional memory.low reclaim") Now I'm confused how that changeset works. Before f56ce412a59d, mem_cgroup_protection would return memcg->memory.emin if sc->memcg_low_reclaim is true, and memcg->memory.elow when not. After f56ce412a59d, we still do the same thing. We just also set sc->memcg_low_skipped so we know to come back if we could not hit our target without skipping groups with memory.low protection... --=20 All Rights Reversed. --=-uZQ16ZnxuqAD9cMNKUrq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAmEuT0wACgkQznnekoTE 3oMNkQgArgplVGq77to07aWXH9+ApUXY21a0WY9aY5T9HxawsoLRnDaDSpQL5a3E dRW0UsFytvNQytBDYersxAuxdnunMe06TvFC70MDP4yzW68WXDr+yzQ2X0RZU55U DwwyWYr8cIfIo83eSbGnqFswdOC2ihtEmvIc4mK1r1XKXEGWvHuusrP0DyTPfe+M u8QtjnWBS5XUTkpmtk1NYUay2kFiE557rx2+OwHp2uO04iE6c1xWQCkkUX29/LSn yaMojBpoz5uM8/QNN1zqF/Zq+ta2NaFvyQiEoh2V/lKsRsbfDQ6j20oZaBpmDAxc 8ZJ2WOCkpJfKWH8e8wTx6dnSzD7iMg== =BgbF -----END PGP SIGNATURE----- --=-uZQ16ZnxuqAD9cMNKUrq--