From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755353AbbLWEOl (ORCPT ); Tue, 22 Dec 2015 23:14:41 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:33912 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752572AbbLWEOk (ORCPT ); Tue, 22 Dec 2015 23:14:40 -0500 Date: Wed, 23 Dec 2015 13:15:46 +0900 From: Sergey Senozhatsky To: Jan Kara Cc: Sergey Senozhatsky , Sergey Senozhatsky , Andrew Morton , Petr Mladek , KY Sri nivasan , Steven Rostedt , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/7] printk: Hand over printing to console if printing too long Message-ID: <20151223041546.GD2008@swordfish> References: <20151210145251.GA540@swordfish> <20151222134730.GD7266@quack.suse.cz> <20151223015420.GA2008@swordfish> <20151223033724.GB2008@swordfish> <20151223035732.GC2008@swordfish> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151223035732.GC2008@swordfish> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (12/23/15 12:57), Sergey Senozhatsky wrote: [..] > > > can we replace this oops_in_progress check with something more reliable? > > > > > > CPU0 CPU1 - CPUN > > > panic() > > > local_irq_disable() executing foo() with irqs disabled, > > > console_verbose() or processing an extremely long irq handler. > > > bust_spinlocks() > > > oops_in_progress++ > > or we huge enough number of CPUs, `deep' stack > traces, slow serial and CPU doing dump_stack() > under raw_spin_lock(&stop_lock), so it can take > longer than 1 second to print the stacks and > thus panic CPU will set oops_in_progress back > to 0. > > > > smp_send_stop() > > > > > > bust_spinlocks() > > > oops_in_progress-- ok, IPI arrives > > > dump_stack()/printk()/etc from IPI_CPU_STOP > > > "while (1) cpu_relax()" with irq/fiq disabled/halt/etc. > > > > > > smp_send_stop() wrapped in `oops_in_progress++/oops_in_progress--' is arch specific, > > > and some platforms don't do any IPI-delivered (e.g. via num_online_cpus()) checks at > > > all. Some do. For example, arm/arm64: > > > > > > void smp_send_stop(void) > > > ... > > > /* Wait up to one second for other CPUs to stop */ > > > timeout = USEC_PER_SEC; > > > while (num_online_cpus() > 1 && timeout--) > > > udelay(1); > > > > > > if (num_online_cpus() > 1) > > > pr_warn("SMP: failed to stop secondary CPUs\n"); > > > ... > > > > > > > > > so there are non-zero chances that IPI will arrive to CPU after 'oops_in_progress--', > > > and thus dump_stack()/etc. happening on that/those cpu/cpus will be lost. > > > > > > > > > bust_spinlocks(0) does > > > ... > > > if (--oops_in_progress == 0) > > > wake_up_klogd(); > > > ... > > > > > > but local cpu has irqs disabled and `panic_timeout' can be zero. well, if panic_timeout != 0, then wake_up_klogd() calls irq_work_queue() which schedule_work. what if we have the following CPU0 CPU1 - CPUN foo preempt_disable bar panic irq/fiq disable schedule_work while (1) cpu_relax -ss