Skip to contentSkip to conversation

log level printk rate limit

PATCH New Steven Rostedt 1 participant 1 message Oct 27, 2006

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/6 log level printk rate limit

(Uses milliseconds instead of jiffies)

Taken from Andi Kleen's rate limit in the Linux kernel.

This keeps large amounts of prints in the HV down.

-- Steve

xen/arch/x86/mm.c +7 -3
diff -r 4a320d26fc24 xen/arch/x86/mm.c
@@ -109,9 +109,13 @@
 #include <public/memory.h>
 
 #ifdef VERBOSE
-#define MEM_LOG(_f, _a...)                                  \
-  printk("DOM%u: (file=mm.c, line=%d) " _f "\n",            \
-         current->domain->domain_id , __LINE__ , ## _a )
+#define MEM_LOG(_f, _a...)                                          \
+    do {                                                            \
+        if (printk_ratelimit()) {                                   \
+            printk("DOM%u: (file=mm.c, line=%d) " _f "\n",          \
+                   current->domain->domain_id , __LINE__ , ## _a ); \
+                }                                                   \
+    } while (0)
 #else
 #define MEM_LOG(_f, _a...) ((void)0)
 #endif
xen/drivers/char/console.c +55 -0

73 lines not on this page · raw message

xen/include/xen/lib.h +2 -0
diff -r 4a320d26fc24 xen/include/xen/lib.h
@@ -56,6 +56,8 @@ extern void panic(const char *format, ..
 extern void panic(const char *format, ...)
     __attribute__ ((format (printf, 1, 2)));
 extern long vm_assist(struct domain *, unsigned int, unsigned int);
+extern int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst);
+extern int printk_ratelimit(void);
 
 /* vsprintf.c */
 extern int sprintf(char * buf, const char * fmt, ...)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel