From: Pintu Agarwal <pintu.ping@gmail.com>
To: David Laight <David.Laight@aculab.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>,
Pintu Kumar <quic_pintu@quicinc.com>,
open list <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm <linux-mm@kvack.org>,
"ebiederm@xmission.com" <ebiederm@xmission.com>,
"christian.brauner@ubuntu.com" <christian.brauner@ubuntu.com>,
"sfr@canb.auug.org.au" <sfr@canb.auug.org.au>,
"legion@kernel.org" <legion@kernel.org>,
"sashal@kernel.org" <sashal@kernel.org>,
"chris.hyser@oracle.com" <chris.hyser@oracle.com>,
"ccross@google.com" <ccross@google.com>,
"pcc@google.com" <pcc@google.com>,
"dave@stgolabs.net" <dave@stgolabs.net>,
"caoxiaofeng@yulong.com" <caoxiaofeng@yulong.com>,
"david@redhat.com" <david@redhat.com>
Subject: Re: [PATCH] sysinfo: include availram field in sysinfo struct
Date: Thu, 6 Jan 2022 23:29:02 +0530 [thread overview]
Message-ID: <CAOuPNLjh+OhnqqGWWj015eQmwGqp96iu2zycVq4sM+K7JjxumQ@mail.gmail.com> (raw)
In-Reply-To: <14316cf852784a32b5214119a9d976cf@AcuMS.aculab.com>
On Thu, 6 Jan 2022 at 23:12, David Laight <David.Laight@aculab.com> wrote:
>
> From: Pintu Agarwal
> > Sent: 06 January 2022 16:50
> >
> > On Thu, 6 Jan 2022 at 21:41, Cyrill Gorcunov <gorcunov@gmail.com> 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 <quic_pintu@quicinc.com>
> > > > Signed-off-by: Pintu Agarwal <pintu.ping@gmail.com>
> > > > ---
> > > > 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.
>
> You can't add a field in the middle of a UAPI structure.
> It breaks compatibility for old binaries.
>
> Depending on the interface definition you may be able to add one at the end.
>
oh okay thank you for your feedback. I will move to the end and check again.
But my doubt is, whether I should move before this
char _f[20-2*sizeof(__kernel_ulong_t)-sizeof(__u32)];
or after this ?
Also, I could not understand what this is for ?
Do we need to update this since sture is changed ?
next prev parent reply other threads:[~2022-01-06 17:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-06 15:34 [PATCH] sysinfo: include availram field in sysinfo struct Pintu Kumar
2022-01-06 16:11 ` Cyrill Gorcunov
2022-01-06 16:49 ` Pintu Agarwal
2022-01-06 17:27 ` Cyrill Gorcunov
2022-01-07 12:04 ` Christian Brauner
2022-01-07 13:44 ` Pintu Agarwal
2022-01-07 16:58 ` Vlastimil Babka
2022-01-07 17:47 ` Pintu Agarwal
2022-01-07 22:18 ` David Laight
2022-01-07 19:51 ` Cyrill Gorcunov
2022-01-06 17:41 ` David Laight
2022-01-06 17:59 ` Pintu Agarwal [this message]
2022-01-06 19:20 ` Eric W. Biederman
2022-01-07 18:07 ` [PATCH v2] " Pintu Kumar
2022-01-07 21:01 ` Cyrill Gorcunov
2022-01-08 16:24 ` Pintu Agarwal
2022-01-10 8:11 ` Cyrill Gorcunov
2022-01-07 22:22 ` David Laight
2022-01-08 16:53 ` Pintu Agarwal
2022-01-08 22:35 ` David Laight
2022-01-10 14:55 ` Pintu Agarwal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOuPNLjh+OhnqqGWWj015eQmwGqp96iu2zycVq4sM+K7JjxumQ@mail.gmail.com \
--to=pintu.ping@gmail.com \
--cc=David.Laight@aculab.com \
--cc=akpm@linux-foundation.org \
--cc=caoxiaofeng@yulong.com \
--cc=ccross@google.com \
--cc=chris.hyser@oracle.com \
--cc=christian.brauner@ubuntu.com \
--cc=dave@stgolabs.net \
--cc=david@redhat.com \
--cc=ebiederm@xmission.com \
--cc=gorcunov@gmail.com \
--cc=legion@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pcc@google.com \
--cc=quic_pintu@quicinc.com \
--cc=sashal@kernel.org \
--cc=sfr@canb.auug.org.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).