Skip to contentSkip to conversation

add printf_ratelimit to tame the wild prints

PATCH RESEND New Steven Rostedt 1 participant 1 message Oct 20, 2006

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 add printf_ratelimit to tame the wild prints

f someone turns on verbose and/or debug the hypervisor slams the serial pretty badly when starting a FV domain. So I pulled the printk_ratelimit from Linux and put it into the hypervisor. Right now the only user of it is the MEM_LOG in arch/x86/mm.c which can really spit out a lot.

Since printk_ratelimit is very helpful in the Linux kernel, I can see it being also used in HV. I changed it slightly from Linux to match the naming convention in Xen. Since printk is defined to printf, I declared the function printf_ratelimit and made a define of printk_ratelimit to just be a clone of printf_ratelimit.

-- Steve

xen/arch/x86/mm.c +7 -3
diff -r 1eccc411a141 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 +50 -0

62 lines not on this page · raw message

xen/include/xen/lib.h +3 -0
diff -r 1eccc411a141 xen/include/xen/lib.h
@@ -52,8 +52,11 @@ extern void debugtrace_printk(const char
 /* Allows us to use '%p' as general-purpose machine-word format char. */
 #define _p(_x) ((void *)(unsigned long)(_x))
 #define printk(_f , _a...) printf( _f , ## _a )
+#define printk_ratelimit() printf_ratelimit()
 extern void printf(const char *format, ...)
     __attribute__ ((format (printf, 1, 2)));
+extern int __printf_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
+extern int printf_ratelimit(void);
 extern void panic(const char *format, ...)
     __attribute__ ((format (printf, 1, 2)));
 extern long vm_assist(struct domain *, unsigned int, unsigned int);

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