linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yang Shi <shy828301@gmail.com>
To: Miaohe Lin <linmiaohe@huawei.com>
Cc: akpm@linux-foundation.org, tony.luck@intel.com, bp@alien8.de,
	 naoya.horiguchi@nec.com, mike.kravetz@oracle.com,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	linux-edac@vger.kernel.org
Subject: Re: [PATCH v2 3/3] mm/memory-failure.c: make non-LRU movable pages unhandlable
Date: Mon, 14 Mar 2022 10:34:17 -0700	[thread overview]
Message-ID: <CAHbLzkp_7iJts8NfCFQdEQuvh-o7YFpU3Axc+6ZCx1ZcJB7z1g@mail.gmail.com> (raw)
In-Reply-To: <20220312074613.4798-4-linmiaohe@huawei.com>

On Fri, Mar 11, 2022 at 11:47 PM Miaohe Lin <linmiaohe@huawei.com> wrote:
>
> We can not really handle non-LRU movable pages in memory failure. Typically
> they are balloon, zsmalloc, etc. Assuming we run into a base (4K) non-LRU
> movable page, we could reach as far as identify_page_state(), it should not
> fall into any category except me_unknown. For the non-LRU compound movable
> pages, they could be taken for transhuge pages but it's unexpected to split
> non-LRU  movable pages using split_huge_page_to_list in memory_failure. So
> we could just simply make non-LRU  movable pages unhandlable to avoid these
> possible nasty cases.
>
> Suggested-by: Yang Shi <shy828301@gmail.com>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Reviewed-by: Yang Shi <shy828301@gmail.com>

> ---
>  mm/memory-failure.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 2ff7dd2078c4..ba621c6823ed 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -1177,12 +1177,18 @@ void ClearPageHWPoisonTakenOff(struct page *page)
>   * does not return true for hugetlb or device memory pages, so it's assumed
>   * to be called only in the context where we never have such pages.
>   */
> -static inline bool HWPoisonHandlable(struct page *page)
> +static inline bool HWPoisonHandlable(struct page *page, unsigned long flags)
>  {
> -       return PageLRU(page) || __PageMovable(page) || is_free_buddy_page(page);
> +       bool movable = false;
> +
> +       /* Soft offline could mirgate non-LRU movable pages */
> +       if ((flags & MF_SOFT_OFFLINE) && __PageMovable(page))
> +               movable = true;
> +
> +       return movable || PageLRU(page) || is_free_buddy_page(page);
>  }
>
> -static int __get_hwpoison_page(struct page *page)
> +static int __get_hwpoison_page(struct page *page, unsigned long flags)
>  {
>         struct page *head = compound_head(page);
>         int ret = 0;
> @@ -1197,7 +1203,7 @@ static int __get_hwpoison_page(struct page *page)
>          * for any unsupported type of page in order to reduce the risk of
>          * unexpected races caused by taking a page refcount.
>          */
> -       if (!HWPoisonHandlable(head))
> +       if (!HWPoisonHandlable(head, flags))
>                 return -EBUSY;
>
>         if (get_page_unless_zero(head)) {
> @@ -1222,7 +1228,7 @@ static int get_any_page(struct page *p, unsigned long flags)
>
>  try_again:
>         if (!count_increased) {
> -               ret = __get_hwpoison_page(p);
> +               ret = __get_hwpoison_page(p, flags);
>                 if (!ret) {
>                         if (page_count(p)) {
>                                 /* We raced with an allocation, retry. */
> @@ -1250,7 +1256,7 @@ static int get_any_page(struct page *p, unsigned long flags)
>                 }
>         }
>
> -       if (PageHuge(p) || HWPoisonHandlable(p)) {
> +       if (PageHuge(p) || HWPoisonHandlable(p, flags)) {
>                 ret = 1;
>         } else {
>                 /*
> @@ -2308,7 +2314,7 @@ int soft_offline_page(unsigned long pfn, int flags)
>
>  retry:
>         get_online_mems();
> -       ret = get_hwpoison_page(page, flags);
> +       ret = get_hwpoison_page(page, flags | MF_SOFT_OFFLINE);
>         put_online_mems();
>
>         if (ret > 0) {
> --
> 2.23.0
>


      parent reply	other threads:[~2022-03-14 17:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-12  7:46 [PATCH v2 0/3] A few fixup patches for memory failure Miaohe Lin
2022-03-12  7:46 ` [PATCH v2 1/3] mm/memory-failure.c: fix race with changing page compound again Miaohe Lin
2022-03-13 23:41   ` HORIGUCHI NAOYA(堀口 直也)
2022-03-14  1:51     ` Miaohe Lin
2022-03-14 18:20   ` Mike Kravetz
2022-03-15 14:19     ` Miaohe Lin
2022-03-15 18:19       ` Yang Shi
2022-03-16  8:18         ` Miaohe Lin
2022-03-16  8:30           ` HORIGUCHI NAOYA(堀口 直也)
2022-03-16  8:41             ` Miaohe Lin
2022-03-12  7:46 ` [PATCH v2 2/3] mm/memory-failure.c: avoid calling invalidate_inode_page() with unexpected pages Miaohe Lin
2022-03-13 23:41   ` HORIGUCHI NAOYA(堀口 直也)
2022-03-14  1:58     ` Miaohe Lin
2022-03-14  2:50       ` HORIGUCHI NAOYA(堀口 直也)
2022-03-14  2:59         ` Miaohe Lin
2022-03-14 23:45           ` Andrew Morton
2022-03-15 13:55             ` Miaohe Lin
2022-03-12  7:46 ` [PATCH v2 3/3] mm/memory-failure.c: make non-LRU movable pages unhandlable Miaohe Lin
2022-03-13 23:43   ` HORIGUCHI NAOYA(堀口 直也)
2022-03-14 17:34   ` Yang Shi [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=CAHbLzkp_7iJts8NfCFQdEQuvh-o7YFpU3Axc+6ZCx1ZcJB7z1g@mail.gmail.com \
    --to=shy828301@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=linmiaohe@huawei.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=naoya.horiguchi@nec.com \
    --cc=tony.luck@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