Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp168022rdb; Thu, 8 Feb 2024 02:20:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjpveSTp2bu8TYDDKmBCTuOJS+sRWiVHnPHvJdLCBcEU2E20UXVFUXD5dV9C3/HQDJ14AJ X-Received: by 2002:a05:6a00:b82:b0:6e0:51cf:8a01 with SMTP id g2-20020a056a000b8200b006e051cf8a01mr6774468pfj.6.1707387639221; Thu, 08 Feb 2024 02:20:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707387639; cv=pass; d=google.com; s=arc-20160816; b=DqRFc9lniP7VXIdonOMgzDU8j0W0EzsCGDtEAVivuDNFIdxmIvhpR7IncqkfSB0mzU RrvxH3cLQODNnlK+jCqZMtpT8myymy31CFGyH8G/Safn0xDn3COdtYyk40nRcBsNRRqW kvqIZsIo1IVCXAXGlE3g/kbufHPAB9wQMGmmITFyFXAdJl4zqRSyDUNE6L2dbarEkgIn blwCTff1yWVSDrVFcJk06K9wa49nxGOdFiDMRrmQxJagdJkygu5WA9q0CfNmuQgeeQL1 ziZ5mLpFBatGWWpmKfFjw+gHbGP/7E8SoM+gN4QC49OxYMPadGEXPQc0laTGooW8c7iu HM4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=B7XuXgv+DNsdiKrdT48zgIwhcbZVfMfgfa5zhzqcj2s=; fh=ultgYvJL4XpY+A2UhLheVcqiPVK3i4T7L97lhaKOUZ8=; b=hHZvUPrs1howUMv6Kse5TX/zZuLWMXSYoVr5pyL5zexjEMoE3S15gzjzcp0C9NZ36H q9kSz4gw3lGr9RsbOA8kmk5OooSwSTTot5hw7gLnl3xSy35Pt8OJvb7aeL8lsyqkAis+ /rU+tuW4pNnKa+UdLvLipzpzw8NI8OtnAVxAiLDNG6UhLiGSzOvaJhuEKbKAWucELG3q TywiXxSvdyOeaT3emtzhq/JMwiudiqV8nz8IaAAMNbMKJPRAmuoGRzAeOnSUbFTHhWYE 8YgAHfdFbIArUm/ceInxV4K0pDkvOl1etLp34IgzrhPQUT2Kr8UEOvAUbc9kbFLP4a40 K/0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=C76K69iN; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-57833-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57833-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org X-Forwarded-Encrypted: i=2; AJvYcCX3cngUB4buLX6xFQOvGclbwSOyUcdJiVGYvkkgG11PItL3qas6T2u44Uh1gt1ChsSbVy4MHiDGYVhFiRiotIPrWBpYvXCgUTM4wt4eQg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a19-20020aa78653000000b006e0379f3935si3646982pfo.261.2024.02.08.02.20.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 02:20:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57833-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=C76K69iN; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-57833-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57833-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 607AE28CC27 for ; Thu, 8 Feb 2024 10:18:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 997846D1A2; Thu, 8 Feb 2024 10:18:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="C76K69iN" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1D536BFC2; Thu, 8 Feb 2024 10:18:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707387518; cv=none; b=RExouByf9IVe7f3andPuMgQJBbTVFKQtoAUGMxW0MaAXq3MCeqGwEfMdnk1/I6CKFVKOsOoKvO9F+oKfzcYSwm+FIraBCqJUAIE3o+MWKM0vjM74uWhHiHbBRdUQFFlEK45rARwk4QpFGIdik46TiUtMxOUKJxnNkyhlQEGk/T8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707387518; c=relaxed/simple; bh=uhvalGSkL3ej/pnChIRBm8dpvY069eIscLpqr/mfNjM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hJMnAbWFv+6h8QP/6uXjVKD4K4WvEouVBqTmdUjgPdSTttE4mPYJDGNo73vdhC2PYD5KE8cqbnCO9+004Yp27r2kDFIHBvK5Wj1hhXnr5gmREiQiQZUmJCAwHvysPvWlG+fm6o2uinOush8HbEidWq3uAE1KLBFh1FWJ3p/oD2Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=C76K69iN; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88635C433F1; Thu, 8 Feb 2024 10:18:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1707387518; bh=uhvalGSkL3ej/pnChIRBm8dpvY069eIscLpqr/mfNjM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=C76K69iNT1RPa3juo5uWTFrboEuHrqgEw71QgP8AG9z6A+XLj9N8CsuxN+ouMcMFl emRZGF8bxvsvczRwYW7qd8intl0G2z9uYZgSi5Qgv85epKaWTQ6IBI3ERkVWXbXvrb 1drZVUAoJjI1k466fauUMSU0TM8IQaH8vtVHFVXc= Date: Thu, 8 Feb 2024 10:18:35 +0000 From: Greg KH To: Petr Mladek Cc: Sreenath Vijayan , john.ogness@linutronix.de, corbet@lwn.net, jirislaby@kernel.org, rdunlap@infradead.org, rostedt@goodmis.org, senozhatsky@chromium.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, taichi.shimoyashiki@sony.com, daniel.palmer@sony.com, anandakumar.balasubramaniam@sony.com Subject: Re: [PATCH v4 2/2] tty/sysrq: Dump printk ring buffer messages via sysrq Message-ID: <2024020845-antiquely-faculty-407d@gregkh> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Feb 07, 2024 at 04:09:34PM +0100, Petr Mladek wrote: > On Thu 2024-02-01 13:12:41, Sreenath Vijayan wrote: > > When terminal is unresponsive, one cannot use dmesg to view printk > > ring buffer messages. Also, syslog services may be disabled, > > to check the messages after a reboot, especially on embedded systems. > > In this scenario, dump the printk ring buffer messages via sysrq > > by pressing sysrq+D. > > I would use sysrq-R and say that it replays the kernel log on > consoles. > > The word "dump" is ambiguous. People might thing that it calls > dmesg dumpers. > > Also the messages would be shown on the terminal only when > console_loglevel is set to show all messages. This is done > in __handle_sysrq(). But it is not done in the workqueue > context. > > Finally, the commit message should explain why workqueues are used > and what are the limitations. Something like: > > > The log is replayed using workqueues. The reason is that it has to > be done a safe way (in compare with panic context). > > This also means that the sysrq won't have the desired effect > when the system is in so bad state that workqueues do not > make any progress. > > > Another reason might be that we do not want to do it in > an interrupt context. But this reason is questionable. > Many other sysrq commands do a complicate work and > print many messages as well. > > Another reason is that the function need to use console_lock() > which can't be called in IRQ context. Maybe, we should use > console_trylock() instead. > > The function would replay the messages only when console_trylock() > succeeds. Users could repeat the sysrq when it fails. > > Idea: > > Using console_trylock() actually might be more reliable than > workqueues. console_trylock() might fail repeatably when: > > + the console_lock() owner is stuck. But workqueues would fail > in this case as well. > > + there is a flood of messages. In this case, replaying > the log would not help much. > > Another advantage is that the consoles would be flushed > in sysrq context with the manipulated console_loglevel. I just remembered all the rt-changes coming down the pipe for consoles/printk, is this going to mess with that? And in thinking about it, the workqueue is a worry, sysrq is only usually hit if you have a lockup, and this isn't going to work well here, if at all, in that situation. So when this option fails when people need it the most, perhaps it's not worth adding? When else would people want to use it? thanks, greg k-h