linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "HORIGUCHI NAOYA(堀口 直也)" <naoya.horiguchi@nec.com>
To: Oscar Salvador <osalvador@suse.de>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"aris@ruivo.org" <aris@ruivo.org>,
	"mhocko@kernel.org" <mhocko@kernel.org>,
	"tony.luck@intel.com" <tony.luck@intel.com>,
	"cai@lca.pw" <cai@lca.pw>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH v7 09/14] mm,hwpoison: rework soft offline for in-use pages
Date: Wed, 23 Sep 2020 07:30:25 +0000	[thread overview]
Message-ID: <20200923073024.GB15221@hori.linux.bs1.fc.nec.co.jp> (raw)
In-Reply-To: <20200922135650.1634-10-osalvador@suse.de>

On Tue, Sep 22, 2020 at 03:56:45PM +0200, Oscar Salvador wrote:
> This patch changes the way we set and handle in-use poisoned pages.  Until
> now, poisoned pages were released to the buddy allocator, trusting that
> the checks that take place at allocation time would act as a safe net
> and would skip that page.
> 
> This has proved to be wrong, as we got some pfn walkers out there, like
> compaction, that all they care is the page to be in a buddy freelist.
> 
> Although this might not be the only user, having poisoned pages in the
> buddy allocator seems a bad idea as we should only have free pages that
> are ready and meant to be used as such.
> 
> Before explaining the taken approach, let us break down the kind of pages
> we can soft offline.
> 
> - Anonymous THP (after the split, they end up being 4K pages)
> - Hugetlb
> - Order-0 pages (that can be either migrated or invalited)
> 
> * Normal pages (order-0 and anon-THP)
> 
>   - If they are clean and unmapped page cache pages, we invalidate
>     then by means of invalidate_inode_page().
>   - If they are mapped/dirty, we do the isolate-and-migrate dance.
> 
> Either way, do not call put_page directly from those paths.
> Instead, we keep the page and send it to page_handle_poison to perform the
> right handling.
> 
> page_handle_poison sets the HWPoison flag and does the last put_page.
> 
> Down the chain, we placed a check for HWPoison page in
> free_pages_prepare, that just skips any poisoned page, so those pages
> do not end up in any pcplist/freelist.
> 
> After that, we set the refcount on the page to 1 and we increment
> the poisoned pages counter.
> 
> If we see that the check in free_pages_prepare creates trouble, we can
> always do what we do for free pages:
> 
>   - wait until the page hits buddy's freelists
>   - take it off, and flag it
> 
> The downside of the above approach is that we could race with an
> allocation, so by the time we  want to take the page off the buddy, the
> page has been already allocated so we cannot soft offline it.
> But the user could always retry it.
> 
> * Hugetlb pages
> 
>   - We isolate-and-migrate them
> 
> After the migration has been successful, we call dissolve_free_huge_page,
> and we set HWPoison on the page if we succeed.
> Hugetlb has a slightly different handling though.
> 
> While for non-hugetlb pages we cared about closing the race with an
> allocation, doing so for hugetlb pages requires quite some additional
> and intrusive code (we would need to hook in free_huge_page and some other
> places).
> So I decided to not make the code overly complicated and just fail
> normally if the page we allocated in the meantime.
> 
> We can always build on top of this.
> 
> As a bonus, because of the way we handle now in-use pages, we no longer
> need the put-as-isolation-migratetype dance, that was guarding for poisoned
> pages to end up in pcplists.
> 
> Signed-off-by: Oscar Salvador <osalvador@suse.de>

Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>

  reply	other threads:[~2020-09-23  7:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22 13:56 [PATCH v7 00/14] HWPOISON: soft offline rework Oscar Salvador
2020-09-22 13:56 ` [PATCH v7 01/14] mm,hwpoison: cleanup unused PageHuge() check Oscar Salvador
2020-09-22 13:56 ` [PATCH v7 02/14] mm, hwpoison: remove recalculating hpage Oscar Salvador
2020-09-22 13:56 ` [PATCH v7 03/14] mm,hwpoison-inject: don't pin for hwpoison_filter Oscar Salvador
2020-09-22 13:56 ` [PATCH v7 04/14] mm,hwpoison: unexport get_hwpoison_page and make it static Oscar Salvador
2020-09-23  7:24   ` HORIGUCHI NAOYA(堀口 直也)
2020-09-22 13:56 ` [PATCH v7 05/14] mm,hwpoison: refactor madvise_inject_error Oscar Salvador
2020-09-23  7:24   ` HORIGUCHI NAOYA(堀口 直也)
2020-09-22 13:56 ` [PATCH v7 06/14] mm,hwpoison: kill put_hwpoison_page Oscar Salvador
2020-09-23  7:24   ` HORIGUCHI NAOYA(堀口 直也)
2020-09-22 13:56 ` [PATCH v7 07/14] mm,hwpoison: unify THP handling for hard and soft offline Oscar Salvador
2020-09-23  7:26   ` HORIGUCHI NAOYA(堀口 直也)
2020-09-22 13:56 ` [PATCH v7 08/14] mm,hwpoison: rework soft offline for free pages Oscar Salvador
2020-09-23  7:27   ` HORIGUCHI NAOYA(堀口 直也)
2020-09-22 13:56 ` [PATCH v7 09/14] mm,hwpoison: rework soft offline for in-use pages Oscar Salvador
2020-09-23  7:30   ` HORIGUCHI NAOYA(堀口 直也) [this message]
2020-09-22 13:56 ` [PATCH v7 10/14] mm,hwpoison: refactor soft_offline_huge_page and __soft_offline_page Oscar Salvador
2020-09-23  7:35   ` HORIGUCHI NAOYA(堀口 直也)
2020-09-22 13:56 ` [PATCH v7 11/14] mm,hwpoison: return 0 if the page is already poisoned in soft-offline Oscar Salvador
2020-09-23  7:39   ` HORIGUCHI NAOYA(堀口 直也)
2020-09-22 13:56 ` [PATCH v7 12/14] mm,hwpoison: introduce MF_MSG_UNSPLIT_THP Oscar Salvador
2020-09-22 13:56 ` [PATCH v7 13/14] mm,hwpoison: double-check page count in __get_any_page() Oscar Salvador
2020-09-22 13:56 ` [PATCH v7 14/14] mm,hwpoison: Try to narrow window race for free pages Oscar Salvador
2020-09-23  7:40   ` HORIGUCHI NAOYA(堀口 直也)
2020-09-22 17:03 ` [PATCH v7 00/14] HWPOISON: soft offline rework Andrew Morton
2020-09-22 17:56   ` osalvador
2020-09-23 13:29 ` Aristeu Rozanski

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=20200923073024.GB15221@hori.linux.bs1.fc.nec.co.jp \
    --to=naoya.horiguchi@nec.com \
    --cc=akpm@linux-foundation.org \
    --cc=aris@ruivo.org \
    --cc=cai@lca.pw \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=osalvador@suse.de \
    --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