From patchwork Thu Nov 15 23:41:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 199457 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2081C2C0519 for ; Fri, 16 Nov 2012 10:41:16 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751283Ab2KOXlN (ORCPT ); Thu, 15 Nov 2012 18:41:13 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:60238 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750788Ab2KOXlN (ORCPT ); Thu, 15 Nov 2012 18:41:13 -0500 Received: by mail-pa0-f46.google.com with SMTP id hz1so1435546pad.19 for ; Thu, 15 Nov 2012 15:41:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=FPngt/ULUOi+tQv/lB5pO2R8SblgHJfuXPCQUrvXm8M=; b=KBRKPjgT9Belek2W7B1M3XVF1yhl9xzwJCkYdio5FOyPsyBgzDxAqKVKQDTYeJHcPr 2UXGEOBkCYEroIo/wnLnDnHY3n07uwn6mtcD5J/9RniGk03O487PR9kW3gClIKvAnd8U wW02wqymT/j3Bo86RTPpXu063SXyLE47cO9upRhRQrJ2aT+YewhT2VNiHQP0doU31fwf 3af+AlovTIw22dtL3tCZakCUpMrd6Bl9m1/dgxNrcN6fvTMkiHfh4oXhDdmD1uhpIRZS FSqCigoXeEsFj3o8wMK++R2cANu+r+usUtTEnW8T5B+SYAA+971tH9gWTyq/GdH7tPAL tXnA== Received: by 10.66.74.65 with SMTP id r1mr7506602pav.75.1353022872724; Thu, 15 Nov 2012 15:41:12 -0800 (PST) Received: from [172.19.68.135] (dhcp-172-19-68-135.mtv.corp.google.com [172.19.68.135]) by mx.google.com with ESMTPS id ak10sm146391pbd.24.2012.11.15.15.41.04 (version=SSLv3 cipher=OTHER); Thu, 15 Nov 2012 15:41:11 -0800 (PST) Subject: [PATCH] tcp: handle tcp_net_metrics_init() order-5 memory allocation failures From: Eric Dumazet To: David Miller Cc: netdev , Julien Tinnes Date: Thu, 15 Nov 2012 15:41:04 -0800 Message-ID: <1353022864.10798.6.camel@edumazet-glaptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet order-5 allocations can fail with current kernels, we should try to reduce allocation sizes to allow network namespace creation. Reported-by: Julien Tinnes Signed-off-by: Eric Dumazet --- net/ipv4/tcp_metrics.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; }