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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 DD2CEC4320E for ; Tue, 31 Aug 2021 15:48:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2080E60F46 for ; Tue, 31 Aug 2021 15:48:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2080E60F46 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 8E1AF8D0009; Tue, 31 Aug 2021 11:48:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88FBE8D0001; Tue, 31 Aug 2021 11:48:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77EC68D0009; Tue, 31 Aug 2021 11:48:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0003.hostedemail.com [216.40.44.3]) by kanga.kvack.org (Postfix) with ESMTP id 64D408D0001 for ; Tue, 31 Aug 2021 11:48:36 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1B89E1801D2E5 for ; Tue, 31 Aug 2021 15:48:36 +0000 (UTC) X-FDA: 78535808232.35.6240989 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by imf05.hostedemail.com (Postfix) with ESMTP id B829F503CCCE for ; Tue, 31 Aug 2021 15:48:35 +0000 (UTC) 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 Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=none; spf=none (imf05.hostedemail.com: domain of riel@shelob.surriel.com has no SPF policy when checking 96.67.55.147) smtp.mailfrom=riel@shelob.surriel.com X-Stat-Signature: 8zsdeoqcu6ae1q7g499et4jtoyuemx3f X-Rspamd-Queue-Id: B829F503CCCE X-Rspamd-Server: rspam04 X-HE-Tag: 1630424915-956709 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: --=-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--