[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1] xen/console: remove __printk_ratelimit()



On Fri, Jul 25, 2025 at 09:24:48PM +0000, dmkhn@xxxxxxxxx wrote:
> From: Denis Mukhin <dmukhin@xxxxxxxx> 
> 
> __printk_ratelimit() is never used outside of the console driver.
> Remove it from the lib.h and merge with the public printk_ratelimit().
> 
> Not a functional change.
> 
> Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
> ---
>  xen/drivers/char/console.c | 29 ++++++++++++-----------------
>  xen/include/xen/lib.h      |  1 -
>  2 files changed, 12 insertions(+), 18 deletions(-)
> 
> diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
> index 75fa033ce74d..80f8f2ed1bae 100644
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -979,7 +979,7 @@ static void vprintk_common(const char *fmt, va_list args, 
> const char *prefix)
>      char         *p, *q;
>      unsigned long flags;
>  
> -    /* console_lock can be acquired recursively from __printk_ratelimit(). */
> +    /* console_lock can be acquired recursively from printk_ratelimit(). */
>      local_irq_save(flags);
>      rspin_lock(&console_lock);
>      state = &this_cpu(state);
> @@ -1266,13 +1266,19 @@ void console_end_sync(void)
>      atomic_dec(&print_everything);
>  }
>  
> +/* minimum time in ms between messages */
> +static int __read_mostly printk_ratelimit_ms = 5 * 1000;
> +
> +/* number of messages we send before ratelimiting */
> +static int __read_mostly printk_ratelimit_burst = 10;

You possibly want to make them const for the time being?

It's unclear whether we would like to dynamically change those values
in the future.  Given the current usage they would better be const.

> +
>  /*
>   * printk rate limiting, lifted from Linux.
>   *
>   * This enforces a rate limit: not more than one kernel message
>   * every printk_ratelimit_ms (millisecs).
>   */
> -int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst)
> +int printk_ratelimit(void)

As suggested by Jan, I would just make this static and remove the
prototype from lib.h.  That results in less changes, and allows to
more easily export the fine grained function in the future if we had a
need to.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.