Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp978262imc; Mon, 11 Mar 2019 03:53:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqoQxgcPvyUV+oRSyVV9KJvSWC2zxPwCWz9xoBF+BIK3FoCQzW3r/YniAbC+SHJVuabAgq X-Received: by 2002:a63:8542:: with SMTP id u63mr29631712pgd.323.1552301599712; Mon, 11 Mar 2019 03:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552301599; cv=none; d=google.com; s=arc-20160816; b=cYOnI0xd7+w5cQRKEDoEzuO+yQbygN2ixu69sh/eaCdYEaj0xLM8GfYQrtp6B9shRD 73EEsJ97IRAjGTy5UZmvyOJRwnB2kLtbbYzP/pC35fQ89Sd+5C4vkoahwD65vKqXM2uY 8Nf4bHuD9c+TfdxsGpLQldQjbdJm8939ubsWQnm0pnzA10DWcEAEcxZrtUoAof/ggbAr D2l+4BOe50Z/4/3bSXYD2lrBya7ALHZktcpPFy69V9x4LVpsv1tqXGgZEQ6kLVIe5lkr RcqXpybAViNm+4T//PZmOz51GkB5/xzpy8N3LF3R6+O3NMY/IEunDOP8bhEwY9g/vD9D 7xvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=+CfUG0g82BmAc/sUzPM74y5m4d4lGp3n+H/8nhSWuHE=; b=EZMHcLJqKVGhoSh/DPaiHLTILt4ETzFCN8FMSdQbh7uHesNsCpBwyZ+y0BfluMdZ0a 7Wf6pgxP2EFvEaRAQ76ymtKn9VvC9Bkt+NW65R6W3rXbJx9s6Tszzgrwrl3IOGBvn6hM F1YV/N2QPwnX6R+oPYBB7Bis8+8AgQSUiOWOebB4L9QSy3IWEIcnWQ/ajkfTOvB4/rE0 UHs3X2AHmuMDg6hPN/QA1MT+Q4BJS76EwGqKPUzWWji3ojk9osN9dbJAh7V9ZxseOACk Jj/h75wHEXE23AxpGuLuWlK2tdudXs/gaXMbAN9zjllNpOaC6BwXO/RQzEYJ/WoYvlX6 am6A== 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 v11si5121732plo.377.2019.03.11.03.53.03; Mon, 11 Mar 2019 03:53:19 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727321AbfCKKwJ (ORCPT + 99 others); Mon, 11 Mar 2019 06:52:09 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:38055 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727261AbfCKKwJ (ORCPT ); Mon, 11 Mar 2019 06:52:09 -0400 Received: from localhost ([127.0.0.1] helo=vostro.local) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1h3IX9-00021p-IH; Mon, 11 Mar 2019 11:51:51 +0100 From: John Ogness To: Sergey Senozhatsky Cc: Sergey Senozhatsky , linux-kernel@vger.kernel.org, Peter Zijlstra , Petr Mladek , Steven Rostedt , Daniel Wang , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , Alan Cox , Jiri Slaby , Peter Feiner , linux-serial@vger.kernel.org Subject: Re: [RFC PATCH v1 08/25] printk: add ring buffer and kthread References: <20190212143003.48446-1-john.ogness@linutronix.de> <20190212143003.48446-9-john.ogness@linutronix.de> <20190304073856.GA552@jagdpanzerIV> <20190304100044.GC21004@jagdpanzerIV> <20190304110703.GA960@tigerII.localdomain> <87o96p9gtx.fsf@linutronix.de> <20190307051530.GC4893@jagdpanzerIV> Date: Mon, 11 Mar 2019 11:51:49 +0100 In-Reply-To: <20190307051530.GC4893@jagdpanzerIV> (Sergey Senozhatsky's message of "Thu, 7 Mar 2019 14:15:30 +0900") Message-ID: <87va0pznsq.fsf@linutronix.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-03-07, Sergey Senozhatsky wrote: >> The current printk implementation will do a better job of getting the >> informational messages out, but at an enormous cost to all the tasks >> on the system (including the realtime tasks). I am proposing a printk >> implementation where the tasks are not affected by console printing >> floods. > > In new printk design the tasks are still affected by printing floods. > Tasks have to line up and (busy) wait for each other, regardless of > contexts. They only line up and busy wait is to add the informational message to the ring buffer. The current printk implementation is the same in this respect. And as you've noted, the logbuf spinlock is not a source of latencies. > One of the late patch sets which I had (I never ever published it) was > a different kind of printk-kthread offloading. The idea was that > whatever should be printed (suppress_message_printing()) should be > printed. We obviously can't loop in console_unlock() for ever and > there is only one way to figure out if we can print out more messages, > that's why printk became RCU stall detector and watchdog aware; and > printk would break out and wake up printk_kthread if it sees that > watchdog is about to get angry on that particular CPU. printk_kthread > would run with preemption disabled and do the same thing: if it spent > watchdog_threshold / 2 printing - breakout, enable local IRQ, > cond_resched(). IOW watchdogs determine how much time we can spend on > printing. I studied and experimented with this (from your git). It was an interesting idea of keeping the current logic, but allowing to offload to a separate kthread if things were getting too overloaded. (It is also where I got term "emergency" from.) But I was satisfied with neither the direct printing (winner takes all, printk-safe defers) nor _relying_ on a kthread for important messages in an offload situation. This is what convinced me that the kernel needs a new interface so that it can communicate the _really_ important things synchronously: write_atomic(). >> I want messages of the information category to cause no disturbance >> to the system. Give the kernel the freedom to communicate to users >> without destroying its own performance. This can only be achieved if >> the messages are printed from a _fully_ preemptible context. > [..] >> And I want messages of the emergency category to be as reliable as >> possible, regardless of the costs to the system. Give the kernel a >> clear mechanism to _reliably_ communicate critical information. Such >> messages should never appear on a correctly functioning system. > > I don't really understand the role of loglevel anymore. > > When I do ./a.out --loglevel=X I have a clear understanding that > all messages which fall into [critical, X] range will be in the logs, > because I told that application that those messages are important to > me right now. And it used to be the same with the kernel loglevel. The loglevel is not related to logging. It specifies the amount of console printing. But I will assume you are referring to creating log files by having an external device store the console printing. > But now the kernel will do its own thing: > > - what the kernel considers important will go into the logs > - what the kernel doesn't consider important _maybe_ will end up > in the logs (preemptible printk kthread). And this is where > loglevel now. After the _maybe_ part. "what the kernel considers" is a configuration option of the administrator. The administrator can increase the verbocity of the console (loglevel) without having negative effects on the system itself. Also, if the system were to suddenly crash, those crash messages shouldn't be in jeopardy just because the verbocity of the console was turned up. You (and Petr) talk about that _all_ console printing is for emergencies. That if an administrator sets the loglevel to 7 it is because the pr_info messages are just as important as the pr_emerg. And if that is indeed the intention of console printing and loglevel, then why is asynchronous printk calls for console messages even allowed today? IMO that isn't taking the importance of the message very seriously. > If I'm not mistaken, Tetsuo reported that on a box under heavy OOM > pressure he saw preemptible printk dragging 5 minutes behind the > logbuf head. Preemptible printk is good for nothing. It's beyond > useless, it's something else. The informational messages are correctly timestamped and can be sorted offline. They are informational, so any loss is less tragic. And they aren't affecting system performance because they are being printed in preemptible contexts. John Ogness