rpms/kernel/devel xen-printf-rate-limit.patch, NONE, 1.1 kernel-2.6.spec, 1.2681, 1.2682
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Wed Sep 20 14:55:14 UTC 2006
Author: quintela
Update of /cvs/dist/rpms/kernel/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv30812
Modified Files:
kernel-2.6.spec
Added Files:
xen-printf-rate-limit.patch
Log Message:
xen printf rate limit patch (rostedt)
xen-printf-rate-limit.patch:
arch/x86/mm.c | 10 ++++++---
drivers/char/console.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
include/xen/lib.h | 3 ++
3 files changed, 60 insertions(+), 3 deletions(-)
--- NEW FILE xen-printf-rate-limit.patch ---
Index: xen/arch/x86/mm.c
===================================================================
--- xen.orig/arch/x86/mm.c
+++ 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
Index: xen/drivers/char/console.c
===================================================================
--- xen.orig/drivers/char/console.c
+++ xen/drivers/char/console.c
@@ -4,6 +4,10 @@
* Emergency console I/O for Xen and the domain-0 guest OS.
*
* Copyright (c) 2002-2004, K A Fraser.
+ *
+ * Added printf_ratelimit
+ * Taken from Linux - Author: Andy Kleen (net_ratelimit)
+ * Ported to Xen - Steven Rostedt - Red Hat
*/
#include <stdarg.h>
@@ -420,6 +424,52 @@ int console_getc(void)
return serial_getc(sercon_handle);
}
+/*
+ * printk rate limiting, lifted from Linux.
+ *
+ * This enforces a rate limit: not more than one kernel message
+ * every printf_ratelimit_jiffies.
+ */
+int __printf_ratelimit(int ratelimit_jiffies, int ratelimit_burst)
+{
+ static DEFINE_SPINLOCK(ratelimit_lock);
+ static unsigned long toks = 10 * 5 * HZ;
+ static unsigned long last_msg;
+ static int missed;
+ unsigned long flags;
+ unsigned long now = jiffies;
+
+ spin_lock_irqsave(&ratelimit_lock, flags);
+ toks += now - last_msg;
+ last_msg = now;
+ if (toks > (ratelimit_burst * ratelimit_jiffies))
+ toks = ratelimit_burst * ratelimit_jiffies;
+ if (toks >= ratelimit_jiffies) {
+ int lost = missed;
+
+ missed = 0;
+ toks -= ratelimit_jiffies;
+ spin_unlock_irqrestore(&ratelimit_lock, flags);
+ if (lost)
+ printk("printk: %d messages suppressed.\n", lost);
+ return 1;
+ }
+ missed++;
+ spin_unlock_irqrestore(&ratelimit_lock, flags);
+ return 0;
+}
+
+/* minimum time in jiffies between messages */
+int printf_ratelimit_jiffies = 5 * HZ;
+
+/* number of messages we send before ratelimiting */
+int printf_ratelimit_burst = 10;
+
+int printf_ratelimit(void)
+{
+ return __printf_ratelimit(printf_ratelimit_jiffies,
+ printf_ratelimit_burst);
+}
/*
* **************************************************************
Index: xen/include/xen/lib.h
===================================================================
--- xen.orig/include/xen/lib.h
+++ 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);
Index: kernel-2.6.spec
===================================================================
RCS file: /cvs/dist/rpms/kernel/devel/kernel-2.6.spec,v
retrieving revision 1.2681
retrieving revision 1.2682
diff -u -r1.2681 -r1.2682
--- kernel-2.6.spec 20 Sep 2006 14:48:29 -0000 1.2681
+++ kernel-2.6.spec 20 Sep 2006 14:55:07 -0000 1.2682
@@ -526,6 +526,7 @@
Patch10000: linux-2.6-compile-fixes.patch
# Xen hypervisor patches (20000+)
+Patch20000: xen-printf-rate-limit.patch
# END OF PATCH DEFINITIONS
@@ -1189,6 +1190,7 @@
%setup -D -T -q -n %{name}-%{version} -a1
cd xen
# Any necessary hypervisor patches go here
+%patch20000 -p1
%endif
@@ -1899,6 +1901,7 @@
%changelog
* Wed Sep 20 2006 Juan Quintela <quintela at redhat.com>
+- xen HV printf rate limit (rostedt).
- xen HV update to xen-unstable cset11540:9837ff37e354
- xen-update:
* linux-2.6 changeset: 34294:dc1d277d06e0
More information about the fedora-cvs-commits
mailing list