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 <mho...@suse.com>
> Cc: Oscar Salvador <osalva...@suse.de>
> Cc: Andrew Morton <a...@linux-foundation.org>
> Cc: Anshuman Khandual <anshuman.khand...@arm.com>
> Cc: David Hildenbrand <da...@redhat.com>
> Cc: Pingfan Liu <kernelf...@gmail.com>
> Cc: Qian Cai <c...@lca.pw>
> Cc: Pavel Tatashin <pasha.tatas...@soleen.com>
> Cc: Dan Williams <dan.j.willi...@intel.com>
> Cc: Vlastimil Babka <vba...@suse.cz>
> Cc: Mel Gorman <mgor...@techsingularity.net>
> Cc: Mike Rapoport <r...@linux.vnet.ibm.com>
> Cc: Alexander Duyck <alexander.h.du...@linux.intel.com>
> Suggested-by: Michal Hocko <mho...@suse.com>
> Signed-off-by: David Hildenbrand <da...@redhat.com>

Yes, a highlevel flag makes more sense than requesting specific types of
pages to skip over.

Acked-by: Michal Hocko <mho...@suse.com>

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

Reply via email to