Skip to content

Commit 2364b40

Browse files
jognesspmladek
authored andcommitted
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 <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 98d0052 commit 2364b40

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

include/linux/printk.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ static inline const char *printk_skip_headers(const char *buffer)
4444
return buffer;
4545
}
4646

47-
#define CONSOLE_EXT_LOG_MAX 8192
48-
4947
/* printk's without a loglevel use this.. */
5048
#define MESSAGE_LOGLEVEL_DEFAULT CONFIG_MESSAGE_LOGLEVEL_DEFAULT
5149

kernel/printk/internal.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ int devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write,
1414

1515
#ifdef CONFIG_PRINTK
1616

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+
1735
/* Flags for a single printk record. */
1836
enum printk_info_flags {
1937
LOG_NEWLINE = 2, /* text ended with a newline */
@@ -48,6 +66,12 @@ u16 printk_parse_prefix(const char *text, int *level,
4866
enum printk_info_flags *flags);
4967
#else
5068

69+
#define PREFIX_MAX 0
70+
#define CONSOLE_LOG_MAX 0
71+
#define CONSOLE_EXT_LOG_MAX 0
72+
#define DROPPED_TEXT_MAX 0
73+
#define LOG_LINE_MAX 0
74+
5175
/*
5276
* In !PRINTK builds we still export console_sem
5377
* semaphore and some of console functions (console_unlock()/etc.), so

kernel/printk/printk.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -465,21 +465,6 @@ static struct latched_seq clear_seq = {
465465
.val[1] = 0,
466466
};
467467

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-
483468
#define LOG_LEVEL(v) ((v) & 0x07)
484469
#define LOG_FACILITY(v) ((v) >> 3 & 0xff)
485470

@@ -2387,8 +2372,6 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
23872372

23882373
#else /* CONFIG_PRINTK */
23892374

2390-
#define CONSOLE_LOG_MAX 0
2391-
#define DROPPED_TEXT_MAX 0
23922375
#define printk_time false
23932376

23942377
#define prb_read_valid(rb, seq, r) false

0 commit comments

Comments
 (0)