From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-mm@kvack.org, Hugh Dickins <hughd@google.com>,
David Hildenbrand <david@redhat.com>,
Mike Kravetz <mike.kravetz@oracle.com>
Subject: Re: folio mapcount
Date: Thu, 16 Dec 2021 21:56:36 +0300 [thread overview]
Message-ID: <20211216185636.oqymb5zzb7p6btbn@box.shutemov.name> (raw)
In-Reply-To: <YbtFqccUEBduZfNg@casper.infradead.org>
On Thu, Dec 16, 2021 at 01:56:57PM +0000, Matthew Wilcox wrote:
> > Okay, so you will have mapcount == 2 or 3 for mprotect case above, not
> > 512. But it doesn't help with answering question if the page can be
> > re-used. You would need to do rmap walk to get the answer.
> >
> > Note also that VMA lifecycle is different from page lifecycle:
> > MADV_DONTNEED removes mapping, but leaves VMA intact. Who would decrement
> > mapcount here?
>
> I think page_remove_rmap() does when called from zap_huge_pmd().
> The tricky part is handling partial DONTNEED calls. eg we could have
> a 2MB page (if we're talking about shmem, it could even be mapped
> askew), MADV_DONTNEED the first 512KB, then MADV_DONTNEED the last
> 512KB, then finally MADV_DONTNEED the middle 1MB and only at the third
> call should the mapcount be decremented.
>
> So a zap call has to check all the PTE/PMD entries in the range of the
> (folio intersect vma) to be sure that there are no more references to
> a part of this folio. It might not be terribly fast, but it probably
> won't be noticable compared to all the other costs of doing a munmap().
It's not only the area around unmapped. The rest of the page can be
anywhere in the address space, thanks to mremap(2).
I think it would require full rmap, but I'm not sure. Or some very special
tricks on mremap() or vma split. Looks like suffling complexity around,
not reducing it.
--
Kirill A. Shutemov
next prev parent reply other threads:[~2021-12-16 18:56 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-15 21:55 Matthew Wilcox
2021-12-16 9:37 ` Kirill A. Shutemov
2021-12-16 13:56 ` Matthew Wilcox
2021-12-16 15:19 ` Jason Gunthorpe
2021-12-16 15:54 ` Matthew Wilcox
2021-12-16 16:45 ` David Hildenbrand
2021-12-16 17:01 ` Jason Gunthorpe
2021-12-16 18:56 ` Kirill A. Shutemov [this message]
2023-01-24 18:13 Folio mapcount Matthew Wilcox
2023-01-24 18:35 ` David Hildenbrand
2023-01-24 18:37 ` David Hildenbrand
2023-01-24 18:35 ` Yang Shi
2023-02-02 3:45 ` Mike Kravetz
2023-02-02 15:31 ` Matthew Wilcox
2023-02-07 16:19 ` Zi Yan
2023-02-07 16:44 ` Matthew Wilcox
2023-02-06 20:34 ` Matthew Wilcox
2023-02-06 22:55 ` Yang Shi
2023-02-06 23:09 ` Matthew Wilcox
2023-02-07 3:06 ` Yin, Fengwei
2023-02-07 4:08 ` Matthew Wilcox
2023-02-07 22:39 ` Peter Xu
2023-02-07 23:27 ` Matthew Wilcox
2023-02-08 19:40 ` Peter Xu
2023-02-08 20:25 ` Matthew Wilcox
2023-02-08 20:58 ` Peter Xu
2023-02-09 15:10 ` Chih-En Lin
2023-02-09 15:43 ` Peter Xu
2023-02-07 22:56 ` James Houghton
2023-02-07 23:08 ` Matthew Wilcox
2023-02-07 23:27 ` James Houghton
2023-02-07 23:35 ` Matthew Wilcox
2023-02-08 0:35 ` James Houghton
2023-02-08 2:26 ` Matthew Wilcox
2023-02-07 16:23 ` Zi Yan
2023-02-07 16:51 ` Matthew Wilcox
2023-02-08 19:36 ` Zi Yan
2023-02-08 19:54 ` Matthew Wilcox
2023-02-10 15:15 ` Zi Yan
2023-03-29 14:02 ` Yin, Fengwei
2023-07-01 1:17 ` Zi Yan
2023-07-02 9:50 ` Yin, Fengwei
2023-07-02 11:45 ` David Hildenbrand
2023-07-02 12:26 ` Matthew Wilcox
2023-07-03 20:54 ` David Hildenbrand
2023-07-02 19:51 ` Zi Yan
2023-07-03 1:09 ` Yin, Fengwei
2023-07-03 13:24 ` Zi Yan
2023-07-03 20:46 ` David Hildenbrand
2023-07-04 1:22 ` Yin, Fengwei
2023-07-04 2:25 ` Matthew Wilcox
2023-07-03 21:09 ` David Hildenbrand
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=20211216185636.oqymb5zzb7p6btbn@box.shutemov.name \
--to=kirill@shutemov.name \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.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