From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Duyck Subject: kernel WARNING/BUG with IOMMU + skb_dma_map/unmap + pktgen Date: Tue, 03 Nov 2009 17:44:33 -0800 Message-ID: <4AF0DC81.10305@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "Tantilov, Emil S" , "davem@davemloft.net" , dwmw2@infradead.org To: "netdev@vger.kernel.org" Return-path: Received: from mga03.intel.com ([143.182.124.21]:4917 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751012AbZKDBo3 (ORCPT ); Tue, 3 Nov 2009 20:44:29 -0500 Sender: netdev-owner@vger.kernel.org List-ID: It looks like skb_dma_map/unmap plus trying to transmit multiple copies of the same skb via pktgen doesn't work when a hardware IOMMU is enabled. We first saw this on igb doing a loopback test partially due to the fact that I had copied the approach used by pktgen of just incrementing the user count and sending the same skb into the transmit path multiple times. However we did some testing to verify that this is reproducible on other NICs using skb_dma_map/unmap and pktgen and generated the traces below on a tg3 w/ pktgen configured to clone_skb several times. The issue seems to be due to the fact that skb_dma_map assumes that dma_map_single/page should return the same value every time it is called, however in the case of having a hardware iommu enabled this is not so and as a result we end up leaking dma mappings and then attempt multiple unmaps on the last dma mapping we received. I'm wondering if this is a valid issue since I am not sure how many different situations will result in a skb being cloned and sent either to the same device multiple times or to multiple devices. Also I am looking for suggestions on how best to address this without negatively impacting TX performance. Thanks, Alex DRHD: handling fault status reg 2 DMAR:[DMA Read] Request device [05:00.0] fault addr ffb9c000 DMAR:[fault reason 06] PTE Read access is not set ------------[ cut here ]------------ WARNING: at lib/dma-debug.c:798 check_unmap+0x158/0x5bf() Hardware name: S5520HC tg3 0000:05:00.0: DMA-API: device driver tries to free DMA memory it has not allocated [device address=0x00000000ffb9c822] [size=1200 bytes] Modules linked in: pktgen tg3 ipv6 autofs4 sunrpc cpufreq_ondemand acpi_cpufreq freq_table video output sbs sbshc joydev shpchp iTCO_wdt i2c_i801 i2c_core pcspkr iTCO_vendor_support usb_storage [last unloaded: igb] Pid: 8701, comm: kpktgend_0 Not tainted 2.6.32-rc3-net-next-igb-tag110309 #12 Call Trace: [] ? check_unmap+0x158/0x5bf [] warn_slowpath_common+0x77/0x8f [] warn_slowpath_fmt+0x9f/0xa1 [] ? _spin_lock_irqsave+0x44/0x50 [] ? get_hash_bucket+0x28/0x33 [] ? register_lock_class+0x20/0x29f [] check_unmap+0x158/0x5bf [] ? __lock_acquire+0x20d/0x3ce [] ? do_IRQ+0x97/0xae [] debug_dma_unmap_page+0x80/0x92 [] ? intel_unmap_page+0xf6/0x103 [] dma_unmap_single_attrs+0x5c/0x68 [] skb_dma_unmap+0x3f/0x78 [] tg3_poll+0x172/0x77d [tg3] [] ? rcu_read_lock+0x0/0x3a [] net_rx_action+0xbc/0x19f [] __do_softirq+0xd5/0x19d [] call_softirq+0x1c/0x34 [] do_softirq+0x33/0x6b [] _local_bh_enable_ip+0x78/0xa7 [] local_bh_enable_ip+0x9/0xb [] _spin_unlock_bh+0x39/0x3d [] pktgen_xmit+0xf5f/0xfe3 [pktgen] [] ? tg3_start_xmit_dma_bug+0x0/0x7cd [tg3] [] ? __lock_acquire+0x20d/0x3ce [] ? pktgen_thread_worker+0x9e/0x660 [pktgen] [] pktgen_thread_worker+0x1a6/0x660 [pktgen] [] ? need_resched+0x1e/0x28 [] ? autoremove_wake_function+0x0/0x38 [] ? autoremove_wake_function+0x0/0x38 [] ? pktgen_thread_worker+0x0/0x660 [pktgen] [] kthread+0x69/0x71 [] child_rip+0xa/0x20 [] ? kthread+0x0/0x71 [] ? child_rip+0x0/0x20 ---[ end trace 39dadbc5c44cf3fd ]--- ------------[ cut here ]------------ WARNING: at drivers/pci/intel-iommu.c:2719 intel_unmap_page+0x8e/0x103() Hardware name: S5520HC Driver unmaps unmatched page at PFN ffb9c822 Modules linked in: pktgen tg3 ipv6 autofs4 sunrpc cpufreq_ondemand acpi_cpufreq freq_table video output sbs sbshc joydev shpchp iTCO_wdt i2c_i801 i2c_core pcspkr iTCO_vendor_support usb_storage [last unloaded: igb] Pid: 8701, comm: kpktgend_0 Tainted: G W 2.6.32-rc3-net-next-igb-tag110309 #12 Call Trace: [] ? intel_unmap_page+0x8e/0x103 [] warn_slowpath_common+0x77/0x8f [] warn_slowpath_fmt+0x9f/0xa1 [] ? find_iova+0x18/0x66 [] ? _spin_unlock_irqrestore+0x57/0x5c [] ? find_iova+0x5b/0x66 [] intel_unmap_page+0x8e/0x103 [] dma_unmap_single_attrs+0x46/0x68 [] skb_dma_unmap+0x3f/0x78 [] tg3_poll+0x172/0x77d [tg3] [] ? rcu_read_lock+0x0/0x3a [] net_rx_action+0xbc/0x19f [] __do_softirq+0xd5/0x19d [] call_softirq+0x1c/0x34 [] do_softirq+0x33/0x6b [] _local_bh_enable_ip+0x78/0xa7 [] local_bh_enable_ip+0x9/0xb [] _spin_unlock_bh+0x39/0x3d [] pktgen_xmit+0xf5f/0xfe3 [pktgen] [] ? tg3_start_xmit_dma_bug+0x0/0x7cd [tg3] [] ? __lock_acquire+0x20d/0x3ce [] ? pktgen_thread_worker+0x9e/0x660 [pktgen] [] pktgen_thread_worker+0x1a6/0x660 [pktgen] [] ? need_resched+0x1e/0x28 [] ? autoremove_wake_function+0x0/0x38 [] ? autoremove_wake_function+0x0/0x38 [] ? pktgen_thread_worker+0x0/0x660 [pktgen] [] kthread+0x69/0x71 [] child_rip+0xa/0x20 [] ? kthread+0x0/0x71 [] ? child_rip+0x0/0x20 ---[ end trace 39dadbc5c44cf3fe ]--- ------------[ cut here ]------------ kernel BUG at drivers/pci/iova.c:155! invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC last sysfs file: /sys/devices/pci0000:00/0000:00:1e.0/0000:0a:00.0/local_cpus CPU 0 Modules linked in: pktgen tg3 ipv6 autofs4 sunrpc cpufreq_ondemand acpi_cpufreq freq_table video output sbs sbshc joydev shpchp iTCO_wdt i2c_i801 i2c_core pcspkr iTCO_vendor_support usb_storage [last unloaded: igb] Pid: 8701, comm: kpktgend_0 Tainted: G W 2.6.32-rc3-net-next-igb-tag110309 #12 S5520HC RIP: 0010:[] [] alloc_iova+0x174/0x1d7 RSP: 0018:ffff88036570fac0 EFLAGS: 00010046 RAX: 00000000000ffb9b RBX: ffff8801e78d4180 RCX: 0000000000000000 RDX: ffff8801e73ba710 RSI: ffff8801e73ba700 RDI: 0000000000000001 RBP: ffff88036570fb20 R08: 0000000000000000 R09: ffff880100000000 R10: ffffffff811daf48 R11: 0000fffffffff000 R12: 00000000000ffb9b R13: 0000000000000001 R14: ffff8801e5cad520 R15: ffff8801e73ba700 FS: 0000000000000000(0000) GS:ffff880028200000(0000) knlGS:0000000000000000 CS: 0010 DS: 0018 ES: 0018 CR0: 000000008005003b CR2: 00007fef515530a0 CR3: 0000000001001000 CR4: 00000000000006f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Process kpktgend_0 (pid: 8701, threadinfo ffff88036570e000, task ffff8803661d3fc0) Stack: ffffffff81e5a328 ffffffff81e5a310 00000000000fffff 0000000000000286 <0> 01ff8801e88de890 ffffffff81e5a310 ffff8801e78d4180 ffff8801e88de890 <0> 0000fffffffff000 ffff8801e5cad500 0000000000000001 ffff8801e88de890 Call Trace: [] intel_alloc_iova+0x68/0xb4 [] __intel_map_single+0x7d/0x152 [] ? intel_map_page+0x0/0x3e [] intel_map_page+0x3c/0x3e [] skb_dma_map+0x92/0x21f [] ? finish_task_switch+0x7c/0x9e [] tg3_start_xmit_dma_bug+0x37f/0x7cd [tg3] [] ? pktgen_xmit+0xe8b/0xfe3 [pktgen] [] pktgen_xmit+0xecc/0xfe3 [pktgen] [] ? tg3_start_xmit_dma_bug+0x0/0x7cd [tg3] [] ? __lock_acquire+0x20d/0x3ce [] ? pktgen_thread_worker+0x9e/0x660 [pktgen] [] pktgen_thread_worker+0x1a6/0x660 [pktgen] [] ? need_resched+0x1e/0x28 [] ? autoremove_wake_function+0x0/0x38 [] ? autoremove_wake_function+0x0/0x38 [] ? pktgen_thread_worker+0x0/0x660 [pktgen] [] kthread+0x69/0x71 [] child_rip+0xa/0x20 [] ? kthread+0x0/0x71 [] ? child_rip+0x0/0x20 Code: 05 ff 49 89 47 18 48 83 7d d0 00 75 04 49 8d 56 30 31 c0 eb 1d 48 8b 46 20 48 8d 56 10 49 39 47 20 72 0c 76 06 48 8d 56 08 eb 04 <0f> 0b eb fe 48 89 f0 48 8b 32 48 85 f6 75 db 48 89 c6 4c 89 ff RIP [] alloc_iova+0x174/0x1d7 RSP ---[ end trace 39dadbc5c44cf3ff ]--- Kernel panic - not syncing: Fatal exception in interrupt Pid: 8701, comm: kpktgend_0 Tainted: G D W 2.6.32-rc3-net-next-igb-tag110309 #12 Call Trace: [] panic+0xe5/0x195 [] ? _spin_unlock_irqrestore+0x4e/0x5c [] ? release_console_sem+0x19e/0x1ab [] ? console_unblank+0x65/0x69 [] ? print_oops_end_marker+0x1e/0x20 [] oops_end+0xaa/0xba [] die+0x55/0x5e [] do_trap+0x110/0x11f [] do_invalid_op+0x91/0x9a [] ? alloc_iova+0x174/0x1d7 [] ? _spin_unlock+0x4a/0x57 [] ? __lock_acquire+0x20d/0x3ce [] invalid_op+0x15/0x20 [] ? alloc_iova+0x57/0x1d7 [] ? alloc_iova+0x174/0x1d7 [] intel_alloc_iova+0x68/0xb4 [] __intel_map_single+0x7d/0x152 [] ? intel_map_page+0x0/0x3e [] intel_map_page+0x3c/0x3e [] skb_dma_map+0x92/0x21f [] ? finish_task_switch+0x7c/0x9e [] tg3_start_xmit_dma_bug+0x37f/0x7cd [tg3] [] ? pktgen_xmit+0xe8b/0xfe3 [pktgen] [] pktgen_xmit+0xecc/0xfe3 [pktgen] [] ? tg3_start_xmit_dma_bug+0x0/0x7cd [tg3] [] ? __lock_acquire+0x20d/0x3ce [] ? pktgen_thread_worker+0x9e/0x660 [pktgen] [] pktgen_thread_worker+0x1a6/0x660 [pktgen] [] ? need_resched+0x1e/0x28 [] ? autoremove_wake_function+0x0/0x38 [] ? autoremove_wake_function+0x0/0x38 [] ? pktgen_thread_worker+0x0/0x660 [pktgen] [] kthread+0x69/0x71 [] child_rip+0xa/0x20 [] ? kthread+0x0/0x71 [] ? child_rip+0x0/0x20 ------------[ cut here ]------------ WARNING: at arch/x86/kernel/smp.c:117 native_smp_send_reschedule+0x25/0x43() Hardware name: S5520HC Modules linked in: pktgen tg3 ipv6 autofs4 sunrpc cpufreq_ondemand acpi_cpufreq freq_table video output sbs sbshc joydev shpchp iTCO_wdt i2c_i801 i2c_core pcspkr iTCO_vendor_support usb_storage [last unloaded: igb] Pid: 8701, comm: kpktgend_0 Tainted: G D W 2.6.32-rc3-net-next-igb-tag110309 #12 Call Trace: [] ? __enqueue_entity+0x74/0x76 [] ? native_smp_send_reschedule+0x25/0x43 [] warn_slowpath_common+0x77/0x8f [] warn_slowpath_null+0xf/0x11 [] native_smp_send_reschedule+0x25/0x43 [] smp_send_reschedule+0xa/0xc [] resched_task+0x67/0x6c [] check_preempt_curr_idle+0x10/0x12 [] check_preempt_curr+0x12/0x14 [] try_to_wake_up+0x249/0x2b2 [] default_wake_function+0xd/0xf [] autoremove_wake_function+0x11/0x38 [] __wake_up_common+0x41/0x74 [] __wake_up+0x38/0x4f [] printk_tick+0x53/0x58 [] update_process_times+0x3e/0x54 [] tick_sched_timer+0x70/0x99 [] ? tick_sched_timer+0x0/0x99 [] __run_hrtimer+0xba/0x121 [] hrtimer_interrupt+0xf6/0x152 [] ? rcu_irq_enter+0x15/0x63 [] smp_apic_timer_interrupt+0x73/0x87 [] apic_timer_interrupt+0x13/0x20 [] ? __atomic_notifier_call_chain+0x0/0xb2 [] ? __atomic_notifier_call_chain+0x0/0xb2 [] ? panic+0x173/0x195 [] ? panic+0x107/0x195 [] ? _spin_unlock_irqrestore+0x4e/0x5c [] ? release_console_sem+0x19e/0x1ab [] ? console_unblank+0x65/0x69 [] ? print_oops_end_marker+0x1e/0x20 [] ? oops_end+0xaa/0xba [] ? die+0x55/0x5e [] ? do_trap+0x110/0x11f [] ? do_invalid_op+0x91/0x9a [] ? alloc_iova+0x174/0x1d7 [] ? _spin_unlock+0x4a/0x57 [] ? __lock_acquire+0x20d/0x3ce [] ? invalid_op+0x15/0x20 [] ? alloc_iova+0x57/0x1d7 [] ? alloc_iova+0x174/0x1d7 [] ? intel_alloc_iova+0x68/0xb4 [] ? __intel_map_single+0x7d/0x152 [] ? intel_map_page+0x0/0x3e [] ? intel_map_page+0x3c/0x3e [] ? skb_dma_map+0x92/0x21f [] ? finish_task_switch+0x7c/0x9e [] ? tg3_start_xmit_dma_bug+0x37f/0x7cd [tg3] [] ? pktgen_xmit+0xe8b/0xfe3 [pktgen] [] ? pktgen_xmit+0xecc/0xfe3 [pktgen] [] ? tg3_start_xmit_dma_bug+0x0/0x7cd [tg3] [] ? __lock_acquire+0x20d/0x3ce [] ? pktgen_thread_worker+0x9e/0x660 [pktgen] [] ? pktgen_thread_worker+0x1a6/0x660 [pktgen] [] ? need_resched+0x1e/0x28 [] ? autoremove_wake_function+0x0/0x38 [] ? autoremove_wake_function+0x0/0x38 [] ? pktgen_thread_worker+0x0/0x660 [pktgen] [] ? kthread+0x69/0x71 [] ? child_rip+0xa/0x20 [] ? kthread+0x0/0x71 [] ? child_rip+0x0/0x20 ---[ end trace 39dadbc5c44cf400 ]---