From patchwork Tue May 10 03:00:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 12844442 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19A4AC433F5 for ; Tue, 10 May 2022 03:00:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E0036B0072; Mon, 9 May 2022 23:00:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 568466B0073; Mon, 9 May 2022 23:00:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BAA76B0074; Mon, 9 May 2022 23:00:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 267926B0072 for ; Mon, 9 May 2022 23:00:21 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DE73C3152D for ; Tue, 10 May 2022 03:00:20 +0000 (UTC) X-FDA: 79448329800.06.D297EDC Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf28.hostedemail.com (Postfix) with ESMTP id AA420C0093 for ; Tue, 10 May 2022 03:00:01 +0000 (UTC) Received: by mail-pj1-f73.google.com with SMTP id s18-20020a17090aa11200b001d92f7609e8so7046735pjp.3 for ; Mon, 09 May 2022 20:00:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=DVOA1HWoo1xAq42eK94cnyQwLywIDvR1bD4VuJZi5js=; b=aeumVFAeovTeBq/VEg4tfDKCF6fMQ1t6TdeJRMNC9XG/pCoX4IKrBBUuBKC7essrdM xaQntmkvQauUlJzB30tqRxOBxi5H6dLwNHLJGngdDd6DsCIxqECmPSdFb1ogrYsIGfoM qHtLUDtdeVuJL6hj9Evd2QIKlCfYt3+CBsHD/ydwPp31U+6TbXJ3W3Q1P9h20lh+b+Pd dMvRmB1AbU9PG5NHV6k+LSt8C00ytOZHl4x8wgy6/v0LdP0KDfvzwuEZt+0wmZbyzVAB aYvyzXQeLhb1TRQB3ar28rLR4YqbGKxpNY29XGu8AVBd7T5g/fideFxVJMYo6VgrtBCl /yWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=DVOA1HWoo1xAq42eK94cnyQwLywIDvR1bD4VuJZi5js=; b=tNK7c/cVRr9qrhVZH4d4BoiL0ABEt0JtR0xpe83M/XFhGqCjLPsYzLoAQl0/f473G4 ICb2L7K5Tz9D1YYL2naciq3dJAbfZEJSGg8z3IYBqb0Ahq7oUqz0B6by+88/CwExLnIo oKra1eoWqIdy1FBS7DVFlIqJaHDwgRt5U6iuldH1kIwZmFZjj7U5oO7pUgChqaA5DhRQ kO3lrhTW6MqlkgKihht0EqBkMZVLzMSlNpNY1+b5MONWi9XSZu36WGSxjDFWEO8zMuzA 0M30Tr5c6/sJs8+jkqaXncDaXD9tzExmA1vTLFPps/Xzthhj+3PXsmY+Stn7FEuqC8RG uECw== X-Gm-Message-State: AOAM531GbznZzktBwYBF0/Y1W+AZ/GnONRXiB9na2qSq1rMGlaPXI9xq 3ryO50nkPAYtVOzdI2ExQfCi+c9Ud74= X-Google-Smtp-Source: ABdhPJwonbf0F08sh6730vpp1nM889khfj0HOKvD6Nl6PbNjOrRXYNoFe/OL7vCiBBCEWFm2QZ/mKO2DMts= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:c861:f04:adab:761b]) (user=surenb job=sendgmr) by 2002:a17:90a:930b:b0:1d5:684b:8e13 with SMTP id p11-20020a17090a930b00b001d5684b8e13mr21049188pjo.153.1652151619049; Mon, 09 May 2022 20:00:19 -0700 (PDT) Date: Mon, 9 May 2022 20:00:12 -0700 Message-Id: <20220510030014.3842475-1-surenb@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog Subject: [PATCH 1/3] selftests: vm: add process_mrelease tests From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: mhocko@suse.com, rientjes@google.com, willy@infradead.org, hannes@cmpxchg.org, guro@fb.com, minchan@kernel.org, kirill@shutemov.name, aarcange@redhat.com, brauner@kernel.org, hch@infradead.org, oleg@redhat.com, david@redhat.com, jannh@google.com, shakeelb@google.com, peterx@redhat.com, jhubbard@nvidia.com, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, kernel-team@android.com, surenb@google.com Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=aeumVFAe; spf=pass (imf28.hostedemail.com: domain of 3Q9V5YgYKCO4ikhUdRWeeWbU.SecbYdkn-ccalQSa.ehW@flex--surenb.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3Q9V5YgYKCO4ikhUdRWeeWbU.SecbYdkn-ccalQSa.ehW@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: AA420C0093 X-Stat-Signature: b3mihyoefwf95p39oa1shozfm1ycpj8r X-HE-Tag: 1652151601-512660 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Introduce process_mrelease syscall sanity tests. They include tests of invalid pidfd and flags inputs, attempting to call process_mrelease with a live process and a valid usage of process_mrelease. Because process_mrelease has to be used against a process with a pending SIGKILL, it's possible that the process exits before process_mrelease gets called. In such cases we retry the test with a victim that allocates twice more memory up to 1GB. This would require the victim process to spend more time during exit and process_mrelease has a better chance of catching the process before it exits. Signed-off-by: Suren Baghdasaryan --- tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/mrelease_test.c | 176 +++++++++++++++++++++ tools/testing/selftests/vm/run_vmtests.sh | 16 ++ 3 files changed, 193 insertions(+) create mode 100644 tools/testing/selftests/vm/mrelease_test.c diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index 04a49e876a46..733fccbff0ef 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -43,6 +43,7 @@ TEST_GEN_FILES += map_populate TEST_GEN_FILES += memfd_secret TEST_GEN_FILES += mlock-random-test TEST_GEN_FILES += mlock2-tests +TEST_GEN_FILES += mrelease_test TEST_GEN_FILES += mremap_dontunmap TEST_GEN_FILES += mremap_test TEST_GEN_FILES += on-fault-limit diff --git a/tools/testing/selftests/vm/mrelease_test.c b/tools/testing/selftests/vm/mrelease_test.c new file mode 100644 index 000000000000..a61061bf8433 --- /dev/null +++ b/tools/testing/selftests/vm/mrelease_test.c @@ -0,0 +1,176 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2022 Google LLC + */ +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +#include "util.h" + +static inline int pidfd_open(pid_t pid, unsigned int flags) +{ +#ifdef __NR_pidfd_open + return syscall(__NR_pidfd_open, pid, flags); +#else + errno = ENOSYS; + return -1; +#endif +} + +static inline int process_mrelease(int pidfd, unsigned int flags) +{ +#ifdef __NR_process_mrelease + return syscall(__NR_process_mrelease, pidfd, flags); +#else + errno = ENOSYS; + return -1; +#endif +} + +static void write_fault_pages(char *addr, unsigned long nr_pages) +{ + unsigned long i; + + for (i = 0; i < nr_pages; i++) + *((unsigned long *)(addr + (i * PAGE_SIZE))) = i; +} + +static int alloc_noexit(unsigned long nr_pages, int pipefd) +{ + int ppid = getppid(); + void *buf; + + buf = mmap(NULL, nr_pages * PAGE_SIZE, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON, 0, 0); + if (buf == MAP_FAILED) { + perror("mmap"); + return 1; + } + + write_fault_pages((char *)buf, nr_pages); + + /* Signal the parent that the child is ready */ + if (write(pipefd, "", 1) < 0) { + perror("write"); + return 1; + } + + /* Wait to be killed (when reparenting happens) */ + while (getppid() == ppid) + sleep(1); + + munmap(buf, nr_pages * PAGE_SIZE); + + return 0; +} + + +#define MB(x) (x << 20) +#define MAX_SIZE_MB 1024 + +int main(void) +{ + int res; + int pipefd[2], pidfd; + pid_t pid; + char byte; + size_t size; + int negative_tests_done = 0; + + /* Test a wrong pidfd */ + if (!process_mrelease(-1, 0) || errno != EBADF) { + perror("process_mrelease with wring pidfd"); + exit(1); + } + + /* + * Start the test with 1MB allocation and double every time + * process_mrelease fails + */ + for (size = 1; size <= MAX_SIZE_MB; size *= 2) { + /* + * Pipe for the child to signal when it's done allocating + * memory + */ + if (pipe(pipefd)) { + perror("pipe"); + exit(1); + } + pid = fork(); + if (pid < 0) { + perror("fork"); + exit(1); + } + + if (pid == 0) { + close(pipefd[0]); + res = alloc_noexit(MB(size) / PAGE_SIZE, pipefd[1]); + close(pipefd[1]); + exit(res); + } + + close(pipefd[1]); + /* Block until the child is ready */ + res = read(pipefd[0], &byte, 1); + close(pipefd[0]); + if (res < 0) { + perror("read"); + exit(1); + } + + pidfd = pidfd_open(pid, 0); + if (pidfd < 0) { + perror("pidfd_open"); + exit(1); + } + + /* Run negative tests which require a valid child only once */ + if (!negative_tests_done) { + /* Test invalid flags */ + if (!process_mrelease(pidfd, (unsigned int)-1) || + errno != EINVAL) { + perror("process_mrelease with wrong flags"); + exit(1); + } + /* Test reapling while process is still alive */ + if (!process_mrelease(pidfd, 0) || + errno != EINVAL) { + perror("process_mrelease on a live process"); + exit(1); + } + negative_tests_done = 1; + } + + if (kill(pid, SIGKILL)) { + perror("kill"); + exit(1); + } + + if (!process_mrelease(pidfd, 0)) { + /* Terminate the test once process_mrelease succeeds */ + return 0; + } + + /* + * Ignore the failure if the child exited before mrelease got + * called, increase allocation size and retry the test + */ + if (errno != ESRCH) { + perror("process_mrelease"); + exit(1); + } + + if (waitpid(pid, NULL, 0) < 0) { + perror("waitpid"); + exit(1); + } + close(pidfd); + } + + printf("All process_mrelease attempts failed!\n"); + exit(1); +} diff --git a/tools/testing/selftests/vm/run_vmtests.sh b/tools/testing/selftests/vm/run_vmtests.sh index 352ba00cf26b..1986162fea39 100755 --- a/tools/testing/selftests/vm/run_vmtests.sh +++ b/tools/testing/selftests/vm/run_vmtests.sh @@ -287,6 +287,22 @@ else echo "[PASS]" fi +echo "---------------------" +echo "running mrelease_test" +echo "---------------------" +./mrelease_test +ret_val=$? + +if [ $ret_val -eq 0 ]; then + echo "[PASS]" +elif [ $ret_val -eq $ksft_skip ]; then + echo "[SKIP]" + exitcode=$ksft_skip +else + echo "[FAIL]" + exitcode=1 +fi + echo "-------------------" echo "running mremap_test" echo "-------------------" From patchwork Tue May 10 03:00:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 12844443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00647C433FE for ; Tue, 10 May 2022 03:00:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C9616B0073; Mon, 9 May 2022 23:00:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 653BA8D0001; Mon, 9 May 2022 23:00:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CBD86B0075; Mon, 9 May 2022 23:00:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3A7146B0073 for ; Mon, 9 May 2022 23:00:23 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 2166A81377 for ; Tue, 10 May 2022 03:00:23 +0000 (UTC) X-FDA: 79448329926.29.DA61D63 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf13.hostedemail.com (Postfix) with ESMTP id 1A2A92008D for ; Tue, 10 May 2022 03:00:05 +0000 (UTC) Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-2f4e17a5809so136198277b3.2 for ; Mon, 09 May 2022 20:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=0AgUzbjAvIGQIJ3TKegneiDhTRDvs3xkC1XjZGJhuTM=; b=g2QUSKlRjvRS+HoSod1AhsivUbuFmEFJg57nBgO2wWxFMQNX8TsbB41XI1BTaumzbB 6dpabPhWR5+CjlSCvGkHLatd/WH7DTMT9+YpzFnMX5YnTqC63pNh0jGXTOwMvm/EekcO 1G82nTItky0wND+qfqPnQnhEFucQi98nX1BAmm560CLqvAd6UjZFzwDZnQLkdvRGqJKC lDQHbrXjl6MaKJWo0QyHQhnb1KINt/R/Nif3SsK6F3E/csIPox5QHrzItKaFGqIdHj9i jnao6Vz1C95NxOnvQrDnVNQx/S1fX7vCdGcb5oC/oJNzcg5EuqIaKKkZUIrYg2wglL1y BE9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=0AgUzbjAvIGQIJ3TKegneiDhTRDvs3xkC1XjZGJhuTM=; b=2tIaeQ6bXlZhL4oNaP/d9lWWYGhgnAf2DbU/pfZpJzwaDmDnLGjGjT7cuDAY3G48U0 b6lN+wpoXSQ/OHGSKwuHDPSGIfYE6htfiMJ97rz2qxxnhyzoXi/Ge5GIimTEPPp8piUx PF/8McQvSLYGt50FW6Q8OUazLNQXXnLsI54JO8DYTANiYj5cQVVcpDf2ntXpbHU7S58F 40CMvg4FjNhj3+PDBrCcencbS737w/wbBucTU8+5t9BXH2jg/A/DHObhhkXcARTo7xcZ SbEm2E2Fnokl4UMIt1F8e8qtyQI1YpPtiGvaDGmLbvuvTAQ+9fXIAWIYReLHVHsg3C6K ow5g== X-Gm-Message-State: AOAM5301yClG8di90AmLAxcGyN2mKA/CECKUiCM1HOYGIqqUObpg7Vgz wCwfmw7Uj2OTrZmvi+8GHxntuTRSuFc= X-Google-Smtp-Source: ABdhPJzDKMEzb2CAKUZ4Pj/zM4asaQ571FFbXOKj7mf4MBe/jnpHMEbX7l3RdYkWo2AAdpU/z6TgOHILws8= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:c861:f04:adab:761b]) (user=surenb job=sendgmr) by 2002:a25:e606:0:b0:648:402e:598a with SMTP id d6-20020a25e606000000b00648402e598amr16042195ybh.170.1652151621410; Mon, 09 May 2022 20:00:21 -0700 (PDT) Date: Mon, 9 May 2022 20:00:13 -0700 In-Reply-To: <20220510030014.3842475-1-surenb@google.com> Message-Id: <20220510030014.3842475-2-surenb@google.com> Mime-Version: 1.0 References: <20220510030014.3842475-1-surenb@google.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog Subject: [PATCH 2/3] mm: drop oom code from exit_mmap From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: mhocko@suse.com, rientjes@google.com, willy@infradead.org, hannes@cmpxchg.org, guro@fb.com, minchan@kernel.org, kirill@shutemov.name, aarcange@redhat.com, brauner@kernel.org, hch@infradead.org, oleg@redhat.com, david@redhat.com, jannh@google.com, shakeelb@google.com, peterx@redhat.com, jhubbard@nvidia.com, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, kernel-team@android.com, surenb@google.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 1A2A92008D X-Stat-Signature: 93p73cuy79j7iymsyp8jue7w1snpf5rm Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=g2QUSKlR; spf=pass (imf13.hostedemail.com: domain of 3RdV5YgYKCPAkmjWfTYggYdW.Ugedafmp-eecnSUc.gjY@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3RdV5YgYKCPAkmjWfTYggYdW.Ugedafmp-eecnSUc.gjY@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1652151605-470649 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: With the oom-killer being able to operate on locked pages, exit_mmap does not need to ensure that oom_reap_task_mm is done before it can proceed. Instead it can rely on mmap_lock write lock to prevent oom-killer from operating on the vma tree while it's freeing page tables. exit_mmap can hold mmap_lock read lock when unmapping vmas and then take mmap_lock write lock before freeing page tables. Signed-off-by: Suren Baghdasaryan Acked-by: Michal Hocko --- include/linux/oom.h | 2 -- mm/mmap.c | 25 ++++++------------------- mm/oom_kill.c | 2 +- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/include/linux/oom.h b/include/linux/oom.h index 2db9a1432511..6cdf0772dbae 100644 --- a/include/linux/oom.h +++ b/include/linux/oom.h @@ -106,8 +106,6 @@ static inline vm_fault_t check_stable_address_space(struct mm_struct *mm) return 0; } -bool __oom_reap_task_mm(struct mm_struct *mm); - long oom_badness(struct task_struct *p, unsigned long totalpages); diff --git a/mm/mmap.c b/mm/mmap.c index 313b57d55a63..feaa840fb95d 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -3105,30 +3105,13 @@ void exit_mmap(struct mm_struct *mm) /* mm's last user has gone, and its about to be pulled down */ mmu_notifier_release(mm); - if (unlikely(mm_is_oom_victim(mm))) { - /* - * Manually reap the mm to free as much memory as possible. - * Then, as the oom reaper does, set MMF_OOM_SKIP to disregard - * this mm from further consideration. Taking mm->mmap_lock for - * write after setting MMF_OOM_SKIP will guarantee that the oom - * reaper will not run on this mm again after mmap_lock is - * dropped. - * - * Nothing can be holding mm->mmap_lock here and the above call - * to mmu_notifier_release(mm) ensures mmu notifier callbacks in - * __oom_reap_task_mm() will not block. - */ - (void)__oom_reap_task_mm(mm); - set_bit(MMF_OOM_SKIP, &mm->flags); - } - - mmap_write_lock(mm); + mmap_read_lock(mm); arch_exit_mmap(mm); vma = mm->mmap; if (!vma) { /* Can happen if dup_mmap() received an OOM */ - mmap_write_unlock(mm); + mmap_read_unlock(mm); return; } @@ -3138,6 +3121,10 @@ void exit_mmap(struct mm_struct *mm) /* update_hiwater_rss(mm) here? but nobody should be looking */ /* Use -1 here to ensure all VMAs in the mm are unmapped */ unmap_vmas(&tlb, vma, 0, -1); + mmap_read_unlock(mm); + /* Set MMF_OOM_SKIP to disregard this mm from further consideration.*/ + set_bit(MMF_OOM_SKIP, &mm->flags); + mmap_write_lock(mm); free_pgtables(&tlb, vma, FIRST_USER_ADDRESS, USER_PGTABLES_CEILING); tlb_finish_mmu(&tlb); diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 49d7df39b02d..36355b162727 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -509,7 +509,7 @@ static DECLARE_WAIT_QUEUE_HEAD(oom_reaper_wait); static struct task_struct *oom_reaper_list; static DEFINE_SPINLOCK(oom_reaper_lock); -bool __oom_reap_task_mm(struct mm_struct *mm) +static bool __oom_reap_task_mm(struct mm_struct *mm) { struct vm_area_struct *vma; bool ret = true; From patchwork Tue May 10 03:00:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 12844444 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7E00C433F5 for ; Tue, 10 May 2022 03:00:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 51E6B8D0001; Mon, 9 May 2022 23:00:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 47CE96B0075; Mon, 9 May 2022 23:00:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F8F78D0001; Mon, 9 May 2022 23:00:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1F6FB6B0074 for ; Mon, 9 May 2022 23:00:25 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E10E320C8D for ; Tue, 10 May 2022 03:00:24 +0000 (UTC) X-FDA: 79448329968.15.EE49703 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf24.hostedemail.com (Postfix) with ESMTP id C5E541800C4 for ; Tue, 10 May 2022 03:00:16 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id z14-20020a5b0b0e000000b0064848b628cfso13678335ybp.0 for ; Mon, 09 May 2022 20:00:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=v8x+eJcpkdL63Ie+naoRJ5K0tY4VeOqZU3kdjwItKXU=; b=tQbZ/WVD3zHYzCMARi8lOIW6XMFgAqOYrHo1j1YMjmf1E6Db2YUEzn7zBhUfO02eJR uNsGGz9W6xVLA1AYHmS5NuZ7r/mRzpYH2Hnx/tmOtgNec150hi0ujhXc1tediKwiGf/h EPXp+GS+9N1Qw/QPsn0+c2TSoT9Gnu2f45AOpRYTz9Q7W6nM8VTqau2PAaYWtx/57eQc sCO4QD6WawO8xsNiG1kegbzuCNfwShl9YZ7etBeoKA2AtPazAPjk+4gc+G0GOH9R0oiT M2apOyLag5zgEmw+/WD/CZ9WQgMbVbFWjv93NsBsofE2y3+wrl4wEPRuAGpdMDyRRL5D oFew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=v8x+eJcpkdL63Ie+naoRJ5K0tY4VeOqZU3kdjwItKXU=; b=s7IqL7oQYBfJUFNkCzI8lGq/olgF2dPU0IVM3aNREvZdULLtk56Eat3LgYW+md3QbV KQp8GFPch6jKqFIRs7eA+0ZiI/pFOdTc7+PUvh9oxAk/dGG9wHaAnPikYjsPU6t+wBVB Ochf8PbqnCuLgtG9rq66YQR7PiJc2pCy63JH1AZUflUsUVfJocdLtnh46CMRanptzkfs SjpT8fdunARtnJuJh0L4RLOWaFnRddUb+XH72Nf+/uN3EvmAG58C9EzjEID8hitZPj12 i9cfihRhaKoZoGQ9MMkKocciSgzdYAiUqb/anESzbvHttlqXZMO7BP8pOPGKh5UvUjAx imZQ== X-Gm-Message-State: AOAM533oO1yDwHDExL1YWdo7YJwGwgOFFwcVu3orh7au46vVoxXwB4R3 vINGUYfR9Cq+YIcmbUoKnzPrQX/jItc= X-Google-Smtp-Source: ABdhPJwPgNaVr9a+2gxmOd31MQgAEbhuyPy+GMIaxiFaw1vY5fiRw6vfJCoJcKJvO7YSwWHFwedVmy6Y5vo= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:c861:f04:adab:761b]) (user=surenb job=sendgmr) by 2002:a81:342:0:b0:2f8:a36c:1ddd with SMTP id 63-20020a810342000000b002f8a36c1dddmr17464093ywd.505.1652151623732; Mon, 09 May 2022 20:00:23 -0700 (PDT) Date: Mon, 9 May 2022 20:00:14 -0700 In-Reply-To: <20220510030014.3842475-1-surenb@google.com> Message-Id: <20220510030014.3842475-3-surenb@google.com> Mime-Version: 1.0 References: <20220510030014.3842475-1-surenb@google.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog Subject: [PATCH 3/3] mm: delete unused MMF_OOM_VICTIM flag From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: mhocko@suse.com, rientjes@google.com, willy@infradead.org, hannes@cmpxchg.org, guro@fb.com, minchan@kernel.org, kirill@shutemov.name, aarcange@redhat.com, brauner@kernel.org, hch@infradead.org, oleg@redhat.com, david@redhat.com, jannh@google.com, shakeelb@google.com, peterx@redhat.com, jhubbard@nvidia.com, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, kernel-team@android.com, surenb@google.com X-Stat-Signature: on44k3q7ffuwri1bpff3xr7g1t7xozyt X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C5E541800C4 X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="tQbZ/WVD"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of 3R9V5YgYKCPImolYhVaiiafY.Wigfchor-ggepUWe.ila@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3R9V5YgYKCPImolYhVaiiafY.Wigfchor-ggepUWe.ila@flex--surenb.bounces.google.com X-HE-Tag: 1652151616-447362 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: With the last usage of MMF_OOM_VICTIM in exit_mmap gone, this flag is now unused and can be removed. Signed-off-by: Suren Baghdasaryan Acked-by: Michal Hocko --- include/linux/oom.h | 9 --------- include/linux/sched/coredump.h | 1 - mm/oom_kill.c | 4 +--- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/include/linux/oom.h b/include/linux/oom.h index 6cdf0772dbae..25990e9d9e15 100644 --- a/include/linux/oom.h +++ b/include/linux/oom.h @@ -77,15 +77,6 @@ static inline bool tsk_is_oom_victim(struct task_struct * tsk) return tsk->signal->oom_mm; } -/* - * Use this helper if tsk->mm != mm and the victim mm needs a special - * handling. This is guaranteed to stay true after once set. - */ -static inline bool mm_is_oom_victim(struct mm_struct *mm) -{ - return test_bit(MMF_OOM_VICTIM, &mm->flags); -} - /* * Checks whether a page fault on the given mm is still reliable. * This is no longer true if the oom reaper started to reap the diff --git a/include/linux/sched/coredump.h b/include/linux/sched/coredump.h index 4d9e3a656875..746f6cb07a20 100644 --- a/include/linux/sched/coredump.h +++ b/include/linux/sched/coredump.h @@ -70,7 +70,6 @@ static inline int get_dumpable(struct mm_struct *mm) #define MMF_UNSTABLE 22 /* mm is unstable for copy_from_user */ #define MMF_HUGE_ZERO_PAGE 23 /* mm has ever used the global huge zero page */ #define MMF_DISABLE_THP 24 /* disable THP for all VMAs */ -#define MMF_OOM_VICTIM 25 /* mm is the oom victim */ #define MMF_OOM_REAP_QUEUED 26 /* mm was queued for oom_reaper */ #define MMF_MULTIPROCESS 27 /* mm is shared between processes */ /* diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 36355b162727..11291b99599f 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -732,10 +732,8 @@ static void mark_oom_victim(struct task_struct *tsk) return; /* oom_mm is bound to the signal struct life time. */ - if (!cmpxchg(&tsk->signal->oom_mm, NULL, mm)) { + if (!cmpxchg(&tsk->signal->oom_mm, NULL, mm)) mmgrab(tsk->signal->oom_mm); - set_bit(MMF_OOM_VICTIM, &mm->flags); - } /* * Make sure that the task is woken up from uninterruptible sleep