aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2009-06-13 00:27:02 -0400
committerRusty Russell <rusty@rustcorp.com.au>2009-06-12 08:57:03 -0400
commita32a8813d0173163ba44d8f9556e0d89fdc4fb46 (patch)
treefddb6742338047d0219e8c2536cd39b04e643b16 /drivers
parentabd41f037e1a64543000ed73b42f616d04d92700 (diff)
lguest: improve interrupt handling, speed up stream networking
lguest never checked for pending interrupts when enabling interrupts, and things still worked. However, it makes a significant difference to TCP performance, so it's time we fixed it by introducing a pending_irq flag and checking it on irq_restore and irq_enable. These two routines are now too big to patch into the 8/10 bytes patch space, so we drop that code. Note: The high latency on interrupt delivery had a very curious effect: once everything else was optimized, networking without GSO was faster than networking with GSO, since more interrupts were sent and hence a greater chance of one getting through to the Guest! Note2: (Almost) Closing the same loophole for iret doesn't have any measurable effect, so I'm leaving that patch for the moment. Before: 1GB tcpblast Guest->Host: 30.7 seconds 1GB tcpblast Guest->Host (no GSO): 76.0 seconds After: 1GB tcpblast Guest->Host: 6.8 seconds 1GB tcpblast Guest->Host (no GSO): 27.8 seconds Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/lguest/core.c7
-rw-r--r--drivers/lguest/hypercalls.c4
-rw-r--r--drivers/lguest/interrupts_and_traps.c16
-rw-r--r--drivers/lguest/lg.h4
4 files changed, 23 insertions, 8 deletions
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
index 8ca1def5b142..03fbc88c0023 100644
--- a/drivers/lguest/core.c
+++ b/drivers/lguest/core.c
@@ -189,6 +189,7 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
189 /* We stop running once the Guest is dead. */ 189 /* We stop running once the Guest is dead. */
190 while (!cpu->lg->dead) { 190 while (!cpu->lg->dead) {
191 unsigned int irq; 191 unsigned int irq;
192 bool more;
192 193
193 /* First we run any hypercalls the Guest wants done. */ 194 /* First we run any hypercalls the Guest wants done. */
194 if (cpu->hcall) 195 if (cpu->hcall)
@@ -213,9 +214,9 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
213 /* Check if there are any interrupts which can be delivered now: 214 /* Check if there are any interrupts which can be delivered now:
214 * if so, this sets up the hander to be executed when we next 215 * if so, this sets up the hander to be executed when we next
215 * run the Guest. */ 216 * run the Guest. */
216 irq = interrupt_pending(cpu); 217 irq = interrupt_pending(cpu, &more);
217 if (irq < LGUEST_IRQS) 218 if (irq < LGUEST_IRQS)
218 try_deliver_interrupt(cpu, irq); 219 try_deliver_interrupt(cpu, irq, more);
219 220
220 /* All long-lived kernel loops need to check with this horrible 221 /* All long-lived kernel loops need to check with this horrible
221 * thing called the freezer. If the Host is trying to suspend, 222 * thing called the freezer. If the Host is trying to suspend,
@@ -233,7 +234,7 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
233 set_current_state(TASK_INTERRUPTIBLE); 234 set_current_state(TASK_INTERRUPTIBLE);
234 /* Just before we sleep, make sure nothing snuck in 235 /* Just before we sleep, make sure nothing snuck in
235 * which we should be doing. */ 236 * which we should be doing. */
236 if (interrupt_pending(cpu) < LGUEST_IRQS 237 if (interrupt_pending(cpu, &more) < LGUEST_IRQS
237 || cpu->break_out) 238 || cpu->break_out)
238 set_current_state(TASK_RUNNING); 239 set_current_state(TASK_RUNNING);
239 else 240 else
diff --git a/drivers/lguest/hypercalls.c b/drivers/lguest/hypercalls.c
index 54d66f05fefa..f252b71ae79e 100644
--- a/drivers/lguest/hypercalls.c
+++ b/drivers/lguest/hypercalls.c
@@ -37,6 +37,10 @@ static void do_hcall(struct lg_cpu *cpu, struct hcall_args *args)
37 /* This call does nothing, except by breaking out of the Guest 37 /* This call does nothing, except by breaking out of the Guest
38 * it makes us process all the asynchronous hypercalls. */ 38 * it makes us process all the asynchronous hypercalls. */
39 break; 39 break;
40 case LHCALL_SEND_INTERRUPTS:
41 /* This call does nothing too, but by breaking out of the Guest
42 * it makes us process any pending interrupts. */
43 break;
40 case LHCALL_LGUEST_INIT: 44 case LHCALL_LGUEST_INIT:
41 /* You can't get here unless you're already initialized. Don't 45 /* You can't get here unless you're already initialized. Don't
42 * do that. */ 46 * do that. */
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c
index a8c966fee1e4..5a10754b4790 100644
--- a/drivers/lguest/interrupts_and_traps.c
+++ b/drivers/lguest/interrupts_and_traps.c
@@ -131,7 +131,7 @@ static void set_guest_interrupt(struct lg_cpu *cpu, u32 lo, u32 hi,
131 * interrupt_pending() returns the first pending interrupt which isn't blocked 131 * interrupt_pending() returns the first pending interrupt which isn't blocked
132 * by the Guest. It is called before every entry to the Guest, and just before 132 * by the Guest. It is called before every entry to the Guest, and just before
133 * we go to sleep when the Guest has halted itself. */ 133 * we go to sleep when the Guest has halted itself. */
134unsigned int interrupt_pending(struct lg_cpu *cpu) 134unsigned int interrupt_pending(struct lg_cpu *cpu, bool *more)
135{ 135{
136 unsigned int irq; 136 unsigned int irq;
137 DECLARE_BITMAP(blk, LGUEST_IRQS); 137 DECLARE_BITMAP(blk, LGUEST_IRQS);
@@ -149,13 +149,14 @@ unsigned int interrupt_pending(struct lg_cpu *cpu)
149 149
150 /* Find the first interrupt. */ 150 /* Find the first interrupt. */
151 irq = find_first_bit(blk, LGUEST_IRQS); 151 irq = find_first_bit(blk, LGUEST_IRQS);
152 *more = find_next_bit(blk, LGUEST_IRQS, irq+1);
152 153
153 return irq; 154 return irq;
154} 155}
155 156
156/* This actually diverts the Guest to running an interrupt handler, once an 157/* This actually diverts the Guest to running an interrupt handler, once an
157 * interrupt has been identified by interrupt_pending(). */ 158 * interrupt has been identified by interrupt_pending(). */
158void try_deliver_interrupt(struct lg_cpu *cpu, unsigned int irq) 159void try_deliver_interrupt(struct lg_cpu *cpu, unsigned int irq, bool more)
159{ 160{
160 struct desc_struct *idt; 161 struct desc_struct *idt;
161 162
@@ -178,8 +179,12 @@ void try_deliver_interrupt(struct lg_cpu *cpu, unsigned int irq)
178 u32 irq_enabled; 179 u32 irq_enabled;
179 if (get_user(irq_enabled, &cpu->lg->lguest_data->irq_enabled)) 180 if (get_user(irq_enabled, &cpu->lg->lguest_data->irq_enabled))
180 irq_enabled = 0; 181 irq_enabled = 0;
181 if (!irq_enabled) 182 if (!irq_enabled) {
183 /* Make sure they know an IRQ is pending. */
184 put_user(X86_EFLAGS_IF,
185 &cpu->lg->lguest_data->irq_pending);
182 return; 186 return;
187 }
183 } 188 }
184 189
185 /* Look at the IDT entry the Guest gave us for this interrupt. The 190 /* Look at the IDT entry the Guest gave us for this interrupt. The
@@ -202,6 +207,11 @@ void try_deliver_interrupt(struct lg_cpu *cpu, unsigned int irq)
202 * here is a compromise which means at least it gets updated every 207 * here is a compromise which means at least it gets updated every
203 * timer interrupt. */ 208 * timer interrupt. */
204 write_timestamp(cpu); 209 write_timestamp(cpu);
210
211 /* If there are no other interrupts we want to deliver, clear
212 * the pending flag. */
213 if (!more)
214 put_user(0, &cpu->lg->lguest_data->irq_pending);
205} 215}
206/*:*/ 216/*:*/
207 217
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h
index 6743cf147d97..573896533ac9 100644
--- a/drivers/lguest/lg.h
+++ b/drivers/lguest/lg.h
@@ -139,8 +139,8 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user);
139#define pgd_pfn(x) (pgd_val(x) >> PAGE_SHIFT) 139#define pgd_pfn(x) (pgd_val(x) >> PAGE_SHIFT)
140 140
141/* interrupts_and_traps.c: */ 141/* interrupts_and_traps.c: */
142unsigned int interrupt_pending(struct lg_cpu *cpu); 142unsigned int interrupt_pending(struct lg_cpu *cpu, bool *more);
143void try_deliver_interrupt(struct lg_cpu *cpu, unsigned int irq); 143void try_deliver_interrupt(struct lg_cpu *cpu, unsigned int irq, bool more);
144bool deliver_trap(struct lg_cpu *cpu, unsigned int num); 144bool deliver_trap(struct lg_cpu *cpu, unsigned int num);
145void load_guest_idt_entry(struct lg_cpu *cpu, unsigned int i, 145void load_guest_idt_entry(struct lg_cpu *cpu, unsigned int i,
146 u32 low, u32 hi); 146 u32 low, u32 hi);