Commit 7d66d3ab authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull printk updates from Petr Mladek:

 - Print more precise information about the printk log buffer memory
   usage.

 - Make sure that the sysrq title is shown on the console even when
   deferred.

 - Do not enable earlycon by `console=` which is meant to disable the
   default console.

* tag 'printk-for-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux:
  printk: add dummy printk_force_console_enter/exit helpers
  tty: sysrq: Use printk_force_console context on __handle_sysrq
  printk: Introduce FORCE_CON flag
  printk: Improve memory usage logging during boot
  init: Don't proxy `console=` to earlycon
parents c3cda60e 34767e53
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -248,6 +248,29 @@ static int __init param_setup_earlycon(char *buf)
}
early_param("earlycon", param_setup_earlycon);

/*
 * The `console` parameter is overloaded. It's handled here as an early param
 * and in `printk.c` as a late param. It's possible to specify an early
 * `bootconsole` using `earlycon=uartXXXX` (handled above), or via
 * the `console=uartXXX` alias. See the comment in `8250_early.c`.
 */
static int __init param_setup_earlycon_console_alias(char *buf)
{
	/*
	 * A plain `console` parameter must not enable the SPCR `bootconsole`
	 * like a plain `earlycon` does.
	 *
	 * A `console=` parameter that specifies an empty value is used to
	 * disable the `console`, not the `earlycon` `bootconsole`. The
	 * disabling of the `console` is handled by `printk.c`.
	 */
	if (!buf || !buf[0])
		return 0;

	return param_setup_earlycon(buf);
}
early_param("console", param_setup_earlycon_console_alias);

#ifdef CONFIG_OF_EARLY_FLATTREE

int __init of_setup_earlycon(const struct earlycon_id *match,
+8 −10
Original line number Diff line number Diff line
@@ -583,7 +583,6 @@ static void __sysrq_put_key_op(u8 key, const struct sysrq_key_op *op_p)
void __handle_sysrq(u8 key, bool check_mask)
{
	const struct sysrq_key_op *op_p;
	int orig_log_level;
	int orig_suppress_printk;
	int i;

@@ -593,13 +592,12 @@ void __handle_sysrq(u8 key, bool check_mask)
	rcu_sysrq_start();
	rcu_read_lock();
	/*
	 * Raise the apparent loglevel to maximum so that the sysrq header
	 * is shown to provide the user with positive feedback.  We do not
	 * simply emit this at KERN_EMERG as that would change message
	 * routing in the consumers of /proc/kmsg.
	 * Enter in the force_console context so that sysrq header is shown to
	 * provide the user with positive feedback.  We do not simply emit this
	 * at KERN_EMERG as that would change message routing in the consumers
	 * of /proc/kmsg.
	 */
	orig_log_level = console_loglevel;
	console_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
	printk_force_console_enter();

	op_p = __sysrq_get_key_op(key);
	if (op_p) {
@@ -609,11 +607,11 @@ void __handle_sysrq(u8 key, bool check_mask)
		 */
		if (!check_mask || sysrq_on_mask(op_p->enable_mask)) {
			pr_info("%s\n", op_p->action_msg);
			console_loglevel = orig_log_level;
			printk_force_console_exit();
			op_p->handler(key);
		} else {
			pr_info("This sysrq operation is disabled.\n");
			console_loglevel = orig_log_level;
			printk_force_console_exit();
		}
	} else {
		pr_info("HELP : ");
@@ -631,7 +629,7 @@ void __handle_sysrq(u8 key, bool check_mask)
			}
		}
		pr_cont("\n");
		console_loglevel = orig_log_level;
		printk_force_console_exit();
	}
	rcu_read_unlock();
	rcu_sysrq_end();
+11 −0
Original line number Diff line number Diff line
@@ -166,6 +166,9 @@ __printf(1, 2) __cold int _printk_deferred(const char *fmt, ...);
extern void __printk_deferred_enter(void);
extern void __printk_deferred_exit(void);

extern void printk_force_console_enter(void);
extern void printk_force_console_exit(void);

/*
 * The printk_deferred_enter/exit macros are available only as a hack for
 * some code paths that need to defer all printk console printing. Interrupts
@@ -229,6 +232,14 @@ static inline void printk_deferred_exit(void)
{
}

static inline void printk_force_console_enter(void)
{
}

static inline void printk_force_console_exit(void)
{
}

static inline int printk_ratelimit(void)
{
	return 0;
+1 −4
Original line number Diff line number Diff line
@@ -754,10 +754,7 @@ static int __init do_early_param(char *param, char *val,
	const struct obs_kernel_param *p;

	for (p = __setup_start; p < __setup_end; p++) {
		if ((p->early && parameq(param, p->str)) ||
		    (strcmp(param, "console") == 0 &&
		     strcmp(p->str, "earlycon") == 0)
		) {
		if (p->early && parameq(param, p->str)) {
			if (p->setup_func(val) != 0)
				pr_warn("Malformed early option '%s'\n", param);
		}
+3 −0
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@ int devkmsg_sysctl_set_loglvl(const struct ctl_table *table, int write,

/* Flags for a single printk record. */
enum printk_info_flags {
	/* always show on console, ignore console_loglevel */
	LOG_FORCE_CON	= 1,
	LOG_NEWLINE	= 2,	/* text ended with a newline */
	LOG_CONT	= 8,	/* text is a fragment of a continuation line */
};
@@ -90,6 +92,7 @@ bool printk_percpu_data_ready(void);

void defer_console_output(void);
bool is_printk_legacy_deferred(void);
bool is_printk_force_console(void);

u16 printk_parse_prefix(const char *text, int *level,
			enum printk_info_flags *flags);
Loading