From: Peter Xu <peterx@redhat.com>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: linux-mm@kvack.org, Naoya Horiguchi <naoya.horiguchi@linux.dev>,
David Rientjes <rientjes@google.com>,
Michal Hocko <mhocko@suse.com>,
Matthew Wilcox <willy@infradead.org>,
David Hildenbrand <david@redhat.com>,
James Houghton <jthoughton@google.com>,
Muchun Song <songmuchun@bytedance.com>
Subject: Re: A mapcount riddle
Date: Wed, 25 Jan 2023 15:13:02 -0500 [thread overview]
Message-ID: <Y9GNTl+5mrzsd0KT@x1n> (raw)
In-Reply-To: <Y9FyGuIWAW3n1t7k@monkey>
On Wed, Jan 25, 2023 at 10:16:58AM -0800, Mike Kravetz wrote:
> On 01/25/23 11:46, Peter Xu wrote:
> > On Tue, Jan 24, 2023 at 03:35:38PM -0800, Mike Kravetz wrote:
> > > On 01/24/23 18:00, Peter Xu wrote:
> > > > On Tue, Jan 24, 2023 at 12:56:24PM -0800, Mike Kravetz wrote:
> > > > Besides, I'm also curious on the planned fix too regarding the two issues
> > > > mentioned.
> > >
> > > My planned 'fix' is to simply check for shared a PMD
> > > (page_count(virt_to_page(pte))) to determine if page with mapcount == 1
> > > is shared.
> >
> > I think having the current pte* won't easily work, we'll need to walk all
> > the pgtable that mapped this page.
> >
> > To be explicit, one page can be mapped at pgtable1 which is shared by proc1
> > & proc2, and it can also be mapped at pgtable2 which is shared by proc3 &
> > proc4. Then (assuming pte1* points to pgtable1):
> >
> > page_count(virt_to_page(pte1)) + page_mapcount(page)
> >
> > Won't be the right mapcount we're looking for.
>
> That assumes we want an accurate mapcount. In the two code segments I pointed
> out, we only need to know if more than one process maps the page. We can
> get that with 'page_count(virt_to_page(pte)) + page_mapcount(page)'.
I see. Yes it sounds working. We can check mapcount==1 first and only go
for the pgtable if mapcount>1, then we also know that's the only pmd it got
mapped at.
>
> For now (and stable releases), I propose just fixing the improper behavior.
> If we really need an accurate mapcount in the shared PMD case (and I am not
> 100% sure we do), then we can add code to maintain or compute that.
>
> Part of my reason for sending this email was to determine if there may
> be some places where we really do need an accurate mapcount in the shared
> PMD case. I have not found any, but could have easily missed something.
Nothing I noticed either.
Thanks,
--
Peter Xu
next prev parent reply other threads:[~2023-01-25 20:13 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-24 20:56 Mike Kravetz
2023-01-24 23:00 ` Peter Xu
2023-01-24 23:29 ` Yang Shi
2023-01-25 16:02 ` Peter Xu
2023-01-25 18:26 ` Yang Shi
2023-01-24 23:35 ` Mike Kravetz
2023-01-25 16:46 ` Peter Xu
2023-01-25 18:16 ` Mike Kravetz
2023-01-25 20:13 ` Peter Xu [this message]
2023-01-25 8:24 ` Michal Hocko
2023-01-25 17:59 ` Mike Kravetz
2023-01-26 9:16 ` Michal Hocko
2023-01-26 17:51 ` Mike Kravetz
2023-01-27 9:56 ` Michal Hocko
2023-01-25 9:09 ` David Hildenbrand
2023-01-25 15:26 ` James Houghton
2023-01-25 15:54 ` Peter Xu
2023-01-25 16:22 ` James Houghton
2023-01-25 19:26 ` Vishal Moola
2023-01-26 9:15 ` David Hildenbrand
2023-01-26 18:22 ` Yang Shi
2023-01-26 9:10 ` 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=Y9GNTl+5mrzsd0KT@x1n \
--to=peterx@redhat.com \
--cc=david@redhat.com \
--cc=jthoughton@google.com \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=mike.kravetz@oracle.com \
--cc=naoya.horiguchi@linux.dev \
--cc=rientjes@google.com \
--cc=songmuchun@bytedance.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