public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] common/rc: Include swap in memory size calculation
@ 2021-10-15 18:35 Matthew Wilcox (Oracle)
  2021-10-24 14:09 ` Eryu Guan
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Wilcox (Oracle) @ 2021-10-15 18:35 UTC (permalink / raw)
  To: fstests; +Cc: Matthew Wilcox (Oracle)

_free_memory_bytes() is used to determine whether it's reasonable to
create a tmpfs of a particular size.  Since tmpfs can swap (and some of
these tests are good for evaluating swapping), it makes sense to include
the free swap as well as the free memory in the calculation.

Use perl instead of awk because at least mawk will saturate at 2^31-1.
gawk doesn't, but that kind of dependency is a bad thing to require.
At least this eliminates a use of grep.

With this fixed, generic/273 generic/274 generic/275 generic/312
generic/320 generic/466 all now pass on tmpfs instead of being skipped.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 common/rc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/rc b/common/rc
index 7f693d39..f84d3873 100644
--- a/common/rc
+++ b/common/rc
@@ -966,7 +966,7 @@ _scratch_pool_mkfs()
 # Return the amount of free memory available on the system
 _free_memory_bytes()
 {
-    free -b | grep ^Mem | awk '{print $4}'
+    free -b | perl -lane '$F[0] =~ /^[A-Z]/ and $total += $F[3]; END { print $total }'
 }
 
 _available_memory_bytes()
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-24 14:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-15 18:35 [PATCH] common/rc: Include swap in memory size calculation Matthew Wilcox (Oracle)
2021-10-24 14:09 ` Eryu Guan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox