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=1796279171; b=jnn1oWUq75X4ncEeawxT5tKerCC3XFPPrbK9r2bbN3zG+Fdx9LNEu1YQWIzx7DEbTuzq CjDIwzXnCPtgT+cknm2YTFFJ4GlBOeYo/g1aYtWq0KjZzoy7cynTZhimFtd/NzwUlZ/23 W2pm0Pjjd0vEO13k0SPwmc46Ub3p+Tl7lzzezfUe6kauyPtPdEJZwOl5p6CFcHGH5Hui9 I+PRSI86lqlXOggLwgF2Gy9liXq3tJDTXym7wS+TrUtS4NY+GCLQSeZP0stP1nmzphppP 2yhtGJDkYpywP1+RMLAAlyQAI8rJtzX7mR/0MmideXB1QorNTI2UA2OU51tBuootQOA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796279171; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=6GsVoO3rOIM/8STRGXcy84mVz2p/xIfzZ6sfeirqkAY=; b=GhHx8m9OOZbBgm1Y/hKFLwFqpVcol0qHIMKNk+CLhj9yEKEUcPdBgeDrFYV4SMvbkNAz JVxNKwZcrf17d06v878N4MSWIOselw2GsZlR1XX82pShl8oO79lZPX11Kc1Xd58XeUtLG 6YTyYeV4u1VRtenPrLYKvtEMvYczm0JfjQnr1Lb3jtaJECIF109dAydMmpNdxAxedr2xI +vypBbAAaDkzDpBd7arXjDr6JLEzJ0p4NbPDkHqmQ0veFBLTuJ/Hkbxdu9zP6vPjqpGWP HQN44Jm6ExoUGyv9brORnJRPvGT4IxsrTf3tZ7502+OEi37LVua1f25AdGIt/co/Urg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cY7On80E; 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 96A4E606A322; Thu, 3 Dec 2026 06:26:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cY7On80E Received: by smtp.kernel.org (Postfix) with ESMTPSA id 054141F000C1; Thu, 3 Dec 2026 06:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796279171; bh=6GsVoO3rOIM/8STRGXcy84mVz2p/xIfzZ6sfeirqkAY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=cY7On80Eqmn4dcZAIV9KXly/BgoXAEqdBYpA4OGT0xqccqnvXjKzgNyZu7AheSLGB EHWEJTlLEYFcohzzl/dL82rYcc+vwvt8oiZA1okxD/gcGnIFIpatHRY16kAm9DwniS RQmh+YeIO5yZZV1thgNOYOzLgkFTKl0a9SpwtOlBhsJ6IFXDCK/6wyHhOQJWh0oUKf jkucbxMxWwAP+dNxergzeqRNGZKFqlfH+klw1rE4VKEyshzV/3ukWU4/SvhVRjp7jt dCmNMHU+06vRK/U+NcUc/EOXWj0kmtWrwkPTRZ8QM7VkkTqqUcOLAyzDNt2NLbIyvU tXiPIIAq8lJfA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] vhost_task: avoid hanging in vhost_task_stop() when worker is frozen Reply-To: sashiko-reviews@lists.linux.dev To: "Prabhakar Reddy K" Cc: kvm@vger.kernel.org, virtualization@lists.linux.dev, "Michael S. Tsirkin" , "Eugenio Perez" In-Reply-To: <20261202062516.677164-1-K.Prabhakarr84@gmail.com> References: <20261202062516.677164-1-K.Prabhakarr84@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 06:26:10 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] vhost_task: per-iteration exit_mutex lock in vhost_task_fn() hot path -- commit 87833b26c841d86ec6124bf02ba1edeecfcdf435 Author: Prabhakar Reddy K vhost_task: avoid hanging in vhost_task_stop() when worker is frozen This commit replaces vhost_task's exit completion with a refcount_t and serializes vtsk->fn() with exit_mutex so vhost_task_stop() can return without waiting for a frozen or stopped worker thread to exit. > diff --git a/kernel/vhost_task.c b/kernel/vhost_task.c > index 3717885a5992a..56b9080469ed7 100644 > --- a/kernel/vhost_task.c > +++ b/kernel/vhost_task.c [ ... ] > @@ -38,15 +46,19 @@ static int vhost_task_fn(void *data) > break; > } > =20 > + mutex_lock(&vtsk->exit_mutex); > /* mb paired w/ vhost_task_stop */ > set_current_state(TASK_INTERRUPTIBLE); > =20 > if (test_bit(VHOST_TASK_FLAGS_STOP, &vtsk->flags)) { > __set_current_state(TASK_RUNNING); > + mutex_unlock(&vtsk->exit_mutex); > break; > } > =20 > did_work =3D vtsk->fn(vtsk->data); > + mutex_unlock(&vtsk->exit_mutex); > + > if (!did_work) > schedule(); > } [Severity: Medium] Does locking vtsk->exit_mutex on every iteration of vhost_task_fn() add mutex overhead to the lockless vhost I/O worker hot path and hold the mutex across multi-second sleeps? For vhost I/O workers, vhost_run_work_list() drains worker->work_list locklessly via llist_del_all(), and each wakeup runs at least two loop iterations (one to process the work and a second to re-check the list before calling schedule()), incurring at least two mutex_lock() and mutex_unlock() pairs per wakeup. In addition, kvm_nx_huge_page_recovery_worker() sleeps in schedule_timeout() inside vtsk->fn(): arch/x86/kvm/mmu/mmu.c:kvm_nx_huge_page_recovery_worker() { ... if (remaining_time > 0) { schedule_timeout(remaining_time); /* check for signals and come back */ return true; } ... } Holding vtsk->exit_mutex across that sleep forces vhost_task_stop() to block in TASK_UNINTERRUPTIBLE on exit_mutex until the worker is scheduled back onto a CPU to return from schedule_timeout(), which can stall if the worker's cgroup CPU quota is throttled. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202062516.6771= 64-1-K.Prabhakarr84@gmail.com?part=3D1