Files
linux/kernel
Liang Chen 3be6453a90 kthread: do not preempt current task if it is going to call schedule()
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.

Change-Id: I2ae4edb538ea6f55cf5b8f8b5dc6311d1811a4ae
Signed-off-by: Liang Chen <cl@rock-chips.com>
2020-03-09 16:51:17 +08:00
..
2020-01-27 15:55:44 +01:00
2020-01-27 15:55:44 +01:00
2019-05-17 16:05:09 -07:00
2020-01-23 08:36:16 +01:00
2019-12-13 08:51:11 +01:00
2019-05-31 06:46:17 -07:00
2019-12-01 09:17:17 +01:00
2020-01-27 15:55:44 +01:00
2019-12-01 09:17:38 +01:00
2020-01-15 14:51:23 +00:00
2019-12-01 09:53:43 +01:00
2019-12-18 09:03:30 +01:00
2019-08-12 13:36:37 -04:00
2020-01-27 15:55:44 +01:00
2018-07-03 09:20:44 +02:00
2020-01-09 10:18:59 +01:00
2018-06-07 16:56:28 -04:00
2019-03-06 15:59:21 +00:00
2019-12-18 09:03:30 +01:00