public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Eryu Guan <guan@eryu.me>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH] common/rc: Include swap in memory size calculation
Date: Sun, 24 Oct 2021 22:09:36 +0800	[thread overview]
Message-ID: <YXVpIJe6Wz0leDqq@desktop> (raw)
In-Reply-To: <20211015183534.2193978-1-willy@infradead.org>

On Fri, Oct 15, 2021 at 07:35:34PM +0100, Matthew Wilcox (Oracle) wrote:
> _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()

This _available_memory_bytes() may also use _free_memory_bytes(), and
right now only generic/551 takes use of it, but generic/551 doesn't seem
to want to include swap.

Perhaps introduce a new helper to query free memory including swap space?

Thanks,
Eryu

      reply	other threads:[~2021-10-24 14:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=YXVpIJe6Wz0leDqq@desktop \
    --to=guan@eryu.me \
    --cc=fstests@vger.kernel.org \
    --cc=willy@infradead.org \
    /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