debuggers.hg
changeset 20975:bd0d6ec8caaa
keyhandler: global shared scratch space for temporary strings
Put one static definition in one place and we can make it as big as we
think reasonable.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Put one static definition in one place and we can make it as big as we
think reasonable.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Thu Feb 11 21:08:06 2010 +0000 (2010-02-11) |
parents | 9a9ea52c3680 |
children | 0e8557c6a47a |
files | xen/common/keyhandler.c xen/common/sched_credit.c xen/include/xen/keyhandler.h |
line diff
1.1 --- a/xen/common/keyhandler.c Thu Feb 11 19:51:15 2010 +0000 1.2 +++ b/xen/common/keyhandler.c Thu Feb 11 21:08:06 2010 +0000 1.3 @@ -20,19 +20,18 @@ 1.4 static struct keyhandler *key_table[256]; 1.5 static unsigned char keypress_key; 1.6 1.7 +char keyhandler_scratch[100]; 1.8 + 1.9 static void keypress_action(unsigned long unused) 1.10 { 1.11 - unsigned char key = keypress_key; 1.12 - console_start_log_everything(); 1.13 - if ( key_table[key] != NULL ) 1.14 - (*key_table[key]->u.fn)(key); 1.15 - console_end_log_everything(); 1.16 + handle_keypress(keypress_key, NULL); 1.17 } 1.18 1.19 static DECLARE_TASKLET(keypress_tasklet, keypress_action, 0); 1.20 1.21 void handle_keypress(unsigned char key, struct cpu_user_regs *regs) 1.22 { 1.23 + static bool_t executing_handler; 1.24 struct keyhandler *h; 1.25 1.26 if ( (h = key_table[key]) == NULL ) 1.27 @@ -40,9 +39,18 @@ void handle_keypress(unsigned char key, 1.28 1.29 if ( !in_irq() || h->irq_callback ) 1.30 { 1.31 + /* 1.32 + * No concurrent handler execution: prevents garbled console and 1.33 + * protects keyhandler_scratch[]. 1.34 + */ 1.35 + if ( test_and_set_bool(executing_handler) ) 1.36 + return; 1.37 + wmb(); 1.38 console_start_log_everything(); 1.39 - (*h->u.irq_fn)(key, regs); 1.40 + h->irq_callback ? (*h->u.irq_fn)(key, regs) : (*h->u.fn)(key); 1.41 console_end_log_everything(); 1.42 + wmb(); 1.43 + executing_handler = 0; 1.44 } 1.45 else 1.46 { 1.47 @@ -174,7 +182,7 @@ static void dump_domains(unsigned char k 1.48 struct domain *d; 1.49 struct vcpu *v; 1.50 s_time_t now = NOW(); 1.51 - char tmpstr[100]; 1.52 +#define tmpstr keyhandler_scratch 1.53 1.54 printk("'%c' pressed -> dumping domain info (now=0x%X:%08X)\n", key, 1.55 (u32)(now>>32), (u32)now); 1.56 @@ -234,6 +242,7 @@ static void dump_domains(unsigned char k 1.57 } 1.58 1.59 rcu_read_unlock(&domlist_read_lock); 1.60 +#undef tmpstr 1.61 } 1.62 1.63 static struct keyhandler dump_domains_keyhandler = {
2.1 --- a/xen/common/sched_credit.c Thu Feb 11 19:51:15 2010 +0000 2.2 +++ b/xen/common/sched_credit.c Thu Feb 11 21:08:06 2010 +0000 2.3 @@ -21,6 +21,7 @@ 2.4 #include <xen/softirq.h> 2.5 #include <asm/atomic.h> 2.6 #include <xen/errno.h> 2.7 +#include <xen/keyhandler.h> 2.8 2.9 /* 2.10 * CSCHED_STATS 2.11 @@ -1241,7 +1242,7 @@ csched_dump_pcpu(int cpu) 2.12 struct csched_pcpu *spc; 2.13 struct csched_vcpu *svc; 2.14 int loop; 2.15 - char cpustr[100]; 2.16 +#define cpustr keyhandler_scratch 2.17 2.18 spc = CSCHED_PCPU(cpu); 2.19 runq = &spc->runq; 2.20 @@ -1269,6 +1270,7 @@ csched_dump_pcpu(int cpu) 2.21 csched_dump_vcpu(svc); 2.22 } 2.23 } 2.24 +#undef cpustr 2.25 } 2.26 2.27 static void 2.28 @@ -1276,7 +1278,7 @@ csched_dump(void) 2.29 { 2.30 struct list_head *iter_sdom, *iter_svc; 2.31 int loop; 2.32 - char idlers_buf[100]; 2.33 +#define idlers_buf keyhandler_scratch 2.34 2.35 printk("info:\n" 2.36 "\tncpus = %u\n" 2.37 @@ -1323,6 +1325,7 @@ csched_dump(void) 2.38 csched_dump_vcpu(svc); 2.39 } 2.40 } 2.41 +#undef idlers_buf 2.42 } 2.43 2.44 static void
3.1 --- a/xen/include/xen/keyhandler.h Thu Feb 11 19:51:15 2010 +0000 3.2 +++ b/xen/include/xen/keyhandler.h Thu Feb 11 21:08:06 2010 +0000 3.3 @@ -52,4 +52,7 @@ extern void register_keyhandler(unsigned 3.4 /* Inject a keypress into the key-handling subsystem. */ 3.5 extern void handle_keypress(unsigned char key, struct cpu_user_regs *regs); 3.6 3.7 +/* Scratch space is available for use of any keyhandler. */ 3.8 +extern char keyhandler_scratch[100]; 3.9 + 3.10 #endif /* __XEN_KEYHANDLER_H__ */