Messages in this thread | | | Date | Wed, 11 Mar 2020 16:39:29 +0100 | From | Peter Zijlstra <> | Subject | Re: [PATCH v3 1/1] kthread: do not preempt current task if it is going to call schedule() |
| |
On Fri, Mar 06, 2020 at 03:01:33PM +0800, cl@rock-chips.com wrote: > From: Liang Chen <cl@rock-chips.com> > > when we create a kthread with ktrhead_create_on_cpu(),the child thread > entry is ktread.c:ktrhead() which will be preempted by the parent after > call complete(done) while schedule() is not called yet,then the parent > will call wait_task_inactive(child) but the child is still on the runqueue, > so the parent will schedule_hrtimeout() for 1 jiffy,it will waste a lot of > time,especially on startup. > > parent child > ktrhead_create_on_cpu() > wait_fo_completion(&done) -----> ktread.c:ktrhead() > |----- complete(done);--wakeup and preempted by parent > kthread_bind() <------------| |-> schedule();--dequeue here > wait_task_inactive(child) | > schedule_hrtimeout(1 jiffy) -| > > So we hope the child just wakeup parent but not preempted by parent, and the > child is going to call schedule() soon,then the parent will not call > schedule_hrtimeout(1 jiffy) as the child is already dequeue. > > The same issue for ktrhead_park()&&kthread_parkme(). > This patch can save 120ms on rk312x startup with CONFIG_HZ=300. > > Signed-off-by: Liang Chen <cl@rock-chips.com>
Thanks!
| |