public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tcp: handle tcp_net_metrics_init() order-5 memory allocation failures
@ 2012-11-15 23:41 Eric Dumazet
  2012-11-15 23:55 ` Joe Perches
  2012-11-16  6:39 ` David Miller
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Dumazet @ 2012-11-15 23:41 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Julien Tinnes

From: Eric Dumazet <edumazet@google.com>

order-5 allocations can fail with current kernels, we should
try to reduce allocation sizes to allow network namespace
creation.

Reported-by: Julien Tinnes <jln@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp_metrics.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index 53bc584..15e93c4 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -1030,14 +1030,17 @@ static int __net_init tcp_net_metrics_init(struct net *net)
 		else
 			slots = 8 * 1024;
 	}
-
+retry:
 	net->ipv4.tcp_metrics_hash_log = order_base_2(slots);
 	size = sizeof(struct tcpm_hash_bucket) << net->ipv4.tcp_metrics_hash_log;
 
-	net->ipv4.tcp_metrics_hash = kzalloc(size, GFP_KERNEL);
-	if (!net->ipv4.tcp_metrics_hash)
-		return -ENOMEM;
-
+	net->ipv4.tcp_metrics_hash = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
+	if (!net->ipv4.tcp_metrics_hash) {
+		if (slots <= 16)
+			return -ENOMEM;
+		slots >>= 1;
+		goto retry;
+	}
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-11-16 19:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-15 23:41 [PATCH] tcp: handle tcp_net_metrics_init() order-5 memory allocation failures Eric Dumazet
2012-11-15 23:55 ` Joe Perches
2012-11-16  0:47   ` Eric Dumazet
2012-11-16  6:39 ` David Miller
2012-11-16 15:31   ` Eric Dumazet
2012-11-16 18:37     ` David Miller
2012-11-16 18:51     ` Julien Tinnes
2012-11-16 19:08       ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox