Christian Borntraeger 4265f161b6 virtio: fix race in enable_cb
There is a race in virtio_net, dealing with disabling/enabling the callback.
I saw the following oops:

kernel BUG at /space/kvm/drivers/virtio/virtio_ring.c:218!
illegal operation: 0001 [#1] SMP
Modules linked in: sunrpc dm_mod
CPU: 2 Not tainted 2.6.25-rc1zlive-host-10623-gd358142-dirty #99
Process swapper (pid: 0, task: 000000000f85a610, ksp: 000000000f873c60)
Krnl PSW : 0404300180000000 00000000002b81a6 (vring_disable_cb+0x16/0x20)
           R:0 T:1 IO:0 EX:0 Key:0 M:1 W:0 P:0 AS:0 CC:3 PM:0 EA:3
Krnl GPRS: 0000000000000001 0000000000000001 0000000010005800 0000000000000001
           000000000f3a0900 000000000f85a610 0000000000000000 0000000000000000
           0000000000000000 000000000f870000 0000000000000000 0000000000001237
           000000000f3a0920 000000000010ff74 00000000002846f6 000000000fa0bcd8
Krnl Code: 00000000002b819a: a7110001           tmll    %r1,1
           00000000002b819e: a7840004           brc     8,2b81a6
           00000000002b81a2: a7f40001           brc     15,2b81a4
          >00000000002b81a6: a51b0001           oill    %r1,1
           00000000002b81aa: 40102000           sth     %r1,0(%r2)
           00000000002b81ae: 07fe               bcr     15,%r14
           00000000002b81b0: eb7ff0380024       stmg    %r7,%r15,56(%r15)
           00000000002b81b6: a7f13e00           tmll    %r15,15872
Call Trace:
([<000000000fa0bcd0>] 0xfa0bcd0)
 [<00000000002b8350>] vring_interrupt+0x5c/0x6c
 [<000000000010ab08>] do_extint+0xb8/0xf0
 [<0000000000110716>] ext_no_vtime+0x16/0x1a
 [<0000000000107e72>] cpu_idle+0x1c2/0x1e0

The problem can be triggered with a high amount of host->guest traffic.
I think its the following race:

poll says netif_rx_complete
poll calls enable_cb
enable_cb opens the interrupt mask
a new packet comes, an interrupt is triggered----\
enable_cb sees that there is more work           |
enable_cb disables the interrupt                 |
       .                                         V
       .                            interrupt is delivered
       .                            skb_recv_done does atomic napi test, ok
 some waiting                       disable_cb is called->check fails->bang!
       .
poll would do napi check
poll would do disable_cb

The fix is to let enable_cb not disable the interrupt again, but expect the
caller to do the cleanup if it returns false. In that case, the interrupt is
only disabled, if the napi test_set_bit was successful.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (cleaned up doco)
2008-03-17 22:58:21 +11:00
..
2008-01-28 14:54:13 -08:00
2008-02-06 10:41:15 -08:00
2008-02-07 08:42:23 -08:00
2008-02-14 21:17:08 -08:00
2008-02-05 09:44:13 -08:00
2008-02-20 20:11:49 -05:00
2008-02-10 18:11:16 -05:00
2007-12-26 19:36:35 -08:00
2008-02-05 03:20:13 -08:00
2008-02-06 10:41:02 -08:00
2008-02-19 10:04:00 +01:00
2007-10-10 16:51:59 -07:00
2008-01-28 15:00:14 -08:00
2007-10-17 08:42:45 -07:00
2007-10-17 08:43:07 -07:00
2008-02-19 10:04:00 +01:00
2007-10-18 14:37:29 -07:00
2007-10-19 11:53:42 -07:00
2007-10-19 11:53:42 -07:00
2008-01-29 21:55:15 +01:00
2008-01-28 14:54:10 -08:00
2008-02-23 17:13:24 -08:00
2007-10-19 11:53:36 -07:00
2008-02-03 17:45:46 +02:00
2008-01-28 23:21:18 +01:00
2008-03-04 16:35:12 -08:00
2007-12-06 17:40:19 -05:00
2008-02-14 20:58:05 -08:00
2007-10-17 08:42:52 -07:00
2008-01-25 21:08:02 +01:00
2008-01-30 13:31:10 +01:00
2008-02-03 17:45:46 +02:00
2008-02-03 15:42:53 +02:00
2008-03-04 14:47:06 -08:00
2007-10-19 11:53:36 -07:00
2008-02-08 02:09:56 +00:00
2008-03-04 10:16:46 -07:00
2008-02-08 09:22:24 -08:00
2007-10-22 08:13:19 -07:00
2008-02-07 08:42:30 -08:00
2008-01-28 23:21:18 +01:00
2007-10-29 07:41:32 -07:00
2007-10-17 08:43:02 -07:00
2007-10-17 08:42:48 -07:00
2007-10-17 08:43:01 -07:00
2008-02-19 10:04:00 +01:00
2007-11-29 09:24:54 -08:00
2008-02-03 15:42:53 +02:00
2008-02-11 13:01:51 +01:00
2008-02-05 09:44:19 -08:00
2008-01-30 13:30:27 +01:00
2008-02-13 16:21:18 -08:00
2008-02-07 20:39:44 -05:00
2007-10-16 11:21:00 +02:00
2007-10-22 00:56:52 -04:00
2008-02-11 09:20:50 -08:00
2008-02-01 16:13:16 -05:00
2007-10-10 16:51:59 -07:00
2007-10-17 08:42:52 -07:00
2008-01-28 15:07:58 -08:00
2007-10-10 16:52:04 -07:00
2008-01-28 15:07:57 -08:00
2008-01-28 14:55:09 -08:00
2008-01-28 14:55:09 -08:00
2007-12-05 05:37:32 -08:00
2008-02-19 21:00:18 +01:00
2007-10-18 14:37:32 -07:00
2008-01-31 19:28:20 -08:00
2008-02-13 16:21:18 -08:00
2008-01-28 23:58:27 -05:00
2008-02-06 10:41:21 -08:00
2008-02-08 09:22:29 -08:00
2007-11-05 15:12:32 -08:00
2007-10-17 08:42:52 -07:00
2007-11-29 09:24:52 -08:00
2008-01-08 16:10:35 -08:00
2008-01-24 20:40:05 -08:00
2008-01-25 21:08:34 +01:00
2007-10-25 15:02:50 +10:00
2008-02-13 16:21:18 -08:00
2008-02-03 17:45:46 +02:00
2008-02-06 10:41:01 -08:00
2008-02-26 14:03:47 +09:00
2007-10-10 16:54:03 -07:00
2008-03-04 16:35:15 -08:00
2008-03-12 12:34:37 -07:00
2007-10-19 11:53:44 -07:00
2008-02-08 09:22:31 -08:00
2008-02-14 21:13:33 -08:00
2008-01-28 14:56:29 -08:00
2008-01-30 02:06:08 -05:00
2007-10-17 08:42:58 -07:00
2008-02-06 16:29:59 +11:00
2007-10-16 09:43:02 -07:00
2008-02-14 21:13:33 -08:00
2008-02-02 11:32:01 -08:00
2008-02-02 02:44:34 +03:00
2007-10-17 08:42:44 -07:00
2008-02-07 23:11:56 -08:00
2007-10-19 11:53:41 -07:00
2008-02-06 10:41:20 -08:00
2008-02-08 09:22:31 -08:00
2007-10-19 11:53:41 -07:00
2007-10-17 08:42:45 -07:00
2008-02-08 09:22:26 -08:00
2007-10-17 08:42:56 -07:00
2008-01-25 21:08:24 +01:00
2008-02-05 09:44:22 -08:00
2008-01-30 13:31:47 +01:00
2008-02-08 09:22:41 -08:00
2008-01-31 19:26:46 -08:00
2007-11-29 09:24:54 -08:00
2008-03-07 16:42:59 +01:00
2007-10-16 09:43:17 -07:00
2007-10-19 11:53:44 -07:00
2008-02-07 08:42:34 -08:00
2008-02-07 08:42:30 -08:00
2008-02-08 09:22:41 -08:00
2008-02-08 09:22:27 -08:00
2008-01-02 13:04:48 -08:00
2008-03-03 12:22:32 -08:00
2008-01-25 21:08:33 +01:00
2008-01-31 19:28:30 -08:00
2008-01-24 00:47:27 -05:00
2008-01-30 13:31:20 +01:00
2008-01-30 13:31:20 +01:00
2008-02-08 09:22:31 -08:00
2008-01-25 21:08:34 +01:00
2008-02-07 08:42:34 -08:00
2008-02-05 09:44:07 -08:00
2008-02-01 17:45:14 +01:00
2008-02-07 08:42:16 -08:00
2008-02-08 09:22:34 -08:00
2008-02-08 09:22:36 -08:00
2008-01-24 20:40:26 -08:00
2008-03-04 14:57:43 -08:00
2007-12-26 19:36:35 -08:00
2007-10-23 13:47:31 -05:00
2008-02-04 23:50:13 +11:00
2008-02-04 23:50:03 +11:00
2007-10-23 15:49:55 +10:00
2008-02-04 23:50:02 +11:00
2008-03-17 22:58:21 +11:00
2008-02-06 10:41:03 -08:00
2007-10-19 11:53:34 -07:00
2008-02-03 15:42:53 +02:00