Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp890003yba; Mon, 1 Apr 2019 20:16:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9kIR8cED3OQjnHO6bmh5e6LYtkwd7y+nEEptkiqUyj6tGOa+FwAAwnyhIBHeJNTEAP4Lx X-Received: by 2002:a63:5149:: with SMTP id r9mr25617511pgl.177.1554174989114; Mon, 01 Apr 2019 20:16:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554174989; cv=none; d=google.com; s=arc-20160816; b=SjUK27UZZQ234uNFpCnZKBczI+oK4sVaFw3V29ijqB1cu3hBUfvC4gPF/+7Qbukr0g 04WFiGPYwf9TrBECft4nYGYbxgg5vjKoLSSOginvPzsoNJbYiPA0ZFq5i7T7Hr20Sq9M aSa/FQD6cWnXDKG0m6k1WPL9ZemE6O/dhfNgx3d7n03uvqkEVEa/QQign6oFHLSI6uf6 L82/74znrdHhGqTG3XxACn+dFewsoDv3rE1UK9/rmyov5RG3BLiNhBYi9b9vzwCmnDww CxG8jDWxTGm1H7hXcxVXAVlle79PiM8d7xcV+ibDxksIrQAyHWp+z5pvDNEPDrRzeJRV W0eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=1XOC6p9umqYHcSq+nF0G2b6BDhSmYsvChWFCxCo5V6s=; b=X87e8kz0oRuUEKzfpGYR61F95Q6dEkqhL0dvDNMsu8nA024bF6joTRj029RDXogbDH wm9dIh0ylsLZ/jm2Xp00SpktInBbJwdKtIcmprF/TaYejNtgVBy28noCRHr9hhujz/Ap nvSwmj29r5/nlRMfvV1TSyxdTiScNaQycqQQZ61hpkqIxInUe5vmVkNhKNWVNAmKkOSn iHkFs4RXm2ampsbntqubJN1inedvgdQE8oC1SH3mgj8s8y/oj+RwEc83pKP0gJqROcny Oo3z8VDB10VBUaVsXyXI31Bwsktc0BX+dahI0lAN4apLe63JTc23l8DvCrioVqaDhtZ7 U8Cg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n15si10107175pff.144.2019.04.01.20.16.01; Mon, 01 Apr 2019 20:16:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728797AbfDBCoO (ORCPT + 99 others); Mon, 1 Apr 2019 22:44:14 -0400 Received: from mga11.intel.com ([192.55.52.93]:33455 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726411AbfDBCoN (ORCPT ); Mon, 1 Apr 2019 22:44:13 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 19:44:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,298,1549958400"; d="scan'208";a="287896110" Received: from shbuild888.sh.intel.com (HELO localhost) ([10.239.147.114]) by orsmga004.jf.intel.com with ESMTP; 01 Apr 2019 19:44:10 -0700 Date: Tue, 2 Apr 2019 10:47:17 +0800 From: Feng Tang To: Mukesh Ojha Cc: Andrew Morton , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , linux-kernel@vger.kernel.org, Kees Cook , Borislav Petkov Subject: Re: [PATCH 1/2] printk: Add an option to flush all messages on panic Message-ID: <20190402024717.az4bjtmfd7yhyaom@shbuild888> References: <1554115684-26846-1-git-send-email-feng.tang@intel.com> <0020b526-ad88-309a-8dce-1c852f0ebb31@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0020b526-ad88-309a-8dce-1c852f0ebb31@codeaurora.org> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mukesh, On Mon, Apr 01, 2019 at 05:20:33PM +0530, Mukesh Ojha wrote: > > On 4/1/2019 4:18 PM, Feng Tang wrote: > > Current console_flush_on_panic() will only dump the new messages > > in buffer, and users may need an opportunity to check all the > > messages on panic which could help debugging, as user may haven't > > seen the log before panic due to loglevel settings. > > > > Add a flag for console_flush_on_panic() to chose whether to > > dump all messages. > > > > Signed-off-by: Feng Tang > > > Looks good to me. Thanks for the review. > > > But, Will it not be good if put it under a config and not change the > prototype, as it is a debug feature? My understanding is the console_flush_on_panic() is also a debug feature too :), and my 2/2 patch will has a bitmask (either controlled by kernel cmdline or sysctl) to turn on this. Thanks, Feng > > Thanks, > Mukesh > > > --- > > arch/powerpc/kernel/traps.c | 2 +- > > include/linux/console.h | 2 +- > > kernel/panic.c | 2 +- > > kernel/printk/printk.c | 9 ++++++++- > > 4 files changed, 11 insertions(+), 4 deletions(-) > > > > diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c > > index 1fd45a8..58d9580 100644 > > --- a/arch/powerpc/kernel/traps.c > > +++ b/arch/powerpc/kernel/traps.c > > @@ -179,7 +179,7 @@ extern void panic_flush_kmsg_end(void) > > kmsg_dump(KMSG_DUMP_PANIC); > > bust_spinlocks(0); > > debug_locks_off(); > > - console_flush_on_panic(); > > + console_flush_on_panic(false); > > } > > static unsigned long oops_begin(struct pt_regs *regs) > > diff --git a/include/linux/console.h b/include/linux/console.h > > index ec9bdb3..825ecf5 100644 > > --- a/include/linux/console.h > > +++ b/include/linux/console.h > > @@ -175,7 +175,7 @@ extern int console_trylock(void); > > extern void console_unlock(void); > > extern void console_conditional_schedule(void); > > extern void console_unblank(void); > > -extern void console_flush_on_panic(void); > > +extern void console_flush_on_panic(bool flush_all); > > extern struct tty_driver *console_device(int *); > > extern void console_stop(struct console *); > > extern void console_start(struct console *); > > diff --git a/kernel/panic.c b/kernel/panic.c > > index 0ae0d73..fb77e01 100644 > > --- a/kernel/panic.c > > +++ b/kernel/panic.c > > @@ -277,7 +277,7 @@ void panic(const char *fmt, ...) > > * panic() is not being callled from OOPS. > > */ > > debug_locks_off(); > > - console_flush_on_panic(); > > + console_flush_on_panic(false); > > panic_print_sys_info(); > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > > index 02ca827..8ff099b 100644 > > --- a/kernel/printk/printk.c > > +++ b/kernel/printk/printk.c > > @@ -2525,10 +2525,11 @@ void console_unblank(void) > > /** > > * console_flush_on_panic - flush console content on panic > > + * @flush_all: whether to print all messages in buffer > > * > > * Immediately output all pending messages no matter what. > > */ > > -void console_flush_on_panic(void) > > +void console_flush_on_panic(bool flush_all) > > { > > /* > > * If someone else is holding the console lock, trylock will fail > > @@ -2539,6 +2540,12 @@ void console_flush_on_panic(void) > > */ > > console_trylock(); > > console_may_schedule = 0; > > + > > + /* User may want to see all the printk messages on panic */ > > + if (flush_all) { > > + console_seq = log_first_seq; > > + console_idx = log_first_idx; > > + } > > console_unlock(); > > }