On 06.02.2026 21:24, [email protected] wrote:
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -1291,21 +1291,27 @@ static bool do_printk_ratelimit(unsigned int 
> ratelimit_ms,
>                                  unsigned int ratelimit_burst)
>  {
>      static DEFINE_SPINLOCK(ratelimit_lock);
> -    static unsigned long toks = 10 * 5 * 1000;
> +    static unsigned long toks;
>      static unsigned long last_msg;
>      static unsigned int missed;
>      unsigned long flags;
> -    unsigned long long now = NOW(); /* ns */
> +    unsigned long long now;
>      unsigned long ms;
>  
> +    if ( !printk_ratelimit_burst || !printk_ratelimit_burst )
> +        return true;
> +
> +    if ( !toks )
> +        toks = printk_ratelimit_burst * printk_ratelimit_ms;

Btw, instead of this I wonder whether it wouldn't be neater to use the nested
functions extension of the compiler:

    void __constructor __init init(void)
    {
        toks = printk_ratelimit_burst * printk_ratelimit_ms;
    }

If we wanted this, we'd need to record the extension use in
docs/misra/C-language-toolchain.rst, though. Plus init_constructors() would
need invoking _far_ earlier (perhaps right after command line parsing).

Jan

Reply via email to