From nobody Fri Dec 19 20:32:32 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC563313E0B for ; Tue, 14 Oct 2025 12:45:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760445904; cv=none; b=mrEDoPW9PSihEa2DRhKGbpQwPKg1YJHUFgBMAdRz11aG+Rs7C1ir8tK0Gj+Y72PQJMmI8c0M1C3QiGyLJK0fv2mZKOfgRL/mE8/pnwzYRKIzdaSV7nctGHt0juZ5SWdbzaRT6JSMyaFxZM+C8+goLfVM1nLEpe+dPIqrXQIsdoo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760445904; c=relaxed/simple; bh=IrdiHcJ9N5g16Q3ASpx314J/26lOuQJs6WEhZdyqT3k=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gVaBWJxQWJnTnv7+zn2R+f6R5q6sOrNeP7T9jpvbkvuXb0mBSSubsbnF7+X8IEM6SgkHYp9uocPqp+nqs2u3/8AX4Ofovn46a8+ML7ViA53riG2cfM/j5iegMo+ekXZzIKcPSs1TCheVV26Z3Tcs2LDlCdcGqPPr+RDawzN1hh8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=FILiOJ2K; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FILiOJ2K" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760445900; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=oq5FU6UUWvw2KLYz4msTSjy80Lvwg4TbSIDB93lwHNo=; b=FILiOJ2KE0GykacXyD6iUmL+TpbK3IKaJtGMEfccgphe+9CYoRUes68QzyEyKIxlC0ZuUU x32BgbI3gnKRTpyMTsvP3paHypL9NAw/Cb+oYUI/VJ6mIdjcZhGJRu1fTHbqjyCiGbWGts jMv4/XnEerPUl2vx88ImjvTnLPcVSDI= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-384-oo5zEpIzMWGwc7mivSUkhQ-1; Tue, 14 Oct 2025 08:44:59 -0400 X-MC-Unique: oo5zEpIzMWGwc7mivSUkhQ-1 X-Mimecast-MFC-AGG-ID: oo5zEpIzMWGwc7mivSUkhQ_1760445898 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-401dbafbcfaso4191494f8f.1 for ; Tue, 14 Oct 2025 05:44:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760445898; x=1761050698; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oq5FU6UUWvw2KLYz4msTSjy80Lvwg4TbSIDB93lwHNo=; b=uwl7U7U2NARhX+QlzHai1zhENKd8NcGhrTD42ImVcdPChWycPUi4OGiKHSU2N9RVOC kqqOUfkNQDl/V8ElciUOYVf3jH0U/Ghn+1ZC8CJ98PLUKp5kkl3E82XFDA6PnjQJlnjm LXUh1/p5GTSwYNYG3mOO5XeuV+EvptGIezvv8b+FgGImnYK22C4xdB+vkgbhwoWIFyaF c+cvj2EfwRYSzpBe2/LyBDgy9YyOxVeMxVmo2ivJZ7uPuZQph12IXXnqDtO2t7VZiKmN xftb+0ijPBSfdSxoXLzsc4Bdk4Dlk2VoDKI3ZFZe7FROVezJaQmt1ZdLBpo2x/P2XlYK I18w== X-Gm-Message-State: AOJu0Yw+OPEDjWW0Kr7Rb/WR2ug0yx6g37RGRai3KdKLxWMSdyVkFWd1 sZZmzH3GEh8Zq5btKu95U1rkbh0fHb5dNacmqJ3bImhUtFiXqfkD7j+eUkWl6BhaFX8MoWuGcsB GvQB8ObEZ9CiWfNKu/ydfDl2ww+hl4zAVwMCb0enQqYyxxi28liY3IkZ34OUBPM56RopQRGQ/0J y9woX8bJHiIbHXTBgO50JIwtJ2mF9lnRl+8YeM+PlbyPh7yQ== X-Gm-Gg: ASbGncszijZEzLN+ABeQBpyxDlwpOcUoVxc7ARkpxJVPWoJPC94Qy3M89yiIExOBpJ/ MVZEq6pI3bTbKF3r71FWToxIw64VyDekQJxnfcZVGW1TbPII1a7iGeOzLMERGUWglBTz4n2PgSN UuTv8Hq/VGeqY8P8WB4E2LeaODT1iKpUnQAdsXdl8zez4Y410R+4CnMtCaF6i6NblY+hxNvoU6+ UNd5HnvbVduOEHo+wXLh8n4JjkGpv5lzNVrce2BiqUGiqm+9jsrNHSobgjKxkcjwboTP/Lqsg+n 3+I1aY8ikM+cX0dOnOyXMC3tzqicebaMOFw= X-Received: by 2002:a05:6000:2003:b0:3eb:5e99:cbb9 with SMTP id ffacd0b85a97d-42666ac410emr16251750f8f.10.1760445898060; Tue, 14 Oct 2025 05:44:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGxSeyruCmc9SGR2jeGa4d8IULuUIdP5u2aBzan4Fq5iEL1yjTsOV2vBHOnBmYhi1j6hNaRzA== X-Received: by 2002:a05:6000:2003:b0:3eb:5e99:cbb9 with SMTP id ffacd0b85a97d-42666ac410emr16251717f8f.10.1760445897499; Tue, 14 Oct 2025 05:44:57 -0700 (PDT) Received: from localhost ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-426e50ef821sm8878961f8f.38.2025.10.14.05.44.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Oct 2025 05:44:56 -0700 (PDT) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , stable@vger.kernel.org, Andrew Morton , Jerrin Shaji George , Broadcom internal kernel review list , Arnd Bergmann , Greg Kroah-Hartman Subject: [PATCH v1] vmw_balloon: indicate success when effectively deflating during migration Date: Tue, 14 Oct 2025 14:44:55 +0200 Message-ID: <20251014124455.478345-1-david@redhat.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 3544c4faccb8 ("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. Fixes: 3544c4faccb8 ("mm/balloon_compaction: stop using __ClearPageMovable(= )") Cc: Cc: Andrew Morton Cc: Jerrin Shaji George Cc: Broadcom internal kernel review list Cc: Arnd Bergmann Cc: Greg Kroah-Hartman Signed-off-by: David Hildenbrand --- I have no easy way to test this, and I assume it happens very very rarely (inflation during migration failing). I would prefer this to go through the MM-tree, as I have some follow-up balloon_compaction reworks also mess with this code. --- drivers/misc/vmw_balloon.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index 6df51ee8db621..cc1d18b3df5ca 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -1737,7 +1737,7 @@ static int vmballoon_migratepage(struct balloon_dev_i= nfo *b_dev_info, { unsigned long status, flags; struct vmballoon *b; - int ret; + int ret =3D 0; =20 b =3D container_of(b_dev_info, struct vmballoon, b_dev_info); =20 @@ -1796,17 +1796,15 @@ static int vmballoon_migratepage(struct balloon_dev= _info *b_dev_info, * A failure happened. While we can deflate the page we just * inflated, this deflation can also encounter an error. Instead * we will decrease the size of the balloon to reflect the - * change and report failure. + * change. */ atomic64_dec(&b->size); - ret =3D -EBUSY; } else { /* * Success. Take a reference for the page, and we will add it to * the list after acquiring the lock. */ get_page(newpage); - ret =3D 0; } =20 /* Update the balloon list under the @pages_lock */ @@ -1817,7 +1815,7 @@ static int vmballoon_migratepage(struct balloon_dev_i= nfo *b_dev_info, * If we succeed just insert it to the list and update the statistics * under the lock. */ - if (!ret) { + if (status =3D=3D VMW_BALLOON_SUCCESS) { balloon_page_insert(&b->b_dev_info, newpage); __count_vm_event(BALLOON_MIGRATE); } base-commit: 1c58c31dc83e39f4790ae778626b6b8b59bc0db8 --=20 2.51.0