public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 3/4] memcg_lib.sh: Get rid of sleep 1 in signal_memcg_process
Date: Mon, 5 Sep 2016 14:50:20 +0200	[thread overview]
Message-ID: <20160905125020.GC14029@rei.lan> (raw)
In-Reply-To: <57C94968.5070609@oracle.com>

Hi!
> > This further brings down the test runtime down by another minute, now
> > the tests finish in about 30 second while we also assert that the
> > usage_in_bytes gets incremented as process consumes memory.
> 
> 50s vs 2m30s in my environment. Cool :)

:)

> >  signal_memcg_process()
> >  {
> > -	pid=$1
> > +	local pid=$1
> > +	local size=$2
> > +	local path=$3
> > +	local usage_start=$(cat ${path}memory.usage_in_bytes)
> 
> A side note.
> 
> In fact, in LTP we use 'local' in test cases written for '/bin/sh',
> whereas 'local' is not in POSIX. Maybe document this fact in the test
> writing guidelines?

Sure. FYI Debian has similar policy see 10.4 in
https://www.debian.org/doc/debian-policy/ch-files.html

> > +
> >  	kill -s USR1 $pid 2> /dev/null
> > -	sleep 1
> > +
> > +	if [ -z "$size" ]; then
> > +		return
> > +	fi
> > +
> > +	while kill -0 $pid 2> /dev/null; do
> > +		local usage=$(cat ${path}memory.usage_in_bytes)
> > +		local diff_a=$((usage_start - usage))
> > +		local diff_b=$((usage - usage_start))
> > +
> > +		if [ "$diff_a" -ge "$size" -o "$diff_b" -ge "$size" ]; then
> > +			return
> > +		fi
> > +
> > +		tst_sleep 100ms
> > +	done
> 
> Maybe add some limit on the number of checks? In case the process
> consumes less memory than in $size.

Will do.

> >  # Test hierarchical_memory_limit with enabling hierarchical accounting
> > diff --git a/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh
> > index ab86318..69dc874 100755
> > --- a/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh
> > +++ b/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh
> > @@ -34,7 +34,7 @@ TST_TOTAL=2
> >  # Test memory.usage_in_bytes
> >  testcase_1()
> >  {
> > -	test_mem_stat "--mmap-anon" $((PAGESIZE*1024)) \
> > +	test_mem_stat "--mmap-anon" $((PAGESIZE*1024)) $((PAGESIZE*1024)) \
> >  		"memory.usage_in_bytes" $((PAGESIZE*1024)) 0
> >  }
> >  
> > @@ -48,7 +48,7 @@ testcase_2()
> >  
> >  	echo $((PAGESIZE*2048)) > memory.limit_in_bytes
> >  	echo $((PAGESIZE*2048)) > memory.memsw.limit_in_bytes
> > -	test_mem_stat "--mmap-anon" $((PAGESIZE*1024)) \
> > +	test_mem_stat "--mmap-anon" $((PAGESIZE*1024)) $((PAGESIZE*1024)) \
> >  		"memory.memsw.usage_in_bytes" $((PAGESIZE*1024)) 0
> >  }
> 
> The above two calls need '0' substituted with 'false'.

My bad, I've missed that one.

-- 
Cyril Hrubis
chrubis@suse.cz

  parent reply	other threads:[~2016-09-05 12:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-01 17:18 [LTP] [PATCH 1/4] memcg_lib.sh: Print test number at test start Cyril Hrubis
2016-09-01 17:18 ` [LTP] [PATCH 2/4] memcg_lib.sh: Move all the kill -s XXX to functions Cyril Hrubis
2016-09-02  9:27   ` Stanislav Kholmanskikh
2016-09-01 17:18 ` [LTP] [PATCH 3/4] memcg_lib.sh: Get rid of sleep 1 in signal_memcg_process Cyril Hrubis
2016-09-02  9:42   ` Stanislav Kholmanskikh
2016-09-05 10:18     ` Jan Stancek
2016-09-05 12:10       ` Cyril Hrubis
2016-09-05 12:50     ` Cyril Hrubis [this message]
2016-09-07 10:19     ` Cyril Hrubis
2016-09-08  8:38       ` Stanislav Kholmanskikh
2016-09-01 17:18 ` [LTP] [PATCH 4/4] memcg_function_test.sh: Split Cyril Hrubis
2016-09-02 10:28   ` Stanislav Kholmanskikh

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=20160905125020.GC14029@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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