public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* new warning on sysrq kernel crash trigger
@ 2015-12-10 23:57 Ani Sinha
  2015-12-11  5:26 ` Paul E. McKenney
  0 siblings, 1 reply; 20+ messages in thread
From: Ani Sinha @ 2015-12-10 23:57 UTC (permalink / raw)
  To: Rik van Riel, Randy Dunlap, Paul E. McKenney, Richard Weinberger,
	linux-kernel@vger.kernel.org, Ivan Delalande, fruggeri

Hi guys

I am noticing a new warning in linux 3.18 which we did not see before
in linux 3.4 :

bash-4.1# echo c > /proc/sysrq-trigger
[  978.807185] BUG: sleeping function called from invalid context at
../arch/x86/mm/fault.c:1187
[  978.909816] in_atomic(): 0, irqs_disabled(): 0, pid: 4706, name: bash
[  978.987358] Preemption disabled at:[<ffffffff81484339>] printk+0x48/0x4a


I have bisected this to the following change :

commit 984d74a72076a12b400339973e8c98fd2fcd90e5
Author: Rik van Riel <riel@redhat.com>
Date:   Fri Jun 6 14:38:13 2014 -0700

    sysrq: rcu-ify __handle_sysrq


the rcu_read_lock() in handle_sysrq() bumps up
current->rcu_read_lock_nesting. Hence, in __do_page_fault() when it
calls might_sleep() in x86/mm/fault.c line 1191,
preempt_count_equals(0) returns false and hence the warning is
printed.

One way to handle this would be to do something like this:

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index eef44d9..d4dbe22 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1132,7 +1132,7 @@ __do_page_fault(struct pt_regs *regs, unsigned
long error_code,
  * If we're in an interrupt, have no user context or are running
  * in a region with pagefaults disabled then we must not take the fault
  */
- if (unlikely(faulthandler_disabled() || !mm)) {
+ if (unlikely(faulthandler_disabled() || rcu_preempt_depth() || !mm)) {
  bad_area_nosemaphore(regs, error_code, address);
  return;
  }

I am wondering if this would be the right approach. I have tested that
this patch does indeed suppress the warning. If you guys agree, I will
send a patch. It's true that this is a trivial issue since we are
intentionally crashing the kernel but in our case, this additional
complaint from the kernel is confusing our test scripts and they are
generating false positives.

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2015-12-18  1:18 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-10 23:57 new warning on sysrq kernel crash trigger Ani Sinha
2015-12-11  5:26 ` Paul E. McKenney
2015-12-11 18:50   ` Ani Sinha
2015-12-11 20:44   ` Ani Sinha
2015-12-11 21:25     ` Paul E. McKenney
2015-12-11 22:10     ` Rik van Riel
2015-12-11 22:27       ` Paul E. McKenney
2015-12-11 23:41         ` Ani Sinha
2015-12-12  0:02           ` Paul E. McKenney
2015-12-12  0:11             ` Ani Sinha
2015-12-12  0:16         ` Ani Sinha
2015-12-12  1:03           ` Paul E. McKenney
2015-12-14 16:24             ` Ani Sinha
2015-12-14 17:07               ` Rik van Riel
2015-12-15  0:14                 ` Anirban Sinha
2015-12-16  0:52                   ` Ani Sinha
2015-12-16 16:25                     ` Rik van Riel
2015-12-17 17:28                       ` Greg KH
2015-12-18  1:18                         ` Ani Sinha
2015-12-16 16:22                   ` Rik van Riel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox