]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
s390: Fix unmatched preempt_disable() on exit
authorBen Hutchings <ben@decadent.org.uk>
Thu, 6 Feb 2020 15:17:16 +0000 (15:17 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 11 Feb 2020 20:03:58 +0000 (20:03 +0000)
exit_thread_runtime_instr() may return with preemption disabled,
leading to the following lockdep splat:

BUG: sleeping function called from invalid context at kernel/locking/mutex.c:586
in_atomic(): 1, irqs_disabled(): 0, pid: 565, name: kworker/u2:0
no locks held by kworker/u2:0/565.
CPU: 0 PID: 565 Comm: kworker/u2:0 Not tainted 3.16.81-00145-gafe1c874fa44 #1
       00000000025dbbd8 00000000025dbbe8 0000000000000002 0000000000000000
       00000000025dbc78 00000000025dbbf0 00000000025dbbf0 000000000098c55c
       0000000000000000 00000000025d05b8 00000000025d1590 0000000000000000
       0000000000000000 000000000000000c 00000000025dbbd8 0000000000000070
       00000000009b7220 000000000098c55c 00000000025dbbd8 00000000025dbc20
Call Trace:
([<000000000098c4ce>] show_trace+0xb6/0xd8)
 [<000000000098c592>] show_stack+0xa2/0xd8
 [<0000000000992c04>] dump_stack+0xc4/0x118
 [<0000000000191e20>] __might_sleep+0x230/0x238
 [<000000000099fbb0>] mutex_lock_nested+0x48/0x3d8
 [<000000000025e33e>] perf_event_exit_task+0x36/0x398
 [<0000000000158536>] do_exit+0x3ae/0xca0
 [<0000000000175826>] ____call_usermodehelper+0x136/0x148
 [<00000000009a550a>] kernel_thread_starter+0x6/0xc
 [<00000000009a5504>] kernel_thread_starter+0x0/0xc

This was fixed by commit 8d9047f8b967 "s390/runtime instrumentation:
simplify task exit handling" upstream, but that won't apply here.

Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/s390/kernel/runtime_instr.c

index ddbec1054f75d022c8222b37fcf8eb40dfe6dce5..9808fe741def1f6fac0489e1d98ca3b7bb9ebc4b 100644 (file)
@@ -53,9 +53,9 @@ void exit_thread_runtime_instr(void)
 {
        struct task_struct *task = current;
 
-       preempt_disable();
        if (!task->thread.ri_cb)
                return;
+       preempt_disable();
        disable_runtime_instr();
        kfree(task->thread.ri_cb);
        task->thread.ri_signum = 0;