Files
rockchip-kernel/kernel
Stephen Dickey a64f42d1df ANDROID: sched: Fix missing RQCF_UPDATED in migrate_tasks
Currently, the sched code checks if the rq clock has been
updated after its lock has been held when CONFIG_SCHED_DEBUG
is enabled. It tracks this by clearing the RQCF_UPDATED bit
when a lock is acquired and setting it upon a subsequent
update_rq_clock() call. It warns if rq clock is read without
RQCF_UPDATED flag indicating the code path missed updating
the clock.

When migrate_tasks() is called during a pause_cpus() event,
the local variable orf is updated with the contents of *rf,
prior to the call to update_rq_clock(). As a result, when
migrate_tasks() restores *rf from the local variable the
RQCF_UPDATED flag is lost. This clearing out of the
RQCF_UPDATED flag leads to a warning when the next task
is being pushed out.

For example in migrate_tasks()

   orf = rf; // save flags, RQCF_UPDATE cleared
   update_rq_clock() // set RQCF_UPDATE
   for()
      ...
      __migrate_task(dead_rq, new_cpu)
      ...
      --> if migration, restore dead_rq's flags with orf.
         --> We loose RQCF_UPDATE
	 rq_relock(dead_rq, orf)

This leaves the current cpu's rq clock_update_flags with the
RQCF_UPDATED flag cleared, an error condition with
CONFIG_SCHED_DEBUG enabled.

Fix the issue for by ensuring that the local variable orf
has the RQCF_UPDATED flag set, allowing the current
CPU's rq to have the flag set and leaving it in a good state
for future usage.

pause_cpus() is currently Android specific. As cpu_pause does
not rely on stop_machine_cpuslocked() like the regular
hotunplug path does, there's a risk for another CPU to
read the rq_clock, after we cleared RQCF_UPDATE, when using
pause_cpus(). This change will have little or no impact outside
of Android currently. If pause_cpus() or drain_rq_cpu_stop()
are merged upstream this change should be merged as well.

Bug: 186222712
Change-Id: Id241122e1449cdd4dcd15f94eb68735b40e3d6f5
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2021-04-28 21:28:55 +00:00
..
2021-04-22 11:12:08 +02:00
2021-04-14 08:41:58 +02:00
2021-03-25 17:15:27 +01:00
2021-04-22 11:12:08 +02:00
2021-04-02 15:25:50 +02:00
2021-04-16 16:01:44 +02:00
2020-08-26 09:10:39 -04:00
2021-03-25 17:15:27 +01:00
2020-08-12 10:58:02 -07:00
2021-02-08 20:05:12 -08:00
2021-03-07 12:33:33 +01:00
2021-03-25 17:15:27 +01:00
2020-11-14 11:26:04 -08:00
2021-01-13 10:28:55 +01:00
2020-07-27 14:31:12 -04:00
2021-03-07 12:33:33 +01:00
2021-04-09 02:30:55 +00:00
2021-02-07 15:37:17 +01:00
2021-03-19 09:42:56 +01:00
2021-04-15 14:23:41 +02:00