Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3919347imj; Tue, 12 Feb 2019 06:56:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IbtNmghyEcCQLoWtcm2r4Ypm3ftDD5BMqPryR+Vilj/nCmHSs1SClCIoSCIDbpnKsG26DSY X-Received: by 2002:a63:2117:: with SMTP id h23mr3942412pgh.375.1549983404501; Tue, 12 Feb 2019 06:56:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549983404; cv=none; d=google.com; s=arc-20160816; b=bs+pEL727o/qN8y39l3ojkCgbgFA1N8bfkdhalOS//7AS4mzX/mkW30I2LUjS36Rhq j7ehWaSXajJ4uBJhVjmy5CBpgDyO4k7QwFYFtW2qg0Ni3pu9jkvdr/+paJrOKMmofY/V i7yqsuEeRbe+nIBid/Lqgb3HdIv7S4w3sSBhFAoCT8XfNVBE3x8mshXHyXbb6/QdOdpg WMZlzaj0Lnkf5hebuEw0m8NSQzvSOgnvzPNLAZMZ0VGtpBe5RntKjiEPq87Vinjc+OtR EggK3JIA1jdpiqPEReJip8GCATRa70X4b4lEMhozQNvg3wXsyEYRqSt9MtOI7mIG1PTb SatA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=+xL2mUYO0X39VArGMEnPMhbWEs+ju9X/kjAmdsnUzDs=; b=FIrICGWoMuKTYyf+iuz65NIKjFRrRVgfgMJccwLkRifrl+X1QyUIvKOShZsVwPi+Wt BwZ0pe4yx2tzMkubT6HZNnfxLk5v0cY/d8ZINqwRj5gPpHa5FQAmfM/g8dhq2Xi5Ouz4 iDLr+TK8sijhjiZyJhoWVLJbBZ+VAW1mxaVVNmWSqv/ZJFSTs6psQQUBRO7SJ5gjDWoH Ocb9AyfeXDSYCTMDfP1yPvHpGPM6Ii3AMec9DI0VeCJRXV47TLbxxrd1vSpNvP6SW3oT 3M1NG5ahEtXL53l8culMf/Se/VyAbGaTK+gkjDu3+NkOr891b7u5kIGjhoSRNHythTKu AvNA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5si5299953pfn.219.2019.02.12.06.56.28; Tue, 12 Feb 2019 06:56:44 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729027AbfBLOcu (ORCPT + 99 others); Tue, 12 Feb 2019 09:32:50 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:43742 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729497AbfBLOab (ORCPT ); Tue, 12 Feb 2019 09:30:31 -0500 Received: from [5.158.153.53] (helo=linux.lab.linutronix.de.) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1gtZ4l-0005Af-SJ; Tue, 12 Feb 2019 15:30:20 +0100 From: John Ogness To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Daniel Wang , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , Alan Cox , Jiri Slaby , Peter Feiner , linux-serial@vger.kernel.org, Sergey Senozhatsky Subject: [RFC PATCH v1 13/25] printk: track seq per console Date: Tue, 12 Feb 2019 15:29:51 +0100 Message-Id: <20190212143003.48446-14-john.ogness@linutronix.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190212143003.48446-1-john.ogness@linutronix.de> References: <20190212143003.48446-1-john.ogness@linutronix.de> X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow each console to track which seq record was last printed. This simplifies identifying dropped records. Signed-off-by: John Ogness --- include/linux/console.h | 1 + kernel/printk/printk.c | 30 +++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/linux/console.h b/include/linux/console.h index ec9bdb3d7bab..7fa06a058339 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -153,6 +153,7 @@ struct console { short flags; short index; int cflag; + unsigned long printk_seq; void *data; struct console *next; }; diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index ece54c24ea0d..ebd9aac06323 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1453,6 +1453,16 @@ SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len) return do_syslog(type, buf, len, SYSLOG_FROM_READER); } +static void print_console_dropped(struct console *con, u64 count) +{ + char text[64]; + int len; + + len = sprintf(text, "** %llu printk message%s dropped **\n", + count, count > 1 ? "s" : ""); + con->write(con, text, len); +} + static void format_text(struct printk_log *msg, u64 seq, char *ext_text, size_t *ext_len, char *text, size_t *len, bool time) @@ -1486,7 +1496,7 @@ static void format_text(struct printk_log *msg, u64 seq, * log_buf[start] to log_buf[end - 1]. * The console_lock must be held. */ -static void call_console_drivers(const char *ext_text, size_t ext_len, +static void call_console_drivers(u64 seq, const char *ext_text, size_t ext_len, const char *text, size_t len) { struct console *con; @@ -1504,6 +1514,19 @@ static void call_console_drivers(const char *ext_text, size_t ext_len, if (!cpu_online(raw_smp_processor_id()) && !(con->flags & CON_ANYTIME)) continue; + if (con->printk_seq >= seq) + continue; + + con->printk_seq++; + if (con->printk_seq < seq) { + print_console_dropped(con, seq - con->printk_seq); + con->printk_seq = seq; + } + + /* for supressed messages, only seq is updated */ + if (len == 0 && ext_len == 0) + continue; + if (con->flags & CON_EXTENDED) con->write(con, ext_text, ext_len); else @@ -1738,7 +1761,7 @@ static ssize_t msg_print_ext_header(char *buf, size_t size, static ssize_t msg_print_ext_body(char *buf, size_t size, char *dict, size_t dict_len, char *text, size_t text_len) { return 0; } -static void call_console_drivers(const char *ext_text, size_t ext_len, +static void call_console_drivers(u64 seq, const char *ext_text, size_t ext_len, const char *text, size_t len) {} static size_t msg_print_text(const struct printk_log *msg, bool syslog, bool time, char *buf, size_t size) { return 0; } @@ -2481,8 +2504,9 @@ static int printk_kthread_func(void *data) &len, printk_time); console_lock(); + call_console_drivers(master_seq, ext_text, + ext_len, text, len); if (len > 0 || ext_len > 0) { - call_console_drivers(ext_text, ext_len, text, len); boot_delay_msec(msg->level); printk_delay(); } -- 2.11.0