linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Matthew Wilcox <willy@infradead.org>, Huang Ying <ying.huang@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Muchun Song <muchun.song@linux.dev>,
	David Hildenbrand <david@redhat.com>, <linux-mm@kvack.org>
Subject: Re: [PATCH 1/2] mm: convert clear_huge_page() to clear_large_folio()
Date: Fri, 14 Jun 2024 13:29:59 +0800	[thread overview]
Message-ID: <f4ec66ba-c9e3-439e-b5e1-dbd4323858c3@huawei.com> (raw)
In-Reply-To: <ZmsHjv4boc3uHC3J@casper.infradead.org>



On 2024/6/13 22:51, Matthew Wilcox wrote:
> On Thu, Jun 13, 2024 at 06:53:43PM +0800, Kefeng Wang wrote:
>> +++ b/include/linux/mm.h
>> @@ -4071,9 +4071,7 @@ enum mf_action_page_type {
>>   };
>>   
>>   #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLBFS)
>> -extern void clear_huge_page(struct page *page,
>> -			    unsigned long addr_hint,
>> -			    unsigned int pages_per_huge_page);
>> +void clear_large_folio(struct folio *folio, unsigned long addr_hint);
> 
> I think this is properly called
> 
> void folio_zero_user(struct folio *folio, unsigned long user_addr);

OK,

> 
>> -void clear_huge_page(struct page *page,
>> -		     unsigned long addr_hint, unsigned int pages_per_huge_page)
>> +void clear_large_folio(struct folio *folio, unsigned long addr_hint)
>>   {
>> +	unsigned int pages_per_huge_page = folio_nr_pages(folio);
> 
> I think it's worth renaming to nr_pages here. >
>>   	unsigned long addr = addr_hint &
>>   		~(((unsigned long)pages_per_huge_page << PAGE_SHIFT) - 1);
> 
> This can just be:
> 
> 	unsigned long addr = user_addr & ~(folio_size(folio) - 1);
> 
> Umm.  Except this assumes that the folio is always mapped to userspace
> at its natural alignment.  And that's true for hugetlb, but not true
> for THP.  So I think this needs to be moved into the callers for which
> it is true, and we need documentation that user_addr is expected to be
> the base address that the folio is mapped at.
> 

It's better to move it into the callers, but one more question, the
user_addr is that the app will access, or the base addres if we can't
know it, so even in hugetlb, we should use vmf->real_address in
hugetlb_no_page(), also Cced Huang Ying, correct me if I'm wrong.

Thanks.


      reply	other threads:[~2024-06-14  5:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13 10:53 Kefeng Wang
2024-06-13 10:53 ` [PATCH 2/2] mm: memory: use folio in struct copy_subpage_arg Kefeng Wang
2024-06-14 12:26   ` David Hildenbrand
2024-06-13 14:51 ` [PATCH 1/2] mm: convert clear_huge_page() to clear_large_folio() Matthew Wilcox
2024-06-14  5:29   ` Kefeng Wang [this message]

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=f4ec66ba-c9e3-439e-b5e1-dbd4323858c3@huawei.com \
    --to=wangkefeng.wang@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    --cc=willy@infradead.org \
    --cc=ying.huang@intel.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