Re: [PATCH v1 2/2] mm/page_isolation.c: Convert SKIP_HWPOISON to MEMORY_OFFLINE
From: Michal Hocko
Date: Mon Oct 21 2019 - 11:02:42 EST
On Mon 21-10-19 16:19:26, David Hildenbrand wrote:
> We have two types of users of page isolation:
> 1. Memory offlining: Offline memory so it can be unplugged. Memory won't
> be touched.
> 2. Memory allocation: Allocate memory (e.g., alloc_contig_range()) to
> become the owner of the memory and make use of it.
>
> For example, in case we want to offline memory, we can ignore (skip over)
> PageHWPoison() pages, as the memory won't get used. We can allow to
> offline memory. In contrast, we don't want to allow to allocate such
> memory.
>
> Let's generalize the approach so we can special case other types of
> pages we want to skip over in case we offline memory. While at it, also
> pass the same flags to test_pages_isolated().
>
> Cc: Michal Hocko <mhocko@xxxxxxxx>
> Cc: Oscar Salvador <osalvador@xxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: Anshuman Khandual <anshuman.khandual@xxxxxxx>
> Cc: David Hildenbrand <david@xxxxxxxxxx>
> Cc: Pingfan Liu <kernelfans@xxxxxxxxx>
> Cc: Qian Cai <cai@xxxxxx>
> Cc: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx>
> Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
> Cc: Vlastimil Babka <vbabka@xxxxxxx>
> Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx>
> Cc: Mike Rapoport <rppt@xxxxxxxxxxxxxxxxxx>
> Cc: Alexander Duyck <alexander.h.duyck@xxxxxxxxxxxxxxx>
> Suggested-by: Michal Hocko <mhocko@xxxxxxxx>
> Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
Yes, a highlevel flag makes more sense than requesting specific types of
pages to skip over.
Acked-by: Michal Hocko <mhocko@xxxxxxxx>
Please make the code easier to follow ...
> ---
> include/linux/page-isolation.h | 4 ++--
> mm/memory_hotplug.c | 8 +++++---
> mm/page_alloc.c | 4 ++--
> mm/page_isolation.c | 12 ++++++------
> 4 files changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index bf6b21f02154..b44712c7fdd7 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -8270,7 +8270,7 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count,
> * The HWPoisoned page may be not in buddy system, and
> * page_count() is not 0.
> */
> - if ((flags & SKIP_HWPOISON) && PageHWPoison(page))
> + if (flags & MEMORY_OFFLINE && PageHWPoison(page))
> continue;
>
> if (__PageMovable(page))
[...]
> @@ -257,7 +258,7 @@ void undo_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn,
> */
> static unsigned long
> __test_page_isolated_in_pageblock(unsigned long pfn, unsigned long end_pfn,
> - bool skip_hwpoisoned_pages)
> + int flags)
> {
> struct page *page;
>
> @@ -274,7 +275,7 @@ __test_page_isolated_in_pageblock(unsigned long pfn, unsigned long end_pfn,
> * simple way to verify that as VM_BUG_ON(), though.
> */
> pfn += 1 << page_order(page);
> - else if (skip_hwpoisoned_pages && PageHWPoison(page))
> + else if (flags & MEMORY_OFFLINE && PageHWPoison(page))
> /* A HWPoisoned page cannot be also PageBuddy */
> pfn++;
> else
.. and use parentheses for the flag check.
--
Michal Hocko
SUSE Labs