From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379431; b=4NK1E20SsZoYMQMfijDyI5gK8PS5mnBDQZxskYckc9ozGa+QB+TFEqXZvwYzcE549Uwy J92RR+oBd31IHzdB16mkh5ylZvR3u6/eZCnl7m343Wp8nEZP2WvCtqh+D5FCPuMOrMv4X sgiWXgd0OVs0Mx0Pfa79tf/JEvG6TbwfGZ4cDJ6dCuLYLezdkbCnQW2E1VBqXMRQr4cwQ 4zAxb5+0qFePcJHY5f5MadFPhFcL3vWrJbDYF/SCsTnWicf7sB539MzcrpnMN3eGQqK3h v2HJN52kllE56zIM9xVeNzLzpRcLbInp0xpydWyNA18QA5ROVqlWgPhVWROdM47VZkQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379431; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=y2tF/2ZnpPt5zMaF7vJnpzpjepPeA8Z7S6xrmCU+7Is=; b=AtGYCCHISXhRqGsl4TWotCtASn2j0e5/QzvZ6Q42mHXPz2ugR8+trpzWDKXiK72JMhAO EX2speZdsqdeGfGLXZOehj6diXEExTyeHfpQvNsholI1VgPEUBW7adpLS8DTK8d0b7kMN fxmyREqxVvfHKhoH12K+pfd+dYASuIUUAtvPQ7xrLcFeTL9ckAvnfus+71e+jxITXg54f hjW8LOzidoXMyvreUkEK4ZakciNs8FeQSPReL7tJmRe4JfHdbpT8ioR3g8m/8IEuKTUiN q1i3tv2n6eUUaTVbGOJ2n8oMUk8ArzL9lE/yy/3F1w5cxGBrbEymqot68+ygE22/jsw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=kxy06e0L; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D735B606A322; Fri, 4 Dec 2026 10:17:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=kxy06e0L Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54C9E1F000CE; Fri, 4 Dec 2026 10:17:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379431; bh=y2tF/2ZnpPt5zMaF7vJnpzpjepPeA8Z7S6xrmCU+7Is=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kxy06e0LIvJ2Q0r9iXPNCpqAwpxk2rOy+GhNs3zf0/8P45OexuM07JGSZERU6vkFT e/RwUX6cDgQO8OinZSDLP0pBrYa3YGApiHNvNiRaWnNc93TX0doCDJovKbP24hkJEb Se+EZBGn4GgbV+4mfA6+wlAZ/TTEGpagkjZqg+Go= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Denis V. Lunev" , "David Hildenbrand (Arm)" , "Michael S. Tsirkin" , Dickson Wu , Sasha Levin Subject: [PATCH 6.12 004/555] virtio_balloon: factor out virtballoon_quiesce() Date: Fri, 4 Dec 2026 19:00:47 +0900 Message-ID: <20261204100604.130935228@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Denis V. Lunev commit 29536a923a9412812eb3e378258019b54538a220 upstream. virtballoon_remove() stops all of the balloon's asynchronous work (the free page reporting worker, the inflate/deflate and stats workers, the OOM notifier and the free page shrinker) before tearing the device down. A following change needs the same teardown from a .shutdown handler, so move it into a virtballoon_quiesce() helper. No functional change. Signed-off-by: Denis V. Lunev Reviewed-by: David Hildenbrand (Arm) Signed-off-by: Michael S. Tsirkin Message-ID: <20260624140846.2616797-3-den@openvz.org> Signed-off-by: Dickson Wu Signed-off-by: Sasha Levin --- drivers/virtio/virtio_balloon.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 5a093d8786b7f..a3b6e38752ab9 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -1120,26 +1120,39 @@ static void remove_common(struct virtio_balloon *vb) vb->vdev->config->del_vqs(vb->vdev); } -static void virtballoon_remove(struct virtio_device *vdev) +/* + * Stop all asynchronous balloon work. The device must still be alive so that + * in-flight requests can drain via the host before it is reset or freed. + */ +static void virtballoon_quiesce(struct virtio_balloon *vb) { - struct virtio_balloon *vb = vdev->priv; + struct virtio_device *vdev = vb->vdev; - if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_REPORTING)) + if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_REPORTING)) page_reporting_unregister(&vb->pr_dev_info); - if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) + if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) unregister_oom_notifier(&vb->oom_nb); - if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) + if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) virtio_balloon_unregister_shrinker(vb); + spin_lock_irq(&vb->stop_update_lock); vb->stop_update = true; spin_unlock_irq(&vb->stop_update_lock); cancel_work_sync(&vb->update_balloon_size_work); cancel_work_sync(&vb->update_balloon_stats_work); - if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) { + if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) cancel_work_sync(&vb->report_free_page_work); +} + +static void virtballoon_remove(struct virtio_device *vdev) +{ + struct virtio_balloon *vb = vdev->priv; + + virtballoon_quiesce(vb); + + if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) destroy_workqueue(vb->balloon_wq); - } remove_common(vb); kfree(vb); -- 2.53.0