linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Vlastimil Babka' <vbabka@suse.cz>,
	Pintu Agarwal <pintu.ping@gmail.com>,
	Christian Brauner <christian.brauner@ubuntu.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>,
	"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>,
	Linux API <linux-api@vger.kernel.org>
Subject: RE: [PATCH] sysinfo: include availram field in sysinfo struct
Date: Fri, 7 Jan 2022 22:18:30 +0000	[thread overview]
Message-ID: <c6abe87e4c284248985ea039428ab3fe@AcuMS.aculab.com> (raw)
In-Reply-To: <91d662f1-baf6-1114-f237-a66ebc164009@suse.cz>

> > These are the header changes for quick look:
> > {{{
> > diff --git a/include/uapi/linux/sysinfo.h b/include/uapi/linux/sysinfo.h
> > index 6e77e90..fe84c6a 100644
> > --- a/include/uapi/linux/sysinfo.h
> > +++ b/include/uapi/linux/sysinfo.h
> > @@ -12,7 +12,6 @@ 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 */
> > @@ -20,7 +19,8 @@ struct sysinfo {
> >         __kernel_ulong_t totalhigh;     /* Total high memory size */
> >         __kernel_ulong_t freehigh;      /* Available high memory size */
> >         __u32 mem_unit;                 /* Memory unit size in bytes */
> > -       char _f[20-2*sizeof(__kernel_ulong_t)-sizeof(__u32)];   /*
> > Padding: libc5 uses this.. */
> > +       __kernel_ulong_t availram;      /* Memory available for allocation */
> > +       char _f[20-3*sizeof(__kernel_ulong_t)-sizeof(__u32)];   /*
> > Padding: libc5 uses this.. */
> >  };
> > }}}
> >
> > If this is fine, I will push the new patch set.
> 
> Please CC linux-api@vger.kernel.org on the new posting.

That is probably still broken.
If __kernel_ulong_t is 64bit there is architecture
dependant padding after mem_unit.

In particular a 32bit x86 app running on a 64bit kernel
will probably see the wrong layout.

You definitely need a compile-time assert on the total structure size.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  parent reply	other threads:[~2022-01-07 22:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1641483250-18839-1-git-send-email-quic_pintu@quicinc.com>
     [not found] ` <YdcUttZWaqYQpR1K@grain>
     [not found]   ` <CAOuPNLifYFPU4Gt2+1sOSsYNNLQq7U2aGVaYknrhaMc-CVx8vg@mail.gmail.com>
     [not found]     ` <Ydcmk+WaBWKlLkAw@grain>
     [not found]       ` <20220107120451.z2eqru2tm5mlhla3@wittgenstein>
     [not found]         ` <CAOuPNLiJZu_HJQ+Hf5BJOgmT+v7DT96VLkiXrfx0MJQrkD3rSw@mail.gmail.com>
2022-01-07 16:58           ` [PATCH] sysinfo: include availram field in sysinfo struct Vlastimil Babka
2022-01-07 17:47             ` Pintu Agarwal
2022-01-07 22:18             ` David Laight [this message]
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=c6abe87e4c284248985ea039428ab3fe@AcuMS.aculab.com \
    --to=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-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pcc@google.com \
    --cc=pintu.ping@gmail.com \
    --cc=quic_pintu@quicinc.com \
    --cc=sashal@kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=vbabka@suse.cz \
    /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).