From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752065AbcF0Rvn (ORCPT ); Mon, 27 Jun 2016 13:51:43 -0400 Received: from lists.s-osg.org ([54.187.51.154]:39208 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbcF0Rvm (ORCPT ); Mon, 27 Jun 2016 13:51:42 -0400 Subject: Re: [PATCH] selftests/vm: write strlen length instead of sizeof to nr_hugepages To: Yannick Brosseau , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org References: <1466435241-7954-1-git-send-email-scientist@fb.com> Cc: kernel-team@fb.com From: Shuah Khan Message-ID: <577167AC.3030706@osg.samsung.com> Date: Mon, 27 Jun 2016 11:51:40 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <1466435241-7954-1-git-send-email-scientist@fb.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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; > } > >