Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp677701rwl; Thu, 5 Jan 2023 03:03:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXuZ00llTN+IDpF6HXf9PI2MJ23XRT4nP1iLwhje2qw7N0Dwz9dnIw8v/Iml4LTJVkqEwn2x X-Received: by 2002:a17:906:2854:b0:7c0:e30a:d3e5 with SMTP id s20-20020a170906285400b007c0e30ad3e5mr40903924ejc.18.1672916622232; Thu, 05 Jan 2023 03:03:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672916622; cv=none; d=google.com; s=arc-20160816; b=KEG9IjMmlHknPhizKRkeKiC7qFujSBu+V1UdvX4T8jmzKDrZyHTF2TtDVCfjJP2ZnS UN150upY+jRrpzvsKmMCV1VID3vG5CKpyRINb+dQVdxNDbkZ53xG+LLV5jk7lG6Vkc4X rOL9C2gZ8NdTirNdULaVSG/7DCaDFlJMBhjoQUN0SsGIgcyYFpl0VIqNa9zjc8EJmCQB WUjfbbw1+gIExuxWL2RePKgvmFyzstDR3CGn6wR3IQiosPd8wQTeigMXa2clNUkv0juW 9YRPR1BDHS1TtkgkaFd2FM/6JGOtQp1bhLrHrET/615ckJG9It/5Jx7lvh8CYsxYeDGY qzZg== 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 header.s=2020e header.b="6A/kl4Du"; 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 hd16-20020a170907969000b007826de24087si31919881ejc.228.2023.01.05.03.03.29; Thu, 05 Jan 2023 03:03:42 -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 header.s=2020e header.b="6A/kl4Du"; 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 + 55 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 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 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 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 --- 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 -- 2.30.2