From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752904AbcJADDl (ORCPT ); Fri, 30 Sep 2016 23:03:41 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:34716 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751559AbcJADDd (ORCPT ); Fri, 30 Sep 2016 23:03:33 -0400 Date: Sat, 1 Oct 2016 12:02:51 +0900 From: Sergey Senozhatsky To: Petr Mladek Cc: Sergey Senozhatsky , Sergey Senozhatsky , Jan Kara , Andrew Morton , Tejun Heo , Calvin Owens , linux-kernel@vger.kernel.org Subject: Re: [RFC][PATCH 0/7] printk: use alt_printk to handle printk() recursive calls Message-ID: <20161001030251.GC527@swordfish> References: <20160927142237.5539-1-sergey.senozhatsky@gmail.com> <20160929132502.GG26796@pathway.suse.cz> <20160930024307.GE547@swordfish> <20160930112743.GJ26796@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160930112743.GJ26796@pathway.suse.cz> User-Agent: Mutt/1.7.0 (2016-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (09/30/16 13:27), Petr Mladek wrote: > > > > 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. > > > > > > I was skeptical but I really like this way now. > > > > > > The switching of the buffers is a bit hairy in this version but I > > > think that we could make it much better. > > > > > > Other than that it looks like a big win. It kills a lot of > > > printk-related pain points. And it will not be that complicated > > > after all. > > > > many thanks for looking at this train wreck. > > > > so, like I said, it addresses printk()-recursion in *ideally* quite > > a minimalistic way -- just several alt_printk_enter/exit calls in > > printk.c, without ever touching any other parts of the kernel. > > > > gunning down printk deadlocks in general, however, requires much more > > effort; or even a completely different approach. > > > > a) a lock-less printk() by default > > um, `#define printk alt_printk'. but this will break printk() from irq. > > and the ordering of messages from per-cpu buffers may be far from correct. > > Well, the current vprintk_nmi() is lockless. The alternative printk() > is going to use the same code, so it will be lockless as well. It > means that even this patchset is supposed to avoid all possible > deadlocks via printk() calls. I meant that printk-recursion and printk-deadlock can be different scenarios. deadlocks are harder to handle devkmsg_open() raw_spin_lock_irq(&logbuf_lock) spin_dump() printk() raw_spin_lock_irqsave(&logbuf_lock) this one can be handled by alt_printk. devkmsg_open() local_irq_save(); alt_printk_enter() raw_spin_lock(&logbuf_lock) spin_dump() printk() vprintk_alt() but there are some that can't be handled solely in printk.c -ss