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 4D00FC3DA7D for ; Tue, 3 Jan 2023 08:32:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC2F08E0002; Tue, 3 Jan 2023 03:32:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B72988E0001; Tue, 3 Jan 2023 03:32:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3ACF8E0002; Tue, 3 Jan 2023 03:32:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 95A828E0001 for ; Tue, 3 Jan 2023 03:32:10 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 604C0140ABB for ; Tue, 3 Jan 2023 08:32:10 +0000 (UTC) X-FDA: 80312820420.13.281D4AE Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf04.hostedemail.com (Postfix) with ESMTP id 8237640016 for ; Tue, 3 Jan 2023 08:32:08 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=AZGQFsAC; spf=pass (imf04.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 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=1672734728; 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=otz19k1tc7qzP2hV2fG+WMWuYfwYpYbTF6IlJwVmXWM=; b=VKFCB/LQI5zg61w+JW3Lw7CNz4LTTQxvjTNDekoqltqKsknlxZoEFgn+CyW0nNfU3+dKYU +3Cb1Jy+7nS7FQO+9nojT8OfVzK2zVX3UloZUa9Q8RJsRxBg1TXaZuy+vdkWh1WYkll5FH FVTCni7oi4waI9q+57Qj+ia4/mU6jn8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=AZGQFsAC; spf=pass (imf04.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 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=1672734728; a=rsa-sha256; cv=none; b=vukbYAtDcjpBzfYBoEKTBo/E4AMEsIHbJfc+IUmNWuE0FUMBp+xqk09l3zdWwBFpE6Dnvs HmnX+7qSR1e+D9GPlEsYZCqf79xgK5NKJXGEiomMQijXEPRG2mYqEg9x8bsHJ4FrP1pr2J 3KNjVfsOMmGk55g3Ku7xM86Dcw3cKjg= 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-out1.suse.de (Postfix) with ESMTPS id 1C41237F0D; Tue, 3 Jan 2023 08:32:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1672734727; 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=otz19k1tc7qzP2hV2fG+WMWuYfwYpYbTF6IlJwVmXWM=; b=AZGQFsAC5EaiBv+XveQ+4UmNX6EaEKIH8Ux13WW/BOlmVOwcHt9N+mGVRbN5uzwCdaBuVQ U3arMH591+NVs4tIRzDYGhvnHhG8azwZVlqJyWMF4qjCFmsW5X3VgA2Wh7LmcdKuYCdoT0 xJxUNORQmCPI/qwcwk9seLuY1Nc59WE= 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 F1A381390C; Tue, 3 Jan 2023 08:32:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id xrkTOAbos2P3CAAAMHmgww (envelope-from ); Tue, 03 Jan 2023 08:32:06 +0000 Date: Tue, 3 Jan 2023 09:32:06 +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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230103082008epcms1p6f75b54cbfeba0a1ab9a8044dc650134b@epcms1p6> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 8237640016 X-Stat-Signature: es97ubhdjynh38hrm75nwyu9p7kjxnzm X-Rspam-User: X-HE-Tag: 1672734728-619391 X-HE-Meta: U2FsdGVkX18j6uNvxA6iJ+o/U8DRPrsOB9c0OUw1Nxp7vfFwOs+/8B7mGQ46Hys3W7Bn/6rhUjM17LpWNv/96/VVylw0GcJlNvrjULUfsnBl1AqbZ6fd+dXdbY1JKpFOVQrBFsjKLDgT2DFhyLo7Awtdk7V+FLXZDCWxHUq9blS8U+TRDYnONGS9x7b4f/stPUWZuC5BgZ6lnONwTU8T+rASB6mF9Cat5RLTq3yqxePSfleqJQe4NBymV+Wj0EmVhSXdu4c7yG/ojo2A5JM/rle0cwsRdfgrz3ugzb9BJGbH75U3xdUJyvM4MAFRj6SyBEpmVcpSMs0m2SYPQoVaKIhs2CqbJbFFafQlVzqKMIvxv9XwV69jNn/wCTCUQgS50++fBiZrvDVyur2nxSVnHFuypQgPFKUGkNbETqKFW8HWcYJPptUlqfNA1+lvniDGYtMJ9GCvqJNHR7t4Tzu7TwmhLTu2GhCWgvMrUGcRQd1E0XuRECz5wHlO3xoPYtuz51Gc0jvRYUQanXyjGaZpZdN4sQ7XTvDNppvuG7PwrNm8d5ruFSnsl8/lensXDiJcbbg3q2SvF2PxXy62OjnYzo8UIz8DHvO0K6EvOO15eeJj73kVDGm73XWu/GVInjY6VFD5P7WswJi7Rq4G7SpGhFc9Ng6yLKiVtX3hbacNYqOnRiq+4+T+xXNX3k8s9coqQg1D4u6Q0ELxcv8h9v0u570FscXKrB2UElzU1YCIuCb/CnVm3hBDHl5TX9FrHMYFtEMLuWCu6fvg+ol0cJgfaPi4oC32hCvN7IW9GyjYBPxQcacjRh0lFeYwXhl/DQbG6wGSeVXw9kW/vFcl32FCH/ww4iOeQwLZufTf+ujqGb6KZDwn4hhPvrp6/GdzG3nhJopjqmV7ZDxVLrJmMqzAHE4V/GJ2cOl03nnbDGEVvgSE+hFhbwt2RozDYhEZdhQZg/3GJuUUUoUg2K5TTmx q6ZUvqIs MjlKcWPPYEZNqnmeBH2bkPoxVYGGQwatwf9TVkcDpVEyVykK5FUwNAESqaA== 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 17:20:08, 김재원 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? 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? > 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 > -- Michal Hocko SUSE Labs