Re: [PATCH] virtio-scsi: Fix virtqueue affinity setup
vscsi-num_queues counts the number of request virtqueue which does not include the control and event virtqueue. It is wrong to subtract VIRTIO_SCSI_VQ_BASE from vscsi-num_queues. Reviewed-by: Paolo Bonzini pbonz...@redhat.com This patch fixes the following panic. (qemu) device_del scsi0 BUG: unable to handle kernel NULL pointer dereference at 0020 IP: [8179b29f] __virtscsi_set_affinity+0x6f/0x120 PGD 0 Oops: [#1] SMP Modules linked in: CPU: 0 PID: 659 Comm: kworker/0:1 Not tainted 3.11.0-rc2+ #1172 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Workqueue: kacpi_hotplug _handle_hotplug_event_func task: 88007bee1cc0 ti: 88007bfe4000 task.ti: 88007bfe4000 RIP: 0010:[8179b29f] [8179b29f] __virtscsi_set_affinity+0x6f/0x120 RSP: 0018:88007bfe5a38 EFLAGS: 00010202 RAX: 0010 RBX: 880077fd0d28 RCX: 0050 RDX: RSI: 0246 RDI: RBP: 88007bfe5a58 R08: 880077f6ff00 R09: 0001 R10: 8143e673 R11: 0001 R12: 0001 R13: 880077fd0800 R14: R15: 88007bf489b0 FS: () GS:88007ea0() knlGS: CS: 0010 DS: ES: CR0: 8005003b CR2: 0020 CR3: 79f8b000 CR4: 06f0 Stack: 880077fd0d28 880077fd0800 0008 88007bfe5a78 8179b37d 88007bccc800 88007bccc800 88007bfe5a98 8179b3b6 88007bccc800 880077fd0d28 Call Trace: [8179b37d] virtscsi_set_affinity+0x2d/0x40 [8179b3b6] virtscsi_remove_vqs+0x26/0x50 [8179c7d2] virtscsi_remove+0x82/0xa0 [814cb6b2] virtio_dev_remove+0x22/0x70 [8167ca49] __device_release_driver+0x69/0xd0 [8167cb9d] device_release_driver+0x2d/0x40 [8167bb96] bus_remove_device+0x116/0x150 [81679936] device_del+0x126/0x1e0 [81679a06] device_unregister+0x16/0x30 [814cb889] unregister_virtio_device+0x19/0x30 [814cdad6] virtio_pci_remove+0x36/0x80 [81464ae7] pci_device_remove+0x37/0x70 [8167ca49] __device_release_driver+0x69/0xd0 [8167cb9d] device_release_driver+0x2d/0x40 [8167bb96] bus_remove_device+0x116/0x150 [81679936] device_del+0x126/0x1e0 [8145edfc] pci_stop_bus_device+0x9c/0xb0 [8145f036] pci_stop_and_remove_bus_device+0x16/0x30 [81474a9e] acpiphp_disable_slot+0x8e/0x150 [81474f6a] hotplug_event_func+0xba/0x1a0 [814906c8] ? acpi_os_release_object+0xe/0x12 [81475911] _handle_hotplug_event_func+0x31/0x70 [810b5333] process_one_work+0x183/0x500 [810b66e2] worker_thread+0x122/0x400 [810b65c0] ? manage_workers+0x2d0/0x2d0 [810bc5de] kthread+0xce/0xe0 [810bc510] ? kthread_freezable_should_stop+0x70/0x70 [81ca045c] ret_from_fork+0x7c/0xb0 [810bc510] ? kthread_freezable_should_stop+0x70/0x70 Code: 01 00 00 00 74 59 45 31 e4 83 bb c8 01 00 00 02 74 46 66 2e 0f 1f 84 00 00 00 00 00 49 63 c4 48 c1 e0 04 48 8b bc 0 3 10 02 00 00 48 8b 47 20 48 8b 80 d0 01 00 00 48 8b 40 50 48 85 c0 74 07 be RIP [8179b29f] __virtscsi_set_affinity+0x6f/0x120 RSP 88007bfe5a38 CR2: 0020 ---[ end trace 99679331a3775f48 ]--- CC: sta...@vger.kernel.org Signed-off-by: Asias He as...@redhat.com --- drivers/scsi/virtio_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 2168258..74b88ef 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -751,7 +751,7 @@ static void __virtscsi_set_affinity(struct virtio_scsi *vscsi, bool affinity) vscsi-affinity_hint_set = true; } else { - for (i = 0; i vscsi-num_queues - VIRTIO_SCSI_VQ_BASE; i++) + for (i = 0; i vscsi-num_queues; i++) virtqueue_set_affinity(vscsi-req_vqs[i].vq, -1); vscsi-affinity_hint_set = false; -- 1.8.3.1 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] virtio-scsi: Fix virtqueue affinity setup
vscsi-num_queues counts the number of request virtqueue which does not include the control and event virtqueue. It is wrong to subtract VIRTIO_SCSI_VQ_BASE from vscsi-num_queues. This patch fixes the following panic. (qemu) device_del scsi0 BUG: unable to handle kernel NULL pointer dereference at 0020 IP: [8179b29f] __virtscsi_set_affinity+0x6f/0x120 PGD 0 Oops: [#1] SMP Modules linked in: CPU: 0 PID: 659 Comm: kworker/0:1 Not tainted 3.11.0-rc2+ #1172 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Workqueue: kacpi_hotplug _handle_hotplug_event_func task: 88007bee1cc0 ti: 88007bfe4000 task.ti: 88007bfe4000 RIP: 0010:[8179b29f] [8179b29f] __virtscsi_set_affinity+0x6f/0x120 RSP: 0018:88007bfe5a38 EFLAGS: 00010202 RAX: 0010 RBX: 880077fd0d28 RCX: 0050 RDX: RSI: 0246 RDI: RBP: 88007bfe5a58 R08: 880077f6ff00 R09: 0001 R10: 8143e673 R11: 0001 R12: 0001 R13: 880077fd0800 R14: R15: 88007bf489b0 FS: () GS:88007ea0() knlGS: CS: 0010 DS: ES: CR0: 8005003b CR2: 0020 CR3: 79f8b000 CR4: 06f0 Stack: 880077fd0d28 880077fd0800 0008 88007bfe5a78 8179b37d 88007bccc800 88007bccc800 88007bfe5a98 8179b3b6 88007bccc800 880077fd0d28 Call Trace: [8179b37d] virtscsi_set_affinity+0x2d/0x40 [8179b3b6] virtscsi_remove_vqs+0x26/0x50 [8179c7d2] virtscsi_remove+0x82/0xa0 [814cb6b2] virtio_dev_remove+0x22/0x70 [8167ca49] __device_release_driver+0x69/0xd0 [8167cb9d] device_release_driver+0x2d/0x40 [8167bb96] bus_remove_device+0x116/0x150 [81679936] device_del+0x126/0x1e0 [81679a06] device_unregister+0x16/0x30 [814cb889] unregister_virtio_device+0x19/0x30 [814cdad6] virtio_pci_remove+0x36/0x80 [81464ae7] pci_device_remove+0x37/0x70 [8167ca49] __device_release_driver+0x69/0xd0 [8167cb9d] device_release_driver+0x2d/0x40 [8167bb96] bus_remove_device+0x116/0x150 [81679936] device_del+0x126/0x1e0 [8145edfc] pci_stop_bus_device+0x9c/0xb0 [8145f036] pci_stop_and_remove_bus_device+0x16/0x30 [81474a9e] acpiphp_disable_slot+0x8e/0x150 [81474f6a] hotplug_event_func+0xba/0x1a0 [814906c8] ? acpi_os_release_object+0xe/0x12 [81475911] _handle_hotplug_event_func+0x31/0x70 [810b5333] process_one_work+0x183/0x500 [810b66e2] worker_thread+0x122/0x400 [810b65c0] ? manage_workers+0x2d0/0x2d0 [810bc5de] kthread+0xce/0xe0 [810bc510] ? kthread_freezable_should_stop+0x70/0x70 [81ca045c] ret_from_fork+0x7c/0xb0 [810bc510] ? kthread_freezable_should_stop+0x70/0x70 Code: 01 00 00 00 74 59 45 31 e4 83 bb c8 01 00 00 02 74 46 66 2e 0f 1f 84 00 00 00 00 00 49 63 c4 48 c1 e0 04 48 8b bc 0 3 10 02 00 00 48 8b 47 20 48 8b 80 d0 01 00 00 48 8b 40 50 48 85 c0 74 07 be RIP [8179b29f] __virtscsi_set_affinity+0x6f/0x120 RSP 88007bfe5a38 CR2: 0020 ---[ end trace 99679331a3775f48 ]--- CC: sta...@vger.kernel.org Signed-off-by: Asias He as...@redhat.com --- drivers/scsi/virtio_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 2168258..74b88ef 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -751,7 +751,7 @@ static void __virtscsi_set_affinity(struct virtio_scsi *vscsi, bool affinity) vscsi-affinity_hint_set = true; } else { - for (i = 0; i vscsi-num_queues - VIRTIO_SCSI_VQ_BASE; i++) + for (i = 0; i vscsi-num_queues; i++) virtqueue_set_affinity(vscsi-req_vqs[i].vq, -1); vscsi-affinity_hint_set = false; -- 1.8.3.1 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] virtio-scsi: Fix virtqueue affinity setup
On 07/31/2013 10:17 PM, Asias He wrote: vscsi-num_queues counts the number of request virtqueue which does not include the control and event virtqueue. It is wrong to subtract VIRTIO_SCSI_VQ_BASE from vscsi-num_queues. This patch fixes the following panic. (qemu) device_del scsi0 BUG: unable to handle kernel NULL pointer dereference at 0020 IP: [8179b29f] __virtscsi_set_affinity+0x6f/0x120 PGD 0 Oops: [#1] SMP Modules linked in: CPU: 0 PID: 659 Comm: kworker/0:1 Not tainted 3.11.0-rc2+ #1172 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Workqueue: kacpi_hotplug _handle_hotplug_event_func task: 88007bee1cc0 ti: 88007bfe4000 task.ti: 88007bfe4000 RIP: 0010:[8179b29f] [8179b29f] __virtscsi_set_affinity+0x6f/0x120 RSP: 0018:88007bfe5a38 EFLAGS: 00010202 RAX: 0010 RBX: 880077fd0d28 RCX: 0050 RDX: RSI: 0246 RDI: RBP: 88007bfe5a58 R08: 880077f6ff00 R09: 0001 R10: 8143e673 R11: 0001 R12: 0001 R13: 880077fd0800 R14: R15: 88007bf489b0 FS: () GS:88007ea0() knlGS: CS: 0010 DS: ES: CR0: 8005003b CR2: 0020 CR3: 79f8b000 CR4: 06f0 Stack: 880077fd0d28 880077fd0800 0008 88007bfe5a78 8179b37d 88007bccc800 88007bccc800 88007bfe5a98 8179b3b6 88007bccc800 880077fd0d28 Call Trace: [8179b37d] virtscsi_set_affinity+0x2d/0x40 [8179b3b6] virtscsi_remove_vqs+0x26/0x50 [8179c7d2] virtscsi_remove+0x82/0xa0 [814cb6b2] virtio_dev_remove+0x22/0x70 [8167ca49] __device_release_driver+0x69/0xd0 [8167cb9d] device_release_driver+0x2d/0x40 [8167bb96] bus_remove_device+0x116/0x150 [81679936] device_del+0x126/0x1e0 [81679a06] device_unregister+0x16/0x30 [814cb889] unregister_virtio_device+0x19/0x30 [814cdad6] virtio_pci_remove+0x36/0x80 [81464ae7] pci_device_remove+0x37/0x70 [8167ca49] __device_release_driver+0x69/0xd0 [8167cb9d] device_release_driver+0x2d/0x40 [8167bb96] bus_remove_device+0x116/0x150 [81679936] device_del+0x126/0x1e0 [8145edfc] pci_stop_bus_device+0x9c/0xb0 [8145f036] pci_stop_and_remove_bus_device+0x16/0x30 [81474a9e] acpiphp_disable_slot+0x8e/0x150 [81474f6a] hotplug_event_func+0xba/0x1a0 [814906c8] ? acpi_os_release_object+0xe/0x12 [81475911] _handle_hotplug_event_func+0x31/0x70 [810b5333] process_one_work+0x183/0x500 [810b66e2] worker_thread+0x122/0x400 [810b65c0] ? manage_workers+0x2d0/0x2d0 [810bc5de] kthread+0xce/0xe0 [810bc510] ? kthread_freezable_should_stop+0x70/0x70 [81ca045c] ret_from_fork+0x7c/0xb0 [810bc510] ? kthread_freezable_should_stop+0x70/0x70 Code: 01 00 00 00 74 59 45 31 e4 83 bb c8 01 00 00 02 74 46 66 2e 0f 1f 84 00 00 00 00 00 49 63 c4 48 c1 e0 04 48 8b bc 0 3 10 02 00 00 48 8b 47 20 48 8b 80 d0 01 00 00 48 8b 40 50 48 85 c0 74 07 be RIP [8179b29f] __virtscsi_set_affinity+0x6f/0x120 RSP 88007bfe5a38 CR2: 0020 ---[ end trace 99679331a3775f48 ]--- CC: sta...@vger.kernel.org Signed-off-by: Asias He as...@redhat.com Reviewed-by: Wanlong Gao gaowanl...@cn.fujitsu.com --- drivers/scsi/virtio_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 2168258..74b88ef 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -751,7 +751,7 @@ static void __virtscsi_set_affinity(struct virtio_scsi *vscsi, bool affinity) vscsi-affinity_hint_set = true; } else { - for (i = 0; i vscsi-num_queues - VIRTIO_SCSI_VQ_BASE; i++) + for (i = 0; i vscsi-num_queues; i++) virtqueue_set_affinity(vscsi-req_vqs[i].vq, -1); vscsi-affinity_hint_set = false; -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] virtio-scsi: Fix virtqueue affinity setup
Asias He as...@redhat.com writes: vscsi-num_queues counts the number of request virtqueue which does not include the control and event virtqueue. It is wrong to subtract VIRTIO_SCSI_VQ_BASE from vscsi-num_queues. This patch fixes the following panic. Applied. Thanks, Rusty. (qemu) device_del scsi0 BUG: unable to handle kernel NULL pointer dereference at 0020 IP: [8179b29f] __virtscsi_set_affinity+0x6f/0x120 PGD 0 Oops: [#1] SMP Modules linked in: CPU: 0 PID: 659 Comm: kworker/0:1 Not tainted 3.11.0-rc2+ #1172 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Workqueue: kacpi_hotplug _handle_hotplug_event_func task: 88007bee1cc0 ti: 88007bfe4000 task.ti: 88007bfe4000 RIP: 0010:[8179b29f] [8179b29f] __virtscsi_set_affinity+0x6f/0x120 RSP: 0018:88007bfe5a38 EFLAGS: 00010202 RAX: 0010 RBX: 880077fd0d28 RCX: 0050 RDX: RSI: 0246 RDI: RBP: 88007bfe5a58 R08: 880077f6ff00 R09: 0001 R10: 8143e673 R11: 0001 R12: 0001 R13: 880077fd0800 R14: R15: 88007bf489b0 FS: () GS:88007ea0() knlGS: CS: 0010 DS: ES: CR0: 8005003b CR2: 0020 CR3: 79f8b000 CR4: 06f0 Stack: 880077fd0d28 880077fd0800 0008 88007bfe5a78 8179b37d 88007bccc800 88007bccc800 88007bfe5a98 8179b3b6 88007bccc800 880077fd0d28 Call Trace: [8179b37d] virtscsi_set_affinity+0x2d/0x40 [8179b3b6] virtscsi_remove_vqs+0x26/0x50 [8179c7d2] virtscsi_remove+0x82/0xa0 [814cb6b2] virtio_dev_remove+0x22/0x70 [8167ca49] __device_release_driver+0x69/0xd0 [8167cb9d] device_release_driver+0x2d/0x40 [8167bb96] bus_remove_device+0x116/0x150 [81679936] device_del+0x126/0x1e0 [81679a06] device_unregister+0x16/0x30 [814cb889] unregister_virtio_device+0x19/0x30 [814cdad6] virtio_pci_remove+0x36/0x80 [81464ae7] pci_device_remove+0x37/0x70 [8167ca49] __device_release_driver+0x69/0xd0 [8167cb9d] device_release_driver+0x2d/0x40 [8167bb96] bus_remove_device+0x116/0x150 [81679936] device_del+0x126/0x1e0 [8145edfc] pci_stop_bus_device+0x9c/0xb0 [8145f036] pci_stop_and_remove_bus_device+0x16/0x30 [81474a9e] acpiphp_disable_slot+0x8e/0x150 [81474f6a] hotplug_event_func+0xba/0x1a0 [814906c8] ? acpi_os_release_object+0xe/0x12 [81475911] _handle_hotplug_event_func+0x31/0x70 [810b5333] process_one_work+0x183/0x500 [810b66e2] worker_thread+0x122/0x400 [810b65c0] ? manage_workers+0x2d0/0x2d0 [810bc5de] kthread+0xce/0xe0 [810bc510] ? kthread_freezable_should_stop+0x70/0x70 [81ca045c] ret_from_fork+0x7c/0xb0 [810bc510] ? kthread_freezable_should_stop+0x70/0x70 Code: 01 00 00 00 74 59 45 31 e4 83 bb c8 01 00 00 02 74 46 66 2e 0f 1f 84 00 00 00 00 00 49 63 c4 48 c1 e0 04 48 8b bc 0 3 10 02 00 00 48 8b 47 20 48 8b 80 d0 01 00 00 48 8b 40 50 48 85 c0 74 07 be RIP [8179b29f] __virtscsi_set_affinity+0x6f/0x120 RSP 88007bfe5a38 CR2: 0020 ---[ end trace 99679331a3775f48 ]--- CC: sta...@vger.kernel.org Signed-off-by: Asias He as...@redhat.com --- drivers/scsi/virtio_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 2168258..74b88ef 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -751,7 +751,7 @@ static void __virtscsi_set_affinity(struct virtio_scsi *vscsi, bool affinity) vscsi-affinity_hint_set = true; } else { - for (i = 0; i vscsi-num_queues - VIRTIO_SCSI_VQ_BASE; i++) + for (i = 0; i vscsi-num_queues; i++) virtqueue_set_affinity(vscsi-req_vqs[i].vq, -1); vscsi-affinity_hint_set = false; -- 1.8.3.1 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html