mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Chris Down <chris@chrisdown.name>
Cc: linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	John Ogness <john.ogness@linutronix.de>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Tony Lindgren <tony.lindgren@linux.intel.com>,
	kernel-team@fb.com
Subject: Conflict with FORCE_CON: Re: [PATCH v6 04/11] printk: Support toggling per-console loglevel via syslog() and cmdline
Date: Tue, 12 Nov 2024 11:56:15 +0100	[thread overview]
Message-ID: <ZzM0T5b4uKIN0PM7@pathway.suse.cz> (raw)
In-Reply-To: <07141a533c4071c364c4f2eda6d97a9a89797e67.1730133890.git.chris@chrisdown.name>

On Mon 2024-10-28 16:45:40, Chris Down wrote:
> A new module parameter (ignore_per_console_loglevel) is added, which can
> be set via the kernel command line or at runtime through
> /sys/module/printk/parameters/ignore_per_console_loglevel. When set, the
> per-console loglevels are ignored, and the global console loglevel
> (console_loglevel) is used for all consoles.
> 
> During sysrq, we temporarily disable per-console loglevels to ensure all
> requisite messages are printed to the console. This is necessary because
> sysrq is often used in dire circumstances where access to
> /sys/class/console may not be trivially possible.

I have just pushed a patchset which removed the console_loglevel
manipulation from sysrq, see
https://lore.kernel.org/r/20241105-printk-loud-con-v2-0-bd3ecdf7b0e4@suse.com

As a result, the change in drivers/tty/sysrq.c is not needed anymore.

Note that the other patchset causes some conflict with this patchset.
But they does not seem to be hard to resolved:


1st conflict is in boot_delay_msec(). But the affected logic
has actually been moved to printk_delay(). As a result,
boot_delay_msec() might stay as it is:

static void boot_delay_msec(void)
{
	unsigned long long k;
	unsigned long timeout;

	if (boot_delay == 0 || system_state >= SYSTEM_RUNNING)
		return;

	k = (unsigned long long)loops_per_msec * boot_delay;

	timeout = jiffies + msecs_to_jiffies(boot_delay);
	while (k) {
		k--;
		cpu_relax();
		/*
		 * use (volatile) jiffies to prevent
		 * compiler reduction; loop termination via jiffies
		 * is secondary and may or may not happen.
		 */
		if (time_after(jiffies, timeout))
			break;
		touch_nmi_watchdog();
	}
}


Instead, we should add check of is_printk_force_console() into
printk_delay(). I suggest to do it the following way:

static bool suppress_message_printing_everywhere(int level)
{
	bool suppress_everywhere = true;
	struct console *con;
	int cookie;

	cookie = console_srcu_read_lock();

	for_each_console_srcu(con) {
		if (!suppress_message_printing(level, con)) {
			suppress_everywhere = false;
			break;
		}
	}
	console_srcu_read_unlock(cookie);

	return suppress_everywhere;
}

static inline void printk_delay(int level)
{
	if (!is_printk_force_console() &&
	    suppress_message_printing_everywhere(level))
		return;

	boot_delay_msec();

	if (unlikely(printk_delay_msec)) {
		int m = printk_delay_msec;

		while (m--) {
			mdelay(1);
			touch_nmi_watchdog();
		}
	}
}


2nd conflict is in printk_get_next_message(). I suggest to do
something like:

	force_con = r.info->flags & LOG_FORCE_CON;

	/*
	 * Skip records that are not forced to be printed on consoles and that
	 * has level above the console loglevel. Never suppress when used in
	 * devkmsg_read().
	 */
	if (!force_con && con && suppress_message_printing(r.info->level, con))
		goto out;


Actually, I suggested to pass @con_level instead of @con here.
In which case, we might need something like:

	if (con) {
		is_extended = console_srcu_read_flags(con) & CON_EXTENDED;
		con_level = console_srcu_read_loglevel(con);
	} else {
		/* Used only by devkmsg_read(). Show all messages there. */
		is_extended = true;
		con_level = CONSOLE_LOGLEVEL_MOTORMOUTH;
	}
[...]
	force_con = r.info->flags & LOG_FORCE_CON;

	/*
	 * Skip records that are not forced to be printed on consoles and that
	 * has level above the console loglevel.
	 */
	if (!force_con && suppress_message_printing(r.info->level, con_level))
		goto out;



I hope that you find there code snippets useful. I provide them
because I feel a bit guilty that I have already merged the other
patchset... ;-)

Best Regards,
Petr

  reply	other threads:[~2024-11-12 10:56 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-28 16:45 [PATCH v6 00/11] printk: console: Per-console loglevels Chris Down
2024-10-28 16:45 ` [PATCH v6 01/11] printk: Avoid delaying messages that aren't solicited by any console Chris Down
2024-10-28 16:45 ` [PATCH v6 02/11] printk: Use struct console for suppression and extended console state Chris Down
2024-11-08  9:57   ` Petr Mladek
2024-11-15  8:30   ` John Ogness
2024-11-20  4:17     ` Chris Down
2024-11-20 12:03       ` Petr Mladek
2024-10-28 16:45 ` [PATCH v6 03/11] printk: console: Implement core per-console loglevel infrastructure Chris Down
2024-11-08 16:10   ` Petr Mladek
2024-11-12 10:25     ` Petr Mladek
2024-11-14 16:51     ` Petr Mladek
2024-10-28 16:45 ` [PATCH v6 04/11] printk: Support toggling per-console loglevel via syslog() and cmdline Chris Down
2024-11-12 10:56   ` Petr Mladek [this message]
2024-11-14 19:28     ` Conflict with FORCE_CON: " Chris Down
2024-11-15 11:41       ` Petr Mladek
2024-11-12 12:59   ` Petr Mladek
2024-11-14 17:14   ` syslog warning: was: " Petr Mladek
2024-11-14 18:53     ` Chris Down
2024-11-15 11:36       ` Petr Mladek
2024-10-28 16:45 ` [PATCH v6 05/11] MAINTAINERS: Mark printk-basics.rst as owned by printk subsystem Chris Down
2024-10-28 23:26   ` Thomas Gleixner
2024-10-28 23:52     ` Chris Down
2024-11-12 13:00   ` Petr Mladek
2024-10-28 16:45 ` [PATCH v6 06/11] printk: console: Introduce sysfs interface for per-console loglevels Chris Down
2024-11-13 15:58   ` Petr Mladek
2024-11-13 15:59   ` register_device: was: " Petr Mladek
2024-11-14 18:41     ` Chris Down
2024-11-15  4:08       ` Greg Kroah-Hartman
2024-11-18 15:19     ` Petr Mladek
2024-11-15  4:20   ` Greg Kroah-Hartman
2024-11-15 14:09     ` Petr Mladek
2024-11-20  5:01     ` Chris Down
2024-11-20  8:43       ` John Ogness
2024-11-20 14:54         ` Petr Mladek
2024-11-20 15:29           ` John Ogness
2024-11-20 14:45       ` Petr Mladek
2025-01-10 10:27   ` Joel Granados
2025-01-15 10:31     ` Petr Mladek
2024-10-28 16:45 ` [PATCH v6 07/11] printk: Constrain hardware-addressed console checks to name position Chris Down
2024-10-29  8:26   ` Tony Lindgren
2024-11-13 16:11   ` Petr Mladek
2024-10-28 16:45 ` [PATCH v6 08/11] printk: Support setting initial console loglevel via console= on cmdline Chris Down
2024-11-14  9:11   ` Petr Mladek
2024-10-28 16:45 ` [PATCH v6 09/11] printk: Add sysctl interface to set global loglevels Chris Down
2024-11-14 16:21   ` Petr Mladek
2025-01-10 10:09     ` Joel Granados
2024-10-28 16:45 ` [PATCH v6 10/11] printk: Deprecate the kernel.printk sysctl interface Chris Down
2024-11-14 16:25   ` Petr Mladek
2024-10-28 16:46 ` [PATCH v6 11/11] printk: Purge default_console_loglevel Chris Down
2024-11-14 16:38   ` Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZzM0T5b4uKIN0PM7@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=chris@chrisdown.name \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=john.ogness@linutronix.de \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=tony.lindgren@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome