There are currently no runtime diagnostic checks for detecting when we
have inadvertently missed a call to update_rq_clock() before accessing
rq_clock() or rq_clock_task().

The idea in these patches, which came from Peter, is to piggyback on
the rq->lock pin/unpin context to detect when we expected (and failed)
to see an update to the rq clock. They've already caught a couple of
bugs: see commit b52fad2db5d7 ("sched/fair: Update rq clock before
updating nohz CPU load").

All the diagnostic code is guarded by CONFIG_SCHED_DEBUG, but there
are minimal changes to __schedule() in patch 5 for the !SCHED_DEBUG

Jan and Sergey, Petr asked that you be Cc'd on this series because of
the recent issues with using WARN_ON() in the async printk work.

Changes in v2:

 - Add a check for missing update_rq_clock() before rq_clock_task().

 - Address review comments from Yuyang where I messed up the
   __schedule() ::clock_update_flags manipulation

Matt Fleming (7):
  sched/fair: Update the rq clock before detaching tasks
  sched/fair: Update rq clock before waking up new task
  sched/fair: Update rq clock in task_hot()
  sched: Add wrappers for lockdep_(un)pin_lock()
  sched/core: Reset RQCF_ACT_SKIP before unpinning rq->lock
  sched/fair: Push rq lock pin/unpin into idle_balance()
  sched/core: Add debug code to catch missing update_rq_clock()

 kernel/sched/core.c      |  92 +++++++++++++++++++++-------------------
 kernel/sched/deadline.c  |  10 ++---
 kernel/sched/fair.c      |  40 +++++++++++-------
 kernel/sched/idle_task.c |   2 +-
 kernel/sched/rt.c        |   6 +--
 kernel/sched/sched.h     | 107 ++++++++++++++++++++++++++++++++++++++++-------
 kernel/sched/stop_task.c |   2 +-
 7 files changed, 177 insertions(+), 82 deletions(-)


Reply via email to