mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yin Fengwei <fengwei.yin@intel.com>
To: David Hildenbrand <david@redhat.com>,
	Matthew Wilcox <willy@infradead.org>,
	Ryan Roberts <ryan.roberts@arm.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>,
	<linux-doc@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Hugh Dickins <hughd@google.com>, Yang Shi <shy828301@gmail.com>,
	Zi Yan <ziy@nvidia.com>
Subject: Re: [PATCH mm-unstable v1] mm: add a total mapcount for large folios
Date: Thu, 10 Aug 2023 11:14:43 +0800	[thread overview]
Message-ID: <adfdea09-571e-fe1e-6663-f1c78a79e830@intel.com> (raw)
In-Reply-To: <703bb7de-aba7-ee4b-c2fb-3562318072a5@redhat.com>



On 8/10/23 03:26, David Hildenbrand wrote:
> On 09.08.23 21:21, Matthew Wilcox wrote:
>> On Wed, Aug 09, 2023 at 08:07:43PM +0100, Ryan Roberts wrote:
>>>> +++ b/mm/hugetlb.c
>>>> @@ -1479,7 +1479,7 @@ static void __destroy_compound_gigantic_folio(struct folio *folio,
>>>>       struct page *p;
>>>>         atomic_set(&folio->_entire_mapcount, 0);
>>>> -    atomic_set(&folio->_nr_pages_mapped, 0);
>>>> +    atomic_set(&folio->_total_mapcount, 0);
>>>
>>> Just checking this is definitely what you intended? _total_mapcount is -1 when
>>> it means "no pages mapped", so 0 means 1 page mapped?
>>
>> We're destroying the page here, so rather than setting the meaning of
>> this, we're setting the contents of this memory to 0.
>>
>>
>> Other thoughts that ran through my mind ... can we wrap?  I don't think
>> we can; we always increment total_mapcount by 1, no matter whether we're
>> incrementing entire_mapcount or an individual page's mapcount, and we
>> always call folio_get() first, so we can't increment total_mapcount
>> past 2^32 because folio_get() will die first.  We might be able to
>> wrap past 2^31, but I don't think so.
> 
> From my understanding, if we wrap the total mapcount, we already wrapped the refcount -- as you say, grabbing a reference ahead of time for each mapping is mandatory. Both are 31bit values. We could treat the total mapcount as an unsigned int, but that's rather future work.
> 
> Also, even folio_mapcount() and total_mapcount() return an "int" as of now.
> 
> But yes, I also thought about that. In the future we might want (at least) for bigger folios refcount+total_mapcount to be 64bit. Or we manage to decouple both and only have the total_mapcount be 64bit only.
This means pvmw may need to check more than 2^32 pte entries. :). I hope
we have other way to get bigger folio and keep mapcount not too big.


Regards
Yin, Fengwei

> 

  reply	other threads:[~2023-08-10  3:17 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09  8:32 David Hildenbrand
2023-08-09 15:45 ` Zi Yan
2023-08-09 19:07 ` Ryan Roberts
2023-08-09 19:17   ` David Hildenbrand
2023-08-10 10:40     ` Ryan Roberts
2023-08-10 11:14     ` David Hildenbrand
2023-08-10 11:27       ` David Hildenbrand
2023-08-10 11:32         ` David Hildenbrand
2023-08-10 11:35           ` Ryan Roberts
2023-08-09 19:21   ` Matthew Wilcox
2023-08-09 19:26     ` David Hildenbrand
2023-08-10  3:14       ` Yin Fengwei [this message]
2023-08-09 21:23 ` Peter Xu
2023-08-10  3:25   ` Matthew Wilcox
2023-08-10  8:37     ` David Hildenbrand
2023-08-10 21:48       ` Peter Xu
2023-08-10 21:54         ` Matthew Wilcox
2023-08-10 21:59           ` David Hildenbrand
2023-08-11 15:03             ` Peter Xu
2023-08-11 15:14               ` Zi Yan
2023-08-11 15:17               ` David Hildenbrand
2023-08-10  8:59   ` David Hildenbrand
2023-08-10 10:48     ` Ryan Roberts
2023-08-10 17:15       ` Peter Xu
2023-08-10 17:47         ` David Hildenbrand
2023-08-10 19:02           ` Ryan Roberts
2023-08-10 20:57           ` Peter Xu
2023-08-10 21:48             ` Matthew Wilcox
2023-08-10 22:27               ` David Hildenbrand
2023-08-11 15:18                 ` Peter Xu
2023-08-11 15:32                   ` David Hildenbrand
2023-08-11 15:58                     ` Peter Xu
2023-08-11 16:08                       ` David Hildenbrand
2023-08-11 16:11                         ` Zi Yan
2023-08-11 22:18                           ` Peter Xu
2023-08-10 22:16             ` David Hildenbrand
2023-08-10  3:24 ` Yin Fengwei

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=adfdea09-571e-fe1e-6663-f1c78a79e830@intel.com \
    --to=fengwei.yin@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=david@redhat.com \
    --cc=hughd@google.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=ryan.roberts@arm.com \
    --cc=shy828301@gmail.com \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.com \
    /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

all inboxes | Powered by JetHome®