Skip to contentSkip to conversation

log level setup

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

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/6 log level setup

This is the code that implements the log level settings.

It adds the thresholds and code to printk to implement the thresholds. It also adds xen_startup (still needs to be used) and oops_in_progress.

-- Steve

xen/drivers/char/console.c +53 -0
diff -r 066de2eb02f8 xen/drivers/char/console.c
@@ -57,6 +57,13 @@ static int sercon_handle = -1;
 static int sercon_handle = -1;
 
 static DEFINE_SPINLOCK(console_lock);
+
+int xenlog_upper_thresh = XENLOG_UPPER_THRESHOLD;
+int xenlog_lower_thresh = XENLOG_LOWER_THRESHOLD;
+int xenlog_guest_upper_thresh = XENLOG_GUEST_UPPER_THRESHOLD;
+int xenlog_guest_lower_thresh = XENLOG_GUEST_LOWER_THRESHOLD;
+
+int xen_startup = 1;
 
 /*
  * ********************************************************
@@ -307,6 +314,10 @@ void printk(const char *fmt, ...)
     va_list       args;
     char         *p, *q;
     unsigned long flags;
+    int           level = XENLOG_DEFAULT;
+    int           upper_thresh = xenlog_upper_thresh;
+    int           lower_thresh = xenlog_lower_thresh;
+    int           print_regardless = xen_startup;
 
     spin_lock_irqsave(&console_lock, flags);
 
@@ -315,6 +326,42 @@ void printk(const char *fmt, ...)
     va_end(args);        
 
     p = buf;
+
+    /*
+     * Is this print caused by a guest?
+     */
+    if (strncmp("<G>", p, 3) == 0)
+    {
+        upper_thresh = xenlog_guest_upper_thresh;
+        lower_thresh = xenlog_guest_lower_thresh;
+        level = XENLOG_GUEST_DEFAULT;
+        p += 3;
+    }
+
+    if ( (p[0] == '<') && (p[1] >= '0')
+         && (p[1] <= ('0' + XENLOG_MAX))
+         && (p[2] == '>') )
+    {
+        level = p[1] - '0';
+        p += 3;
+    }
+
+    if ( print_regardless )
+    {
+        goto printme;
+    }
+
+    if ( level > upper_thresh )
+    {
+        goto out;
+    }
+
+    if ( (level >= lower_thresh) && (!printk_ratelimit()) )
+    {
+        goto out;
+    }
+
+ printme:
     while ( (q = strchr(p, '\n')) != NULL )
     {
         *q = '\0';
@@ -334,6 +381,7 @@ void printk(const char *fmt, ...)
         start_of_line = 0;
     }
 
+ out:
     spin_unlock_irqrestore(&console_lock, flags);
 }
 
@@ -419,6 +467,11 @@ void console_endboot(void)
 
     /* Serial input is directed to DOM0 by default. */
     switch_serial_input();
+
+    /*
+     * Now we implement the thresholds.
+     */
+    xen_startup = 0;
 }
 
 void console_force_unlock(void)
xen/include/xen/config.h +106 -13

132 lines not on this page · raw message

xen/include/xen/lib.h +6 -0
diff -r 066de2eb02f8 xen/include/xen/lib.h
@@ -58,6 +58,12 @@ extern long vm_assist(struct domain *, u
 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);
+extern int xenlog_upper_thresh;
+extern int xenlog_lower_thresh;
+extern int xenlog_guest_upper_thresh;
+extern int xenlog_guest_lower_thresh;
+
+extern int xen_startup;
 
 /* vsprintf.c */
 extern int sprintf(char * buf, const char * fmt, ...)

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