From: Yang Shi <yang.shi@linux.alibaba.com>
To: Laurent Dufour <ldufour@linux.vnet.ibm.com>,
mhocko@kernel.org, willy@infradead.org, kirill@shutemov.name,
akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC v5 PATCH 2/2] mm: mmap: zap pages with read mmap_sem in munmap
Date: Tue, 24 Jul 2018 10:56:31 -0700 [thread overview]
Message-ID: <02228f42-438b-7840-5653-f076fc190f14@linux.alibaba.com> (raw)
In-Reply-To: <e9553340-3b8d-bc26-781d-8a6a8716bc8f@linux.vnet.ibm.com>
>>>> +static int vm_munmap_zap_rlock(unsigned long start, size_t len)
>>>> +{
>>>> +A A A int ret;
>>>> +A A A struct mm_struct *mm = current->mm;
>>>> +A A A LIST_HEAD(uf);
>>>> +
>>>> +A A A ret = do_munmap_zap_rlock(mm, start, len, &uf);
>>>> +A A A userfaultfd_unmap_complete(mm, &uf);
>>>> +A A A return ret;
>>>> +}
>>>> +
>>>> A int vm_munmap(unsigned long start, size_t len)
>>>> A {
>>>> A A A A A int ret;
>>> A stupid question, since the overhead of vm_munmap_zap_rlock() compared to
>>> vm_munmap() is not significant, why not putting that in vm_munmap() instead of
>>> introducing a new vm_munmap_zap_rlock() ?
>> Since vm_munmap() is called in other paths too, i.e. drm driver, kvm, etc. I'm
>> not quite sure if those paths are safe enough to this optimization. And, it
>> looks they are not the main sources of the latency, so here I introduced
>> vm_munmap_zap_rlock() for munmap() only.
> For my information, what could be unsafe for these paths ?
I'm just not sure if they are safe enough nor not, because I'm not
knowledgeable enough to kvm and drm drivers. They might be safe, but I
don't know how to prove that.
So, since they might be not the main sources of latency (I haven't seen
any hung report due to them), so it sounds safe to not touch them for now.
>
>> If someone reports or we see they are the sources of latency too, and the
>> optimization is proved safe to them, we can definitely extend this to all
>> vm_munmap() calls
>>
>> Thanks,
>> Yang
>>
>>>> @@ -2855,10 +2939,9 @@ int vm_munmap(unsigned long start, size_t len)
>>>> A SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
>>>> A {
>>>> A A A A A profile_munmap(addr);
>>>> -A A A return vm_munmap(addr, len);
>>>> +A A A return vm_munmap_zap_rlock(addr, len);
>>>> A }
>>>>
>>>> -
>>>> A /*
>>>> A A * Emulation of deprecated remap_file_pages() syscall.
>>>> A A */
>>>> @@ -3146,7 +3229,7 @@ void exit_mmap(struct mm_struct *mm)
>>>> A A A A A tlb_gather_mmu(&tlb, mm, 0, -1);
>>>> A A A A A /* update_hiwater_rss(mm) here? but nobody should be looking */
>>>> A A A A A /* Use -1 here to ensure all VMAs in the mm are unmapped */
>>>> -A A A unmap_vmas(&tlb, vma, 0, -1);
>>>> +A A A unmap_vmas(&tlb, vma, 0, -1, false);
>>>> A A A A A free_pgtables(&tlb, vma, FIRST_USER_ADDRESS, USER_PGTABLES_CEILING);
>>>> A A A A A tlb_finish_mmu(&tlb, 0, -1);
>>>>
next prev parent reply other threads:[~2018-07-24 17:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-18 23:21 [RFC v5 0/2] mm: zap pages with read mmap_sem in munmap for large mapping Yang Shi
2018-07-18 23:21 ` [RFC v5 PATCH 1/2] mm: refactor do_munmap() to extract the common part Yang Shi
2018-07-24 16:22 ` Laurent Dufour
2018-07-18 23:21 ` [RFC v5 PATCH 2/2] mm: mmap: zap pages with read mmap_sem in munmap Yang Shi
2018-07-24 9:26 ` Kirill A. Shutemov
2018-07-24 15:42 ` Yang Shi
2018-07-24 17:18 ` Laurent Dufour
2018-07-24 17:26 ` Yang Shi
2018-07-24 17:31 ` Laurent Dufour
2018-07-24 17:56 ` Yang Shi [this message]
2018-07-23 22:00 ` [RFC v5 0/2] mm: zap pages with read mmap_sem in munmap for large mapping Yang Shi
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=02228f42-438b-7840-5653-f076fc190f14@linux.alibaba.com \
--to=yang.shi@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=kirill@shutemov.name \
--cc=ldufour@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--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