Skip to content

Commit 7dd2dbd

Browse files
arndbgregkh
authored andcommitted
kselftest: fix OOM in memory compaction test
commit 4c1baad upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9c2e7a0 commit 7dd2dbd

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎tools/testing/selftests/vm/compaction_test.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
137137
printf("No of huge pages allocated = %d\n",
138138
(atoi(nr_hugepages)));
139139

140+
lseek(fd, 0, SEEK_SET);
141+
140142
if (write(fd, initial_nr_hugepages, strlen(initial_nr_hugepages))
141143
!= strlen(initial_nr_hugepages)) {
142144
perror("Failed to write value to /proc/sys/vm/nr_hugepages\n");

0 commit comments

Comments
 (0)