From patchwork Tue Aug 6 05:51:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 264875 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 28C8D2C007A for ; Tue, 6 Aug 2013 15:54:34 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753062Ab3HFFyI (ORCPT ); Tue, 6 Aug 2013 01:54:08 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:57854 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752652Ab3HFFyH (ORCPT ); Tue, 6 Aug 2013 01:54:07 -0400 Received: by mail-pd0-f177.google.com with SMTP id u10so4118274pdi.36 for ; Mon, 05 Aug 2013 22:54:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-type:content-transfer-encoding; bh=StiRp7R+ldGNYqMyFyKdGdLIJ0S8II4gLJmJ7HhcYus=; b=czrR3RA2aqaJHArFzRzk47zHx9XoV9Gl/ruyXIHfj+JHuniT5Fq27vWy5uR9DmKFe7 25S6PGG1J+Qu0c5i33m6o2/YkiEORLa3GDSXrCJEu1vX6DrJegVCxO/uifrxRy4idzew EbM8dJsr+Qpte/2cLol9HTDqyzW14z0hZnVvw6OFjgeul+PS326Wc3ZRnDG4EruogqvJ rGQhH9ypZUqa9ECPtWKX8lXvKWpgU26roCnHaIFlk2YZKOC6XRxQhOP0ANr8IQX73+Ko HRw2FfHgD4O3iJuP6M1yhe4bNId/nI7yOF6MmhlSmgcYGhsfBhOiIfYdtrSEf55kylHW N3Ow== X-Gm-Message-State: ALoCoQko2p5WrnqmKID5CaotcKAZjrZPyvZeeB6I/4sKaTMS8+M4fZFURx3WySkYuq9iOgxCZEuT X-Received: by 10.66.171.77 with SMTP id as13mr1250194pac.170.1375768446556; Mon, 05 Aug 2013 22:54:06 -0700 (PDT) Received: from nehalam.linuxnetplumber.net (static-50-53-71-109.bvtn.or.frontiernet.net. [50.53.71.109]) by mx.google.com with ESMTPSA id ll5sm1804664pab.19.2013.08.05.22.54.05 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 05 Aug 2013 22:54:06 -0700 (PDT) Date: Mon, 5 Aug 2013 22:51:37 -0700 From: Stephen Hemminger To: Pravin B Shelar , David Miller Cc: netdev@vger.kernel.org Subject: [PATCH net-next 1/2] ip_tunnel: embed hash list head Message-ID: <20130805225137.6c934d7f@nehalam.linuxnetplumber.net> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The IP tunnel hash heads can be embedded in the per-net structure since it is a fixed size. Reduce the size so that the total structure fits in a page size. The original size was overly large, even NETDEV_HASHBITS is only 8 bits! Also, add some white space for readability. Signed-off-by: Stephen Hemminger Acked-by: Pravin B Shelar . --- 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 --- a/net/ipv4/ip_tunnel.c 2013-07-20 10:25:11.207494774 -0700 +++ b/net/ipv4/ip_tunnel.c 2013-07-24 08:40:11.025668961 -0700 @@ -838,15 +838,16 @@ int ip_tunnel_init_net(struct net *net, { struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id); struct ip_tunnel_parm parms; + unsigned int i; - itn->tunnels = kzalloc(IP_TNL_HASH_SIZE * sizeof(struct hlist_head), GFP_KERNEL); - if (!itn->tunnels) - return -ENOMEM; + for (i = 0; i < IP_TNL_HASH_SIZE; i++) + INIT_HLIST_HEAD(&itn->tunnels[i]); if (!ops) { itn->fb_tunnel_dev = NULL; return 0; } + memset(&parms, 0, sizeof(parms)); if (devname) strlcpy(parms.name, devname, IFNAMSIZ); @@ -854,10 +855,9 @@ int ip_tunnel_init_net(struct net *net, rtnl_lock(); itn->fb_tunnel_dev = __ip_tunnel_create(net, ops, &parms); rtnl_unlock(); - if (IS_ERR(itn->fb_tunnel_dev)) { - kfree(itn->tunnels); + + if (IS_ERR(itn->fb_tunnel_dev)) return PTR_ERR(itn->fb_tunnel_dev); - } return 0; } @@ -887,7 +887,6 @@ void ip_tunnel_delete_net(struct ip_tunn ip_tunnel_destroy(itn, &list); unregister_netdevice_many(&list); rtnl_unlock(); - kfree(itn->tunnels); } EXPORT_SYMBOL_GPL(ip_tunnel_delete_net); --- a/include/net/ip_tunnels.h 2013-06-28 08:16:54.093005290 -0700 +++ b/include/net/ip_tunnels.h 2013-07-24 08:39:20.822260842 -0700 @@ -86,12 +86,12 @@ struct tnl_ptk_info { #define PACKET_RCVD 0 #define PACKET_REJECT 1 -#define IP_TNL_HASH_BITS 10 +#define IP_TNL_HASH_BITS 7 #define IP_TNL_HASH_SIZE (1 << IP_TNL_HASH_BITS) struct ip_tunnel_net { - struct hlist_head *tunnels; struct net_device *fb_tunnel_dev; + struct hlist_head tunnels[IP_TNL_HASH_SIZE]; }; #ifdef CONFIG_INET