Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1585670img; Wed, 27 Feb 2019 01:49:06 -0800 (PST) X-Google-Smtp-Source: AHgI3IYDglJuOWi0+vL4JqQNYwWdLaglhJKurp8io7BuRArsrdbaP/TTP/bv3kscQ8JDz6I2ehl3 X-Received: by 2002:a62:e005:: with SMTP id f5mr805639pfh.64.1551260946106; Wed, 27 Feb 2019 01:49:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551260946; cv=none; d=google.com; s=arc-20160816; b=ukrEf5Np7B+wB2dzZlPzHXdqx5gnpsjIPL9Wk/9x5SKpNX8+6oOonnwTRBdtUqzKMG /DnIxNuaISzqCNsOb/PpZEAokgIekGPWjSP4J7Msw6IQGaIcwIXYkuwlIH1zXFfPEloI F8bNeotvRdeaX1MBQTdX8Fpo/CUXN78BBNljIpfclaBMAbiETRVA8QJD1yhKEYhfZh3U 6M647P1WljxyjYxwXHdOqGu0CiwPUaMqlKF0jfMxSyB37v+4Yf3YKQ6md6TMcvPNuflL DyIPvtrSl05v0pIo9ZgdUiECxa5H1hgnR7HQ/y6IbTZoiwHXB9VZYuKeIfpr+PYOP5eN VJaw== 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=6NzUC7nxshGA5Ivge74pAilgbvefWYrTWVAt0HmM2NE=; b=TJ9Xjv8lPk9tfR0loHTToK6YlLq8TWqZfu7x9YlIfvxpDzsAfMPDc892ULyd3pZmi1 iLOjcDESsl87YNwz5aWWpe3G8GncrDyPkCZEfZALHnHVGwwBjOYeRo3D9KZRu8bxW7Dm TdKYVNtmBQVt2wVT4ffK5oajeIE+aeaFz3T4eEmJ0dROzOcXdwxFa4JaYWCzhMU7rDgZ dzVdhzCcYCDWwS89srIUInDzwAvgJJF9jKi5aJowqwOjp0RNsjcA8sFRhbYdJPLgG9Py Lfs15ANRK0IiRDurNy1ylD+R9I7MAhnjxuPqgVznSCtqgwLejqA72cIMZyUqghd+5gmF AfiA== 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 c6si13364247pgj.347.2019.02.27.01.48.50; Wed, 27 Feb 2019 01:49:06 -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 S1729808AbfB0JrA (ORCPT + 99 others); Wed, 27 Feb 2019 04:47:00 -0500 Received: from mx2.suse.de ([195.135.220.15]:33656 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725881AbfB0JrA (ORCPT ); Wed, 27 Feb 2019 04:47:00 -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 C9A85AF63; Wed, 27 Feb 2019 09:46:58 +0000 (UTC) Date: Wed, 27 Feb 2019 10:46:55 +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: <20190227094655.ecdwhsc2bf5spkqx@pathway.suse.cz> References: <20190212143003.48446-1-john.ogness@linutronix.de> <20190212143003.48446-21-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190212143003.48446-21-john.ogness@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 Tue 2019-02-12 15:29:58, John Ogness wrote: > Implement a non-sleeping NMI-safe write_atomic console function in > order to support emergency printk messages. It uses console_atomic_lock() added in 18th patch. That one uses prb_lock() added by 2nd patch. Now, prb_lock() allows recursion on the same CPU. But it still needs to wait until it is released on another CPU. It means that it is not completely save when NMIs happen on more CPUs in parallel, for example, when calling nmi_trigger_cpumask_backtrace(). OK, it would be safe when prb_lock() is the only lock taken in the NMI handler. But printk() should not make such limitation to the rest of the system. Not to say, that we would most likely need to add a lock back into nmi_cpu_backtrace() to keep the output sane. Peter Zijlstra several times talked about fully lockless consoles. He is using the early console for debugging, see the patchset https://lkml.kernel.org/r/20170928121823.430053219@infradead.org I am not sure if it is always possible. I personally see the following way: 1. Make the printk ring buffer fully lockless. Then we reduce the problem only to console locking. And we could have a per-console-driver lock (no the big lock like prb_lock()). 2. I am afraid that we need to add some locking between CPUs to avoid mixing characters from directly printed messages. This would be safe everywhere expect in NMI. Then we could either risk ignoring the lock in NMI (there should be few messages anyway, the backtraces would get synchronized another way). Or we might need a compromise between handling console using the current owner and offload. Best Regards, Petr