From: Usama Arif <usamaarif642@gmail.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org, riel@surriel.com,
shakeel.butt@linux.dev, roman.gushchin@linux.dev,
yuzhao@google.com, david@redhat.com, baohua@kernel.org,
ryan.roberts@arm.com, rppt@kernel.org, willy@infradead.org,
cerasuolodomenico@gmail.com, corbet@lwn.net,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
kernel-team@meta.com, Shuang Zhai <zhais@google.com>
Subject: Re: [PATCH v2 2/4] mm: remap unused subpages to shared zeropage when splitting isolated thp
Date: Thu, 8 Aug 2024 16:53:17 +0100 [thread overview]
Message-ID: <c6673e99-5e84-474e-8447-3f41a66bf634@gmail.com> (raw)
In-Reply-To: <20240807200241.GB1828817@cmpxchg.org>
On 07/08/2024 21:02, Johannes Weiner wrote:
> On Wed, Aug 07, 2024 at 02:46:47PM +0100, Usama Arif wrote:
>> @@ -177,13 +177,56 @@ void putback_movable_pages(struct list_head *l)
>> }
>> }
>>
>> +static bool try_to_map_unused_to_zeropage(struct page_vma_mapped_walk *pvmw,
>> + struct folio *folio,
>> + unsigned long idx)
>> +{
>> + struct page *page = folio_page(folio, idx);
>> + bool contains_data;
>> + pte_t newpte;
>> + void *addr;
>> +
>> + VM_BUG_ON_PAGE(PageCompound(page), page);
>> + VM_BUG_ON_PAGE(!PageAnon(page), page);
>> + VM_BUG_ON_PAGE(!PageLocked(page), page);
>> + VM_BUG_ON_PAGE(pte_present(*pvmw->pte), page);
>> +
>> + if (PageMlocked(page) || (pvmw->vma->vm_flags & VM_LOCKED))
>> + return false;
>> +
>> + /*
>> + * The pmd entry mapping the old thp was flushed and the pte mapping
>> + * this subpage has been non present. If the subpage is only zero-filled
>> + * then map it to the shared zeropage.
>> + */
>> + addr = kmap_local_page(page);
>> + contains_data = memchr_inv(addr, 0, PAGE_SIZE);
>> + kunmap_local(addr);
>> +
>> + if (contains_data || mm_forbids_zeropage(pvmw->vma->vm_mm))
>> + return false;
>> +
>> + newpte = pte_mkspecial(pfn_pte(page_to_pfn(ZERO_PAGE(pvmw->address)),
>> + pvmw->vma->vm_page_prot));
>
> Why not use my_zero_pfn() here? On many configurations this just
> returns zero_pfn and avoids the indirection through mem_map.
>
>> @@ -904,7 +958,7 @@ static int writeout(struct address_space *mapping, struct folio *folio)
>> * At this point we know that the migration attempt cannot
>> * be successful.
>> */
>> - remove_migration_ptes(folio, folio, false);
>> + remove_migration_ptes(folio, folio, false, false);
>
> bool params are not great for callsite readability.
>
> How about a flags parameter and using names?
>
> enum rmp_flags {
> RMP_LOCKED = 1 << 0,
> RMP_ZEROPAGES = 1 << 1,
> }
Thanks! Will include both of the above changes in the next revision.
next parent reply other threads:[~2024-08-08 15:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240807134732.3292797-1-usamaarif642@gmail.com>
[not found] ` <20240807134732.3292797-3-usamaarif642@gmail.com>
[not found] ` <20240807200241.GB1828817@cmpxchg.org>
2024-08-08 15:53 ` Usama Arif [this message]
[not found] ` <20240807134732.3292797-5-usamaarif642@gmail.com>
2024-08-08 15:55 ` [PATCH v2 4/4] mm: split underutilized THPs David Hildenbrand
2024-08-09 10:31 ` Usama Arif
2024-08-09 13:21 ` David Hildenbrand
2024-08-09 14:25 ` Usama Arif
[not found] ` <20240807134732.3292797-2-usamaarif642@gmail.com>
2024-08-08 15:56 ` [PATCH v2 1/4] mm: free zapped tail pages when splitting isolated thp 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=c6673e99-5e84-474e-8447-3f41a66bf634@gmail.com \
--to=usamaarif642@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=cerasuolodomenico@gmail.com \
--cc=corbet@lwn.net \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=riel@surriel.com \
--cc=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=shakeel.butt@linux.dev \
--cc=willy@infradead.org \
--cc=yuzhao@google.com \
--cc=zhais@google.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