From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757353AbcK2OLL (ORCPT ); Tue, 29 Nov 2016 09:11:11 -0500 Received: from mx2.suse.de ([195.135.220.15]:55378 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756227AbcK2OK6 (ORCPT ); Tue, 29 Nov 2016 09:10:58 -0500 Date: Tue, 29 Nov 2016 15:10:55 +0100 From: Petr Mladek To: Peter Zijlstra Cc: Sergey Senozhatsky , Andrew Morton , Jan Kara , Tejun Heo , Calvin Owens , Thomas Gleixner , Mel Gorman , Steven Rostedt , Ingo Molnar , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] early_printk: Add simple serialization to early_vprintk() Message-ID: <20161129141054.GD21230@pathway.suse.cz> References: <20161018170830.405990950@infradead.org> <20161018171513.734367391@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161018171513.734367391@infradead.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2016-10-18 19:08:33, 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) Makes sense. Just a small comment below. Reviewd-by: Petr Mladek > --- 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; [...] > + 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); checkpatch.pl complains about using a barrier without a comment. The code is simple but it still might help to add something like: /* Releasing early_printk_cpu custom lock. */ Best Regards, Petr