Received: by 10.223.176.46 with SMTP id f43csp537256wra; Thu, 18 Jan 2018 21:46:45 -0800 (PST) X-Google-Smtp-Source: ACJfBotO6tdwS7oS4ui+kFN2YkitjAaHbv7NFpGUp0P5ZkVf+jQL17Y3BYVrUKzT+/QlTfpIAoRA X-Received: by 2002:a17:902:6988:: with SMTP id l8-v6mr1007203plk.394.1516340805305; Thu, 18 Jan 2018 21:46:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516340805; cv=none; d=google.com; s=arc-20160816; b=SNMgH7NdbeRP88pmVtk4wNuHSRxIDoAmbAJntmBXmYy67691UXAweoXERhe2gxMIdI Ui+9St05tMRaMycuie3bEaxQ2hZda04fDpfWipgOAOASQYAQ9ehryhHC42mpT45aI0gv 6jeHzCKUKwjuK3SX8KqogvGK1TFD8wDl4vkS3BRunF/aOUUPqEDwnYMjRHBPrKD+zoeD ozYxyjnxAFjppQ7y2vpycz35Hc8ZeAlNnq3zrQdKk9EXeHUeh8Op21svWjhMw0cPGs3f /7OkoHh/HujZfWLSxGULRsAHFjTz4xqeO8dQgWNXVLNqn3Hesn8hOjrmxKEsYwTTBxM9 VRYg== 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:dkim-signature:arc-authentication-results; bh=VnMylxzQn8PBvwqkmJy3ANYLoE/FDslyYu/M216Ihrk=; b=qFe6m6uhYj1zneMub9T8zFWVCM9cfEX8PqUl1uxJ3ZpV1HXxVmdk6CQI6LxAsMUVD1 HZOv5kAGk/ZW0LaYch55VU3xcsML0amj2ATfW8YYLaALvKk0Xaxn0lRuUgaLuHddIFMj fp+UFfTFQJwydBvtQ3K0RMpi5RInnonWBP59FaOBJhOv/zMC4psIrhuePbZh+dHudg+o c0nV4gLd6st4+0l5u57dNpfBr8dI7ppK3moc2u0nW6jqhEj4P5g+axt7npc2z5/OmLSe 8bQ7NPzdzbJzJ19e+SbEFFS9xkNMXtNzHS+1xoBlBLYuIqzB+uVJWqliEC1FsZm9pJyA d5Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MggVx3nz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si2545380pgt.621.2018.01.18.21.46.31; Thu, 18 Jan 2018 21:46:45 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MggVx3nz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753772AbeASFpt (ORCPT + 99 others); Fri, 19 Jan 2018 00:45:49 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:41189 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750974AbeASFpn (ORCPT ); Fri, 19 Jan 2018 00:45:43 -0500 Received: by mail-pf0-f196.google.com with SMTP id j3so608238pfh.8 for ; Thu, 18 Jan 2018 21:45:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=VnMylxzQn8PBvwqkmJy3ANYLoE/FDslyYu/M216Ihrk=; b=MggVx3nzAJkMkBF5398rnIIL+hzifpJArvs3T8+pTVvuSSR/PuNlHCWCtw/z89eRzD cCZC2JIlwt/wiVBG5PyYDa5wyLZd4ofcb/R67jjFhLTc27/pqfoa7EHsNIeLjTli5PJg 9l+pN4MSMV8uXh+ErT7g0jqEyipSAqd8ZuiLU6WrldauBNZltcrRqugMyBV7c4jWV/xi As9D87v0FuGekukl9x4kU4/vzs2BuPzG0d9ksOAxyTKDW/EL2un0UgTyZKT8WfVBvYvY jiL0OVLD5AdAJ+rT3jSVRt3d255JmndVXS22FD1lADNODJAPZEpMJXJ1XBAkGuGkvSij iG0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=VnMylxzQn8PBvwqkmJy3ANYLoE/FDslyYu/M216Ihrk=; b=Wo2FR4WchKC7taL3+vBWRL64NB2qpYJjKjYruNdCNhOsvPtgP6SARNAHRyCjJma44i ewJ9xOsdiWFdcHz1VWQGgcy+rLCPcal8sRf0AGs2bb86JUHZOsPfDZwwXr1RgNz9SMaf ZXVpL07iMdY/KqpbwFyVOupiHsVKEffGSINLWMrXKAVlybDXa/v3PnIoJOaE3XkXNA9z QpPpnzC1fuTgHMNt2IWoNYLbtRH1O0Ot5a04NBOGxdZiGrQSxSAzuwb5kfpwvOsrXH/c C/iNaWsSl14hGX4K+33WvwelZszp9RSynLTwRtuhS3pqUCilXfbcRoGNpmDUmhCYEqgs t9iA== X-Gm-Message-State: AKGB3mI8kPXFMMmoHTDGnnCvYe9z2+c5DQfbQeg81z/Q1MoB6BFeD1ao kDVOMPRDSj7JZRZp4kSXN3Y= X-Received: by 10.101.81.7 with SMTP id f7mr39805984pgq.433.1516340743036; Thu, 18 Jan 2018 21:45:43 -0800 (PST) Received: from localhost ([110.70.56.177]) by smtp.gmail.com with ESMTPSA id b8sm13393098pff.31.2018.01.18.21.45.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jan 2018 21:45:41 -0800 (PST) Date: Fri, 19 Jan 2018 14:45:38 +0900 From: Sergey Senozhatsky To: Andi Kleen Cc: Dave Young , pmladek@suse.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, kexec@lists.infradead.org Subject: Re: [PATCH] print kdump kernel loaded status in stack dump Message-ID: <20180119054538.GA484@jagdpanzerIV> References: <20180117045057.GA4994@dhcp-128-65.nay.redhat.com> <878tcvt592.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878tcvt592.fsf@linux.intel.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (01/18/18 10:02), Andi Kleen wrote: > Dave Young writes: > > printk("%sHardware name: %s\n", > > log_lvl, dump_stack_arch_desc_str); > > + if (kexec_crash_loaded()) > > + printk("%skdump kernel loaded\n", log_lvl); > > Oops/warnings are getting longer and longer, often scrolling away > from the screen, and if the kernel crashes backscroll does not work > anymore, so precious information is lost. true. I even ended up having a console_reflush_on_panic() function. it simply re-prints with a delay [so I can at least read the oops] logbuf entries every once in a while, staring with the first oops_in_progress record. something like below [it's completely hacked up, but at least gives an idea] --- include/linux/console.h | 1 + kernel/panic.c | 7 +++++++ kernel/printk/printk.c | 39 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/include/linux/console.h b/include/linux/console.h index b8920a031a3e..502e3f539448 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -168,6 +168,7 @@ 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_reflush_on_panic(void); 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 2cfef408fec9..39cd59bbfaab 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -137,6 +137,7 @@ void panic(const char *fmt, ...) va_list args; long i, i_next = 0; int state = 0; + int reflush_tick = 0; int old_cpu, this_cpu; bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers; @@ -298,6 +299,12 @@ void panic(const char *fmt, ...) i_next = i + 3600 / PANIC_BLINK_SPD; } mdelay(PANIC_TIMER_STEP); + + reflush_tick++; + if (reflush_tick == 32) { /* don't reflush too often */ + console_reflush_on_panic(); + reflush_tick = 0; + } } } diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 9cb943c90d98..ef3f28d4c741 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -426,6 +426,10 @@ static u32 log_next_idx; static u64 console_seq; static u32 console_idx; +/* index and sequence number of the record which started the oops print out */ +static u64 log_oops_seq; +static u32 log_oops_idx; + /* the next printk record to read after the last 'clear' command */ static u64 clear_seq; static u32 clear_idx; @@ -1736,6 +1740,15 @@ static inline void printk_delay(void) } } +/* + * Why do we have printk_delay() in vprintk_emit() + * and not in console_unlock()? + */ +static inline void console_unlock_delay(void) +{ + printk_delay(); +} + /* * Continuation lines are buffered, and not committed to the record buffer * until the line is complete, or a race forces it. The line fragments @@ -1849,6 +1862,7 @@ asmlinkage int vprintk_emit(int facility, int level, /* This stops the holder of console_sem just where we want him */ logbuf_lock_irqsave(flags); + /* * The printf needs to come first; we need the syslog * prefix which might be passed-in as a parameter. @@ -1890,7 +1904,11 @@ asmlinkage int vprintk_emit(int facility, int level, lflags |= LOG_PREFIX|LOG_NEWLINE; printed_len = log_output(facility, level, lflags, dict, dictlen, text, text_len); - + /* Oops... */ + if (oops_in_progress && !log_oops_seq) { + log_oops_seq = log_next_seq; + log_oops_idx = log_next_idx; + } logbuf_unlock_irqrestore(flags); /* If called from the scheduler, we can not call up(). */ @@ -2396,6 +2414,7 @@ void console_unlock(void) stop_critical_timings(); /* don't trace print latency */ call_console_drivers(ext_text, ext_len, text, len); + console_unlock_delay(); start_critical_timings(); if (console_lock_spinning_disable_and_check()) { @@ -2495,6 +2514,24 @@ void console_flush_on_panic(void) console_unlock(); } +/** + * console_reflush_on_panic - re-flush console content starting from the + * first oops_in_progress record + */ +void console_reflush_on_panic(void) +{ + unsigned long flags; + + logbuf_lock_irqsave(flags); + console_seq = log_oops_seq; + console_idx = log_oops_idx; + logbuf_unlock_irqrestore(flags); + + if (!printk_delay_msec) + printk_delay_msec = 273; /* I can't read any faster */ + console_flush_on_panic(); +} + /* * Return the console tty driver structure and its associated index */ -- 2.16.0