From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751725AbcJJCDi (ORCPT ); Sun, 9 Oct 2016 22:03:38 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:35891 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751441AbcJJCDh (ORCPT ); Sun, 9 Oct 2016 22:03:37 -0400 Date: Sat, 8 Oct 2016 04:40:15 +0900 From: Sergey Senozhatsky To: Petr Mladek Cc: Sergey Senozhatsky , Jan Kara , Andrew Morton , Tejun Heo , Calvin Owens , Thomas Gleixner , Mel Gorman , Steven Rostedt , linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: Re: [RFC][PATCHv2 3/7] printk: introduce per-cpu alt_print seq buffer Message-ID: <20161007194015.GB3496@swordfish> References: <20160930151758.8965-1-sergey.senozhatsky@gmail.com> <20160930151758.8965-4-sergey.senozhatsky@gmail.com> <20161001022415.GA527@swordfish> <20161006145656.GH13369@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161006145656.GH13369@pathway.suse.cz> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (10/06/16 16:56), Petr Mladek wrote: [..] > > there are many WARN_ON_* on > > vprintk_alt()->alt_printk_log_store()->vsnprintf() path but they all > > seem to be calling printk(): > > > > - WARN_ON_ONCE() from vsnprintf() > > - WARN_ONCE() from vsnprintf()->format_decode() > > - WARN_ON vsnprintf()->set_field_width() > > - WARN_ON from vsnprintf()->set_precision() > > - WARN_ON from vsnprintf()->pointer()->flags_string() > > > > a side note, some of these WARNs are... 'funny'. e.g., to deadlock a > > system it's enough to just pass an unsupported flag in format string. > > vsnprintf() will > > WARN_ONCE(1, "Please remove unsupported %%%c in format string\n", *fmt) > > > > but the problem is that we are already in printk(): > > > > printk() > > raw_spin_lock(&logbuf_lock) > > text_len = vscnprintf(text, sizeof(textbuf), fmt, args) > > WARN_ONCE(1, "Please remove unsupported ...) > > printk() > > raw_spin_lock(&logbuf_lock) << deadlock > > Just for record. This vscnprintf() is called when logbuf_cpu is set. > Therefore this particular recursion is not possible at the moment. ah, indeed. thanks. > Anyway, I agree that alt_printk_enter() calls might get nested. > The direct vprintk_emit() calls are one reason. I guess that > we will need to use the same counter/enter functions also > for WARN_*DEFERRED(). And it would cause nesting as well. > > Therefore we need to be careful about loosing the original > value of irq flags. > > The question is whether we need to store the flags in > a per-CPU variable. We might also store it on the stack > of the enter()/exit() function caller. I mean something like yes, let's keep it on the stack. this particular implementation was just an experiment, and I hate it. what I currently have in my tree: #define alt_printk_enter(flags) \ do { \ local_irq_save(flags); \ __alt_printk_enter(); \ } while (0) #define alt_printk_exit(flags) \ do { \ __alt_printk_exit(); \ local_irq_restore(flags); \ } while (0) -ss