From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B64833BBFB2 for ; Wed, 24 Jun 2026 14:08:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782310136; cv=none; b=ZOXBDbSUsqsSrh5NIJwbM1lI5aKY1GLPwOTkFzD+8/NqbSkpgcyh7bKE7Ow/Bx60XJVI87nJ3ytlY1DOHkmlHFtkgGAWKC7ZAFTX6/OWmvx6F4/TbHjCSR+7kw+9zkf/6CSuEDWDELM3gOCTnzYZuxdeMykMsxvW8Wjnz4fu01I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782310136; c=relaxed/simple; bh=iJ0nXXEBO/MOSBmfVwMD5Gb1+SrNTM5Q603UKVWvAcM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UoQLeEQr19Z4YN7Wd6uVC19rWVV+bW9JVOvilKowf72UUXJFVGJcZ+LvEwiIwDTBXW4ikNgn2hsHL5Qs1cp+sRIsZA2RbfAvMSGn8qh8Nr8tTKWXBrHnTsUPKtmjqcRR5xvwDYfA8SRc0W/PrfyxRhrZ07vCYxIEKKpFBJcSGEA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=openvz.org; spf=pass smtp.mailfrom=openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b=cHFA/5cR; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=openvz.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=openvz.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="cHFA/5cR" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-490ace40f4bso11123045e9.3 for ; Wed, 24 Jun 2026 07:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1782310133; x=1782914933; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IzlXEJV0FcXuNIk6GbdUEWcGLXrLvl7ADJNJs6ZuJv0=; b=cHFA/5cRHDYjN7EW0nSK/tPi7JlgktQFVHknJsOSozRzEFBAqURTl37Boh7rKHGfTH ZikH4/bkAeAwtqdG4NjwsXlEq4zZ0e4JeR1RFvFAWOgX+FcCg0EB57LBuQ5aJFe+R2by KAIrnmf8DuIyMujoUSJ4PohewPLQPSViZRCk1UIKeC41+uTzdB0oFomn5lL42Rt0m6z2 bjrExp1r9lXK32mvcgXtXJoOD4Q5QtiiI8Fk0afnv2uOiNcfiZ8Pvr2OUA6gDgSm9xYu WAXMAs87WeHIi4I4PUH55HjNjK92oke+QKgDMIFnQ+iaRUf4eVKBDIvg0rRbU/ruIukP nvEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782310133; x=1782914933; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=IzlXEJV0FcXuNIk6GbdUEWcGLXrLvl7ADJNJs6ZuJv0=; b=YzgNJybzWgWN2VXmmBZgGUPk3jsYNghCKGmHyxVjYf8rEKM561/hIFgF7XtpIfBOu5 JWFJOqv6RX+bTfydUUPRExor9AqsUfI5kyfbYnzgLASuoyng6WpNj+jVBhrKsQFLC9DJ jNbTW7zBZ2prOKE5LRo+wf1WVX7e9xoMw3HgEUu91qp6Z99KqB/jMpsKU0dRbSrAfQCN 8as+Kss7yaAMtXvZaL5sA7UmG4D7wO9HMt+kRZL9KdYIbFqK6appymOBW3twkIWy2pQ7 RIXBUCmnHse61djC8nnosuWeZmbOzYJVTgF/cVr7vr4HkkfM3hyBzD4k76NHGzXFcZJE KFbg== X-Forwarded-Encrypted: i=1; AFNElJ8HFWZrpnKDp6iX1UAU/+LB6SpVah3QBzekXdCbLeJVG91cB7V7s20d5EjugYo56wv389+V5gWlig96h04=@vger.kernel.org X-Gm-Message-State: AOJu0YxAHlo2zi0BL6wqWCpISdM4ou4Dlj/ormB0JxDDWW87BAPjQdge +4lODqSYQU8g/l+quTRErlTVB00xeD3glsMDeGF7ZjsilSq+9kBIgN8UUn7WY0qTQTWU2qu0ii5 FRx+eU+JZeg== X-Gm-Gg: AfdE7cmzQGWsC5mxcmSRwPTX01p42LhR6+EeNY4e+LpNhWnNJtgUE84GcVTK4XN+/Qm F4oDRDcyXJz2NCVnzRJc9sg901F2B1vKU5X7ls30c+DD1mRPLRfrRZGKVYQAWtMUbHvdMIZoF58 wWfNFMou11B+Y0DN3VRhxkRd4gNeeTr2UBOJYCit+chuuz1RxuB8OmU1pSVbZ3KGOHEo2NvoGRW 3tZB3N5Swn12ooybNFthmUaD1v3dpwlll1KnIrlQKWfe6opyTLhrRAp2MZgmH1qsW9Z0K+llxFz pKBEjt/jXU8OVsoMk4DHBw9bmg6xQ0rLBtT/tcFO7S/kiuLPiSpFP3ZV+bwebA2QupfMYUoAU23 62xoUJlbO48XbMNnEUb/2I++AJ40YJbKf5TXWy3doGEbf1W+kmARigH7YHoh2CEaDWLrKaA== X-Received: by 2002:a05:600c:83c8:b0:492:3763:aeb9 with SMTP id 5b1f17b1804b1-49260873614mr51941975e9.21.1782310133083; Wed, 24 Jun 2026 07:08:53 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:306c:c2d:85d5:28d5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4923fd1fa34sm519680275e9.5.2026.06.24.07.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 07:08:52 -0700 (PDT) From: "Denis V. Lunev" To: mst@redhat.com, david@kernel.org Cc: virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, "Denis V. Lunev" Subject: [PATCH v2 3/4] virtio_balloon: quiesce balloon work before device shutdown Date: Wed, 24 Jun 2026 16:08:45 +0200 Message-ID: <20260624140846.2616797-4-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260624140846.2616797-1-den@openvz.org> References: <20260624140846.2616797-1-den@openvz.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Commit 8bd2fa086a04 ("virtio: break and reset virtio devices on device_shutdown()") added a generic virtio bus .shutdown handler that breaks and resets every virtio device during device_shutdown(), i.e. on reboot and kexec. virtio_balloon provides no .shutdown of its own, so that generic path runs while the balloon's asynchronous work is still armed. Once the device has been broken, virtqueue_add_inbuf() in virtballoon_free_page_report() returns -EIO and trips its WARN_ON_ONCE(). On a kernel booted with panic_on_warn that turns an ordinary reboot, for example a kexec based upgrade, into a fatal panic in the middle of device_shutdown(), so the machine never reaches the new kernel. Relaxing that single WARN_ON_ONCE() would only hide the symptom: the inflate/deflate and OOM paths do not warn, they call wait_event(vb->acked, ...) and would instead block forever on a broken queue that can no longer complete. The device has to be quiesced, not just kept quiet. Add a .shutdown handler that quiesces the balloon via the shared virtballoon_quiesce() helper while the device is still alive, and only then breaks and resets it via virtio_device_shutdown(). Unlike virtballoon_remove() the balloon workqueue is not destroyed, as shutdown does not free the device and cancel_work_sync() together with stop_update already prevent any further work from being queued. Fixes: 8bd2fa086a04 ("virtio: break and reset virtio devices on device_shutdown()") Signed-off-by: Denis V. Lunev --- drivers/virtio/virtio_balloon.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 5b02d9191ac6..26fc3c40d5b2 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -1137,6 +1137,12 @@ static void virtballoon_remove(struct virtio_device *vdev) kfree(vb); } +static void virtballoon_shutdown(struct virtio_device *vdev) +{ + virtballoon_quiesce(vdev->priv); + virtio_device_shutdown(vdev); +} + #ifdef CONFIG_PM_SLEEP static int virtballoon_freeze(struct virtio_device *vdev) { @@ -1202,6 +1208,7 @@ static struct virtio_driver virtio_balloon_driver = { .validate = virtballoon_validate, .probe = virtballoon_probe, .remove = virtballoon_remove, + .shutdown = virtballoon_shutdown, .config_changed = virtballoon_changed, #ifdef CONFIG_PM_SLEEP .freeze = virtballoon_freeze, -- 2.53.0