All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Miller <davem@davemloft.net>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Eric Dumazet <edumazet@google.com>,
	Willem de Bruijn <willemb@google.com>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>
Subject: Re: [PATCH v5 2/2] sock: Move the socket inuse to namespace.
Date: Sat, 9 Dec 2017 13:25:45 +0800	[thread overview]
Message-ID: <CAMDZJNWVvHZBgUm8ZHVgbURGXvwWPqAkUAaC5qAiEjOdiw_+LA@mail.gmail.com> (raw)
In-Reply-To: <1512739489.25033.26.camel@gmail.com>

On Fri, Dec 8, 2017 at 9:24 PM, Eric Dumazet <eric.dumazet@gmail.com> 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 test if net->core.sock_inuse is NULL or not from
>> sock_inuse_add(). :)
>>
>>  static void __net_exit sock_inuse_exit_net(struct net *net)
>>  {
>>         free_percpu(net->core.prot_inuse);
>> +
>> +       synchronize_rcu();
>> +       rcu_barrier();
>> +
>> +       free_percpu(net->core.sock_inuse);
>>  }
>
>
> Oh well. Do you have any idea of the major problem this would add ?
>
> Try the following, before and after your patches :
>
> for i in `seq 1 40`
> do
>  (for j in `seq 1 100` ; do unshare -n /bin/true >/dev/null ; done) &
> done
> wait
>
> ( Check commit 8ca712c373a462cfa1b62272870b6c2c74aa83f9 )
>
Yes, I did the test. The patches drop the performance.
Before patch:
# time ./add_del_unshare.sh
net_namespace         97    125   6016    5    8 : tunables    0    0
  0 : slabdata     25     25      0

real 8m19.665s
user 0m4.268s
sys 0m6.477s

After :
# time ./add_del_unshare.sh
net_namespace        102    130   6016    5    8 : tunables    0    0
  0 : slabdata     26     26      0

real 8m52.563s
user 0m4.040s
sys 0m7.558s

>
> This is a complex problem, we wont accept patches that kill network
> namespaces dismantling performance by adding brute force
> synchronize_rcu() or rcu_barrier() calls.
>
> Why not freeing net->core.sock_inuse right before feeing net itself in
> net_free() ?
I try this way, alloc  core.sock_inuse in net_alloc(), free it in net_free ().
It does not drop performance, and we will not always to check the
core.sock_inuse
in sock_inuse_add().

After :
# time ./add_del_unshare.sh
net_namespace        109    135   6016    5    8 : tunables    0    0
  0 : slabdata     27     27      0

real 8m19.265s
user 0m4.090s
sys 0m8.185s

> You do not have to hijack sock_inuse_exit_net() just because it has a
> misleading name.
>
>

  reply	other threads:[~2017-12-09  5:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07 16:45 [PATCH v5 1/2] sock: Change the netns_core member name Tonghao Zhang
2017-12-07 16:45 ` [PATCH v5 2/2] sock: Move the socket inuse to namespace Tonghao Zhang
2017-12-07 17:20   ` Eric Dumazet
2017-12-07 21:28     ` Cong Wang
2017-12-08  5:28     ` Tonghao Zhang
2017-12-08  5:40       ` Eric Dumazet
2017-12-08  9:52         ` Tonghao Zhang
2017-12-08 11:29           ` Tonghao Zhang
2017-12-08 13:24             ` Eric Dumazet
2017-12-09  5:25               ` Tonghao Zhang [this message]
2017-12-08 22:09       ` Cong Wang
2017-12-09  5:27         ` Tonghao Zhang
2017-12-09 19:42           ` Cong Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMDZJNWVvHZBgUm8ZHVgbURGXvwWPqAkUAaC5qAiEjOdiw_+LA@mail.gmail.com \
    --to=xiangxia.m.yue@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=willemb@google.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.