[PATCH] ubi: check kthread_should_stop() after the setting of task state

Richard Weinberger richard.weinberger at gmail.com
Fri Aug 7 15:29:43 EDT 2020


On Fri, Aug 7, 2020 at 4:18 AM Zhihao Cheng <chengzhihao1 at huawei.com> wrote:
> That's where we hold different views. I have 3 viewpoints(You can point
> out which one you disagree.):
>
> 1. If kthread_stop() happens at line 12, ubi thread is *marked* with
> stop flag, it will stop at kthread_should_stop() as long as it can reach
> the next iteration.
>
> 2. If task A is on runqueue and its state is TASK_RUNNING, task A will
> be scheduled to execute.
>
> 3. If kthread_stop() happens at line 12, after program counter going to
> line 14, ubi thead is on runqueue and its state is TASK_RUNNING. I have
> explained this in situation 1 in last session.
>
>
> I mean ubi thread is on runqueue with TASK_RUNNING state & stop flag
> after the process you described.
>
> Line 12   kthread_stop()
>
>                   set_bit(mark stop flag) && wake_up_process(enqueue &&
> set TASK_RUNNING )    => TASK_RUNNING & stop flag & on runqueue
>
> Line 13  schedule()
>
>                   Do nothing but pick next task to execute

You are perfectly right! I failed to concentrate on the state changes.
Now all makes sense, also your comment before the if statement.
So I don't know how to make this more clear in the code.
Maybe it's just me being dense and in need for a vacation. ;-)

-- 
Thanks,
//richard



More information about the linux-mtd mailing list