Message ID | 20230728000233.50887-3-john.ogness@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp88173vqg; Thu, 27 Jul 2023 17:06:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlHEzqwjzr1JLPqz0xY1HC+ASFl+6wG1adpFEwUO+RT/KzmgtJp6fZxowXVpMvdgsUt2MCKH X-Received: by 2002:a05:6512:3b13:b0:4fe:df2:b82d with SMTP id f19-20020a0565123b1300b004fe0df2b82dmr604479lfv.37.1690502803787; Thu, 27 Jul 2023 17:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690502803; cv=none; d=google.com; s=arc-20160816; b=xL8MTe9OVVUQW+cW6sUI0ek34Z+wVA6ieSTRnLhh2mPbxNorJ/mcXriFR1/Hb6LwL8 AaUQXJUVmU7wJAvnir/Ogvg4w1O7NckIkeaITOgjWH6uTQRx5UHoTYz2Dgxst1g3Dr9Q FaqQGNkXWGSQ24YpoVoMYDAxHmNxRYSisyToWnl14DJpAT4gFZQujwrVsLUEQlHHLkNH TY7gw1Y4TKnO0ZwnTpqFQ7E1I4V5Odt8DYA4QWeyvHdvOxuvocouykzFl3H9OXmX0mSi PF3rhXonZGf8xOx+1uItBxgUY2C3/oSDlzuA6hyPwURPp/hGA/KbWgM0mwu5hzMCo7hX GFeA== 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=aN/PZD88PlKxnnAWKpPNKfderKHCjvFqWgQcXb3T0GI=; fh=HVRBJStvoKWbFco6Jta18xe5UAVCwWVs9OvJstciom4=; b=g8xArTpqu1lNREH4h9fhR289FweL0/+fB/xIpZArEjUZQPm4A3GOvxVzidGGJBLw01 0CZC7JLdtRYrizNK8jVqTeiRpZ+UCNvPyaFI5CFQmTagO0ffwqn+TKEsDJo48lzIwolC 0PoIDFr+cyOfDJWiCanep/8ONtrY7JzsYucEYMDBkaGnJpjHmWRaSvR/9Ej52IfutMi7 JTsBkKZQF8PII9hN3wlWgW9IBmJG8Y5dZ7AGoU10TCpAfaND+B0H7+L6Na8iWreafsUO PuzCLWYoE1GOWVKhuWTSi51LHssGv4OsmLfeb/htejyibhsZAs1bnNnK0OjadheFdWvV 9MsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JdVIc2tn; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=zyrFz+Na; 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 jo16-20020a170906f6d000b0099bd6fbd6b9si1805696ejb.433.2023.07.27.17.06.20; Thu, 27 Jul 2023 17:06:43 -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=JdVIc2tn; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=zyrFz+Na; 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 S231236AbjG1ACn (ORCPT <rfc822;hanasaki@gmail.com> + 99 others); Thu, 27 Jul 2023 20:02:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbjG1ACl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 27 Jul 2023 20:02:41 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6A2F30FA for <linux-kernel@vger.kernel.org>; Thu, 27 Jul 2023 17:02:39 -0700 (PDT) From: John Ogness <john.ogness@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1690502557; 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=aN/PZD88PlKxnnAWKpPNKfderKHCjvFqWgQcXb3T0GI=; b=JdVIc2tnGLddF4guSyv+W1fRWkdVCzJxI3lOUsfk5IO3LFAb/v2SVjWVzw7JGpk4hkEbgR YMxEkV4bEiy2n9gKVKEyALgwLEEjaI6ldWVsfX/vp0OMn44s5uXmlukHcvmimI0yAIw+JN wyXxDa8PwCD5Nie2M85cJLQ9EavtaAVrCxMjQXd6z3k+LOP0EcA8r38BlZVecCk60uKxJu 6jJMiLjQNV1T9gGOSbzoT+wQEh4bJe+6h08Z9lqMp0Os/+nHuH6C4Iz3rvbasLuHnE8Tnv oa3GZq8kiwOoaBRWMtQzYqbYq8V1Fcumb29YD8y1mIPed5oUcZxma6SUZz4nJQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1690502557; 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=aN/PZD88PlKxnnAWKpPNKfderKHCjvFqWgQcXb3T0GI=; b=zyrFz+NafiJs7zKAN8tZTy+t4GuTNq+lbyyRYH2GMWuzRAMbvkORDmdJiXI2PriwTnEa1z zyqU+VlP3PRz4yBA== 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 Subject: [PATCH printk v2 2/8] printk: Provide debug_store() for nbcon debugging Date: Fri, 28 Jul 2023 02:08:27 +0206 Message-Id: <20230728000233.50887-3-john.ogness@linutronix.de> In-Reply-To: <20230728000233.50887-1-john.ogness@linutronix.de> References: <20230728000233.50887-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,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1772620667685057343 X-GMAIL-MSGID: 1772620667685057343 |
Series |
wire up nbcon consoles
|
|
Commit Message
John Ogness
July 28, 2023, 12:02 a.m. UTC
To debug and validate nbcon ownership transitions, provide a new
macro debug_store() (enabled with DEBUG_NBCON) to log transition
information to the ringbuffer. If enabled, this macro only logs
to the ringbuffer and does not trigger any printing. This is to
avoid triggering recursive printing in the nbcon consoles.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
kernel/printk/printk_nbcon.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
Comments
On 2023-07-28, John Ogness <john.ogness@linutronix.de> wrote: > +/* > + * Define DEBUG_NBCON to allow for nbcon ownership transitions to be logged > + * to the ringbuffer. The debug_store() macro only logs to the lockless > + * ringbuffer and does not trigger any printing. > + */ > +#undef DEBUG_NBCON > + > +#ifdef DEBUG_NBCON > +/* Only write to ringbuffer. */ > +int __debug_store(const char *fmt, ...) > +{ > + va_list args; > + int r; > + > + va_start(args, fmt); > + r = vprintk_store(2, 7, NULL, fmt, args); > + va_end(args); > + > + return r; > +} > +#define debug_store(cond, fmt, ...) \ > + do { \ > + if (cond) \ > + __debug_store(pr_fmt("DEBUG: " fmt), ##__VA_ARGS__) \ Missing a semi-colon here. Wrapping this with a do-while was a last-minute change requested by checkpatch.pl. Probably nobody would notice because you must manually define DEBUG_NBCON by changing the source code. Fixed for v3 (assuming Petr allows me to keep this debugging code in place). > + } while (0) > +#else > +#define debug_store(cond, fmt, ...) > +#endif John
On Fri 2023-07-28 02:08:27, John Ogness wrote: > To debug and validate nbcon ownership transitions, provide a new > macro debug_store() (enabled with DEBUG_NBCON) to log transition > information to the ringbuffer. If enabled, this macro only logs > to the ringbuffer and does not trigger any printing. This is to > avoid triggering recursive printing in the nbcon consoles. > > --- a/kernel/printk/printk_nbcon.c > +++ b/kernel/printk/printk_nbcon.c > @@ -10,6 +10,35 @@ > * the legacy style console_lock mechanism. > */ > > +/* > + * Define DEBUG_NBCON to allow for nbcon ownership transitions to be logged > + * to the ringbuffer. The debug_store() macro only logs to the lockless > + * ringbuffer and does not trigger any printing. > + */ > +#undef DEBUG_NBCON > + > +#ifdef DEBUG_NBCON > +/* Only write to ringbuffer. */ > +int __debug_store(const char *fmt, ...) > +{ > + va_list args; > + int r; > + > + va_start(args, fmt); > + r = vprintk_store(2, 7, NULL, fmt, args); I have never used the facility number before. It seems that they are defined in /usr/include/sys/syslog.h, for example, see https://sites.uclouvain.be/SystInfo/usr/include/sys/syslog.h.html They are even somehow documented in "man 3 syslog", for example, see https://linux.die.net/man/3/syslog We should probably use one of the LOG_LOCALX numbers, e.g. #define LOG_LOCAL0 (16<<3) Also, please use LOGLEVEL_DEBUG instead of the hard coded "7". > + va_end(args); > + > + return r; > +} > +#define debug_store(cond, fmt, ...) \ > + do { \ > + if (cond) \ > + __debug_store(pr_fmt("DEBUG: " fmt), ##__VA_ARGS__) \ > + } while (0) > +#else > +#define debug_store(cond, fmt, ...) > +#endif > + > /** > * nbcon_state_set - Helper function to set the console state > * @con: Console to update Best Regards, Petr
On 2023-07-28, Petr Mladek <pmladek@suse.com> wrote: >> + r = vprintk_store(2, 7, NULL, fmt, args); > > We should probably use one of the LOG_LOCALX numbers, e.g. > > #define LOG_LOCAL0 (16<<3) > > Also, please use LOGLEVEL_DEBUG instead of the hard coded "7". OK. I am also open to dropping the function and its use. When developing the ringbuffer I also had a similar function but never attempted to publish it. It is useful for developing/testing/debugging, but once everything works as it should it has no real purpose. I have no problems keeping the debug stuff hidden in my own private toolbox. John
On Fri 2023-07-28 23:07:08, John Ogness wrote: > On 2023-07-28, Petr Mladek <pmladek@suse.com> wrote: > >> + r = vprintk_store(2, 7, NULL, fmt, args); > > > > We should probably use one of the LOG_LOCALX numbers, e.g. > > > > #define LOG_LOCAL0 (16<<3) > > > > Also, please use LOGLEVEL_DEBUG instead of the hard coded "7". > > OK. > > I am also open to dropping the function and its use. When developing the > ringbuffer I also had a similar function but never attempted to publish > it. It is useful for developing/testing/debugging, but once everything > works as it should it has no real purpose. I have no problems keeping > the debug stuff hidden in my own private toolbox. I do not mind to add this patch. It is actually pretty interesting function. I wonder if it might inspire anyone for using this approach for some other reasons. Best Regards, Petr
diff --git a/kernel/printk/printk_nbcon.c b/kernel/printk/printk_nbcon.c index bb379a4f6263..f9462b088439 100644 --- a/kernel/printk/printk_nbcon.c +++ b/kernel/printk/printk_nbcon.c @@ -10,6 +10,35 @@ * the legacy style console_lock mechanism. */ +/* + * Define DEBUG_NBCON to allow for nbcon ownership transitions to be logged + * to the ringbuffer. The debug_store() macro only logs to the lockless + * ringbuffer and does not trigger any printing. + */ +#undef DEBUG_NBCON + +#ifdef DEBUG_NBCON +/* Only write to ringbuffer. */ +int __debug_store(const char *fmt, ...) +{ + va_list args; + int r; + + va_start(args, fmt); + r = vprintk_store(2, 7, NULL, fmt, args); + va_end(args); + + return r; +} +#define debug_store(cond, fmt, ...) \ + do { \ + if (cond) \ + __debug_store(pr_fmt("DEBUG: " fmt), ##__VA_ARGS__) \ + } while (0) +#else +#define debug_store(cond, fmt, ...) +#endif + /** * nbcon_state_set - Helper function to set the console state * @con: Console to update