Received: by 2002:a05:6830:16d2:b0:61c:ac69:ca1b with SMTP id l18csp2157119otr; Mon, 25 Jul 2022 08:39:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1slLNoUGz/J4EU4YBy+J+FwC+wgWKeM3pEyCUmpmevoi7dZ4KFz9/cTH3KpH7qgjXNU+brc X-Received: by 2002:a63:8bc9:0:b0:412:aa5e:674c with SMTP id j192-20020a638bc9000000b00412aa5e674cmr11851003pge.51.1658763586087; Mon, 25 Jul 2022 08:39:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658763586; cv=none; d=google.com; s=arc-20160816; b=S78wQIVPOjgxMqoyFqQE1MvMhp+FLfkpuoiHB+oefdPFdMfP5xkOxnr03nyPumgZZE vwejCxd+4GL0z4nnr8KywBa8EGoqujzoea3UulEDMD5WEg5nddwfL6PgS2oxHt21/w9A rAVllo/Is2ZiM0+qm1onwQatzFA8uJoEEfCNMrTo3heU0KXJ1Ise8ugx9Mrj0jo3esTE cwBSMB8/zDgRC4TWwCxEm10wHRRgaOHa7ePOG87JP2SxbG9VptzcthwNNE/yAXYuo/+q H2s7x8FZvNWeols059n/hZNwyxZAooPnAPqFjtLL911/ZvvxCO1WrXhhitPddC9HJkr1 oPuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:dkim-signature:date; bh=P33YtHMgl2bIxHCGXheabYqxEWw48Aq4FFEore11rZU=; b=x2sZWrKNX2ixW8vkK20xpvAAcA1yIf7W2M4ut7Btt+zkOk+UGPZW+19r6zCevhtkUj gOstCTes5npUx1qhPE5Pqv4phwUR1DOeahqYyKF+y09DmpdBX19gbECe0oV8TKe9sn4d aZZTrNHTNBBNxONYNJKVUiMywM5R6CyZ16d5Ujt5nv48pIHn7FMr+ARv+V9KeYLzlMNw 4wWBFyqgFXlMvt8W4znE0TwNe2U7fRMcMQrbq7+iPhVplpFLxlGyLOxZtQlQx3YviQKH J4vwnGljs5Af1gJJs7ReBuExTKiR3YSWc8moNcG6GGePUVahqfKiLkur3mpakGVh3LK3 ZUkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JyJuqUpd; dkim=neutral (no key) header.i=@linutronix.de header.b=OquDrbSJ; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q126-20020a634384000000b0041a6772b82esi14773247pga.785.2022.07.25.08.39.30; Mon, 25 Jul 2022 08:39:46 -0700 (PDT) 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=JyJuqUpd; dkim=neutral (no key) header.i=@linutronix.de header.b=OquDrbSJ; 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 S236147AbiGYPTr (ORCPT + 99 others); Mon, 25 Jul 2022 11:19:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236388AbiGYPTG (ORCPT ); Mon, 25 Jul 2022 11:19:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4080C1EAE5 for ; Mon, 25 Jul 2022 08:16:21 -0700 (PDT) Date: Mon, 25 Jul 2022 17:16:16 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1658762177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P33YtHMgl2bIxHCGXheabYqxEWw48Aq4FFEore11rZU=; b=JyJuqUpdivPn+qr8aN+9SoCs/L0lZQdkhKv5SHdzeNr7CXQrtdIRCxD3TP7jvlJd24/lvI f2aLXdLw3Q4Xytt7NMz6of01dThuJ0nHI7la5fNB7rKzDtsBzQyUdu3OLf+ypMNiJYBEw9 8E34kj9cdxvDkfGZ95U8yng/4a6AQQXpqDpTR2KNVzyuHRRFyNS+DDBqV2DW1Jt3JsXKed g0WA8mB6rEU9cPy0yPvvl+nn6recs5hq5odHBfY+fchwJlrOcjsim2YSlNoD67cLYks7Ok yVlDe6F0kmJni64uZWqqs9RcAMDrAVTVkidm+NSebGvC7nK5iAZAJyf2EtGLaQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1658762177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P33YtHMgl2bIxHCGXheabYqxEWw48Aq4FFEore11rZU=; b=OquDrbSJHxBTVvKm+LaqgTt81CmI3ivRZTMWv8yAJf/MiNvw3jQfc6EIDW/0iWihOMTyVa 1i6cf4b1Tpt0agDA== From: Sebastian Andrzej Siewior To: Petr Mladek Cc: John Ogness , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner Subject: [PATCH v3] printk: Skip console drivers on PREEMPT_RT. Message-ID: References: <87y1wn3g3g.fsf@jogness.linutronix.de> <87ilnrn06u.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: X-Mailing-List: linux-kernel@vger.kernel.org printk might be invoked in a context with disabled interrupts and or preemption and additionally disables interrupts before it invokes the console drivers. This behaviour is not desired on PREEMPT_RT: - The console driver are using spinlock_t based locking which become sleepi= ng locks on PREEMPT_RT and must not be acquired with disabled interrupts (or preemption). - The locks within the console drivers must remain sleeping locks and they = must not disable interrupts. Printing (and polling for its completion) at 1152= 00 baud on an UART takes too long for PREEMPT_RT in general and so raises the latency of the IRQ-off time of the system beyond acceptable levels. Skip printing to the console as temporary workaround until the printing thr= eads and atomic consoles have been introduced or another solution which is compatible with the PREEMPT_RT approach. With this change, the user will not see any kernel message printed to the console but can retrieve the printk buffer from userland (via the dmesg command). This allows enable PREEMPT_RT as a whole without disabling printk= and loosing all kernel output. Disable console printing on PREEMPT_RT. Signed-off-by: Sebastian Andrzej Siewior --- v2=E2=80=A6v3: - Reword commit message by adding a few details/ explanations. v1=E2=80=A6v2: - Use __console_unlock() as suggested by John. kernel/printk/printk.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2843,6 +2843,16 @@ void console_unlock(void) } =20 /* + * On PREEMPT_RT it is not possible to invoke console drivers with + * disabled interrupts and or preemption. Therefore all drivers are + * skipped and the output can be retrieved from the buffer. + */ + if (IS_ENABLED(CONFIG_PREEMPT_RT)) { + __console_unlock(); + return; + } + + /* * Console drivers are called with interrupts disabled, so * @console_may_schedule should be cleared before; however, we may * end up dumping a lot of lines, for example, if called from