From patchwork Thu Jan 5 10:37:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 39477 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp234666wrt; Thu, 5 Jan 2023 02:42:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXsKM6b5ijdx34b7+xnkb4zqeba/xWIDSkl7URsFMY4T0/Y0YrqQw/2/G49DIXzelN2O7GaV X-Received: by 2002:a05:6a21:e301:b0:af:85b4:2397 with SMTP id cb1-20020a056a21e30100b000af85b42397mr57724840pzc.41.1672915370582; Thu, 05 Jan 2023 02:42:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672915370; cv=none; d=google.com; s=arc-20160816; b=KGPnDqqTebyQEr0flpXGbVkLnqts2fxcp1CUVhpTiMDpVSSZRnS9PB+NIkLCa1yeWs NlOgqCwRbiPrBKxLtmDYvfb5ZtyaLZv+7yr2fOv/0klptTnyamklIP/3wGuKhdHQofC+ gkEBUM+isI5Pj7VqMf673a8I8xFpHGilg4Ndyyiam6WcHFREMCjFoq9O3x083d1ujshQ 0/2GsgMjuRtUsDrmeZIplDDBHQq5S0AFNxRqWDm9U+QwKe0mCNAsqYgzROZ4BmOdR/aN Hu78JwbmH5DSQv8fo/dDHPy+dS20hJse3lCm4Ynpm3tmyHWDveJYsiitwO5MG0v73yZ0 ziDw== 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=abSBMFxz6OGnYpZ+uMTv9uCdX0Afe+r827cQ4Qs2ufY=; b=AJBXBlw3A5nv4vJGDmHyUxorYHiJU0mBeEKccK1cz66cTAbxsYQrl+m7c5kC2hZJK9 +XuxG/4gQNJfUb2wjeMomgDfhDkcQLnHqTNd8SGfl1OSep26WHR2ZXPM0dsXltTo3tr+ uJFxJrrkeUp2YOddLzPrNc86AIIOitRvgW3hkwUXZ4krSiIen16XxNmWYHqb5wMSMz0d kSOiP3yZDTt1lW3I3G/DnJ2gSkdhewL/y5VkP+D2FWrmWJknI/4aHrOHw+p4a6YGq6Ga PMXergKRx81aFRZttsoW3CUnhpvFcq1PVMyFPzEp/TbmqLDVKyP1lNeLZgAT+ir3qvu0 7ueA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tqehtiML; 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 mv7-20020a17090b198700b00226a8c884a2si1448256pjb.95.2023.01.05.02.42.37; Thu, 05 Jan 2023 02:42:50 -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=tqehtiML; 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 S232785AbjAEKih (ORCPT + 99 others); Thu, 5 Jan 2023 05:38:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233060AbjAEKiR (ORCPT ); Thu, 5 Jan 2023 05:38:17 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC37E395E2 for ; Thu, 5 Jan 2023 02:38:16 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1672915095; 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=abSBMFxz6OGnYpZ+uMTv9uCdX0Afe+r827cQ4Qs2ufY=; b=tqehtiMLazk/qWuhSsaz5i2yKpuIumt7UJ/O9IVTFwWS8oUv9OP2KsY25Vyh2Ur2hw5AhE rwJqybiVS56Yz0rcozukcD4ENkQVvWrLwJUMaz4x3cz7Y9gHEo8gBcEmv9bwJ/DM3kiHXl YBViDZDDmjjZCOYK/joLlQjreviSc1YQrKVp5UVeH+EyqGTkx7Dd99G7UU1rHQelKSDbpl yTdxQ5Xk8WlvhcdCmNWYaLJ1Ia2dVVBipBmCBCVXMilZ56bx7SPWWxJy0dH8CC0WKVCmil VmVdaCKkFjMbbW4rjteHr0nLAU9xmfOOF9kOKRNxCjpdQ5aCOjFT+AAIylidcg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1672915095; 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=abSBMFxz6OGnYpZ+uMTv9uCdX0Afe+r827cQ4Qs2ufY=; b=6A/kl4DuJAeDd+nmgvm37gEIK/iEFtiobj2bA8QZuL8FsdR0mmgRRamGvkcbmbZ2eS1ZVc zbGTvoCRfWk/GlDg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v4 1/8] printk: move size limit macros into internal.h Date: Thu, 5 Jan 2023 11:43:28 +0106 Message-Id: <20230105103735.880956-2-john.ogness@linutronix.de> In-Reply-To: <20230105103735.880956-1-john.ogness@linutronix.de> References: <20230105103735.880956-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?1754178907973903193?= X-GMAIL-MSGID: =?utf-8?q?1754178907973903193?= The size limit macros are located further down in printk.c and behind ifdef conditionals. This complicates their usage for upcoming changes. Move the macros into internal.h so that they are still invisible outside of printk, but easily accessible for printk. Also, the maximum size of formatted extended messages does not need to be known by any code outside of printk, so move it to internal.h as well. And like CONSOLE_LOG_MAX, for !CONFIG_PRINTK set CONSOLE_EXT_LOG_MAX to 0 to reduce the static memory footprint. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- include/linux/printk.h | 2 -- kernel/printk/internal.h | 24 ++++++++++++++++++++++++ kernel/printk/printk.c | 17 ----------------- 3 files changed, 24 insertions(+), 19 deletions(-) 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/internal.h b/kernel/printk/internal.h index d947ca6c84f9..f394332410c9 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -14,6 +14,24 @@ int devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write, #ifdef CONFIG_PRINTK +#ifdef CONFIG_PRINTK_CALLER +#define PREFIX_MAX 48 +#else +#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 of a formatted extended record */ +#define CONSOLE_EXT_LOG_MAX 8192 + +/* the maximum size for a dropped text message */ +#define DROPPED_TEXT_MAX 64 + +/* the maximum size allowed to be reserved for a record */ +#define LOG_LINE_MAX (CONSOLE_LOG_MAX - PREFIX_MAX) + /* Flags for a single printk record. */ enum printk_info_flags { LOG_NEWLINE = 2, /* text ended with a newline */ @@ -48,6 +66,12 @@ u16 printk_parse_prefix(const char *text, int *level, enum printk_info_flags *flags); #else +#define PREFIX_MAX 0 +#define CONSOLE_LOG_MAX 0 +#define CONSOLE_EXT_LOG_MAX 0 +#define DROPPED_TEXT_MAX 0 +#define LOG_LINE_MAX 0 + /* * In !PRINTK builds we still export console_sem * semaphore and some of console functions (console_unlock()/etc.), so diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 7decf1e9c486..55bb065de65f 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -465,21 +465,6 @@ static struct latched_seq clear_seq = { .val[1] = 0, }; -#ifdef CONFIG_PRINTK_CALLER -#define PREFIX_MAX 48 -#else -#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 - -/* the maximum size allowed to be reserved for a record */ -#define LOG_LINE_MAX (CONSOLE_LOG_MAX - PREFIX_MAX) - #define LOG_LEVEL(v) ((v) & 0x07) #define LOG_FACILITY(v) ((v) >> 3 & 0xff) @@ -2387,8 +2372,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 #define prb_read_valid(rb, seq, r) false