2021-10-21 08:44:59

by Cai,Huoqing

[permalink] [raw]
Subject: [PATCH] SUNRPC: Make use of the helper macro kthread_run()

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

Signed-off-by: Cai Huoqing <[email protected]>
---
fs/lockd/svc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index b220e1b91726..934dc13a7011 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -397,7 +397,7 @@ static int lockd_start_svc(struct svc_serv *serv)
svc_sock_update_bufs(serv);
serv->sv_maxconn = nlm_max_connections;

- nlmsvc_task = kthread_create(lockd, nlmsvc_rqst, "%s", serv->sv_name);
+ nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, "%s", serv->sv_name);
if (IS_ERR(nlmsvc_task)) {
error = PTR_ERR(nlmsvc_task);
printk(KERN_WARNING
@@ -405,7 +405,6 @@ static int lockd_start_svc(struct svc_serv *serv)
goto out_task;
}
nlmsvc_rqst->rq_task = nlmsvc_task;
- wake_up_process(nlmsvc_task);

dprintk("lockd_up: service started\n");
return 0;
--
2.25.1


2021-10-21 13:17:43

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH] SUNRPC: Make use of the helper macro kthread_run()

On Thu, 2021-10-21 at 16:43 +0800, Cai Huoqing wrote:
> [You don't often get email from [email protected]. Learn why this
> is important at http://aka.ms/LearnAboutSenderIdentification.]
>
> Repalce kthread_create/wake_up_process() with kthread_run()
> to simplify the code.
>
> Signed-off-by: Cai Huoqing <[email protected]>
> ---
>  fs/lockd/svc.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
> index b220e1b91726..934dc13a7011 100644
> --- a/fs/lockd/svc.c
> +++ b/fs/lockd/svc.c
> @@ -397,7 +397,7 @@ static int lockd_start_svc(struct svc_serv *serv)
>         svc_sock_update_bufs(serv);
>         serv->sv_maxconn = nlm_max_connections;
>
> -       nlmsvc_task = kthread_create(lockd, nlmsvc_rqst, "%s", serv-
> >sv_name);
> +       nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, "%s", serv-
> >sv_name);
>         if (IS_ERR(nlmsvc_task)) {
>                 error = PTR_ERR(nlmsvc_task);
>                 printk(KERN_WARNING
> @@ -405,7 +405,6 @@ static int lockd_start_svc(struct svc_serv *serv)
>                 goto out_task;
>         }
>         nlmsvc_rqst->rq_task = nlmsvc_task;
> -       wake_up_process(nlmsvc_task);

No. That would mean nlmsvc_rqst->rq_task would be uninitialised when
the thread starts. Please try to understand the code before proposing
changes.

>
>         dprintk("lockd_up: service started\n");
>         return 0;
> --
> 2.25.1
>

--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]