diff mbox

[i-g-t] lib: Conservatively include residue buffers in the available ram estimate

Message ID 20180619092055.7424-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson June 19, 2018, 9:20 a.m. UTC
Add any buffers reported by sysinfo to the estimate of available memory.
We do ask the kernel to purge it's caches before reporting sysinfo, but
a few remain that may be forced out by our test usage, so include them.
However, be conservative and only allow them to be swapped out.

References: https://bugs.freedesktop.org/show_bug.cgi?id=105967
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/intel_os.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Joonas Lahtinen June 19, 2018, 1:24 p.m. UTC | #1
Quoting Chris Wilson (2018-06-19 12:20:55)
> Add any buffers reported by sysinfo to the estimate of available memory.
> We do ask the kernel to purge it's caches before reporting sysinfo, but
> a few remain that may be forced out by our test usage, so include them.
> However, be conservative and only allow them to be swapped out.
> 
> References: https://bugs.freedesktop.org/show_bug.cgi?id=105967
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
diff mbox

Patch

diff --git a/lib/intel_os.c b/lib/intel_os.c
index 88a61f378..885ffdcec 100644
--- a/lib/intel_os.c
+++ b/lib/intel_os.c
@@ -105,6 +105,7 @@  intel_get_avail_ram_mb(void)
 
 	igt_assert(sysinfo(&sysinf) == 0);
 	retval = sysinf.freeram;
+	retval += min(sysinf.freeswap, sysinf.bufferram);
 	retval *= sysinf.mem_unit;
 #elif defined(_SC_PAGESIZE) && defined(_SC_AVPHYS_PAGES) /* Solaris */
 	long pagesize, npages;