From: Michal Hocko <mhocko@suse.com>
To: Suren Baghdasaryan <surenb@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Rientjes <rientjes@google.com>,
Matthew Wilcox <willy@infradead.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Roman Gushchin <guro@fb.com>, Minchan Kim <minchan@kernel.org>,
"Kirill A. Shutemov" <kirill@shutemov.name>,
Andrea Arcangeli <aarcange@redhat.com>,
Christian Brauner <brauner@kernel.org>,
Christoph Hellwig <hch@infradead.org>,
Oleg Nesterov <oleg@redhat.com>,
David Hildenbrand <david@redhat.com>,
Jann Horn <jannh@google.com>, Shakeel Butt <shakeelb@google.com>,
Peter Xu <peterx@redhat.com>, John Hubbard <jhubbard@nvidia.com>,
shuah@kernel.org, LKML <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>,
linux-kselftest@vger.kernel.org,
kernel-team <kernel-team@android.com>,
Liam Howlett <liam.howlett@oracle.com>
Subject: Re: [PATCH RESEND v2 1/2] mm: drop oom code from exit_mmap
Date: Thu, 2 Jun 2022 08:53:10 +0200 [thread overview]
Message-ID: <YpheVjLQj5ili7ZJ@dhcp22.suse.cz> (raw)
In-Reply-To: <CAJuCfpHcPhDYTpLj8Vo+W9Q6KkWdT_BOTaEfJW6_PDCPx5kD-A@mail.gmail.com>
On Wed 01-06-22 14:47:41, Suren Baghdasaryan wrote:
> On Wed, Jun 1, 2022 at 2:36 PM Andrew Morton <akpm@linux-foundation.org> wrote:
[...]
> > But iirc mapletree wants to retain a write_lock here, so I ended up with
> >
> > void exit_mmap(struct mm_struct *mm)
> > {
> > struct mmu_gather tlb;
> > struct vm_area_struct *vma;
> > unsigned long nr_accounted = 0;
> > MA_STATE(mas, &mm->mm_mt, 0, 0);
> > int count = 0;
> >
> > /* mm's last user has gone, and its about to be pulled down */
> > mmu_notifier_release(mm);
> >
> > mmap_write_lock(mm);
> > arch_exit_mmap(mm);
> >
> > vma = mas_find(&mas, ULONG_MAX);
> > if (!vma) {
> > /* Can happen if dup_mmap() received an OOM */
> > mmap_write_unlock(mm);
> > return;
> > }
> >
> > lru_add_drain();
> > flush_cache_mm(mm);
> > tlb_gather_mmu_fullmm(&tlb, mm);
> > /* update_hiwater_rss(mm) here? but nobody should be looking */
> > /* Use ULONG_MAX here to ensure all VMAs in the mm are unmapped */
> > unmap_vmas(&tlb, &mm->mm_mt, vma, 0, ULONG_MAX);
> >
> > /*
> > * Set MMF_OOM_SKIP to hide this task from the oom killer/reaper
> > * because the memory has been already freed. Do not bother checking
> > * mm_is_oom_victim because setting a bit unconditionally is cheaper.
> > */
> > set_bit(MMF_OOM_SKIP, &mm->flags);
> > free_pgtables(&tlb, &mm->mm_mt, vma, FIRST_USER_ADDRESS,
> > USER_PGTABLES_CEILING);
> > tlb_finish_mmu(&tlb);
> >
> > /*
> > * Walk the list again, actually closing and freeing it, with preemption
> > * enabled, without holding any MM locks besides the unreachable
> > * mmap_write_lock.
> > */
> > do {
> > if (vma->vm_flags & VM_ACCOUNT)
> > nr_accounted += vma_pages(vma);
> > remove_vma(vma);
> > count++;
> > cond_resched();
> > } while ((vma = mas_find(&mas, ULONG_MAX)) != NULL);
> >
> > BUG_ON(count != mm->map_count);
> >
> > trace_exit_mmap(mm);
> > __mt_destroy(&mm->mm_mt);
> > mm->mmap = NULL;
>
> ^^^ this line above needs to be removed when the patch is applied over
> the maple tree patchset.
I am not fully up to date on the maple tree changes. Could you explain
why resetting mm->mmap is not needed anymore please?
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2022-06-02 6:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-31 22:30 [PATCH RESEND v2 1/2] mm: drop oom code from exit_mmap Suren Baghdasaryan
2022-05-31 22:31 ` [PATCH RESEND v2 2/2] mm: delete unused MMF_OOM_VICTIM flag Suren Baghdasaryan
2022-08-22 22:21 ` Andrew Morton
2022-08-22 22:33 ` Yu Zhao
2022-08-22 22:48 ` Andrew Morton
2022-08-22 22:59 ` Yu Zhao
2022-08-22 23:16 ` Andrew Morton
2022-08-22 23:20 ` Yu Zhao
2022-08-23 8:36 ` Michal Hocko
2022-08-28 19:50 ` Yu Zhao
2022-06-01 21:36 ` [PATCH RESEND v2 1/2] mm: drop oom code from exit_mmap Andrew Morton
2022-06-01 21:47 ` Suren Baghdasaryan
2022-06-01 21:50 ` Suren Baghdasaryan
2022-06-02 6:53 ` Michal Hocko [this message]
2022-06-02 13:31 ` Liam Howlett
2022-06-02 14:08 ` Michal Hocko
2022-06-02 13:39 ` Matthew Wilcox
2022-06-02 15:02 ` Suren Baghdasaryan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YpheVjLQj5ili7ZJ@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=david@redhat.com \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=hch@infradead.org \
--cc=jannh@google.com \
--cc=jhubbard@nvidia.com \
--cc=kernel-team@android.com \
--cc=kirill@shutemov.name \
--cc=liam.howlett@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=oleg@redhat.com \
--cc=peterx@redhat.com \
--cc=rientjes@google.com \
--cc=shakeelb@google.com \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).