linux-stable/include/linux/sched
Xunlei Pang e96a7705e7 sched/rtmutex/deadline: Fix a PI crash for deadline tasks
A crash happened while I was playing with deadline PI rtmutex.

    BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
    IP: [<ffffffff810eeb8f>] rt_mutex_get_top_task+0x1f/0x30
    PGD 232a75067 PUD 230947067 PMD 0
    Oops: 0000 [#1] SMP
    CPU: 1 PID: 10994 Comm: a.out Not tainted

    Call Trace:
    [<ffffffff810b658c>] enqueue_task+0x2c/0x80
    [<ffffffff810ba763>] activate_task+0x23/0x30
    [<ffffffff810d0ab5>] pull_dl_task+0x1d5/0x260
    [<ffffffff810d0be6>] pre_schedule_dl+0x16/0x20
    [<ffffffff8164e783>] __schedule+0xd3/0x900
    [<ffffffff8164efd9>] schedule+0x29/0x70
    [<ffffffff8165035b>] __rt_mutex_slowlock+0x4b/0xc0
    [<ffffffff81650501>] rt_mutex_slowlock+0xd1/0x190
    [<ffffffff810eeb33>] rt_mutex_timed_lock+0x53/0x60
    [<ffffffff810ecbfc>] futex_lock_pi.isra.18+0x28c/0x390
    [<ffffffff810ed8b0>] do_futex+0x190/0x5b0
    [<ffffffff810edd50>] SyS_futex+0x80/0x180

This is because rt_mutex_enqueue_pi() and rt_mutex_dequeue_pi()
are only protected by pi_lock when operating pi waiters, while
rt_mutex_get_top_task(), will access them with rq lock held but
not holding pi_lock.

In order to tackle it, we introduce new "pi_top_task" pointer
cached in task_struct, and add new rt_mutex_update_top_task()
to update its value, it can be called by rt_mutex_setprio()
which held both owner's pi_lock and rq lock. Thus "pi_top_task"
can be safely accessed by enqueue_task_dl() under rq lock.

Originally-From: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: juri.lelli@arm.com
Cc: bigeasy@linutronix.de
Cc: mathieu.desnoyers@efficios.com
Cc: jdesfossez@efficios.com
Cc: bristot@redhat.com
Link: http://lkml.kernel.org/r/20170323150216.157682758@infradead.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2017-04-04 11:44:05 +02:00
..
autogroup.h sched/headers: Remove <linux/sched.h> from <linux/sched/autogroup.h> 2017-03-03 01:45:29 +01:00
clock.h sched/headers: Remove <linux/sched.h> from <linux/sched/clock.h> 2017-03-03 01:45:27 +01:00
coredump.h sched/headers: Remove <linux/sched.h> from <linux/sched/coredump.h> 2017-03-03 01:45:30 +01:00
cpufreq.h sched/headers: Remove <linux/sched.h> from <linux/sched/cpufreq.h> 2017-03-03 01:45:32 +01:00
cputime.h sched/headers: Move cputime functionality from <linux/sched.h> and <linux/cputime.h> into <linux/sched/cputime.h> 2017-03-03 01:45:22 +01:00
deadline.h sched/headers: Make all include/linux/sched/*.h headers build standalone 2017-03-02 08:42:23 +01:00
debug.h sched/headers: Remove <linux/sched.h> from <linux/sched/debug.h> 2017-03-03 01:45:35 +01:00
hotplug.h sched/headers: Remove <linux/sched.h> from <linux/sched/hotplug.h> 2017-03-03 01:45:35 +01:00
idle.h sched/headers: Remove tsk_is_polling() 2017-03-03 01:45:27 +01:00
init.h sched/headers: Remove <linux/sched.h> from <linux/sched/init.h> 2017-03-03 01:45:38 +01:00
jobctl.h sched/headers: Move the JOBCTL_ defines and methods from <linux/sched.h> to <linux/sched/jobctl.h> 2017-03-03 01:43:41 +01:00
loadavg.h sched/headers: Remove <linux/sched.h> from <linux/sched/loadavg.h> 2017-03-03 01:45:28 +01:00
mm.h sched/headers: Remove <linux/sched.h> from <linux/sched/mm.h> 2017-03-03 01:45:29 +01:00
nohz.h sched/headers: Remove <linux/sched.h> from <linux/sched/nohz.h> 2017-03-03 01:45:35 +01:00
numa_balancing.h sched/headers: Move the NUMA balancing interfaces from <linux/sched.h> to <linux/sched/numa_balancing.h> 2017-03-03 01:43:40 +01:00
prio.h sched/headers: Make all include/linux/sched/*.h headers build standalone 2017-03-02 08:42:23 +01:00
rt.h sched/rtmutex/deadline: Fix a PI crash for deadline tasks 2017-04-04 11:44:05 +02:00
signal.h sched/headers: Move cputime functionality from <linux/sched.h> and <linux/cputime.h> into <linux/sched/cputime.h> 2017-03-03 01:45:22 +01:00
stat.h sched/headers: Remove <linux/sched.h> from <linux/sched/stat.h> 2017-03-03 01:45:34 +01:00
sysctl.h sched/headers: Make all include/linux/sched/*.h headers build standalone 2017-03-02 08:42:23 +01:00
task.h sched/headers: Move the sched_exec() prototype to <linux/sched/task.h> 2017-03-03 01:45:26 +01:00
task_stack.h sched/headers: Move kstack_end() from <linux/sched.h> to <linux/sched/task_stack.h> 2017-03-03 01:45:24 +01:00
topology.h sched/headers: Remove the <linux/topology.h> include from <linux/sched.h> 2017-03-03 01:45:41 +01:00
user.h sched/headers: Remove <linux/sched.h> from <linux/sched/user.h> 2017-03-03 01:45:30 +01:00
wake_q.h sched/headers: Move the wake-queue types and interfaces from sched.h into <linux/sched/wake_q.h> 2017-03-02 08:42:42 +01:00
xacct.h sched/headers: Move CONFIG_TASK_XACCT bits from <linux/sched.h> to <linux/sched/xacct.h> 2017-03-03 01:43:41 +01:00