[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMDZJNXPtcNf4zHjbkJWwfvToXt-i7mxfm5VDf+0FSR4ZFV_Hg@mail.gmail.com>
Date: Fri, 8 Dec 2017 13:28:22 +0800
From: Tonghao Zhang <xiangxia.m.yue@...il.com>
To: Eric Dumazet <eric.dumazet@...il.com>
Cc: David Miller <davem@...emloft.net>,
Cong Wang <xiyou.wangcong@...il.com>,
Eric Dumazet <edumazet@...gle.com>,
Willem de Bruijn <willemb@...gle.com>,
Linux Kernel Network Developers <netdev@...r.kernel.org>
Subject: Re: [PATCH v5 2/2] sock: Move the socket inuse to namespace.
On Fri, Dec 8, 2017 at 1:20 AM, Eric Dumazet <eric.dumazet@...il.com> wrote:
> On Thu, 2017-12-07 at 08:45 -0800, Tonghao Zhang wrote:
>> In some case, we want to know how many sockets are in use in
>> different _net_ namespaces. It's a key resource metric.
>>
>
> ...
>
>> +static void sock_inuse_add(struct net *net, int val)
>> +{
>> + if (net->core.prot_inuse)
>> + this_cpu_add(*net->core.sock_inuse, val);
>> +}
>
> This is very confusing.
>
> Why testing net->core.prot_inuse for NULL is needed at all ?
>
> Why not testing net->core.sock_inuse instead ?
>
Hi Eric and Cong, oh it's a typo. it's net->core.sock_inuse there. Why
we should check the net->core.sock_inuse
Now show you the code:
cleanup_net will call all of the network namespace exit methods,
rcu_barrier, and then remove the _net_ namespace.
cleanup_net:
list_for_each_entry_reverse(ops, &pernet_list, list)
ops_exit_list(ops, &net_exit_list);
rcu_barrier(); /* for netlink sock, the ‘deferred_put_nlk_sk’ will
be called. But sock_inuse has been released. */
/* Finally it is safe to free my network namespace structure */
list_for_each_entry_safe(net, tmp, &net_exit_list, exit_list) {}
Release the netlink sock created in kernel(not hold the _net_ namespace):
netlink_release
call_rcu(&nlk->rcu, deferred_put_nlk_sk);
deferred_put_nlk_sk
sk_free(sk);
I may add a comment for sock_inuse_add in v6.
Powered by blists - more mailing lists