public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: ltp-list@lists.sourceforge.net
Subject: [LTP] [PATCH] memcg_function_test: do a warmup before actual test
Date: Thu, 03 Nov 2011 14:45:59 +0100	[thread overview]
Message-ID: <4EB29B17.7090607@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1184 bytes --]


This test relies on getting correct rss number out of memory.stat.
Very rarely it fails and finds bigger number than expected,
for example:
memcg_function_test    6  TFAIL  :  rss=8192/4096

My assumption is that extra page is faulted in as result of
need for another stack page.

Documentation describes it as:
"rss - # of bytes of anonymous and swap cache memory."

This includes also stack pages. I intentionally modified
memcg_process' sigusr handler to grab few extra stack pages,
to confirm, that these indeed contribute to this number.

This patch adds a 'warmup' before actual test. The point
is to exercise the whole code path, so that any page fault,
which is unrelated to actual test occurs before process is
moved to target cgroup.

What happens now is:
spawn process
[NEW] signal it with SIGUSR1 (alloc)
[NEW] signal it with SIGUSR1 (free)
move it to cgroup
signal it with SIGUSR1 (alloc)
check rss in memory.stat
signal it with SIGUSR1 (free)
optionally check rss in memory.stat

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
  .../memcg/functional/memcg_function_test.sh        |   43 
++++++++++++++++++++
  1 files changed, 43 insertions(+), 0 deletions(-)



[-- Attachment #2: 0001-memcg_function_test-do-a-warmup-before-actual-test.patch --]
[-- Type: text/x-patch, Size: 1795 bytes --]

diff --git a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
index 73c1fa1..f281256 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
@@ -93,6 +93,34 @@ check_mem_stat()
 	result $pass "rss=$rss/$1"
 }
 
+warmup()
+{
+	pid=$1
+
+	case $cur_id in
+	"11"|"12"|"13")
+		#no warmp here, these are expected to fail
+		;;
+	*)
+		echo "Warming up for test: $cur_id, pid: $pid"
+		/bin/kill -s SIGUSR1 $pid 2> /dev/null
+		sleep 1
+		/bin/kill -s SIGUSR1 $pid 2> /dev/null
+		sleep 1
+
+		kill -0 $pid
+		if [ $? -ne 0 ]; then
+			result $FAIL "cur_id=$cur_id"
+			return 1
+		else
+			echo "Process is still here after warm up: $pid"
+		fi
+		;;
+	esac
+	return 0
+}
+
+
 # Run test cases which checks memory.stat after make
 # some memory allocation
 #
@@ -102,8 +130,15 @@ check_mem_stat()
 # $4 - check after free ?
 test_mem_stat()
 {
+	echo "Running $TEST_PATH/memcg_process $1 -s $2"
 	$TEST_PATH/memcg_process $1 -s $2 &
 	sleep 1
+
+	warmup $!
+	if [ $? -ne 0 ]; then
+		return
+	fi
+
 	echo $! > tasks
 	/bin/kill -s SIGUSR1 $! 2> /dev/null
 	sleep 1
@@ -235,8 +270,15 @@ test_subgroup()
 	echo $1 > memory.limit_in_bytes
 	echo $2 > subgroup/memory.limit_in_bytes
 
+	echo "Running $TEST_PATH/memcg_process --mmap-anon -s $PAGESIZE"
 	$TEST_PATH/memcg_process --mmap-anon -s $PAGESIZE &
 	sleep 1
+
+	warmup $!
+	if [ $? -ne 0 ]; then
+		return
+	fi
+
 	echo $! > tasks
 	/bin/kill -s SIGUSR1 $! 2> /dev/null
 	sleep 1
@@ -520,6 +562,7 @@ fi
 
 cleanup()
 {
+	killall -9 memcg_process 2>/dev/null
 	if [ -e /dev/memcg ]; then
 		umount /dev/memcg 2>/dev/null
 		rmdir /dev/memcg 2>/dev/null


[-- Attachment #3: Type: text/plain, Size: 169 bytes --]

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

             reply	other threads:[~2011-11-03 13:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-03 13:45 Jan Stancek [this message]
2011-11-11 14:04 ` [LTP] [PATCH] memcg_function_test: do a warmup before actual test Cyril Hrubis

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=4EB29B17.7090607@redhat.com \
    --to=jstancek@redhat.com \
    --cc=ltp-list@lists.sourceforge.net \
    /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