Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp279006imi; Wed, 20 Jul 2022 23:57:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uX/O79UUEE/GXpkSLTLA28mwAx8mWxfaiLp395njMKIyh+jX+Pt+t0oNVHagWZed1Vcjg8 X-Received: by 2002:a17:902:ef48:b0:16a:1d4b:22ca with SMTP id e8-20020a170902ef4800b0016a1d4b22camr42121257plx.6.1658386650119; Wed, 20 Jul 2022 23:57:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658386650; cv=none; d=google.com; s=arc-20160816; b=hWbSOzp/SKpdTn1fJALtHMmZlWZiBHsjvtkgci3RSDIYMjEAeLvewepJx2SykBSWtT WmUN/0BxxxZGzIBXNcXbY0pP6cvaLKZws/FNbMVS4PVqIMwx3iiRix9ZOOKDx9tN8PFH NTccd9uVZhbbF+ZiuYaxPnUTkz27w6qNQATq2WiFEWg82Qg6qkpbazNKUAFjRHbwCBJe I56jNGqkflqqwWYnlnNHau2FZ5rmB5CH4bKznaCk6A5rwYs8r+mPl7Gg2gXxZGwBPfFW fHLUfTqUsu9ezWmgFJU9TmN5k3nKu3tRm7tBAl5U4VGHVNrJ6rvhbK/oX/9R71Y2fiTt VcNQ== 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=wPAOjeZDV8PQ0JIHQbcC+MvRzPwsrJZD80FwPieDSug=; b=omVTQtzERAY+qAUMUyKPeZHmB7xdYsu7pk5M2b5j1sC5It9IJ1G0xvhOnSvI7IvVd9 6GE6syYEy2mF0PM3gKaFSE16DakBobQ77TcgOJbzP4xzxYE3V0bO9mSkKqYsph24aL+6 SmwWiR+JxuOt5BdfVif81Yi79E4a2oIVFjlu4EnDKyO/EPgf46F4lh6d5K3bN6LHsXxR HGtJGvCsppV3XyswM+OOODl0x2tKFN/pBg21Rykw8xq66HDy2rFHFkCS2MEzfv8H6RMJ k8SScpEVBwdcz+mEcmLy4gOAWSw3U9IR9irFc+3X6mVaxwly4Ch4MlYdNDOkfwLqoWtk l7eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=l5EyobWa; dkim=neutral (no key) header.i=@linutronix.de; 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 a10-20020a170902ecca00b0016c049ada3csi1478928plh.454.2022.07.20.23.57.15; Wed, 20 Jul 2022 23:57:30 -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=l5EyobWa; dkim=neutral (no key) header.i=@linutronix.de; 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 S231640AbiGUGup (ORCPT + 99 others); Thu, 21 Jul 2022 02:50:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbiGUGuo (ORCPT ); Thu, 21 Jul 2022 02:50:44 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9386242ADA for ; Wed, 20 Jul 2022 23:50:43 -0700 (PDT) Date: Thu, 21 Jul 2022 08:50:38 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1658386240; 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=wPAOjeZDV8PQ0JIHQbcC+MvRzPwsrJZD80FwPieDSug=; b=l5EyobWaZSf2DM369jADlWsHiS7CgvjJ82mgiui7AoqXhzuCyxKpgpIUSzyHxw5f1L3QJR hPEjA5p2SQX+0zK1CSv/xVrKNkw2TCDpvvfyzOdGiOyEeQyu4id+5jNWEJMEEoDdX8zgx/ i+TUfW6g72lztuiHvOom2vEurfww51IR+FNXtlYT09lrkgG8Nt7qVREzZ07M3bxrLSgvUa EhTpDLYCbPU4BEOVeQp7PbPP1QFzvYvSAbQYvU887frMIdy5XM1QUA5GG9OV3VzqcFG00r PHrmBUNvzwGlWZq9MpBr8K7OMDl3uSAMfNMcHEDdmvpQzlWv//vq6Ief9D9OGg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1658386240; 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=wPAOjeZDV8PQ0JIHQbcC+MvRzPwsrJZD80FwPieDSug=; b=uw25/yj+CujdL2XiVlEpChMMWvTFNZd8FAowpYqzv8/3G1WQtWpz+exLueFWXMQYqJLLw8 0hIQ/XXWuD+vdEDg== From: Sebastian Andrzej Siewior To: John Ogness Cc: linux-kernel@vger.kernel.org, Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner Subject: [PATCH v2] 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: <87ilnrn06u.fsf@jogness.linutronix.de> 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 is behaviour is not compatible with PREEMPT_RT. Disable console printing until the return of atomic consoles and the printing thread. This allows to retrieve the log buffer from user space which is not possible by disable printk. Signed-off-by: Sebastian Andrzej Siewior --- 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