From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752218AbdDCLxM (ORCPT ); Mon, 3 Apr 2017 07:53:12 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33747 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751647AbdDCLxL (ORCPT ); Mon, 3 Apr 2017 07:53:11 -0400 Date: Mon, 3 Apr 2017 20:53:11 +0900 From: Sergey Senozhatsky To: Petr Mladek Cc: Steven Rostedt , Andrew Morton , Linus Torvalds , Peter Zijlstra , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Sergey Senozhatsky Subject: Re: [RFC][PATCH 0/4] printk: introduce printing kernel thread Message-ID: <20170403115311.GC7867@jagdpanzerIV.localdomain> References: <20170306124554.828-1-sergey.senozhatsky@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170306124554.828-1-sergey.senozhatsky@gmail.com> User-Agent: Mutt/1.8.0 (2017-02-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (03/06/17 21:45), Sergey Senozhatsky wrote: [..] > printk kthread changes the behavior of printk in one _corner case_. > The corner case is quite interesting and actually consists of two corner > cases. Suppose on SMP system there is only one CPU that printk()-s a lot, > the rest of CPUs don't lock console_sem and don't printk(). Previously > that printing CPU had been throttling itself (*) because of console drivers > call for every printk(): > > CPU0 > > printk("a") > console_unlock() > call_console_drivers("a") > > ... > > printk("z") > console_unlock() > call_console_drivers("z") > > * Given that no other CPU locks the console_sem. > > With printk kthread the case turns into this one: > > CPU0 CPU1 > > printk("a") > wake_up printk_kthread > ... printk_kthread > printk("k") console_unlock() > ... call_console_drivers("a") > printk("z") call_console_drivers("b") > call_console_drivers("c") > ... > > > The second 'corner case' part here is that CPU0 may be much faster > than printing CPU, which may result in dropped printk messages. > > This all is absolutely possible even with out the printk-kthread. > A single console_lock() call from CPUx will result in exactly the > same condition. So it's not necessarily a regression. But there may > be some scenarios in the kernel that may suffer from this change. > From the top of my head -- sysrq backtrace dump, and, probably, OOM > print out and backtrace dump. there is another possibility here. being always reschedulable potentially can put us at risk of having unpleasant situations when printk_kthread is getting preempted too often (well, who knows what can happen on the system), which can slow down logbuf emit process (printk_kthread) up to the point when printk() CPUs will force log_store() to begin dropping the messages. this can happen. -ss