* [PATCH -next 1/1] mm/memory-failure.c: Cleanup in unpoison_memory
@ 2022-11-25 6:54 Wupeng Ma
2022-11-25 8:54 ` HORIGUCHI NAOYA(堀口 直也)
2022-11-26 1:41 ` Miaohe Lin
0 siblings, 2 replies; 3+ messages in thread
From: Wupeng Ma @ 2022-11-25 6:54 UTC (permalink / raw)
To: naoya.horiguchi
Cc: linmiaohe, akpm, pizhenwei, linux-mm, mawupeng1, linux-kernel
From: Ma Wupeng <mawupeng1@huawei.com>
If freeit it true, the value of ret must be zero, there is no need to
check the value of freeit after label unlock_mutex.
We can drop variable freeit to do this cleanup.
Signed-off-by: Ma Wupeng <mawupeng1@huawei.com>
---
mm/memory-failure.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 2e62940c7bae..c77a9e37e27e 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2338,7 +2338,6 @@ int unpoison_memory(unsigned long pfn)
struct page *page;
struct page *p;
int ret = -EBUSY;
- int freeit = 0;
unsigned long count = 1;
bool huge = false;
static DEFINE_RATELIMIT_STATE(unpoison_rs, DEFAULT_RATELIMIT_INTERVAL,
@@ -2413,10 +2412,9 @@ int unpoison_memory(unsigned long pfn)
goto unlock_mutex;
}
}
- freeit = !!TestClearPageHWPoison(p);
put_page(page);
- if (freeit) {
+ if (TestClearPageHWPoison(p)) {
put_page(page);
ret = 0;
}
@@ -2424,7 +2422,7 @@ int unpoison_memory(unsigned long pfn)
unlock_mutex:
mutex_unlock(&mf_mutex);
- if (!ret || freeit) {
+ if (!ret) {
if (!huge)
num_poisoned_pages_sub(pfn, 1);
unpoison_pr_info("Unpoison: Software-unpoisoned page %#lx\n",
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -next 1/1] mm/memory-failure.c: Cleanup in unpoison_memory
2022-11-25 6:54 [PATCH -next 1/1] mm/memory-failure.c: Cleanup in unpoison_memory Wupeng Ma
@ 2022-11-25 8:54 ` HORIGUCHI NAOYA(堀口 直也)
2022-11-26 1:41 ` Miaohe Lin
1 sibling, 0 replies; 3+ messages in thread
From: HORIGUCHI NAOYA(堀口 直也) @ 2022-11-25 8:54 UTC (permalink / raw)
To: Wupeng Ma; +Cc: linmiaohe, akpm, pizhenwei, linux-mm, linux-kernel
On Fri, Nov 25, 2022 at 02:54:44PM +0800, Wupeng Ma wrote:
> From: Ma Wupeng <mawupeng1@huawei.com>
>
> If freeit it true, the value of ret must be zero, there is no need to
> check the value of freeit after label unlock_mutex.
>
> We can drop variable freeit to do this cleanup.
>
> Signed-off-by: Ma Wupeng <mawupeng1@huawei.com>
Hi Wupeng,
> ---
> mm/memory-failure.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 2e62940c7bae..c77a9e37e27e 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -2338,7 +2338,6 @@ int unpoison_memory(unsigned long pfn)
> struct page *page;
> struct page *p;
> int ret = -EBUSY;
> - int freeit = 0;
> unsigned long count = 1;
> bool huge = false;
> static DEFINE_RATELIMIT_STATE(unpoison_rs, DEFAULT_RATELIMIT_INTERVAL,
> @@ -2413,10 +2412,9 @@ int unpoison_memory(unsigned long pfn)
> goto unlock_mutex;
> }
> }
> - freeit = !!TestClearPageHWPoison(p);
>
> put_page(page);
> - if (freeit) {
> + if (TestClearPageHWPoison(p)) {
This reorders put_page() and TestClearPageHWPoison(), but when we run
into this else block, the target page or hugepage should have refcount > 1,
so it does not cause any behavioral change. So I'm fine with it.
Looks good to me. Thank you for the patch.
Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
> put_page(page);
> ret = 0;
> }
> @@ -2424,7 +2422,7 @@ int unpoison_memory(unsigned long pfn)
>
> unlock_mutex:
> mutex_unlock(&mf_mutex);
> - if (!ret || freeit) {
> + if (!ret) {
> if (!huge)
> num_poisoned_pages_sub(pfn, 1);
> unpoison_pr_info("Unpoison: Software-unpoisoned page %#lx\n",
> --
> 2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next 1/1] mm/memory-failure.c: Cleanup in unpoison_memory
2022-11-25 6:54 [PATCH -next 1/1] mm/memory-failure.c: Cleanup in unpoison_memory Wupeng Ma
2022-11-25 8:54 ` HORIGUCHI NAOYA(堀口 直也)
@ 2022-11-26 1:41 ` Miaohe Lin
1 sibling, 0 replies; 3+ messages in thread
From: Miaohe Lin @ 2022-11-26 1:41 UTC (permalink / raw)
To: Wupeng Ma; +Cc: akpm, pizhenwei, linux-mm, linux-kernel, HORIGUCHI NAOYA
On 2022/11/25 14:54, Wupeng Ma wrote:
> From: Ma Wupeng <mawupeng1@huawei.com>
>
> If freeit it true, the value of ret must be zero, there is no need to
s/it/is/
> check the value of freeit after label unlock_mutex.
>
> We can drop variable freeit to do this cleanup.
>
> Signed-off-by: Ma Wupeng <mawupeng1@huawei.com>
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
Thanks,
Miaohe Lin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-26 1:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25 6:54 [PATCH -next 1/1] mm/memory-failure.c: Cleanup in unpoison_memory Wupeng Ma
2022-11-25 8:54 ` HORIGUCHI NAOYA(堀口 直也)
2022-11-26 1:41 ` Miaohe Lin
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).