vmw_balloon: mark inflated pages PG_offline
authorDavid Hildenbrand <[email protected]>
Tue, 5 Mar 2019 23:42:41 +0000 (15:42 -0800)
committerLinus Torvalds <[email protected]>
Wed, 6 Mar 2019 05:07:14 +0000 (21:07 -0800)
Mark inflated and never onlined pages PG_offline, to tell the world that
the content is stale and should not be dumped.

[[email protected]: use vmballoon_page_in_frames more widely]
Link: http://lkml.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: David Hildenbrand <[email protected]>
Acked-by: Nadav Amit <[email protected]>
Cc: Xavier Deguillard <[email protected]>
Cc: Nadav Amit <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Julien Freche <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Alexander Duyck <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Baoquan He <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Boris Ostrovsky <[email protected]>
Cc: Christian Hansen <[email protected]>
Cc: Dave Young <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Haiyang Zhang <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Kairui Song <[email protected]>
Cc: Kazuhito Hagio <[email protected]>
Cc: "Kirill A. Shutemov" <[email protected]>
Cc: Konstantin Khlebnikov <[email protected]>
Cc: "K. Y. Srinivasan" <[email protected]>
Cc: Len Brown <[email protected]>
Cc: Lianbo Jiang <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Mike Rapoport <[email protected]>
Cc: Miles Chen <[email protected]>
Cc: Naoya Horiguchi <[email protected]>
Cc: Omar Sandoval <[email protected]>
Cc: Pankaj gupta <[email protected]>
Cc: Pavel Machek <[email protected]>
Cc: Pavel Tatashin <[email protected]>
Cc: Rafael J. Wysocki <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Stephen Hemminger <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Cc: Vitaly Kuznetsov <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
drivers/misc/vmw_balloon.c

index f8240b87df2295a435a84b7aaa05631fad0550d4..869ec842729efd07076419b7eb74a6f40fc8df93 100644 (file)
@@ -556,6 +556,36 @@ vmballoon_page_in_frames(enum vmballoon_page_size_type page_size)
        return 1 << vmballoon_page_order(page_size);
 }
 
+/**
+ * vmballoon_mark_page_offline() - mark a page as offline
+ * @page: pointer for the page.
+ * @page_size: the size of the page.
+ */
+static void
+vmballoon_mark_page_offline(struct page *page,
+                           enum vmballoon_page_size_type page_size)
+{
+       int i;
+
+       for (i = 0; i < vmballoon_page_in_frames(page_size); i++)
+               __SetPageOffline(page + i);
+}
+
+/**
+ * vmballoon_mark_page_online() - mark a page as online
+ * @page: pointer for the page.
+ * @page_size: the size of the page.
+ */
+static void
+vmballoon_mark_page_online(struct page *page,
+                          enum vmballoon_page_size_type page_size)
+{
+       int i;
+
+       for (i = 0; i < vmballoon_page_in_frames(page_size); i++)
+               __ClearPageOffline(page + i);
+}
+
 /**
  * vmballoon_send_get_target() - Retrieve desired balloon size from the host.
  *
@@ -612,6 +642,7 @@ static int vmballoon_alloc_page_list(struct vmballoon *b,
                                         ctl->page_size);
 
                if (page) {
+                       vmballoon_mark_page_offline(page, ctl->page_size);
                        /* Success. Add the page to the list and continue. */
                        list_add(&page->lru, &ctl->pages);
                        continue;
@@ -850,6 +881,7 @@ static void vmballoon_release_page_list(struct list_head *page_list,
 
        list_for_each_entry_safe(page, tmp, page_list, lru) {
                list_del(&page->lru);
+               vmballoon_mark_page_online(page, page_size);
                __free_pages(page, vmballoon_page_order(page_size));
        }