From patchwork Wed Jun 13 17:11:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 928986 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="C1D7h2eA"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 415YFv4zvnz9s01 for ; Thu, 14 Jun 2018 03:12:03 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934951AbeFMRMB (ORCPT ); Wed, 13 Jun 2018 13:12:01 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:43085 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934817AbeFMRMA (ORCPT ); Wed, 13 Jun 2018 13:12:00 -0400 Received: by mail-pf0-f194.google.com with SMTP id y8-v6so1751175pfm.10 for ; Wed, 13 Jun 2018 10:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=34Fx0TxfeBlZY8VoB7snuDugFLHH7xdLxWrpRy3syQ0=; b=C1D7h2eABMcWZeFq5ionR91MF2YBu4rb9Q+D7pGgRJK96JQesjYBu/LCrfdmQDYbb3 CpIFhqWvTnlYVZ8LEJLdV6xF8GargrPBhn9JUupsqTbLcnzb4FNtAZjm5yOMnj6LtAiw BPN5boiS5hrisJsFZwj8Ex4DZa/SVohfN3m9rN6U3zce2GMRswIGouPN/sSsRdE8Ftl3 ls0YgBPvzlashAWtAllZmbCy30x5YfBaFCMx9KBGpJ41MtpCDkA1F297BXKKv5zlq8gL amK52b/jbI49tZlfXFRGmTQ+lTM60hoNZy/V2g2ah5dCJWqYk9C0ZSEjNuFnyS31AGBE p02Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=34Fx0TxfeBlZY8VoB7snuDugFLHH7xdLxWrpRy3syQ0=; b=CguTfSGImJZyhMw3pXFr7KrRe+RTAPS+WMplWLdVqedwHRceowLNJXCtcXbGIJB+WT qG17ApW6XWZRWKqpmNm48nfbvDRRriNMLgGBRvMHuu+69gtCktTMUsIbt/o2thHZNo3K rtReeyeOfS12n6ksDcD1he3A82RnjvLG22318n0Z7pH1EPvkpw2covNYxjLQfuY2e7mZ CSH5BanY2vFfQKvuV9et6emlwUKNFysnGI7R0dOL6XUUEC2I87P3wqwtvV+M5cpKnc8H dFKpGdpa16JurN+yCiyvMygqM+9nBvPm93wKyP9xGSRxM2CHogIxlaNuJ0GWljlFq3Ya eGwA== X-Gm-Message-State: APt69E2QENDdWmd8svkw0az4ac+PcYicx2OVBkC0lhOK9AHEFhtyUZTR gA/WYEBJhWkeI14jbpythkA0UA== X-Google-Smtp-Source: ADUXVKJkOonakqWt+ROgCCMXJIr6ZAVUoWbxu5yW//I0AZuvHuFJ1W76zqNBCKFs84s1psFch26AOA== X-Received: by 2002:a62:9652:: with SMTP id c79-v6mr5824160pfe.114.1528909919159; Wed, 13 Jun 2018 10:11:59 -0700 (PDT) Received: from localhost ([2620:15c:2c4:201:f5a:7eca:440a:3ead]) by smtp.gmail.com with ESMTPSA id f16-v6sm6854514pff.57.2018.06.13.10.11.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Jun 2018 10:11:58 -0700 (PDT) From: Eric Dumazet To: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal Cc: netfilter-devel@vger.kernel.org, netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net] netfilter: ipv6: nf_defrag: reduce struct net memory waste Date: Wed, 13 Jun 2018 10:11:56 -0700 Message-Id: <20180613171156.240889-1-edumazet@google.com> X-Mailer: git-send-email 2.18.0.rc1.242.g61856ae69a-goog Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org 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 --- 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(-) diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 47e35cce3b648d696b127ed7bd643036128795f6..a71264d75d7f98d28f92dfd861ffe6e0d39c0198 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -128,6 +128,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; diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h index c978a31b0f846210b4c2a369af960d5349b5395a..762ac9931b6251152b6ee0e5780df0f7b073f3e6 100644 --- a/include/net/netns/ipv6.h +++ b/include/net/netns/ipv6.h @@ -109,7 +109,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 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 5e0332014c1738999e680c1853829f384e880284..a452d99c9f5281b5e5d7e6f0162611deeb82212d 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -107,7 +107,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net) if (hdr == NULL) goto err_reg; - net->nf_frag.sysctl.frags_hdr = hdr; + net->nf_frag_frags_hdr = hdr; return 0; err_reg: @@ -121,8 +121,8 @@ static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net) { 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); }