From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964828AbcFCUlO (ORCPT ); Fri, 3 Jun 2016 16:41:14 -0400 Received: from mail-qg0-f66.google.com ([209.85.192.66]:33058 "EHLO mail-qg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964769AbcFCUlG (ORCPT ); Fri, 3 Jun 2016 16:41:06 -0400 From: "Luis Claudio R. Goncalves" X-Google-Original-From: "Luis Claudio R. Goncalves" Date: Fri, 3 Jun 2016 17:41:00 -0300 To: Daniel Bristot de Oliveira Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Christian Borntraeger Subject: Re: [PATCH] sched: Panic on scheduling while atomic if kernel.panic_on_warn is set Message-ID: <20160603204100.GD27058@uudg.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 03, 2016 at 05:10:18PM -0300, Daniel Bristot de Oliveira wrote: | Currently, a schedule while atomic error prints the stack trace to the | kernel log and the system continue running. | | Although it is possible to collect the kernel log messages and analyze | it, often more information are needed. Furthermore, keep the system | running is not always the best choice. For example, when the preempt | count underflows the system will not stop to complain about scheduling | while atomic, so the kernel log can wrap around overwriting the first | stack trace, tuning the analysis even more challenging. | | This patch uses the kernel.panic_on_warn sysctl to help out on these | more complex situations. | | When kernel.panic_on_warn is set to 1, the kernel will panic() in the | schedule while atomic detection. | | The default value of the sysctl is 0, maintaining the current behavior. | | Cc: Ingo Molnar | Cc: Peter Zijlstra | Cc: Christian Borntraeger | Cc: "Luis Claudio R. Goncalves" | Signed-off-by: Daniel Bristot de Oliveira | --- | kernel/sched/core.c | 3 +++ | 1 file changed, 3 insertions(+) | | diff --git a/kernel/sched/core.c b/kernel/sched/core.c | index 7f2cae4..7d07ed9 100644 | --- a/kernel/sched/core.c | +++ b/kernel/sched/core.c | @@ -3146,6 +3146,9 @@ static noinline void __schedule_bug(struct task_struct *prev) | pr_cont("\n"); | } | #endif | + if (panic_on_warn) | + panic("scheduling while atomic\n"); | + | dump_stack(); | add_taint(TAINT_WARN, LOCKDEP_STILL_OK); | } | -- | 2.5.5 Reviewed-by: Luis Claudio R. Goncalves