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 57DFDC433EF for ; Thu, 16 Dec 2021 15:43:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D8EB16B0071; Thu, 16 Dec 2021 10:43:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D40AE6B0073; Thu, 16 Dec 2021 10:43:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDE956B0074; Thu, 16 Dec 2021 10:43:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0034.hostedemail.com [216.40.44.34]) by kanga.kvack.org (Postfix) with ESMTP id ABA286B0071 for ; Thu, 16 Dec 2021 10:43:40 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 74B5E85D4E for ; Thu, 16 Dec 2021 15:43:30 +0000 (UTC) X-FDA: 78924076980.09.022B067 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf29.hostedemail.com (Postfix) with ESMTP id B62DC120008 for ; Thu, 16 Dec 2021 15:43:26 +0000 (UTC) Received: by mail-pj1-f45.google.com with SMTP id y16-20020a17090a6c9000b001b13ffaa625so451519pjj.2 for ; Thu, 16 Dec 2021 07:43:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:to:cc:references :from:in-reply-to:content-transfer-encoding; bh=DvAPGtEpiVuU2kvz5o3dTRnY8wThKOHqUQeQ2z/x2nI=; b=TDw2lsfmLNMlPpF/QUBVtH96UAWZMsN2GODesQ5HklEqtoo0QugXSDaDPwbEd4RnWy 8eDBR1nDxvH2lPAMAWSabqcQU12Rvhfw7X2c6voSULc6AiieTCIJBIA9yydPw92UdAe2 +adEr8c4TaqyrlVHL0zY6KGeGEeBAghwQMMWeSfwK9f3NwUwE00h+PFpdPRlQUHWiepY 0HY8aT7QWedjpygs9ZDS+GzVpWEtN78WlRyCyHkTGO94sMuCghojbVHhHnq0be/wa8Ws d5MMQpkOu2xeFC90SUHL4e7DBwx83a0qDVrNGDcc1NwFymh2OqM4/GvnCM4uOi4U194a LnQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :to:cc:references:from:in-reply-to:content-transfer-encoding; bh=DvAPGtEpiVuU2kvz5o3dTRnY8wThKOHqUQeQ2z/x2nI=; b=KIdQAYii8HwXc0BLfYAl4nDoNgAanYDF5iasXPvhoh0Udu+8s00ADMQKr30B9lpETc IsVx3GP3eXsBP3PIvD4wXAAbHNgElG5LTSMO6MBBMKmASPta/2x1WRyMSBl/96TSpnNR v3ebEbUFgSMtsepImKgI3dXjawSgLsQkBpgiSenL0rJiX5IfIgo+fqUC7Cn1pMNi3A+N Lax/XJ0GJtxSTf9kJ229AMcyO/Xw+gegB8s/z1eH4KhrMu5q+HyWzi71LsFGdyYWzMZX ZGtJxpANtrDgoOOWDH/QSV9mwDY6zGqntEIAUZcq7J9Ae0QbJNrp7xeBolivQxKY+l/v dXCw== X-Gm-Message-State: AOAM531tYuy0owVTzxymW6WxO9IYWadzxPw7vHVpwJ4nb72hCjlCC2Ij UDU435P5LS5kJ+Us3rm0300hBA== X-Google-Smtp-Source: ABdhPJw9xZUGD7sedtpr2wZO0uk5qeTLPkVOD4gbQBdsF2irncVIbC4KF0hJQDMYHvMkGBrFf32Buw== X-Received: by 2002:a17:90a:b103:: with SMTP id z3mr6719356pjq.23.1639669407379; Thu, 16 Dec 2021 07:43:27 -0800 (PST) Received: from [10.255.28.103] ([139.177.225.243]) by smtp.gmail.com with ESMTPSA id j1sm6944895pfu.47.2021.12.16.07.43.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Dec 2021 07:43:27 -0800 (PST) Message-ID: <917bb0a2-acb5-f2af-317b-73f1fa60f22d@bytedance.com> Date: Thu, 16 Dec 2021 23:43:23 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH 1/2] mm: add MemAvailable to per-node meminfo To: Greg KH Cc: akpm@linux-foundation.org, rafael@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, songmuchun@bytedance.com References: <20211216124655.32247-1-zhengqi.arch@bytedance.com> <20211216124655.32247-2-zhengqi.arch@bytedance.com> <34cc2f26-9fba-f7c6-5dae-d21498ccbe2d@bytedance.com> From: Qi Zheng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: B62DC120008 X-Stat-Signature: xrs3yk3ys5717b16rhdcuwerxks4fff3 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=TDw2lsfm; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf29.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com X-HE-Tag: 1639669406-797460 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 12/16/21 11:37 PM, Greg KH wrote: > On Thu, Dec 16, 2021 at 11:31:36PM +0800, Qi Zheng wrote: >> >> >> On 12/16/21 9:16 PM, Greg KH wrote: >>> On Thu, Dec 16, 2021 at 08:46:54PM +0800, Qi Zheng wrote: >>>> In /proc/meminfo, we can show the sum of all the available memory >>>> as "MemAvailable". Add the same counter also to per-node meminfo >>>> under /sys. >>>> >>>> With this counter, some processes that bind nodes can make some >>>> decisions by reading the "MemAvailable" of the corresponding nodes >>>> directly. >>>> >>>> Signed-off-by: Qi Zheng >>>> --- >>>> drivers/base/node.c | 4 ++++ >>>> include/linux/mm.h | 1 + >>>> include/linux/mmzone.h | 5 +++++ >>>> mm/page_alloc.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ >>>> 4 files changed, 59 insertions(+) >>>> >>>> diff --git a/drivers/base/node.c b/drivers/base/node.c >>>> index 87acc47e8951..deb2a7965ae4 100644 >>>> --- a/drivers/base/node.c >>>> +++ b/drivers/base/node.c >>>> @@ -375,8 +375,10 @@ static ssize_t node_read_meminfo(struct device *dev, >>>> struct sysinfo i; >>>> unsigned long sreclaimable, sunreclaimable; >>>> unsigned long swapcached = 0; >>>> + long available; >>>> si_meminfo_node(&i, nid); >>>> + available = si_mem_available_node(&i, nid); >>>> sreclaimable = node_page_state_pages(pgdat, NR_SLAB_RECLAIMABLE_B); >>>> sunreclaimable = node_page_state_pages(pgdat, NR_SLAB_UNRECLAIMABLE_B); >>>> #ifdef CONFIG_SWAP >>>> @@ -386,6 +388,7 @@ static ssize_t node_read_meminfo(struct device *dev, >>>> "Node %d MemTotal: %8lu kB\n" >>>> "Node %d MemFree: %8lu kB\n" >>>> "Node %d MemUsed: %8lu kB\n" >>>> + "Node %d MemAvailable: %8lu kB\n" >>> >>> You just changed a user/kernel api without documenting it anywhere, or >>> ensuring that you did not just break anything. >> >> Hi greg k-h, >> >> The MemAvailable has long existed in the /proc/meminfo, it's meaning >> has been described in the Documentation/filesystems/proc.rst. Since >> the semantics of per-node MemAvailable has not changed, so I did not >> add a new document description. > > This is not a proc file, it is in sysfs. > > And it violates all of the sysfs rules, and has all of the problems that > proc files have. So the worst of both worlds :( > >>> Also, this api is crazy, and not ok, please never add anything new to >>> it, it is broken as-is. >> >> The consideration of adding per-node MemAvailable is that some processes >> that bind nodes need this information to do some decisions. >> >> Now their approach is to read other information in per-node meminfo >> and /proc/sys/vm/watermark_scale_factor, and then approximate this >> value. With this counter, they can directly read >> /sys/devices/system/node/node*/meminfo to get the MemAvailable >> information of each node. >> >> And MemTotal, MemFree and SReclaimable(etc.) all have corresponding >> per-node versions, so I think that adding per-node MemAvailable might >> also make sense. :) > > Please no, I do not want new things added to this file, as you might > break parsers of this file. OK, Got it. Thank, Qi > > Also, again, you did not document this at all in Documentation/ABI/ so > for that reason alone it is not ok. > > thanks, > > greg k-h > -- Thanks, Qi