Commit babde186 authored by Miaohe Lin's avatar Miaohe Lin Committed by Andrew Morton

mm/memory-failure: add macro GET_PAGE_MAX_RETRY_NUM

Add helper macro GET_PAGE_MAX_RETRY_NUM to replace magic number 3.  No
functional change intended.

Link: https://lkml.kernel.org/r/20240612071835.157004-4-linmiaohe@huawei.comSigned-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Cc: Borislav Petkov (AMD) <bp@alien8.de>
Cc: David Hildenbrand <david@redhat.com>
Cc: kernel test robot <lkp@intel.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Tony Luck <tony.luck@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent ceb32d6a
...@@ -1417,6 +1417,8 @@ static int __get_hwpoison_page(struct page *page, unsigned long flags) ...@@ -1417,6 +1417,8 @@ static int __get_hwpoison_page(struct page *page, unsigned long flags)
return 0; return 0;
} }
#define GET_PAGE_MAX_RETRY_NUM 3
static int get_any_page(struct page *p, unsigned long flags) static int get_any_page(struct page *p, unsigned long flags)
{ {
int ret = 0, pass = 0; int ret = 0, pass = 0;
...@@ -1431,12 +1433,12 @@ static int get_any_page(struct page *p, unsigned long flags) ...@@ -1431,12 +1433,12 @@ static int get_any_page(struct page *p, unsigned long flags)
if (!ret) { if (!ret) {
if (page_count(p)) { if (page_count(p)) {
/* We raced with an allocation, retry. */ /* We raced with an allocation, retry. */
if (pass++ < 3) if (pass++ < GET_PAGE_MAX_RETRY_NUM)
goto try_again; goto try_again;
ret = -EBUSY; ret = -EBUSY;
} else if (!PageHuge(p) && !is_free_buddy_page(p)) { } else if (!PageHuge(p) && !is_free_buddy_page(p)) {
/* We raced with put_page, retry. */ /* We raced with put_page, retry. */
if (pass++ < 3) if (pass++ < GET_PAGE_MAX_RETRY_NUM)
goto try_again; goto try_again;
ret = -EIO; ret = -EIO;
} }
...@@ -1462,7 +1464,7 @@ static int get_any_page(struct page *p, unsigned long flags) ...@@ -1462,7 +1464,7 @@ static int get_any_page(struct page *p, unsigned long flags)
* A page we cannot handle. Check whether we can turn * A page we cannot handle. Check whether we can turn
* it into something we can handle. * it into something we can handle.
*/ */
if (pass++ < 3) { if (pass++ < GET_PAGE_MAX_RETRY_NUM) {
put_page(p); put_page(p);
shake_page(p); shake_page(p);
count_increased = false; count_increased = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment