linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Rientjes <rientjes@google.com>
To: Ben Hutchings <ben@decadent.org.uk>
Cc: Shuah Khan <shuahkh@osg.samsung.com>,
	linux-api@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH selftests 5/6] selftests: vm: Try harder to allocate huge pages
Date: Tue, 10 Nov 2015 12:01:48 -0800 (PST)	[thread overview]
Message-ID: <alpine.DEB.2.10.1511101159480.29993@chino.kir.corp.google.com> (raw)
In-Reply-To: <1446334747.2595.19.camel@decadent.org.uk>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1902 bytes --]

On Sat, 31 Oct 2015, Ben Hutchings wrote:

> If we need to increase the number of huge pages, drop caches first
> to reduce fragmentation and then check that we actually allocated
> as many as we wanted.A A Retry once if that doesn't work.
> 
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> ---
> The test always fails for me in a 1 GB VM without this.
> 
> Ben.
> 
> A tools/testing/selftests/vm/run_vmtests | 15 ++++++++++++++-
> A 1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
> index 9179ce8..97ed1b2 100755
> --- a/tools/testing/selftests/vm/run_vmtests
> +++ b/tools/testing/selftests/vm/run_vmtests
> @@ -20,13 +20,26 @@ done < /proc/meminfo
> A if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then
> A 	nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
> A 	needpgs=`expr $needmem / $pgsize`
> -	if [ $freepgs -lt $needpgs ]; then
> +	tries=2
> +	while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
> A 		lackpgs=$(( $needpgs - $freepgs ))
> +		echo 3 > /proc/sys/vm/drop_caches
> A 		echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
> A 		if [ $? -ne 0 ]; then
> A 			echo "Please run this test as root"
> A 			exit 1
> A 		fi
> +		while read name size unit; do
> +			if [ "$name" = "HugePages_Free:" ]; then
> +				freepgs=$size
> +			fi
> +		done < /proc/meminfo
> +		tries=$((tries - 1))
> +	done
> +	if [ $freepgs -lt $needpgs ]; then
> +		printf "Not enough huge pages available (%d < %d)\n" \
> +		A A A A A A A $freepgs $needpgs
> +		exit 1
> A 	fi
> A else
> A 	echo "no hugetlbfs support in kernel?"
> 

I know this patch is in -mm and hasn't been merged by Linus yet, but I'm 
wondering why the multiple /proc/sys/vm/drop_caches is helping?  Would it 
simply suffice to put a sleep in there instead or is drop_caches actually 
doing something useful a second time around?

  reply	other threads:[~2015-11-10 20:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1446334510.2595.13.camel@decadent.org.uk>
2015-10-31 23:39 ` Ben Hutchings
2015-11-10 20:01   ` David Rientjes [this message]
2015-11-10 20:05     ` Shuah Khan
2015-11-10 21:48     ` Ben Hutchings
2015-11-11  1:11       ` David Rientjes

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=alpine.DEB.2.10.1511101159480.29993@chino.kir.corp.google.com \
    --to=rientjes@google.com \
    --cc=ben@decadent.org.uk \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shuahkh@osg.samsung.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox