Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp24682pja; Fri, 22 Nov 2019 02:59:38 -0800 (PST) X-Google-Smtp-Source: APXvYqzWv43hyd9CWVNtPe4Srad36hyvs6iGatIWLDfzfLPgOExHA2q/NG8o8TMeNGUOqZ92KUpB X-Received: by 2002:aa7:df87:: with SMTP id b7mr277103edy.296.1574420378805; Fri, 22 Nov 2019 02:59:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574420378; cv=none; d=google.com; s=arc-20160816; b=Ppn4H0ZCMJOchsf4iiecAg7W2YQLPdBwaf3Nj4eusxOXrKhfjNtmj/SuMEWVosqD3X emr7sHXmxoXu9lAG4maxw3t7gTVE//KIgyezvTCdQy2Z4yzTYwQDbfyidQZkHflNONUR D9reSoyVZg9Auq8RMQ6SvKtzcalrJ3Zt1dgOGrdfVYJsdkvtEg3bYODmPJ8HmkbNWBif L+yxmro/DdgwEGkYUK2sdysSCD1C0rZPuqCWPJrFd++ItJ7qJ8rlfhkO0WxVEYDMCjgA 1IYwyYzXC/DALcAEUDWmTOA2Ao9Fh8kbTvLGtGHbOSBF2Shz2ZmIil8c9q5U2gqLi9W7 41xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+1CzXxZFu1uv+JFMz56d3HMZckSAUhtgeDK9XM+jD6o=; b=KggZpZ2RWymzmLk439jz3BSLRHY98mQbTNr+luWZT2eO8e49TN6Ccx2AJUATKnUyhl UtCbX2/XFFb8tfh20H43nwt6g7tMwxZnedyM8Rl6gMAdWOG8Jamw3/DflUnHfIr6znJY Qg2nxTxbaVbS/WiQEbhiZhL53WooE4amvUC40vZTY1isSKIfYibpdZGnB9+Zbr21zYae 54MSyZ1/k732cLNEs8AhXRNg5WXI+Jwi0Mn5TDYIUUJbxUKLL8NQbT5/ba2TNNlhsQem FeOUpAqIWeqnEUsLwIWYijPkCFmSQrydLfUkqCCwC/n2lmZX+0dJgzANOARqKfLNskla 5jWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NhBvFC3E; 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 h2si321242ejt.8.2019.11.22.02.59.15; Fri, 22 Nov 2019 02:59:38 -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=@kernel.org header.s=default header.b=NhBvFC3E; 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 S1730272AbfKVK6K (ORCPT + 99 others); Fri, 22 Nov 2019 05:58:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:47636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730079AbfKVK6G (ORCPT ); Fri, 22 Nov 2019 05:58:06 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6AC972075B; Fri, 22 Nov 2019 10:58:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574420285; bh=Er1C0v6WOPG9MdMVv1ytWpIZtgZTMmVtrfz1ICT1oRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NhBvFC3EqXdQVHKUdbuNZz4S6vYQupVumcwBIFMPV8lY22jp4e4N/bOrLSyy/t1me fUiRMaXw8S9ElPcfF/V9xN7dc3W/2eUfv1+Nz5ZvNTEobNktRj3GyyiXydjLe2TW0O Rarsb8Clo0tsQF2OxRQeC2Of0D1Omaf9j4mqSG/c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, Steven Rostedt Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergey Senozhatsky , Peter Zijlstra , Sergey Senozhatsky , Petr Mladek , Sasha Levin Subject: [PATCH 4.19 055/220] printk: Do not miss new messages when replaying the log Date: Fri, 22 Nov 2019 11:27:00 +0100 Message-Id: <20191122100916.121259277@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100912.732983531@linuxfoundation.org> References: <20191122100912.732983531@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Petr Mladek [ Upstream commit f92b070f2dc89a8ff1a0cc8b608e20abef894c7d ] The variable "exclusive_console" is used to reply all existing messages on a newly registered console. It is cleared when all messages are out. The problem is that new messages might appear in the meantime. These are then visible only on the exclusive console. The obvious solution is to clear "exclusive_console" after we replay all messages that were already proceed before we started the reply. Reported-by: Sergey Senozhatsky Link: http://lkml.kernel.org/r/20180913123406.14378-1-pmladek@suse.com To: Steven Rostedt Cc: Peter Zijlstra Cc: Sergey Senozhatsky Cc: linux-kernel@vger.kernel.org Acked-by: Sergey Senozhatsky Signed-off-by: Petr Mladek Signed-off-by: Sasha Levin --- kernel/printk/printk.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index d0d03223b45b1..b627954061bb6 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -423,6 +423,7 @@ static u32 log_next_idx; /* the next printk record to write to the console */ static u64 console_seq; static u32 console_idx; +static u64 exclusive_console_stop_seq; /* the next printk record to read after the last 'clear' command */ static u64 clear_seq; @@ -2014,6 +2015,7 @@ static u64 syslog_seq; static u32 syslog_idx; static u64 console_seq; static u32 console_idx; +static u64 exclusive_console_stop_seq; static u64 log_first_seq; static u32 log_first_idx; static u64 log_next_seq; @@ -2381,6 +2383,12 @@ void console_unlock(void) goto skip; } + /* Output to all consoles once old messages replayed. */ + if (unlikely(exclusive_console && + console_seq >= exclusive_console_stop_seq)) { + exclusive_console = NULL; + } + len += msg_print_text(msg, console_msg_format & MSG_FORMAT_SYSLOG, text + len, @@ -2423,10 +2431,6 @@ void console_unlock(void) console_locked = 0; - /* Release the exclusive_console once it is used */ - if (unlikely(exclusive_console)) - exclusive_console = NULL; - raw_spin_unlock(&logbuf_lock); up_console_sem(); @@ -2711,6 +2715,7 @@ void register_console(struct console *newcon) * the already-registered consoles. */ exclusive_console = newcon; + exclusive_console_stop_seq = console_seq; } console_unlock(); console_sysfs_notify(); -- 2.20.1