Re: A mapcount riddle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)'.

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.
-- 
Mike Kravetz




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux