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 9C726C433FE for ; Fri, 7 Jan 2022 22:22:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1C796B0072; Fri, 7 Jan 2022 17:22:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CCC226B0073; Fri, 7 Jan 2022 17:22:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B93AE6B0074; Fri, 7 Jan 2022 17:22:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id A6DA36B0072 for ; Fri, 7 Jan 2022 17:22:25 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6A9E3181F6005 for ; Fri, 7 Jan 2022 22:22:25 +0000 (UTC) X-FDA: 79004915850.27.E3B1B1B Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by imf15.hostedemail.com (Postfix) with ESMTP id D9364A0004 for ; Fri, 7 Jan 2022 22:22:24 +0000 (UTC) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-251-JoaqXrwHMNK52GUaJf95PQ-1; Fri, 07 Jan 2022 22:22:22 +0000 X-MC-Unique: JoaqXrwHMNK52GUaJf95PQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Fri, 7 Jan 2022 22:22:21 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.026; Fri, 7 Jan 2022 22:22:21 +0000 From: David Laight To: 'Pintu Kumar' , "linux-kernel@vger.kernel.org" , "akpm@linux-foundation.org" , "linux-mm@kvack.org" , "ebiederm@xmission.com" , "christian.brauner@ubuntu.com" , "sfr@canb.auug.org.au" , "legion@kernel.org" , "sashal@kernel.org" , "gorcunov@gmail.com" , "chris.hyser@oracle.com" , "ccross@google.com" , "pcc@google.com" , "dave@stgolabs.net" , "caoxiaofeng@yulong.com" , "david@redhat.com" , "pintu.ping@gmail.com" , "vbabka@suse.cz" CC: "linux-api@vger.kernel.org" Subject: RE: [PATCH v2] sysinfo: include availram field in sysinfo struct Thread-Topic: [PATCH v2] sysinfo: include availram field in sysinfo struct Thread-Index: AQHYA/GqnIwLmHPdn0+moS7Mf5DX3axYIclA Date: Fri, 7 Jan 2022 22:22:21 +0000 Message-ID: <19cce51e24584c2a8090b618c580a0bd@AcuMS.aculab.com> References: <1641483250-18839-1-git-send-email-quic_pintu@quicinc.com> <1641578854-14232-1-git-send-email-quic_pintu@quicinc.com> In-Reply-To: <1641578854-14232-1-git-send-email-quic_pintu@quicinc.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D9364A0004 X-Stat-Signature: kwzxjczczej71cdan9nghutgoabfkhzg Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=aculab.com; spf=pass (imf15.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com X-HE-Tag: 1641594144-591491 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: From: Pintu Kumar > Sent: 07 January 2022 18:08 >=20 > 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. >=20 > One needs to parse MemAvailable field separately from /proc/meminfo > to get this info instead of directly getting if from sysinfo itself. >=20 > 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. >=20 ... > diff --git a/include/uapi/linux/sysinfo.h b/include/uapi/linux/sysinfo.h > index 435d5c2..fe84c6a 100644 > --- a/include/uapi/linux/sysinfo.h > +++ b/include/uapi/linux/sysinfo.h > @@ -19,7 +19,8 @@ struct sysinfo { > =09__kernel_ulong_t totalhigh;=09/* Total high memory size */ > =09__kernel_ulong_t freehigh;=09/* Available high memory size */ > =09__u32 mem_unit;=09=09=09/* Memory unit size in bytes */ > -=09char _f[20-2*sizeof(__kernel_ulong_t)-sizeof(__u32)];=09/* Padding: l= ibc5 uses this.. */ There are 4 pad bytes here on most 64bit architectures. > +=09__kernel_ulong_t availram;=09/* Memory available for allocation */ > +=09char _f[20-3*sizeof(__kernel_ulong_t)-sizeof(__u32)];=09/* Padding: l= ibc5 uses this.. */ > }; You've not compile-time tested the size of the structure. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)