Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

David Hildenbrand and committed by
Linus Torvalds
ca215086 4d3467e1

+21 -15
+6 -3
Documentation/admin-guide/mm/pagemap.rst
··· 75 75 20. NOPAGE 76 76 21. KSM 77 77 22. THP 78 - 23. BALLOON 78 + 23. OFFLINE 79 79 24. ZERO_PAGE 80 80 25. IDLE 81 + 26. PGTABLE 81 82 82 83 * ``/proc/kpagecgroup``. This file contains a 64-bit inode number of the 83 84 memory cgroup each page is charged to, indexed by PFN. Only available when ··· 119 118 identical memory pages dynamically shared between one or more processes 120 119 22 - THP 121 120 contiguous pages which construct transparent hugepages 122 - 23 - BALLOON 123 - balloon compaction page 121 + 23 - OFFLINE 122 + page is logically offline 124 123 24 - ZERO_PAGE 125 124 zero page for pfn_zero or huge_zero page 126 125 25 - IDLE ··· 129 128 Note that this flag may be stale in case the page was accessed via 130 129 a PTE. To make sure the flag is up-to-date one has to read 131 130 ``/sys/kernel/mm/page_idle/bitmap`` first. 131 + 26 - PGTABLE 132 + page is in use as a page table 132 133 133 134 IO related page flags 134 135 ---------------------
+2 -2
fs/proc/page.c
··· 152 152 else if (page_count(page) == 0 && is_free_buddy_page(page)) 153 153 u |= 1 << KPF_BUDDY; 154 154 155 - if (PageBalloon(page)) 156 - u |= 1 << KPF_BALLOON; 155 + if (PageOffline(page)) 156 + u |= 1 << KPF_OFFLINE; 157 157 if (PageTable(page)) 158 158 u |= 1 << KPF_PGTABLE; 159 159
+4 -4
include/linux/balloon_compaction.h
··· 95 95 static inline void balloon_page_insert(struct balloon_dev_info *balloon, 96 96 struct page *page) 97 97 { 98 - __SetPageBalloon(page); 98 + __SetPageOffline(page); 99 99 __SetPageMovable(page, balloon->inode->i_mapping); 100 100 set_page_private(page, (unsigned long)balloon); 101 101 list_add(&page->lru, &balloon->pages); ··· 111 111 */ 112 112 static inline void balloon_page_delete(struct page *page) 113 113 { 114 - __ClearPageBalloon(page); 114 + __ClearPageOffline(page); 115 115 __ClearPageMovable(page); 116 116 set_page_private(page, 0); 117 117 /* ··· 141 141 static inline void balloon_page_insert(struct balloon_dev_info *balloon, 142 142 struct page *page) 143 143 { 144 - __SetPageBalloon(page); 144 + __SetPageOffline(page); 145 145 list_add(&page->lru, &balloon->pages); 146 146 } 147 147 148 148 static inline void balloon_page_delete(struct page *page) 149 149 { 150 - __ClearPageBalloon(page); 150 + __ClearPageOffline(page); 151 151 list_del(&page->lru); 152 152 } 153 153
+7 -4
include/linux/page-flags.h
··· 671 671 /* Reserve 0x0000007f to catch underflows of page_mapcount */ 672 672 #define PAGE_MAPCOUNT_RESERVE -128 673 673 #define PG_buddy 0x00000080 674 - #define PG_balloon 0x00000100 674 + #define PG_offline 0x00000100 675 675 #define PG_kmemcg 0x00000200 676 676 #define PG_table 0x00000400 677 677 ··· 706 706 PAGE_TYPE_OPS(Buddy, buddy) 707 707 708 708 /* 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. 711 714 */ 712 - PAGE_TYPE_OPS(Balloon, balloon) 715 + PAGE_TYPE_OPS(Offline, offline) 713 716 714 717 /* 715 718 * If kmemcg is enabled, the buddy allocator will set PageKmemcg() on
+1 -1
include/uapi/linux/kernel-page-flags.h
··· 32 32 33 33 #define KPF_KSM 21 34 34 #define KPF_THP 22 35 - #define KPF_BALLOON 23 35 + #define KPF_OFFLINE 23 36 36 #define KPF_ZERO_PAGE 24 37 37 #define KPF_IDLE 25 38 38 #define KPF_PGTABLE 26
+1 -1
tools/vm/page-types.c
··· 133 133 [KPF_NOPAGE] = "n:nopage", 134 134 [KPF_KSM] = "x:ksm", 135 135 [KPF_THP] = "t:thp", 136 - [KPF_BALLOON] = "o:balloon", 136 + [KPF_OFFLINE] = "o:offline", 137 137 [KPF_PGTABLE] = "g:pgtable", 138 138 [KPF_ZERO_PAGE] = "z:zero_page", 139 139 [KPF_IDLE] = "i:idle_page",