[PATCH] vhost: Make use of the helper macro kthread_run()

Subsystems: the rest, virtio host (vhost)

STALE1756d

3 messages, 3 authors, 2021-10-27 · open the first message on its own page

[PATCH] vhost: Make use of the helper macro kthread_run()

From: Cai Huoqing <hidden>
Date: 2021-10-21 08:44:14

Repalce kthread_create/wake_up_process() with kthread_run()
to simplify the code.

Signed-off-by: Cai Huoqing <redacted>
---
 drivers/vhost/vhost.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 59edb5a1ffe2..e67bd5603b5f 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -595,15 +595,15 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
 
 	dev->kcov_handle = kcov_common_handle();
 	if (dev->use_worker) {
-		worker = kthread_create(vhost_worker, dev,
-					"vhost-%d", current->pid);
+		/* avoid contributing to loadavg */
+		worker = kthread_run(vhost_worker, dev,
+				     "vhost-%d", current->pid);
 		if (IS_ERR(worker)) {
 			err = PTR_ERR(worker);
 			goto err_worker;
 		}
 
 		dev->worker = worker;
-		wake_up_process(worker); /* avoid contributing to loadavg */
 
 		err = vhost_attach_cgroups(dev);
 		if (err)
-- 
2.25.1

Re: [PATCH] vhost: Make use of the helper macro kthread_run()

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: 2021-10-27 20:02:19

On Thu, Oct 21, 2021 at 04:44:06PM +0800, Cai Huoqing wrote:
Repalce kthread_create/wake_up_process() with kthread_run()
to simplify the code.

Signed-off-by: Cai Huoqing <redacted>
Pls check how this interacts with Mike Christie's patches.
Pls fix up the typo in the commit log.
quoted hunk
---
 drivers/vhost/vhost.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 59edb5a1ffe2..e67bd5603b5f 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -595,15 +595,15 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
 
 	dev->kcov_handle = kcov_common_handle();
 	if (dev->use_worker) {
-		worker = kthread_create(vhost_worker, dev,
-					"vhost-%d", current->pid);
+		/* avoid contributing to loadavg */
doesn't this comment have any value anymore?
+		worker = kthread_run(vhost_worker, dev,
+				     "vhost-%d", current->pid);
 		if (IS_ERR(worker)) {
 			err = PTR_ERR(worker);
 			goto err_worker;
 		}
 
 		dev->worker = worker;
-		wake_up_process(worker); /* avoid contributing to loadavg */
 
 		err = vhost_attach_cgroups(dev);
 		if (err)
-- 
2.25.1

Re: [PATCH] vhost: Make use of the helper macro kthread_run()

From: Mike Christie <michael.christie@oracle.com>
Date: 2021-10-27 20:13:01

On 10/27/21 3:02 PM, Michael S. Tsirkin wrote:
On Thu, Oct 21, 2021 at 04:44:06PM +0800, Cai Huoqing wrote:
quoted
Repalce kthread_create/wake_up_process() with kthread_run()
to simplify the code.

Signed-off-by: Cai Huoqing <redacted>
Pls check how this interacts with Mike Christie's patches.
Pls fix up the typo in the commit log.
Hi Cai,

We probably don't need this patch since it's an API cleanup and
not fixing a bug. I'm replacing this code with the kernel_worker API
with this patch

https://lore.kernel.org/all/20211007214448.6282-9-michael.christie@oracle.com/

in this patchset;

https://lore.kernel.org/all/20211007214448.6282-1-michael.christie@oracle.com/

so the issue of using kthread_create + wake_up_process will be
gone shortly either way.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help