From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752504AbcIAIRo (ORCPT ); Thu, 1 Sep 2016 04:17:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:41364 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751229AbcIAIRk (ORCPT ); Thu, 1 Sep 2016 04:17:40 -0400 Date: Thu, 1 Sep 2016 10:17:33 +0200 From: Petr Mladek To: Sergey Senozhatsky Cc: Sergey Senozhatsky , Andrew Morton , Jan Kara , linux-kernel@vger.kernel.org Subject: Re: [PATCH] printk/nmi: avoid direct printk()-s from __printk_nmi_flush() Message-ID: <20160901081732.GV4866@pathway.suse.cz> References: <20160829123220.1295-1-sergey.senozhatsky@gmail.com> <20160829151600.GM4866@pathway.suse.cz> <20160830075834.GA494@swordfish> <20160830090436.GO4866@pathway.suse.cz> <20160830093918.GA23693@swordfish> <20160830111948.GQ4866@pathway.suse.cz> <20160901075507.GA504@swordfish> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160901075507.GA504@swordfish> 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 Thu 2016-09-01 16:55:07, Sergey Senozhatsky wrote: > On (08/30/16 13:19), Petr Mladek wrote: > > > > I see. But then we will need to be more careful because printk_func > > and printk_func_saved will be manipulated in different contexts: > > normal, irq, nmi. A solution might be using an atomic counter > > and selecting the right vprintk_func according to the value. > > alt_printk_enter() must be done with local IRQs disabled. so IRQ cannot > race with `normal' alt_printk. other IRQs cannot race with the current IRQ, > because we have local IRQs disabled. the only thing that can race here is - NMI. > both `normal' and IRQ alt_printk can use the same per-CPU buffer, they never > race. NMI needs to have its own. Yes. Well, my concern was how to atomically change the printk_func pointer and save the previous value at the same time. You could not use locks because NMIs are involved. Best Regards, Petr