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 E0887C3DA7D for ; Tue, 3 Jan 2023 10:20:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1FB708E0002; Tue, 3 Jan 2023 05:20:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1ACF88E0001; Tue, 3 Jan 2023 05:20:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 073328E0002; Tue, 3 Jan 2023 05:20:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id EA5868E0001 for ; Tue, 3 Jan 2023 05:20:08 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9F6FAC0B28 for ; Tue, 3 Jan 2023 10:20:08 +0000 (UTC) X-FDA: 80313092496.09.3F87A81 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf12.hostedemail.com (Postfix) with ESMTP id D948540008 for ; Tue, 3 Jan 2023 10:20:05 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=an+tYDRS; spf=pass (imf12.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672741206; h=from:from:sender: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=WxwzilripMrMET7cDXrClsfcZECAT4drpWNCobXQpAM=; b=Ia8X67NWgya29Vlv6D5X7T1CwZF1mhc9xAfAFBJig/yeMgEwTHHl5gRvplU9S1e8rhAyP8 ZCQQCa4EAYpmXpzaeZvgfTA/UL3hDXZSNCYy5qFdMrvVr8sXRIe6FUVu3gk3PRrB58mRNe RPAHGNcOatc1+sPt5nWLdcfGZkS5xU4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=an+tYDRS; spf=pass (imf12.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672741206; a=rsa-sha256; cv=none; b=56dU3swmkHjTdfWCcPswB6wAmlH1EWU+anVV7Hv6kTIrjJ8FXVbku3Sw5f52d1RGn98Wa4 75oTEA293YwKj+R2TM3GebCoAjYzkp1//aKMvMeKRxT3ogV0mUS2SGvOr2Owty8/cgoIzu H3A3cMLaEd2IqR2K80BS4xguVzm5gJQ= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6C1AF611A4; Tue, 3 Jan 2023 10:20:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1672741204; h=from:from:reply-to: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; bh=WxwzilripMrMET7cDXrClsfcZECAT4drpWNCobXQpAM=; b=an+tYDRSWJI67+lk8LBlngSSuYmwlz1zLTlFZ+NtuMAWAQVrizDo+RMIK8n+eBkeBovvji 5WJrajd2OQk8VXCFgdUQaKQFC3OCbtHr63ckwqYFI1+eFmvQo6nOVfkrzjGpDQ+RG9Hz39 zugmIkR4dVaxvCffsrqMij1BLrycVgE= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 506C11392B; Tue, 3 Jan 2023 10:20:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id t1SmElQBtGM7PwAAMHmgww (envelope-from ); Tue, 03 Jan 2023 10:20:04 +0000 Date: Tue, 3 Jan 2023 11:20:03 +0100 From: Michal Hocko To: =?utf-8?B?6rmA7J6s7JuQ?= Cc: "akpm@linux-foundation.org" , "hannes@cmpxchg.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "jaewon31.kim@gmail.com" Subject: Re: (2) [PATCH] page_alloc: avoid the negative free for meminfo available Message-ID: References: <20230103072807.19578-1-jaewon31.kim@samsung.com> <20230103082008epcms1p6f75b54cbfeba0a1ab9a8044dc650134b@epcms1p6> <20230103092232epcms1p7f2df94d75fc1b6f11ee986a3a1aa1900@epcms1p7> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230103092232epcms1p7f2df94d75fc1b6f11ee986a3a1aa1900@epcms1p7> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D948540008 X-Stat-Signature: 9myxxkcu4xsfyeg5ndomf8bd1tcpwbsz X-Rspam-User: X-HE-Tag: 1672741205-4750 X-HE-Meta: U2FsdGVkX1/PmwiZyBgQZFHLuwNYzjJ/GVUfttia9AoVisvIcUYB86I8J5khcO97T2PMiyS3/rckarBVpz0HcW/SM8/1hREGfPECUhvWFTEaymbGOXLTTxwuVDqGGKdnNdQC/Y2GGaZ0761aB0+QW/kD3XOHVunMk6s/8OLIUhYEjFxSsgyooJgR5eHUTv8BCMTGgJoZAkxWs1hYqdo3VR2CLKuutYMkHV03ZcyvDFceXcl/30UxCt3+BRL8aXPljyxgw6mDfPWBVBwQ/x4zOd6djxoa8piSa/6kDgM3fTbevlX6Kjb7fqHs27oFZH80YxZJpM8pqWn2IgtHyXCuoGKRBAjdyX5MYit0MhmJxV0rXJ12h+ky4JUajuXuNHwvgexU/VCVSab8+38nRkmvdwQj4O/KVFerv/R/D/E8NRemdbW2cDex/OLl37ujAddTmCetkgzdf+z4wzAT1RqkyctmrO3cyHECjLqhOjgzITNfPKIQcgoREWFNp/HR7zPluw7Vkhs8AxzYUG/DptntTzrs6vLDxVQosBoGcRxdFb0RmtVDuNzGr69z/p2pzYuJLiFQktGCNhLSG4nvMn/c5bexT2r5nYt5pefgQOzOilLnYI9WQ4onaIjAMcbaSARNT+YWpq4g8+07IhlabgOhusxmZMr4G4arhqVkfEf38Yq4NT/CK4tj1rn4vH4VQf7ZjL9tqptvdiwUSLsVClcu2+My51jdW2cvyKU9G7CHq5BOYElo37slDGMlVr+hLBYQKfRz0rK3pO+a0TaG/mWY0qXBpBlfxNgK3MLBnDsI9yZaiqvuRWbDv5o+tJonX4N7ak4cjRF9/57rs4Ovh/JhoKfjMCLBO+WFbvW7TNrWFeP0exP4n6EMb7aNME7pWPv5Z44OHiSM9b9QTkjBvtxmY51ZJR7ruLG7UJwHUNk5V1H669pjUFe8T94j1X60mqWBIbACVic6ospBaEw9vFw 55tLN/ET t/7NWBCic/HnJ+6UYG8RBzvF6tQt+E3GpUCX5bSu0DCDu1YA= 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 18:22:32, 김재원 wrote: > >> >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. 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. -- Michal Hocko SUSE Labs