From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754778AbcIVLWm (ORCPT ); Thu, 22 Sep 2016 07:22:42 -0400 Received: from merlin.infradead.org ([205.233.59.134]:45222 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751546AbcIVLWl (ORCPT ); Thu, 22 Sep 2016 07:22:41 -0400 Date: Thu, 22 Sep 2016 12:17:25 +0200 From: Peter Zijlstra To: Jan Kara Cc: Petr Mladek , Matt Fleming , Ingo Molnar , Byungchul Park , Frederic Weisbecker , Luca Abeni , Rik van Riel , Thomas Gleixner , Wanpeng Li , Yuyang Du , Sergey Senozhatsky , linux-kernel@vger.kernel.org, Mel Gorman , Mike Galbraith Subject: Re: [PATCH v2 7/7] sched/core: Add debug code to catch missing update_rq_clock() Message-ID: <20160922101725.GK5020@twins.programming.kicks-ass.net> References: <20160921133813.31976-1-matt@codeblueprint.co.uk> <20160921133813.31976-8-matt@codeblueprint.co.uk> <20160921155826.GB8408@pathway.suse.cz> <20160922080436.GX5008@twins.programming.kicks-ass.net> <20160922083637.GE2834@quack2.suse.cz> <20160922093909.GW5012@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160922093909.GW5012@twins.programming.kicks-ass.net> 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 Thu, Sep 22, 2016 at 11:39:09AM +0200, Peter Zijlstra wrote: > bit banging the serial port is absolutely awesome, the rest of printk > not so much. I also have this second patch that goes on top of this. I think I had more hacks (like using the per-cpu NMI buffers for output instead of the on-stack thing), but I cannot seem to find them just now. --- kernel/printk/printk.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -356,14 +356,28 @@ static int __init force_early_printk_set } early_param("force_early_printk", force_early_printk_setup); +static int early_printk_cpu = -1; + static int early_vprintk(const char *fmt, va_list args) { + int n, cpu, old; char buf[512]; - int n; + + cpu = get_cpu(); + for (;;) { + old = cmpxchg(&early_printk_cpu, -1, cpu); + if (old == -1 || old == cpu) + break; + + cpu_relax(); + } n = vscnprintf(buf, sizeof(buf), fmt, args); early_console->write(early_console, buf, n); + smp_store_release(&early_printk_cpu, old); + put_cpu(); + return n; }