* [PATCH] usb: atm: Make use of the helper macro kthread_run()
@ 2021-10-21 8:43 Cai Huoqing
2021-10-21 8:56 ` Duncan Sands
0 siblings, 1 reply; 4+ messages in thread
From: Cai Huoqing @ 2021-10-21 8:43 UTC (permalink / raw)
To: caihuoqing; +Cc: Duncan Sands, Greg Kroah-Hartman, linux-usb, linux-kernel
Repalce kthread_create/wake_up_process() with kthread_run()
to simplify the code.
Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
---
drivers/usb/atm/usbatm.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index da17be1ef64e..b1ea3c6384f9 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -976,7 +976,7 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
{
struct task_struct *t;
- t = kthread_create(usbatm_do_heavy_init, instance, "%s",
+ t = kthread_run(usbatm_do_heavy_init, instance, "%s",
instance->driver->driver_name);
if (IS_ERR(t)) {
usb_err(instance, "%s: failed to create kernel_thread (%ld)!\n",
@@ -985,7 +985,6 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
}
instance->thread = t;
- wake_up_process(t);
wait_for_completion(&instance->thread_started);
return 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: atm: Make use of the helper macro kthread_run()
2021-10-21 8:43 [PATCH] usb: atm: Make use of the helper macro kthread_run() Cai Huoqing
@ 2021-10-21 8:56 ` Duncan Sands
0 siblings, 0 replies; 4+ messages in thread
From: Duncan Sands @ 2021-10-21 8:56 UTC (permalink / raw)
To: Cai Huoqing; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel
Hi Cai Huoqing,
On 21/10/2021 10:43, Cai Huoqing wrote:
> Repalce kthread_create/wake_up_process() with kthread_run()
> to simplify the code.
>
> Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
> ---
> drivers/usb/atm/usbatm.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
> index da17be1ef64e..b1ea3c6384f9 100644
> --- a/drivers/usb/atm/usbatm.c
> +++ b/drivers/usb/atm/usbatm.c
> @@ -976,7 +976,7 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
> {
> struct task_struct *t;
>
> - t = kthread_create(usbatm_do_heavy_init, instance, "%s",
> + t = kthread_run(usbatm_do_heavy_init, instance, "%s",
> instance->driver->driver_name);
> if (IS_ERR(t)) {
> usb_err(instance, "%s: failed to create kernel_thread (%ld)!\n",
> @@ -985,7 +985,6 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
> }
>
> instance->thread = t;
> - wake_up_process(t);
doesn't this mean that the thread may now start running before instance->thread
has been assigned? It's not clear to me what race conditions this may open up,
if any (I haven't looked at the code in a long time), but it does need to be
carefully analyzed. So I can't sign off on this as it stands.
Best wishes, Duncan.
> wait_for_completion(&instance->thread_started);
>
> return 0;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: atm: Make use of the helper macro kthread_run()
2022-01-27 7:47 Yin Xiujiang
@ 2022-01-28 12:19 ` Duncan Sands
0 siblings, 0 replies; 4+ messages in thread
From: Duncan Sands @ 2022-01-28 12:19 UTC (permalink / raw)
To: Yin Xiujiang, gregkh; +Cc: linux-usb, linux-kernel
Hi Yin Xiujiang, please see my earlier reply to Cai Huoqing for the same patch
below. Did you do the analysis?
>> instance->thread = t;
>> - wake_up_process(t);
>
> doesn't this mean that the thread may now start running before instance->thread has been assigned? It's not clear to me what race conditions this may open up, if any (I haven't looked at the code in a long time), but it does need to be carefully analyzed. So I can't sign off on this as it stands.
Best wishes, Duncan.
On 27/01/2022 08:47, 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/usb/atm/usbatm.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
> index e3a49d837609..24ba739a85e0 100644
> --- a/drivers/usb/atm/usbatm.c
> +++ b/drivers/usb/atm/usbatm.c
> @@ -976,7 +976,7 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
> {
> struct task_struct *t;
>
> - t = kthread_create(usbatm_do_heavy_init, instance, "%s",
> + t = kthread_run(usbatm_do_heavy_init, instance, "%s",
> instance->driver->driver_name);
> if (IS_ERR(t)) {
> usb_err(instance, "%s: failed to create kernel_thread (%ld)!\n",
> @@ -985,7 +985,6 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
> }
>
> instance->thread = t;
> - wake_up_process(t);
> wait_for_completion(&instance->thread_started);
>
> return 0;
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] usb: atm: Make use of the helper macro kthread_run()
@ 2022-01-27 7:47 Yin Xiujiang
2022-01-28 12:19 ` Duncan Sands
0 siblings, 1 reply; 4+ messages in thread
From: Yin Xiujiang @ 2022-01-27 7:47 UTC (permalink / raw)
To: duncan.sands, gregkh; +Cc: linux-usb, 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/usb/atm/usbatm.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index e3a49d837609..24ba739a85e0 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -976,7 +976,7 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
{
struct task_struct *t;
- t = kthread_create(usbatm_do_heavy_init, instance, "%s",
+ t = kthread_run(usbatm_do_heavy_init, instance, "%s",
instance->driver->driver_name);
if (IS_ERR(t)) {
usb_err(instance, "%s: failed to create kernel_thread (%ld)!\n",
@@ -985,7 +985,6 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
}
instance->thread = t;
- wake_up_process(t);
wait_for_completion(&instance->thread_started);
return 0;
--
2.30.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-28 12:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 8:43 [PATCH] usb: atm: Make use of the helper macro kthread_run() Cai Huoqing
2021-10-21 8:56 ` Duncan Sands
2022-01-27 7:47 Yin Xiujiang
2022-01-28 12:19 ` Duncan Sands
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).