[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190625075227.15193-4-osalvador@suse.de>
Date: Tue, 25 Jun 2019 09:52:25 +0200
From: Oscar Salvador <osalvador@...e.de>
To: akpm@...ux-foundation.org
Cc: mhocko@...e.com, dan.j.williams@...el.com,
pasha.tatashin@...een.com, Jonathan.Cameron@...wei.com,
david@...hat.com, anshuman.khandual@....com, vbabka@...e.cz,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Oscar Salvador <osalvador@...e.de>
Subject: [PATCH v2 3/5] mm,memory_hotplug: Introduce Vmemmap page helpers
Introduce a set of functions for Vmemmap pages.
Set of functions:
- {Set,Clear,Check} Vmemmap flag
- Given a vmemmap page, get its vmemmap-head
- Get #nr of vmemmap pages taking into account the current position
of the page
These functions will be used for the code handling Vmemmap pages.
Signed-off-by: Oscar Salvador <osalvador@...e.de>
---
include/linux/page-flags.h | 34 ++++++++++++++++++++++++++++++++++
mm/util.c | 2 ++
2 files changed, 36 insertions(+)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index b848517da64c..a8b9b57162b3 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -466,6 +466,40 @@ static __always_inline int __PageMovable(struct page *page)
PAGE_MAPPING_MOVABLE;
}
+#define VMEMMAP_PAGE (~PAGE_MAPPING_FLAGS)
+static __always_inline int PageVmemmap(struct page *page)
+{
+ return PageReserved(page) && (unsigned long)page->mapping == VMEMMAP_PAGE;
+}
+
+static __always_inline int __PageVmemmap(struct page *page)
+{
+ return (unsigned long)page->mapping == VMEMMAP_PAGE;
+}
+
+static __always_inline void __ClearPageVmemmap(struct page *page)
+{
+ __ClearPageReserved(page);
+ page->mapping = NULL;
+}
+
+static __always_inline void __SetPageVmemmap(struct page *page)
+{
+ __SetPageReserved(page);
+ page->mapping = (void *)VMEMMAP_PAGE;
+}
+
+static __always_inline struct page *vmemmap_get_head(struct page *page)
+{
+ return (struct page *)page->freelist;
+}
+
+static __always_inline unsigned long get_nr_vmemmap_pages(struct page *page)
+{
+ struct page *head = vmemmap_get_head(page);
+ return head->private - (page - head);
+}
+
#ifdef CONFIG_KSM
/*
* A KSM page is one of those write-protected "shared pages" or "merged pages"
diff --git a/mm/util.c b/mm/util.c
index 021648a8a3a3..5e20563cdef6 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -607,6 +607,8 @@ struct address_space *page_mapping(struct page *page)
mapping = page->mapping;
if ((unsigned long)mapping & PAGE_MAPPING_ANON)
return NULL;
+ if ((unsigned long)mapping == VMEMMAP_PAGE)
+ return NULL;
return (void *)((unsigned long)mapping & ~PAGE_MAPPING_FLAGS);
}
--
2.12.3
Powered by blists - more mailing lists