From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cong Wang Subject: Re: [PATCH v6 2/3] sock: Move the socket inuse to namespace. Date: Tue, 12 Dec 2017 10:04:31 -0800 Message-ID: References: <1512918726-2731-1-git-send-email-xiangxia.m.yue@gmail.com> <1512918726-2731-2-git-send-email-xiangxia.m.yue@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: David Miller , Eric Dumazet , Willem de Bruijn , Pavel Emelyanov , Linux Kernel Network Developers To: Tonghao Zhang Return-path: Received: from mail-pf0-f178.google.com ([209.85.192.178]:39323 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752366AbdLLSEw (ORCPT ); Tue, 12 Dec 2017 13:04:52 -0500 Received: by mail-pf0-f178.google.com with SMTP id l24so14789377pfj.6 for ; Tue, 12 Dec 2017 10:04:52 -0800 (PST) In-Reply-To: <1512918726-2731-2-git-send-email-xiangxia.m.yue@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: On Sun, Dec 10, 2017 at 7:12 AM, Tonghao Zhang wrote: > diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c > index b797832..6c191fb 100644 > --- a/net/core/net_namespace.c > +++ b/net/core/net_namespace.c > @@ -363,6 +363,13 @@ static struct net *net_alloc(void) > if (!net) > goto out_free; > > +#ifdef CONFIG_PROC_FS > + net->core.sock_inuse = alloc_percpu(int); > + if (!net->core.sock_inuse) { > + kmem_cache_free(net_cachep, net); > + goto out_free; > + } > +#endif > rcu_assign_pointer(net->gen, ng); > out: > return net; > @@ -374,6 +381,9 @@ static struct net *net_alloc(void) > > static void net_free(struct net *net) > { > +#ifdef CONFIG_PROC_FS > + free_percpu(net->core.sock_inuse); > +#endif > kfree(rcu_access_pointer(net->gen)); > kmem_cache_free(net_cachep, net); > } Putting socket code in net_namespace.c doesn't look good.