Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1332195imm; Thu, 23 Aug 2018 00:58:39 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwowdahlM4+PUh2WsuQqJYpGEFhk+3ykyZE9J7tOMaSTD5K1WcuCZ4QOa0GUQ5w/lvJ2Ezg X-Received: by 2002:a17:902:27a8:: with SMTP id d37-v6mr57758574plb.290.1535011119205; Thu, 23 Aug 2018 00:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535011119; cv=none; d=google.com; s=arc-20160816; b=taO3rCEjBaf5stDeBxeUSSSCTtd5MgfBxXHaZoNfCo0QJqH0c3j9egJ3V8VV3Z46oF R/++4rvADnX6X314gI3DDY3bScQNGoqDEYiZFwEo8feVRpeNxfImnaMZY8llOtNvcs9M VXFJYCf3vp5xnYuieWCb0qWqIeyIYZ4cpLKjF3ZT7SGOz8aZ6NUefhS27H2kC5Mk7oCd tuRBNhlPFOi4gTVILoF6vf4m2XuM0qVNVmeVq5k/Gftuq7GVgm8uLx2E1U83JuHDqkDW cKe6AfpDy7HkoyWAX450xgSFOyqr+MV1CBq4x2cLbDLNiDsg4bE+YCk8w0ouEg0DKscn h7ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hs0AebZR7cTN2abvL60uX25yI9Lsd/Dm+ZwvcWdWpHM=; b=fjG9fbptREW1bt1qtxAP6oB3Pf3Lpi82WL4HGkf0LFSiaFEwnI4bbyRdEQ3PhN7Tam xKHupVFUez3GpBY2mo+JjlyO2IZ7anY39UeUWpYZSTOYH2CW7nLEkryynoW7zmj5fit6 3oqK5h0IpZOXuJyOGWULxUNPHiZ0V5XfM5Z7q297ArftCcwuPeDbW5Ki798zsngjzFyB P8QtM6m3Bcs95t6KPLhUhHyrN+RHo2x55iMsmZBryGUl/x2BtoZzYe1xsXLVYnSPDI19 Be1gHgZbI4NDCvwqBgdZ3GFvM2y1eAHesmV9MTFdQHOC9Pf/SYpIhByi3QL9OwT5ualg 0i2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p19-v6si3894777pgm.109.2018.08.23.00.58.24; Thu, 23 Aug 2018 00:58:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727238AbeHWLZf (ORCPT + 99 others); Thu, 23 Aug 2018 07:25:35 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41544 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbeHWLZf (ORCPT ); Thu, 23 Aug 2018 07:25:35 -0400 Received: from localhost (5355525A.cm-6-6b.dynamic.ziggo.nl [83.85.82.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5519E9D2; Thu, 23 Aug 2018 07:57:12 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.4 02/79] netfilter: ipv6: nf_defrag: reduce struct net memory waste Date: Thu, 23 Aug 2018 09:52:38 +0200 Message-Id: <20180823074918.803607364@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180823074918.641878835@linuxfoundation.org> References: <20180823074918.641878835@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 9ce7bc036ae4cfe3393232c86e9e1fea2153c237 ] It is a waste of memory to use a full "struct netns_sysctl_ipv6" while only one pointer is really used, considering netns_sysctl_ipv6 keeps growing. Also, since "struct netns_frags" has cache line alignment, it is better to move the frags_hdr pointer outside, otherwise we spend a full cache line for this pointer. This saves 192 bytes of memory per netns. Fixes: c038a767cd69 ("ipv6: add a new namespace for nf_conntrack_reasm") Signed-off-by: Eric Dumazet Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- include/net/net_namespace.h | 1 + include/net/netns/ipv6.h | 1 - net/ipv6/netfilter/nf_conntrack_reasm.c | 6 +++--- 3 files changed, 4 insertions(+), 4 deletions(-) --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -115,6 +115,7 @@ struct net { #endif #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6) struct netns_nf_frag nf_frag; + struct ctl_table_header *nf_frag_frags_hdr; #endif struct sock *nfnl; struct sock *nfnl_stash; --- a/include/net/netns/ipv6.h +++ b/include/net/netns/ipv6.h @@ -86,7 +86,6 @@ struct netns_ipv6 { #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6) struct netns_nf_frag { - struct netns_sysctl_ipv6 sysctl; struct netns_frags frags; }; #endif --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -118,7 +118,7 @@ static int nf_ct_frag6_sysctl_register(s if (hdr == NULL) goto err_reg; - net->nf_frag.sysctl.frags_hdr = hdr; + net->nf_frag_frags_hdr = hdr; return 0; err_reg: @@ -132,8 +132,8 @@ static void __net_exit nf_ct_frags6_sysc { struct ctl_table *table; - table = net->nf_frag.sysctl.frags_hdr->ctl_table_arg; - unregister_net_sysctl_table(net->nf_frag.sysctl.frags_hdr); + table = net->nf_frag_frags_hdr->ctl_table_arg; + unregister_net_sysctl_table(net->nf_frag_frags_hdr); if (!net_eq(net, &init_net)) kfree(table); }