All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <shuahkh@osg.samsung.com>
To: Yannick Brosseau <scientist@fb.com>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: kernel-team@fb.com
Subject: Re: [PATCH] selftests/vm: write strlen length instead of sizeof to nr_hugepages
Date: Mon, 27 Jun 2016 11:51:40 -0600	[thread overview]
Message-ID: <577167AC.3030706@osg.samsung.com> (raw)
In-Reply-To: <1466435241-7954-1-git-send-email-scientist@fb.com>

On 06/20/2016 09:07 AM, Yannick Brosseau wrote:
> When setting back the initial value to nr_hugepages, the
> test was writing a length sizeof of the string and checking
> that strlen was writen. Since those values are not the same,
> use strlen in both place instead.
> 
> Also make the error messages more explicit to help in future
> debugging.
> 
> Signed-off-by: Yannick Brosseau <scientist@fb.com>

Looks good. This is a good improvement. Will get this
into 4.8-rc1.

thanks,
-- Shuah

> ---
>  tools/testing/selftests/vm/compaction_test.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/vm/compaction_test.c b/tools/testing/selftests/vm/compaction_test.c
> index 932ff57..6d1437f 100644
> --- a/tools/testing/selftests/vm/compaction_test.c
> +++ b/tools/testing/selftests/vm/compaction_test.c
> @@ -101,7 +101,7 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
>  
>  	/* Start with the initial condition of 0 huge pages*/
>  	if (write(fd, "0", sizeof(char)) != sizeof(char)) {
> -		perror("Failed to write to /proc/sys/vm/nr_hugepages\n");
> +		perror("Failed to write 0 to /proc/sys/vm/nr_hugepages\n");
>  		goto close_fd;
>  	}
>  
> @@ -110,14 +110,14 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
>  	/* Request a large number of huge pages. The Kernel will allocate
>  	   as much as it can */
>  	if (write(fd, "100000", (6*sizeof(char))) != (6*sizeof(char))) {
> -		perror("Failed to write to /proc/sys/vm/nr_hugepages\n");
> +		perror("Failed to write 100000 to /proc/sys/vm/nr_hugepages\n");
>  		goto close_fd;
>  	}
>  
>  	lseek(fd, 0, SEEK_SET);
>  
>  	if (read(fd, nr_hugepages, sizeof(nr_hugepages)) <= 0) {
> -		perror("Failed to read from /proc/sys/vm/nr_hugepages\n");
> +		perror("Failed to re-read from /proc/sys/vm/nr_hugepages\n");
>  		goto close_fd;
>  	}
>  
> @@ -136,9 +136,9 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
>  	printf("No of huge pages allocated = %d\n",
>  	       (atoi(nr_hugepages)));
>  
> -	if (write(fd, initial_nr_hugepages, sizeof(initial_nr_hugepages))
> +	if (write(fd, initial_nr_hugepages, strlen(initial_nr_hugepages))
>  	    != strlen(initial_nr_hugepages)) {
> -		perror("Failed to write to /proc/sys/vm/nr_hugepages\n");
> +		perror("Failed to write value to /proc/sys/vm/nr_hugepages\n");
>  		goto close_fd;
>  	}
>  
> 

      reply	other threads:[~2016-06-27 17:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-20 15:07 [PATCH] selftests/vm: write strlen length instead of sizeof to nr_hugepages Yannick Brosseau
2016-06-27 17:51 ` Shuah Khan [this message]

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=577167AC.3030706@osg.samsung.com \
    --to=shuahkh@osg.samsung.com \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=scientist@fb.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.