]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
kselftest: fix OOM in memory compaction test
authorArnd Bergmann <arnd@arndb.de>
Tue, 9 Jan 2018 16:26:24 +0000 (17:26 +0100)
committerSeth Forshee <seth.forshee@canonical.com>
Fri, 23 Feb 2018 14:26:30 +0000 (08:26 -0600)
BugLink: http://bugs.launchpad.net/bugs/1751131
commit 4c1baad223906943b595a887305f2e8124821dad 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>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
tools/testing/selftests/vm/compaction_test.c

index a65b016d4c13a3ead88ed63fa4d7ddc44527ce76..1097f04e4d80e6cff93bb9e912c4c38894cd5959 100644 (file)
@@ -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");