* [LTP] [PATCH] memcg_function_test: do a warmup before actual test
@ 2011-11-03 13:45 Jan Stancek
2011-11-11 14:04 ` Cyril Hrubis
0 siblings, 1 reply; 2+ messages in thread
From: Jan Stancek @ 2011-11-03 13:45 UTC (permalink / raw)
To: ltp-list
[-- 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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH] memcg_function_test: do a warmup before actual test
2011-11-03 13:45 [LTP] [PATCH] memcg_function_test: do a warmup before actual test Jan Stancek
@ 2011-11-11 14:04 ` Cyril Hrubis
0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2011-11-11 14:04 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp-list
Hi!
Commited thanks.
> What happens now is:
> spawn process
> [NEW] signal it with SIGUSR1 (alloc)
> [NEW] signal it with SIGUSR1 (free)
Doing malloc() and/or free() from signal handler is simply wrong and
will lead to memory corruptions or deadlocks someday. Here it may work
most of the time as you aren't doing anything in the main program loop,
but still correct way of doing this is to create pipe and sleep on the
file decriptor.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-11-11 13:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-03 13:45 [LTP] [PATCH] memcg_function_test: do a warmup before actual test Jan Stancek
2011-11-11 14:04 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox