All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masayoshi Mizuma <msys.mizuma@gmail.com>
To: fstests@vger.kernel.org
Cc: Masayoshi Mizuma <msys.mizuma@gmail.com>,
	Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Subject: [PATCH] generic/551: Adjust the size argument for aio-dio-write-verify
Date: Mon, 18 Nov 2019 12:40:37 -0500	[thread overview]
Message-ID: <20191118174037.363-1-msys.mizuma@gmail.com> (raw)

From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>

generic/551 sometimes fails because it's killed by OOM killer.
That is because aio-dio-write-verify, which is called by
generic/551, tries to allocate memory even though the total
allocation size exceeds the available memory.

aio-dio-write-verify allocates memory according to the 'size'
argument, and generic/551 passes the argument.

Stop adding the argument when the total size is exceeds
the available memory.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
---
 common/rc         | 11 +++++++++++
 tests/generic/551 |  6 ++++++
 2 files changed, 17 insertions(+)

diff --git a/common/rc b/common/rc
index b988e912..3494426e 100644
--- a/common/rc
+++ b/common/rc
@@ -910,6 +910,17 @@ _free_memory_bytes()
     free -b | grep ^Mem | awk '{print $4}'
 }
 
+_available_memory_bytes()
+{
+    nf=`free -b | grep ^Mem | awk '{print NF}'`
+    if [[ nf -lt 7 ]]; then
+        # Doesn't have available field. Fallback.
+        _free_memory_bytes
+    else
+        free -b | grep ^Mem | awk '{print $7}'
+    fi
+}
+
 # Create fs of certain size on scratch device
 # _scratch_mkfs_sized <size in bytes> [optional blocksize]
 _scratch_mkfs_sized()
diff --git a/tests/generic/551 b/tests/generic/551
index a2a5b51d..a0dc9cd7 100755
--- a/tests/generic/551
+++ b/tests/generic/551
@@ -55,12 +55,18 @@ do_test()
 	local size
 	local off
 	local truncsize
+	local total_size=0
+	local avail_mem=`_available_memory_bytes`
 
 	# the number of AIO write operation
 	num_oper=$((RANDOM % 64 + 1))
 
 	for ((i=0; i<num_oper; i++)); do
 		size=$(((RANDOM % max_io_size_b + 1) * diosize))
+		total_size=$((total_size + size*2))
+		if [[ $total_size -ge $avail_mem ]]; then
+			break
+		fi
 		off=$((RANDOM % max_io_size_b * diosize))
 		oper_list="$oper_list -a size=$size,off=$off"
 	done
-- 
2.18.1


                 reply	other threads:[~2019-11-18 17:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20191118174037.363-1-msys.mizuma@gmail.com \
    --to=msys.mizuma@gmail.com \
    --cc=fstests@vger.kernel.org \
    --cc=m.mizuma@jp.fujitsu.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.