On Wed, Jan 10, 2024 at 03:11:01AM -0500, Michael S. Tsirkin wrote: > On Mon, Jan 08, 2024 at 04:50:15PM -0500, Theodore Ts'o wrote: > > Hi, while doing final testing before sending a pull request, I merged > > in linux-next, and commit 5b9ce7ecd7: virtio_balloon: stay awake while > > adjusting balloon seems to be causing a lockdep warning (see attached) > > when running gce-xfstests on a Google Compute Engine e2 VM. I was not > > able to trigger it using kvm-xfstests, but the following command: > > "gce-xfstests -C 10 ext4/4k generic/476) was sufficient to triger the > > problem. For more information please see [1] and [2]. > > > > [1] https://github.com/tytso/xfstests-bld/blob/master/Documentation/gce-xfstests.md > > [2] https://thunk.org/gce-xfstests > > > > I found it by looking at the git logs, and this commit aroused my > > suspicions, and I further testing showed that the lockdep warning was > > reproducible with this commit, but not when testing with the > > immediately preceeding commit (15b9ce7ecd^). > > > > Cheers, > > > Thanks a lot for the report! > I pushed a fixed patch out (tree rebased). > Would be great if you can confirm it's allright now. I manually fixed up the white-space issues with the patch last night, and verified that it fixed it for me with an overnight test run. (My patch was versus next-20240109, and then I tested with ext4/dev merged in. Previously I had noted the problem with next-20240107 with ext4/dev merged in.) Thanks, - Ted >From 98097bbd4fe2e15db8fa357aa6e29435cb62e450 Mon Sep 17 00:00:00 2001 From: David Stevens <stevensd@xxxxxxxxxxxx> Date: Tue, 9 Jan 2024 14:41:21 +0900 Subject: [PATCH] virtio_balloon: Fix interrupt context deadlock Use _irq spinlock functions with the adjustment_lock, since start_update_balloon_size needs to acquire it in an interrupt context. Fixes: 5b9ce7ecd715 ("virtio_balloon: stay awake while adjusting balloon") Reported-by: Theodore Ts'o <tytso@xxxxxxx> Tested-by: Theodore Ts'o <tytso@xxxxxxx> Signed-off-by: David Stevens <stevensd@xxxxxxxxxxxx> Signed-off-by: Theodore Ts'o <tytso@xxxxxxx> --- drivers/virtio/virtio_balloon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index aa6a1a649ad6..1f5b3dd31fcf 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -459,12 +459,12 @@ static void start_update_balloon_size(struct virtio_balloon *vb) static void end_update_balloon_size(struct virtio_balloon *vb) { - spin_lock(&vb->adjustment_lock); + spin_lock_irq(&vb->adjustment_lock); if (!vb->adjustment_signal_pending && vb->adjustment_in_progress) { vb->adjustment_in_progress = false; pm_relax(vb->vdev->dev.parent); } - spin_unlock(&vb->adjustment_lock); + spin_unlock_irq(&vb->adjustment_lock); } static void virtballoon_changed(struct virtio_device *vdev) @@ -506,9 +506,9 @@ static void update_balloon_size_func(struct work_struct *work) vb = container_of(work, struct virtio_balloon, update_balloon_size_work); - spin_lock(&vb->adjustment_lock); + spin_lock_irq(&vb->adjustment_lock); vb->adjustment_signal_pending = false; - spin_unlock(&vb->adjustment_lock); + spin_unlock_irq(&vb->adjustment_lock); diff = towards_target(vb); -- 2.43.0