Re: [PATCH v5 2/2] sock: Move the socket inuse to namespace.

2017-12-09 Thread Cong Wang
On Fri, Dec 8, 2017 at 9:27 PM, Tonghao Zhang wrote: > On Sat, Dec 9, 2017 at 6:09 AM, Cong Wang wrote: >> On Thu, Dec 7, 2017 at 9:28 PM, Tonghao Zhang >> wrote: >>> >>> Release the netlink sock created in kernel(not hold the _net_ namespace): >>> >> >> You can avoid counting kernel sock by te

Re: [PATCH v5 2/2] sock: Move the socket inuse to namespace.

2017-12-08 Thread Tonghao Zhang
On Sat, Dec 9, 2017 at 6:09 AM, Cong Wang wrote: > On Thu, Dec 7, 2017 at 9:28 PM, Tonghao Zhang > wrote: >> >> Release the netlink sock created in kernel(not hold the _net_ namespace): >> > > You can avoid counting kernel sock by testing 'kern' in sk_alloc() > and testing 'sk->sk_net_refcnt' in

Re: [PATCH v5 2/2] sock: Move the socket inuse to namespace.

2017-12-08 Thread Tonghao Zhang
On Fri, Dec 8, 2017 at 9:24 PM, Eric Dumazet wrote: > On Fri, 2017-12-08 at 19:29 +0800, Tonghao Zhang wrote: >> hi all. we can add synchronize_rcu and rcu_barrier in >> sock_inuse_exit_net to >> ensure there are no outstanding rcu callbacks using this network >> namespace. >> we will not have to

Re: [PATCH v5 2/2] sock: Move the socket inuse to namespace.

2017-12-08 Thread Cong Wang
On Thu, Dec 7, 2017 at 9:28 PM, Tonghao Zhang wrote: > > Release the netlink sock created in kernel(not hold the _net_ namespace): > You can avoid counting kernel sock by testing 'kern' in sk_alloc() and testing 'sk->sk_net_refcnt' in __sk_free().

Re: [PATCH v5 2/2] sock: Move the socket inuse to namespace.

2017-12-08 Thread Eric Dumazet
On Fri, 2017-12-08 at 19:29 +0800, Tonghao Zhang wrote: > hi all. we can add synchronize_rcu and rcu_barrier in > sock_inuse_exit_net to > ensure there are no outstanding rcu callbacks using this network > namespace. > we will not have to test if net->core.sock_inuse is NULL or not from > sock_inus

Re: [PATCH v5 2/2] sock: Move the socket inuse to namespace.

2017-12-08 Thread Tonghao Zhang
hi all. we can add synchronize_rcu and rcu_barrier in sock_inuse_exit_net to ensure there are no outstanding rcu callbacks using this network namespace. we will not have to test if net->core.sock_inuse is NULL or not from sock_inuse_add(). :) static void __net_exit sock_inuse_exit_net(struct net

Re: [PATCH v5 2/2] sock: Move the socket inuse to namespace.

2017-12-08 Thread Tonghao Zhang
On Fri, Dec 8, 2017 at 1:40 PM, Eric Dumazet wrote: > On Fri, 2017-12-08 at 13:28 +0800, Tonghao Zhang wrote: >> On Fri, Dec 8, 2017 at 1:20 AM, Eric Dumazet >> 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

Re: [PATCH v5 2/2] sock: Move the socket inuse to namespace.

2017-12-07 Thread Eric Dumazet
On Fri, 2017-12-08 at 13:28 +0800, Tonghao Zhang wrote: > On Fri, Dec 8, 2017 at 1:20 AM, Eric Dumazet > 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 metri

Re: [PATCH v5 2/2] sock: Move the socket inuse to namespace.

2017-12-07 Thread Tonghao Zhang
On Fri, Dec 8, 2017 at 1:20 AM, Eric Dumazet 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

Re: [PATCH v5 2/2] sock: Move the socket inuse to namespace.

2017-12-07 Thread Cong Wang
On Thu, Dec 7, 2017 at 9:20 AM, Eric Dumazet 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

Re: [PATCH v5 2/2] sock: Move the socket inuse to namespace.

2017-12-07 Thread Eric Dumazet
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) > + th

[PATCH v5 2/2] sock: Move the socket inuse to namespace.

2017-12-07 Thread Tonghao Zhang
In some case, we want to know how many sockets are in use in different _net_ namespaces. It's a key resource metric. This patch add a member in struct netns_core. This is a counter for socket-inuse in the _net_ namespace. The patch will add/sub counter in the sk_alloc, sk_clone_lock and __sk_free.