From patchwork Wed Nov 23 23:13:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 25237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3079491wrr; Wed, 23 Nov 2022 15:14:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf7pp+i+OFh73cH48Qya9w1l0biq7KPeCWFrnFgat0J/oRdKlBwqc4GbY18F15Tf/bdoTQOa X-Received: by 2002:a17:906:a983:b0:7b8:31b1:b23f with SMTP id jr3-20020a170906a98300b007b831b1b23fmr9060096ejb.591.1669245296061; Wed, 23 Nov 2022 15:14:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669245296; cv=none; d=google.com; s=arc-20160816; b=Gxb2UWI1ZymwvVQCXUnSf6BkxhYREWuoqwnuq4tlfrhyJw/JDK+aOcOBkJoYRRVKl0 qAxbI+sB9kmqnt+ztR/NwSwfDNW0VjzM7WZzkQmzsLXKPenQg53zZOn9j7waeBaDv2HA 6oqXKwEGdqPNbYkFpTAKaNeRsASNX7Q0BFkz0j6VZOwFPd2ZcTMlIeGIedfonfI0RhA7 PRvKQtTydA3UYwRskzi98vkPLqVYlGIJHS0B5QDSsrssN80BmVx+P9KE+B/qhPYes9tk psz5tGgSn8ZLUury64W2AyMR/mjSZhvuTFYrveBzUDjO2Fm0lESAXqhpB6XqmnxoMGXd TMHw== 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=/iaK6Q3VBEVIk95GUMPiu3drrm6jETQodWaJtL9sezc=; b=tN2A7lDC8RkUaMyYVV7S0Agj1w+1iFX2bdWOPLN+g4ubhOnO72Ew6TOdppaPVK2n7g r2QL3pDr78qWeCyW0mXWRLuW/bfsEYtF/p/c+t0KL5/BwURce/an0sWH65PGQNzWAixo /MkeE83KqkJYkl6le/+pe3RVQSHDRj4U16lJbbcYH1k0dYZxLX0Tyr2Ho7Qfajj2HbK/ 8hiVla5mAllJzbIvWQrapqJiH91TAAkc4HGCf02Y3dqx/AkxDTTkiiSY+cosjTAuJSR5 +eogIn2kn3fob2RLIHaYeFvTSYZdhxx1u6WFXFa5jld/Ju+sMrt6IqVgXYhKVpJWho4r kDAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RPvCHbze; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=69B7EmoO; 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 m11-20020a170906258b00b0078adad5930esi12079233ejb.255.2022.11.23.15.14.32; Wed, 23 Nov 2022 15:14:56 -0800 (PST) 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=RPvCHbze; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=69B7EmoO; 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 S229720AbiKWXOQ (ORCPT + 99 others); Wed, 23 Nov 2022 18:14:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbiKWXON (ORCPT ); Wed, 23 Nov 2022 18:14:13 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48BB49B3B0 for ; Wed, 23 Nov 2022 15:14:12 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669245250; 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=/iaK6Q3VBEVIk95GUMPiu3drrm6jETQodWaJtL9sezc=; b=RPvCHbzeTnVF+1dfTWNpp1u2Ja4oUusnLtx0+NH6sMCxYoOR02JlqMlu3LV9oTETqz4j9n t9Wc/t26f4+a2isGNtBY6ZtXYv9rwvZifPRr+uPZTZ/t7tdUF6eIBaLN6S51VLoT14la88 0LplEnL7XKetw/yLNGMg2E5S/M+D2wzXpJucFLxf2w5ma2O2O2DcP1j+NpSWc7I4+q8TXJ NXs2eeNoeJnOYk23Gj56igQeMgwz4zJlv9LW5qk33hmFyG18sYzE0NYjS+/w1X13Z3SWZ4 76uWOnvJA2OcNSdqvW1ig1eiOkLmFlIHsEm2ym5SwmtL1R9J+L5cMliwc7i19A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669245250; 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=/iaK6Q3VBEVIk95GUMPiu3drrm6jETQodWaJtL9sezc=; b=69B7EmoOEwgiqYg29s+3eHdc8AjiAjVWVTXwWTObH4kfEJ8gT1qdFR7VycoxkUJPky/uGu ADMt+2TjjCRTz7DQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH printk v2 1/7] printk: Move buffer size defines Date: Thu, 24 Nov 2022 00:19:54 +0106 Message-Id: <20221123231400.614679-2-john.ogness@linutronix.de> In-Reply-To: <20221123231400.614679-1-john.ogness@linutronix.de> References: <20221123231400.614679-1-john.ogness@linutronix.de> MIME-Version: 1.0 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750330555439641824?= X-GMAIL-MSGID: =?utf-8?q?1750330555439641824?= From: Thomas Gleixner Move the buffer size defines to console.h in preparation of adding a buffer structure. The new buffer structure will be embedded within struct console. Therefore console.h was chosen as the new home for these defines. Signed-off-by: Thomas Gleixner Signed-off-by: John Ogness --- include/linux/console.h | 14 ++++++++++++++ include/linux/printk.h | 2 -- kernel/printk/printk.c | 4 ---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/linux/console.h b/include/linux/console.h index 9cea254b34b8..799fc3216aad 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -122,6 +122,20 @@ static inline int con_debug_leave(void) #define CM_ERASE (2) #define CM_MOVE (3) +#ifdef CONFIG_PRINTK + +/* The maximum size of a formatted record (i.e. with prefix added per line) */ +#define CONSOLE_LOG_MAX 1024 + +#else + +#define CONSOLE_LOG_MAX 0 + +#endif + +/* The maximum size of a formatted extended record */ +#define CONSOLE_EXT_LOG_MAX 8192 + /* * The interface for a console, or any other device that wants to capture * console messages (printer driver?) diff --git a/include/linux/printk.h b/include/linux/printk.h index 8c81806c2e99..8ef499ab3c1e 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -44,8 +44,6 @@ static inline const char *printk_skip_headers(const char *buffer) return buffer; } -#define CONSOLE_EXT_LOG_MAX 8192 - /* printk's without a loglevel use this.. */ #define MESSAGE_LOGLEVEL_DEFAULT CONFIG_MESSAGE_LOGLEVEL_DEFAULT diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 9ec101766471..a4854a60e6d8 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -471,9 +471,6 @@ static struct latched_seq clear_seq = { #define PREFIX_MAX 32 #endif -/* the maximum size of a formatted record (i.e. with prefix added per line) */ -#define CONSOLE_LOG_MAX 1024 - /* the maximum size for a dropped text message */ #define DROPPED_TEXT_MAX 64 @@ -2387,7 +2384,6 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre #else /* CONFIG_PRINTK */ -#define CONSOLE_LOG_MAX 0 #define DROPPED_TEXT_MAX 0 #define printk_time false From patchwork Wed Nov 23 23:13:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 25238 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3079588wrr; Wed, 23 Nov 2022 15:15:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf7K82oRD+R/yvVgoQezTVZdi+03EeWfBQqI9/kshsjhM5BnO5ce+/oKn7xw1DS+j82AK61J X-Received: by 2002:a17:906:3fce:b0:7ad:bb54:75d3 with SMTP id k14-20020a1709063fce00b007adbb5475d3mr25196118ejj.484.1669245307898; Wed, 23 Nov 2022 15:15:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669245307; cv=none; d=google.com; s=arc-20160816; b=uQsxOycUzpdAGr5RmRkXP6NoIc+XyGldgs5QymadLD/DEZarjZkUL0MkG0obUsJagP LubGpGNZJwvdBbb+sJbL/gO9wF9sX3jD8/3iwcCozzSWdq3pr7q3nuwHXeSHLgPnHzNa qBsj517UEbpFCaJqeyBzvt7Lx8y0QfpoOSRsMsjzUpymj65qPG8yRWZnVwl4BoZddE1N NsCbvm3WyHU0D8K5GBnyxwbFvVfvaxtjXAlUwku/8Eh6xlpZv3rrvT+In45ZbhLioSLL jAcq/iHd44OFYGYT35MD5fdlbznWNGdZQTv86JqpDNSTqxPtzFFYQdZkcoD/giKoj448 vTBg== 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=F3opJ7HlbeLq3ffu10RUcIJy4CWkVQ7ilUuqExGzyjQ=; b=CjU/ftidSzGavjeL4/YcpSiIyMuuItXor66iWpehbjbEgQ+qBqYRnP0/Wf9r8Su3YU Q2AE3w1MuZcQphstGnZ33u2F2QJaxy8mv8uXeXgCtj6HQJcvdE53Ao1+gxw9G5/Zk4Pt laWudDT8m4nsbsXpiCW0YU+MPM94Cu3Kq/odF/cnhhwU5AEiB+2+BPssgxQoenFsN95L f3jeD3y/EZ/KPmiyuTDBYTM5Qj4QBocz4tKWftBVOimahQmjOmwb4rKwimXi4Jou5LbE l7g3c8fyqgXtvN2eFmC1DTachOu5W206hGUo6e/BxUzLXH6LIcvSTgiGWz3xy6vNovOu V00A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=dqKa6Wr1; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a170906a18b00b007adf6f0f962si12799023ejy.291.2022.11.23.15.14.43; Wed, 23 Nov 2022 15:15:07 -0800 (PST) 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=dqKa6Wr1; 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 S229810AbiKWXOX (ORCPT + 99 others); Wed, 23 Nov 2022 18:14:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229607AbiKWXOO (ORCPT ); Wed, 23 Nov 2022 18:14:14 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E2F0B8572 for ; Wed, 23 Nov 2022 15:14:13 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669245251; 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=F3opJ7HlbeLq3ffu10RUcIJy4CWkVQ7ilUuqExGzyjQ=; b=dqKa6Wr1Wdtr4Pf6qxKwBGE8yTiS7HowAJnEYkCsZBht7qIyYlU5t6DYmzm13I2y+RtbTV GQmYX/78A+otM0IMGWAFs+Y5Yzio/l6x2vEFdNBI5LS6YHUYLcaYyphjdnirY4nnEkW9uI XtGAsuz649cQinBcrr2jDcHqvLZSF+nLyDRCRE3J57uru/WsBNw8CLF2dRVCuxh30J9ojw g9LEF8wT0kdeROQt6PLP47saUTwI24kWk8sx2xRXnHWkD9K5TQpbDMEzysrC8DcD6Zv491 EZ/gDsWJRgHC6y0TL9wTL9WZa8XdioUUiR6bAklSK4lHnKwJ1xb6QN5FiF3gww== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669245251; 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=F3opJ7HlbeLq3ffu10RUcIJy4CWkVQ7ilUuqExGzyjQ=; b=W1ydZ2KGZJWegCfX3wzYey2lDEjnY0PfPIF0wpO9cLHp6C/dqNGjtEdLsYkchSQ65Qk7t2 lwhG+M7/4iWYbFDg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH printk v2 2/7] console: Use BIT() macros for @flags values Date: Thu, 24 Nov 2022 00:19:55 +0106 Message-Id: <20221123231400.614679-3-john.ogness@linutronix.de> In-Reply-To: <20221123231400.614679-1-john.ogness@linutronix.de> References: <20221123231400.614679-1-john.ogness@linutronix.de> MIME-Version: 1.0 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750330567893156721?= X-GMAIL-MSGID: =?utf-8?q?1750330567893156721?= From: Thomas Gleixner Rather than manually calculating powers of 2, use the BIT() macros. Also take this opportunatity to cleanup and restructure the value comments into proper kerneldoc comments. Signed-off-by: Thomas Gleixner Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- include/linux/console.h | 46 ++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/include/linux/console.h b/include/linux/console.h index 799fc3216aad..f7a14ea6bae0 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -15,6 +15,7 @@ #define _LINUX_CONSOLE_H_ 1 #include +#include #include #include @@ -139,18 +140,43 @@ static inline int con_debug_leave(void) /* * The interface for a console, or any other device that wants to capture * console messages (printer driver?) - * - * If a console driver is marked CON_BOOT then it will be auto-unregistered - * when the first real console is registered. This is for early-printk drivers. */ -#define CON_PRINTBUFFER (1) -#define CON_CONSDEV (2) /* Preferred console, /dev/console */ -#define CON_ENABLED (4) -#define CON_BOOT (8) -#define CON_ANYTIME (16) /* Safe to call when cpu is offline */ -#define CON_BRL (32) /* Used for a braille device */ -#define CON_EXTENDED (64) /* Use the extended output format a la /dev/kmsg */ +/** + * cons_flags - General console flags + * @CON_PRINTBUFFER: Used by newly registered consoles to avoid duplicate + * output of messages that were already shown by boot + * consoles or read by userspace via syslog() syscall. + * @CON_CONSDEV: Indicates that the console driver is backing + * /dev/console. + * @CON_ENABLED: Indicates if a console is allowed to print records. If + * false, the console also will not advance to later + * records. + * @CON_BOOT: Marks the console driver as early console driver which + * is used during boot before the real driver becomes + * available. It will be automatically unregistered + * when the real console driver is registered unless + * "keep_bootcon" parameter is used. + * @CON_ANYTIME: A misnomed historical flag which tells the core code + * that the legacy @console::write callback can be invoked + * on a CPU which is marked OFFLINE. That is misleading as + * it suggests that there is no contextual limit for + * invoking the callback. The original motivation was + * readiness of the per-CPU areas. + * @CON_BRL: Indicates a braille device which is exempt from + * receiving the printk spam for obvious reasons. + * @CON_EXTENDED: The console supports the extended output format of + * /dev/kmesg which requires a larger output buffer. + */ +enum cons_flags { + CON_PRINTBUFFER = BIT(0), + CON_CONSDEV = BIT(1), + CON_ENABLED = BIT(2), + CON_BOOT = BIT(3), + CON_ANYTIME = BIT(4), + CON_BRL = BIT(5), + CON_EXTENDED = BIT(6), +}; struct console { char name[16]; From patchwork Wed Nov 23 23:13:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 25239 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3080662wrr; Wed, 23 Nov 2022 15:17:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf48MgKeMu5DZB05PcqHGti/I3s5sRSmNKimGUrF7eNJ35Ul+x1uejDCOGAGn4SnJ7f/BS4K X-Received: by 2002:a05:6402:3226:b0:461:37c2:e85c with SMTP id g38-20020a056402322600b0046137c2e85cmr18771401eda.74.1669245438047; Wed, 23 Nov 2022 15:17:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669245438; cv=none; d=google.com; s=arc-20160816; b=tSeba6DhC8S1GZF1tYyTa5eqvvDgxXa+X90NWp7FSyoLaO/mxAQCxOZKJ3fTdNQHAv XrRop2D5+pwJjsp21JZQZwURuVYMnkQfttjH+l+lt5fich6YAbLGdN1uaJIFNBEgJwgL eyqLFOHCK/1bKqA3LH/wh9zCb2cd20npUKmMiJu3Y9KmFJg5Q1HwYBk2k95bzejPvdmK WOCf+7Cn2j4eTQDI8ADTBQLGW3pmPVOrXIvDbHw//vGiRLDYzmFOk9v00S7ZtODK1bC0 C7f4vVUBbnypK2FW9aSb3w6LQHD7arQeD79QuEPwyudR4GClLvVj9pscwDDadU90qSMK e17Q== 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=j15phA1lmvkZMkDgT4Ymay4UivTflRDgylXp+daG2hk=; b=m5m7ZPEgM7E4Hoy7X/xOlPxjjkX6FltrF7Z9EZyFGUsGB+JtmC1hdGoxudKYzeFJCa ZDZylAW4x22udaqLq/j2SVayR+6Tg1oH0FRpNxvAnLzB5+e8ZIIW1U9ix9m39ONlEgVh GPEotROx+9z2gk4gyBiltZkYVHyFE7jSt1AkfcqJ9b0O2RgJ48WWHZspo/5sFKBJPYO/ fyGNkua4kFTfKB8XPdJwWDK7PcjbyrLXPqx6Tv1TepH+G5ztDcND0mtynndBo8xvbsk+ ZDGo8G0f1QDCJvAJ3fGP3TFQ+d8SaO5cFpUWJheFGLZjtkFeEgTIh0xfJLjjkN2TxJZL c75A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tC75imPv; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=HjI+6lRU; 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 dp17-20020a170906c15100b00791a41d1b39si16807901ejc.656.2022.11.23.15.16.53; Wed, 23 Nov 2022 15:17:18 -0800 (PST) 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=tC75imPv; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=HjI+6lRU; 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 S229842AbiKWXO1 (ORCPT + 99 others); Wed, 23 Nov 2022 18:14:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229700AbiKWXOP (ORCPT ); Wed, 23 Nov 2022 18:14:15 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 652D9BCDF1 for ; Wed, 23 Nov 2022 15:14:14 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669245252; 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=j15phA1lmvkZMkDgT4Ymay4UivTflRDgylXp+daG2hk=; b=tC75imPv7KTPVlhTdENOrDnePftFnntPZqtOo7lXs8ITaY4oNHRqw1ZsSB5hamb6Bkb0gd 2zixhJ0bY3k88YMItL69goWwRxiL4CESyvF+ZytQQOa1BxxrQC1P5U1/dQ2LW++qbXgy4p htcVDjnh50BOPr4dOSv9hCzNjCIWA1Z5wY/0/tVjfbm+v6rehUDBoOBcrl+XSOypLI7hvU yMygGWWhxw5Do3Nq5gzqNgFZ4WFXwpombaPzhZIQkqo9LWY9lm3zm9gpuvqPRMyOdCwKqV FtLs0esGtSBhJurR5GSasRoXVcUm/o8hXLRTEZFPpJK8Ox/BgbhowIb51C6lVQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669245252; 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=j15phA1lmvkZMkDgT4Ymay4UivTflRDgylXp+daG2hk=; b=HjI+6lRUyAYxQIumILednEjKM+aPeEeewy5p9ga2fhkB5bUNDm/Q2UScBZniOqI6yz1ggy wAec0LLVJTqzfpCQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH printk v2 3/7] console: Document struct console Date: Thu, 24 Nov 2022 00:19:56 +0106 Message-Id: <20221123231400.614679-4-john.ogness@linutronix.de> In-Reply-To: <20221123231400.614679-1-john.ogness@linutronix.de> References: <20221123231400.614679-1-john.ogness@linutronix.de> MIME-Version: 1.0 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750330704423085181?= X-GMAIL-MSGID: =?utf-8?q?1750330704423085181?= From: Thomas Gleixner Add kerneldoc comments to struct console. Signed-off-by: Thomas Gleixner Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- include/linux/console.h | 54 ++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/include/linux/console.h b/include/linux/console.h index f7a14ea6bae0..b2cf256c23b6 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -178,24 +178,44 @@ enum cons_flags { CON_EXTENDED = BIT(6), }; +/** + * struct console - The console descriptor structure + * @name: The name of the console driver + * @write: Write callback to output messages (Optional) + * @read: Read callback for console input (Optional) + * @device: The underlying TTY device driver (Optional) + * @unblank: Callback to unblank the console (Optional) + * @setup: Callback for initializing the console (Optional) + * @exit: Callback for teardown of the console (Optional) + * @match: Callback for matching a console (Optional) + * @flags: Console flags. See enum cons_flags + * @index: Console index, e.g. port number + * @cflag: TTY control mode flags + * @ispeed: TTY input speed + * @ospeed: TTY output speed + * @seq: Sequence number of the next ringbuffer record to print + * @dropped: Number of dropped ringbuffer records + * @data: Driver private data + * @node: hlist node for the console list + */ struct console { - char name[16]; - void (*write)(struct console *, const char *, unsigned); - int (*read)(struct console *, char *, unsigned); - struct tty_driver *(*device)(struct console *, int *); - void (*unblank)(void); - int (*setup)(struct console *, char *); - int (*exit)(struct console *); - int (*match)(struct console *, char *name, int idx, char *options); - short flags; - short index; - int cflag; - uint ispeed; - uint ospeed; - u64 seq; - unsigned long dropped; - void *data; - struct hlist_node node; + char name[16]; + void (*write)(struct console *co, const char *s, unsigned int count); + int (*read)(struct console *co, char *s, unsigned int count); + struct tty_driver *(*device)(struct console *co, int *index); + void (*unblank)(void); + int (*setup)(struct console *co, char *options); + int (*exit)(struct console *co); + int (*match)(struct console *co, char *name, int idx, char *options); + short flags; + short index; + int cflag; + uint ispeed; + uint ospeed; + u64 seq; + unsigned long dropped; + void *data; + struct hlist_node node; }; #ifdef CONFIG_LOCKDEP From patchwork Wed Nov 23 23:13:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 25240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3081363wrr; Wed, 23 Nov 2022 15:18:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf54a14ytBAANfgfPn+D7cAZwOk+ovL1Uq/4ZF7hI0sbMIsCI+SkGIW4TZzeIKcD+nw0mCGa X-Received: by 2002:a05:6402:2070:b0:467:5e4f:591 with SMTP id bd16-20020a056402207000b004675e4f0591mr13202880edb.414.1669245524936; Wed, 23 Nov 2022 15:18:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669245524; cv=none; d=google.com; s=arc-20160816; b=qCeGmGJbjwrDaROtL42OZm/Xc3lRwU8nYZR6U4wGP2DHV0Ja4eR7cdLPG/wKu+UuSR tbX0VpI+s88uPkJt2FLbYnItfTwP0/4DgInA944wDU+S1+58JJuM2IUGmHCIvhxsPlzQ 7sf1WItYrBKYC661PnDjed8n7+0p1rvr0MhG3SqRTNaA2jQoWLTmjnbyM+efDeCNGcrt bcHo0Mfzbwq/f1u3C21rwlOWHNe6l7+LlWYL5x0AQKl3J14Bf0AyL+a+OIde8GgCis7J wWJ+aEntqmAsPHiYyd4DJykHHYOQs5BfyGQfuiYAIxZpXFTUmM8y8CHlAQVcdgmoc33k 5G7A== 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=aHekk7rHrVj5L5T/94RT0HyGLRna0DzwZs8ha+Ccyvw=; b=hejo9BOiV+tYa8RPTS8F55yY7rYy/auh3AwEInuA4+Ixv1cr/TXHtbYL3kQtyBhnuW nirS0imgALS4KJw8w34m+xuikr41qq/7IJh4+Igo9JlJtjl3M/P46U4c8U0nLeYtefh0 kGj4MZGoqvISFMeY5jTPY4R7IYqNEVzVMuQpcDyFO8A5FNgSjLb2qfvUhsDnXiEx9DXn l7gn39Qj2dbhBixJDbqvG/FLukoa5NfmmFi2Hjsr6JsdZ6rWj17dctQbCBRF0VQYJvWt gxePOGHGg8yamuexEo46n8fybblnUrcf0UxQHoWxpEWAw7Bn3UBh7oBYWqGxFS+6HxEP AcnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=rUgi9ajh; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=2GHZKoSr; 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 z6-20020a056402274600b004488842d88esi16425108edd.13.2022.11.23.15.18.21; Wed, 23 Nov 2022 15:18:44 -0800 (PST) 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=rUgi9ajh; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=2GHZKoSr; 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 S229884AbiKWXOb (ORCPT + 99 others); Wed, 23 Nov 2022 18:14:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbiKWXOQ (ORCPT ); Wed, 23 Nov 2022 18:14:16 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B7136BDEE for ; Wed, 23 Nov 2022 15:14:15 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669245253; 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=aHekk7rHrVj5L5T/94RT0HyGLRna0DzwZs8ha+Ccyvw=; b=rUgi9ajh583f3DafswGx6DnJgtX1nVcRAI0OyvdmARANW4/vl6t1tWVQkHydEMakuWWC11 USYMG+Gs8LFd4tcL6UReH+pZX4mBlHObcxMHf+AKL9UvcdGeq2e4uRKAyK3le2jXCfAyts n+ppQ+9SW7jvNmqXyvoh7/2iWz/RAsfVn06Qu+ag4MlIBbVKOFMMx4XUWSPL24cMJhemaG KDXxrR6MbH+huS7Ii4ul3e2XVCASSvMolb6UQO103ehl3MO+mKu5qQCgzzgM2anf/BKsWW YlLxKESOAulXbigFgHDL6LRpLI/6nlI5QTGHxhVtPG9bqEfXBWEvBZnAfNkWtg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669245253; 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=aHekk7rHrVj5L5T/94RT0HyGLRna0DzwZs8ha+Ccyvw=; b=2GHZKoSrpfphmj+qCrBjg2+U05bc9CFtPkG0ZSPQaa+D8zKrUOuD28SZDr66qVARIhuUIb dM9dzZOLn74ztsCw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH printk v2 4/7] printk: Add struct console_buffers Date: Thu, 24 Nov 2022 00:19:57 +0106 Message-Id: <20221123231400.614679-5-john.ogness@linutronix.de> In-Reply-To: <20221123231400.614679-1-john.ogness@linutronix.de> References: <20221123231400.614679-1-john.ogness@linutronix.de> MIME-Version: 1.0 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750330795516747388?= X-GMAIL-MSGID: =?utf-8?q?1750330795516747388?= From: Thomas Gleixner Create a data structure to replace the open coded separate buffers for regular, extended, and dropped message formatting. A separate @ext_text buffer is needed because info_print_ext_header() and msg_print_ext_body() are not able to add the needed extra information in-place. @ext_text can be used for dropped text because they are never used at the same time. Signed-off-by: Thomas Gleixner Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- include/linux/console.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/console.h b/include/linux/console.h index b2cf256c23b6..641c1ca7fb67 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -178,6 +178,16 @@ enum cons_flags { CON_EXTENDED = BIT(6), }; +/** + * struct console_buffers - console output text buffers + * @ext_text: Buffer for extended log format or dropped text + * @text: Buffer for ringbuffer text + */ +struct console_buffers { + char ext_text[CONSOLE_EXT_LOG_MAX]; + char text[CONSOLE_LOG_MAX]; +}; + /** * struct console - The console descriptor structure * @name: The name of the console driver From patchwork Wed Nov 23 23:13:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 25241 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3082520wrr; Wed, 23 Nov 2022 15:21:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf5/G/UhzdtH3wj9rjFdJ/13B3uGK20E3kwspYmudy1utbUmmruB221C69O8YxtdZliBZ135 X-Received: by 2002:a17:902:8347:b0:188:f570:7bb6 with SMTP id z7-20020a170902834700b00188f5707bb6mr24155298pln.74.1669245690851; Wed, 23 Nov 2022 15:21:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669245690; cv=none; d=google.com; s=arc-20160816; b=q3OcpSQek/4kDVcNWsZSm//2tgx67yAhX+e6v90+5ME2WigQO4RSS/o7DP7LO4DTDO i37D9pPE00WwJNsHkRbYbPqgo43Mb2JZruGKi1x/5cD4QqNh0CTjzhN2oy6jfpzJnBBw r+P+YcyByXQQezMkw/3Qjzuni3BkY2c2gxQKud1YVn9+Qf8oX1PHzdVEOdoR5cTh0Czc RjnhNslzA461dZuBdiUfWuhS0AxLsof0CGESyh83ClZs2VpVrmUxFzjdp3ND0W1UaR0a 0V6HsYGT4wlWu9ZWwmwXaloTQQZPFWaFONSG6fjgpNp7U49xt/Y0HgtyTFqNq4WIqI7f S9Hw== 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=JpOUi4hZM07oyPRVgjxj+qDi5g9936QFYUmsuEbCZ8s=; b=VUGjlz9Z6Qrb8u3Ybsocfji5kg8bl0exy3wpVIzgvYam+NqhJUobeiW/qGbtZgnqBF iTekX/if4Kl0XvMrOhyb0wS0dY7GtrzQ5RzmfUD47Ad9nccJej3Sn7qHjkfx+AhdiJn6 iSmaxD2coilNPAuI2QISwvxbIvmafUIuMnz/uzTCJfPVVOLQi3g9TOkEJnrTRkp75w8v 8G/itvuOX8AMVVCioievs5VEEKs3fin7Co3wMpdDJp0rUE0glEOHbTJXUrQl/rtq98Dq ccx3t5ZiDqoetCkS6fIfskyM9flWg8qBqge9jsHrUBORpLZAF1s0T62Iu1x2rMNYAxBk ShTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="QQn/XAVQ"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Nu0tMTfq; 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 y1-20020a63fa01000000b00470274bbc14si167742pgh.676.2022.11.23.15.21.17; Wed, 23 Nov 2022 15:21:30 -0800 (PST) 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="QQn/XAVQ"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Nu0tMTfq; 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 S229892AbiKWXOd (ORCPT + 99 others); Wed, 23 Nov 2022 18:14:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229753AbiKWXOR (ORCPT ); Wed, 23 Nov 2022 18:14:17 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 739ABB8572 for ; Wed, 23 Nov 2022 15:14:16 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669245254; 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=JpOUi4hZM07oyPRVgjxj+qDi5g9936QFYUmsuEbCZ8s=; b=QQn/XAVQEtN5GlT1O7T6LLtNJGecVagnIyP5bepPSTYdXmr9caQK312pU7kF61/zQHHcja SITbmNu+NfbGQzajqSW0KhBJija/Civf4YGMl9GMK7VGxFZ1UzOPUH6/3izLQesNK4nSKI cCH+i0f/CPc62Ly9Z1e0loHmoWj62+VehtwdI7nJJDD7USQGjTfdUHUI0A8ocwTd/Z4Syh CJvFUVqyqdBA9tosW41VhcW3AfHQ/Dt68t7tCnCKwQcOaQFaRJevGTway0B/IIFvdYYLA/ vyZbj7BK2O69Ckaf6KBlEJTHvnrBMM52YAW1SSLCgGmGV1g8qRobFX2Gkd7yBg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669245254; 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=JpOUi4hZM07oyPRVgjxj+qDi5g9936QFYUmsuEbCZ8s=; b=Nu0tMTfqSA6a0V+xGV40DqsroZQ5CWfNxABHcURW2PrGgPxY251ku8vWm9PNS0vXGjTjWE Z6CTBuVoFpRmZaCw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 5/7] printk: Use struct console_buffers Date: Thu, 24 Nov 2022 00:19:58 +0106 Message-Id: <20221123231400.614679-6-john.ogness@linutronix.de> In-Reply-To: <20221123231400.614679-1-john.ogness@linutronix.de> References: <20221123231400.614679-1-john.ogness@linutronix.de> MIME-Version: 1.0 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750330969344011319?= X-GMAIL-MSGID: =?utf-8?q?1750330969344011319?= From: Thomas Gleixner Replace the separately allocated output buffers with a single instance of struct console_buffers. Note that the buffer size of devkmsg_user.text_buf, when replaced with console_buffers.text, reduces from CONSOLE_EXT_LOG_MAX to CONSOLE_LOG_MAX. However, the buffer is only used to read ringbuffer records. These records have a maximum size of LOG_LINE_MAX, which is defined as CONSOLE_LOG_MAX - PREFIX_MAX. Signed-off-by: Thomas Gleixner Signed-off-by: John Ogness --- kernel/printk/printk.c | 68 ++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index a4854a60e6d8..750559171e30 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -712,11 +712,9 @@ struct devkmsg_user { atomic64_t seq; struct ratelimit_state rs; struct mutex lock; - char buf[CONSOLE_EXT_LOG_MAX]; - struct printk_info info; - char text_buf[CONSOLE_EXT_LOG_MAX]; struct printk_record record; + struct console_buffers cbufs; }; static __printf(3, 4) __cold @@ -798,6 +796,8 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct devkmsg_user *user = file->private_data; + const int ext_text_size = sizeof(user->cbufs.ext_text); + char *ext_text = &user->cbufs.ext_text[0]; struct printk_record *r = &user->record; size_t len; ssize_t ret; @@ -839,8 +839,8 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf, goto out; } - len = info_print_ext_header(user->buf, sizeof(user->buf), r->info); - len += msg_print_ext_body(user->buf + len, sizeof(user->buf) - len, + len = info_print_ext_header(ext_text, ext_text_size, r->info); + len += msg_print_ext_body(ext_text + len, ext_text_size - len, &r->text_buf[0], r->info->text_len, &r->info->dev_info); @@ -851,7 +851,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf, goto out; } - if (copy_to_user(buf, user->buf, len)) { + if (copy_to_user(buf, ext_text, len)) { ret = -EFAULT; goto out; } @@ -950,7 +950,7 @@ static int devkmsg_open(struct inode *inode, struct file *file) mutex_init(&user->lock); prb_rec_init_rd(&user->record, &user->info, - &user->text_buf[0], sizeof(user->text_buf)); + &user->cbufs.text[0], sizeof(user->cbufs.text)); atomic64_set(&user->seq, prb_first_valid_seq(prb)); @@ -2007,6 +2007,10 @@ static int console_trylock_spinning(void) return 1; } +#if DROPPED_TEXT_MAX > CONSOLE_EXT_LOG_MAX +#error "DROPPED_TEXT_MAX too large for console_buffers->ext_text" +#endif + /* * Call the specified console driver, asking it to write out the specified * text and length. If @dropped_text is non-NULL and any records have been @@ -2741,36 +2745,32 @@ static void __console_unlock(void) * Print one record for the given console. The record printed is whatever * record is the next available record for the given console. * - * @text is a buffer of size CONSOLE_LOG_MAX. + * @cbufs is the console buffers used to string-print the formatted messages. * - * If extended messages should be printed, @ext_text is a buffer of size - * CONSOLE_EXT_LOG_MAX. Otherwise @ext_text must be NULL. - * - * If dropped messages should be printed, @dropped_text is a buffer of size - * DROPPED_TEXT_MAX. Otherwise @dropped_text must be NULL. + * @cookie is the cookie from entering the SRCU read-side critical section. * * @handover will be set to true if a printk waiter has taken over the * console_lock, in which case the caller is no longer holding both the * console_lock and the SRCU read lock. Otherwise it is set to false. * - * @cookie is the cookie from the SRCU read lock. - * * Returns false if the given console has no next record to print, otherwise * true. * * Requires the console_lock and the SRCU read lock. */ -static bool console_emit_next_record(struct console *con, char *text, char *ext_text, - char *dropped_text, bool *handover, int cookie) +static bool console_emit_next_record(struct console *con, struct console_buffers *cbufs, + int cookie, bool *handover) { static int panic_console_dropped; struct printk_info info; struct printk_record r; + size_t write_text_size; unsigned long flags; + char *dropped_text; char *write_text; size_t len; - prb_rec_init_rd(&r, &info, text, CONSOLE_LOG_MAX); + prb_rec_init_rd(&r, &info, &cbufs->text[0], sizeof(cbufs->text)); *handover = false; @@ -2792,13 +2792,20 @@ static bool console_emit_next_record(struct console *con, char *text, char *ext_ goto skip; } - if (ext_text) { - write_text = ext_text; - len = info_print_ext_header(ext_text, CONSOLE_EXT_LOG_MAX, r.info); - len += msg_print_ext_body(ext_text + len, CONSOLE_EXT_LOG_MAX - len, + if (console_srcu_read_flags(con) & CON_EXTENDED) { + /* Extended consoles do not print "dropped messages". */ + dropped_text = NULL; + + write_text = &cbufs->ext_text[0]; + write_text_size = sizeof(cbufs->ext_text); + len = info_print_ext_header(write_text, write_text_size, r.info); + len += msg_print_ext_body(write_text + len, write_text_size - len, &r.text_buf[0], r.info->text_len, &r.info->dev_info); } else { - write_text = text; + /* @ext_text is unused. Use it for "dropped messages". */ + dropped_text = &cbufs->ext_text[0]; + + write_text = &cbufs->text[0]; len = record_print_text(&r, console_msg_format & MSG_FORMAT_SYSLOG, printk_time); } @@ -2852,9 +2859,7 @@ static bool console_emit_next_record(struct console *con, char *text, char *ext_ */ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handover) { - static char dropped_text[DROPPED_TEXT_MAX]; - static char ext_text[CONSOLE_EXT_LOG_MAX]; - static char text[CONSOLE_LOG_MAX]; + static struct console_buffers cbufs; bool any_usable = false; struct console *con; bool any_progress; @@ -2874,16 +2879,7 @@ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handove continue; any_usable = true; - if (console_srcu_read_flags(con) & CON_EXTENDED) { - /* Extended consoles do not print "dropped messages". */ - progress = console_emit_next_record(con, &text[0], - &ext_text[0], NULL, - handover, cookie); - } else { - progress = console_emit_next_record(con, &text[0], - NULL, &dropped_text[0], - handover, cookie); - } + progress = console_emit_next_record(con, &cbufs, cookie, handover); /* * If a handover has occurred, the SRCU read lock From patchwork Wed Nov 23 23:13:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 25243 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3082923wrr; Wed, 23 Nov 2022 15:22:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf5K1scew6Qxg2VpxIx+1JqhgotPLfACrtHxFCXeRpGDuOb4QDkVD13BeHbFIX5ODCSihbmw X-Received: by 2002:a17:90a:8c96:b0:218:7e9d:8d0a with SMTP id b22-20020a17090a8c9600b002187e9d8d0amr28852847pjo.41.1669245752069; Wed, 23 Nov 2022 15:22:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669245752; cv=none; d=google.com; s=arc-20160816; b=yV4Yd58gM/TgcyoqU/ofMmB2i7rVmLfRiGChC5Cf+Z7+ngK5E6WWAsb39erdWvgQF5 gQjTc1WCjBBFOpG50lHQtnfqjhdfIrc9IJUNwzKNoxYcR4G7uw8hNV83uIEB4OUYjX9F mV6xys/kSUKx4eogE71465YfTESulPNZG9EK8q2TMrgHLySUzKS7oNY3SNmjli12rpen ivGIwFxL6Bz7UxWv9RlHh79VJ7fakOqadmKwFxW7RIDCKiwROHJuqqXuyfkiABpqrJst 1njlA5nXTiLXyrJYQy7cv9nuTTf0IsGNTTrmCV+/1lGaNTwfA32wGUmECKit/VLpX8+e 5fOA== 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=/+ga5EsQ4Q0dD6QKcBL7AASWXoGeU5dLsOdcdIgzrhs=; b=RxLJ9ptgpfbTbTvVpKX83BKlNtStIlonktqtKW+pPEKS2UnIajoDI9zM/N1za0Jaan qL5fuhuk8FVj2G24O71tabmV95U68wfEliSWQ9k4G3bvln7MbJbj2lTMVOmuWnaZlU6I whN6Fq0BQZQPFB41sF4fUa42DXvMxlMZN2++JvkU/I6hBwHNN7H7acSZTMTAMC7bOD8H DGTFEieQGDUJCqhcnbrUhK/VJX7VZMTV92U5x0NdgArQIndSTOYQQaOMqSR+K8aCbJRB vFM9r381s+HewDCUVFs7V0Jhs05oDVENWDikyb5ZOQEHsXTMo6tT1uhSq9CByTmDgTsk 80KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ENbn+NVe; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oc14-20020a17090b1c0e00b00213cb58e47bsi1358089pjb.8.2022.11.23.15.22.19; Wed, 23 Nov 2022 15:22:32 -0800 (PST) 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=ENbn+NVe; 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 S229902AbiKWXOi (ORCPT + 99 others); Wed, 23 Nov 2022 18:14:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229766AbiKWXOT (ORCPT ); Wed, 23 Nov 2022 18:14:19 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAEC8D14D9 for ; Wed, 23 Nov 2022 15:14:17 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669245255; 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=/+ga5EsQ4Q0dD6QKcBL7AASWXoGeU5dLsOdcdIgzrhs=; b=ENbn+NVeyH3goCHcBewID4TRhVV6TmCCFuuG2iQfD7h0paqLwG/rHRTVm1q9gCCJFpJTMa XC3fJbUgQO2BVeUKwUGj9GTVtD+kJFSTqMyoy1XQSk5gjLSInHpVDfPvw5Ov35XK3Efs07 zhifff4+2qJBwOYPv/ciWdEXfB9Iw203sWEWg9MJ76MtDjfzINAoXuSXOa89Do2mohtUjI RdtdklCZXjOMAZ/S9BhnIMAxE+Rm1hhqKGRnb8+rPnBb0F1TksbGO2WGtn3fh90srC5fP0 DkeAZjjbICwMpxJEpL4H/FvOu6bHKMJNjJ0aIQXQpL6Tx4NK06OFd3YIa2+m0g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669245255; 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=/+ga5EsQ4Q0dD6QKcBL7AASWXoGeU5dLsOdcdIgzrhs=; b=mTgAe5Nxh1q4mgK3PfLQ6P+S/ViwtZ4ERFiuk8l/2jxdxCU6/uzf7eMa7aa4MvbCPqnN4m 9o2HKk52WW56qzBA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH printk v2 6/7] printk: Use an output buffer descriptor struct for emit Date: Thu, 24 Nov 2022 00:19:59 +0106 Message-Id: <20221123231400.614679-7-john.ogness@linutronix.de> In-Reply-To: <20221123231400.614679-1-john.ogness@linutronix.de> References: <20221123231400.614679-1-john.ogness@linutronix.de> MIME-Version: 1.0 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750331033698334698?= X-GMAIL-MSGID: =?utf-8?q?1750331033698334698?= From: Thomas Gleixner To prepare for a new console infrastructure that is independent of the console BKL, wrap the output mode into a descriptor struct so the new infrastructure can share the emit code that dumps the ringbuffer record into the output text buffers. Signed-off-by: Thomas Gleixner Signed-off-by: John Ogness --- include/linux/console.h | 15 ++++++ kernel/printk/printk.c | 107 ++++++++++++++++++++++++++++------------ 2 files changed, 90 insertions(+), 32 deletions(-) diff --git a/include/linux/console.h b/include/linux/console.h index 641c1ca7fb67..32614011a950 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -188,6 +188,21 @@ struct console_buffers { char text[CONSOLE_LOG_MAX]; }; +/** + * struct console_message - console output buffer descriptor + * @cbufs: Pointer to console buffers storing the record text + * @outbuf: Pointer to the text buffer to be used for writing out + * to the device + * @outbuf_len: Length of text at @outbuf + * @is_extmsg: True if this is an extended format message + */ +struct console_message { + struct console_buffers *cbufs; + char *outbuf; + unsigned int outbuf_len; + bool is_extmsg; +}; + /** * struct console - The console descriptor structure * @name: The name of the console driver diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 750559171e30..dd1d8599ce5a 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2741,11 +2741,76 @@ static void __console_unlock(void) up_console_sem(); } +/** + * console_get_next_message - Fill the output buffer with the next record + * @con: The console to print on + * @cmsg: Pointer to the output buffer descriptor + * + * Return: False if there is no pending record in the ringbuffer. + * True if there is a pending record in the ringbuffer. + * + * When the return value is true, then the caller must check + * @cmsg->outbuf. If not NULL it points to the first character to write + * to the device and @cmsg->outbuf_len contains the length of the message. + * If it is NULL then the record will be skipped. + */ +static bool console_get_next_message(struct console *con, struct console_message *cmsg) +{ + struct console_buffers *cbufs = cmsg->cbufs; + static int panic_console_dropped; + struct printk_info info; + struct printk_record r; + size_t write_text_size; + char *write_text; + size_t len; + + cmsg->outbuf = NULL; + cmsg->outbuf_len = 0; + + prb_rec_init_rd(&r, &info, &cbufs->text[0], sizeof(cbufs->text)); + + if (!prb_read_valid(prb, con->seq, &r)) + return false; + + if (con->seq != r.info->seq) { + con->dropped += r.info->seq - con->seq; + con->seq = r.info->seq; + if (panic_in_progress() && panic_console_dropped++ > 10) { + suppress_panic_printk = 1; + pr_warn_once("Too many dropped messages. Suppress messages on non-panic CPUs to prevent livelock.\n"); + } + } + + /* + * Skip record that has level above the console loglevel. + * Return true so the caller knows a record exists and + * leave cmsg->outbuf NULL so the caller knows the record + * is being skipped. + */ + if (suppress_message_printing(r.info->level)) + return true; + + if (cmsg->is_extmsg) { + write_text = &cbufs->ext_text[0]; + write_text_size = sizeof(cbufs->ext_text); + len = info_print_ext_header(write_text, write_text_size, r.info); + len += msg_print_ext_body(write_text + len, write_text_size - len, + &r.text_buf[0], r.info->text_len, &r.info->dev_info); + } else { + write_text = &cbufs->text[0]; + len = record_print_text(&r, console_msg_format & MSG_FORMAT_SYSLOG, printk_time); + } + + cmsg->outbuf = write_text; + cmsg->outbuf_len = len; + return true; +} + /* * Print one record for the given console. The record printed is whatever * record is the next available record for the given console. * - * @cbufs is the console buffers used to string-print the formatted messages. + * @cbufs is the console buffers to use for string-printing the message. * * @cookie is the cookie from entering the SRCU read-side critical section. * @@ -2761,52 +2826,30 @@ static void __console_unlock(void) static bool console_emit_next_record(struct console *con, struct console_buffers *cbufs, int cookie, bool *handover) { - static int panic_console_dropped; - struct printk_info info; - struct printk_record r; - size_t write_text_size; + struct console_message cmsg = { + .cbufs = cbufs, + .is_extmsg = console_srcu_read_flags(con) & CON_EXTENDED, + }; unsigned long flags; char *dropped_text; - char *write_text; - size_t len; - - prb_rec_init_rd(&r, &info, &cbufs->text[0], sizeof(cbufs->text)); *handover = false; - if (!prb_read_valid(prb, con->seq, &r)) + if (!console_get_next_message(con, &cmsg)) return false; - if (con->seq != r.info->seq) { - con->dropped += r.info->seq - con->seq; - con->seq = r.info->seq; - if (panic_in_progress() && panic_console_dropped++ > 10) { - suppress_panic_printk = 1; - pr_warn_once("Too many dropped messages. Suppress messages on non-panic CPUs to prevent livelock.\n"); - } - } - - /* Skip record that has level above the console loglevel. */ - if (suppress_message_printing(r.info->level)) { + if (!cmsg.outbuf) { + /* Skipping this record. */ con->seq++; goto skip; } - if (console_srcu_read_flags(con) & CON_EXTENDED) { + if (cmsg.is_extmsg) { /* Extended consoles do not print "dropped messages". */ dropped_text = NULL; - - write_text = &cbufs->ext_text[0]; - write_text_size = sizeof(cbufs->ext_text); - len = info_print_ext_header(write_text, write_text_size, r.info); - len += msg_print_ext_body(write_text + len, write_text_size - len, - &r.text_buf[0], r.info->text_len, &r.info->dev_info); } else { /* @ext_text is unused. Use it for "dropped messages". */ dropped_text = &cbufs->ext_text[0]; - - write_text = &cbufs->text[0]; - len = record_print_text(&r, console_msg_format & MSG_FORMAT_SYSLOG, printk_time); } /* @@ -2823,7 +2866,7 @@ static bool console_emit_next_record(struct console *con, struct console_buffers console_lock_spinning_enable(); stop_critical_timings(); /* don't trace print latency */ - call_console_driver(con, write_text, len, dropped_text); + call_console_driver(con, cmsg.outbuf, cmsg.outbuf_len, dropped_text); start_critical_timings(); con->seq++; From patchwork Wed Nov 23 23:14:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 25242 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3082895wrr; Wed, 23 Nov 2022 15:22:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf7k7hGAc9flxDOxwHjfZS/NeuM5PT22BlsyGWNr8vv6UpgG5z84B8QmKCcKLVtogv4YCoTm X-Received: by 2002:a05:6a00:2a8:b0:56c:db44:7b1f with SMTP id q8-20020a056a0002a800b0056cdb447b1fmr11810919pfs.54.1669245746490; Wed, 23 Nov 2022 15:22:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669245746; cv=none; d=google.com; s=arc-20160816; b=z99wcorfvmxiioBxxIgupThjKRcN1+rLYuTaRtK0XirlnbE9vvHnWlR0kJc/jgXK6n brZoWjMbymkv3HkTgicVEkZ753UcGChyIa6cBdjxp/s7SILX2yWI5S2PVgLtFVGsBlu1 f3hFk01jg9q846p7b5WaB6jdgQ6QRmr4Qj6k8QYhLk1baH7j1X5BZyGllLEdXtVr7lfl kRJ1JUsc3CtW9SgZQVgY2/7Jla/QZTHGpJqc2zgDGED/7aqw4qTAGKeHLf/P8Uvnjfsp wyN+aMBuFsaFQ3r+2rdtBuvLP5depjNhv7uxjw6Th6QwObLR1HXiGcmQPkIDheVe0I2t nDvQ== 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=0qJ3iGikvuTukQn/cCJfO+65/fD4hTu0WWCBxLF08iQ=; b=uHb+qk1JYAIb5aA8RTGkyAzcZ+vX/CNAnuIb2CCBE3OC5kn9p88LPa8RegQpx2GKdj x93n8FaRwVxl4GybODHjST4H7J0jcmiSXdDDRK17cq3C6kUubCJFfKj3feFzIXmuLp5Q Ev1A9CLcftPuns+V57AnaWJsAafVoHR5v2ynQznsrvHJesp9TJdyXcbjd8+9JW0qEiFp +axsamfVouDgpeV64KrpMePuV6xqaMTnpV15KtJasmLz7xPxRp7WHMO4iIgaeuVBoB/5 yeEpJwN7z6A5wjicpDRHkiWtrBp6cYtfV/NSVma/PWtcLH2ZzsdVVqjGiWM7jY8ykilN 00Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qFG7KOKP; dkim=neutral (no key) header.i=@linutronix.de header.b=SDLoP6aD; 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 o3-20020a1709026b0300b00188bee77e8fsi3884287plk.35.2022.11.23.15.22.13; Wed, 23 Nov 2022 15:22:26 -0800 (PST) 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=qFG7KOKP; dkim=neutral (no key) header.i=@linutronix.de header.b=SDLoP6aD; 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 S229920AbiKWXOm (ORCPT + 99 others); Wed, 23 Nov 2022 18:14:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229797AbiKWXOU (ORCPT ); Wed, 23 Nov 2022 18:14:20 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11019D14E8 for ; Wed, 23 Nov 2022 15:14:19 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669245256; 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=0qJ3iGikvuTukQn/cCJfO+65/fD4hTu0WWCBxLF08iQ=; b=qFG7KOKPIOGPVQw4I4QTVM52nnmpM91ysQ6T70Acjrw1gpl0mSL1hKuzjaYH3IyrBdHtv6 oh/j557mygD9WK7tfw/fKTKt1veJRrSPK/tfHkUVK2/aD1rCsP9TA24uV7U6CwgM+UnHK3 33M0kpa68PuW0Ut2XgbpCvlM5j5RRdPeszmPqkKCBPHHmvZTE/TT/ad9TN6LxRbxPV5DUv WpwG0pluX/88uGy/c12JMEfAt+cQjzIfzZQ3Qg2oVIXdDCmxYEh75Xm/C23581Dg3PZEZw Cc1NwxIkCOATcuq59S94MuFyyppOkXrb0C0tO/A08yqCqgTUkZ/Ci6ANn0QXGQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669245256; 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=0qJ3iGikvuTukQn/cCJfO+65/fD4hTu0WWCBxLF08iQ=; b=SDLoP6aDtGO+Fh77Cy+vmar1/O+F8pe4MEZi8b2SuHvnnXV3AVCXOa3UDf8N3bIdogk61N B3dJyH5e3wquaECg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 7/7] printk: Handle dropped message smarter Date: Thu, 24 Nov 2022 00:20:00 +0106 Message-Id: <20221123231400.614679-8-john.ogness@linutronix.de> In-Reply-To: <20221123231400.614679-1-john.ogness@linutronix.de> References: <20221123231400.614679-1-john.ogness@linutronix.de> MIME-Version: 1.0 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750331027750724661?= X-GMAIL-MSGID: =?utf-8?q?1750331027750724661?= From: Thomas Gleixner If a 'dropped message' is to be printed, move the record text to be directly appended to the 'dropped message' and let console->write() output it in one go. Signed-off-by: Thomas Gleixner Signed-off-by: John Ogness --- kernel/printk/printk.c | 125 +++++++++++++++++++++++++++-------------- 1 file changed, 82 insertions(+), 43 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index dd1d8599ce5a..c4b148a7d114 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2007,31 +2007,6 @@ static int console_trylock_spinning(void) return 1; } -#if DROPPED_TEXT_MAX > CONSOLE_EXT_LOG_MAX -#error "DROPPED_TEXT_MAX too large for console_buffers->ext_text" -#endif - -/* - * Call the specified console driver, asking it to write out the specified - * text and length. If @dropped_text is non-NULL and any records have been - * dropped, a dropped message will be written out first. - */ -static void call_console_driver(struct console *con, const char *text, size_t len, - char *dropped_text) -{ - size_t dropped_len; - - if (con->dropped && dropped_text) { - dropped_len = snprintf(dropped_text, DROPPED_TEXT_MAX, - "** %lu printk messages dropped **\n", - con->dropped); - con->dropped = 0; - con->write(con, dropped_text, dropped_len); - } - - con->write(con, text, len); -} - /* * Recursion is tracked separately on each CPU. If NMIs are supported, an * additional NMI context per CPU is also separately tracked. Until per-CPU @@ -2412,10 +2387,6 @@ static ssize_t msg_print_ext_body(char *buf, size_t size, struct dev_printk_info *dev_info) { return 0; } static void console_lock_spinning_enable(void) { } static int console_lock_spinning_disable_and_check(int cookie) { return 0; } -static void call_console_driver(struct console *con, const char *text, size_t len, - char *dropped_text) -{ -} static bool suppress_message_printing(int level) { return false; } static bool pr_flush(int timeout_ms, bool reset_on_progress) { return true; } static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progress) { return true; } @@ -2741,6 +2712,60 @@ static void __console_unlock(void) up_console_sem(); } +/* + * A maximum dropped message together with a maximum regular message + * must be able to fit within console_buffers->ext_text. + */ +#if DROPPED_TEXT_MAX > (CONSOLE_EXT_LOG_MAX - CONSOLE_LOG_MAX) +#error "DROPPED_TEXT_MAX too large for console_buffers->ext_text" +#endif + +/** + * msg_print_dropped - Prepend a "dropped message" if required + * @desc: Pointer to the output descriptor + * @dropped: The number of dropped messages to report + * + * Inserts the "dropped message" into the output buffer if @dropped is + * not 0 and the regular format is requested. Extended format does not + * need this message because it prints the sequence numbers. + * + * In regular format, the extended message buffer is not in use. So + * string-print the dropped message there and move the record text to be + * appended to the dropped message. The extended message buffer is much + * larger and can accommodate both messages. + * + * In case a dropped message is needed, this returns with @desc->outbuf + * and @desc->len updated. The caller is responsible for tracking and + * resetting the dropped count. If no dropped message is required then + * @desc is not modified. + */ +static void msg_print_dropped(struct console_message *cmsg, unsigned long dropped) +{ + struct console_buffers *cbufs = cmsg->cbufs; + char *ext_text = &cbufs->ext_text[0]; + size_t len; + + if (!dropped || cmsg->is_extmsg) + return; + + if (WARN_ON_ONCE(cmsg->outbuf != &cbufs->text[0])) + return; + + /* Print it into ext_text, which is unused. */ + len = snprintf(ext_text, DROPPED_TEXT_MAX, + "** %lu printk messages dropped **\n", dropped); + + /* + * Append the record text to the dropped message so that it + * goes out with one write. + */ + memcpy(ext_text + len, &cbufs->text[0], cmsg->outbuf_len); + + /* Update the output buffer descriptor. */ + cmsg->outbuf = ext_text; + cmsg->outbuf_len += len; +} + /** * console_get_next_message - Fill the output buffer with the next record * @con: The console to print on @@ -2796,13 +2821,32 @@ static bool console_get_next_message(struct console *con, struct console_message len = info_print_ext_header(write_text, write_text_size, r.info); len += msg_print_ext_body(write_text + len, write_text_size - len, &r.text_buf[0], r.info->text_len, &r.info->dev_info); + + cmsg->outbuf = write_text; + cmsg->outbuf_len = len; + + /* + * Extended consoles do not print "dropped messages" + * as that can be seen from the sequence number. + */ } else { - write_text = &cbufs->text[0]; len = record_print_text(&r, console_msg_format & MSG_FORMAT_SYSLOG, printk_time); + + cmsg->outbuf = &cbufs->text[0]; + cmsg->outbuf_len = len; + + if (con->dropped) { + /* + * It is expected that @outbuf and @outbuf_len are + * already set. They will be updated after inserting + * the "dropped message". + */ + msg_print_dropped(cmsg, con->dropped); + + con->dropped = 0; + } } - cmsg->outbuf = write_text; - cmsg->outbuf_len = len; return true; } @@ -2831,7 +2875,6 @@ static bool console_emit_next_record(struct console *con, struct console_buffers .is_extmsg = console_srcu_read_flags(con) & CON_EXTENDED, }; unsigned long flags; - char *dropped_text; *handover = false; @@ -2844,14 +2887,6 @@ static bool console_emit_next_record(struct console *con, struct console_buffers goto skip; } - if (cmsg.is_extmsg) { - /* Extended consoles do not print "dropped messages". */ - dropped_text = NULL; - } else { - /* @ext_text is unused. Use it for "dropped messages". */ - dropped_text = &cbufs->ext_text[0]; - } - /* * While actively printing out messages, if another printk() * were to occur on another CPU, it may wait for this one to @@ -2865,8 +2900,12 @@ static bool console_emit_next_record(struct console *con, struct console_buffers printk_safe_enter_irqsave(flags); console_lock_spinning_enable(); - stop_critical_timings(); /* don't trace print latency */ - call_console_driver(con, cmsg.outbuf, cmsg.outbuf_len, dropped_text); + /* Do not trace print latency. */ + stop_critical_timings(); + + /* Write everything out to the hardware. */ + con->write(con, cmsg.outbuf, cmsg.outbuf_len); + start_critical_timings(); con->seq++;