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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50BE2C433F5 for ; Wed, 29 Sep 2021 06:16:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC012613CD for ; Wed, 29 Sep 2021 06:16:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EC012613CD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 72D7694000F; Wed, 29 Sep 2021 02:16:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6DD01940009; Wed, 29 Sep 2021 02:16:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CC1294000F; Wed, 29 Sep 2021 02:16:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0043.hostedemail.com [216.40.44.43]) by kanga.kvack.org (Postfix) with ESMTP id 447D1940009 for ; Wed, 29 Sep 2021 02:16:22 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D8BD1181A47F6 for ; Wed, 29 Sep 2021 06:16:21 +0000 (UTC) X-FDA: 78639601362.01.9773C1A Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) by imf07.hostedemail.com (Postfix) with ESMTP id A031E1000099 for ; Wed, 29 Sep 2021 06:16:21 +0000 (UTC) Received: by mail-io1-f41.google.com with SMTP id p80so1685061iod.10 for ; Tue, 28 Sep 2021 23:16:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ue2L72Yfa5y6ge63nlG9vKeGiwu3moJ7Urp0CKfDZT0=; b=ngmZOUK7gUzxHkbE4NjGhdHnB1ja0k9VeSYIzbC4VTlKX/5aNtROcQLvSMsiAN8fDS votmpw4/M0pwqwLET5us7zujCPvMuiZ+gY5KgAy+LEXdr/zDkRl2RjbaQMtCYktRmh1p nfg0BBkIKvVjc0R7aD/LeB6N+b31sSpO38nAGf41Gzpnb3LYOXh8YYN7uX8zp58ok2jc SPlJSPSmHocAwC+kPPW5xarFzPglrEZRphwvg1xwXYnmqyAdtc4HRbUnzRFYRMdcauJT QWNbJSR5qfqi3yn8nmTTKCBdqqkr6L/ZSOjmVPzllZNFTosZSN0BTTXjg5e2y9AAaT5+ Rr5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ue2L72Yfa5y6ge63nlG9vKeGiwu3moJ7Urp0CKfDZT0=; b=OtjgBiuzMQC8wOZRqk/62k0ESvZ2VMX62KLEEEZfR2EeqiPDpGeyY8EYHe3s5TLus3 CGmzoCbNsLQxjJqG/3pob21Jgp6XFEHaNeaekMsxgngh3gkFv0IxriCfTMmzkiLwJD95 iryIsSKeqwU9pyebDR188lRsBfKVFV2im4c84DFSiTBaUFaWMBXh0dx340M/wIBCzRb2 VAoHMK4PaJMJT2Wo1CfKwdyLu2ny0sN5/3f15NEiQbbqvWM1v0dwHVIwPX0ecfS89mDe GnRnt1SSZcO2eDBbrYha8lU9Z6EiQdyiLduo2tBF44CzXQEQSJs3WlUEN9DZI3Y2zEz/ drQQ== X-Gm-Message-State: AOAM533rP7WbZHTE6O5g0VGGAKoW1AjwKyjDLaFE6GOZ4sgUNmcgxQSb CZFQVKLzYX1GToDkXkiRsVNkGqF/ugApIRkHG+0= X-Google-Smtp-Source: ABdhPJyI+Ic2qBPRcopqrZ34ZMTuw7uTPBjY9+UwnwywG2bCSxm8ounk7mWOZpCjxJn5a1+eSbTQWUknvws5N+qH5+k= X-Received: by 2002:a05:6638:d0e:: with SMTP id q14mr7867836jaj.139.1632896180981; Tue, 28 Sep 2021 23:16:20 -0700 (PDT) MIME-Version: 1.0 References: <1632831797-32192-1-git-send-email-liangcaifan19@gmail.com> <20210928152919.df87f6c8194316ff1407cdc7@linux-foundation.org> In-Reply-To: <20210928152919.df87f6c8194316ff1407cdc7@linux-foundation.org> From: Fan Liangcai Date: Wed, 29 Sep 2021 14:15:53 +0800 Message-ID: Subject: Re: [PATCH] mm: Set min_free_kbytes with user_min_free_kbytes when user_min_free_kbytes is preferred To: Andrew Morton Cc: liangcai.fan@unisoc.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chunyan Zhang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ngmZOUK7; spf=pass (imf07.hostedemail.com: domain of liangcaifan19@gmail.com designates 209.85.166.41 as permitted sender) smtp.mailfrom=liangcaifan19@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: A031E1000099 X-Stat-Signature: 6kbny3tjpikhzukkr9qmoxse6hhyz7cb X-HE-Tag: 1632896181-184474 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: Andrew Morton =E4=BA=8E2021=E5=B9=B49=E6=9C=882= 9=E6=97=A5=E5=91=A8=E4=B8=89 =E4=B8=8A=E5=8D=886:29=E5=86=99=E9=81=93=EF=BC= =9A > > On Tue, 28 Sep 2021 20:23:17 +0800 Liangcai Fan = wrote: > > > The 'min_free_kbytes' and 'user_min_free_kbytes' maybe inconsistent > > after a few times of memory hotplug. > > What does "inconsistent" mean here? > > Please describe the problem in more detail, perhaps with examples. > example: 1. Turn on the device with 1G memory, and the calculated 'new_min_free_kbyt= es' is 3452kb, at this time 'min_free_kbytes' =3D 'new_min_free_kbytes' =3D 345= 2kb, 'user_min_free_kbytes' is the initial value -1. 2. The user sets 'min_free_kbytes' to 4096kb through the node, at this time 'user_min_free_kbytes' =3D 'min_free_kbytes' =3D 4096kb. 3. The memory has increased by 2G, and the memory has become 3G. Recalculate 'new_min_free_kbytes' to be 6568kb, which is greater than 'user_min_free_kbytes'(4096kb), at this time 'min_free_kbytes' =3D 'new_min_free_kbytes' =3D 6568kb, 'user_min_free_kbytes' =3D 4096kb. 4. The memory has been reduced by 2G, and now the memory has become 1G. Recalculate 'new_min_free_kbytes' to be 3452kb, which is less than 'user_min_free_kbytes'(4096kb). The original logic does not modify 'min_free_kbytes'. At this time, 'min_free_kbytes' is the last 'new_min_free_kbytes'(6568kb). The memory is 1G ,'min_free_kbytes' should be equal to 'user_min_free_kbytes'(4096kb) set by the user. > > When 'new_min_free_kbytes' is not larger than 'user_min_free_kbytes', > > set 'min_free_kbytes' with 'user_min_free_kbytes' rather than leave > > it as the 'new_min_free_kbytes' calculated for the last time. > > > > Signed-off-by: Liangcai Fan > > Cc: Chunyan Zhang > > --- > > mm/page_alloc.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index b37435c..ddf9dc1 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -8467,6 +8467,12 @@ int __meminit init_per_zone_wmark_min(void) > > if (min_free_kbytes > 262144) > > min_free_kbytes =3D 262144; > > } else { > > + /* > > + * Set 'min_free_kbytes' with 'user_min_free_kbytes' rath= er than > > + * leave it as the 'new_min_free_kbytes' calculated for t= he last > > + * time. > > + */ > > This comment explains what the code is doing, which is almost always > obvious from reading the code! A better comment will describe *why* > the code is doing whatever is does. "why, not what", please. > I think this comment is redundant and will be deleted. > > + min_free_kbytes =3D user_min_free_kbytes; > > pr_warn("min_free_kbytes is not updated to %d because use= r defined value %d is preferred\n", > > new_min_free_kbytes, user_min_free_kbytes= ); > > } >