Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11658242rwl; Tue, 3 Jan 2023 02:48:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXvCnxQGbMfYtSfKMxZwZD5VZkxbfjPNgudXg7bSvLBensx8NFglf3mJ8Y+wEmqwHW2R7ywg X-Received: by 2002:a05:6402:43c8:b0:48d:a0fc:d334 with SMTP id p8-20020a05640243c800b0048da0fcd334mr6861641edc.30.1672742897577; Tue, 03 Jan 2023 02:48:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672742897; cv=none; d=google.com; s=arc-20160816; b=wDRWAbGKlDtAyOyiF+r8C0ln9g20qg0pw9+qc3fHdLzg/KRFBQVEzOLKAGmFMph86n V9jIUcEGh9RuFjKucphbB9vMKyKu+cgvnwTN/Bli2zrqVskUt7BcOrMrjmUB1SveYM7u k3l/EKOhK37y7V22ArqjXP4b938VVXJXTjItjRKc8Bi2AbAcz0Ra644M/FvFd1QLVHNQ 3cQDx1RBD/Lr2SAnLOvj2KstEM104ERJORLaxx0H9wzAqROWhkiGCXPswn82Ris8pep7 gciOUachsOi3lPacxBV35ccfpuy0iqBMQUaoIUzefnVot03mc6qdu4k9rNmrW3yV2Puc cITw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WxwzilripMrMET7cDXrClsfcZECAT4drpWNCobXQpAM=; b=rKLzYQD/asHl+qq8NCuzXRbUVX1fOnSxwL2GxMsEmcINJjSHCEx6nqlALMXFu0H8Zl glMY1XvZi7rwIR+fi9ETXACCuh4IJotpjoU81U4Fbma34CqmMWRFgHlhf+GSfSi86RWb lmP/0HyTEXEIjdDUYKJCUISvEpCbg5FyoZE4b6x38d06EC7jS+ItjPFQxdkdjijb9uRc FG+2TJbbgAMHL2YjDUOiGQb33bpzrJNOfgtqmWgvwYt0hz8Hjg+ZexAj1Cu+ExrkS/hC 72978d4aA4uzbDEVVHgF3acmKByad5lfFLFr+B2OFlIMA7u3QbUPows8aAUo17kAOSjy 29jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=an+tYDRS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n18-20020aa7c692000000b0047f2f8bfc05si24533024edq.135.2023.01.03.02.48.00; Tue, 03 Jan 2023 02:48:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=an+tYDRS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237140AbjACKUN (ORCPT + 61 others); Tue, 3 Jan 2023 05:20:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232898AbjACKUH (ORCPT ); Tue, 3 Jan 2023 05:20:07 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF060B1D1 for ; Tue, 3 Jan 2023 02:20:05 -0800 (PST) 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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