Skip to contentSkip to conversation

net-next: NULL pointer dereference on adding a net namespace and a system freeze

PATCH In review Jakub Kicinski 5 participants 21 messages Mar 10, 2014 – Mar 12, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi!

Running Fedora 20 with net-next I get the following warning when libvirt or rtkit comes up:

[  272.143488] kmem_cache_sanity_check (flow_cache): Cache name already exists.
[  272.143586] CPU: 0 PID: 975 Comm: libvirtd Not tainted 3.14.0-rc5+ #1
[  272.143589] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[  272.143591]  0000000000000000 ffff88003ceadba0 ffffffff8167baf0 ffff88003db3d300
[  272.143595]  ffff88003ceadc18 ffffffff8117795b ffff88003ceadbc8 ffff88003b235158
[  272.143599]  0000000000000000 0000000000040000 0000000000000068 0000000000000000
[  272.143602] Call Trace:
[  272.143610]  [<ffffffff8167baf0>] dump_stack+0x4d/0x66
[  272.143615]  [<ffffffff8117795b>] kmem_cache_create_memcg+0x12b/0x420
[  272.143618]  [<ffffffff81177c7b>] kmem_cache_create+0x2b/0x30
[  272.143622]  [<ffffffff815c4a0e>] flow_cache_init+0x2e/0x2b0
[  272.143626]  [<ffffffff8164b017>] xfrm_net_init+0x227/0x360
[  272.143629]  [<ffffffff8164af41>] ? xfrm_net_init+0x151/0x360
[  272.143632]  [<ffffffff815a5921>] ops_init+0x41/0x150
[  272.143635]  [<ffffffff815a5aa3>] setup_net+0x73/0x110
[  272.143638]  [<ffffffff815a5fe2>] copy_net_ns+0x72/0x100
[  272.143642]  [<ffffffff810943f9>] create_new_namespaces+0xf9/0x190
[  272.143645]  [<ffffffff81094560>] copy_namespaces+0xd0/0xf0
[  272.143648]  [<ffffffff81094495>] ? copy_namespaces+0x5/0xf0
[  272.143651]  [<ffffffff81069be0>] copy_process.part.31+0x950/0x1b30
[  272.143655]  [<ffffffff8106af95>] do_fork+0xd5/0x370
[  272.143658]  [<ffffffff811c1b2d>] ? __fput+0x17d/0x240
[  272.143662]  [<ffffffff8110440c>] ? __audit_syscall_entry+0x9c/0xf0
[  272.143665]  [<ffffffff8106b2b6>] SyS_clone+0x16/0x20
[  272.143669]  [<ffffffff8168cf19>] stub_clone+0x69/0x90
[  272.143673]  [<ffffffff8168cb69>] ? system_call_fastpath+0x16/0x1b

When I try to add a netns with

# ip netns add abcd
I it dies with:
[  887.482891] kmem_cache_sanity_check (flow_cache): Cache name already exists.
[  887.483001] CPU: 0 PID: 1135 Comm: ip Not tainted 3.14.0-rc5+ #1
[  887.483003] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[  887.483036]  0000000000000000 ffff88003bc71d20 ffffffff8167baf0 ffff88003db3d300
[  887.483041]  ffff88003bc71d98 ffffffff8117795b ffff88003bc71d48 ffff88003d88e218
[  887.483044]  0000000000000000 0000000000040000 0000000000000068 0000000000000000
[  887.483048] Call Trace:
[  887.483056]  [<ffffffff8167baf0>] dump_stack+0x4d/0x66
[  887.483060]  [<ffffffff8117795b>] kmem_cache_create_memcg+0x12b/0x420
[  887.483063]  [<ffffffff81177c7b>] kmem_cache_create+0x2b/0x30
[  887.483068]  [<ffffffff815c4a0e>] flow_cache_init+0x2e/0x2b0
[  887.483072]  [<ffffffff8164b017>] xfrm_net_init+0x227/0x360
[  887.483075]  [<ffffffff8164af41>] ? xfrm_net_init+0x151/0x360
[  887.483078]  [<ffffffff815a5921>] ops_init+0x41/0x150
[  887.483081]  [<ffffffff815a5aa3>] setup_net+0x73/0x110
[  887.483084]  [<ffffffff815a5fe2>] copy_net_ns+0x72/0x100
[  887.483088]  [<ffffffff810943f9>] create_new_namespaces+0xf9/0x190
[  887.483092]  [<ffffffff81094671>] unshare_nsproxy_namespaces+0x61/0xa0
[  887.483095]  [<ffffffff8106b419>] SyS_unshare+0x159/0x270
[  887.483099]  [<ffffffff8168cb69>] system_call_fastpath+0x16/0x1b
[  887.484459] BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
[  887.484546] IP: [<ffffffff81094840>] raw_notifier_chain_register+0x20/0x40
[  887.484627] PGD 3c183067 PUD 3b1ec067 PMD 0 
[  887.484703] Oops: 0000 [#1] SMP 
[  887.484775] Modules linked in: cfg80211 rfkill xt_conntrack iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw ppdev serio_raw virtio_console virtio_balloon i2c_piix4 floppy parport_pc parport nfsd auth_rpcgss nfs_acl lockd sunrpc virtio_blk virtio_net qxl drm_kms_helper ttm virtio_pci virtio_ring virtio
[  887.485019] CPU: 0 PID: 1135 Comm: ip Not tainted 3.14.0-rc5+ #1
[  887.485019] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[  887.485019] task: ffff88003b234300 ti: ffff88003bc70000 task.ti: ffff88003bc70000
[  887.485019] RIP: 0010:[<ffffffff81094840>]  [<ffffffff81094840>] raw_notifier_chain_register+0x20/0x40
[  887.485019] RSP: 0018:ffff88003bc71d98  EFLAGS: 00010202
[  887.485019] RAX: 0000000000000008 RBX: ffff88003d88e248 RCX: 0000000000000004
[  887.485019] RDX: 0000000000000000 RSI: ffff88003d88e248 RDI: ffff88003b235190
[  887.485019] RBP: ffff88003bc71d98 R08: 0000000000000000 R09: 0000000000000000
[  887.485019] R10: 0000000000000000 R11: 0000000000000000 R12: ffff88003d88e268
[  887.485019] R13: ffff88003d88e238 R14: ffff88003d88d550 R15: 0000000000000005
[  887.485019] FS:  00007f7de7389740(0000) GS:ffff88003fc00000(0000) knlGS:0000000000000000
[  887.485019] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  887.485019] CR2: 0000000000000018 CR3: 000000003d1de000 CR4: 00000000000006f0
[  887.485019] Stack:
[  887.485019]  ffff88003bc71db0 ffffffff81673f4a ffff88003d88d3c0 ffff88003bc71de0
[  887.485019]  ffffffff815c4bbe ffff88003d88d3c0 0000000000000000 ffff88003d88d420
[  887.485019]  ffff88003d88d550 ffff88003bc71e28 ffffffff8164b017 ffffffff8164af41
[  887.485019] Call Trace:
[  887.485019]  [<ffffffff81673f4a>] register_cpu_notifier+0x2a/0x40
[  887.485019]  [<ffffffff815c4bbe>] flow_cache_init+0x1de/0x2b0
[  887.485019]  [<ffffffff8164b017>] xfrm_net_init+0x227/0x360
[  887.485019]  [<ffffffff8164af41>] ? xfrm_net_init+0x151/0x360
[  887.485019]  [<ffffffff815a5921>] ops_init+0x41/0x150
[  887.485019]  [<ffffffff815a5aa3>] setup_net+0x73/0x110
[  887.485019]  [<ffffffff815a5fe2>] copy_net_ns+0x72/0x100
[  887.485019]  [<ffffffff810943f9>] create_new_namespaces+0xf9/0x190
[  887.485019]  [<ffffffff81094671>] unshare_nsproxy_namespaces+0x61/0xa0
[  887.485019]  [<ffffffff8106b419>] SyS_unshare+0x159/0x270
[  887.485019]  [<ffffffff8168cb69>] system_call_fastpath+0x16/0x1b
[  887.485019] Code: 4c 63 f8 e9 7b ff ff ff 0f 1f 00 66 66 66 66 90 55 48 8b 07 48 89 e5 48 85 c0 74 21 8b 56 10 3b 50 10 7e 0c eb 17 0f 1f 44 00 00 <39> 50 10 7c 0d 48 8d 78 08 48 8b 40 08 48 85 c0 75 ee 48 89 46 
[  887.485019] RIP  [<ffffffff81094840>] raw_notifier_chain_register+0x20/0x40
[  887.485019]  RSP <ffff88003bc71d98>
[  887.485019] CR2: 0000000000000018

If I let the machine run for a few minutes (without adding netns, just with libvirtd running), I get the following:

[ 1173.850646] WARNING: CPU: 1 PID: 0 at /home/kuba/Development/Linux/net-next/lib/list_debug.c:33 __list_add+0xac/0xc0()
[ 1173.850892] list_add corruption. prev->next should be next (ffffffff81e8e648), but was 0000000000010000. (prev=ffff88003b2351a8).
[ 1173.851333] Modules linked in: cfg80211 rfkill xt_conntrack iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw ppdev serio_raw virtio_console virtio_balloon i2c_piix4 floppy parport_pc parport nfsd auth_rpcgss nfs_acl lockd sunrpc virtio_blk virtio_net qxl drm_kms_helper ttm virtio_pci virtio_ring virtio
[ 1173.851576] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G      D      3.14.0-rc5+ #1
[ 1173.851576] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[ 1173.851576]  0000000000000009 ffff88003fd03928 ffffffff8167baf0 ffff88003fd03970
[ 1173.851576]  ffff88003fd03960 ffffffff8106bd5d ffff88003bee03e0 ffffffff81e8e648
[ 1173.851576]  ffff88003b2351a8 ffffffff81e8d180 000000010011e95a ffff88003fd039c0
[ 1173.851576] Call Trace:
[ 1173.851576]  <IRQ>  [<ffffffff8167baf0>] dump_stack+0x4d/0x66
[ 1173.851576]  [<ffffffff8106bd5d>] warn_slowpath_common+0x7d/0xa0
[ 1173.851576]  [<ffffffff8106bdcc>] warn_slowpath_fmt+0x4c/0x50
[ 1173.851576]  [<ffffffff813217ac>] __list_add+0xac/0xc0
[ 1173.851576]  [<ffffffff810778b3>] __internal_add_timer+0x113/0x130
[ 1173.851576]  [<ffffffff81077ac7>] internal_add_timer+0x17/0x40
[ 1173.851576]  [<ffffffff8107a1fd>] mod_timer_pending+0xfd/0x190
[ 1173.851576]  [<ffffffffa0171748>] __nf_ct_refresh_acct+0xb8/0xd0 [nf_conntrack]
[ 1173.851576]  [<ffffffffa01793a0>] tcp_packet+0x6c0/0x14c0 [nf_conntrack]
[ 1173.851576]  [<ffffffffa01729bd>] ? __nf_conntrack_find_get+0x2fd/0x350 [nf_conntrack]
[ 1173.851576]  [<ffffffffa01726c5>] ? __nf_conntrack_find_get+0x5/0x350 [nf_conntrack]
[ 1173.851576]  [<ffffffffa017393c>] nf_conntrack_in+0x34c/0xa00 [nf_conntrack]
[ 1173.851576]  [<ffffffff815ea050>] ? ip_local_deliver_finish+0x330/0x330
[ 1173.851576]  [<ffffffffa019e2d2>] ipv4_conntrack_in+0x22/0x30 [nf_conntrack_ipv4]
[ 1173.851576]  [<ffffffff815e085a>] nf_iterate+0x9a/0xb0
[ 1173.851576]  [<ffffffff815ea050>] ? ip_local_deliver_finish+0x330/0x330
[ 1173.851576]  [<ffffffff815e0914>] nf_hook_slow+0xa4/0x170
[ 1173.851576]  [<ffffffff815ea050>] ? ip_local_deliver_finish+0x330/0x330
[ 1173.851576]  [<ffffffff815eab48>] ip_rcv+0x2f8/0x3d0
[ 1173.851576]  [<ffffffff815ade16>] __netif_receive_skb_core+0x6c6/0x8b0
[ 1173.851576]  [<ffffffff815ad852>] ? __netif_receive_skb_core+0x102/0x8b0
[ 1173.851576]  [<ffffffff815ae018>] __netif_receive_skb+0x18/0x60
[ 1173.851576]  [<ffffffff815ae093>] netif_receive_skb_internal+0x33/0x120
[ 1173.851576]  [<ffffffff815ae19c>] netif_receive_skb+0x1c/0x70
[ 1173.851576]  [<ffffffffa00166ea>] virtnet_poll+0x4ea/0x840 [virtio_net]
[ 1173.851576]  [<ffffffff815ae56a>] net_rx_action+0x15a/0x270
[ 1173.851576]  [<ffffffff81071345>] __do_softirq+0xf5/0x2b0
[ 1173.851576]  [<ffffffff8107177d>] irq_exit+0xbd/0xd0
[ 1173.851576]  [<ffffffff8168ea48>] do_IRQ+0x58/0xf0
[ 1173.851576]  [<ffffffff81683fed>] common_interrupt+0x6d/0x6d
[ 1173.851576]  <EOI>  [<ffffffff81687dd5>] ? __atomic_notifier_call_chain+0x5/0xa0
[ 1173.851576]  [<ffffffff8103b3f6>] ? native_safe_halt+0x6/0x10
[ 1173.851576]  [<ffffffff8100b8cf>] default_idle+0x1f/0xe0
[ 1173.851576]  [<ffffffff8100c206>] arch_cpu_idle+0x26/0x30
[ 1173.851576]  [<ffffffff810c8d5e>] cpu_startup_entry+0x9e/0x260
[ 1173.851576]  [<ffffffff8102ec04>] start_secondary+0x1d4/0x280

Or a similar warning related to adding a timer to the list (not necessarily network related timer). After a few seconds/minutes the machine freezes (I guess it happens when the broken timer fires).

It didn't happen on wireless-testing from a week ago, but I didn't have time today to bisect :/

	-- kuba
#1 lore raw
Quoted 33 lines · Jakub Kicinski

Hi!

Running Fedora 20 with net-next I get the following warning when libvirt or rtkit comes up:

[  272.143488] kmem_cache_sanity_check (flow_cache): Cache name already exists.
[  272.143586] CPU: 0 PID: 975 Comm: libvirtd Not tainted 3.14.0-rc5+ #1
[  272.143589] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[  272.143591]  0000000000000000 ffff88003ceadba0 ffffffff8167baf0 ffff88003db3d300
[  272.143595]  ffff88003ceadc18 ffffffff8117795b ffff88003ceadbc8 ffff88003b235158
[  272.143599]  0000000000000000 0000000000040000 0000000000000068 0000000000000000
[  272.143602] Call Trace:
[  272.143610]  [<ffffffff8167baf0>] dump_stack+0x4d/0x66
[  272.143615]  [<ffffffff8117795b>] kmem_cache_create_memcg+0x12b/0x420
[  272.143618]  [<ffffffff81177c7b>] kmem_cache_create+0x2b/0x30
[  272.143622]  [<ffffffff815c4a0e>] flow_cache_init+0x2e/0x2b0
[  272.143626]  [<ffffffff8164b017>] xfrm_net_init+0x227/0x360
[  272.143629]  [<ffffffff8164af41>] ? xfrm_net_init+0x151/0x360
[  272.143632]  [<ffffffff815a5921>] ops_init+0x41/0x150
[  272.143635]  [<ffffffff815a5aa3>] setup_net+0x73/0x110
[  272.143638]  [<ffffffff815a5fe2>] copy_net_ns+0x72/0x100
[  272.143642]  [<ffffffff810943f9>] create_new_namespaces+0xf9/0x190
[  272.143645]  [<ffffffff81094560>] copy_namespaces+0xd0/0xf0
[  272.143648]  [<ffffffff81094495>] ? copy_namespaces+0x5/0xf0
[  272.143651]  [<ffffffff81069be0>] copy_process.part.31+0x950/0x1b30
[  272.143655]  [<ffffffff8106af95>] do_fork+0xd5/0x370
[  272.143658]  [<ffffffff811c1b2d>] ? __fput+0x17d/0x240
[  272.143662]  [<ffffffff8110440c>] ? __audit_syscall_entry+0x9c/0xf0
[  272.143665]  [<ffffffff8106b2b6>] SyS_clone+0x16/0x20
[  272.143669]  [<ffffffff8168cf19>] stub_clone+0x69/0x90
[  272.143673]  [<ffffffff8168cb69>] ? system_call_fastpath+0x16/0x1b
Quoted 3 lines

When I try to add a netns with

# ip netns add abcd
I it dies with:

Yep, commit ca925cf1534ebcec332c08719a7dee6ee1782ce4 is buggy.

flowcache: Make flow cache name space aware

Inserting a entry into flowcache, or flushing flowcache should be based on per net scope. The reason to do so is flushing operation from fat netns crammed with flow entries will also making the slim netns with only a few flow cache entries go away in original implementation.

Since flowcache is tightly coupled with IPsec, so it would be easier to put flow cache global parameters into xfrm namespace part. And one last thing needs to do is bumping flow cache genid, and flush flow cache should also be made in per net style.

I fail to understand why the kmem_cache must be private to a netns.

#2 lore raw
Quoted 53 lines · Eric Dumazet
Quoted 33 lines · Jakub Kicinski

Hi!

Running Fedora 20 with net-next I get the following warning when libvirt or rtkit comes up:

[  272.143488] kmem_cache_sanity_check (flow_cache): Cache name already exists.
[  272.143586] CPU: 0 PID: 975 Comm: libvirtd Not tainted 3.14.0-rc5+ #1
[  272.143589] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[  272.143591]  0000000000000000 ffff88003ceadba0 ffffffff8167baf0 ffff88003db3d300
[  272.143595]  ffff88003ceadc18 ffffffff8117795b ffff88003ceadbc8 ffff88003b235158
[  272.143599]  0000000000000000 0000000000040000 0000000000000068 0000000000000000
[  272.143602] Call Trace:
[  272.143610]  [<ffffffff8167baf0>] dump_stack+0x4d/0x66
[  272.143615]  [<ffffffff8117795b>] kmem_cache_create_memcg+0x12b/0x420
[  272.143618]  [<ffffffff81177c7b>] kmem_cache_create+0x2b/0x30
[  272.143622]  [<ffffffff815c4a0e>] flow_cache_init+0x2e/0x2b0
[  272.143626]  [<ffffffff8164b017>] xfrm_net_init+0x227/0x360
[  272.143629]  [<ffffffff8164af41>] ? xfrm_net_init+0x151/0x360
[  272.143632]  [<ffffffff815a5921>] ops_init+0x41/0x150
[  272.143635]  [<ffffffff815a5aa3>] setup_net+0x73/0x110
[  272.143638]  [<ffffffff815a5fe2>] copy_net_ns+0x72/0x100
[  272.143642]  [<ffffffff810943f9>] create_new_namespaces+0xf9/0x190
[  272.143645]  [<ffffffff81094560>] copy_namespaces+0xd0/0xf0
[  272.143648]  [<ffffffff81094495>] ? copy_namespaces+0x5/0xf0
[  272.143651]  [<ffffffff81069be0>] copy_process.part.31+0x950/0x1b30
[  272.143655]  [<ffffffff8106af95>] do_fork+0xd5/0x370
[  272.143658]  [<ffffffff811c1b2d>] ? __fput+0x17d/0x240
[  272.143662]  [<ffffffff8110440c>] ? __audit_syscall_entry+0x9c/0xf0
[  272.143665]  [<ffffffff8106b2b6>] SyS_clone+0x16/0x20
[  272.143669]  [<ffffffff8168cf19>] stub_clone+0x69/0x90
[  272.143673]  [<ffffffff8168cb69>] ? system_call_fastpath+0x16/0x1b
Quoted 3 lines

When I try to add a netns with

# ip netns add abcd
I it dies with:

Yep, commit ca925cf1534ebcec332c08719a7dee6ee1782ce4 is buggy.

flowcache: Make flow cache name space aware

Inserting a entry into flowcache, or flushing flowcache should be based on per net scope. The reason to do so is flushing operation from fat netns crammed with flow entries will also making the slim netns with only a few flow cache entries go away in original implementation.

Since flowcache is tightly coupled with IPsec, so it would be easier to put flow cache global parameters into xfrm namespace part. And one last thing needs to do is bumping flow cache genid, and flush flow cache should also be made in per net style.

Quoted 4 lines

I fail to understand why the kmem_cache must be private to a netns.

Could you please try the following patch ?

include/net/netns/xfrm.h +0 -1
index 51f0dce7b643..3492434baf88 100644
@@ -64,7 +64,6 @@ struct netns_xfrm {
 
 	/* flow cache part */
 	struct flow_cache	flow_cache_global;
-	struct kmem_cache	*flow_cachep;
 	atomic_t		flow_cache_genid;
 	struct list_head	flow_cache_gc_list;
 	spinlock_t		flow_cache_gc_lock;
net/core/flow.c +8 -6
index 344a184011fd..102f8ea2eb6e 100644
@@ -45,6 +45,8 @@ struct flow_flush_info {
 	struct completion		completion;
 };
 
+static struct kmem_cache *flow_cachep __read_mostly;
+
 #define flow_cache_hash_size(cache)	(1 << (cache)->hash_shift)
 #define FLOW_HASH_RND_PERIOD		(10 * 60 * HZ)
 
@@ -75,7 +77,7 @@ static void flow_entry_kill(struct flow_cache_entry *fle,
 {
 	if (fle->object)
 		fle->object->ops->delete(fle->object);
-	kmem_cache_free(xfrm->flow_cachep, fle);
+	kmem_cache_free(flow_cachep, fle);
 }
 
 static void flow_cache_gc_task(struct work_struct *work)
@@ -230,7 +232,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
 		if (fcp->hash_count > fc->high_watermark)
 			flow_cache_shrink(fc, fcp);
 
-		fle = kmem_cache_alloc(net->xfrm.flow_cachep, GFP_ATOMIC);
+		fle = kmem_cache_alloc(flow_cachep, GFP_ATOMIC);
 		if (fle) {
 			fle->net = net;
 			fle->family = family;
@@ -435,10 +437,10 @@ int flow_cache_init(struct net *net)
 	int i;
 	struct flow_cache *fc = &net->xfrm.flow_cache_global;
 
-	/* Initialize per-net flow cache global variables here */
-	net->xfrm.flow_cachep = kmem_cache_create("flow_cache",
-					sizeof(struct flow_cache_entry),
-					0, SLAB_PANIC, NULL);
+	if (!flow_cachep)
+		flow_cachep = kmem_cache_create("flow_cache",
+						sizeof(struct flow_cache_entry),
+						0, SLAB_PANIC, NULL);
 	spin_lock_init(&net->xfrm.flow_cache_gc_lock);
 	INIT_LIST_HEAD(&net->xfrm.flow_cache_gc_list);
 	INIT_WORK(&net->xfrm.flow_cache_gc_work, flow_cache_gc_task);
Tested-by
#3 lore raw
Quoted 54 lines · Eric Dumazet
Quoted 53 lines · Eric Dumazet
Quoted 33 lines · Jakub Kicinski

Hi!

Running Fedora 20 with net-next I get the following warning when libvirt or rtkit comes up:

[  272.143488] kmem_cache_sanity_check (flow_cache): Cache name already exists.
[  272.143586] CPU: 0 PID: 975 Comm: libvirtd Not tainted 3.14.0-rc5+ #1
[  272.143589] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[  272.143591]  0000000000000000 ffff88003ceadba0 ffffffff8167baf0 ffff88003db3d300
[  272.143595]  ffff88003ceadc18 ffffffff8117795b ffff88003ceadbc8 ffff88003b235158
[  272.143599]  0000000000000000 0000000000040000 0000000000000068 0000000000000000
[  272.143602] Call Trace:
[  272.143610]  [<ffffffff8167baf0>] dump_stack+0x4d/0x66
[  272.143615]  [<ffffffff8117795b>] kmem_cache_create_memcg+0x12b/0x420
[  272.143618]  [<ffffffff81177c7b>] kmem_cache_create+0x2b/0x30
[  272.143622]  [<ffffffff815c4a0e>] flow_cache_init+0x2e/0x2b0
[  272.143626]  [<ffffffff8164b017>] xfrm_net_init+0x227/0x360
[  272.143629]  [<ffffffff8164af41>] ? xfrm_net_init+0x151/0x360
[  272.143632]  [<ffffffff815a5921>] ops_init+0x41/0x150
[  272.143635]  [<ffffffff815a5aa3>] setup_net+0x73/0x110
[  272.143638]  [<ffffffff815a5fe2>] copy_net_ns+0x72/0x100
[  272.143642]  [<ffffffff810943f9>] create_new_namespaces+0xf9/0x190
[  272.143645]  [<ffffffff81094560>] copy_namespaces+0xd0/0xf0
[  272.143648]  [<ffffffff81094495>] ? copy_namespaces+0x5/0xf0
[  272.143651]  [<ffffffff81069be0>] copy_process.part.31+0x950/0x1b30
[  272.143655]  [<ffffffff8106af95>] do_fork+0xd5/0x370
[  272.143658]  [<ffffffff811c1b2d>] ? __fput+0x17d/0x240
[  272.143662]  [<ffffffff8110440c>] ? __audit_syscall_entry+0x9c/0xf0
[  272.143665]  [<ffffffff8106b2b6>] SyS_clone+0x16/0x20
[  272.143669]  [<ffffffff8168cf19>] stub_clone+0x69/0x90
[  272.143673]  [<ffffffff8168cb69>] ? system_call_fastpath+0x16/0x1b
Quoted 3 lines

When I try to add a netns with

# ip netns add abcd
I it dies with:

Yep, commit ca925cf1534ebcec332c08719a7dee6ee1782ce4 is buggy.

flowcache: Make flow cache name space aware

Inserting a entry into flowcache, or flushing flowcache should be based on per net scope. The reason to do so is flushing operation from fat netns crammed with flow entries will also making the slim netns with only a few flow cache entries go away in original implementation.

Since flowcache is tightly coupled with IPsec, so it would be easier to put flow cache global parameters into xfrm namespace part. And one last thing needs to do is bumping flow cache genid, and flush flow cache should also be made in per net style.

Quoted 4 lines
Quoted 4 lines

I fail to understand why the kmem_cache must be private to a netns.

Sorry, I didn't turn on CONFIG_DEBUG_VM before...

Sometimes network activity only on netns could trigger bugs like memory leakage, using per-netns kmem_cache could help to identify which netns to be blamed.

Anyway if this is inappropriate, let's make it global as you did below.

Quoted 2 lines

Could you please try the following patch ?

Quoted 61 lines
include/net/netns/xfrm.h +0 -1
index 51f0dce7b643..3492434baf88 100644
@@ -64,7 +64,6 @@ struct netns_xfrm {
 
  	/* flow cache part */
  	struct flow_cache	flow_cache_global;
-	struct kmem_cache	*flow_cachep;
  	atomic_t		flow_cache_genid;
  	struct list_head	flow_cache_gc_list;
  	spinlock_t		flow_cache_gc_lock;
net/core/flow.c +8 -6
index 344a184011fd..102f8ea2eb6e 100644
@@ -45,6 +45,8 @@ struct flow_flush_info {
  	struct completion		completion;
  };
 
+static struct kmem_cache *flow_cachep __read_mostly;
+
  #define flow_cache_hash_size(cache)	(1<<  (cache)->hash_shift)
  #define FLOW_HASH_RND_PERIOD		(10 * 60 * HZ)
 
@@ -75,7 +77,7 @@ static void flow_entry_kill(struct flow_cache_entry *fle,
  {
  	if (fle->object)
  		fle->object->ops->delete(fle->object);
-	kmem_cache_free(xfrm->flow_cachep, fle);
+	kmem_cache_free(flow_cachep, fle);
  }
 
  static void flow_cache_gc_task(struct work_struct *work)
@@ -230,7 +232,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
  		if (fcp->hash_count>  fc->high_watermark)
  			flow_cache_shrink(fc, fcp);
 
-		fle = kmem_cache_alloc(net->xfrm.flow_cachep, GFP_ATOMIC);
+		fle = kmem_cache_alloc(flow_cachep, GFP_ATOMIC);
  		if (fle) {
  			fle->net = net;
  			fle->family = family;
@@ -435,10 +437,10 @@ int flow_cache_init(struct net *net)
  	int i;
  	struct flow_cache *fc =&net->xfrm.flow_cache_global;
 
-	/* Initialize per-net flow cache global variables here */
-	net->xfrm.flow_cachep = kmem_cache_create("flow_cache",
-					sizeof(struct flow_cache_entry),
-					0, SLAB_PANIC, NULL);
+	if (!flow_cachep)
+		flow_cachep = kmem_cache_create("flow_cache",
+						sizeof(struct flow_cache_entry),
+						0, SLAB_PANIC, NULL);
  	spin_lock_init(&net->xfrm.flow_cache_gc_lock);
  	INIT_LIST_HEAD(&net->xfrm.flow_cache_gc_list);
  	INIT_WORK(&net->xfrm.flow_cache_gc_work, flow_cache_gc_task);
Signature · 3 lines
浮沉随浪只记今朝笑

--fan
#4 lore raw
Quoted 4 lines · Fan Du

Sometimes network activity only on netns could trigger bugs like memory leakage, using per-netns kmem_cache could help to identify which netns to be blamed.

Anyway if this is inappropriate, let's make it global as you did below.

But you forgot to kmem_cache_destroy() the cache at netns removal, so this also is a leak ;)

#5 lore raw

PATCH 1/1 flowcache: restore a single flow_cache kmem_cache

From: Eric Dumazet <[email protected]>

It is not legal to create multiple kmem_cache having the same name.

flowcache can use a single kmem_cache, no need for a per netns one.

Fixes ca925cf1534e ("flowcache: Make flow cache name space aware")
---
 include/net/netns/xfrm.h |    1 -
 net/core/flow.c          |   14 ++++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)
include/net/netns/xfrm.h +0 -1
index 51f0dce7b643..3492434baf88 100644
@@ -64,7 +64,6 @@ struct netns_xfrm {
 
 	/* flow cache part */
 	struct flow_cache	flow_cache_global;
-	struct kmem_cache	*flow_cachep;
 	atomic_t		flow_cache_genid;
 	struct list_head	flow_cache_gc_list;
 	spinlock_t		flow_cache_gc_lock;
net/core/flow.c +8 -6
index 344a184011fd..102f8ea2eb6e 100644
@@ -45,6 +45,8 @@ struct flow_flush_info {
 	struct completion		completion;
 };
 
+static struct kmem_cache *flow_cachep __read_mostly;
+
 #define flow_cache_hash_size(cache)	(1 << (cache)->hash_shift)
 #define FLOW_HASH_RND_PERIOD		(10 * 60 * HZ)
 
@@ -75,7 +77,7 @@ static void flow_entry_kill(struct flow_cache_entry *fle,
 {
 	if (fle->object)
 		fle->object->ops->delete(fle->object);
-	kmem_cache_free(xfrm->flow_cachep, fle);
+	kmem_cache_free(flow_cachep, fle);
 }
 
 static void flow_cache_gc_task(struct work_struct *work)
@@ -230,7 +232,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
 		if (fcp->hash_count > fc->high_watermark)
 			flow_cache_shrink(fc, fcp);
 
-		fle = kmem_cache_alloc(net->xfrm.flow_cachep, GFP_ATOMIC);
+		fle = kmem_cache_alloc(flow_cachep, GFP_ATOMIC);
 		if (fle) {
 			fle->net = net;
 			fle->family = family;
@@ -435,10 +437,10 @@ int flow_cache_init(struct net *net)
 	int i;
 	struct flow_cache *fc = &net->xfrm.flow_cache_global;
 
-	/* Initialize per-net flow cache global variables here */
-	net->xfrm.flow_cachep = kmem_cache_create("flow_cache",
-					sizeof(struct flow_cache_entry),
-					0, SLAB_PANIC, NULL);
+	if (!flow_cachep)
+		flow_cachep = kmem_cache_create("flow_cache",
+						sizeof(struct flow_cache_entry),
+						0, SLAB_PANIC, NULL);
 	spin_lock_init(&net->xfrm.flow_cache_gc_lock);
 	INIT_LIST_HEAD(&net->xfrm.flow_cache_gc_list);
 	INIT_WORK(&net->xfrm.flow_cache_gc_work, flow_cache_gc_task);
maintainer
#6 lore raw

Re: [PATCH net-next] flowcache: restore a single flow_cache kmem_cache

From: Eric Dumazet <[email protected]>
Date: Mon, 10 Mar 2014 07:09:07 -0700

Quoted 4 lines

From: Eric Dumazet <[email protected]>

It is not legal to create multiple kmem_cache having the same name.

Quoted 8 lines

flowcache can use a single kmem_cache, no need for a per netns one.

Fixes ca925cf1534e ("flowcache: Make flow cache name space aware")

I'll apply this directly to net-next, thanks Eric!

#7 lore raw
In reply to Eric Dumazet
Quoted 54 lines · Eric Dumazet
Quoted 53 lines · Eric Dumazet
Quoted 33 lines · Jakub Kicinski

Hi!

Running Fedora 20 with net-next I get the following warning when libvirt or rtkit comes up:

[  272.143488] kmem_cache_sanity_check (flow_cache): Cache name already exists.
[  272.143586] CPU: 0 PID: 975 Comm: libvirtd Not tainted 3.14.0-rc5+ #1
[  272.143589] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[  272.143591]  0000000000000000 ffff88003ceadba0 ffffffff8167baf0 ffff88003db3d300
[  272.143595]  ffff88003ceadc18 ffffffff8117795b ffff88003ceadbc8 ffff88003b235158
[  272.143599]  0000000000000000 0000000000040000 0000000000000068 0000000000000000
[  272.143602] Call Trace:
[  272.143610]  [<ffffffff8167baf0>] dump_stack+0x4d/0x66
[  272.143615]  [<ffffffff8117795b>] kmem_cache_create_memcg+0x12b/0x420
[  272.143618]  [<ffffffff81177c7b>] kmem_cache_create+0x2b/0x30
[  272.143622]  [<ffffffff815c4a0e>] flow_cache_init+0x2e/0x2b0
[  272.143626]  [<ffffffff8164b017>] xfrm_net_init+0x227/0x360
[  272.143629]  [<ffffffff8164af41>] ? xfrm_net_init+0x151/0x360
[  272.143632]  [<ffffffff815a5921>] ops_init+0x41/0x150
[  272.143635]  [<ffffffff815a5aa3>] setup_net+0x73/0x110
[  272.143638]  [<ffffffff815a5fe2>] copy_net_ns+0x72/0x100
[  272.143642]  [<ffffffff810943f9>] create_new_namespaces+0xf9/0x190
[  272.143645]  [<ffffffff81094560>] copy_namespaces+0xd0/0xf0
[  272.143648]  [<ffffffff81094495>] ? copy_namespaces+0x5/0xf0
[  272.143651]  [<ffffffff81069be0>] copy_process.part.31+0x950/0x1b30
[  272.143655]  [<ffffffff8106af95>] do_fork+0xd5/0x370
[  272.143658]  [<ffffffff811c1b2d>] ? __fput+0x17d/0x240
[  272.143662]  [<ffffffff8110440c>] ? __audit_syscall_entry+0x9c/0xf0
[  272.143665]  [<ffffffff8106b2b6>] SyS_clone+0x16/0x20
[  272.143669]  [<ffffffff8168cf19>] stub_clone+0x69/0x90
[  272.143673]  [<ffffffff8168cb69>] ? system_call_fastpath+0x16/0x1b
Quoted 3 lines

When I try to add a netns with

# ip netns add abcd
I it dies with:

Yep, commit ca925cf1534ebcec332c08719a7dee6ee1782ce4 is buggy.

flowcache: Make flow cache name space aware

Inserting a entry into flowcache, or flushing flowcache should be based on per net scope. The reason to do so is flushing operation from fat netns crammed with flow entries will also making the slim netns with only a few flow cache entries go away in original implementation.

Since flowcache is tightly coupled with IPsec, so it would be easier to put flow cache global parameters into xfrm namespace part. And one last thing needs to do is bumping flow cache genid, and flush flow cache should also be made in per net style.

Quoted 6 lines
Quoted 4 lines

I fail to understand why the kmem_cache must be private to a netns.

Could you please try the following patch ?

It helps with the flow_cache warning and BUG ("ip netns add" works) but machine still freezes after 5-10 minutes. I will try to revert ca925cf1534ebcec332c08719a7dee6ee1782ce4 and see if that solves it.

	-- kuba
Quoted 61 lines
include/net/netns/xfrm.h +0 -1
index 51f0dce7b643..3492434baf88 100644
@@ -64,7 +64,6 @@ struct netns_xfrm {
 
 	/* flow cache part */
 	struct flow_cache	flow_cache_global;
-	struct kmem_cache	*flow_cachep;
 	atomic_t		flow_cache_genid;
 	struct list_head	flow_cache_gc_list;
 	spinlock_t		flow_cache_gc_lock;
net/core/flow.c +8 -6
index 344a184011fd..102f8ea2eb6e 100644
@@ -45,6 +45,8 @@ struct flow_flush_info {
 	struct completion		completion;
 };
 
+static struct kmem_cache *flow_cachep __read_mostly;
+
 #define flow_cache_hash_size(cache)	(1 << (cache)->hash_shift)
 #define FLOW_HASH_RND_PERIOD		(10 * 60 * HZ)
 
@@ -75,7 +77,7 @@ static void flow_entry_kill(struct flow_cache_entry *fle,
 {
 	if (fle->object)
 		fle->object->ops->delete(fle->object);
-	kmem_cache_free(xfrm->flow_cachep, fle);
+	kmem_cache_free(flow_cachep, fle);
 }
 
 static void flow_cache_gc_task(struct work_struct *work)
@@ -230,7 +232,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
 		if (fcp->hash_count > fc->high_watermark)
 			flow_cache_shrink(fc, fcp);
 
-		fle = kmem_cache_alloc(net->xfrm.flow_cachep, GFP_ATOMIC);
+		fle = kmem_cache_alloc(flow_cachep, GFP_ATOMIC);
 		if (fle) {
 			fle->net = net;
 			fle->family = family;
@@ -435,10 +437,10 @@ int flow_cache_init(struct net *net)
 	int i;
 	struct flow_cache *fc = &net->xfrm.flow_cache_global;
 
-	/* Initialize per-net flow cache global variables here */
-	net->xfrm.flow_cachep = kmem_cache_create("flow_cache",
-					sizeof(struct flow_cache_entry),
-					0, SLAB_PANIC, NULL);
+	if (!flow_cachep)
+		flow_cachep = kmem_cache_create("flow_cache",
+						sizeof(struct flow_cache_entry),
+						0, SLAB_PANIC, NULL);
 	spin_lock_init(&net->xfrm.flow_cache_gc_lock);
 	INIT_LIST_HEAD(&net->xfrm.flow_cache_gc_list);
 	INIT_WORK(&net->xfrm.flow_cache_gc_work, flow_cache_gc_task);
#8 lore raw
Quoted 3 lines · Jakub Kiciński

It helps with the flow_cache warning and BUG ("ip netns add" works) but machine still freezes after 5-10 minutes. I will try to revert ca925cf1534ebcec332c08719a7dee6ee1782ce4 and see if that solves it.

I think the other issue is separate. It might be triggered by conntracking change.

Thanks !

#9 lore raw
Quoted 8 lines · Eric Dumazet
Quoted 3 lines · Jakub Kiciński

It helps with the flow_cache warning and BUG ("ip netns add" works) but machine still freezes after 5-10 minutes. I will try to revert ca925cf1534ebcec332c08719a7dee6ee1782ce4 and see if that solves it.

I think the other issue is separate. It might be triggered by conntracking change.

I bisected the other issue to be caused/uncovered by:

commit 1a1ccc96abb2ed9b8fbb71018e64b97324caef53

Author: Steffen Klassert <[email protected]>
Date:   Wed Feb 19 10:07:34 2014 +0100

xfrm: Remove caching of xfrm_policy_sk_bundles

We currently cache socket policy bundles at xfrm_policy_sk_bundles. These cached bundles are never used. Instead we create and cache a new one whenever xfrm_lookup() is called on a socket policy.

Most protocols cache the used routes to the socket, so let's remove the unused caching of socket policy bundles in xfrm.

Machine freezes after FLOW_HASH_RND_PERIOD (default 10 minutes). Now get this warning during boot:

[   31.664820] ------------[ cut here ]------------
[   31.664824] WARNING: CPU: 2 PID: 3560 at /home/kuba/Development/Linux/net-next/lib/list_debug.c:33 __list_add+0xac/0xc0()
[   31.664826] list_add corruption. prev->next should be next (ffff880224579598), but was           (null). (prev=ffff8802106140e8).
[   31.664827] Modules linked in: xt_CHECKSUM tun bridge stp llc ccm xt_conntrack iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw ftdi_sio arc4 rt2800pci rt2800mmio rt2800lib crc_ccitt eeprom_93cx6 rt2x00pci kvm_amd rt2x00mmio rt2x00lib mac80211 kvm snd_ca0106 cfg80211 e1000e snd_ac97_codec ac97_bus microcode serio_raw ptp i2c_piix4 k10temp acpi_cpufreq pps_core wmi r8169 mii rfkill nfsd auth_rpcgss nfs_acl lockd binfmt_misc sunrpc usb_storage radeon drm_kms_helper ttm
[   31.664855] CPU: 2 PID: 3560 Comm: (t-daemon) Not tainted 3.14.0-rc2-1a1ccc96abb2ed9b8fbb71018e64b97324caef53+ #11
[   31.664856] Hardware name: Gigabyte Technology Co., Ltd. GA-MA790XT-UD4P/GA-MA790XT-UD4P, BIOS F9b 08/17/2012
[   31.664857]  0000000000000009 ffff8802242e7c70 ffffffff81627878 ffff8802242e7cb8
[   31.664859]  ffff8802242e7ca8 ffffffff8104a28d ffff880210610ea8 ffff880224579598
[   31.664861]  ffff8802106140e8 ffff880224578000 0000000000000000 ffff8802242e7d08
[   31.664863] Call Trace:
[   31.664865]  [<ffffffff81627878>] dump_stack+0x4d/0x66
[   31.664867]  [<ffffffff8104a28d>] warn_slowpath_common+0x7d/0xa0
[   31.664869]  [<ffffffff8104a2fc>] warn_slowpath_fmt+0x4c/0x50
[   31.664871]  [<ffffffff812fdd8c>] __list_add+0xac/0xc0
[   31.664873]  [<ffffffff81055d33>] __internal_add_timer+0x113/0x130
[   31.664875]  [<ffffffff81055f47>] internal_add_timer+0x17/0x40
[   31.664876]  [<ffffffff810587b2>] mod_timer+0x102/0x230
[   31.664878]  [<ffffffff810588f8>] add_timer+0x18/0x20
[   31.664880]  [<ffffffff81572204>] flow_cache_init+0x224/0x2b0
[   31.664882]  [<ffffffff815f7247>] xfrm_net_init+0x227/0x360
[   31.664884]  [<ffffffff815f7171>] ? xfrm_net_init+0x151/0x360
[   31.664886]  [<ffffffff81553131>] ops_init+0x41/0x150
[   31.664888]  [<ffffffff815532b3>] setup_net+0x73/0x110
[   31.664890]  [<ffffffff815537f2>] copy_net_ns+0x72/0x100
[   31.664892]  [<ffffffff81072619>] create_new_namespaces+0xf9/0x190
[   31.664894]  [<ffffffff81072891>] unshare_nsproxy_namespaces+0x61/0xa0
[   31.664895]  [<ffffffff81049949>] SyS_unshare+0x159/0x270
[   31.664897]  [<ffffffff81638092>] system_call_fastpath+0x16/0x1b
	-- kuba
maintainer
#10 lore raw
Quoted 22 lines · Jakub Kiciński
Quoted 8 lines · Eric Dumazet
Quoted 3 lines · Jakub Kiciński

It helps with the flow_cache warning and BUG ("ip netns add" works) but machine still freezes after 5-10 minutes. I will try to revert ca925cf1534ebcec332c08719a7dee6ee1782ce4 and see if that solves it.

I think the other issue is separate. It might be triggered by conntracking change.

I bisected the other issue to be caused/uncovered by:

commit 1a1ccc96abb2ed9b8fbb71018e64b97324caef53

Author: Steffen Klassert <[email protected]>
Date:   Wed Feb 19 10:07:34 2014 +0100

xfrm: Remove caching of xfrm_policy_sk_bundles

We currently cache socket policy bundles at xfrm_policy_sk_bundles. These cached bundles are never used. Instead we create and cache a new one whenever xfrm_lookup() is called on a socket policy.

Quoted 7 lines

Most protocols cache the used routes to the socket, so let's remove the unused caching of socket policy bundles in xfrm.

Machine freezes after FLOW_HASH_RND_PERIOD (default 10 minutes).

Hm, I used this for more than a month before I pushed it upstream. But this was without the flowcache namespace changes, maybe this interferes with the flowcache namespace changes.

I'll look into it, thanks for reporting and bisecting!

maintainer
#11 lore raw
In reply to Jakub Kiciński
Quoted 9 lines · Jakub Kiciński

I bisected the other issue to be caused/uncovered by:

commit 1a1ccc96abb2ed9b8fbb71018e64b97324caef53

Author: Steffen Klassert <[email protected]>
Date:   Wed Feb 19 10:07:34 2014 +0100

xfrm: Remove caching of xfrm_policy_sk_bundles

Quoted 9 lines

We currently cache socket policy bundles at xfrm_policy_sk_bundles. These cached bundles are never used. Instead we create and cache a new one whenever xfrm_lookup() is called on a socket policy.

Most protocols cache the used routes to the socket, so let's remove the unused caching of socket policy bundles in xfrm.

This patch should affect only on the usage of IPsec socket policies. Do you use socket policies, or do you use IPsec at all?

Quoted 24 lines

Machine freezes after FLOW_HASH_RND_PERIOD (default 10 minutes). Now get this warning during boot:

[   31.664820] ------------[ cut here ]------------
[   31.664824] WARNING: CPU: 2 PID: 3560 at /home/kuba/Development/Linux/net-next/lib/list_debug.c:33 __list_add+0xac/0xc0()
[   31.664826] list_add corruption. prev->next should be next (ffff880224579598), but was           (null). (prev=ffff8802106140e8).
[   31.664827] Modules linked in: xt_CHECKSUM tun bridge stp llc ccm xt_conntrack iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw ftdi_sio arc4 rt2800pci rt2800mmio rt2800lib crc_ccitt eeprom_93cx6 rt2x00pci kvm_amd rt2x00mmio rt2x00lib mac80211 kvm snd_ca0106 cfg80211 e1000e snd_ac97_codec ac97_bus microcode serio_raw ptp i2c_piix4 k10temp acpi_cpufreq pps_core wmi r8169 mii rfkill nfsd auth_rpcgss nfs_acl lockd binfmt_misc sunrpc usb_storage radeon drm_kms_helper ttm
[   31.664855] CPU: 2 PID: 3560 Comm: (t-daemon) Not tainted 3.14.0-rc2-1a1ccc96abb2ed9b8fbb71018e64b97324caef53+ #11
[   31.664856] Hardware name: Gigabyte Technology Co., Ltd. GA-MA790XT-UD4P/GA-MA790XT-UD4P, BIOS F9b 08/17/2012
[   31.664857]  0000000000000009 ffff8802242e7c70 ffffffff81627878 ffff8802242e7cb8
[   31.664859]  ffff8802242e7ca8 ffffffff8104a28d ffff880210610ea8 ffff880224579598
[   31.664861]  ffff8802106140e8 ffff880224578000 0000000000000000 ffff8802242e7d08
[   31.664863] Call Trace:
[   31.664865]  [<ffffffff81627878>] dump_stack+0x4d/0x66
[   31.664867]  [<ffffffff8104a28d>] warn_slowpath_common+0x7d/0xa0
[   31.664869]  [<ffffffff8104a2fc>] warn_slowpath_fmt+0x4c/0x50
[   31.664871]  [<ffffffff812fdd8c>] __list_add+0xac/0xc0
[   31.664873]  [<ffffffff81055d33>] __internal_add_timer+0x113/0x130
[   31.664875]  [<ffffffff81055f47>] internal_add_timer+0x17/0x40
[   31.664876]  [<ffffffff810587b2>] mod_timer+0x102/0x230
[   31.664878]  [<ffffffff810588f8>] add_timer+0x18/0x20
[   31.664880]  [<ffffffff81572204>] flow_cache_init+0x224/0x2b0
[   31.664882]  [<ffffffff815f7247>] xfrm_net_init+0x227/0x360
Quoted 9 lines
[   31.664884]  [<ffffffff815f7171>] ? xfrm_net_init+0x151/0x360
[   31.664886]  [<ffffffff81553131>] ops_init+0x41/0x150
[   31.664888]  [<ffffffff815532b3>] setup_net+0x73/0x110
[   31.664890]  [<ffffffff815537f2>] copy_net_ns+0x72/0x100
[   31.664892]  [<ffffffff81072619>] create_new_namespaces+0xf9/0x190
[   31.664894]  [<ffffffff81072891>] unshare_nsproxy_namespaces+0x61/0xa0
[   31.664895]  [<ffffffff81049949>] SyS_unshare+0x159/0x270
[   31.664897]  [<ffffffff81638092>] system_call_fastpath+0x16/0x1b

I was unable to reproduce this here, but it looks like the flowcache namespace changes are still not complete. We leak an active timer and all the allocated resources when we exit a namespace.

Could you please try the patch below?

Also, please send your config if the patch does not fix your problem.

Thanks!

---
 include/net/flow.h     |    1 +
 net/core/flow.c        |   18 ++++++++++++++++++
 net/xfrm/xfrm_policy.c |    7 ++++++-
 3 files changed, 25 insertions(+), 1 deletion(-)
include/net/flow.h +1 -0
index bee3741..64fd248 100644
@@ -219,6 +219,7 @@ struct flow_cache_object *flow_cache_lookup(struct net *net,
 					    u8 dir, flow_resolve_t resolver,
 					    void *ctx);
 int flow_cache_init(struct net *net);
+void flow_cache_fini(struct net *net);
 
 void flow_cache_flush(struct net *net);
 void flow_cache_flush_deferred(struct net *net);
net/core/flow.c +18 -0
index 102f8ea..d31c3c4 100644
@@ -484,3 +484,21 @@ err:
 	return -ENOMEM;
 }
 EXPORT_SYMBOL(flow_cache_init);
+
+void flow_cache_fini(struct net *net)
+{
+	int i;
+	struct flow_cache *fc = &net->xfrm.flow_cache_global;
+
+	del_timer(&fc->rnd_timer);
+
+	for_each_possible_cpu(i) {
+		struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, i);
+		kfree(fcp->hash_table);
+		fcp->hash_table = NULL;
+	}
+
+	free_percpu(fc->percpu);
+	fc->percpu = NULL;
+}
+EXPORT_SYMBOL(flow_cache_fini);
net/xfrm/xfrm_policy.c +6 -1
index a75fae4..f02f511 100644
@@ -2913,15 +2913,19 @@ static int __net_init xfrm_net_init(struct net *net)
 	rv = xfrm_sysctl_init(net);
 	if (rv < 0)
 		goto out_sysctl;
+	rv = flow_cache_init(net);
+	if (rv < 0)
+		goto out;
 
 	/* Initialize the per-net locks here */
 	spin_lock_init(&net->xfrm.xfrm_state_lock);
 	rwlock_init(&net->xfrm.xfrm_policy_lock);
 	mutex_init(&net->xfrm.xfrm_cfg_mutex);
 
-	flow_cache_init(net);
 	return 0;
 
+out:
+	xfrm_sysctl_fini(net);
 out_sysctl:
 	xfrm_policy_fini(net);
 out_policy:
@@ -2934,6 +2938,7 @@ out_statistics:
 
 static void __net_exit xfrm_net_exit(struct net *net)
 {
+	flow_cache_fini(net);
 	xfrm_sysctl_fini(net);
 	xfrm_policy_fini(net);
 	xfrm_state_fini(net);
Signature · 1 line
1.7.9.5
#12 lore raw
Quoted 33 lines · Steffen Klassert

I was unable to reproduce this here, but it looks like the flowcache namespace changes are still not complete. We leak an active timer and all the allocated resources when we exit a namespace.

Could you please try the patch below?

Also, please send your config if the patch does not fix your problem.

Thanks!

---
 include/net/flow.h     |    1 +
 net/core/flow.c        |   18 ++++++++++++++++++
 net/xfrm/xfrm_policy.c |    7 ++++++-
 3 files changed, 25 insertions(+), 1 deletion(-)
include/net/flow.h +1 -0
index bee3741..64fd248 100644
@@ -219,6 +219,7 @@ struct flow_cache_object *flow_cache_lookup(struct net *net,
 					    u8 dir, flow_resolve_t resolver,
 					    void *ctx);
 int flow_cache_init(struct net *net);
+void flow_cache_fini(struct net *net);
 
 void flow_cache_flush(struct net *net);
 void flow_cache_flush_deferred(struct net *net);
net/core/flow.c +0 -0
index 102f8ea..d31c3c4 100644

net/core/flow.c err: · line 493

Quoted 10 lines
net/core/flow.c +7 -0
@@ -484,3 +484,21 @@ err:
 	return -ENOMEM;
 }
 EXPORT_SYMBOL(flow_cache_init);
+
+void flow_cache_fini(struct net *net)
+{
+	int i;
+	struct flow_cache *fc = &net->xfrm.flow_cache_global;
+
+	del_timer(&fc->rnd_timer);

del_timer_sync() I guess is better.

Quoted 44 lines
net/core/flow.c +11 -0
+
+	for_each_possible_cpu(i) {
+		struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, i);
+		kfree(fcp->hash_table);
+		fcp->hash_table = NULL;
+	}
+
+	free_percpu(fc->percpu);
+	fc->percpu = NULL;
+}
+EXPORT_SYMBOL(flow_cache_fini);
net/xfrm/xfrm_policy.c +6 -1
index a75fae4..f02f511 100644
@@ -2913,15 +2913,19 @@ static int __net_init xfrm_net_init(struct net *net)
 	rv = xfrm_sysctl_init(net);
 	if (rv < 0)
 		goto out_sysctl;
+	rv = flow_cache_init(net);
+	if (rv < 0)
+		goto out;
 
 	/* Initialize the per-net locks here */
 	spin_lock_init(&net->xfrm.xfrm_state_lock);
 	rwlock_init(&net->xfrm.xfrm_policy_lock);
 	mutex_init(&net->xfrm.xfrm_cfg_mutex);
 
-	flow_cache_init(net);
 	return 0;
 
+out:
+	xfrm_sysctl_fini(net);
 out_sysctl:
 	xfrm_policy_fini(net);
 out_policy:
@@ -2934,6 +2938,7 @@ out_statistics:
 
 static void __net_exit xfrm_net_exit(struct net *net)
 {
+	flow_cache_fini(net);
 	xfrm_sysctl_fini(net);
 	xfrm_policy_fini(net);
 	xfrm_state_fini(net);
maintainer
#13 lore raw
Quoted 40 lines · Eric Dumazet
Quoted 38 lines · Steffen Klassert

I was unable to reproduce this here, but it looks like the flowcache namespace changes are still not complete. We leak an active timer and all the allocated resources when we exit a namespace.

Could you please try the patch below?

Also, please send your config if the patch does not fix your problem.

Thanks!

---
 include/net/flow.h     |    1 +
 net/core/flow.c        |   18 ++++++++++++++++++
 net/xfrm/xfrm_policy.c |    7 ++++++-
 3 files changed, 25 insertions(+), 1 deletion(-)
include/net/flow.h +1 -0
index bee3741..64fd248 100644
@@ -219,6 +219,7 @@ struct flow_cache_object *flow_cache_lookup(struct net *net,
 					    u8 dir, flow_resolve_t resolver,
 					    void *ctx);
 int flow_cache_init(struct net *net);
+void flow_cache_fini(struct net *net);
 
 void flow_cache_flush(struct net *net);
 void flow_cache_flush_deferred(struct net *net);
net/core/flow.c +2 -0
index 102f8ea..d31c3c4 100644
@@ -484,3 +484,21 @@ err:
 	return -ENOMEM;
 }
 EXPORT_SYMBOL(flow_cache_init);
+
+void flow_cache_fini(struct net *net)
Quoted 9 lines

net/core/flow.c err: · line 493

Quoted 5 lines
net/core/flow.c +5 -0
+{
+	int i;
+	struct flow_cache *fc = &net->xfrm.flow_cache_global;
+
+	del_timer(&fc->rnd_timer);

del_timer_sync() I guess is better.

Right.

I've just noticed that I also forgot to do a
unregister_hotcpu_notifier(&fc->hotcpu_notifier).

Will update the next version according to that.

#14 lore raw
Quoted 51 lines · Steffen Klassert
Quoted 40 lines · Eric Dumazet
Quoted 38 lines · Steffen Klassert

I was unable to reproduce this here, but it looks like the flowcache namespace changes are still not complete. We leak an active timer and all the allocated resources when we exit a namespace.

Could you please try the patch below?

Also, please send your config if the patch does not fix your problem.

Thanks!

---
 include/net/flow.h     |    1 +
 net/core/flow.c        |   18 ++++++++++++++++++
 net/xfrm/xfrm_policy.c |    7 ++++++-
 3 files changed, 25 insertions(+), 1 deletion(-)
include/net/flow.h +1 -0
index bee3741..64fd248 100644
@@ -219,6 +219,7 @@ struct flow_cache_object *flow_cache_lookup(struct net *net,
 					    u8 dir, flow_resolve_t resolver,
 					    void *ctx);
 int flow_cache_init(struct net *net);
+void flow_cache_fini(struct net *net);
 
 void flow_cache_flush(struct net *net);
 void flow_cache_flush_deferred(struct net *net);
net/core/flow.c +2 -0
index 102f8ea..d31c3c4 100644
@@ -484,3 +484,21 @@ err:
 	return -ENOMEM;
 }
 EXPORT_SYMBOL(flow_cache_init);
+
+void flow_cache_fini(struct net *net)
Quoted 9 lines

net/core/flow.c err: · line 493

Quoted 5 lines
net/core/flow.c +5 -0
+{
+	int i;
+	struct flow_cache *fc = &net->xfrm.flow_cache_global;
+
+	del_timer(&fc->rnd_timer);

del_timer_sync() I guess is better.

Quoted 6 lines

Right.

I've just noticed that I also forgot to do a
unregister_hotcpu_notifier(&fc->hotcpu_notifier).

Will update the next version according to that.

Tested with del_timer_sync and unregister_hotcpu_notifier:

void flow_cache_fini(struct net *net)

{
	int i;
	struct flow_cache *fc = &net->xfrm.flow_cache_global;

	unregister_hotcpu_notifier(&fc->hotcpu_notifier);
	del_timer_sync(&fc->rnd_timer);

	for_each_possible_cpu(i) {
		struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, i);
		kfree(fcp->hash_table);
		fcp->hash_table = NULL;
	}

	free_percpu(fc->percpu);
	fc->percpu = NULL;
}

EXPORT_SYMBOL(flow_cache_fini);

Seems to solve both the freeze and the bug on restarting libvirtd/rtkit!

	-- kuba
maintainer
#15 lore raw
Quoted 20 lines · Jakub Kiciński

Tested with del_timer_sync and unregister_hotcpu_notifier:

void flow_cache_fini(struct net *net)

{
	int i;
	struct flow_cache *fc = &net->xfrm.flow_cache_global;

	unregister_hotcpu_notifier(&fc->hotcpu_notifier);
	del_timer_sync(&fc->rnd_timer);

	for_each_possible_cpu(i) {
		struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, i);
		kfree(fcp->hash_table);
		fcp->hash_table = NULL;
	}

	free_percpu(fc->percpu);
	fc->percpu = NULL;
}
Quoted 5 lines

EXPORT_SYMBOL(flow_cache_fini);

Seems to solve both the freeze and the bug on restarting libvirtd/rtkit!

Thanks a lot for testing!

I'll submit the updated patch now.

maintainer
#16 lore raw

PATCH 1/1 flowcache: Fix resource leaks on namespace exit.

We leak an active timer, the hotcpu notifier and all allocated resources when we exit a namespace. Fix this by introducing a flow_cache_fini() function where we release the resources before we exit.

Fixes ca925cf1534e ("flowcache: Make flow cache name space aware")
Cc Eric Dumazet <[email protected]>
Cc Fan Du <[email protected]>
---
 include/net/flow.h     |    1 +
 net/core/flow.c        |   19 +++++++++++++++++++
 net/xfrm/xfrm_policy.c |    7 ++++++-
 3 files changed, 26 insertions(+), 1 deletion(-)
include/net/flow.h +1 -0
index bee3741..64fd248 100644
@@ -219,6 +219,7 @@ struct flow_cache_object *flow_cache_lookup(struct net *net,
 					    u8 dir, flow_resolve_t resolver,
 					    void *ctx);
 int flow_cache_init(struct net *net);
+void flow_cache_fini(struct net *net);
 
 void flow_cache_flush(struct net *net);
 void flow_cache_flush_deferred(struct net *net);
net/core/flow.c +19 -0
index 102f8ea..31cfb36 100644
@@ -484,3 +484,22 @@ err:
 	return -ENOMEM;
 }
 EXPORT_SYMBOL(flow_cache_init);
+
+void flow_cache_fini(struct net *net)
+{
+	int i;
+	struct flow_cache *fc = &net->xfrm.flow_cache_global;
+
+	del_timer_sync(&fc->rnd_timer);
+	unregister_hotcpu_notifier(&fc->hotcpu_notifier);
+
+	for_each_possible_cpu(i) {
+		struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, i);
+		kfree(fcp->hash_table);
+		fcp->hash_table = NULL;
+	}
+
+	free_percpu(fc->percpu);
+	fc->percpu = NULL;
+}
+EXPORT_SYMBOL(flow_cache_fini);
net/xfrm/xfrm_policy.c +6 -1
index a75fae4..f02f511 100644
@@ -2913,15 +2913,19 @@ static int __net_init xfrm_net_init(struct net *net)
 	rv = xfrm_sysctl_init(net);
 	if (rv < 0)
 		goto out_sysctl;
+	rv = flow_cache_init(net);
+	if (rv < 0)
+		goto out;
 
 	/* Initialize the per-net locks here */
 	spin_lock_init(&net->xfrm.xfrm_state_lock);
 	rwlock_init(&net->xfrm.xfrm_policy_lock);
 	mutex_init(&net->xfrm.xfrm_cfg_mutex);
 
-	flow_cache_init(net);
 	return 0;
 
+out:
+	xfrm_sysctl_fini(net);
 out_sysctl:
 	xfrm_policy_fini(net);
 out_policy:
@@ -2934,6 +2938,7 @@ out_statistics:
 
 static void __net_exit xfrm_net_exit(struct net *net)
 {
+	flow_cache_fini(net);
 	xfrm_sysctl_fini(net);
 	xfrm_policy_fini(net);
 	xfrm_state_fini(net);
Signature · 1 line
1.7.9.5
Acked-by on v1 1/1
#17 lore raw

Re: [PATCH net-next] flowcache: Fix resource leaks on namespace exit.

Quoted 5 lines · Steffen Klassert

We leak an active timer, the hotcpu notifier and all allocated resources when we exit a namespace. Fix this by introducing a flow_cache_fini() function where we release the resources before we exit.

Quoted 7 lines
Fixes ca925cf1534e ("flowcache: Make flow cache name space aware")
Cc Eric Dumazet <[email protected]>
Cc Fan Du <[email protected]>

---

maintainer Applied
#18 lore raw

Re: [PATCH net-next] flowcache: Fix resource leaks on namespace exit.

In reply to Steffen Klassert

From: Steffen Klassert <[email protected]>
Date: Wed, 12 Mar 2014 09:43:17 +0100

Quoted 11 lines

We leak an active timer, the hotcpu notifier and all allocated resources when we exit a namespace. Fix this by introducing a flow_cache_fini() function where we release the resources before we exit.

Fixes ca925cf1534e ("flowcache: Make flow cache name space aware")
Cc Eric Dumazet <[email protected]>
Cc Fan Du <[email protected]>

Applied, thanks everyone.

#19 lore raw
In reply to Steffen Klassert
Quoted 14 lines · Steffen Klassert
Quoted 13 lines · Jakub Kiciński

I bisected the other issue to be caused/uncovered by:

commit 1a1ccc96abb2ed9b8fbb71018e64b97324caef53

Author: Steffen Klassert <[email protected]>
Date:   Wed Feb 19 10:07:34 2014 +0100

xfrm: Remove caching of xfrm_policy_sk_bundles

We currently cache socket policy bundles at xfrm_policy_sk_bundles. These cached bundles are never used. Instead we create and cache a new one whenever xfrm_lookup() is called on a socket policy.

Quoted 8 lines
Quoted 5 lines

Most protocols cache the used routes to the socket, so let's remove the unused caching of socket policy bundles in xfrm.

This patch should affect only on the usage of IPsec socket policies. Do you use socket policies, or do you use IPsec at all?

I'm running pretty standard Fedora 20 installation here (notably with NetowrkManager removed). Two daemons that trigger flow_cache warnings are libvirt and rtkit.

I'm not sure how to check IPsec policies, ip xfrm state/policy don't show anything.

Quoted 34 lines
Quoted 24 lines

Machine freezes after FLOW_HASH_RND_PERIOD (default 10 minutes). Now get this warning during boot:

[   31.664820] ------------[ cut here ]------------
[   31.664824] WARNING: CPU: 2 PID: 3560 at /home/kuba/Development/Linux/net-next/lib/list_debug.c:33 __list_add+0xac/0xc0()
[   31.664826] list_add corruption. prev->next should be next (ffff880224579598), but was           (null). (prev=ffff8802106140e8).
[   31.664827] Modules linked in: xt_CHECKSUM tun bridge stp llc ccm xt_conntrack iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw ftdi_sio arc4 rt2800pci rt2800mmio rt2800lib crc_ccitt eeprom_93cx6 rt2x00pci kvm_amd rt2x00mmio rt2x00lib mac80211 kvm snd_ca0106 cfg80211 e1000e snd_ac97_codec ac97_bus microcode serio_raw ptp i2c_piix4 k10temp acpi_cpufreq pps_core wmi r8169 mii rfkill nfsd auth_rpcgss nfs_acl lockd binfmt_misc sunrpc usb_storage radeon drm_kms_helper ttm
[   31.664855] CPU: 2 PID: 3560 Comm: (t-daemon) Not tainted 3.14.0-rc2-1a1ccc96abb2ed9b8fbb71018e64b97324caef53+ #11
[   31.664856] Hardware name: Gigabyte Technology Co., Ltd. GA-MA790XT-UD4P/GA-MA790XT-UD4P, BIOS F9b 08/17/2012
[   31.664857]  0000000000000009 ffff8802242e7c70 ffffffff81627878 ffff8802242e7cb8
[   31.664859]  ffff8802242e7ca8 ffffffff8104a28d ffff880210610ea8 ffff880224579598
[   31.664861]  ffff8802106140e8 ffff880224578000 0000000000000000 ffff8802242e7d08
[   31.664863] Call Trace:
[   31.664865]  [<ffffffff81627878>] dump_stack+0x4d/0x66
[   31.664867]  [<ffffffff8104a28d>] warn_slowpath_common+0x7d/0xa0
[   31.664869]  [<ffffffff8104a2fc>] warn_slowpath_fmt+0x4c/0x50
[   31.664871]  [<ffffffff812fdd8c>] __list_add+0xac/0xc0
[   31.664873]  [<ffffffff81055d33>] __internal_add_timer+0x113/0x130
[   31.664875]  [<ffffffff81055f47>] internal_add_timer+0x17/0x40
[   31.664876]  [<ffffffff810587b2>] mod_timer+0x102/0x230
[   31.664878]  [<ffffffff810588f8>] add_timer+0x18/0x20
[   31.664880]  [<ffffffff81572204>] flow_cache_init+0x224/0x2b0
[   31.664882]  [<ffffffff815f7247>] xfrm_net_init+0x227/0x360
Quoted 9 lines
[   31.664884]  [<ffffffff815f7171>] ? xfrm_net_init+0x151/0x360
[   31.664886]  [<ffffffff81553131>] ops_init+0x41/0x150
[   31.664888]  [<ffffffff815532b3>] setup_net+0x73/0x110
[   31.664890]  [<ffffffff815537f2>] copy_net_ns+0x72/0x100
[   31.664892]  [<ffffffff81072619>] create_new_namespaces+0xf9/0x190
[   31.664894]  [<ffffffff81072891>] unshare_nsproxy_namespaces+0x61/0xa0
[   31.664895]  [<ffffffff81049949>] SyS_unshare+0x159/0x270
[   31.664897]  [<ffffffff81638092>] system_call_fastpath+0x16/0x1b
Quoted 3 lines

I was unable to reproduce this here, but it looks like the flowcache namespace changes are still not complete. We leak an active timer and all the allocated resources when we exit a namespace.

I also failed to reproduce it reliably on a VM. On a VM it happens 50% of the times while on physical machine it's triggered reliably on every boot.

While playing restarting libvirt and rtkit to see it they produce any xfrm noise I got this:

[  292.624771] BUG: soft lockup - CPU#1 stuck for 22s! [(t-daemon):4655]
[  292.624777] Modules linked in: bnep bluetooth 6lowpan_iphc fuse ipt_MASQUERADE xt_CHECKSUM tun bridge stp llc ccm xt_conntrack iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw arc4 rt2800pci rt2800mmio rt2800lib crc_ccitt eeprom_93cx6 rt2x00pci rt2x00mmio rt2x00lib ftdi_sio kvm_amd mac80211 cfg80211 kvm e1000e snd_ca0106 snd_ac97_codec i2c_piix4 rfkill microcode ac97_bus serio_raw k10temp r8169 mii acpi_cpufreq ptp wmi pps_core nfsd auth_rpcgss nfs_acl lockd binfmt_misc sunrpc usb_storage radeon drm_kms_helper ttm
[  292.624884] CPU: 1 PID: 4655 Comm: (t-daemon) Not tainted 3.14.0-rc2d3623099d3509fa68fa28235366049dd3156c63a+ #10
[  292.624889] Hardware name: Gigabyte Technology Co., Ltd. GA-MA790XT-UD4P/GA-MA790XT-UD4P, BIOS F9b 08/17/2012
[  292.624894] task: ffff8802228753c0 ti: ffff8800b515a000 task.ti: ffff8800b515a000
[  292.624899] RIP: 0010:[<ffffffff81072a63>]  [<ffffffff81072a63>] raw_notifier_chain_register+0x23/0x40
[  292.624910] RSP: 0018:ffff8800b515bd98  EFLAGS: 00000246
[  292.624914] RAX: ffff8802014d0ec0 RBX: ffffffff81c23340 RCX: 0000000000000004
[  292.624919] RDX: 0000000000000000 RSI: ffff8800b50f1fc0 RDI: ffff8802014d0ec8
[  292.624923] RBP: ffff8800b515bd98 R08: 0000000000000000 R09: 0000000000000000
[  292.624928] R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff81c233a8
[  292.624933] R13: 0000000180040004 R14: 0000000000000246 R15: 000060fd00000000
[  292.624939] FS:  00007fa39d6118c0(0000) GS:ffff88022fc80000(0000) knlGS:00000000e26ffb40
[  292.624944] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  292.624948] CR2: 00007fa4b45a7f40 CR3: 00000000bd2e6000 CR4: 00000000000007e0
[  292.624951] Stack:
[  292.624955]  ffff8800b515bdb0 ffffffff8161ff8a ffff8800b50f1100 ffff8800b515bde0
[  292.624965]  ffffffff815721be ffff8800b50f1100 0000000000000000 ffff8800b50f1160
[  292.624974]  ffff8800b50f1290 ffff8800b515be28 ffffffff815f7321 ffffffff815f7231
[  292.624982] Call Trace:
[  292.624992]  [<ffffffff8161ff8a>] register_cpu_notifier+0x2a/0x40
[  292.625001]  [<ffffffff815721be>] flow_cache_init+0x1de/0x2b0
[  292.625009]  [<ffffffff815f7321>] xfrm_net_init+0x241/0x380
[  292.625016]  [<ffffffff815f7231>] ? xfrm_net_init+0x151/0x380
[  292.625025]  [<ffffffff81553131>] ops_init+0x41/0x150
[  292.625033]  [<ffffffff815532b3>] setup_net+0x73/0x110
[  292.625042]  [<ffffffff815537f2>] copy_net_ns+0x72/0x100
[  292.625050]  [<ffffffff81072619>] create_new_namespaces+0xf9/0x190
[  292.625058]  [<ffffffff81072891>] unshare_nsproxy_namespaces+0x61/0xa0
[  292.625065]  [<ffffffff81049949>] SyS_unshare+0x159/0x270
[  292.625073]  [<ffffffff816381d2>] system_call_fastpath+0x16/0x1b
[  292.625077] Code: e9 7b ff ff ff 0f 1f 00 66 66 66 66 90 55 48 8b 07 48 89 e5 48 85 c0 74 21 8b 56 10 3b 50 10 7e 0c eb 17 0f 1f 44 00 00 39 50 10 <7c> 0d 48 8d 78 08 48 8b 40 08 48 85 c0 75 ee 48 89 46 08 31 c0

This is net-next with head at d3623099d3509fa68fa28235366049dd3156c63a

It takes a few restarts of libvirt/rtkit-daemon to trigger, but I've definitely seen register_cpu_notifier appearing in backtraces before... maybe this is some kind of a lead?

Quoted 1 line

Could you please try the patch below?

Testing now... Expect results in 15 minutes...

Quoted 1 line

Also, please send your config if the patch does not fix your problem.

config: http://paste.fedoraproject.org/84281/54146313

	-- kuba
#20 lore raw
In reply to Steffen Klassert
Quoted 55 lines · Steffen Klassert
Quoted 13 lines · Jakub Kiciński
Quoted 13 lines

I bisected the other issue to be caused/uncovered by:

commit 1a1ccc96abb2ed9b8fbb71018e64b97324caef53
Author: Steffen Klassert<[email protected]>
Date: Wed Feb 19 10:07:34 2014 +0100

xfrm: Remove caching of xfrm_policy_sk_bundles

We currently cache socket policy bundles at xfrm_policy_sk_bundles. These cached bundles are never used. Instead we create and cache a new one whenever xfrm_lookup() is called on a socket policy.

Quoted 5 lines
Quoted 5 lines

Most protocols cache the used routes to the socket, so let's remove the unused caching of socket policy bundles in xfrm.

This patch should affect only on the usage of IPsec socket policies. Do you use socket policies, or do you use IPsec at all?

Quoted 25 lines
Quoted 25 lines

Machine freezes after FLOW_HASH_RND_PERIOD (default 10 minutes). Now get this warning during boot:

 [   31.664820] ------------[ cut here ]------------
 [   31.664824] WARNING: CPU: 2 PID: 3560 at /home/kuba/Development/Linux/net-next/lib/list_debug.c:33 __list_add+0xac/0xc0()
 [   31.664826] list_add corruption. prev->next should be next (ffff880224579598), but was           (null). (prev=ffff8802106140e8).
 [   31.664827] Modules linked in: xt_CHECKSUM tun bridge stp llc ccm xt_conntrack iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw ftdi_sio arc4 rt2800pci rt2800mmio rt2800lib crc_ccitt eeprom_93cx6 rt2x00pci kvm_amd rt2x00mmio rt2x00lib mac80211 kvm snd_ca0106 cfg80211 e1000e snd_ac97_codec ac97_bus microcode serio_raw ptp i2c_piix4 k10temp acpi_cpufreq pps_core wmi r8169 mii rfkill nfsd auth_rpcgss nfs_acl lockd binfmt_misc sunrpc usb_storage radeon drm_kms_helper ttm
 [   31.664855] CPU: 2 PID: 3560 Comm: (t-daemon) Not tainted 3.14.0-rc2-1a1ccc96abb2ed9b8fbb71018e64b97324caef53+ #11
 [   31.664856] Hardware name: Gigabyte Technology Co., Ltd. GA-MA790XT-UD4P/GA-MA790XT-UD4P, BIOS F9b 08/17/2012
 [   31.664857]  0000000000000009 ffff8802242e7c70 ffffffff81627878 ffff8802242e7cb8
 [   31.664859]  ffff8802242e7ca8 ffffffff8104a28d ffff880210610ea8 ffff880224579598
 [   31.664861]  ffff8802106140e8 ffff880224578000 0000000000000000 ffff8802242e7d08
 [   31.664863] Call Trace:
 [   31.664865]  [<ffffffff81627878>] dump_stack+0x4d/0x66
 [   31.664867]  [<ffffffff8104a28d>] warn_slowpath_common+0x7d/0xa0
 [   31.664869]  [<ffffffff8104a2fc>] warn_slowpath_fmt+0x4c/0x50
 [   31.664871]  [<ffffffff812fdd8c>] __list_add+0xac/0xc0
 [   31.664873]  [<ffffffff81055d33>] __internal_add_timer+0x113/0x130
 [   31.664875]  [<ffffffff81055f47>] internal_add_timer+0x17/0x40
 [   31.664876]  [<ffffffff810587b2>] mod_timer+0x102/0x230
 [   31.664878]  [<ffffffff810588f8>] add_timer+0x18/0x20
 [   31.664880]  [<ffffffff81572204>] flow_cache_init+0x224/0x2b0
 [   31.664882]  [<ffffffff815f7247>] xfrm_net_init+0x227/0x360
 [   31.664884]  [<ffffffff815f7171>] ? xfrm_net_init+0x151/0x360
Quoted 8 lines
Quoted 8 lines
 [   31.664886]  [<ffffffff81553131>] ops_init+0x41/0x150
 [   31.664888]  [<ffffffff815532b3>] setup_net+0x73/0x110
 [   31.664890]  [<ffffffff815537f2>] copy_net_ns+0x72/0x100
 [   31.664892]  [<ffffffff81072619>] create_new_namespaces+0xf9/0x190
 [   31.664894]  [<ffffffff81072891>] unshare_nsproxy_namespaces+0x61/0xa0
 [   31.664895]  [<ffffffff81049949>] SyS_unshare+0x159/0x270
 [   31.664897]  [<ffffffff81638092>] system_call_fastpath+0x16/0x1b
Quoted 3 lines

I was unable to reproduce this here, but it looks like the flowcache namespace changes are still not complete. We leak an active timer and all the allocated resources when we exit a namespace.

My bad! and embarrassing。。。
Thanks for the fix for my errors.

Quoted 2 lines

Could you please try the patch below?

Signature · 3 lines
浮沉随浪只记今朝笑

--fan