Skip to contentSkip to conversation

Use SLAB_PANIC when creating critical slab cache

PATCH In review Chris Wright 3 participants 13 messages Nov 14, 2004

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

cover Use SLAB_PANIC when creating critical slab cache

The following trivial patches update networking code to use the SLAB_PANIC flag when creating a critical slab cache instead of doing localized calls to panic(). This brings networking inline with other core kernel code.

 core/flow.c       |    5 +----
 core/skbuff.c     |    4 +---
 decnet/dn_route.c |    9 +++------
 ipv4/inetpeer.c   |    5 +----
 ipv4/ipmr.c       |    5 +----
 ipv6/ip6_fib.c    |    4 +---
 ipv6/route.c      |    9 +++------
 xfrm/xfrm_input.c |    4 +---
 8 files changed, 12 insertions(+), 33 deletions(-)

thanks,
-chris

#1 lore raw

PATCH 1/8 Use SLAB_PANIC when creating critical slab cache

Use SLAB_PANIC when creating a critical slab cache.

===== net/core/flow.c 1.20 vs edited =====

net/core/flow.c +1 -4
@@ -343,11 +343,8 @@ static int __init flow_cache_init(void)
 
 	flow_cachep = kmem_cache_create("flow_cache",
 					sizeof(struct flow_cache_entry),
-					0, SLAB_HWCACHE_ALIGN,
+					0, SLAB_HWCACHE_ALIGN|SLAB_PANIC,
 					NULL, NULL);
-
-	if (!flow_cachep)
-		panic("NET: failed to allocate flow cache slab\n");
 
 	flow_hash_shift = 10;
 	flow_lwm = 2 * flow_hash_size;
#2 lore raw

PATCH 2/8 Use SLAB_PANIC when creating critical slab cache

In reply to Chris Wright

Use SLAB_PANIC when creating a critical slab cache.

===== net/core/skbuff.c 1.39 vs edited =====

net/core/skbuff.c +1 -3
@@ -1430,10 +1430,8 @@ void __init skb_init(void)
 	skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
 					      sizeof(struct sk_buff),
 					      0,
-					      SLAB_HWCACHE_ALIGN,
+					      SLAB_HWCACHE_ALIGN|SLAB_PANIC,
 					      NULL, NULL);
-	if (!skbuff_head_cache)
-		panic("cannot create skbuff cache");
 }
 
 EXPORT_SYMBOL(___pskb_trim);
#3 lore raw

PATCH 3/8 Use SLAB_PANIC when creating critical slab cache

In reply to Chris Wright

Use SLAB_PANIC when creating a critical slab cache.

===== net/decnet/dn_route.c 1.29 vs edited =====

net/decnet/dn_route.c +3 -6
@@ -1778,12 +1778,9 @@ void __init dn_route_init(void)
 	int i, goal, order;
 
 	dn_dst_ops.kmem_cachep = kmem_cache_create("dn_dst_cache",
-						   sizeof(struct dn_route),
-						   0, SLAB_HWCACHE_ALIGN,
-						   NULL, NULL);
-
-	if (!dn_dst_ops.kmem_cachep)
-		panic("DECnet: Failed to allocate dn_dst_cache\n");
+						  sizeof(struct dn_route), 0,
+						  SLAB_HWCACHE_ALIGN|SLAB_PANIC,
+						  NULL, NULL);
 
 	init_timer(&dn_route_timer);
 	dn_route_timer.function = dn_dst_check_expire;
#4 lore raw

PATCH 4/8 Use SLAB_PANIC when creating critical slab cache

In reply to Chris Wright

Use SLAB_PANIC when creating a critical slab cache.

===== net/ipv4/inetpeer.c 1.9 vs edited =====

net/ipv4/inetpeer.c +1 -4
@@ -126,11 +126,8 @@ void __init inet_initpeers(void)
 
 	peer_cachep = kmem_cache_create("inet_peer_cache",
 			sizeof(struct inet_peer),
-			0, SLAB_HWCACHE_ALIGN,
+			0, SLAB_HWCACHE_ALIGN|SLAB_PANIC,
 			NULL, NULL);
-
-	if (!peer_cachep)
-		panic("cannot create inet_peer_cache");
 
 	/* All the timers, started at system startup tend
 	   to synchronize. Perturb it a bit.
#5 lore raw

PATCH 5/8 Use SLAB_PANIC when creating critical slab cache

In reply to Chris Wright

Use SLAB_PANIC when creating a critical slab cache.

===== net/ipv4/ipmr.c 1.45 vs edited =====

net/ipv4/ipmr.c +1 -4
@@ -1885,11 +1885,8 @@ void __init ip_mr_init(void)
 {
 	mrt_cachep = kmem_cache_create("ip_mrt_cache",
 				       sizeof(struct mfc_cache),
-				       0, SLAB_HWCACHE_ALIGN,
+				       0, SLAB_HWCACHE_ALIGN|SLAB_PANIC,
 				       NULL, NULL);
-	if (!mrt_cachep)
-		panic("cannot allocate ip_mrt_cache");
-
 	init_timer(&ipmr_expire_timer);
 	ipmr_expire_timer.function=ipmr_expire_process;
 	register_netdevice_notifier(&ip_mr_notifier);
#6 lore raw

PATCH 6/8 Use SLAB_PANIC when creating critical slab cache

In reply to Chris Wright

Use SLAB_PANIC when creating a critical slab cache.

===== net/ipv6/ip6_fib.c 1.33 vs edited =====

net/ipv6/ip6_fib.c +1 -3
@@ -1242,10 +1242,8 @@ void __init fib6_init(void)
 {
 	fib6_node_kmem = kmem_cache_create("fib6_nodes",
 					   sizeof(struct fib6_node),
-					   0, SLAB_HWCACHE_ALIGN,
+					   0, SLAB_HWCACHE_ALIGN|SLAB_PANIC,
 					   NULL, NULL);
-	if (!fib6_node_kmem)
-		panic("cannot create fib6_nodes cache");
 }
 
 void __exit fib6_gc_cleanup(void)
#10 lore raw

PATCH 7/8 Use SLAB_PANIC when creating critical slab cache

In reply to Chris Wright

Use SLAB_PANIC when creating a critical slab cache.

===== net/ipv6/route.c 1.101 vs edited =====

net/ipv6/route.c +3 -6
@@ -2069,12 +2069,9 @@ void __init ip6_route_init(void)
 	struct proc_dir_entry *p;
 
 	ip6_dst_ops.kmem_cachep = kmem_cache_create("ip6_dst_cache",
-						     sizeof(struct rt6_info),
-						     0, SLAB_HWCACHE_ALIGN,
-						     NULL, NULL);
-	if (!ip6_dst_ops.kmem_cachep)
-		panic("cannot create ip6_dst_cache");
-
+						  sizeof(struct rt6_info), 0,
+						  SLAB_HWCACHE_ALIGN|SLAB_PANIC,
+						  NULL, NULL);
 	fib6_init();
 #ifdef 	CONFIG_PROC_FS
 	p = proc_net_create("ipv6_route", 0, rt6_proc_info);
#11 lore raw

PATCH 8/8 Use SLAB_PANIC when creating critical slab cache

In reply to Chris Wright

Use SLAB_PANIC when creating a critical slab cache.

===== net/xfrm/xfrm_input.c 1.13 vs edited =====

net/xfrm/xfrm_input.c +1 -3
@@ -78,8 +78,6 @@ void __init xfrm_input_init(void)
 {
 	secpath_cachep = kmem_cache_create("secpath_cache",
 					   sizeof(struct sec_path),
-					   0, SLAB_HWCACHE_ALIGN,
+					   0, SLAB_HWCACHE_ALIGN|SLAB_PANIC,
 					   NULL, NULL);
-	if (!secpath_cachep)
-		panic("XFRM: failed to allocate secpath_cache\n");
 }
#7 lore raw
In reply to Chris Wright

Chris,

I think somebody proposed this in the past and it was refused
because we better get rid of the panics and return an error, propagate it and refuse to load the module, better have the machine still alive but without networking than panic it.

- Arnaldo

Quoted 21 lines · Chris Wright

Use SLAB_PANIC when creating a critical slab cache.

===== net/ipv6/ip6_fib.c 1.33 vs edited =====

net/ipv6/ip6_fib.c +1 -3
@@ -1242,10 +1242,8 @@ void __init fib6_init(void)
 {
 	fib6_node_kmem = kmem_cache_create("fib6_nodes",
 					   sizeof(struct fib6_node),
-					   0, SLAB_HWCACHE_ALIGN,
+					   0, SLAB_HWCACHE_ALIGN|SLAB_PANIC,
 					   NULL, NULL);
-	if (!fib6_node_kmem)
-		panic("cannot create fib6_nodes cache");
 }
 
 void __exit fib6_gc_cleanup(void)
#8 lore raw
Quoted 6 lines · * Arnaldo Carvalho de Melo ([email protected]) wrote:

Chris,

I think somebody proposed this in the past and it was refused
because we better get rid of the panics and return an error, propagate it and refuse to load the module, better have the machine still alive but without networking than panic it.

Sounds good too. Part of my thinking was that these patches would be a good chance to review if these are necessarily panic conditions. What was the plan on error return, since I expect some caches are interdependent?

thanks,
-chris

#12 lore raw
In reply to Chris Wright
Quoted 4 lines · Chris Wright

The following trivial patches update networking code to use the SLAB_PANIC flag when creating a critical slab cache instead of doing localized calls to panic(). This brings networking inline with other core kernel code.

Quoted 8 lines
 core/flow.c       |    5 +----
 core/skbuff.c     |    4 +---
 decnet/dn_route.c |    9 +++------
 ipv4/inetpeer.c   |    5 +----
 ipv4/ipmr.c       |    5 +----
 ipv6/ip6_fib.c    |    4 +---
 ipv6/route.c      |    9 +++------
 xfrm/xfrm_input.c |    4 +---

decnet, ipv6 and xfrm can be modular, so using SLAB_PANIC there is bogus.

#9 lore raw
In reply to Chris Wright
Quoted 10 lines · Chris Wright
Quoted 6 lines · * Arnaldo Carvalho de Melo ([email protected]) wrote:

Chris,

I think somebody proposed this in the past and it was refused
because we better get rid of the panics and return an error, propagate it and refuse to load the module, better have the machine still alive but without networking than panic it.

Quoted 3 lines

Sounds good too. Part of my thinking was that these patches would be a good chance to review if these are necessarily panic conditions. What was the plan on error return, since I expect some caches are interdependent?

I lost track, perhaps we should push this to the janitor mailing list?

:-)

- Arnaldo