Skip to content

Commit ca21508

Browse files
davidhildenbrandtorvalds
authored andcommitted
mm: convert PG_balloon to PG_offline
PG_balloon was introduced to implement page migration/compaction for pages inflated in virtio-balloon. Nowadays, it is only a marker that a page is part of virtio-balloon and therefore logically offline. We also want to make use of this flag in other balloon drivers - for inflated pages or when onlining a section but keeping some pages offline (e.g. used right now by XEN and Hyper-V via set_online_page_callback()). We are going to expose this flag to dump tools like makedumpfile. But instead of exposing PG_balloon, let's generalize the concept of marking pages as logically offline, so it can be reused for other purposes later on. Rename PG_balloon to PG_offline. This is an indicator that the page is logically offline, the content stale and that it should not be touched (e.g. a hypervisor would have to allocate backing storage in order for the guest to dump an unused page). We can then e.g. exclude such pages from dumps. We replace and reuse KPF_BALLOON (23), as this shouldn't really harm (and for now the semantics stay the same). In following patches, we will make use of this bit also in other balloon drivers. While at it, document PGTABLE. [akpm@linux-foundation.org: fix comment text, per David] Link: http://lkml.kernel.org/r/20181119101616.8901-3-david@redhat.com Signed-off-by: David Hildenbrand <david@redhat.com> Acked-by: Konstantin Khlebnikov <koct9i@gmail.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Pankaj gupta <pagupta@redhat.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Mike Rapoport <rppt@linux.vnet.ibm.com> Cc: Christian Hansen <chansen3@cisco.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Cc: Matthew Wilcox <willy@infradead.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Pavel Tatashin <pasha.tatashin@oracle.com> Cc: Alexander Duyck <alexander.h.duyck@linux.intel.com> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Cc: Miles Chen <miles.chen@mediatek.com> Cc: David Rientjes <rientjes@google.com> Cc: Kazuhito Hagio <k-hagio@ab.jp.nec.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Baoquan He <bhe@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Dave Young <dyoung@redhat.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Haiyang Zhang <haiyangz@microsoft.com> Cc: Juergen Gross <jgross@suse.com> Cc: Julien Freche <jfreche@vmware.com> Cc: Kairui Song <kasong@redhat.com> Cc: "K. Y. Srinivasan" <kys@microsoft.com> Cc: Len Brown <len.brown@intel.com> Cc: Lianbo Jiang <lijiang@redhat.com> Cc: Michal Hocko <mhocko@kernel.org> Cc: Nadav Amit <namit@vmware.com> Cc: Omar Sandoval <osandov@fb.com> Cc: Pavel Machek <pavel@ucw.cz> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> Cc: Stefano Stabellini <sstabellini@kernel.org> Cc: Stephen Hemminger <sthemmin@microsoft.com> Cc: Vitaly Kuznetsov <vkuznets@redhat.com> Cc: Xavier Deguillard <xdeguillard@vmware.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4d3467e commit ca21508

File tree

6 files changed

+21
-15
lines changed

6 files changed

+21
-15
lines changed

Documentation/admin-guide/mm/pagemap.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ number of times a page is mapped.
7575
20. NOPAGE
7676
21. KSM
7777
22. THP
78-
23. BALLOON
78+
23. OFFLINE
7979
24. ZERO_PAGE
8080
25. IDLE
81+
26. PGTABLE
8182

8283
* ``/proc/kpagecgroup``. This file contains a 64-bit inode number of the
8384
memory cgroup each page is charged to, indexed by PFN. Only available when
@@ -118,8 +119,8 @@ Short descriptions to the page flags
118119
identical memory pages dynamically shared between one or more processes
119120
22 - THP
120121
contiguous pages which construct transparent hugepages
121-
23 - BALLOON
122-
balloon compaction page
122+
23 - OFFLINE
123+
page is logically offline
123124
24 - ZERO_PAGE
124125
zero page for pfn_zero or huge_zero page
125126
25 - IDLE
@@ -128,6 +129,8 @@ Short descriptions to the page flags
128129
Note that this flag may be stale in case the page was accessed via
129130
a PTE. To make sure the flag is up-to-date one has to read
130131
``/sys/kernel/mm/page_idle/bitmap`` first.
132+
26 - PGTABLE
133+
page is in use as a page table
131134

132135
IO related page flags
133136
---------------------

fs/proc/page.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ u64 stable_page_flags(struct page *page)
152152
else if (page_count(page) == 0 && is_free_buddy_page(page))
153153
u |= 1 << KPF_BUDDY;
154154

155-
if (PageBalloon(page))
156-
u |= 1 << KPF_BALLOON;
155+
if (PageOffline(page))
156+
u |= 1 << KPF_OFFLINE;
157157
if (PageTable(page))
158158
u |= 1 << KPF_PGTABLE;
159159

include/linux/balloon_compaction.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ extern int balloon_page_migrate(struct address_space *mapping,
9595
static inline void balloon_page_insert(struct balloon_dev_info *balloon,
9696
struct page *page)
9797
{
98-
__SetPageBalloon(page);
98+
__SetPageOffline(page);
9999
__SetPageMovable(page, balloon->inode->i_mapping);
100100
set_page_private(page, (unsigned long)balloon);
101101
list_add(&page->lru, &balloon->pages);
@@ -111,7 +111,7 @@ static inline void balloon_page_insert(struct balloon_dev_info *balloon,
111111
*/
112112
static inline void balloon_page_delete(struct page *page)
113113
{
114-
__ClearPageBalloon(page);
114+
__ClearPageOffline(page);
115115
__ClearPageMovable(page);
116116
set_page_private(page, 0);
117117
/*
@@ -141,13 +141,13 @@ static inline gfp_t balloon_mapping_gfp_mask(void)
141141
static inline void balloon_page_insert(struct balloon_dev_info *balloon,
142142
struct page *page)
143143
{
144-
__SetPageBalloon(page);
144+
__SetPageOffline(page);
145145
list_add(&page->lru, &balloon->pages);
146146
}
147147

148148
static inline void balloon_page_delete(struct page *page)
149149
{
150-
__ClearPageBalloon(page);
150+
__ClearPageOffline(page);
151151
list_del(&page->lru);
152152
}
153153

include/linux/page-flags.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ PAGEFLAG_FALSE(DoubleMap)
671671
/* Reserve 0x0000007f to catch underflows of page_mapcount */
672672
#define PAGE_MAPCOUNT_RESERVE -128
673673
#define PG_buddy 0x00000080
674-
#define PG_balloon 0x00000100
674+
#define PG_offline 0x00000100
675675
#define PG_kmemcg 0x00000200
676676
#define PG_table 0x00000400
677677

@@ -706,10 +706,13 @@ static __always_inline void __ClearPage##uname(struct page *page) \
706706
PAGE_TYPE_OPS(Buddy, buddy)
707707

708708
/*
709-
* PageBalloon() is true for pages that are on the balloon page list
710-
* (see mm/balloon_compaction.c).
709+
* PageOffline() indicates that the page is logically offline although the
710+
* containing section is online. (e.g. inflated in a balloon driver or
711+
* not onlined when onlining the section).
712+
* The content of these pages is effectively stale. Such pages should not
713+
* be touched (read/write/dump/save) except by their owner.
711714
*/
712-
PAGE_TYPE_OPS(Balloon, balloon)
715+
PAGE_TYPE_OPS(Offline, offline)
713716

714717
/*
715718
* If kmemcg is enabled, the buddy allocator will set PageKmemcg() on

include/uapi/linux/kernel-page-flags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#define KPF_KSM 21
3434
#define KPF_THP 22
35-
#define KPF_BALLOON 23
35+
#define KPF_OFFLINE 23
3636
#define KPF_ZERO_PAGE 24
3737
#define KPF_IDLE 25
3838
#define KPF_PGTABLE 26

tools/vm/page-types.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static const char * const page_flag_names[] = {
133133
[KPF_NOPAGE] = "n:nopage",
134134
[KPF_KSM] = "x:ksm",
135135
[KPF_THP] = "t:thp",
136-
[KPF_BALLOON] = "o:balloon",
136+
[KPF_OFFLINE] = "o:offline",
137137
[KPF_PGTABLE] = "g:pgtable",
138138
[KPF_ZERO_PAGE] = "z:zero_page",
139139
[KPF_IDLE] = "i:idle_page",

0 commit comments

Comments
 (0)