Thread (7 messages) 7 messages, 6 authors, 2025-07-16

Re: [PATCH v13] vhost: Reintroduces support of kthread API and adds mode selection

From: Simon Horman <horms@kernel.org>
Date: 2025-07-16 08:50:59
Also in: lkml, virtualization

On Tue, Jul 15, 2025 at 08:43:45PM +0200, Markus Elfring wrote:
quoted
This patch reintroduces kthread mode for vhost workers and provides
configuration to select between kthread and task worker.
…

Is there a need to reconsider the relevance once more for the presented
cover letter?


…
quoted
+++ b/drivers/vhost/vhost.c
quoted
+static int vhost_attach_task_to_cgroups(struct vhost_worker *worker)
+{
quoted
+	vhost_worker_queue(worker, &attach.work);
+
+	mutex_lock(&worker->mutex);
quoted
+	worker->attachment_cnt = saved_cnt;
+
+	mutex_unlock(&worker->mutex);
…

Under which circumstances would you become interested to apply a statement
like “guard(mutex)(&worker->mutex);”?
https://elixir.bootlin.com/linux/v6.16-rc6/source/include/linux/mutex.h#L225
Quoting the documentation, I'd suggest these circumstances:

  1.6.5. Using device-managed and cleanup.h constructs

  Netdev remains skeptical about promises of all “auto-cleanup” APIs,
  including even devm_ helpers, historically. They are not the preferred
  style of implementation, merely an acceptable one.

  Use of guard() is discouraged within any function longer than 20 lines,
  scoped_guard() is considered more readable. Using normal lock/unlock is
  still (weakly) preferred.

  Low level cleanup constructs (such as __free()) can be used when building
  APIs and helpers, especially scoped iterators. However, direct use of
  __free() within networking core and drivers is discouraged. Similar
  guidance applies to declaring variables mid-function.

https://docs.kernel.org/6.16-rc6/process/maintainer-netdev.html#using-device-managed-and-cleanup-h-constructs

IOW, the code is fine as-is.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help