kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vhost: Make use of the helper macro kthread_run()
@ 2021-10-21  8:44 Cai Huoqing
  2021-10-27 20:02 ` Michael S. Tsirkin
  0 siblings, 1 reply; 6+ messages in thread
From: Cai Huoqing @ 2021-10-21  8:44 UTC (permalink / raw)
  To: caihuoqing
  Cc: Michael S. Tsirkin, Jason Wang, kvm, virtualization, netdev,
	linux-kernel

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

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] vhost: Make use of the helper macro kthread_run()
  2021-10-21  8:44 [PATCH] vhost: Make use of the helper macro kthread_run() Cai Huoqing
@ 2021-10-27 20:02 ` Michael S. Tsirkin
  2021-10-27 20:12   ` Mike Christie
  0 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2021-10-27 20:02 UTC (permalink / raw)
  To: Cai Huoqing
  Cc: Jason Wang, kvm, virtualization, netdev, linux-kernel, Mike Christie

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 <caihuoqing@baidu.com>

Pls check how this interacts with Mike Christie's patches.
Pls fix up the typo in the commit log.

> ---
>  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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vhost: Make use of the helper macro kthread_run()
  2021-10-27 20:02 ` Michael S. Tsirkin
@ 2021-10-27 20:12   ` Mike Christie
  0 siblings, 0 replies; 6+ messages in thread
From: Mike Christie @ 2021-10-27 20:12 UTC (permalink / raw)
  To: Michael S. Tsirkin, Cai Huoqing
  Cc: Jason Wang, kvm, virtualization, netdev, linux-kernel

On 10/27/21 3:02 PM, Michael S. Tsirkin wrote:
> 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 <caihuoqing@baidu.com>
> 
> 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vhost: Make use of the helper macro kthread_run()
  2022-01-27  2:08 Yin Xiujiang
  2022-01-27  8:31 ` Jason Wang
@ 2022-01-27 12:41 ` Michael S. Tsirkin
  1 sibling, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2022-01-27 12:41 UTC (permalink / raw)
  To: Yin Xiujiang; +Cc: jasowang, kvm, virtualization, netdev, linux-kernel

On Thu, Jan 27, 2022 at 10:08:07AM +0800, Yin Xiujiang wrote:
> Repalce kthread_create/wake_up_process() with kthread_run()
> to simplify the code.
> 
> Signed-off-by: Yin Xiujiang <yinxiujiang@kylinos.cn>
> ---
>  drivers/vhost/vhost.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 59edb5a1ffe2..19e9eda9fc71 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -595,7 +595,7 @@ 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,
> +		worker = kthread_run(vhost_worker, dev,
>  					"vhost-%d", current->pid);
>  		if (IS_ERR(worker)) {
>  			err = PTR_ERR(worker);
> @@ -603,7 +603,6 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
>  		}
>  
>  		dev->worker = worker;
> -		wake_up_process(worker); /* avoid contributing to loadavg */
>  
>  		err = vhost_attach_cgroups(dev);
>  		if (err)

I think if you do this, you need to set dev->worker earlier.

> -- 
> 2.30.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] vhost: Make use of the helper macro kthread_run()
  2022-01-27  2:08 Yin Xiujiang
@ 2022-01-27  8:31 ` Jason Wang
  2022-01-27 12:41 ` Michael S. Tsirkin
  1 sibling, 0 replies; 6+ messages in thread
From: Jason Wang @ 2022-01-27  8:31 UTC (permalink / raw)
  To: Yin Xiujiang; +Cc: mst, kvm, virtualization, netdev, linux-kernel

On Thu, Jan 27, 2022 at 10:08 AM Yin Xiujiang <yinxiujiang@kylinos.cn> wrote:
>
> Repalce kthread_create/wake_up_process() with kthread_run()
> to simplify the code.
>
> Signed-off-by: Yin Xiujiang <yinxiujiang@kylinos.cn>
> ---
>  drivers/vhost/vhost.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 59edb5a1ffe2..19e9eda9fc71 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -595,7 +595,7 @@ 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,
> +               worker = kthread_run(vhost_worker, dev,
>                                         "vhost-%d", current->pid);

Mike plans to introduce user_worker_create() to allow rlimit check[1].
So this is probably not needed.

Thanks

[1] https://www.spinics.net/lists/kernel/msg4161030.html (I'm not sure
this is the recent version, please check the list)


>                 if (IS_ERR(worker)) {
>                         err = PTR_ERR(worker);
> @@ -603,7 +603,6 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
>                 }
>
>                 dev->worker = worker;
> -               wake_up_process(worker); /* avoid contributing to loadavg */
>
>                 err = vhost_attach_cgroups(dev);
>                 if (err)
> --
> 2.30.0
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] vhost: Make use of the helper macro kthread_run()
@ 2022-01-27  2:08 Yin Xiujiang
  2022-01-27  8:31 ` Jason Wang
  2022-01-27 12:41 ` Michael S. Tsirkin
  0 siblings, 2 replies; 6+ messages in thread
From: Yin Xiujiang @ 2022-01-27  2:08 UTC (permalink / raw)
  To: mst, jasowang; +Cc: kvm, virtualization, netdev, linux-kernel, yinxiujiang

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

Signed-off-by: Yin Xiujiang <yinxiujiang@kylinos.cn>
---
 drivers/vhost/vhost.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 59edb5a1ffe2..19e9eda9fc71 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -595,7 +595,7 @@ 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,
+		worker = kthread_run(vhost_worker, dev,
 					"vhost-%d", current->pid);
 		if (IS_ERR(worker)) {
 			err = PTR_ERR(worker);
@@ -603,7 +603,6 @@ long vhost_dev_set_owner(struct vhost_dev *dev)
 		}
 
 		dev->worker = worker;
-		wake_up_process(worker); /* avoid contributing to loadavg */
 
 		err = vhost_attach_cgroups(dev);
 		if (err)
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-27 12:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21  8:44 [PATCH] vhost: Make use of the helper macro kthread_run() Cai Huoqing
2021-10-27 20:02 ` Michael S. Tsirkin
2021-10-27 20:12   ` Mike Christie
2022-01-27  2:08 Yin Xiujiang
2022-01-27  8:31 ` Jason Wang
2022-01-27 12:41 ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).