From: David Hildenbrand <david@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, "David Hildenbrand" <david@redhat.com>,
"Michal Hocko" <mhocko@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
kvm@vger.kernel.org, linux-hyperv@vger.kernel.org,
devel@driverdev.osuosl.org, xen-devel@lists.xenproject.org,
x86@kernel.org, "Alexander Duyck" <alexander.duyck@gmail.com>,
"Alexander Duyck" <alexander.h.duyck@linux.intel.com>,
"Alex Williamson" <alex.williamson@redhat.com>,
"Allison Randal" <allison@lohutok.net>,
"Andy Lutomirski" <luto@kernel.org>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
"Anshuman Khandual" <anshuman.khandual@arm.com>,
"Anthony Yznaga" <anthony.yznaga@oracle.com>,
"Ben Chan" <benchan@chromium.org>,
"Benjamin Herrenschmidt" <benh@kernel.crashing.org>,
"Borislav Petkov" <bp@alien8.de>,
"Boris Ostrovsky" <boris.ostrovsky@oracle.com>,
"Christophe Leroy" <christophe.leroy@c-s.fr>,
"Cornelia Huck" <cohuck@redhat.com>,
"Dan Carpenter" <dan.carpenter@oracle.com>,
"Dan Williams" <dan.j.williams@intel.com>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"Fabio Estevam" <festevam@gmail.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Haiyang Zhang" <haiyangz@microsoft.com>,
"H. Peter Anvin" <hpa@zytor.com>,
"Ingo Molnar" <mingo@redhat.com>,
"Isaac J. Manjarres" <isaacm@codeaurora.org>,
"Jeremy Sowden" <jeremy@azazel.net>,
"Jim Mattson" <jmattson@google.com>,
"Joerg Roedel" <joro@8bytes.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Juergen Gross" <jgross@suse.com>,
"KarimAllah Ahmed" <karahmed@amazon.de>,
"Kate Stewart" <kstewart@linuxfoundation.org>,
"Kees Cook" <keescook@chromium.org>,
"K. Y. Srinivasan" <kys@microsoft.com>,
"Madhumitha Prabakaran" <madhumithabiw@gmail.com>,
"Matt Sickler" <Matt.Sickler@daktronics.com>,
"Mel Gorman" <mgorman@techsingularity.net>,
"Michael Ellerman" <mpe@ellerman.id.au>,
"Michal Hocko" <mhocko@suse.com>,
"Mike Rapoport" <rppt@linux.ibm.com>,
"Mike Rapoport" <rppt@linux.vnet.ibm.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Nishka Dasgupta" <nishkadg.linux@gmail.com>,
"Oscar Salvador" <osalvador@suse.de>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Paul Mackerras" <paulus@ozlabs.org>,
"Paul Mackerras" <paulus@samba.org>,
"Pavel Tatashin" <pasha.tatashin@soleen.com>,
"Pavel Tatashin" <pavel.tatashin@microsoft.com>,
"Peter Zijlstra" <peterz@infradead.org>, "Qian Cai" <cai@lca.pw>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Rob Springer" <rspringer@google.com>,
"Sasha Levin" <sashal@kernel.org>,
"Sean Christopherson" <sean.j.christopherson@intel.com>,
"Simon Sandström" <simon@nikanor.nu>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Stephen Hemminger" <sthemmin@microsoft.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Todd Poynor" <toddpoynor@google.com>,
"Vandana BN" <bnvandana@gmail.com>,
"Vitaly Kuznetsov" <vkuznets@redhat.com>,
"Vlastimil Babka" <vbabka@suse.cz>,
"Wanpeng Li" <wanpengli@tencent.com>,
YueHaibing <yuehaibing@huawei.com>
Subject: [PATCH RFC v1 12/12] mm/memory_hotplug: Don't mark pages PG_reserved when initializing the memmap
Date: Tue, 22 Oct 2019 19:12:39 +0200 [thread overview]
Message-ID: <20191022171239.21487-13-david@redhat.com> (raw)
In-Reply-To: <20191022171239.21487-1-david@redhat.com>
Everything should be prepared to stop setting pages PG_reserved when
initializing the memmap on memory hotplug. Most importantly, we
stop marking ZONE_DEVICE pages PG_reserved.
a) We made sure that any code that relied on PG_reserved to detect
ZONE_DEVICE memory will no longer rely on PG_reserved - either
by using pfn_to_online_page() to exclude them right away or by
checking against is_zone_device_page().
b) We made sure that memory blocks with holes cannot be offlined and
therefore also not onlined. We have quite some code that relies on
memory holes being marked PG_reserved. This is now not an issue
anymore.
generic_online_page() still calls __free_pages_core(), which performs
__ClearPageReserved(p). AFAIKS, this should not hurt.
It is worth nothing that the users of online_page_callback_t might see a
change. E.g., until now, pages not freed to the buddy by the HyperV
balloonm were set PG_reserved until freed via generic_online_page(). Now,
they would look like ordinarily allocated pages (refcount == 1). This
callback is used by the XEN balloon and the HyperV balloon. To not
introduce any silent errors, keep marking the pages PG_reserved. We can
most probably stop doing that, but have to double check if there are
issues (e.g., offlining code aborts right away in has_unmovable_pages()
when it runs into a PageReserved(page))
Update the documentation at various places.
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: Sasha Levin <sashal@kernel.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Cc: Pavel Tatashin <pavel.tatashin@microsoft.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Anthony Yznaga <anthony.yznaga@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Suggested-by: Michal Hocko <mhocko@kernel.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
drivers/hv/hv_balloon.c | 6 ++++++
drivers/xen/balloon.c | 7 +++++++
include/linux/page-flags.h | 8 +-------
mm/memory_hotplug.c | 17 +++++++----------
mm/page_alloc.c | 11 -----------
5 files changed, 21 insertions(+), 28 deletions(-)
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index c722079d3c24..3214b0ef5247 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -670,6 +670,12 @@ static struct notifier_block hv_memory_nb = {
/* Check if the particular page is backed and can be onlined and online it. */
static void hv_page_online_one(struct hv_hotadd_state *has, struct page *pg)
{
+ /*
+ * TODO: The core used to mark the pages reserved. Most probably
+ * we can stop doing that now.
+ */
+ __SetPageReserved(pg);
+
if (!has_pfn_is_backed(has, page_to_pfn(pg))) {
if (!PageOffline(pg))
__SetPageOffline(pg);
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 4f2e78a5e4db..af69f057913a 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -374,6 +374,13 @@ static void xen_online_page(struct page *page, unsigned int order)
mutex_lock(&balloon_mutex);
for (i = 0; i < size; i++) {
p = pfn_to_page(start_pfn + i);
+ /*
+ * TODO: The core used to mark the pages reserved. Most probably
+ * we can stop doing that now. However, especially
+ * alloc_xenballooned_pages() left PG_reserved set
+ * on pages that can get mapped to user space.
+ */
+ __SetPageReserved(p);
balloon_append(p);
}
mutex_unlock(&balloon_mutex);
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index f91cb8898ff0..d4f85d866b71 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -30,24 +30,18 @@
* - Pages falling into physical memory gaps - not IORESOURCE_SYSRAM. Trying
* to read/write these pages might end badly. Don't touch!
* - The zero page(s)
- * - Pages not added to the page allocator when onlining a section because
- * they were excluded via the online_page_callback() or because they are
- * PG_hwpoison.
* - Pages allocated in the context of kexec/kdump (loaded kernel image,
* control pages, vmcoreinfo)
* - MMIO/DMA pages. Some architectures don't allow to ioremap pages that are
* not marked PG_reserved (as they might be in use by somebody else who does
* not respect the caching strategy).
- * - Pages part of an offline section (struct pages of offline sections should
- * not be trusted as they will be initialized when first onlined).
* - MCA pages on ia64
* - Pages holding CPU notes for POWER Firmware Assisted Dump
- * - Device memory (e.g. PMEM, DAX, HMM)
* Some PG_reserved pages will be excluded from the hibernation image.
* PG_reserved does in general not hinder anybody from dumping or swapping
* and is no longer required for remap_pfn_range(). ioremap might require it.
* Consequently, PG_reserved for a page mapped into user space can indicate
- * the zero page, the vDSO, MMIO pages or device memory.
+ * the zero page, the vDSO, or MMIO pages.
*
* The PG_private bitflag is set on pagecache pages if they contain filesystem
* specific data (which is normally at page->private). It can be used by
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 7210f4375279..9fbcdeaf0339 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -501,9 +501,7 @@ static void __remove_section(unsigned long pfn, unsigned long nr_pages,
* @altmap: alternative device page map or %NULL if default memmap is used
*
* Generic helper function to remove section mappings and sysfs entries
- * for the section of the memory we are removing. Caller needs to make
- * sure that pages are marked reserved and zones are adjust properly by
- * calling offline_pages().
+ * for the section of the memory we are removing.
*/
void __remove_pages(unsigned long pfn, unsigned long nr_pages,
struct vmem_altmap *altmap)
@@ -584,9 +582,9 @@ static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages,
int order;
/*
- * Online the pages. The callback might decide to keep some pages
- * PG_reserved (to add them to the buddy later), but we still account
- * them as being online/belonging to this zone ("present").
+ * Online the pages. The callback might decide to not free some pages
+ * (to add them to the buddy later), but we still account them as
+ * being online/belonging to this zone ("present").
*/
for (pfn = start_pfn; pfn < end_pfn; pfn += 1ul << order) {
order = min(MAX_ORDER - 1, get_order(PFN_PHYS(end_pfn - pfn)));
@@ -659,8 +657,7 @@ static void __meminit resize_pgdat_range(struct pglist_data *pgdat, unsigned lon
}
/*
* Associate the pfn range with the given zone, initializing the memmaps
- * and resizing the pgdat/zone data to span the added pages. After this
- * call, all affected pages are PG_reserved.
+ * and resizing the pgdat/zone data to span the added pages.
*/
void __ref move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
unsigned long nr_pages, struct vmem_altmap *altmap)
@@ -684,8 +681,8 @@ void __ref move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
/*
* TODO now we have a visible range of pages which are not associated
* with their zone properly. Not nice but set_pfnblock_flags_mask
- * expects the zone spans the pfn range. All the pages in the range
- * are reserved so nobody should be touching them so we should be safe
+ * expects the zone spans the pfn range. The sections are not yet
+ * marked online so nobody should be touching the memmap.
*/
memmap_init_zone(nr_pages, nid, zone_idx(zone), start_pfn,
MEMMAP_HOTPLUG, altmap);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e153280bde9a..29787ac4aeb8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5927,8 +5927,6 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
page = pfn_to_page(pfn);
__init_single_page(page, pfn, zone, nid);
- if (context == MEMMAP_HOTPLUG)
- __SetPageReserved(page);
/*
* Mark the block movable so that blocks are reserved for
@@ -5980,15 +5978,6 @@ void __ref memmap_init_zone_device(struct zone *zone,
__init_single_page(page, pfn, zone_idx, nid);
- /*
- * Mark page reserved as it will need to wait for onlining
- * phase for it to be fully associated with a zone.
- *
- * We can use the non-atomic __set_bit operation for setting
- * the flag as we are still initializing the pages.
- */
- __SetPageReserved(page);
-
/*
* ZONE_DEVICE pages union ->lru with a ->pgmap back pointer
* and zone_device_data. It is a bug if a ZONE_DEVICE page is
--
2.21.0
next prev parent reply other threads:[~2019-10-22 17:17 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-22 17:12 [PATCH RFC v1 00/12] mm: Don't mark hotplugged pages PG_reserved (including ZONE_DEVICE) David Hildenbrand
2019-10-22 17:12 ` [PATCH RFC v1 01/12] mm/memory_hotplug: Don't allow to online/offline memory blocks with holes David Hildenbrand
2019-10-24 3:53 ` Anshuman Khandual
2019-10-24 7:55 ` David Hildenbrand
2019-10-22 17:12 ` [PATCH RFC v1 02/12] mm/usercopy.c: Prepare check_page_span() for PG_reserved changes David Hildenbrand
2019-10-23 8:20 ` David Hildenbrand
2019-10-23 16:25 ` Kees Cook
2019-10-23 16:32 ` David Hildenbrand
2019-10-22 17:12 ` [PATCH RFC v1 03/12] KVM: x86/mmu: Prepare kvm_is_mmio_pfn() " David Hildenbrand
2019-10-22 17:12 ` [PATCH RFC v1 04/12] KVM: Prepare kvm_is_reserved_pfn() " David Hildenbrand
2019-10-22 17:12 ` [PATCH RFC v1 05/12] vfio/type1: Prepare is_invalid_reserved_pfn() " David Hildenbrand
2019-10-22 17:12 ` [PATCH RFC v1 06/12] staging/gasket: Prepare gasket_release_page() " David Hildenbrand
2019-10-23 8:17 ` David Hildenbrand
2019-10-22 17:12 ` [PATCH RFC v1 07/12] staging: kpc2000: Prepare transfer_complete_cb() " David Hildenbrand
2019-10-22 17:55 ` Matt Sickler
2019-10-22 21:01 ` David Hildenbrand
2019-10-22 17:12 ` [PATCH RFC v1 08/12] powerpc/book3s: Prepare kvmppc_book3s_instantiate_page() " David Hildenbrand
2019-10-22 17:12 ` [PATCH RFC v1 09/12] powerpc/64s: Prepare hash_page_do_lazy_icache() " David Hildenbrand
2019-10-22 17:12 ` [PATCH RFC v1 10/12] powerpc/mm: Prepare maybe_pte_to_page() " David Hildenbrand
2019-10-22 17:12 ` [PATCH RFC v1 11/12] x86/mm: Prepare __ioremap_check_ram() " David Hildenbrand
2019-10-22 17:12 ` David Hildenbrand [this message]
2019-10-22 21:54 ` [PATCH RFC v1 00/12] mm: Don't mark hotplugged pages PG_reserved (including ZONE_DEVICE) Dan Williams
2019-10-23 7:26 ` David Hildenbrand
2019-10-23 17:09 ` Dan Williams
2019-10-23 17:27 ` David Hildenbrand
2019-10-23 19:39 ` Dan Williams
2019-10-23 21:22 ` David Hildenbrand
2019-10-24 12:50 ` David Hildenbrand
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=20191022171239.21487-13-david@redhat.com \
--to=david@redhat.com \
--cc=Matt.Sickler@daktronics.com \
--cc=akpm@linux-foundation.org \
--cc=alex.williamson@redhat.com \
--cc=alexander.duyck@gmail.com \
--cc=alexander.h.duyck@linux.intel.com \
--cc=allison@lohutok.net \
--cc=aneesh.kumar@linux.ibm.com \
--cc=anshuman.khandual@arm.com \
--cc=anthony.yznaga@oracle.com \
--cc=benchan@chromium.org \
--cc=benh@kernel.crashing.org \
--cc=bnvandana@gmail.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=cai@lca.pw \
--cc=christophe.leroy@c-s.fr \
--cc=cohuck@redhat.com \
--cc=dan.carpenter@oracle.com \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=devel@driverdev.osuosl.org \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=haiyangz@microsoft.com \
--cc=hannes@cmpxchg.org \
--cc=hpa@zytor.com \
--cc=isaacm@codeaurora.org \
--cc=jeremy@azazel.net \
--cc=jgross@suse.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=karahmed@amazon.de \
--cc=keescook@chromium.org \
--cc=kstewart@linuxfoundation.org \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=luto@kernel.org \
--cc=madhumithabiw@gmail.com \
--cc=mgorman@techsingularity.net \
--cc=mhocko@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=nishkadg.linux@gmail.com \
--cc=npiggin@gmail.com \
--cc=osalvador@suse.de \
--cc=pasha.tatashin@soleen.com \
--cc=paulus@ozlabs.org \
--cc=paulus@samba.org \
--cc=pavel.tatashin@microsoft.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rkrcmar@redhat.com \
--cc=rppt@linux.ibm.com \
--cc=rppt@linux.vnet.ibm.com \
--cc=rspringer@google.com \
--cc=sashal@kernel.org \
--cc=sean.j.christopherson@intel.com \
--cc=simon@nikanor.nu \
--cc=sstabellini@kernel.org \
--cc=sthemmin@microsoft.com \
--cc=tglx@linutronix.de \
--cc=toddpoynor@google.com \
--cc=vbabka@suse.cz \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
--cc=yuehaibing@huawei.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;
as well as URLs for NNTP newsgroup(s).