git: 1b1901620028 - stable/13 - linuxkpi: Add `freeram` and `freehigh` to `struct sysinfo`

From: Jean-Sébastien Pédron <dumbbell_at_FreeBSD.org>
Date: Thu, 16 Feb 2023 11:56:10 UTC
The branch stable/13 has been updated by dumbbell (ports committer):

URL: https://cgit.FreeBSD.org/src/commit/?id=1b1901620028a316e55d907069b85a2f077e6db3

commit 1b1901620028a316e55d907069b85a2f077e6db3
Author:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2023-01-02 20:57:35 +0000
Commit:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2023-02-16 11:55:16 +0000

    linuxkpi: Add `freeram` and `freehigh` to `struct sysinfo`
    
    The struct layout is modified with this commit because new fields are
    added in the middle, keeping original Linux order.
    
    Reviewed by:    manu
    Approved by:    manu
    Differential Revision:  https://reviews.freebsd.org/D37932
    
    (cherry picked from commit e400b695991bf3f336e9cbe39e400943d8b1d676)
---
 sys/compat/linuxkpi/common/include/linux/mm.h | 8 +++++---
 sys/compat/linuxkpi/common/src/linux_page.c   | 2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/mm.h b/sys/compat/linuxkpi/common/include/linux/mm.h
index 43d1cb0f8aad..be3890edb5cf 100644
--- a/sys/compat/linuxkpi/common/include/linux/mm.h
+++ b/sys/compat/linuxkpi/common/include/linux/mm.h
@@ -144,9 +144,11 @@ struct vm_operations_struct {
 };
 
 struct sysinfo {
-	uint64_t totalram;
-	uint64_t totalhigh;
-	uint32_t mem_unit;
+	uint64_t totalram;	/* Total usable main memory size */
+	uint64_t freeram;	/* Available memory size */
+	uint64_t totalhigh;	/* Total high memory size */
+	uint64_t freehigh;	/* Available high memory size */
+	uint32_t mem_unit;	/* Memory unit size in bytes */
 };
 
 /*
diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c
index 10172d341e95..a82a8c45be01 100644
--- a/sys/compat/linuxkpi/common/src/linux_page.c
+++ b/sys/compat/linuxkpi/common/src/linux_page.c
@@ -79,7 +79,9 @@ void
 si_meminfo(struct sysinfo *si)
 {
 	si->totalram = physmem;
+	si->freeram = vm_free_count();
 	si->totalhigh = 0;
+	si->freehigh = 0;
 	si->mem_unit = PAGE_SIZE;
 }