Skip to content

Commit aa05a04

Browse files
davidhildenbrandgregkh
authored andcommitted
vmw_balloon: indicate success when effectively deflating during migration
[ Upstream commit 4ba5a8a7faa647ada8eae61a36517cf369f5bbe4 ] When migrating a balloon page, we first deflate the old page to then inflate the new page. However, if inflating the new page succeeded, we effectively deflated the old page, reducing the balloon size. In that case, the migration actually worked: similar to migrating+ immediately deflating the new page. The old page will be freed back to the buddy. Right now, the core will leave the page be marked as isolated (as we returned an error). When later trying to putback that page, we will run into the WARN_ON_ONCE() in balloon_page_putback(). That handling was changed in commit 3544c4f ("mm/balloon_compaction: stop using __ClearPageMovable()"); before that change, we would have tolerated that way of handling it. To fix it, let's just return 0 in that case, making the core effectively just clear the "isolated" flag + freeing it back to the buddy as if the migration succeeded. Note that the new page will also get freed when the core puts the last reference. Note that this also makes it all be more consistent: we will no longer unisolate the page in the balloon driver while keeping it marked as being isolated in migration core. This was found by code inspection. Link: https://lkml.kernel.org/r/[email protected] Fixes: 3544c4f ("mm/balloon_compaction: stop using __ClearPageMovable()") Signed-off-by: David Hildenbrand <[email protected]> Cc: Jerrin Shaji George <[email protected]> Cc: Broadcom internal kernel review list <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent df5c32a commit aa05a04

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

drivers/misc/vmw_balloon.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ static int vmballoon_migratepage(struct balloon_dev_info *b_dev_info,
17371737
{
17381738
unsigned long status, flags;
17391739
struct vmballoon *b;
1740-
int ret;
1740+
int ret = 0;
17411741

17421742
b = container_of(b_dev_info, struct vmballoon, b_dev_info);
17431743

@@ -1796,17 +1796,15 @@ static int vmballoon_migratepage(struct balloon_dev_info *b_dev_info,
17961796
* A failure happened. While we can deflate the page we just
17971797
* inflated, this deflation can also encounter an error. Instead
17981798
* we will decrease the size of the balloon to reflect the
1799-
* change and report failure.
1799+
* change.
18001800
*/
18011801
atomic64_dec(&b->size);
1802-
ret = -EBUSY;
18031802
} else {
18041803
/*
18051804
* Success. Take a reference for the page, and we will add it to
18061805
* the list after acquiring the lock.
18071806
*/
18081807
get_page(newpage);
1809-
ret = 0;
18101808
}
18111809

18121810
/* Update the balloon list under the @pages_lock */
@@ -1817,7 +1815,7 @@ static int vmballoon_migratepage(struct balloon_dev_info *b_dev_info,
18171815
* If we succeed just insert it to the list and update the statistics
18181816
* under the lock.
18191817
*/
1820-
if (!ret) {
1818+
if (status == VMW_BALLOON_SUCCESS) {
18211819
balloon_page_insert(&b->b_dev_info, newpage);
18221820
__count_vm_event(BALLOON_MIGRATE);
18231821
}

0 commit comments

Comments
 (0)