mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: Naoya Horiguchi <naoya.horiguchi@linux.dev>
Cc: <akpm@linux-foundation.org>, <naoya.horiguchi@nec.com>,
	<shy828301@gmail.com>, <linux-mm@kvack.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/4] mm: memory-failure: fix potential unexpected return value from unpoison_memory()
Date: Thu, 20 Jul 2023 16:44:01 +0800	[thread overview]
Message-ID: <40d3505b-e27f-b294-582d-b0926a27419e@huawei.com> (raw)
In-Reply-To: <20230719234851.GA1583723@ik1-406-35019.vs.sakura.ne.jp>

On 2023/7/20 7:48, Naoya Horiguchi wrote:
> On Sat, Jul 15, 2023 at 11:17:27AM +0800, Miaohe Lin wrote:
>> If unpoison_memory() fails to clear page hwpoisoned flag, return value
>> ret is expected to be -EBUSY. But when get_hwpoison_page() returns 1
>> and fails to clear page hwpoisoned flag due to races, return value will
>> be unexpected 1 leading to users being confused.
> 
> Thank you for fixing this.
> 
>>
>> Fixes: bf181c582588 ("mm/hwpoison: fix unpoison_memory()")
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>>  mm/memory-failure.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>> index 9ab97016877e..ac074f82f5b3 100644
>> --- a/mm/memory-failure.c
>> +++ b/mm/memory-failure.c
>> @@ -2546,11 +2546,11 @@ int unpoison_memory(unsigned long pfn)
>>  			unpoison_pr_info("Unpoison: failed to grab page %#lx\n",
>>  					 pfn, &unpoison_rs);
>>  	} else {
>> +		ret = -EBUSY;
> 
> It seems be a code smell to me that the variable "ret" is used not only to
> save the return value of unpoison_memory(), but also to save the return
> value from get_hwpoison_page(). So I think that it might be better to use
> another auto-variable solely to save the return value of get_hwpoison_page.
> Then ret has the initial value -EBUSY at this point and no need to
> reinitialize it.
> 

This should be a nice improvement. Will do it in v2.

Thanks Naoya.


  reply	other threads:[~2023-07-20  8:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-15  3:17 [PATCH 0/4] A few fixup and cleanup patches for memory-failure Miaohe Lin
2023-07-15  3:17 ` [PATCH 1/4] mm/swapfile: fix wrong swap entry type for hwpoisoned swapcache page Miaohe Lin
2023-07-15  3:50   ` Matthew Wilcox
2023-07-17  2:33     ` Miaohe Lin
2023-07-17  2:53       ` Matthew Wilcox
2023-07-17  5:55         ` Miaohe Lin
2023-07-23  2:23         ` Miaohe Lin
2023-07-15  3:17 ` [PATCH 2/4] mm: memory-failure: fix potential unexpected return value from unpoison_memory() Miaohe Lin
2023-07-19 23:48   ` Naoya Horiguchi
2023-07-20  8:44     ` Miaohe Lin [this message]
2023-07-15  3:17 ` [PATCH 3/4] mm: memory-failure: avoid false hwpoison page mapped error info Miaohe Lin
2023-07-15  3:59   ` Matthew Wilcox
2023-07-19 23:50   ` Naoya Horiguchi
2023-07-15  3:17 ` [PATCH 4/4] mm: memory-failure: add PageOffline() check Miaohe Lin
2023-07-20  1:09   ` Naoya Horiguchi
2023-07-20  8:42     ` Miaohe Lin
2023-07-20 23:55       ` Naoya Horiguchi

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=40d3505b-e27f-b294-582d-b0926a27419e@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=naoya.horiguchi@linux.dev \
    --cc=naoya.horiguchi@nec.com \
    --cc=shy828301@gmail.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®