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 87E9AC3DA7D for ; Tue, 3 Jan 2023 10:39:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6E3F8E0002; Tue, 3 Jan 2023 05:39:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E1DFE8E0001; Tue, 3 Jan 2023 05:39:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE62B8E0002; Tue, 3 Jan 2023 05:39:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C05248E0001 for ; Tue, 3 Jan 2023 05:39:58 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 86E5080B49 for ; Tue, 3 Jan 2023 10:39:58 +0000 (UTC) X-FDA: 80313142476.03.08DB77B Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by imf02.hostedemail.com (Postfix) with ESMTP id 914148000C for ; Tue, 3 Jan 2023 10:39:55 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=nT2Ctl6y; spf=pass (imf02.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.34 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=1672742396; 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=0TJaPWMtey8kBZptPJkIvvP316f+QOmtcQ1ZopckNj4=; b=lUVVn+H7zo90i8JemmBKqTwD1CVnr2bCNnm5MQmUDlpF4UMaKfEd6IJ94yvaBR47CKnwpp 4QpbCfHysrhaUqhz7TUCrcQB4Cx26Bd+gW/TXDoH4DH0JsRyehRHLEv1OlREGmRh19kybd h9fivMdj6FNzuNH5VlPaVFp4gDxoOts= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=nT2Ctl6y; spf=pass (imf02.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.34 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=1672742396; a=rsa-sha256; cv=none; b=Fwgkvdsf44PPFCV6Vv/mk6OWSDg3HTzU7ZfG8vSMb571mNqGZtN+2IPFKe68ys9AFCfPAL aGn5eErsv80+amWxWgqz/hzFtJQY3k5PV6hmpib93Xx96DTz7aP8+WDWeVqcZ65HbHzrhT fXKzkjq9DRcYYm6s85TK6/ppqV9SbYs= Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230103103951epoutp04e1f27640deb434650f022d10e11d2731~2xlfBA2IA2203222032epoutp04E for ; Tue, 3 Jan 2023 10:39:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230103103951epoutp04e1f27640deb434650f022d10e11d2731~2xlfBA2IA2203222032epoutp04E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1672742391; bh=0TJaPWMtey8kBZptPJkIvvP316f+QOmtcQ1ZopckNj4=; h=Subject:Reply-To:From:To:CC:In-Reply-To:Date:References:From; b=nT2Ctl6yoO4emiZLrVSR1Ch4SXiFGx+H5IgX+KbBamUaUCdTuPIjVmtdCYGn2ofa0 GpOT7GAmWrQFAOoEbVyVFQHjlHweNSlTOTrEA+A9mrYKGNvi5XvH23SxVTR7a2UfCY +wQuly5UD8rOPt596gt6pA1dnTb3AfY9MAwP7yMQ= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20230103103951epcas1p46e4b207f50c7823402645d0b51566d41~2xleyuy-Q1633416334epcas1p4j; Tue, 3 Jan 2023 10:39:51 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.36.223]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4NmTkv1cfwz4x9Pw; Tue, 3 Jan 2023 10:39:51 +0000 (GMT) X-AuditID: b6c32a35-21ffd70000014e05-3c-63b405f7dc99 Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 49.F1.19973.7F504B36; Tue, 3 Jan 2023 19:39:51 +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: <20230103103950epcms1p5fc40605dd0f3165f86d7fbaff78ff87b@epcms1p5> Date: Tue, 03 Jan 2023 19:39:50 +0900 X-CMS-MailID: 20230103103950epcms1p5fc40605dd0f3165f86d7fbaff78ff87b Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P X-Brightmail-Tracker: H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5jE/AyeH/tn7xDrn6Qvlbn j7CVE+3t3sQa36rb+67no0Pq45spp7jW37OviVv66ngB98KEpcEbXHuVvrakfj8We9bYRkQj wUp/oXOT19+DP2q3P1ylILco1vH2PMbX95WDJ4uef3boe3nUnPzHjoeeeUpvz1bnt7pQZLj6 eVjdRi45cW8FxQN88XOVWIozEg21mIuKEwHZxjSOIAQAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230103072834epcas1p3441ef50a6cc26ac48d184f1244b76a0e References: <20230103072807.19578-1-jaewon31.kim@samsung.com> <20230103082008epcms1p6f75b54cbfeba0a1ab9a8044dc650134b@epcms1p6> <20230103092232epcms1p7f2df94d75fc1b6f11ee986a3a1aa1900@epcms1p7> X-Rspamd-Queue-Id: 914148000C X-Stat-Signature: uj1f8pzxrf7oeo9spz3k3bmxscunmhhx X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1672742395-666167 X-HE-Meta: U2FsdGVkX188ewh7WWHFEfDPWrMJaIHG7it2Cry27SXQDVAc3rhHbcwD+W7DA+tr4cHdcV6qevqMBKONXasnLoNvPXt7yPMZ+dDLwvpbM4yPhlgvZc0E8ghmP1Dk7OR9pB+yXZZPGhOxAFDZkWXXqHtF/AL+V50ZeI3gfIbXGqw6WvqkRH9JOjJT76Qus0GQfj7xHkI7wLNSJYtHfsLF4YlxtZAVDKwa+oA+lqFygJfeFZcNUQPYzw8Df6LyU7E9dyF3KUtjUjhJnZHkSbGK101ehSNSDPiTy4iCZYs1UElh4fem/9dgtpZPzvtq8YzYGeXAzNLoE3d1nsPi+iiEcVOr/cDCG8GbemE1lC/6QLD9s5Q+xGKiT9EEz3Eab7zsTh2tsNe/F7xP7/RvCcnnXXR8xWNKo3UXJaH+tnYdTCWZ3EhFPuApOTays2XQXjA5xN0CrEwDx49AzNqe5yIBhsIhegfGxOQ8BbnDBrMwoqfAg/RjopQukgUt4G98OQzPSnx328R3oWy6ElOOv6lyznQYsXa0c2PEzUEAWTIrNGHMtpttppa6ywMNt9B92x9Jrl81ZPUJ97gX8Vi0Pt0IsyMt2kFkZnR/exMmT8C/i6/RP6xtuoS+rZbuUj2iazzr68dL1U5YgFGCtGOIcudrsKGLnKurGXCDhjliuUBgh6np8jQFI9xNZWhUUfCJ6NRXbV0xgJR94rGqfn2WzTeDq8xjrRH9I9zvwbhgMIeRy2iKa/dEnbzISXLkPyMy7zvzLVOpa9962kmngQ471rIlOtOmjI1P8LJ51/K7SXWgw8JwAPH8I+5J9evbKYoR9r9pype1aytU4Tm1idMLZVSxloEZeR+dAZFcYpukzACxjM/nNJItWtlYMDUVDSomeAgFG67SsC5RaSs+d069Dh6+qOhINyqS7fvE2NoCBtp4wX3LOUqD76Bq/gsydP6YOOsYC1M75ypgbP0J9uCGIWR xW1AuKn7 0dlt/xgMaIaPQExeViW6rDt8YBeyqwsW09p1WaaC8qh8OGAIH/o8xpaTSPikzrg3kbo1/dSxahagtgQRotn0ZOcg7CBXusWg92y37O7xHaLyeue00SpXvWtoIBTcwwJPImfzFF4w5uv2i2+I10sJthN0cPwcJ+ne8mqkwp35wW/ZQ8p+UHWr3odziDCPvt1UzacUJrO/+ITCTvYSFo+/AjCkkt/2qGoijIZ8YppRVdJtrpqZka8rwrPzbstV+jBZpi5KD6fNGVrRNxV+yqRlQMqfzQ9fFnt95gLFCjcmKao6qxD8= 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. > >How have you concluded that? Are you saying that a userspace would be >behaving more sanely when considering more memory to be available? >Please see more on the semantics below. > >> >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, > >What I meant here is that the core of the high level definition says: >"An estimate of how much memory is available for starting new >applications, without swapping." If the system is close enough to watermarks >that NR_FREE_PAGES < reserves then it is likely that further memory >allocations will not do without reclaim and potentially swapout. Yes reclaim would be needed in that case. I think it is just a matter of perspective. If I follow you, I think, the totalreserve_pages should be considered as must-have free size. > >So the question really is whether just clamping the value to 0 is >actually making MemAvailable more "correct"? See my point? > >The actual value is never going to be lazer cut precise. Close to >watermark behavior will vary wildly depending on the memory >reclaimability. Kswapd might easily keep up with memory demand but it >also could get stuck. MemAvailable should be considered a hint rather >than an exact value IMHO. Yeah correct, it is not perfect. I will drop my patch. It was nice discussion. Thank you