Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752097AbYCLMSS (ORCPT ); Wed, 12 Mar 2008 08:18:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751141AbYCLMSJ (ORCPT ); Wed, 12 Mar 2008 08:18:09 -0400 Received: from viefep20-int.chello.at ([62.179.121.40]:46612 "EHLO viefep20-int.chello.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751195AbYCLMSH (ORCPT ); Wed, 12 Mar 2008 08:18:07 -0400 Message-Id: <20080312121323.959513000@chello.nl> References: <20080312120920.929901000@chello.nl> User-Agent: quilt/0.45-1 Date: Wed, 12 Mar 2008 13:09:22 +0100 From: Peter Zijlstra To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Gautham R Shenoy , Hugh Dickins , Peter Zijlstra , Eric Dumazet , "David S. Miller" Subject: [PATCH 2/2] lockdep: fix fib_hash softirq inversion Content-Disposition: inline; filename=lockdep-fib_hash-softirq-inversion.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 32636 Lines: 506 ========================================================= [ INFO: possible irq lock inversion dependency detected ] 2.6.25-rc4-sched-devel.git #56 --------------------------------------------------------- swapper/0 just changed the state of lock: (&rt_hash_locks[i]){-+..}, at: [] rt_intern_hash+0x8c/0x3b0 but this lock took another, soft-read-irq-unsafe lock in the past: (fib_hash_lock){-.-?} and interrupts could create inverse lock ordering between them. other info that might help us debug this: 1 lock held by swapper/0: #0: (rcu_read_lock){..--}, at: [] netif_receive_skb+0x76/0x350 the first lock's dependencies: -> (&rt_hash_locks[i]){-+..} ops: 0 { initial-use at: [] __lock_acquire+0x150/0x1080 [] lock_acquire+0x65/0x90 [] _spin_lock_bh+0x36/0x70 [] rt_intern_hash+0x8c/0x3b0 [] __ip_route_output_key+0x5fd/0xb10 [] ip_route_output_flow+0x1c/0x70 [] udp_sendmsg+0x5dd/0x760 [] inet_sendmsg+0x45/0x80 [] sock_sendmsg+0x127/0x140 [] sys_sendto+0xea/0x120 [] system_call_after_swapgs+0x7b/0x80 [] 0xffffffffffffffff in-softirq-W at: [] 0xffffffffffffffff hardirq-on-W at: [] __lock_acquire+0x6c2/0x1080 [] lock_acquire+0x65/0x90 [] _spin_lock_bh+0x36/0x70 [] rt_intern_hash+0x8c/0x3b0 [] __ip_route_output_key+0x5fd/0xb10 [] ip_route_output_flow+0x1c/0x70 [] udp_sendmsg+0x5dd/0x760 [] inet_sendmsg+0x45/0x80 [] sock_sendmsg+0x127/0x140 [] sys_sendto+0xea/0x120 [] system_call_after_swapgs+0x7b/0x80 [] 0xffffffffffffffff } ... key at: [] __key.37724+0x0/0x8 -> (&tbl->lock){-+-+} ops: 0 { initial-use at: [] 0xffffffffffffffff in-softirq-W at: [] 0xffffffffffffffff hardirq-on-W at: [] 0xffffffffffffffff in-softirq-R at: [] 0xffffffffffffffff hardirq-on-R at: [] __lock_acquire+0x440/0x1080 [] lock_acquire+0x65/0x90 [] _read_lock_bh+0x39/0x70 [] neigh_lookup+0x76/0x150 [] arp_bind_neighbour+0x72/0xb0 [] rt_intern_hash+0x11a/0x3b0 [] __ip_route_output_key+0x5fd/0xb10 [] ip_route_output_flow+0x1c/0x70 [] udp_sendmsg+0x5dd/0x760 [] inet_sendmsg+0x45/0x80 [] sock_sendmsg+0x127/0x140 [] sys_sendto+0xea/0x120 [] system_call_after_swapgs+0x7b/0x80 [] 0xffffffffffffffff } ... key at: [] __key.29558+0x0/0x8 -> (base_lock_keys + cpu){++..} ops: 0 { initial-use at: [] __lock_acquire+0x150/0x1080 [] lock_acquire+0x65/0x90 [] _spin_lock_irqsave+0x47/0x80 [] lock_timer_base+0x36/0x70 [] __mod_timer+0x3b/0xf0 [] mod_timer+0x2e/0x50 [] con_init+0x26b/0x290 [] console_init+0x32/0x50 [] start_kernel+0x1e0/0x330 [] _sinittext+0x1b2/0x200 [] 0xffffffffffffffff in-hardirq-W at: [] 0xffffffffffffffff in-softirq-W at: [] 0xffffffffffffffff } ... key at: [] base_lock_keys+0x0/0x40 ... acquired at: [] 0xffffffffffffffff ... acquired at: [] __lock_acquire+0xf84/0x1080 [] lock_acquire+0x65/0x90 [] _read_lock_bh+0x39/0x70 [] neigh_lookup+0x76/0x150 [] arp_bind_neighbour+0x72/0xb0 [] rt_intern_hash+0x11a/0x3b0 [] __ip_route_output_key+0x5fd/0xb10 [] ip_route_output_flow+0x1c/0x70 [] udp_sendmsg+0x5dd/0x760 [] inet_sendmsg+0x45/0x80 [] sock_sendmsg+0x127/0x140 [] sys_sendto+0xea/0x120 [] system_call_after_swapgs+0x7b/0x80 [] 0xffffffffffffffff -> (fib_hash_lock){-.-?} ops: 0 { initial-use at: [] __lock_acquire+0x150/0x1080 [] lock_acquire+0x65/0x90 [] _write_lock_bh+0x36/0x70 [] fn_hash_insert+0x5a3/0x720 [] fib_magic+0x10f/0x120 [] fib_add_ifaddr+0x73/0x170 [] fib_inetaddr_event+0x4b/0x280 [] notifier_call_chain+0x53/0x80 [] __blocking_notifier_call_chain+0x58/0x80 [] blocking_notifier_call_chain+0x11/0x20 [] __inet_insert_ifa+0xd4/0x170 [] inet_insert_ifa+0xd/0x10 [] inetdev_event+0x3df/0x480 [] notifier_call_chain+0x53/0x80 [] __raw_notifier_call_chain+0x9/0x10 [] raw_notifier_call_chain+0x11/0x20 [] call_netdevice_notifiers+0x16/0x20 [] dev_open+0x82/0x90 [] dev_change_flags+0x99/0x1b0 [] devinet_ioctl+0x5ce/0x780 [] inet_ioctl+0x5c/0x80 [] sock_ioctl+0x65/0x250 [] vfs_ioctl+0x31/0x90 [] do_vfs_ioctl+0x73/0x2d0 [] sys_ioctl+0x82/0xa0 [] system_call_after_swapgs+0x7b/0x80 [] 0xffffffffffffffff hardirq-on-W at: [] __lock_acquire+0x6c2/0x1080 [] lock_acquire+0x65/0x90 [] _write_lock_bh+0x36/0x70 [] fn_hash_insert+0x5a3/0x720 [] fib_magic+0x10f/0x120 [] fib_add_ifaddr+0x73/0x170 [] fib_inetaddr_event+0x4b/0x280 [] notifier_call_chain+0x53/0x80 [] __blocking_notifier_call_chain+0x58/0x80 [] blocking_notifier_call_chain+0x11/0x20 [] __inet_insert_ifa+0xd4/0x170 [] inet_insert_ifa+0xd/0x10 [] inetdev_event+0x3df/0x480 [] notifier_call_chain+0x53/0x80 [] __raw_notifier_call_chain+0x9/0x10 [] raw_notifier_call_chain+0x11/0x20 [] call_netdevice_notifiers+0x16/0x20 [] dev_open+0x82/0x90 [] dev_change_flags+0x99/0x1b0 [] devinet_ioctl+0x5ce/0x780 [] inet_ioctl+0x5c/0x80 [] sock_ioctl+0x65/0x250 [] vfs_ioctl+0x31/0x90 [] do_vfs_ioctl+0x73/0x2d0 [] sys_ioctl+0x82/0xa0 [] system_call_after_swapgs+0x7b/0x80 [] 0xffffffffffffffff in-softirq-R at: [] 0xffffffffffffffff softirq-on-R at: [] __lock_acquire+0x46b/0x1080 [] lock_acquire+0x65/0x90 [] _read_lock+0x34/0x70 [] fn_hash_lookup+0x27/0xf0 [] inet_addr_type+0x6d/0xf0 [] fib_create_info+0x5a2/0xbf0 [] fn_hash_insert+0x6b/0x720 [] fib_magic+0x10f/0x120 [] fib_add_ifaddr+0xc8/0x170 [] fib_inetaddr_event+0x4b/0x280 [] notifier_call_chain+0x53/0x80 [] __blocking_notifier_call_chain+0x58/0x80 [] blocking_notifier_call_chain+0x11/0x20 [] __inet_insert_ifa+0xd4/0x170 [] inet_insert_ifa+0xd/0x10 [] inetdev_event+0x3df/0x480 [] notifier_call_chain+0x53/0x80 [] __raw_notifier_call_chain+0x9/0x10 [] raw_notifier_call_chain+0x11/0x20 [] call_netdevice_notifiers+0x16/0x20 [] dev_open+0x82/0x90 [] dev_change_flags+0x99/0x1b0 [] devinet_ioctl+0x5ce/0x780 [] inet_ioctl+0x5c/0x80 [] sock_ioctl+0x65/0x250 [] vfs_ioctl+0x31/0x90 [] do_vfs_ioctl+0x73/0x2d0 [] sys_ioctl+0x82/0xa0 [] system_call_after_swapgs+0x7b/0x80 [] 0xffffffffffffffff hardirq-on-R at: [] __lock_acquire+0x440/0x1080 [] lock_acquire+0x65/0x90 [] _read_lock+0x34/0x70 [] fn_hash_lookup+0x27/0xf0 [] inet_addr_type+0x6d/0xf0 [] fib_create_info+0x5a2/0xbf0 [] fn_hash_insert+0x6b/0x720 [] fib_magic+0x10f/0x120 [] fib_add_ifaddr+0xc8/0x170 [] fib_inetaddr_event+0x4b/0x280 [] notifier_call_chain+0x53/0x80 [] __blocking_notifier_call_chain+0x58/0x80 [] blocking_notifier_call_chain+0x11/0x20 [] __inet_insert_ifa+0xd4/0x170 [] inet_insert_ifa+0xd/0x10 [] inetdev_event+0x3df/0x480 [] notifier_call_chain+0x53/0x80 [] __raw_notifier_call_chain+0x9/0x10 [] raw_notifier_call_chain+0x11/0x20 [] call_netdevice_notifiers+0x16/0x20 [] dev_open+0x82/0x90 [] dev_change_flags+0x99/0x1b0 [] devinet_ioctl+0x5ce/0x780 [] inet_ioctl+0x5c/0x80 [] sock_ioctl+0x65/0x250 [] vfs_ioctl+0x31/0x90 [] do_vfs_ioctl+0x73/0x2d0 [] sys_ioctl+0x82/0xa0 [] system_call_after_swapgs+0x7b/0x80 [] 0xffffffffffffffff } ... key at: [] fib_hash_lock+0x18/0x40 ... acquired at: [] __lock_acquire+0xf84/0x1080 [] lock_acquire+0x65/0x90 [] _read_lock+0x34/0x70 [] fn_hash_lookup+0x27/0xf0 [] inet_addr_type+0x6d/0xf0 [] arp_constructor+0x86/0x280 [] neigh_create+0x19f/0x5b0 [] arp_bind_neighbour+0x9f/0xb0 [] rt_intern_hash+0x11a/0x3b0 [] __ip_route_output_key+0x5fd/0xb10 [] tcp_v4_connect+0x10c/0x550 [] inet_stream_connect+0x23a/0x2d0 [] sys_connect+0xa0/0xc0 [] system_call_after_swapgs+0x7b/0x80 [] 0xffffffffffffffff the second lock's dependencies: -> (fib_hash_lock){-.-?} ops: 0 { initial-use at: [] __lock_acquire+0x150/0x1080 [] lock_acquire+0x65/0x90 [] _write_lock_bh+0x36/0x70 [] fn_hash_insert+0x5a3/0x720 [] fib_magic+0x10f/0x120 [] fib_add_ifaddr+0x73/0x170 [] fib_inetaddr_event+0x4b/0x280 [] notifier_call_chain+0x53/0x80 [] __blocking_notifier_call_chain+0x58/0x80 [] blocking_notifier_call_chain+0x11/0x20 [] __inet_insert_ifa+0xd4/0x170 [] inet_insert_ifa+0xd/0x10 [] inetdev_event+0x3df/0x480 [] notifier_call_chain+0x53/0x80 [] __raw_notifier_call_chain+0x9/0x10 [] raw_notifier_call_chain+0x11/0x20 [] call_netdevice_notifiers+0x16/0x20 [] dev_open+0x82/0x90 [] dev_change_flags+0x99/0x1b0 [] devinet_ioctl+0x5ce/0x780 [] inet_ioctl+0x5c/0x80 [] sock_ioctl+0x65/0x250 [] vfs_ioctl+0x31/0x90 [] do_vfs_ioctl+0x73/0x2d0 [] sys_ioctl+0x82/0xa0 [] system_call_after_swapgs+0x7b/0x80 [] 0xffffffffffffffff hardirq-on-W at: [] __lock_acquire+0x6c2/0x1080 [] lock_acquire+0x65/0x90 [] _write_lock_bh+0x36/0x70 [] fn_hash_insert+0x5a3/0x720 [] fib_magic+0x10f/0x120 [] fib_add_ifaddr+0x73/0x170 [] fib_inetaddr_event+0x4b/0x280 [] notifier_call_chain+0x53/0x80 [] __blocking_notifier_call_chain+0x58/0x80 [] blocking_notifier_call_chain+0x11/0x20 [] __inet_insert_ifa+0xd4/0x170 [] inet_insert_ifa+0xd/0x10 [] inetdev_event+0x3df/0x480 [] notifier_call_chain+0x53/0x80 [] __raw_notifier_call_chain+0x9/0x10 [] raw_notifier_call_chain+0x11/0x20 [] call_netdevice_notifiers+0x16/0x20 [] dev_open+0x82/0x90 [] dev_change_flags+0x99/0x1b0 [] devinet_ioctl+0x5ce/0x780 [] inet_ioctl+0x5c/0x80 [] sock_ioctl+0x65/0x250 [] vfs_ioctl+0x31/0x90 [] do_vfs_ioctl+0x73/0x2d0 [] sys_ioctl+0x82/0xa0 [] system_call_after_swapgs+0x7b/0x80 [] 0xffffffffffffffff in-softirq-R at: [] 0xffffffffffffffff softirq-on-R at: [] __lock_acquire+0x46b/0x1080 [] lock_acquire+0x65/0x90 [] _read_lock+0x34/0x70 [] fn_hash_lookup+0x27/0xf0 [] inet_addr_type+0x6d/0xf0 [] fib_create_info+0x5a2/0xbf0 [] fn_hash_insert+0x6b/0x720 [] fib_magic+0x10f/0x120 [] fib_add_ifaddr+0xc8/0x170 [] fib_inetaddr_event+0x4b/0x280 [] notifier_call_chain+0x53/0x80 [] __blocking_notifier_call_chain+0x58/0x80 [] blocking_notifier_call_chain+0x11/0x20 [] __inet_insert_ifa+0xd4/0x170 [] inet_insert_ifa+0xd/0x10 [] inetdev_event+0x3df/0x480 [] notifier_call_chain+0x53/0x80 [] __raw_notifier_call_chain+0x9/0x10 [] raw_notifier_call_chain+0x11/0x20 [] call_netdevice_notifiers+0x16/0x20 [] dev_open+0x82/0x90 [] dev_change_flags+0x99/0x1b0 [] devinet_ioctl+0x5ce/0x780 [] inet_ioctl+0x5c/0x80 [] sock_ioctl+0x65/0x250 [] vfs_ioctl+0x31/0x90 [] do_vfs_ioctl+0x73/0x2d0 [] sys_ioctl+0x82/0xa0 [] system_call_after_swapgs+0x7b/0x80 [] 0xffffffffffffffff hardirq-on-R at: [] __lock_acquire+0x440/0x1080 [] lock_acquire+0x65/0x90 [] _read_lock+0x34/0x70 [] fn_hash_lookup+0x27/0xf0 [] inet_addr_type+0x6d/0xf0 [] fib_create_info+0x5a2/0xbf0 [] fn_hash_insert+0x6b/0x720 [] fib_magic+0x10f/0x120 [] fib_add_ifaddr+0xc8/0x170 [] fib_inetaddr_event+0x4b/0x280 [] notifier_call_chain+0x53/0x80 [] __blocking_notifier_call_chain+0x58/0x80 [] blocking_notifier_call_chain+0x11/0x20 [] __inet_insert_ifa+0xd4/0x170 [] inet_insert_ifa+0xd/0x10 [] inetdev_event+0x3df/0x480 [] notifier_call_chain+0x53/0x80 [] __raw_notifier_call_chain+0x9/0x10 [] raw_notifier_call_chain+0x11/0x20 [] call_netdevice_notifiers+0x16/0x20 [] dev_open+0x82/0x90 [] dev_change_flags+0x99/0x1b0 [] devinet_ioctl+0x5ce/0x780 [] inet_ioctl+0x5c/0x80 [] sock_ioctl+0x65/0x250 [] vfs_ioctl+0x31/0x90 [] do_vfs_ioctl+0x73/0x2d0 [] sys_ioctl+0x82/0xa0 [] system_call_after_swapgs+0x7b/0x80 [] 0xffffffffffffffff } ... key at: [] fib_hash_lock+0x18/0x40 stack backtrace: Pid: 0, comm: swapper Not tainted 2.6.25-rc4-sched-devel.git #56 Call Trace: [] print_irq_inversion_bug+0x13c/0x160 [] check_usage_forwards+0x4d/0x60 [] mark_lock+0x196/0x5e0 [] __lock_acquire+0x565/0x1080 [] lock_acquire+0x65/0x90 [] ? rt_intern_hash+0x8c/0x3b0 [] _spin_lock_bh+0x36/0x70 [] rt_intern_hash+0x8c/0x3b0 [] ip_route_input+0x8fe/0x1250 [] ? trace_hardirqs_on+0xd/0x10 [] ? trace_hardirqs_on+0xd/0x10 [] ip_rcv+0x518/0x650 [] netif_receive_skb+0x269/0x350 [] e1000_clean_rx_irq+0x1a9/0x5a0 [] e1000_clean+0x1fb/0x5b0 [] ? trace_hardirqs_off+0xd/0x10 [] net_rx_action+0xbf/0x180 [] __do_softirq+0x75/0x100 [] call_softirq+0x1c/0x30 [] do_softirq+0x65/0xa0 [] irq_exit+0x97/0xa0 [] do_IRQ+0xa8/0x130 [] ret_from_intr+0x0/0xf [] ? default_idle+0x43/0x80 [] ? default_idle+0x41/0x80 [] ? default_idle+0x0/0x80 [] ? cpu_idle+0x6d/0x120 [] ? start_secondary+0x31b/0x420 Signed-off-by: Peter Zijlstra CC: Eric Dumazet CC: David S. Miller --- net/ipv4/fib_hash.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) Index: linux-2.6-2/net/ipv4/fib_hash.c =================================================================== --- linux-2.6-2.orig/net/ipv4/fib_hash.c +++ linux-2.6-2/net/ipv4/fib_hash.c @@ -251,7 +251,7 @@ fn_hash_lookup(struct fib_table *tb, con struct fn_zone *fz; struct fn_hash *t = (struct fn_hash*)tb->tb_data; - read_lock(&fib_hash_lock); + read_lock_bh(&fib_hash_lock); for (fz = t->fn_zone_list; fz; fz = fz->fz_next) { struct hlist_head *head; struct hlist_node *node; @@ -273,7 +273,7 @@ fn_hash_lookup(struct fib_table *tb, con } err = 1; out: - read_unlock(&fib_hash_lock); + read_unlock_bh(&fib_hash_lock); return err; } @@ -295,7 +295,7 @@ fn_hash_select_default(struct fib_table last_resort = NULL; order = -1; - read_lock(&fib_hash_lock); + read_lock_bh(&fib_hash_lock); hlist_for_each_entry(f, node, &fz->fz_hash[0], fn_hash) { struct fib_alias *fa; @@ -343,7 +343,7 @@ fn_hash_select_default(struct fib_table fib_result_assign(res, last_resort); tb->tb_default = last_idx; out: - read_unlock(&fib_hash_lock); + read_unlock_bh(&fib_hash_lock); } /* Insert node F to FZ. */ @@ -753,18 +753,18 @@ static int fn_hash_dump(struct fib_table struct fn_hash *table = (struct fn_hash*)tb->tb_data; s_m = cb->args[2]; - read_lock(&fib_hash_lock); + read_lock_bh(&fib_hash_lock); for (fz = table->fn_zone_list, m=0; fz; fz = fz->fz_next, m++) { if (m < s_m) continue; if (fn_hash_dump_zone(skb, cb, tb, fz) < 0) { cb->args[2] = m; - read_unlock(&fib_hash_lock); + read_unlock_bh(&fib_hash_lock); return -1; } memset(&cb->args[3], 0, sizeof(cb->args) - 3*sizeof(cb->args[0])); } - read_unlock(&fib_hash_lock); + read_unlock_bh(&fib_hash_lock); cb->args[2] = m; return skb->len; } @@ -962,7 +962,7 @@ static void *fib_seq_start(struct seq_fi struct fib_iter_state *iter = seq->private; void *v = NULL; - read_lock(&fib_hash_lock); + read_lock_bh(&fib_hash_lock); if (fib_get_table(iter->p.net, RT_TABLE_MAIN)) v = *pos ? fib_get_idx(seq, *pos - 1) : SEQ_START_TOKEN; return v; @@ -977,7 +977,7 @@ static void *fib_seq_next(struct seq_fil static void fib_seq_stop(struct seq_file *seq, void *v) __releases(fib_hash_lock) { - read_unlock(&fib_hash_lock); + read_unlock_bh(&fib_hash_lock); } static unsigned fib_flag_trans(int type, __be32 mask, struct fib_info *fi) -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/