From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752330AbdF3L5L (ORCPT ); Fri, 30 Jun 2017 07:57:11 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:34088 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752253AbdF3L5I (ORCPT ); Fri, 30 Jun 2017 07:57:08 -0400 Date: Fri, 30 Jun 2017 20:57:11 +0900 From: Sergey Senozhatsky To: Tetsuo Handa Cc: sergey.senozhatsky.work@gmail.com, pmladek@suse.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, jack@suse.cz, akpm@linux-foundation.org, peterz@infradead.org, rjw@rjwysocki.net, ebiederm@xmission.com, gregkh@linuxfoundation.org, jslaby@suse.com, pavel@ucw.cz, andi@lisas.de, linux-kernel@vger.kernel.org Subject: Re: [RFC][PATCHv3 2/5] printk: introduce printing kernel thread Message-ID: <20170630115710.GB474@jagdpanzerIV.localdomain> References: <20170529092906.GD21894@pathway.suse.cz> <20170531072233.GC7672@jagdpanzerIV.localdomain> <20170628121925.GN1538@pathway.suse.cz> <20170629073321.GA475@jagdpanzerIV.localdomain> <20170630070131.GA474@jagdpanzerIV.localdomain> <201706301918.HFI17946.JtOFLOFQSHOMFV@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201706301918.HFI17946.JtOFLOFQSHOMFV@I-love.SAKURA.ne.jp> User-Agent: Mutt/1.8.3 (2017-05-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (06/30/17 19:18), Tetsuo Handa wrote: > Sergey Senozhatsky wrote: > > if (!alloc_cpumask_var(&cpus_allowed, GFP_KERNEL)) { > > wake_up_process(printk_kthread); > > return true; > > } > > Please avoid memory allocations when trying to print something. > __GFP_DIRECT_RECLAIM allocations (e.g. GFP_KERNEL) can sleep for > unpredictable duration. Allocations without __GFP_NOWARN will cause > e.g. memory allocation failure messages. Even with __GFP_NOWARN, > some messages might be still printed (e.g. serious problem). wow... dammit, what a stupid mistake. you are 100% right, thanks! it's sooo unsafe and dumb, console_unlock() and, thus, offloading can happen from IRQ. thanks again. > > I'm still thinking about Steven's proposals; but we will need offloading > > anyways, so the bits we are talking about here are important regardless > > the direction printk design will take, I think. > > Is there a chance that printk() waits for only data queued by that printk() > call (exception will be printk() from NMI). hm, I don't think this can be done easily... consider console_lock(); printk(); printk(); ... -> this guys will wait forever. nothing flushes the logbuf. printk(); console_unlock(); > If we carry penalty for printk() (charge delay according to amount of > data queued by that printk()), users will stop doing stupid flooding > with printk() based on an assumption that offloaded kernel thread will > manage magically with guarantee of being printed out (i.e. users has > to become careful). ratelimiting is on my list. but it's a bit tricky... what should happen if one does CPU1 -> IRQ printk() console_unlock(); printk() console_unlock(); ... printk() ratelimit(); console_unlock(); -> NMI panic() need to think more. -ss