summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2018-01-09 17:26:24 +0100
committerShuah Khan <shuahkh@osg.samsung.com>2018-01-10 16:22:47 +0100
commit4c1baad223906943b595a887305f2e8124821dad (patch)
tree47b232153aab074ebc41a6bb2bc71fd31ae8f02f /tools
parentselftests: seccomp: fix compile error seccomp_bpf (diff)
downloadlinux-4c1baad223906943b595a887305f2e8124821dad.tar.xz
linux-4c1baad223906943b595a887305f2e8124821dad.zip
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@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> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/vm/compaction_test.c2
1 files changed, 2 insertions, 0 deletions
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");