On 06.02.2026 21:24, [email protected] wrote:
> From: Denis Mukhin <[email protected]>
>
> Simplify the code around notification of how many messages have been
> rate-limited.
"Simplify" in what dimension?
> ---
> xen/drivers/char/console.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
Diffstat says there's no difference.
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -1318,15 +1318,15 @@ static bool do_printk_ratelimit(unsigned int
> ratelimit_ms,
> spin_unlock(&ratelimit_lock);
> if ( lost )
> {
> - char lost_str[10];
> + char msg[40];
> +
> + snprintf(msg, sizeof(msg),
> + "printk: %u messages suppressed\n", lost);
Having snprintf() process a longer string means there's more runtime overhead.
> - snprintf(lost_str, sizeof(lost_str), "%u", lost);
> /* console_lock may already be acquired by printk(). */
> rspin_lock(&console_lock);
> printk_start_of_line(CONSOLE_PREFIX);
> - __putstr("printk: ");
> - __putstr(lost_str);
> - __putstr(" messages suppressed.\n");
> + __putstr(msg);
> rspin_unlock(&console_lock);
> }
> local_irq_restore(flags);
The net win therefore looks to be one __putstr() where previously we had three.
While it's less obvious then that the array size is actually large enough.
Jan