xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] console: allow log level threshold adjustments from serial console
@ 2015-09-22 12:45 Jan Beulich
  2015-09-22 13:17 ` Andrew Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2015-09-22 12:45 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell, Keir Fraser, Ian Jackson, Tim Deegan

[-- Attachment #1: Type: text/plain, Size: 3263 bytes --]

... so that one doesn't always need to reboot to see more / fewer
messages.

Note that upper thresholds are sticky, i.e. while they get adjusted
upwards when the lower threshold would otherwise end up above the upper
one, they don't get adjusted when reducing the lower one.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
TBD: Should we also add a (more flexible) sysctl?

--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -168,7 +168,7 @@ static void __init parse_guest_loglvl(ch
     _parse_loglvl(s, &xenlog_guest_lower_thresh, &xenlog_guest_upper_thresh);
 }
 
-static char * __init loglvl_str(int lvl)
+static char *loglvl_str(int lvl)
 {
     switch ( lvl )
     {
@@ -181,6 +181,66 @@ static char * __init loglvl_str(int lvl)
     return "???";
 }
 
+static int *__read_mostly upper_thresh_adj = &xenlog_upper_thresh;
+static int *__read_mostly lower_thresh_adj = &xenlog_lower_thresh;
+static const char *__read_mostly thresh_adj = "standard";
+
+static void do_toggle_guest(unsigned char key, struct cpu_user_regs *regs)
+{
+    if ( upper_thresh_adj == &xenlog_upper_thresh )
+    {
+        upper_thresh_adj = &xenlog_guest_upper_thresh;
+        lower_thresh_adj = &xenlog_guest_lower_thresh;
+        thresh_adj = "guest";
+    }
+    else
+    {
+        upper_thresh_adj = &xenlog_upper_thresh;
+        lower_thresh_adj = &xenlog_lower_thresh;
+        thresh_adj = "standard";
+    }
+    printk("'%c' pressed -> %s log level adjustments enabled\n",
+           key, thresh_adj);
+}
+
+static void do_adj_thresh(unsigned char key)
+{
+    if ( *upper_thresh_adj < *lower_thresh_adj )
+        *upper_thresh_adj = *lower_thresh_adj;
+    printk("'%c' pressed -> %s log level: %s (rate limited %s)\n",
+           key, thresh_adj, loglvl_str(*lower_thresh_adj),
+           loglvl_str(*upper_thresh_adj));
+}
+
+static void do_inc_thresh(unsigned char key, struct cpu_user_regs *regs)
+{
+    ++*lower_thresh_adj;
+    do_adj_thresh(key);
+}
+
+static void do_dec_thresh(unsigned char key, struct cpu_user_regs *regs)
+{
+    if ( *lower_thresh_adj )
+        --*lower_thresh_adj;
+    do_adj_thresh(key);
+}
+
+static struct keyhandler inc_thresh_keyhandler = {
+    .irq_callback = 1,
+    .u.irq_fn = do_inc_thresh,
+    .desc = "increase log level threshold"
+};
+static struct keyhandler dec_thresh_keyhandler = {
+    .irq_callback = 1,
+    .u.irq_fn = do_dec_thresh,
+    .desc = "decrease log level threshold"
+};
+static struct keyhandler toggle_guest_keyhandler = {
+    .irq_callback = 1,
+    .u.irq_fn = do_toggle_guest,
+    .desc = "toggle host/guest log level adjustment"
+};
+
 /*
  * ********************************************************
  * *************** ACCESS TO CONSOLE RING *****************
@@ -834,6 +894,9 @@ void __init console_endboot(void)
         xen_rx = !xen_rx;
 
     register_keyhandler('w', &dump_console_ring_keyhandler);
+    register_keyhandler('+', &inc_thresh_keyhandler);
+    register_keyhandler('-', &dec_thresh_keyhandler);
+    register_keyhandler('G', &toggle_guest_keyhandler);
 
     /* Serial input is directed to DOM0 by default. */
     switch_serial_input();




[-- Attachment #2: loglvl-adjust.patch --]
[-- Type: text/plain, Size: 3327 bytes --]

console: allow log level threshold adjustments from serial console

... so that one doesn't always need to reboot to see more / fewer
messages.

Note that upper thresholds are sticky, i.e. while they get adjusted
upwards when the lower threshold would otherwise end up above the upper
one, they don't get adjusted when reducing the lower one.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
TBD: Should we also add a (more flexible) sysctl?

--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -168,7 +168,7 @@ static void __init parse_guest_loglvl(ch
     _parse_loglvl(s, &xenlog_guest_lower_thresh, &xenlog_guest_upper_thresh);
 }
 
-static char * __init loglvl_str(int lvl)
+static char *loglvl_str(int lvl)
 {
     switch ( lvl )
     {
@@ -181,6 +181,66 @@ static char * __init loglvl_str(int lvl)
     return "???";
 }
 
+static int *__read_mostly upper_thresh_adj = &xenlog_upper_thresh;
+static int *__read_mostly lower_thresh_adj = &xenlog_lower_thresh;
+static const char *__read_mostly thresh_adj = "standard";
+
+static void do_toggle_guest(unsigned char key, struct cpu_user_regs *regs)
+{
+    if ( upper_thresh_adj == &xenlog_upper_thresh )
+    {
+        upper_thresh_adj = &xenlog_guest_upper_thresh;
+        lower_thresh_adj = &xenlog_guest_lower_thresh;
+        thresh_adj = "guest";
+    }
+    else
+    {
+        upper_thresh_adj = &xenlog_upper_thresh;
+        lower_thresh_adj = &xenlog_lower_thresh;
+        thresh_adj = "standard";
+    }
+    printk("'%c' pressed -> %s log level adjustments enabled\n",
+           key, thresh_adj);
+}
+
+static void do_adj_thresh(unsigned char key)
+{
+    if ( *upper_thresh_adj < *lower_thresh_adj )
+        *upper_thresh_adj = *lower_thresh_adj;
+    printk("'%c' pressed -> %s log level: %s (rate limited %s)\n",
+           key, thresh_adj, loglvl_str(*lower_thresh_adj),
+           loglvl_str(*upper_thresh_adj));
+}
+
+static void do_inc_thresh(unsigned char key, struct cpu_user_regs *regs)
+{
+    ++*lower_thresh_adj;
+    do_adj_thresh(key);
+}
+
+static void do_dec_thresh(unsigned char key, struct cpu_user_regs *regs)
+{
+    if ( *lower_thresh_adj )
+        --*lower_thresh_adj;
+    do_adj_thresh(key);
+}
+
+static struct keyhandler inc_thresh_keyhandler = {
+    .irq_callback = 1,
+    .u.irq_fn = do_inc_thresh,
+    .desc = "increase log level threshold"
+};
+static struct keyhandler dec_thresh_keyhandler = {
+    .irq_callback = 1,
+    .u.irq_fn = do_dec_thresh,
+    .desc = "decrease log level threshold"
+};
+static struct keyhandler toggle_guest_keyhandler = {
+    .irq_callback = 1,
+    .u.irq_fn = do_toggle_guest,
+    .desc = "toggle host/guest log level adjustment"
+};
+
 /*
  * ********************************************************
  * *************** ACCESS TO CONSOLE RING *****************
@@ -834,6 +894,9 @@ void __init console_endboot(void)
         xen_rx = !xen_rx;
 
     register_keyhandler('w', &dump_console_ring_keyhandler);
+    register_keyhandler('+', &inc_thresh_keyhandler);
+    register_keyhandler('-', &dec_thresh_keyhandler);
+    register_keyhandler('G', &toggle_guest_keyhandler);
 
     /* Serial input is directed to DOM0 by default. */
     switch_serial_input();

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] console: allow log level threshold adjustments from serial console
  2015-09-22 12:45 [PATCH] console: allow log level threshold adjustments from serial console Jan Beulich
@ 2015-09-22 13:17 ` Andrew Cooper
  2015-09-22 13:24   ` Jan Beulich
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cooper @ 2015-09-22 13:17 UTC (permalink / raw)
  To: Jan Beulich, xen-devel; +Cc: Ian Campbell, Ian Jackson, Keir Fraser, Tim Deegan


[-- Attachment #1.1: Type: text/plain, Size: 3914 bytes --]

On 22/09/15 13:45, Jan Beulich wrote:
> ... so that one doesn't always need to reboot to see more / fewer
> messages.
>
> Note that upper thresholds are sticky, i.e. while they get adjusted
> upwards when the lower threshold would otherwise end up above the upper
> one, they don't get adjusted when reducing the lower one.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> TBD: Should we also add a (more flexible) sysctl?

That would be nicer than using `xl debug-keys +++++; xl dmesg`

>
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -168,7 +168,7 @@ static void __init parse_guest_loglvl(ch
>       _parse_loglvl(s, &xenlog_guest_lower_thresh, &xenlog_guest_upper_thresh);
>   }
>   
> -static char * __init loglvl_str(int lvl)
> +static char *loglvl_str(int lvl)
>   {
>       switch ( lvl )
>       {
> @@ -181,6 +181,66 @@ static char * __init loglvl_str(int lvl)
>       return "???";
>   }
>   
> +static int *__read_mostly upper_thresh_adj = &xenlog_upper_thresh;
> +static int *__read_mostly lower_thresh_adj = &xenlog_lower_thresh;
> +static const char *__read_mostly thresh_adj = "standard";
> +
> +static void do_toggle_guest(unsigned char key, struct cpu_user_regs *regs)
> +{
> +    if ( upper_thresh_adj == &xenlog_upper_thresh )
> +    {
> +        upper_thresh_adj = &xenlog_guest_upper_thresh;
> +        lower_thresh_adj = &xenlog_guest_lower_thresh;
> +        thresh_adj = "guest";
> +    }
> +    else
> +    {
> +        upper_thresh_adj = &xenlog_upper_thresh;
> +        lower_thresh_adj = &xenlog_lower_thresh;
> +        thresh_adj = "standard";
> +    }
> +    printk("'%c' pressed -> %s log level adjustments enabled\n",
> +           key, thresh_adj);
> +}
> +
> +static void do_adj_thresh(unsigned char key)
> +{
> +    if ( *upper_thresh_adj < *lower_thresh_adj )
> +        *upper_thresh_adj = *lower_thresh_adj;
> +    printk("'%c' pressed -> %s log level: %s (rate limited %s)\n",
> +           key, thresh_adj, loglvl_str(*lower_thresh_adj),
> +           loglvl_str(*upper_thresh_adj));

It might be useful for this printk() to indicate whether it was the 
standard or the guest log level which was adjusted.

> +}
> +
> +static void do_inc_thresh(unsigned char key, struct cpu_user_regs *regs)
> +{
> +    ++*lower_thresh_adj;
> +    do_adj_thresh(key);
> +}
> +
> +static void do_dec_thresh(unsigned char key, struct cpu_user_regs *regs)
> +{
> +    if ( *lower_thresh_adj )
> +        --*lower_thresh_adj;
> +    do_adj_thresh(key);
> +}
> +
> +static struct keyhandler inc_thresh_keyhandler = {
> +    .irq_callback = 1,
> +    .u.irq_fn = do_inc_thresh,
> +    .desc = "increase log level threshold"
> +};
> +static struct keyhandler dec_thresh_keyhandler = {
> +    .irq_callback = 1,
> +    .u.irq_fn = do_dec_thresh,
> +    .desc = "decrease log level threshold"
> +};
> +static struct keyhandler toggle_guest_keyhandler = {
> +    .irq_callback = 1,
> +    .u.irq_fn = do_toggle_guest,
> +    .desc = "toggle host/guest log level adjustment"
> +};
> +

I am guessing from the looks of these that I should augment my 
keyhandler cleanup to also be able to register irq handlers from outside 
of common/keyhandler.c

~Andrew

>   /*
>    * ********************************************************
>    * *************** ACCESS TO CONSOLE RING *****************
> @@ -834,6 +894,9 @@ void __init console_endboot(void)
>           xen_rx = !xen_rx;
>   
>       register_keyhandler('w', &dump_console_ring_keyhandler);
> +    register_keyhandler('+', &inc_thresh_keyhandler);
> +    register_keyhandler('-', &dec_thresh_keyhandler);
> +    register_keyhandler('G', &toggle_guest_keyhandler);
>   
>       /* Serial input is directed to DOM0 by default. */
>       switch_serial_input();
>
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel


[-- Attachment #1.2: Type: text/html, Size: 4944 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] console: allow log level threshold adjustments from serial console
  2015-09-22 13:17 ` Andrew Cooper
@ 2015-09-22 13:24   ` Jan Beulich
  2015-09-22 13:35     ` Andrew Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2015-09-22 13:24 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Ian Campbell, xen-devel, Keir Fraser, Ian Jackson, Tim Deegan

>>> On 22.09.15 at 15:17, <andrew.cooper3@citrix.com> wrote:
> On 22/09/15 13:45, Jan Beulich wrote:
>> +static void do_adj_thresh(unsigned char key)
>> +{
>> +    if ( *upper_thresh_adj < *lower_thresh_adj )
>> +        *upper_thresh_adj = *lower_thresh_adj;
>> +    printk("'%c' pressed -> %s log level: %s (rate limited %s)\n",
>> +           key, thresh_adj, loglvl_str(*lower_thresh_adj),
>> +           loglvl_str(*upper_thresh_adj));
> 
> It might be useful for this printk() to indicate whether it was the 
> standard or the guest log level which was adjusted.

It does, by printing the string thresh_adj currently points to.

>> +static struct keyhandler inc_thresh_keyhandler = {
>> +    .irq_callback = 1,
>> +    .u.irq_fn = do_inc_thresh,
>> +    .desc = "increase log level threshold"
>> +};
>> +static struct keyhandler dec_thresh_keyhandler = {
>> +    .irq_callback = 1,
>> +    .u.irq_fn = do_dec_thresh,
>> +    .desc = "decrease log level threshold"
>> +};
>> +static struct keyhandler toggle_guest_keyhandler = {
>> +    .irq_callback = 1,
>> +    .u.irq_fn = do_toggle_guest,
>> +    .desc = "toggle host/guest log level adjustment"
>> +};
>> +
> 
> I am guessing from the looks of these that I should augment my 
> keyhandler cleanup to also be able to register irq handlers from outside 
> of common/keyhandler.c

Yeah, I was actually surprised you got away without (i.e. that all of
them lived in this one file so far).

Jan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] console: allow log level threshold adjustments from serial console
  2015-09-22 13:24   ` Jan Beulich
@ 2015-09-22 13:35     ` Andrew Cooper
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2015-09-22 13:35 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Ian Campbell, xen-devel, Keir Fraser, Ian Jackson, Tim Deegan

On 22/09/15 14:24, Jan Beulich wrote:
>>>> On 22.09.15 at 15:17, <andrew.cooper3@citrix.com> wrote:
>> On 22/09/15 13:45, Jan Beulich wrote:
>>> +static void do_adj_thresh(unsigned char key)
>>> +{
>>> +    if ( *upper_thresh_adj < *lower_thresh_adj )
>>> +        *upper_thresh_adj = *lower_thresh_adj;
>>> +    printk("'%c' pressed -> %s log level: %s (rate limited %s)\n",
>>> +           key, thresh_adj, loglvl_str(*lower_thresh_adj),
>>> +           loglvl_str(*upper_thresh_adj));
>> It might be useful for this printk() to indicate whether it was the
>> standard or the guest log level which was adjusted.
> It does, by printing the string thresh_adj currently points to.

Ah - so it does.  Sorry for the noise.

>
>>> +static struct keyhandler inc_thresh_keyhandler = {
>>> +    .irq_callback = 1,
>>> +    .u.irq_fn = do_inc_thresh,
>>> +    .desc = "increase log level threshold"
>>> +};
>>> +static struct keyhandler dec_thresh_keyhandler = {
>>> +    .irq_callback = 1,
>>> +    .u.irq_fn = do_dec_thresh,
>>> +    .desc = "decrease log level threshold"
>>> +};
>>> +static struct keyhandler toggle_guest_keyhandler = {
>>> +    .irq_callback = 1,
>>> +    .u.irq_fn = do_toggle_guest,
>>> +    .desc = "toggle host/guest log level adjustment"
>>> +};
>>> +
>> I am guessing from the looks of these that I should augment my
>> keyhandler cleanup to also be able to register irq handlers from outside
>> of common/keyhandler.c
> Yeah, I was actually surprised you got away without (i.e. that all of
> them lived in this one file so far).

It surprised me as well, but I didn't fancy adding it simply for the 
sake of adding it.

~Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-09-22 13:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-22 12:45 [PATCH] console: allow log level threshold adjustments from serial console Jan Beulich
2015-09-22 13:17 ` Andrew Cooper
2015-09-22 13:24   ` Jan Beulich
2015-09-22 13:35     ` Andrew Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).