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 3E985C433F5 for ; Thu, 6 Jan 2022 16:50:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 866366B0071; Thu, 6 Jan 2022 11:50:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8140E6B0072; Thu, 6 Jan 2022 11:50:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B4856B0073; Thu, 6 Jan 2022 11:50:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id 59C8C6B0071 for ; Thu, 6 Jan 2022 11:50:08 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 05E2D181AF5EA for ; Thu, 6 Jan 2022 16:50:08 +0000 (UTC) X-FDA: 79000449696.31.7CF63B2 Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) by imf27.hostedemail.com (Postfix) with ESMTP id 52E0140014 for ; Thu, 6 Jan 2022 16:50:06 +0000 (UTC) Received: by mail-yb1-f175.google.com with SMTP id y130so9101775ybe.8 for ; Thu, 06 Jan 2022 08:50:07 -0800 (PST) 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; bh=WzPx2KD6yStcW6nRPoF0Fgqsc5KQDTzeS8k9qPSrfEI=; b=OH9W6LBtCG37NkHK6GpDpHDcEo81EoyG/qeL+Mrh8imbEAQgT+CbZDpKWDw5VN7WQA Sg9njO7IjbAzzrztX4Y2viSJF6FWiq7UBNj/VBtMZlvcycQh8gkSXN63xvjinOyGVlep PIHmpXjyt+qX53Jbg376VARVEusuisI9S+rdeP2r+2Uf6Beq7vQlOxUVA6t6azgkGxd9 nnvLWrGKUyp7Ay+60vdm3OXGHVKh+lPbd8maPGsBaT7yI4+FbIxsenCaViResYZQYZnA 7UES+4Gvv6UZ2Y9GEPHJYPLiJn1IDwmXcitUCgkN3FD0SzGDZvUvuXtbv2vO3RvFhLnF B4Ag== 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; bh=WzPx2KD6yStcW6nRPoF0Fgqsc5KQDTzeS8k9qPSrfEI=; b=VtgRKL17VQZQQTnz4S7ZWEkhMrAcB8+cClx3c6UKrMCrNVCvLpnhJJdgxU94enmPcA 9leMPSe8oCRB/iPSaIYPqENgVc+A5GfNJ+39UlJNhdGrNZP0XBm2A9iT+9c63CkFbIYe dAB1jrLFTYJrZewc3136Pv3P1DOliphPQEmhzcB52my2yA1kRLX6T/tTKCLsH48NubTY Yb70CkGNfqnsOxrc/mM/gEaaAQwuJRiRiapRiWKcgs4DYL6JYKVmwIyKsDWNfSPh94Pp eNyuDqisi/DtUHrhDqjC2i6hAIeDIldBh3ex/iVxPuv7lnn+i5LANxx9SNfhfiPv8uKP JurQ== X-Gm-Message-State: AOAM533FfogGI3igkJLuKdPhTI7B0B3ayShrTvp+I1X0L1YvU0TY7izm TiOtW0zvnQd7H/1bEz7BEcjPw7tBIXYXV4sIY2M= X-Google-Smtp-Source: ABdhPJznAFEAcdv14txnSN76RN7NFQyxcPEpL12uDYscup8TH0C4bfwnhxPPbMUBiD/e29JLTuZ3T3jof3Yp5enmM88= X-Received: by 2002:a05:6902:1549:: with SMTP id r9mr37910993ybu.190.1641487806785; Thu, 06 Jan 2022 08:50:06 -0800 (PST) MIME-Version: 1.0 References: <1641483250-18839-1-git-send-email-quic_pintu@quicinc.com> In-Reply-To: From: Pintu Agarwal Date: Thu, 6 Jan 2022 22:19:55 +0530 Message-ID: Subject: Re: [PATCH] sysinfo: include availram field in sysinfo struct To: Cyrill Gorcunov Cc: Pintu Kumar , open list , Andrew Morton , linux-mm , ebiederm@xmission.com, christian.brauner@ubuntu.com, sfr@canb.auug.org.au, legion@kernel.org, sashal@kernel.org, chris.hyser@oracle.com, ccross@google.com, pcc@google.com, dave@stgolabs.net, caoxiaofeng@yulong.com, david@redhat.com Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OH9W6LBt; spf=pass (imf27.hostedemail.com: domain of pintu.ping@gmail.com designates 209.85.219.175 as permitted sender) smtp.mailfrom=pintu.ping@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Queue-Id: 52E0140014 X-Stat-Signature: ddyw1sjh9411mnesmk6y59eec1ccb95w X-Rspamd-Server: rspam04 X-HE-Tag: 1641487806-986331 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 Thu, 6 Jan 2022 at 21:41, Cyrill Gorcunov wrote: > > On Thu, Jan 06, 2022 at 09:04:10PM +0530, Pintu Kumar wrote: > > The sysinfo member does not have any "available ram" field and > > the bufferram field is not much helpful either, to get a rough > > estimate of available ram needed for allocation. > > > > One needs to parse MemAvailable field separately from /proc/meminfo > > to get this info instead of directly getting if from sysinfo itself. > > > > Thus, this patch introduce a new field as availram in sysinfo > > so that all the info total/free/available can be retrieved from > > one place itself. > > > > There are couple of places in kernel as well where this can be improved. > > For example: > > In fs/proc/meminfo.c: > > meminfo_proc_show: > > si_meminfo(&i); > > available = si_mem_available(); > > Now with this change the second call be avoided. > > Thus, we can directly do: > > show_val_kb(m, "MemAvailable: ", i.availram); > > > > Note, this also requires update in procfs for free and other commands. > > Like in free command as well we frist call sysinfo then again parse > > /proc/meminfo to get available field. > > This can be avoided too with higher kernel version. > > > > A sample output with single sysinfo call is shown below: > > Total RAM: 248376 kB > > Free RAM: 231540 kB > > Avail RAM: 230448 kB > > > > Signed-off-by: Pintu Kumar > > Signed-off-by: Pintu Agarwal > > --- > > include/uapi/linux/sysinfo.h | 1 + > > kernel/sys.c | 4 ++++ > > mm/page_alloc.c | 2 ++ > > 3 files changed, 7 insertions(+) > > > > diff --git a/include/uapi/linux/sysinfo.h b/include/uapi/linux/sysinfo.h > > index 435d5c2..6e77e90 100644 > > --- a/include/uapi/linux/sysinfo.h > > +++ b/include/uapi/linux/sysinfo.h > > @@ -12,6 +12,7 @@ struct sysinfo { > > __kernel_ulong_t freeram; /* Available memory size */ > > __kernel_ulong_t sharedram; /* Amount of shared memory */ > > __kernel_ulong_t bufferram; /* Memory used by buffers */ > > + __kernel_ulong_t availram; /* Memory available for allocation */ > > __kernel_ulong_t totalswap; /* Total swap space size */ > > __kernel_ulong_t freeswap; /* swap space still available */ > > __u16 procs; /* Number of current processes */ > > Hi! Sorry, but I don't understand -- the sysinfo structure seems to > be part of user API, no? Don't we break it up here? Yes, the corresponding user space header /usr/include/linux/sysinfo.h also needs to be updated. When we generate the kernel header it will be updated automatically.