Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5974222rwl; Mon, 9 Jan 2023 02:26:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXvAKd7eDbgb8BE/16XcPOzT8yBvu87Id5csrRdS3x0e9qEbcf07ad0m2s0dpneQ8vfa2gHE X-Received: by 2002:a05:6a00:2786:b0:582:5b8e:533 with SMTP id bd6-20020a056a00278600b005825b8e0533mr24870586pfb.16.1673259994267; Mon, 09 Jan 2023 02:26:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673259994; cv=none; d=google.com; s=arc-20160816; b=J+tI3rRwjhhaVDWh57IYcXyjsSKSpHN3FUOlFFHbKsZOPN5obh2HcLrc6zpUqqzerk 9SzDu998A5rO7FUUwdJY2vc8GXM/z4SdZ3wdMvMElhQGQ+CiRTQlxOAjdelRBeU8fu// I7FZ6blI44ixQ2dQrZOpq3bzzY9jPpn4hCGcQ+Fa1LegZEIkDYR7c4ogu4vhf3OpnaBu RRPCc8mpt1Td9Ujlw/SWf1lzaoBSkQJv6tZXcRFq7XhT2xohPKmwaISor0MK7ZYkQtBO Q5Fft1LVnNBFnigpe40GiJRCzZ1Qopb9UTs3n5sJI5x6NkmfAawI+hSVEfRoYWZuq7ei tVyQ== 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=bX02r2I3Rh7nmjgfNifsLAV7ya3446uEg2LFZ7tsWzo=; b=Hj+6ii2NATn6B+v9+t7DKUK3nFvJQYQeTRRfKE9tEyyqMzgn/J6h2CQJH0kPd4nHnb 4uHEH2KwjFU3myap+Q8e+/RMgHO+j01Af2I/8SSL5sU4FkZbnBqmlz4VuUW4KhcEiGJW xAIT1bQHJlbyeo086qgdsA02n7geX1wH0jEIaKjWR5pzEuIhGX3YgxpWYP9AJTcr6+4q ObxdU3gP9pPb3rEXpE2WrQQ88jFPXuyaWVQApptykNyWw2tPJFXAR5NLaOeCBhJLPRxx snzuM2BheKicie36zdCkVPOuIQ37ralcM+mVTUTWJVCLE5utxEdC77R4iSFqX1beDbwR XWUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hT4bV9gm; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 k4-20020a056a00168400b00557bb4f6977si9663982pfc.106.2023.01.09.02.26.27; Mon, 09 Jan 2023 02:26:34 -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=hT4bV9gm; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S234306AbjAIKJS (ORCPT + 54 others); Mon, 9 Jan 2023 05:09:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236865AbjAIKIs (ORCPT ); Mon, 9 Jan 2023 05:08:48 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A9E310B73 for ; Mon, 9 Jan 2023 02:08:46 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673258924; 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=bX02r2I3Rh7nmjgfNifsLAV7ya3446uEg2LFZ7tsWzo=; b=hT4bV9gmwVYUTgBQHgR3eUlb7nWTyaC7+b3/wB0SZ3LdYzCPC0VJjeVPkrCuZVaNX8igF4 0S2EO5xWTixW0lcWpnwDa7PaevzIDjzalqsHjipUMU1v99o4Gox/H3Ynvjg1T41i7LXWbX uCwSmVMY7FmTVV0WfpKSQpCmqSgocl3p/zQopAKY8ZA+kyYc/34Eu1niXyo8n60JiCoNAS Vji2rY8UQnjz6VqrqzUvs3juHRv1TjXE78jVHTYxxPgfuDx+gA9kcUzqAoTifLUPBweNA/ QCrgkhHldjNuPKZqcd0k/eTv+vtRoKuYzmOtsHXYGFZwh1alatNDzU/2X8Nxaw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673258924; 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=bX02r2I3Rh7nmjgfNifsLAV7ya3446uEg2LFZ7tsWzo=; b=BqxKVCwzy74Cj0XV5ocO47XuNtxxqiK20w+/ek4KfmTraO0d9Gr/1JjZAMbWhVWputtY5m A1L/JD4Wwh5vEPBg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v5 1/8] printk: move size limit macros into internal.h Date: Mon, 9 Jan 2023 11:13:53 +0106 Message-Id: <20230109100800.1085541-2-john.ogness@linutronix.de> In-Reply-To: <20230109100800.1085541-1-john.ogness@linutronix.de> References: <20230109100800.1085541-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 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 -- 2.30.2