Skip to contentSkip to conversation

kselftest: fix OOM in memory compaction test

PATCH In review Arnd Bergmann 2 participants 3 messages Jan 9, 2018 – Jan 10, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kselftest: fix OOM in memory compaction test

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 at vger.kernel.org
Reported-by Naresh Kamboju <naresh.kamboju at linaro.org>
Signed-off-by Arnd Bergmann <arnd at arndb.de>
---
 tools/testing/selftests/vm/compaction_test.c | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/vm/compaction_test.c +2 -0
index a65b016d4c13..1097f04e4d80 100644
@@ -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");
Signature · 6 lines
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#1 lore raw
Quoted 22 lines · Arnd Bergmann

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 at vger.kernel.org
Reported-by Naresh Kamboju <naresh.kamboju at linaro.org>
Signed-off-by Arnd Bergmann <arnd at arndb.de>
---
 tools/testing/selftests/vm/compaction_test.c | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/vm/compaction_test.c +0 -0
index a65b016d4c13..1097f04e4d80 100644

tools/testing/selftests/vm/compaction_test.c int check_compaction(unsigned long mem_free, unsigned int hugepage_size) · line 144

Quoted 8 lines
tools/testing/selftests/vm/compaction_test.c +2 -0
@@ -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
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#2 lore raw
Quoted 25 lines · Shuah Khan
Quoted 24 lines · Arnd Bergmann

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 at vger.kernel.org
Reported-by Naresh Kamboju <naresh.kamboju at linaro.org>
Signed-off-by Arnd Bergmann <arnd at arndb.de>
---
 tools/testing/selftests/vm/compaction_test.c | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/vm/compaction_test.c +0 -0
index a65b016d4c13..1097f04e4d80 100644
@@ -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)));
 
Quoted 10 lines

tools/testing/selftests/vm/compaction_test.c int check_compaction(unsigned long mem_free, unsigned int hugepage_size) · line 144

Quoted 6 lines
tools/testing/selftests/vm/compaction_test.c +2 -0
+	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

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html