xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@novell.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] reduce '0' debug key's global impact
Date: Tue, 04 May 2010 16:48:14 +0100	[thread overview]
Message-ID: <4BE05DDE0200007800001317@vpn.id2.novell.com> (raw)

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

On large systems, dumping state may cause time management to get
stalled for so long a period that it wouldn't recover. Therefore add
a tasklet based alternative mechanism to handle Dom0 state dumps.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

--- 2010-05-04.orig/xen/common/keyhandler.c	2010-04-22 14:43:25.000000000 +0200
+++ 2010-05-04/xen/common/keyhandler.c	2010-05-04 13:21:53.000000000 +0200
@@ -19,6 +19,7 @@
 
 static struct keyhandler *key_table[256];
 static unsigned char keypress_key;
+static bool_t alt_key_handling;
 
 char keyhandler_scratch[1024];
 
@@ -115,6 +116,26 @@ static struct keyhandler dump_registers_
     .desc = "dump registers"
 };
 
+static DECLARE_TASKLET(dump_dom0_tasklet, NULL, 0);
+
+static void dump_dom0_action(unsigned long arg)
+{
+    struct vcpu *v = (void *)arg;
+
+    for ( ; ; ) {
+        vcpu_show_execution_state(v);
+        v = v->next_in_list;
+        if ( !v )
+            break;
+        if ( softirq_pending(smp_processor_id()) )
+        {
+            dump_dom0_tasklet.data = (unsigned long)v;
+            tasklet_schedule_on_cpu(&dump_dom0_tasklet, v->processor);
+            break;
+        }
+    }
+}
+
 static void dump_dom0_registers(unsigned char key)
 {
     struct vcpu *v;
@@ -125,7 +146,17 @@ static void dump_dom0_registers(unsigned
     printk("'%c' pressed -> dumping Dom0's registers\n", key);
 
     for_each_vcpu ( dom0, v )
+    {
+        if ( alt_key_handling && softirq_pending(smp_processor_id()) )
+        {
+            tasklet_kill(&dump_dom0_tasklet);
+            tasklet_init(&dump_dom0_tasklet, dump_dom0_action,
+                         (unsigned long)v);
+            tasklet_schedule_on_cpu(&dump_dom0_tasklet, v->processor);
+            return;
+        }
         vcpu_show_execution_state(v);
+    }
 }
 
 static struct keyhandler dump_dom0_registers_keyhandler = {
@@ -425,8 +456,28 @@ static struct keyhandler do_debug_key_ke
     .desc = "trap to xendbg"
 };
 
+static void do_toggle_alt_key(unsigned char key, struct cpu_user_regs *regs)
+{
+    alt_key_handling = !alt_key_handling;
+    printk("'%c' pressed -> using %s key handling\n", key,
+           alt_key_handling ? "alternative" : "normal");
+}
+
+static struct keyhandler toggle_alt_keyhandler = {
+    .irq_callback = 1,
+    .u.irq_fn = do_toggle_alt_key,
+    .desc = "toggle alternative key handling"
+};
+
 void __init initialize_keytable(void)
 {
+    if ( num_present_cpus() > 16 )
+    {
+        alt_key_handling = 1;
+        printk(XENLOG_INFO "Defaulting to alternative key handling; "
+               "send 'A' to switch to normal mode.\n");
+    }
+    register_keyhandler('A', &toggle_alt_keyhandler);
     register_keyhandler('d', &dump_registers_keyhandler);
     register_keyhandler('h', &show_handlers_keyhandler);
     register_keyhandler('q', &dump_domains_keyhandler);




[-- Attachment #2: keyhandler-alternative.patch --]
[-- Type: text/plain, Size: 2954 bytes --]

On large systems, dumping state may cause time management to get
stalled for so long a period that it wouldn't recover. Therefore add
a tasklet based alternative mechanism to handle Dom0 state dumps.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

--- 2010-05-04.orig/xen/common/keyhandler.c	2010-04-22 14:43:25.000000000 +0200
+++ 2010-05-04/xen/common/keyhandler.c	2010-05-04 13:21:53.000000000 +0200
@@ -19,6 +19,7 @@
 
 static struct keyhandler *key_table[256];
 static unsigned char keypress_key;
+static bool_t alt_key_handling;
 
 char keyhandler_scratch[1024];
 
@@ -115,6 +116,26 @@ static struct keyhandler dump_registers_
     .desc = "dump registers"
 };
 
+static DECLARE_TASKLET(dump_dom0_tasklet, NULL, 0);
+
+static void dump_dom0_action(unsigned long arg)
+{
+    struct vcpu *v = (void *)arg;
+
+    for ( ; ; ) {
+        vcpu_show_execution_state(v);
+        v = v->next_in_list;
+        if ( !v )
+            break;
+        if ( softirq_pending(smp_processor_id()) )
+        {
+            dump_dom0_tasklet.data = (unsigned long)v;
+            tasklet_schedule_on_cpu(&dump_dom0_tasklet, v->processor);
+            break;
+        }
+    }
+}
+
 static void dump_dom0_registers(unsigned char key)
 {
     struct vcpu *v;
@@ -125,7 +146,17 @@ static void dump_dom0_registers(unsigned
     printk("'%c' pressed -> dumping Dom0's registers\n", key);
 
     for_each_vcpu ( dom0, v )
+    {
+        if ( alt_key_handling && softirq_pending(smp_processor_id()) )
+        {
+            tasklet_kill(&dump_dom0_tasklet);
+            tasklet_init(&dump_dom0_tasklet, dump_dom0_action,
+                         (unsigned long)v);
+            tasklet_schedule_on_cpu(&dump_dom0_tasklet, v->processor);
+            return;
+        }
         vcpu_show_execution_state(v);
+    }
 }
 
 static struct keyhandler dump_dom0_registers_keyhandler = {
@@ -425,8 +456,28 @@ static struct keyhandler do_debug_key_ke
     .desc = "trap to xendbg"
 };
 
+static void do_toggle_alt_key(unsigned char key, struct cpu_user_regs *regs)
+{
+    alt_key_handling = !alt_key_handling;
+    printk("'%c' pressed -> using %s key handling\n", key,
+           alt_key_handling ? "alternative" : "normal");
+}
+
+static struct keyhandler toggle_alt_keyhandler = {
+    .irq_callback = 1,
+    .u.irq_fn = do_toggle_alt_key,
+    .desc = "toggle alternative key handling"
+};
+
 void __init initialize_keytable(void)
 {
+    if ( num_present_cpus() > 16 )
+    {
+        alt_key_handling = 1;
+        printk(XENLOG_INFO "Defaulting to alternative key handling; "
+               "send 'A' to switch to normal mode.\n");
+    }
+    register_keyhandler('A', &toggle_alt_keyhandler);
     register_keyhandler('d', &dump_registers_keyhandler);
     register_keyhandler('h', &show_handlers_keyhandler);
     register_keyhandler('q', &dump_domains_keyhandler);

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

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

                 reply	other threads:[~2010-05-04 15:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BE05DDE0200007800001317@vpn.id2.novell.com \
    --to=jbeulich@novell.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).