Commit 07a22b61 authored by Petr Mladek's avatar Petr Mladek
Browse files

Revert "printk: add functions to prefer direct printing"

This reverts commit 2bb2b7b5.

The testing of 5.19 release candidates revealed missing synchronization
between early and regular console functionality.

It would be possible to start the console kthreads later as a workaround.
But it is clear that console lock serialized console drivers between
each other. It opens a big area of possible problems that were not
considered by people involved in the development and review.

printk() is crucial for debugging kernel issues and console output is
very important part of it. The number of consoles is huge and a proper
review would take some time. As a result it need to be reverted for 5.19.

Link: https://lore.kernel.org/r/YrBdjVwBOVgLfHyb@alley


Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20220623145157.21938-7-pmladek@suse.com
parent 5831788a
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -578,7 +578,6 @@ void __handle_sysrq(int key, bool check_mask)

	rcu_sysrq_start();
	rcu_read_lock();
	printk_prefer_direct_enter();
	/*
	 * Raise the apparent loglevel to maximum so that the sysrq header
	 * is shown to provide the user with positive feedback.  We do not
@@ -620,7 +619,6 @@ void __handle_sysrq(int key, bool check_mask)
		pr_cont("\n");
		console_loglevel = orig_log_level;
	}
	printk_prefer_direct_exit();
	rcu_read_unlock();
	rcu_sysrq_end();

+0 −11
Original line number Diff line number Diff line
@@ -170,9 +170,6 @@ extern void __printk_safe_exit(void);
#define printk_deferred_enter __printk_safe_enter
#define printk_deferred_exit __printk_safe_exit

extern void printk_prefer_direct_enter(void);
extern void printk_prefer_direct_exit(void);

extern bool pr_flush(int timeout_ms, bool reset_on_progress);

/*
@@ -225,14 +222,6 @@ static inline void printk_deferred_exit(void)
{
}

static inline void printk_prefer_direct_enter(void)
{
}

static inline void printk_prefer_direct_exit(void)
{
}

static inline bool pr_flush(int timeout_ms, bool reset_on_progress)
{
	return true;
+1 −10
Original line number Diff line number Diff line
@@ -127,8 +127,6 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
	 * complain:
	 */
	if (sysctl_hung_task_warnings) {
		printk_prefer_direct_enter();

		if (sysctl_hung_task_warnings > 0)
			sysctl_hung_task_warnings--;
		pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n",
@@ -144,8 +142,6 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)

		if (sysctl_hung_task_all_cpu_backtrace)
			hung_task_show_all_bt = true;

		printk_prefer_direct_exit();
	}

	touch_nmi_watchdog();
@@ -208,17 +204,12 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
	}
 unlock:
	rcu_read_unlock();
	if (hung_task_show_lock) {
		printk_prefer_direct_enter();
	if (hung_task_show_lock)
		debug_show_all_locks();
		printk_prefer_direct_exit();
	}

	if (hung_task_show_all_bt) {
		hung_task_show_all_bt = false;
		printk_prefer_direct_enter();
		trigger_all_cpu_backtrace();
		printk_prefer_direct_exit();
	}

	if (hung_task_call_panic)
+0 −4
Original line number Diff line number Diff line
@@ -579,8 +579,6 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
{
	disable_trace_on_warning();

	printk_prefer_direct_enter();

	if (file)
		pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS\n",
			raw_smp_processor_id(), current->pid, file, line,
@@ -610,8 +608,6 @@ void __warn(const char *file, int line, void *caller, unsigned taint,

	/* Just a warning, don't kill lockdep. */
	add_taint(taint, LOCKDEP_STILL_OK);

	printk_prefer_direct_exit();
}

#ifndef __WARN_FLAGS
+0 −28
Original line number Diff line number Diff line
@@ -362,34 +362,6 @@ static int console_msg_format = MSG_FORMAT_DEFAULT;
static DEFINE_MUTEX(syslog_lock);

#ifdef CONFIG_PRINTK
static atomic_t printk_prefer_direct = ATOMIC_INIT(0);

/**
 * printk_prefer_direct_enter - cause printk() calls to attempt direct
 *                              printing to all enabled consoles
 *
 * Since it is not possible to call into the console printing code from any
 * context, there is no guarantee that direct printing will occur.
 *
 * This globally effects all printk() callers.
 *
 * Context: Any context.
 */
void printk_prefer_direct_enter(void)
{
	atomic_inc(&printk_prefer_direct);
}

/**
 * printk_prefer_direct_exit - restore printk() behavior
 *
 * Context: Any context.
 */
void printk_prefer_direct_exit(void)
{
	WARN_ON(atomic_dec_if_positive(&printk_prefer_direct) < 0);
}

DECLARE_WAIT_QUEUE_HEAD(log_wait);
/* All 3 protected by @syslog_lock. */
/* the next printk record to read by syslog(READ) or /proc/kmsg */
Loading