Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp555125rwb; Thu, 27 Jul 2023 17:48:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlHKztwZ7AKtZlqvgOYR7RzkVf6lmR+2ZRAR4QNr3Qi+wlf/hl53aYxFG6n5xvmucflaSMjo X-Received: by 2002:a05:620a:d82:b0:75b:23a0:d9dc with SMTP id q2-20020a05620a0d8200b0075b23a0d9dcmr1014683qkl.50.1690505304174; Thu, 27 Jul 2023 17:48:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690505304; cv=none; d=google.com; s=arc-20160816; b=Lp4V7ytia8twVggYFv2h0d/KiORprxdkApQU5M32bVKQZePsyzBkMCFXXTig6+7B2i By45YS8nEiTbFq5AcwHlV1pYXzgp+um47biet+hPSCcKaiJN8GORcbKKIAHn7UAFVBXm Xm0bmX/OSW+1rzlqsE47++ZCBzshWOwc/oEUv15ClnRkKLY39A9+9+RWRwLQQrWhjAWj zi8e8RdCnJ/8YQOvhOl3etlGmVtmMptrR3RVTlA+tSz83xqADIv1nd1+F0/+QUxgEEUO JcFUSeLk4Iu60JrAompMSUaqC31nNIRVYJq1WPn3SIf3nrigUEStEn341ywTKCV/8klS B/yg== 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.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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cm5-20020a056a00338500b0067d204bf281si2064825pfb.3.2023.07.27.17.47.48; Thu, 27 Jul 2023 17:48:24 -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.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 S231230AbjG1ACm (ORCPT + 99 others); Thu, 27 Jul 2023 20:02:42 -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 ); 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 ; Thu, 27 Jul 2023 17:02:39 -0700 (PDT) From: John Ogness 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 Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- kernel/printk/printk_nbcon.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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 -- 2.39.2