mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kselftest: fix OOM in memory compaction test
@ 2018-01-09 16:26 Arnd Bergmann
  2018-01-09 16:47 ` Shuah Khan
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2018-01-09 16:26 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Sri Jayaramappa, Arnd Bergmann, stable, linux-kselftest, linux-kernel

Running the compaction_test sometimes results in out-of-memory
failures. When I debugged this, it turned out that the code to
reset the number of hugepages to the initial value is simply
broken since we write into an open sysctl file descriptor
multiple times without seeking back to the start.

Adding the lseek here fixes the problem.

Cc: stable@vger.kernel.org
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Link: https://bugs.linaro.org/show_bug.cgi?id=3145
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 tools/testing/selftests/vm/compaction_test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/vm/compaction_test.c b/tools/testing/selftests/vm/compaction_test.c
index a65b016d4c13..1097f04e4d80 100644
--- a/tools/testing/selftests/vm/compaction_test.c
+++ b/tools/testing/selftests/vm/compaction_test.c
@@ -137,6 +137,8 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
 	printf("No of huge pages allocated = %d\n",
 	       (atoi(nr_hugepages)));
 
+	lseek(fd, 0, SEEK_SET);
+
 	if (write(fd, initial_nr_hugepages, strlen(initial_nr_hugepages))
 	    != strlen(initial_nr_hugepages)) {
 		perror("Failed to write value to /proc/sys/vm/nr_hugepages\n");
-- 
2.9.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kselftest: fix OOM in memory compaction test
  2018-01-09 16:26 [PATCH] kselftest: fix OOM in memory compaction test Arnd Bergmann
@ 2018-01-09 16:47 ` Shuah Khan
  2018-01-10 17:04   ` Shuah Khan
  0 siblings, 1 reply; 3+ messages in thread
From: Shuah Khan @ 2018-01-09 16:47 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Sri Jayaramappa, stable, linux-kselftest, linux-kernel,
	Shuah Khan, Shuah Khan

On 01/09/2018 09:26 AM, Arnd Bergmann wrote:
> Running the compaction_test sometimes results in out-of-memory
> failures. When I debugged this, it turned out that the code to
> reset the number of hugepages to the initial value is simply
> broken since we write into an open sysctl file descriptor
> multiple times without seeking back to the start.
> 
> Adding the lseek here fixes the problem.
> 
> Cc: stable@vger.kernel.org
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Link: https://bugs.linaro.org/show_bug.cgi?id=3145
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  tools/testing/selftests/vm/compaction_test.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/testing/selftests/vm/compaction_test.c b/tools/testing/selftests/vm/compaction_test.c
> index a65b016d4c13..1097f04e4d80 100644
> --- a/tools/testing/selftests/vm/compaction_test.c
> +++ b/tools/testing/selftests/vm/compaction_test.c
> @@ -137,6 +137,8 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
>  	printf("No of huge pages allocated = %d\n",
>  	       (atoi(nr_hugepages)));
>  
> +	lseek(fd, 0, SEEK_SET);
> +
>  	if (write(fd, initial_nr_hugepages, strlen(initial_nr_hugepages))
>  	    != strlen(initial_nr_hugepages)) {
>  		perror("Failed to write value to /proc/sys/vm/nr_hugepages\n");
> 


Thanks for the patch. I will get this into 4.16-rc1

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kselftest: fix OOM in memory compaction test
  2018-01-09 16:47 ` Shuah Khan
@ 2018-01-10 17:04   ` Shuah Khan
  0 siblings, 0 replies; 3+ messages in thread
From: Shuah Khan @ 2018-01-10 17:04 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Sri Jayaramappa, stable, linux-kselftest, linux-kernel,
	Shuah Khan, Shuah Khan

On 01/09/2018 09:47 AM, Shuah Khan wrote:
> On 01/09/2018 09:26 AM, Arnd Bergmann wrote:
>> Running the compaction_test sometimes results in out-of-memory
>> failures. When I debugged this, it turned out that the code to
>> reset the number of hugepages to the initial value is simply
>> broken since we write into an open sysctl file descriptor
>> multiple times without seeking back to the start.
>>
>> Adding the lseek here fixes the problem.
>>
>> Cc: stable@vger.kernel.org
>> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
>> Link: https://bugs.linaro.org/show_bug.cgi?id=3145
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>> ---
>>  tools/testing/selftests/vm/compaction_test.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/tools/testing/selftests/vm/compaction_test.c b/tools/testing/selftests/vm/compaction_test.c
>> index a65b016d4c13..1097f04e4d80 100644
>> --- a/tools/testing/selftests/vm/compaction_test.c
>> +++ b/tools/testing/selftests/vm/compaction_test.c
>> @@ -137,6 +137,8 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
>>  	printf("No of huge pages allocated = %d\n",
>>  	       (atoi(nr_hugepages)));
>>  
>> +	lseek(fd, 0, SEEK_SET);
>> +
>>  	if (write(fd, initial_nr_hugepages, strlen(initial_nr_hugepages))
>>  	    != strlen(initial_nr_hugepages)) {
>>  		perror("Failed to write value to /proc/sys/vm/nr_hugepages\n");
>>
> 
> 
> Thanks for the patch. I will get this into 4.16-rc1
> 

Applied to linux-kselftest next for 4.16-rc1

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-10 17:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-09 16:26 [PATCH] kselftest: fix OOM in memory compaction test Arnd Bergmann
2018-01-09 16:47 ` Shuah Khan
2018-01-10 17:04   ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®