From patchwork Mon Jul 25 01:28:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 12927675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1A25C43334 for ; Mon, 25 Jul 2022 01:28:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6E0B8E0002; Sun, 24 Jul 2022 21:28:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DF6778E0001; Sun, 24 Jul 2022 21:28:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C49378E0002; Sun, 24 Jul 2022 21:28:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id AF3AE8E0001 for ; Sun, 24 Jul 2022 21:28:47 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7CE401C5DBF for ; Mon, 25 Jul 2022 01:28:47 +0000 (UTC) X-FDA: 79723887894.08.47866C4 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by imf06.hostedemail.com (Postfix) with ESMTP id 3F3C2180082 for ; Mon, 25 Jul 2022 01:28:45 +0000 (UTC) Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220725012841epoutp01c7ef7ad049acd02ffb77ec6dbcd8e666~E7kAY_CSD0774607746epoutp01N for ; Mon, 25 Jul 2022 01:28:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220725012841epoutp01c7ef7ad049acd02ffb77ec6dbcd8e666~E7kAY_CSD0774607746epoutp01N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1658712521; bh=cgqftIejdu4DlnvqSpYYKr2ZM6Zshrmmwe8HB00bCyw=; h=From:To:Cc:Subject:Date:References:From; b=brcS0+UHNj3SJDETuoxt+IKaQ4x44pYhiGRO+HJJY8VvJ/tlm0WNKtJ+quPn4cwiN v6qF9ZYu7s763TsKoUIVXw479uN9nIMFeXHizRB+anEcShrrwVZ9iEJuVy4pqzmn5p XecKlytIKDpF6qmTbzFEil9MsJoICwD11dKdX3jo= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20220725012841epcas1p15740c06feed0b4115fc0b9fbc8d25dcb~E7j--GUCw0952409524epcas1p1E; Mon, 25 Jul 2022 01:28:41 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.38.250]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4Lrj9h74P1z4x9Q0; Mon, 25 Jul 2022 01:28:40 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 4D.1C.09657.8C1FDD26; Mon, 25 Jul 2022 10:28:40 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20220725012840epcas1p4ae36f072b813f97fc27d33b46da5bc67~E7j-JBgAA3107531075epcas1p4B; Mon, 25 Jul 2022 01:28:40 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220725012840epsmtrp1518099624fb28788de9ba6d437d24833~E7j-IIQMG0443104431epsmtrp1k; Mon, 25 Jul 2022 01:28:40 +0000 (GMT) X-AuditID: b6c32a35-733ff700000025b9-05-62ddf1c887d2 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 63.02.08802.8C1FDD26; Mon, 25 Jul 2022 10:28:40 +0900 (KST) Received: from jaewon-linux.10.32.193.11 (unknown [10.253.100.104]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220725012840epsmtip272c4d9d351d60288d6c7cd3d7e8e58de~E7j_8p4We2327023270epsmtip2k; Mon, 25 Jul 2022 01:28:40 +0000 (GMT) From: Jaewon Kim To: minchan@kernel.org, akpm@linux-foundation.org, bhe@redhat.com, vbabka@suse.cz, mgorman@techsingularity.net, hannes@cmpxchg.org, mhocko@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, gh21.hong@samsung.com, ytk.lee@samsung.com, jaewon31.kim@gmail.com, Jaewon Kim Subject: [PATCH] page_alloc: fix invalid watemark check on a negative value Date: Mon, 25 Jul 2022 10:28:43 +0900 Message-Id: <20220725012843.17115-1-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPKsWRmVeSWpSXmKPExsWy7bCmnu6Jj3eTDJ48MLOYs34Nm8X5B7/Y LLb8fsNosXqTr0X35pmMFr3vXzFZXN41h83i3pr/rBY7lu5jsnj9bRmzxbKv79ktZjf2MVo8 Xs/twOtx+M17Zo+ds+6ye2xa1cnmsenTJHaPEzN+s3i833eVzaNvyypGjzMLjrB7bP1l5/F5 k1wAV1S2TUZqYkpqkUJqXnJ+SmZeuq2Sd3C8c7ypmYGhrqGlhbmSQl5ibqqtkotPgK5bZg7Q 6UoKZYk5pUChgMTiYiV9O5ui/NKSVIWM/OISW6XUgpScArMCveLE3OLSvHS9vNQSK0MDAyNT oMKE7Izz9x8zFzTyVezdvomxgXE3dxcjJ4eEgInEltezmbsYuTiEBHYwSqx6NoMJwvnEKNHx 6CkbhPOZUWJx22nWLkYOsJbeRwkg3UICuxglbj3Sgqj5wSixZu9SRpAEm4C2x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NjAuJu7i5GDQ0LARKL3UUIXIyeHkMAO RolvN0tAbAkBGYk355+yQJQISxw+XNzFyAVU8o1R4t63aawgNWwC2hLvF0xiBUmICCxklNj5 /gUziMMssJJR4u3LeYwgVcIC3hIP+yaBTWIRUJV4slcExOQVsJW4t0gbYpe8xOoNB5gnMPIs YGRYxSiZWlCcm55bbFhglJdarlecmFtcmpeul5yfu4kRHKhaWjsY96z6oHeIkYmD8RCjBAez kghvV9rtJCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8F7pOxgsJpCeWpGanphakFsFkmTg4pRqY orkPqz+o2cbw4ZzcnJxrX2yPxb8x8FvxSedekc6rdbPeLfVkf2/788ltu/bib59rtu+V2cz7 tdLbKtNEuzM4cE/3pIBHpwwTrsUnM058HXXRd/LbqGV+bT/4wivCS5g+JZVH3HjGreD0X2+a 3LpVWmpJK2qfbfyyePqT9L3V63f6fWl5OCFoY/TRNqtMK6N5J6dNEV8we+2Wnq3M7y92JYQq Ttrqd8YxfN0TP632VQx793t/Tc36d7Jt/rJPhU6mGpXbhc5bff5YvChtlf42r4nHly0Ps2S9 XLIofZ/XrfJvjzOO/9revuaR0YMl+zRvX5kx7da1LdddntsnaB9Z+CpKXyf/zik3jUm/Cper nQ9SYinOSDTUYi4qTgQAjzzRSMMCAAA= X-CMS-MailID: 20220725012840epcas1p4ae36f072b813f97fc27d33b46da5bc67 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220725012840epcas1p4ae36f072b813f97fc27d33b46da5bc67 References: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658712526; a=rsa-sha256; cv=none; b=BOzyL3EzKkQbHCHGp4MKtyR3VsF30XQkX1HaU1mLxNStX5XnTnG0qnSdYalJYGamnwOMBl AKDlz+ZFoENfu3fQmmxD+Z7k4eSQZKu/VfO8hkW6ufqVlQ8TMtje02B+FuqpxVnvs8zyVb mY2U6BCFa1idbspJ0wARkzW8e/TZQSY= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=brcS0+UH; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf06.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.24 as permitted sender) smtp.mailfrom=jaewon31.kim@samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658712526; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:references:dkim-signature; bh=cgqftIejdu4DlnvqSpYYKr2ZM6Zshrmmwe8HB00bCyw=; b=LSc02YuQoDOxUgpk13qjV3uZapXLc9LHIKfoHYvmO3oBA0v2VbPDnwth4m9Oxsf+S2Vfo8 5UndpSg7A+MeHDS5PkgES8Nv0QPGVVJ4SBccR69fYjWx/KjPviPAys5YbRiEJ+vtRhU7UX V+1/lKMU+mXOpnHPfVXsy2m51brlxow= X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 3F3C2180082 X-Stat-Signature: p9rdjripprgbs36a1mhg1wy1fc8pqgkg Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=brcS0+UH; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf06.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.24 as permitted sender) smtp.mailfrom=jaewon31.kim@samsung.com X-HE-Tag: 1658712525-266610 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: There was a report that a task is waiting at the throttle_direct_reclaim. The pgscan_direct_throttle in vmstat was increasing. This is a bug where zone_watermark_fast returns true even when the free is very low. The commit f27ce0e14088 ("page_alloc: consider highatomic reserve in watermark fast") changed the watermark fast to consider highatomic reserve. But it did not handle a negative value case which can be happened when reserved_highatomic pageblock is bigger than the actual free. If watermark is considered as ok for the negative value, allocating contexts for order-0 will consume all free pages without direct reclaim, and finally free page may become depleted except highatomic free. Then allocating contexts may fall into throttle_direct_reclaim. This symptom may easily happen in a system where wmark min is low and other reclaimers like kswapd does not make free pages quickly. To handle the negative value, get the value as long type like __zone_watermark_ok does. Reported-by: GyeongHwan Hong Signed-off-by: Jaewon Kim Acked-by: Mel Gorman --- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e008a3df0485..cf667fae132e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3968,11 +3968,12 @@ static inline bool zone_watermark_fast(struct zone *z, unsigned int order, * need to be calculated. */ if (!order) { + long min = mark; long fast_free; fast_free = free_pages; fast_free -= __zone_watermark_unusable_free(z, 0, alloc_flags); - if (fast_free > mark + z->lowmem_reserve[highest_zoneidx]) + if (fast_free > min + z->lowmem_reserve[highest_zoneidx]) return true; }