From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965113AbcJRRUG (ORCPT ); Tue, 18 Oct 2016 13:20:06 -0400 Received: from smtprelay0059.hostedemail.com ([216.40.44.59]:53201 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1034087AbcJRRTz (ORCPT ); Tue, 18 Oct 2016 13:19:55 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2731:2736:3138:3139:3140:3141:3142:3352:3622:3865:3867:3870:5007:6261:7875:7903:8531:10004:10400:10848:10967:11026:11232:11658:11914:12043:12438:12740:12760:13069:13311:13357:13439:14181:14659:14721:21080:21433:30054:30055:30064:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:9,LUA_SUMMARY:none X-HE-Tag: rail57_1c076f07df44f X-Filterd-Recvd-Size: 2436 Date: Tue, 18 Oct 2016 13:19:51 -0400 From: Steven Rostedt To: Peter Zijlstra Cc: Sergey Senozhatsky , Petr Mladek , Andrew Morton , Jan Kara , Tejun Heo , Calvin Owens , Thomas Gleixner , Mel Gorman , Ingo Molnar , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] early_printk: Add simple serialization to early_vprintk() Message-ID: <20161018131951.707f320e@gandalf.local.home> In-Reply-To: <20161018171513.734367391@infradead.org> References: <20161018170830.405990950@infradead.org> <20161018171513.734367391@infradead.org> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 18 Oct 2016 19:08:33 +0200 Peter Zijlstra wrote: > In order to avoid multiple CPUs banging on the serial port at the same > time, add simple serialization. This explicitly deals with nested > contexts (like IRQs etc.). > > Signed-off-by: Peter Zijlstra (Intel) > --- hehe, I have the exact same patch for my -rt work. -- Steve > 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; > } > >