From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034165AbcJRRxp (ORCPT ); Tue, 18 Oct 2016 13:53:45 -0400 Received: from smtprelay0193.hostedemail.com ([216.40.44.193]:42022 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1034146AbcJRRxf (ORCPT ); Tue, 18 Oct 2016 13:53:35 -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:1540:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3352:3622:3865:3867:3870:3871:3874:5007:6119:6261:7875:8531:10004:10400:10848:10967:11026:11232:11658:11914:12295:12740:12760:13069:13311:13357:13439:14096:14097:14181:14659:14721:21080:21324:30012:30054: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:2,LUA_SUMMARY:none X-HE-Tag: step82_1ed5a9ac9c51c X-Filterd-Recvd-Size: 2265 Date: Tue, 18 Oct 2016 13:53:29 -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: <20161018135329.3e8eef38@gandalf.local.home> In-Reply-To: <20161018173046.GB3102@twins.programming.kicks-ass.net> References: <20161018170830.405990950@infradead.org> <20161018171513.734367391@infradead.org> <20161018131951.707f320e@gandalf.local.home> <20161018173046.GB3102@twins.programming.kicks-ass.net> 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:30:46 +0200 Peter Zijlstra wrote: > On Tue, Oct 18, 2016 at 01:19:51PM -0400, Steven Rostedt wrote: > Looking at this again, we really should not spin using cmpxchg(), that > thrashes the cacheline. > > The below is slightly better spinning... then again, this isn't > performance code. Yeah, this is similar to the hack I had. May want to fold this in your previous version. -- Steve > > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -376,10 +376,16 @@ static int early_vprintk(const char *fmt > > cpu = get_cpu(); > for (;;) { > - old = cmpxchg(&early_printk_cpu, -1, cpu); > - if (old == -1 || old == cpu) > + old = READ_ONCE(early_printk_cpu); > + if (old == cpu) > break; > > + if (old == -1) { > + old = cmpxchg(&early_printk_cpu, -1, cpu); > + if (old == -1 || old == cpu) > + break; > + } > + > cpu_relax(); > } >