Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3321685imu; Sun, 11 Nov 2018 12:19:44 -0800 (PST) X-Google-Smtp-Source: AJdET5cxdJehLcyKRJ6QDy04PQLVuTpyxrc13fn24OCeDbyjRgvMquEdTIKj7UdeD0viSCUqQ1Ji X-Received: by 2002:a17:902:bd0b:: with SMTP id p11-v6mr17233785pls.35.1541967584350; Sun, 11 Nov 2018 12:19:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541967584; cv=none; d=google.com; s=arc-20160816; b=TtYS+W4raRsoZ429RypwmF9yPf9/csaIsubRI55mKIJJapepZEF2X2d376FE7MhwCG IxIToe664Zhl47A0P9Djy+sw9pqxhik2VpqGQTV6LgJK83W27Y8mmA4ySk3/PDGgdXi7 Lio+zJA55WH3v5oeFGFOD6gJrGQzpNw/5EHM4j3+D+WeRS9EcDOlRsNBKwiqoygEuoJ8 wODx7EUwAdJkkLX4/ME69kolJw65L3uge5fb/4dYgQcKitYAM0qd29oOzXdwS5ET1qaS KayZe8whoJ0bfbzxO3yzmVsT9+qTCZcowFzPaN31/wXGK1Gd09NmCR0yWl4KeD5pZmM0 PZUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=ExqjiJ3LVwVgLG6wZrytMBAM1FjubJx2ursN/mkUfLU=; b=PiCVzzuUARVwf9xS6CUQ8BbhNfIG/rnD4C2RsDdRLf5krGvmQdIRa7rT223z9mlTkW pK+R+kRIRTZwQNFH1t0Reuj20ABJbqPia80B62IQhIdHmcshV0p+m6z8y71GdKSh8/Ib Kdq4IN+ImsJ7lzyipzYlxrgpIoyqlxLod53yKnGXPXCYln7zmmte9zG3fIUVzkUDN9Ai Z9EsZNta7gzC9BBSYG58JPUFtdYV3MQK5sztGyQlq5o3Lv5A6DmuiMvuX4/8IbZBqSv0 UZRZ3xK16+r6rqcwz8/6+DXPo2gnUz0oyOsIvkw2fuYh0l31RLirwowX3sRwEPk9iURe ppgw== 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 x5-v6si16766920pfx.74.2018.11.11.12.19.29; Sun, 11 Nov 2018 12:19:44 -0800 (PST) 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 S1731825AbeKLGFS (ORCPT + 99 others); Mon, 12 Nov 2018 01:05:18 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:53068 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731042AbeKLGFR (ORCPT ); Mon, 12 Nov 2018 01:05:17 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvt0-0000lF-2h; Sun, 11 Nov 2018 19:59:10 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsS-0001Yy-N5; Sun, 11 Nov 2018 19:58:36 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Eric Dumazet" , "Pablo Neira Ayuso" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 150/366] netfilter: ipv6: nf_defrag: reduce struct net memory waste In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet commit 9ce7bc036ae4cfe3393232c86e9e1fea2153c237 upstream. 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: Ben Hutchings --- 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 @@ -112,6 +112,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 @@ -80,7 +80,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 @@ -109,7 +109,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: @@ -123,8 +123,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); }