All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] xen/console: remove __printk_ratelimit()
@ 2025-07-25 21:24 dmkhn
  2025-07-26  9:20 ` Julien Grall
  2025-08-06 11:09 ` Roger Pau Monné
  0 siblings, 2 replies; 11+ messages in thread
From: dmkhn @ 2025-07-25 21:24 UTC (permalink / raw)
  To: xen-devel
  Cc: andrew.cooper3, anthony.perard, jbeulich, julien, michal.orzel,
	roger.pau, sstabellini, dmukhin

From: Denis Mukhin <dmukhin@ford.com> 

__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@ford.com>
---
 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;
+
 /*
  * 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)
 {
     static DEFINE_SPINLOCK(ratelimit_lock);
     static unsigned long toks = 10 * 5 * 1000;
@@ -1288,13 +1294,13 @@ int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst)
     spin_lock_irqsave(&ratelimit_lock, flags);
     toks += ms - last_msg;
     last_msg = ms;
-    if ( toks > (ratelimit_burst * ratelimit_ms))
-        toks = ratelimit_burst * ratelimit_ms;
-    if ( toks >= ratelimit_ms )
+    if ( toks > (printk_ratelimit_burst * printk_ratelimit_ms) )
+        toks = printk_ratelimit_burst * printk_ratelimit_ms;
+    if ( toks >= printk_ratelimit_ms )
     {
         int lost = missed;
         missed = 0;
-        toks -= ratelimit_ms;
+        toks -= printk_ratelimit_ms;
         spin_unlock(&ratelimit_lock);
         if ( lost )
         {
@@ -1316,17 +1322,6 @@ int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst)
     return 0;
 }
 
-/* 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;
-
-int printk_ratelimit(void)
-{
-    return __printk_ratelimit(printk_ratelimit_ms, printk_ratelimit_burst);
-}
-
 /*
  * **************************************************************
  * ********************** Error-report **************************
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index e63ec5039f92..a33c25dd1610 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -80,7 +80,6 @@ extern void guest_printk(const struct domain *d, const char *fmt, ...)
     __attribute__ ((format (printf, 2, 3)));
 extern void noreturn panic(const char *fmt, ...)
     __attribute__ ((format (printf, 1, 2)));
-extern int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst);
 extern int printk_ratelimit(void);
 
 #define gprintk(lvl, fmt, args...) \
-- 
2.34.1




^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-08-06 11:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-25 21:24 [PATCH v1] xen/console: remove __printk_ratelimit() dmkhn
2025-07-26  9:20 ` Julien Grall
2025-07-26 20:56   ` dmkhn
2025-07-28  9:32   ` Jan Beulich
2025-07-29 22:18     ` dmkhn
2025-07-30  5:35       ` Jan Beulich
2025-07-30 18:06         ` dmkhn
2025-07-31  6:23           ` Jan Beulich
2025-07-31 21:28             ` dmkhn
2025-08-01  7:32               ` Jan Beulich
2025-08-06 11:09 ` Roger Pau Monné

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.