From mboxrd@z Thu Jan 1 00:00:00 1970 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 B143AC433F5 for ; Thu, 9 Dec 2021 16:24:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5B666B0072; Thu, 9 Dec 2021 11:24:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C0B476B0073; Thu, 9 Dec 2021 11:24:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD2C26B0074; Thu, 9 Dec 2021 11:24:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0134.hostedemail.com [216.40.44.134]) by kanga.kvack.org (Postfix) with ESMTP id 9BAA46B0072 for ; Thu, 9 Dec 2021 11:24:29 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 61F3389939 for ; Thu, 9 Dec 2021 16:24:19 +0000 (UTC) X-FDA: 78898778238.19.F124188 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) by imf24.hostedemail.com (Postfix) with ESMTP id 39DBB180006 for ; Thu, 9 Dec 2021 16:24:18 +0000 (UTC) Received: by mail-yb1-f181.google.com with SMTP id v64so14907149ybi.5 for ; Thu, 09 Dec 2021 08:24:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TyvL9YX3JikjfEwvnMbTqan/wb4X4wF7RWIiupf6vyc=; b=SXpLskh8ID9WUMu48p7COzm7XOWwZSI8zSjw2PIpwtRQ4RFUSbW9OdExgxyesXeWRE jHd6QNSTNKTwMsSWh/mk0W2kKLb2uG6Oceccl1H3Z5UTrz+fj3bcLIT47lnk5ZTWpeND 7Tvd+GgLZf51WHnGpYZVZzYOMyQhBA5WHHXU4PDitEp9/JzC996EphPVHDtjogFWsbis 7SyPeKmKp1jTVQelWF6zJ1FzOnw7W0lL68MxhVABWCogVu38SKoir6o+aSPgN6vXM7yk zP04lpq9+8Unq+BplFEnuh38QPuhx9KRQq8y5yrCnvCYNXz0p24gb9aDCGjjj77c0C51 D8MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TyvL9YX3JikjfEwvnMbTqan/wb4X4wF7RWIiupf6vyc=; b=rhdf8WfY6ZWJkF6sAZrLbCJ2I7XQ7gctqVRRDJdpqb86hnmDAv0DspSDIUdbWBSZcM rmdFPlNz4CGo51Qoq+qjtBR1pycTje1uAkefLMsSsoX++phOSc39BidjRAiyqcZI61LP FNKOrIvsQS+l75v9He8xwU1OMkhFFYDckEvIgxAT5HfMzNfCWok5PCZN66xyKMQb9yTj rw+e82yOHiTuCuCa5GucsSdkv5EK5htN+9rz4dldXO4ILPc7zH/FqfK3hJTN0celwQiL zIVBrbHShxk45Nkdc1khEbx09CXXrEBWWwGQMfyyDYnHGLpsVQ9bgbMMiRFd7T9Xnxx9 /TSg== X-Gm-Message-State: AOAM532tQ/VX0hbAa1sWcPZhmNehPUo7sPnd01OU6GYKzkUtkTmgUKjQ GwxvOOK4UFefg+0QN3OCx99FWd/dnBgnpSvOFFspag== X-Google-Smtp-Source: ABdhPJzNvWXS1A5jCK7LOPHhMdyEnvfuKQORKBnUgVm497593BgIOQDrRAOYzhkTUIOoFvvu5thD/oCRJEDSh3hfWRo= X-Received: by 2002:a25:6ec5:: with SMTP id j188mr7418743ybc.602.1639067055146; Thu, 09 Dec 2021 08:24:15 -0800 (PST) MIME-Version: 1.0 References: <20211208212211.2860249-1-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 9 Dec 2021 08:24:04 -0800 Message-ID: Subject: Re: [PATCH 4/3] mm: drop MMF_OOM_SKIP from exit_mmap To: Michal Hocko Cc: akpm@linux-foundation.org, rientjes@google.com, willy@infradead.org, hannes@cmpxchg.org, guro@fb.com, riel@surriel.com, minchan@kernel.org, kirill@shutemov.name, aarcange@redhat.com, christian@brauner.io, hch@infradead.org, oleg@redhat.com, david@redhat.com, jannh@google.com, shakeelb@google.com, luto@kernel.org, christian.brauner@ubuntu.com, fweimer@redhat.com, jengelh@inai.de, timmurray@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: scm6gs6z19jme9madjpporf68x98wpfs Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=SXpLskh8; spf=pass (imf24.hostedemail.com: domain of surenb@google.com designates 209.85.219.181 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 39DBB180006 X-HE-Tag: 1639067058-101948 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: On Thu, Dec 9, 2021 at 1:12 AM Michal Hocko wrote: > > Do we want this on top? As we discussed in this thread https://lore.kernel.org/all/YY4snVzZZZYhbigV@dhcp22.suse.cz, __oom_reap_task_mm in exit_mmap allows oom-reaper/process_mrelease to unmap pages in parallel with exit_mmap without blocking each other. Removal of __oom_reap_task_mm from exit_mmap prevents this parallelism and has a negative impact on performance. So the conclusion of that thread I thought was to keep that part. My understanding is that we also wanted to remove MMF_OOM_SKIP as a follow-up patch but __oom_reap_task_mm would stay. > ---- > From 58b04ae6dc97b0105ea2651daca55cf2386f69b4 Mon Sep 17 00:00:00 2001 > From: Michal Hocko > Date: Thu, 9 Dec 2021 10:07:51 +0100 > Subject: [PATCH] mm: drop MMF_OOM_SKIP from exit_mmap > > MMF_OOM_SKIP used to play a synchronization role between exit_mmap and > oom repear in the past. Since the exclusive mmap_sem is held in > exit_mmap to cover all destructive operations the flag synchronization > is not needed anymore and we can safely drop it. Just make sure that > mm->mmap is set to NULL so that nobody will access the freed vma list. > > Signed-off-by: Michal Hocko > --- > mm/mmap.c | 23 +---------------------- > 1 file changed, 1 insertion(+), 22 deletions(-) > > diff --git a/mm/mmap.c b/mm/mmap.c > index f4e09d390a07..0d6af9d89aa8 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -3129,28 +3129,6 @@ 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. > - * > - * This needs to be done before calling unlock_range(), > - * which clears VM_LOCKED, otherwise the oom reaper cannot > - * reliably test it. > - */ > - (void)__oom_reap_task_mm(mm); > - > - set_bit(MMF_OOM_SKIP, &mm->flags); > - } > - > mmap_write_lock(mm); > if (mm->locked_vm) > unlock_range(mm->mmap, ULONG_MAX); > @@ -3180,6 +3158,7 @@ void exit_mmap(struct mm_struct *mm) > vma = remove_vma(vma); > cond_resched(); > } > + mm->mmap = NULL; > mmap_write_unlock(mm); > vm_unacct_memory(nr_accounted); > } > -- > 2.30.2 > > -- > Michal Hocko > SUSE Labs