From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938950AbcJRRJS (ORCPT ); Tue, 18 Oct 2016 13:09:18 -0400 Received: from merlin.infradead.org ([205.233.59.134]:58238 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755582AbcJRRJM (ORCPT ); Tue, 18 Oct 2016 13:09:12 -0400 Date: Tue, 18 Oct 2016 19:07:54 +0200 From: Peter Zijlstra To: Sergey Senozhatsky Cc: Petr Mladek , Andrew Morton , Jan Kara , Tejun Heo , Calvin Owens , Thomas Gleixner , Mel Gorman , Steven Rostedt , Ingo Molnar , linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: Re: [RFC][PATCHv3 0/6] printk: use printk_safe to handle printk() recursive calls Message-ID: <20161018170754.GA3102@twins.programming.kicks-ass.net> References: <20161018154045.7364-1-sergey.senozhatsky@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161018154045.7364-1-sergey.senozhatsky@gmail.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 19, 2016 at 12:40:39AM +0900, Sergey Senozhatsky wrote: > Hello, > > RFC > > This patch set extends a lock-less NMI per-cpu buffers idea to > handle recursive printk() calls. The basic mechanism is pretty much the > same -- at the beginning of a deadlock-prone section we switch to lock-less > printk callback, and return back to a default printk implementation at the > end; the messages are getting flushed to a logbuf buffer from a safer > context. So I think you're not taking this far enough. You've also missed an entire class of deadlocks. The first is that you still keep the logbuf. Having this global serialized thing is a source of fail. It would be much better to only keep per cpu stuff. _OR_ at the very least make the logbuf itself lockfree. So generate the printk entry local (so we know its size) then atomically reserve the logbuf entry and copy it over. The entire class of deadlocks you've missed is that console->write() is a piece of crap too ;-) Even the bog standard 8250 serial console driver can do wakeups. See for example: https://marc.info/?l=linux-kernel&m=132446649823347&w=2 I've entirely given up on printk(), I'll post the 3 patches I carry to make things work for me.