Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5796464imb; Fri, 8 Mar 2019 02:30:45 -0800 (PST) X-Google-Smtp-Source: APXvYqzqPlWhY/6h0iNq09cTXIwp0NURldz8QF8ZWeBI0GfbcAYuJNJJrH0o3NMQC6p1H+BDPPVk X-Received: by 2002:a62:e005:: with SMTP id f5mr18259222pfh.64.1552041045737; Fri, 08 Mar 2019 02:30:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552041045; cv=none; d=google.com; s=arc-20160816; b=IYE8GqdumKMhT1/PSyJk/Bv2LJhgTT/pryOE8dN9/FgyXQw/KkbiGwzW86fa4rhgrL Q1N1jjqd+ajO+FZHt/sEyceRtv3FBmPQGi/FicGmXMfqjZiGaG1KFECiaMe1xFcQLRyN /2cq3sOkkWO+m8Hn1aXL/vfj9QiIKpTXJ9O0Ivvr+Zwpzu/+PdIKcw85N37dZ4dkpFpL MninMQ7qzNpJfqG9Eeca1YIk4NwjNE+CXnw2KeGoNamphbDWA6rxOJgESSvLx8XTBgAK 6gqnMhi8dlkAiMweSOlNA66IWfS15RHt+g/VgvT+psiaub6z0/bB8UbliWDA+XNGd1Tz vXkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=5G7WMpuS3Bnwk3UIwpGe089tfTtA1akRBZwT3ec0MvE=; b=dpNZ8SQSUvy9O3m4MHoqttHn37tKMi9zlguTPvh3J8rrDGjuzeuUHvd4t1vnPm5Eap nppNho0b9qctFde6tXh/uFBWBrWNRUN6dzl9IvH7hOq0yj/w7+HqkHkz2W/VQQI49uhC +qNc6viyepq+MWaToQ95w6XcDcctSHf2ZQ0MHv4vCKuTd9X6+rrv1rVSLZj4ONEJufFX aMo945q/Pvv6OSo85ZhrIoSkrmZDcG6FI3LPx6czcJH0P++M0G/sReu1hCCWn3j4c76G y+T49Vyx+KCLvypg2OaEe9vGzX+JXHl4TvYHdykA/Arxb3mQ335L+3+tX4qRNBqtDhQt 4mHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g8si6079148pgd.52.2019.03.08.02.30.30; Fri, 08 Mar 2019 02:30:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726540AbfCHK2V (ORCPT + 99 others); Fri, 8 Mar 2019 05:28:21 -0500 Received: from mx2.suse.de ([195.135.220.15]:58908 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726254AbfCHK2V (ORCPT ); Fri, 8 Mar 2019 05:28:21 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2D320AD7B; Fri, 8 Mar 2019 10:28:20 +0000 (UTC) Date: Fri, 8 Mar 2019 11:28:19 +0100 From: Petr Mladek To: John Ogness Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Sergey Senozhatsky , Steven Rostedt , Daniel Wang , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , Alan Cox , Jiri Slaby , Peter Feiner , linux-serial@vger.kernel.org, Sergey Senozhatsky Subject: Re: [RFC PATCH v1 20/25] serial: 8250: implement write_atomic Message-ID: <20190308102819.lirle4vlf7mdcetp@pathway.suse.cz> References: <20190212143003.48446-1-john.ogness@linutronix.de> <20190212143003.48446-21-john.ogness@linutronix.de> <20190227094655.ecdwhsc2bf5spkqx@pathway.suse.cz> <87zhqhed3u.fsf@linutronix.de> <20190227135504.gqtcsdwpy4rd7xvs@pathway.suse.cz> <87a7i6ovt3.fsf@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87a7i6ovt3.fsf@linutronix.de> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 2019-03-08 05:05:12, John Ogness wrote: > On 2019-02-27, Petr Mladek wrote: > >>>> Implement a non-sleeping NMI-safe write_atomic console function in > >>>> order to support emergency printk messages. > >>> > >>> OK, it would be safe when prb_lock() is the only lock taken > >>> in the NMI handler. > >> > >> Which is the case. As I wrote to you already [0], NMI contexts are > >> _never_ allowed to do things that rely on waiting forever for other > >> CPUs. > > > > Who says _never_? I agree that it is not reasonable. But the > > history shows that it happens. > > Right, which is why it would need to become policy. > > The emergency messages (aka write_atomic) introduce a new requirement to > the kernel because this callback must be callable from any context. The > console drivers must have some way of synchronizing. The CPU-reentrant > spin lock is the only solution I am aware of. I am not in position to decide if this requirement is acceptable or not. We would need an opinion from Linus at minimum. But it is not acceptable from my point of view. Note that many spinlocks might be safely used in NMI in principle. You want to introduce a single spinlock just because printk() could be called anywhere. Most other subsystems do not have this problem because they a more self-contained. > If the ringbuffer was fully lockless Exactly, I think that a solution would be fully lockless logbuffer. > we should be able to have per-console CPU-reentrant spin locks > as long as the ordering is preserved, which I expect shouldn't > be a problem. If any NMI context needed a spin lock for its own > purposes, it would need to use the CPU-reentrant spin lock of > the first console so as to preserve the ordering in case of a panic. IMHO, this is not acceptable. It would be nice to have direct output from NMI but the cost looks to high here. A solution would be to defer the console to irq_work or so. We might also consider using trylock in NMI and have the irq_work just as a fallback. Best Regars, Petr