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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3390BC46467 for ; Tue, 3 Jan 2023 09:22:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50DC28E0002; Tue, 3 Jan 2023 04:22:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 496598E0001; Tue, 3 Jan 2023 04:22:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E8E38E0002; Tue, 3 Jan 2023 04:22:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 17EDF8E0001 for ; Tue, 3 Jan 2023 04:22:41 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DAE12A2A4E for ; Tue, 3 Jan 2023 09:22:40 +0000 (UTC) X-FDA: 80312947680.07.AA69154 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by imf29.hostedemail.com (Postfix) with ESMTP id AA12A120009 for ; Tue, 3 Jan 2023 09:22:36 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=hwlv4WZu; spf=pass (imf29.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.24 as permitted sender) smtp.mailfrom=jaewon31.kim@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672737757; a=rsa-sha256; cv=none; b=gPm9goRxXUb/bhr+nHB95moWfW+OZiGoP7wvqP9X9puNyjsCIKfy3PlGxXlJm5qJNqCsf5 /NT6E/UW2Oud9Km+TseT63mQK2JhcBINdaAJGBOyh/b4S3dTA7KVVle/aLknvzrydWSA/2 mG+X8DbpKnd++yQCI5CZdaAWdP0FX+E= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=hwlv4WZu; spf=pass (imf29.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.24 as permitted sender) smtp.mailfrom=jaewon31.kim@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672737757; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9hsVUuF18FxAp31aIuTTebw/KbnjjewGzPtYyZ+9y2s=; b=fTtL4qI8juKBCo225V2Yiqq/E3tQo1uxoaYeh7k3xsuSVSFzssaGNPSssBF0t2/LeOvRPg Ealm7fTNWSIdk59A6q82u7XmB7R9dYHNretl/7Q3r73w5JJ+zQXF7iTOZ8/9GXdk2187A1 jR+t+cvvXgBUe2Rtrpmf8LPXkJWP5Rw= Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20230103092233epoutp01f8c4bb22068134f6304f097e093a6ca4~2wh_0FjqJ2865428654epoutp01I for ; Tue, 3 Jan 2023 09:22:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230103092233epoutp01f8c4bb22068134f6304f097e093a6ca4~2wh_0FjqJ2865428654epoutp01I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1672737753; bh=9hsVUuF18FxAp31aIuTTebw/KbnjjewGzPtYyZ+9y2s=; h=Subject:Reply-To:From:To:CC:In-Reply-To:Date:References:From; b=hwlv4WZuGfuN4X7Xg4iN7eMITYGKCe4tRLxBOPnXa4v12drq1Jz0qgHbURTC+GdA4 Xe7ZbhqCrD3vG01ub818u0CN4wHIpz3Bnwj0y4W92eC46pIsIllMqKRrIzCkMIJVmh SjApWs2Ak30dx3lwm8mbsQzVT+iyS9ez2Q9VcnlA= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20230103092232epcas1p142a5e8293a446d2cc365ddc99324630d~2wh_kV5791282112821epcas1p1H; Tue, 3 Jan 2023 09:22:32 +0000 (GMT) Received: from epsmges1p2.samsung.com (unknown [182.195.36.222]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4NmS1h3302z4x9Q0; Tue, 3 Jan 2023 09:22:32 +0000 (GMT) X-AuditID: b6c32a36-1fdff700000095a1-4c-63b3f3d80e90 Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 0A.39.38305.8D3F3B36; Tue, 3 Jan 2023 18:22:32 +0900 (KST) Mime-Version: 1.0 Subject: RE: (2) [PATCH] page_alloc: avoid the negative free for meminfo available Reply-To: jaewon31.kim@samsung.com From: =?UTF-8?B?6rmA7J6s7JuQ?= To: Michal Hocko CC: "akpm@linux-foundation.org" , "hannes@cmpxchg.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "jaewon31.kim@gmail.com" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20230103092232epcms1p7f2df94d75fc1b6f11ee986a3a1aa1900@epcms1p7> Date: Tue, 03 Jan 2023 18:22:32 +0900 X-CMS-MailID: 20230103092232epcms1p7f2df94d75fc1b6f11ee986a3a1aa1900 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P X-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KTuqsbjxSf01V9 8XhV8ncXhm+TGbzm3A++6OPaebL1c8qia8GHSmvzzsXKris9u++5N/Oe9YcixXJ1eKv9Tgi8 b6t/1Lnqyc3+uRy9ztPtT00TWczcv1Cq9c+BaVOfl/hlqe/4E7tFequglHymh8vnhx4LNGXW dfS7ZDREl21rvdk6M9XfU4mlOCPRUIu5qDgRACE7bisgBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230103072834epcas1p3441ef50a6cc26ac48d184f1244b76a0e References: <20230103072807.19578-1-jaewon31.kim@samsung.com> <20230103082008epcms1p6f75b54cbfeba0a1ab9a8044dc650134b@epcms1p6> X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: AA12A120009 X-Stat-Signature: h6usddnw913cfp5zs9p1b7rdagpigz6k X-HE-Tag: 1672737756-203714 X-HE-Meta: U2FsdGVkX18KQSx6F5GAntdkWklniFL6puQX/hkEyugaSQiYmNB+FJhNKuxUr4Yp/gHejSAYJP9OfULXR2T/SIFLO6EzkO7nQF9ncLiIvs2LNbXEc+T/WnfnObkSk70J69EAHtucPn8p1OOGmJW/MoEj2FWJ0UZp0Q8KT87IyRIDhfGGP14EPe0NR3D9aZ7RTrOQC0L5pbTcPud8nFBsVj+EyOaHpMrzrSGyTbJxXNIa9l70/GkXfw+G1JK6c+58YJc1wTMcAI7cAIrik+TuTGi0UbfjngD7b0FYYgu7tBX0NgiRYP2NcJAKZ6kfj51hnCkAnr9p3L24NDsTEux/Y7H/oSV3gByaigKxa/mKlk7KNX+SfbYC3Fa8cGpbpPXqQkR/etqcWTthkRMmCIbgBsMWZesiS29bhWq+RaB2lucDyyvNfWJMtU1HQ8m49vCOM5Onf90gtT1k5Jp8hZZc8qJ4hEz1bA11kfeG+VacMA0riR8u8BO9n8XLldWK8ELYrwv9AD5dhhwK3x1jF2FVy05a5QCEh6Sbh8gqEMmezHW3unCszxOvfT0mfPSGS6SZfyXMvyP3x+JCLbMSz7/x2YaGkVu8UEaMoEJ+BFsTeX59Uq3+0qkLK8u/oVooZR2Tgzf9oxmPsBITYv+m/1hEqDMkwgBI8sKUMIHBKDCz9bq3Noq68V26zViC1bB8UaUNqyW7OkOnt93K/JFd28Nqyx6R+4FAyj7uGaCQU5/W4yVWUfqOelXywbZaxuUxxm82kX1u7WQ9N0VFFiU+snpAS9qL/+L2v0/DDjIGAwEOjqyZpwTbPFrJsTHhutLui76jl81sdWmkRyzyqvq3Pv+yJm2W51h7O3h4ZP7g22blekH4x8espMcuvOLila28mwgBRW9rUCG6VEbs6pCf6glGtRIxhKn2cMwmdmy/slcK0vGnRRk8NgVlxXCAyNoKgvEa9xYdG3cwN6VZX8qXa5o szAZuIeA DQUuh1sRMc8z7hyCbCVWwJdqHUeOdpgw4siVUn6VjFFbASicILuL+O0mTtndUaGviQTzoZtws2UAKFz03K9519x5GFiXo9FvmquABa9VluQ68PcY7Zit57UHqFgdnzo3SuuqkajyYU1VGIjbnHGfVHuclLUbm5Se9T9B9d+CCdMI03VRD/O/Yi0UDJXBwI+Jh4ll8SzLqMo2M8GNCbUXTX5465s2R7bVcaqt7WZwEFXDOy+Dh898Hc5YdxZRsxvJt+fQymNIpAcxsIbBgOeOg3hTR+lBlM6v6SdMsuELDOTGF+Bc= 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: >> >On Tue 03-01-23 16:28:07, Jaewon Kim wrote: >> >> The totalreserve_pages could be higher than the free because of >> >> watermark high or watermark boost. Handle this situation and fix it to 0 >> >> free size. >> > >> >What is the actual problem you are trying to address by this change? >> >> Hello >> >> As described on the original commit, >> 34e431b0ae39 /proc/meminfo: provide estimated available memory >> mm is tring to provide the avaiable memory to user space. >> >> But if free is negative, the available memory shown to userspace >> would be shown smaller thatn the actual available size. The userspace >> may do unwanted memory shrinking actions like process kills. > >Do you have any specific example? Have you seen this happening in >practice or is this based on the code inspection? I found this from a device using v5.10 based kernel. Actually the log was printed by user space in its format after reading /proc/meminfo. MemFree 38220 KB MemAvailable 90008 KB Active(file) 137116 KB Inactive(file) 124128 KB SReclaimable 100960 KB Here's /proc/zoneinfo for wmark info. ------ ZONEINFO (/proc/zoneinfo) ------ Node 0, zone DMA32 pages free 17059 min 862 low 9790 high 18718 spanned 524288 present 497920 managed 413348 Node 0, zone Normal pages free 12795 min 1044 low 11855 high 22666 spanned 8388608 present 524288 managed 500548 The pagecache at this time, seems to be 174,664 KB. pagecache -= min(pagecache / 2, wmark_low) We also need to add the reclaimable and the actual free on it to be MemAvaiable. The MemAvailable should be bigger at leat this 174,664 KB, but it was 90,008 KB only because the big wmark high 165,536 seems to be used. > >Also does this patch actually fix anything? Say the system is really >struggling and we are under min watermark. Shouldn't that lead to >Available to be reported as 0 without even looking at other counters? > Sorry but I did not understand, this mis-calculation can be happened above the min watermark. Do you think the wmark high should be extracted all the time even if the free is negative? >> I think the logic sholud account the positive size only. >> >> BR >> >> > >> >> Signed-off-by: Jaewon Kim >> >> --- >> >> mm/page_alloc.c | 2 ++ >> >> 1 file changed, 2 insertions(+) >> >> >> >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >> >> index 218b28ee49ed..e510ae83d5f3 100644 >> >> --- a/mm/page_alloc.c >> >> +++ b/mm/page_alloc.c >> >> @@ -5948,6 +5948,8 @@ long si_mem_available(void) >> >> * without causing swapping or OOM. >> >> */ >> >> available = global_zone_page_state(NR_FREE_PAGES) - totalreserve_pages; >> >> + if (available < 0) >> >> + available = 0; >> >> >> >> /* >> >> * Not all the page cache can be freed, otherwise the system will >> >> -- >> >> 2.17.1 >> > >> >-- >> >Michal Hocko >> >SUSE Labs >> >> >> >> >> --------- Original Message --------- >> Sender : Michal Hocko >> Date : 2023-01-03 17:03 (GMT+9) >> Title : Re: [PATCH] page_alloc: avoid the negative free for meminfo available >> >> On Tue 03-01-23 16:28:07, Jaewon Kim wrote: >> > The totalreserve_pages could be higher than the free because of >> > watermark high or watermark boost. Handle this situation and fix it to 0 >> > free size. >> >> What is the actual problem you are trying to address by this change? >> >> > Signed-off-by: Jaewon Kim >> > --- >> > mm/page_alloc.c | 2 ++ >> > 1 file changed, 2 insertions(+) >> > >> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c >> > index 218b28ee49ed..e510ae83d5f3 100644 >> > --- a/mm/page_alloc.c >> > +++ b/mm/page_alloc.c >> > @@ -5948,6 +5948,8 @@ long si_mem_available(void) >> > * without causing swapping or OOM. >> > */ >> > available = global_zone_page_state(NR_FREE_PAGES) - totalreserve_pages; >> > + if (available < 0) >> > + available = 0; >> > >> > /* >> > * Not all the page cache can be freed, otherwise the system will >> > -- >> > 2.17.1 >> >> -- >> Michal Hocko >> SUSE Labs >>