From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (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 EC07828469A for ; Fri, 20 Mar 2026 12:56:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774011405; cv=none; b=Ns38DxelP/C/KInLENyb07lN8xSMbHlu7c7p23yzj56ipU29WigAQLpI2OyOFsg88xWS/wAblnRcvEXzQ1H4Yaegmw0s1cDFWMdYG+ZbWwEzpaAxfHpFwvUH+7xARdw5b0ZvV80hNCcbw+LJbhte5uNEZyy4yCHS2cpE4G3QVBg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774011405; c=relaxed/simple; bh=4bVZo/d4rOBIhiZ7XAzKCcJgHrXCFeePsl5rOM9yM3M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ce0k8IMmciuod/MhTeiJcbxSlYuutlVtOqunitepiHXf4RYMORx1pizUwKl8jpmgtSRGhwJmFhDakCPk6NeAwmOPSXlk5n9D9+CiVvSeDQj2xDwDOmMDhPf9y6Oo0T1uZ3ClA09+bdXYDtz6Btk2HOrIcRwCo/lTyHX73WdoJ6o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bitbyteword.org; spf=pass smtp.mailfrom=bitbyteword.org; dkim=pass (2048-bit key) header.d=bitbyteword.org header.i=@bitbyteword.org header.b=JiwAuTdt; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bitbyteword.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bitbyteword.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bitbyteword.org header.i=@bitbyteword.org header.b="JiwAuTdt" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-8cb5c9ba82bso92610285a.2 for ; Fri, 20 Mar 2026 05:56:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bitbyteword.org; s=google; t=1774011403; x=1774616203; 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=vvkndFGKylW8fkh7sz/NV3MjrUD7bcisFfPEBGAPp+8=; b=JiwAuTdt6m93CwJThtZ3ETykiWXv2VwJ1VPtSQqg7YXyv6sCthPD9imxPVUJkNhgZI ofziGhZ/Bt3ggjwd/Tirv4qGsR0ZRX+xLxXWPxxVWwbQkHh/EhlIhZG2oRUSaxDQYF7y lKNrsrZ6i5t2l4OQMNtzuT1CqAvS6yQiNK0OTWVy24KiZGfw3yAxS/029sC9WHgk9uho hPoIN8Ns+lWU4RT+8AsEgb7v3VyCtekSNMuFH5vfbvu25YhM+cN/8Xk+3TLDUzbgbnz4 uwB9aqHT1MjT6ieojj5KkzZMWbQQ/iJGRW89t3MR+Q7KIlFnSsnthBiPTeTpc0LkjniZ fR2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774011403; x=1774616203; 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=vvkndFGKylW8fkh7sz/NV3MjrUD7bcisFfPEBGAPp+8=; b=ELOGZr2Gc1Pg+6/NlK47o663fBOGTdgFWlYWbRsPJx48o1XzYB7+IKJl6eghznBd2T vM82Aa+JBzAzY05ZLUsMohUuxjJoZhM2JGIGKbrYpj+Fkr1i8M7dD9rVjlKjUphzGMHE 6ctBUzcFaGLgxvV53Fd91vXWzYcMfjMwcLcMVNMcIhDRjRNXDyQgGYJugomzRWsvB1PF UTLcHJxKJ/UGEO7LLyQcz0YyDPUIscJNUYDFeuuGl00Xe7swghhu6FlfBobzCoeK6EaI b/kNhSiwu/j1WJtPOkNmvGQR/Yza3tI34rKZgxTbtbe4qj0L3bxnuks4b4mUqhgFFlZF U1sg== X-Forwarded-Encrypted: i=1; AJvYcCWYqfBEkOWRk9jMI3/eD/zxKrtnmAeRoOruGuPTKyccYZdPAyPol3Yx/JLAvYfbrlI/A/3VPRAFjV3CDyY=@vger.kernel.org X-Gm-Message-State: AOJu0YwH8c9GjkajiWaFeMlGtkmROdKUOeGA61YNHvPCT/Bq55tg3PQw IEjJzY9kEuOLQq+VQV/nA/hNIBlOAJQsiFSrO0ERSt2iD5EJxIFdpKqYq/usepYBF0I= X-Gm-Gg: ATEYQzz9HkSEjiPXialGhvxdIu4I1oT36VSHlRuH1+MZAnUA18V8wlNu+lorZ4QgLUo hG4w+Qd+dHObb0ob6qMES5RV59euP3wREp/veEWcNNpAb2OC70n/Y/4kftvxU12q1lT3g7GG1wR i7On95uENW5G4QkeHoknzcj9FlUtpswGHA3UkdEpDQnKlRodj2TSl8IafOOVR0s7iOj0/PCv/60 mH8kzI/zHRZ77TDj7bKrqlNuI4EMC6FJ9F9bFqBGAy4hWtCJczF5u6LoXDZYsm/+zot3/6DLqWx 9svLxkFgMOXo6ph/hnilpmBix01aXIJT746MaKHgUbGulY/yszDlV/I00J0aCd7oFalJLhNWBqh DW+amhxHUxtfViSunIrMk+SHmGdQQ92fmN3LAvWoXGY4Mx8bGx6WV0wT2h4FknJecVbFibXIEuN aO9Ca3sFSiqXeqmHRec6Ki1DnOOHzGvY7IXRugX85U6aA3P4uzz3ahDs3YXYTMXAvZtQ== X-Received: by 2002:a05:6214:601b:b0:89c:5f6e:451f with SMTP id 6a1803df08f44-89c85a0fd6fmr39097576d6.26.1774011402754; Fri, 20 Mar 2026 05:56:42 -0700 (PDT) Received: from vinmini.lan (c-73-143-21-186.hsd1.vt.comcast.net. [73.143.21.186]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89c8525e195sm19110756d6.22.2026.03.20.05.56.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2026 05:56:42 -0700 (PDT) From: "Vineeth Pillai (Google)" To: sonam.sanju@intel.corp-partner.google.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, pbonzini@redhat.com, seanjc@google.com, sonam.sanju@intel.com, dmaluka@chromium.org, "Vineeth Pillai (Google)" Subject: Re: [PATCH] KVM: irqfd: fix shutdown deadlock by moving SRCU sync outside resampler_lock Date: Fri, 20 Mar 2026 08:56:33 -0400 Message-ID: <20260320125633.2290675-1-vineeth@bitbyteword.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260317162754.3231300-1-sonam.sanju@intel.corp-partner.google.com> References: <20260317162754.3231300-1-sonam.sanju@intel.corp-partner.google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi Sonam, > irqfd_resampler_shutdown() calls synchronize_srcu_expedited() while > holding kvm->irqfds.resampler_lock. This can deadlock when multiple > irqfd_shutdown workers run concurrently on the kvm-irqfd-cleanup > workqueue during VM teardown (e.g. crosvm shutdown on Android): > > CPU A (mutex holder) CPU B/C/D (mutex waiters) > irqfd_shutdown() irqfd_shutdown() > irqfd_resampler_shutdown() irqfd_resampler_shutdown() > mutex_lock(resampler_lock) <---- mutex_lock(resampler_lock) // BLOCKED > list_del_rcu(...) ...blocked... > synchronize_srcu_expedited() // Waiters block workqueue, > // waits for SRCU grace preventing SRCU grace > // period which requires period from completing > // workqueue progress --- DEADLOCK --- I think we might have this issue in the kvm_irqfd_assign path as well where synchronize_srcu_expedited is called with the resampler_lock held. I saw similar lockup during a stress test where VMs were created and destroyed continously. I could see one task waiting on SRCU GP: [ T93] task:crosvm_security state:D stack:0 pid:8215 tgid:8215 ppid:1 task_flags:0x400000 flags:0x00080002. [ T93] Call Trace: [ T93] [ T93] __schedule+0x87a/0xd60 [ T93] schedule+0x5e/0xe0 [ T93] schedule_timeout+0x2e/0x130 [ T93] ? queue_delayed_work_on+0x7f/0xd0 [ T93] wait_for_common+0xf7/0x1f0 [ T93] synchronize_srcu_expedited+0x109/0x140 [ T93] ? __cfi_wakeme_after_rcu+0x10/0x10 [ T93] kvm_irqfd+0x362/0x5e0 [ T93] kvm_vm_ioctl+0x706/0x780 [ T93] ? fd_install+0x2c/0xf0 [ T93] __se_sys_ioctl+0x7a/0xd0 [ T93] do_syscall_64+0x61/0xf10 [ T93] ? arch_exit_to_user_mode_prepare+0x9/0xb0 [ T93] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ T93] RIP: 0033:0x79048f9bdd67 [ T93] RSP: 002b:00007ffc3aa82028 EFLAGS: 00000206. And another task waiting on the mutex: [ C0] task:kworker/11:2 state:R running task stack:0 pid:25180 tgid:25180 ppid:2 task_flags:0x4208060 flags:0x00080000 [ C0] Workqueue: kvm-irqfd-cleanup irqfd_shutdown [ C0] Call Trace: [ C0] [ C0] __schedule+0x87a/0xd60 [ C0] schedule+0x5e/0xe0 [ C0] schedule_preempt_disabled+0x10/0x20 [ C0] __mutex_lock+0x413/0xe40 [ C0] irqfd_resampler_shutdown+0x23/0x150 [ C0] irqfd_shutdown+0x66/0xc0 [ C0] process_scheduled_works+0x219/0x450 [ C0] worker_thread+0x30b/0x450 [ C0] ? __cfi_worker_thread+0x10/0x10 [ C0] kthread+0x230/0x270 [ C0] ? __cfi_kthread+0x10/0x10 [ C0] ret_from_fork+0xf2/0x150 [ C0] ? __cfi_kthread+0x10/0x10 [ C0] ret_from_fork_asm+0x1a/0x30 [ C0] The work queue was full as well I think: [ C0] pwq 46: cpus=11 node=0 flags=0x0 nice=0 active=1024 refcnt=2062 There were other tasks waiting for SRCU GP completion in the resampler shutdown path. Also, there were other traces showing lockups (mostly in mm), but I think thats a secondary effect of this lockup and might not be relevant. I can provide the full logs if needed. Please have a look and see if this path needs to be handled to fully fix this issue. Thanks, Vineeth