Message ID | 20230302195618.156940-18-john.ogness@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp43468wrd; Thu, 2 Mar 2023 12:02:17 -0800 (PST) X-Google-Smtp-Source: AK7set+CvD8vXEJav5Kxov5mNR2ZYWaWa04RBmT+7tVas7nuhMfCdo/Dr47bveTOdJ8acGzkL4RE X-Received: by 2002:a17:903:1c1:b0:19d:20f7:dafa with SMTP id e1-20020a17090301c100b0019d20f7dafamr13130787plh.43.1677787337026; Thu, 02 Mar 2023 12:02:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677787337; cv=none; d=google.com; s=arc-20160816; b=cDRPUJzTRnfloDlxok7mVPwj9whLQ0hodhYHituzpWnvyey+6imo2YnLjqGUo60Mes rgFKa7OBSXuriV1qU7S182RNRDOtGE8w2Q1+rI1tT6GpsyI/p0DPuRaWWD2g/ss0j/LP JwkkdNCy2SeU8jY8Df9DzRqm2TeRgiTD/VdLon7FyvCezA8DGYOv0JIXrlQojhxwBZTy j8B51TjO0nTb0b/xKk7evWvknKoPrwByKjT0kGOsBVVocDJ1bMIHjiXaKAz4T7qQyGWm GXFA8MiuOTUhsEpLt/MvPiY/MqLNVug5FWXIQ81JtxMjTqmc0pXIsYhdzkJ9oUw1NbXo VfTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=BQXtIuVdKd6aYDdz0BrUrqG+XHrNJCfdUZckqmV0CGk=; b=ZwgoO2GnPze3xO4Y3g32aUesWWM5x3MH6J0RrghhkC5O5R4Rxp9DfgM10RzzY85pIs iw9jdlhq9HkcM/u3cXxBVnsfhHQpa85HqNqP6MMJIPGQl21q5tngYpbBDUszyVuVNrU1 +ohqd/LTK4mOz7eGC5bxjhqXcVz4vRd+NQl15HmsdLFXwqQbB4kDdLunOtgM+0Kv1jBj IwYrmbhyQD4BeiISUE6ZyNUsiboGuuTW/gOISd88p7ZaqaeiXTjM14GTsZ/EG6RfBhtR NoW5DOTzxKxpVr+N3/ZkAFhAxdv+Am87W2htZ8YtbIL7NH5o5Ndwksr1taZlxaFurt7u G49g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lKgPdymx; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Ivxb5hj7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kt4-20020a170903088400b00194bcc88b52si187929plb.363.2023.03.02.12.02.03; Thu, 02 Mar 2023 12:02:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lKgPdymx; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Ivxb5hj7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229674AbjCBT6d (ORCPT <rfc822;davidbtadokoro@gmail.com> + 99 others); Thu, 2 Mar 2023 14:58:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230027AbjCBT5w (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 2 Mar 2023 14:57:52 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A55B48E31; Thu, 2 Mar 2023 11:57:51 -0800 (PST) From: John Ogness <john.ogness@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1677787067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BQXtIuVdKd6aYDdz0BrUrqG+XHrNJCfdUZckqmV0CGk=; b=lKgPdymx4ineOUjiWIUNWjOABTzLnRXZY8vvYPeuGMuZWqnHBPU9P2t7cAZ2XErOH9TERp mZFVRGlsJDT9mmyXB2vyT/So853g8vXuVt0VrWgeqBDYsl2CQQ0l/JwodkN74KwAeCGd7h GbpcdgKqBRioGBN6RgjmRl6VGTdc6mG/ld1dhiHAbSFr325qgbqtxcA6nLqVVVwzYoamSw 5bzTiusEtufwdgqd2sHwYpbUlebWmaJfgTvsT4WsSdbX//sVYn4zvF7Fe7ewscZJUCIgOq D1Om2f5V4LFfkUtA+45GZzB61yGT32SHDtw4CnLx9Ttz5eih0506JYBj2XPFog== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1677787067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BQXtIuVdKd6aYDdz0BrUrqG+XHrNJCfdUZckqmV0CGk=; b=Ivxb5hj77f/zf0BVQiuddIlSIi9XtkPI5IZVsai/WeryhUuVI7T0Rj3XQdt8Hfl+dPYn3e khSAw2pY/t5rqSBQ== To: Petr Mladek <pmladek@suse.com> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org, "Paul E. McKenney" <paulmck@kernel.org>, Frederic Weisbecker <frederic@kernel.org>, Neeraj Upadhyay <quic_neeraju@quicinc.com>, Josh Triplett <josh@joshtriplett.org>, Mathieu Desnoyers <mathieu.desnoyers@efficios.com>, Lai Jiangshan <jiangshanlai@gmail.com>, Joel Fernandes <joel@joelfernandes.org>, rcu@vger.kernel.org Subject: [PATCH printk v1 17/18] rcu: Add atomic write enforcement for rcu stalls Date: Thu, 2 Mar 2023 21:02:17 +0106 Message-Id: <20230302195618.156940-18-john.ogness@linutronix.de> In-Reply-To: <20230302195618.156940-1-john.ogness@linutronix.de> References: <20230302195618.156940-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759287534635491673?= X-GMAIL-MSGID: =?utf-8?q?1759287534635491673?= |
Series |
threaded/atomic console support
|
|
Commit Message
John Ogness
March 2, 2023, 7:56 p.m. UTC
Invoke the atomic write enforcement functions for rcu stalls to
ensure that the information gets out to the consoles.
It is important to note that if there are any legacy consoles
registered, they will be attempting to directly print from the
printk-caller context, which may jeopardize the reliability of the
atomic consoles. Optimally there should be no legacy consoles
registered.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
kernel/rcu/tree_stall.h | 6 ++++++
1 file changed, 6 insertions(+)
Comments
On Thu 2023-03-02 21:02:17, John Ogness wrote: > Invoke the atomic write enforcement functions for rcu stalls to > ensure that the information gets out to the consoles. "ensure" is too strong. It is still just the best effort. It might fail when the current console user does not pass the lock. I would say that it will increase the chance to see the messages on NOBKL consoles by printing the messages directly instead of waiting for the printk thread. > It is important to note that if there are any legacy consoles > registered, they will be attempting to directly print from the > printk-caller context, which may jeopardize the reliability of the > atomic consoles. Optimally there should be no legacy consoles > registered. The above paragraph is a bit vague. It is not clear how exactly the legacy consoles affect the reliability, Does it mean that they might cause a deadlock because they are not atomic? But there is nothing specific about rcu stalls and priority of NOBKL consoles. This is a generic problem with legacy consoles. > --- a/kernel/rcu/tree_stall.h > +++ b/kernel/rcu/tree_stall.h > @@ -566,6 +568,8 @@ static void print_other_cpu_stall(unsigned long gp_seq, unsigned long gps) > if (rcu_stall_is_suppressed()) > return; > > + prev_prio = cons_atomic_enter(CONS_PRIO_EMERGENCY); Thinking loudly: This would set the EMERGENCY priority on this CPU. But the following function: + rcu_dump_cpu_stacks() + dump_cpu_task() + trigger_single_cpu_backtrace() might send IPI and the backtrace will be printed from another CPU. As a result that backtraces won't be printed with EMERGENCY priority. One solution would be to have also global EMERGENCY priority. Another possibility would be to use EMERGENCY priority also in nmi_cpu_backtrace() which is the callback called by the IPI. I would probably go for the global flag. printk() called in EMERGENCY priority has to flush also messages added by other CPUs. So that messages added by other CPUs are printed "directly" anyway. Also setting the EMERGENCY priority in nmi_cpu_backtrace() is an ad-hoc solution. The backtrace is usually called as part of another global emergency report. > + > /* > * OK, time to rat on our buddy... > * See Documentation/RCU/stallwarn.rst for info on how to debug Best Regards, Petr
diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index 5653560573e2..25207a213e7a 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -8,6 +8,7 @@ */ #include <linux/kvm_para.h> +#include <linux/console.h> ////////////////////////////////////////////////////////////////////////////// // @@ -551,6 +552,7 @@ static void rcu_check_gp_kthread_expired_fqs_timer(void) static void print_other_cpu_stall(unsigned long gp_seq, unsigned long gps) { + enum cons_prio prev_prio; int cpu; unsigned long flags; unsigned long gpa; @@ -566,6 +568,8 @@ static void print_other_cpu_stall(unsigned long gp_seq, unsigned long gps) if (rcu_stall_is_suppressed()) return; + prev_prio = cons_atomic_enter(CONS_PRIO_EMERGENCY); + /* * OK, time to rat on our buddy... * See Documentation/RCU/stallwarn.rst for info on how to debug @@ -620,6 +624,8 @@ static void print_other_cpu_stall(unsigned long gp_seq, unsigned long gps) panic_on_rcu_stall(); rcu_force_quiescent_state(); /* Kick them all. */ + + cons_atomic_exit(CONS_PRIO_EMERGENCY, prev_prio); } static void print_cpu_stall(unsigned long gps)