From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1DB6CA9EAF for ; Mon, 21 Oct 2019 15:02:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5820F20679 for ; Mon, 21 Oct 2019 15:02:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5820F20679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BFAD26B0003; Mon, 21 Oct 2019 11:02:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BAA606B0005; Mon, 21 Oct 2019 11:02:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ABFD66B0006; Mon, 21 Oct 2019 11:02:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0054.hostedemail.com [216.40.44.54]) by kanga.kvack.org (Postfix) with ESMTP id 856756B0003 for ; Mon, 21 Oct 2019 11:02:40 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 1BEFB8249980 for ; Mon, 21 Oct 2019 15:02:40 +0000 (UTC) X-FDA: 76068108480.05.year39_173796aa5a92b X-HE-Tag: year39_173796aa5a92b X-Filterd-Recvd-Size: 4660 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Mon, 21 Oct 2019 15:02:39 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 18F6CB2E9; Mon, 21 Oct 2019 15:02:38 +0000 (UTC) Date: Mon, 21 Oct 2019 17:02:37 +0200 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oscar Salvador , Andrew Morton , Anshuman Khandual , Pingfan Liu , Qian Cai , Pavel Tatashin , Dan Williams , Vlastimil Babka , Mel Gorman , Mike Rapoport , Alexander Duyck Subject: Re: [PATCH v1 2/2] mm/page_isolation.c: Convert SKIP_HWPOISON to MEMORY_OFFLINE Message-ID: <20191021150237.GU9379@dhcp22.suse.cz> References: <20191021141927.10252-1-david@redhat.com> <20191021141927.10252-3-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191021141927.10252-3-david@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 > Cc: Oscar Salvador > Cc: Andrew Morton > Cc: Anshuman Khandual > Cc: David Hildenbrand > Cc: Pingfan Liu > Cc: Qian Cai > Cc: Pavel Tatashin > Cc: Dan Williams > Cc: Vlastimil Babka > Cc: Mel Gorman > Cc: Mike Rapoport > Cc: Alexander Duyck > Suggested-by: Michal Hocko > Signed-off-by: David Hildenbrand Yes, a highlevel flag makes more sense than requesting specific types of pages to skip over. Acked-by: Michal Hocko 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