linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yin Fengwei <fengwei.yin@intel.com>
To: Miaohe Lin <linmiaohe@huawei.com>
Cc: <linux-mm@kvack.org>, <naoya.horiguchi@nec.com>,
	<aaron.lu@intel.com>, <tony.luck@intel.com>,
	<qiuxu.zhuo@intel.com>, Matthew Wilcox <willy@infradead.org>
Subject: Re: [RFC PATCH] mm/memory-failure: release private data before split THP
Date: Thu, 4 Aug 2022 09:54:55 +0800	[thread overview]
Message-ID: <39c1f73d-d90c-1423-7bc8-a39414f2a69e@intel.com> (raw)
In-Reply-To: <410bb7b3-db57-47a9-f97c-1e3441aadb23@huawei.com>

On 2022/8/4 09:19, Miaohe Lin wrote:
> On 2022/8/3 21:01, Matthew Wilcox wrote:
>> On Wed, Aug 03, 2022 at 10:52:43AM +0800, Yin Fengwei wrote:
>>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>>> index da39ec8afca8..08e21973b120 100644
>>> --- a/mm/memory-failure.c
>>> +++ b/mm/memory-failure.c
>>> @@ -1484,7 +1484,16 @@ static int identify_page_state(unsigned long pfn, struct page *p,
>>>  
>>>  static int try_to_split_thp_page(struct page *page, const char *msg)
>>>  {
>>> +	struct page *head = compound_head(page);
>>  > +
>>>  	lock_page(page);
>>> +	/*
>>> +	 * If thp page has private data attached, thp split will fail.
>>> +	 * Release private data before split thp.
>>> +	 */
>>> +	if (page_has_private(head))
>>> +		try_to_release_page(head, GFP_KERNEL);
>>> +
>>>  	if (unlikely(split_huge_page(page))) {
>>>  		unsigned long pfn = page_to_pfn(page);
>>
>> It seems a shame to use the old page approach instead of the
>> shiny new folio approach.  We're quite close to being able to remove
>> try_to_release_page() in 6.1 or 6.2 so adding a new caller is a bad idea.
>> How about this:
>>
>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>> index da39ec8afca8..765b383288b1 100644
>> --- a/mm/memory-failure.c
>> +++ b/mm/memory-failure.c
>> @@ -1484,16 +1484,21 @@ static int identify_page_state(unsigned long pfn, struct page *p,
>>  
>>  static int try_to_split_thp_page(struct page *page, const char *msg)
>>  {
>> -	lock_page(page);
>> +	struct folio *folio = page_folio(page);
>> +
>> +	folio_lock(folio);
>> +	if (folio_test_private(folio))
>> +		filemap_release_folio(folio, GFP_KERNEL);
> 
> If filemap_release_folio fails, we could avoid trying split_huge_page here?
Maybe we could stick to this regarding this is error recovery path
instead of hot path?

> 
>>  	if (unlikely(split_huge_page(page))) {
>>  		unsigned long pfn = page_to_pfn(page);
>>  
>> -		unlock_page(page);
>> +		folio_unlock(folio);
>>  		pr_info("%s: %#lx: thp split failed\n", msg, pfn);
>> -		put_page(page);
>> +		folio_put(folio);
>>  		return -EBUSY;
>>  	}
>> -	unlock_page(page);
>> +	folio = page_folio(page);
> 
> Above line (re-fetching folio) might need a comment to avoid future confusing ?
I will add one line comment about why page_folio need here.

> 
> Anyway, this patch looks good to me. Thanks for fixing.
Thanks.

Regards
Yin, Fengwei

> 
>> +	folio_unlock(folio);
>>  
>>  	return 0;
>>  }
>>
>> .
>>
> 



  reply	other threads:[~2022-08-04  1:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03  2:52 [RFC PATCH] mm/memory-failure: release private data before split THP Yin Fengwei
2022-08-03  9:39 ` HORIGUCHI NAOYA(堀口 直也)
2022-08-03 14:42   ` Yin, Fengwei
2022-08-03 13:01 ` Matthew Wilcox
2022-08-03 13:32   ` Yin, Fengwei
2022-08-03 13:36     ` Matthew Wilcox
2022-08-03 13:40       ` Yin, Fengwei
2022-08-03 14:33       ` Yin, Fengwei
2022-08-03 15:26         ` Matthew Wilcox
2022-08-04  1:19   ` Miaohe Lin
2022-08-04  1:54     ` Yin Fengwei [this message]
2022-08-04  2:05       ` Miaohe Lin

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=39c1f73d-d90c-1423-7bc8-a39414f2a69e@intel.com \
    --to=fengwei.yin@intel.com \
    --cc=aaron.lu@intel.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-mm@kvack.org \
    --cc=naoya.horiguchi@nec.com \
    --cc=qiuxu.zhuo@intel.com \
    --cc=tony.luck@intel.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;
as well as URLs for NNTP newsgroup(s).