Actually printing everything out during boot can be rather useful. What's
the downside? I think we should keep the current behaviour as default and
maybe add a 'quiet_boot' option or similar.
-- Keir
On 7/2/07 05:38, "Alex Williamson" <alex.williamson@xxxxxx> wrote:
>
> We currently print everything during xen bootup regardless of what
> the user has specified on the boot line with loglvl. This seems wrong
> and makes using XENLOG_DEBUG and XENLOG_INFO much less useful. We also
> provide no means (that I could find) to change the console log level at
> runtime. The patch below changes this to only print out console
> messages below the upper threshold during bootup, and toggles rate
> limiting at the end of the xen boot. It also adds a simple inc/dec
> capability to the keyhandler to change the lower thresholds at runtime.
> The cmpxchgs are probably overkill, but maybe another interface will
> want to use these someday. Thanks,
>
> Alex
>
> Signed-off-by: Alex Williamson <alex.williamson@xxxxxx>
> ---
>
> diff -r 7efb3a06c56a xen/common/keyhandler.c
> --- a/xen/common/keyhandler.c Tue Feb 06 15:20:26 2007 -0700
> +++ b/xen/common/keyhandler.c Tue Feb 06 21:21:13 2007 -0700
> @@ -258,6 +258,25 @@ extern void perfc_reset(unsigned char ke
> extern void perfc_reset(unsigned char key);
> #endif
>
> +static void change_loglvl(unsigned char key)
> +{
> + switch ( key )
> + {
> + case '+':
> + console_inc_loglvl();
> + break;
> + case '-':
> + console_dec_loglvl();
> + break;
> + case 'G':
> + console_inc_guest_loglvl();
> + break;
> + case 'g':
> + console_dec_guest_loglvl();
> + break;
> + }
> +}
> +
> static void do_debug_key(unsigned char key, struct cpu_user_regs *regs)
> {
> (void)debugger_trap_fatal(0xf001, regs);
> @@ -290,6 +309,15 @@ void initialize_keytable(void)
> register_keyhandler(
> 'P', perfc_reset, "reset performance counters");
> #endif
> +
> + register_keyhandler(
> + '+', change_loglvl, "increase xen console log level");
> + register_keyhandler(
> + '-', change_loglvl, "decrease xen console log level");
> + register_keyhandler(
> + 'G', change_loglvl, "increase xen guest log level");
> + register_keyhandler(
> + 'g', change_loglvl, "decrease xen guest log level");
>
> register_irq_keyhandler('%', do_debug_key, "Trap to xendbg");
> }
> diff -r 7efb3a06c56a xen/drivers/char/console.c
> --- a/xen/drivers/char/console.c Tue Feb 06 15:20:26 2007 -0700
> +++ b/xen/drivers/char/console.c Tue Feb 06 22:06:24 2007 -0700
> @@ -102,7 +102,8 @@ custom_param("loglvl", parse_loglvl);
> custom_param("loglvl", parse_loglvl);
> custom_param("guest_loglvl", parse_guest_loglvl);
>
> -static atomic_t print_everything = ATOMIC_INIT(1);
> +static atomic_t print_everything = ATOMIC_INIT(0);
> +static int ratelimit_active;
>
> #define ___parse_loglvl(s, ps, lvlstr, lvlnum) \
> if ( !strncmp((s), (lvlstr), strlen(lvlstr)) ) { \
> @@ -151,6 +152,58 @@ static char *loglvl_str(int lvl)
> case 4: return "All";
> }
> return "???";
> +}
> +
> +void console_inc_loglvl(void)
> +{
> + int loglvl;
> +
> + do {
> + loglvl = xenlog_lower_thresh;
> + if (loglvl >= 4)
> + break;
> + } while (cmpxchg(&xenlog_lower_thresh, loglvl, loglvl + 1) != loglvl);
> +
> + printk("Xen Loglevel: %s\n", loglvl_str(xenlog_lower_thresh));
> +}
> +
> +void console_dec_loglvl(void)
> +{
> + int loglvl;
> +
> + do {
> + loglvl = xenlog_lower_thresh;
> + if (loglvl <= 0)
> + break;
> + } while (cmpxchg(&xenlog_lower_thresh, loglvl, loglvl - 1) != loglvl);
> +
> + printk("Xen Loglevel: %s\n", loglvl_str(xenlog_lower_thresh));
> +}
> +
> +void console_inc_guest_loglvl(void)
> +{
> + int loglvl;
> +
> + do {
> + loglvl = xenlog_guest_lower_thresh;
> + if (loglvl >= 4)
> + break;
> + } while (cmpxchg(&xenlog_guest_lower_thresh, loglvl, loglvl + 1) !=
> loglvl);
> +
> + printk("Xen Guest Loglevel: %s\n",
> loglvl_str(xenlog_guest_lower_thresh));
> +}
> +
> +void console_dec_guest_loglvl(void)
> +{
> + int loglvl;
> +
> + do {
> + loglvl = xenlog_guest_lower_thresh;
> + if (loglvl <= 0)
> + break;
> + } while (cmpxchg(&xenlog_guest_lower_thresh, loglvl, loglvl - 1) !=
> loglvl);
> +
> + printk("Xen Guest Loglevel: %s\n",
> loglvl_str(xenlog_guest_lower_thresh));
> }
>
> /*
> @@ -422,9 +475,9 @@ static int printk_prefix_check(char *p,
>
> *pp = p;
>
> - return ((atomic_read(&print_everything) != 0) ||
> - (loglvl < lower_thresh) ||
> - ((loglvl < upper_thresh) && printk_ratelimit()));
> + return (atomic_read(&print_everything) != 0 ||
> + loglvl < lower_thresh ||
> + (loglvl < upper_thresh && printk_ratelimit()));
> }
>
> void printk(const char *fmt, ...)
> @@ -570,8 +623,8 @@ void console_endboot(void)
> /* Serial input is directed to DOM0 by default. */
> switch_serial_input();
>
> - /* Now we implement the logging thresholds. */
> - console_end_log_everything();
> + /* Now we implement the rate limit */
> + ratelimit_active = 1;
> }
>
> void console_start_log_everything(void)
> @@ -676,6 +729,9 @@ int printk_ratelimit_burst = 10;
>
> int printk_ratelimit(void)
> {
> + if (!ratelimit_active)
> + return 1;
> +
> return __printk_ratelimit(printk_ratelimit_ms, printk_ratelimit_burst);
> }
>
> diff -r 7efb3a06c56a xen/include/xen/console.h
> --- a/xen/include/xen/console.h Tue Feb 06 15:20:26 2007 -0700
> +++ b/xen/include/xen/console.h Tue Feb 06 20:32:30 2007 -0700
> @@ -29,6 +29,11 @@ void console_start_log_everything(void);
> void console_start_log_everything(void);
> void console_end_log_everything(void);
>
> +void console_inc_loglvl(void);
> +void console_dec_loglvl(void);
> +void console_inc_guest_loglvl(void);
> +void console_dec_guest_loglvl(void);
> +
> /*
> * Steal output from the console. Returns +ve identifier, else -ve error.
> * Takes the handle of the serial line to steal, and steal callback function.
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|