Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

printk: move size limit macros into internal.h

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 <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20230109100800.1085541-2-john.ogness@linutronix.de

authored by

John Ogness and committed by
Petr Mladek
2364b406 98d0052d

+24 -19
-2
include/linux/printk.h
··· 44 44 return buffer; 45 45 } 46 46 47 - #define CONSOLE_EXT_LOG_MAX 8192 48 - 49 47 /* printk's without a loglevel use this.. */ 50 48 #define MESSAGE_LOGLEVEL_DEFAULT CONFIG_MESSAGE_LOGLEVEL_DEFAULT 51 49
+24
kernel/printk/internal.h
··· 14 14 15 15 #ifdef CONFIG_PRINTK 16 16 17 + #ifdef CONFIG_PRINTK_CALLER 18 + #define PREFIX_MAX 48 19 + #else 20 + #define PREFIX_MAX 32 21 + #endif 22 + 23 + /* the maximum size of a formatted record (i.e. with prefix added per line) */ 24 + #define CONSOLE_LOG_MAX 1024 25 + 26 + /* the maximum size of a formatted extended record */ 27 + #define CONSOLE_EXT_LOG_MAX 8192 28 + 29 + /* the maximum size for a dropped text message */ 30 + #define DROPPED_TEXT_MAX 64 31 + 32 + /* the maximum size allowed to be reserved for a record */ 33 + #define LOG_LINE_MAX (CONSOLE_LOG_MAX - PREFIX_MAX) 34 + 17 35 /* Flags for a single printk record. */ 18 36 enum printk_info_flags { 19 37 LOG_NEWLINE = 2, /* text ended with a newline */ ··· 65 47 u16 printk_parse_prefix(const char *text, int *level, 66 48 enum printk_info_flags *flags); 67 49 #else 50 + 51 + #define PREFIX_MAX 0 52 + #define CONSOLE_LOG_MAX 0 53 + #define CONSOLE_EXT_LOG_MAX 0 54 + #define DROPPED_TEXT_MAX 0 55 + #define LOG_LINE_MAX 0 68 56 69 57 /* 70 58 * In !PRINTK builds we still export console_sem
-17
kernel/printk/printk.c
··· 465 465 .val[1] = 0, 466 466 }; 467 467 468 - #ifdef CONFIG_PRINTK_CALLER 469 - #define PREFIX_MAX 48 470 - #else 471 - #define PREFIX_MAX 32 472 - #endif 473 - 474 - /* the maximum size of a formatted record (i.e. with prefix added per line) */ 475 - #define CONSOLE_LOG_MAX 1024 476 - 477 - /* the maximum size for a dropped text message */ 478 - #define DROPPED_TEXT_MAX 64 479 - 480 - /* the maximum size allowed to be reserved for a record */ 481 - #define LOG_LINE_MAX (CONSOLE_LOG_MAX - PREFIX_MAX) 482 - 483 468 #define LOG_LEVEL(v) ((v) & 0x07) 484 469 #define LOG_FACILITY(v) ((v) >> 3 & 0xff) 485 470 ··· 2372 2387 2373 2388 #else /* CONFIG_PRINTK */ 2374 2389 2375 - #define CONSOLE_LOG_MAX 0 2376 - #define DROPPED_TEXT_MAX 0 2377 2390 #define printk_time false 2378 2391 2379 2392 #define prb_read_valid(rb, seq, r) false