1. 21 Sep, 2017 20 commits
  2. 20 Sep, 2017 14 commits
  3. 19 Sep, 2017 6 commits
    • David S. Miller's avatar
      Merge branch 'net-speedup-netns-create-delete-time' · 8ca712c3
      David S. Miller authored
      Eric Dumazet says:
      
      ====================
      net: speedup netns create/delete time
      
      When rate of netns creation/deletion is high enough,
      we observe softlockups in cleanup_net() caused by huge list
      of netns and way too many rcu_barrier() calls.
      
      This patch series does some optimizations in kobject,
      and add batching to tunnels so that netns dismantles are
      less costly.
      
      IPv6 addrlabels also get a per netns list, and tcp_metrics
      also benefit from batch flushing.
      
      This gives me one order of magnitude gain.
      (~50 ms -> ~5 ms for one netns create/delete pair)
      
      Tested:
      
      for i in `seq 1 40`
      do
       (for j in `seq 1 100` ; do  unshare -n /bin/true >/dev/null ; done) &
      done
      wait ; grep net_namespace /proc/slabinfo
      
      Before patch series :
      
      $ time ./add_del_unshare.sh
      net_namespace        116    258   5504    1    2 : tunables    8    4    0 : slabdata    116    258      0
      
      real	3m24.910s
      user	0m0.747s
      sys	0m43.162s
      
      After :
      $ time ./add_del_unshare.sh
      net_namespace        135    291   5504    1    2 : tunables    8    4    0 : slabdata    135    291      0
      
      real	0m22.117s
      user	0m0.728s
      sys	0m35.328s
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8ca712c3
    • Eric Dumazet's avatar
      ipv4: speedup ipv6 tunnels dismantle · 64bc1781
      Eric Dumazet authored
      Implement exit_batch() method to dismantle more devices
      per round.
      
      (rtnl_lock() ...
       unregister_netdevice_many() ...
       rtnl_unlock())
      
      Tested:
      $ cat add_del_unshare.sh
      for i in `seq 1 40`
      do
       (for j in `seq 1 100` ; do unshare -n /bin/true >/dev/null ; done) &
      done
      wait ; grep net_namespace /proc/slabinfo
      
      Before patch :
      $ time ./add_del_unshare.sh
      net_namespace        126    282   5504    1    2 : tunables    8    4    0 : slabdata    126    282      0
      
      real    1m38.965s
      user    0m0.688s
      sys     0m37.017s
      
      After patch:
      $ time ./add_del_unshare.sh
      net_namespace        135    291   5504    1    2 : tunables    8    4    0 : slabdata    135    291      0
      
      real	0m22.117s
      user	0m0.728s
      sys	0m35.328s
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      64bc1781
    • Eric Dumazet's avatar
      ipv6: speedup ipv6 tunnels dismantle · bb401cae
      Eric Dumazet authored
      Implement exit_batch() method to dismantle more devices
      per round.
      
      (rtnl_lock() ...
       unregister_netdevice_many() ...
       rtnl_unlock())
      
      Tested:
      $ cat add_del_unshare.sh
      for i in `seq 1 40`
      do
       (for j in `seq 1 100` ; do unshare -n /bin/true >/dev/null ; done) &
      done
      wait ; grep net_namespace /proc/slabinfo
      
      Before patch :
      $ time ./add_del_unshare.sh
      net_namespace        110    267   5504    1    2 : tunables    8    4    0 : slabdata    110    267      0
      
      real    3m25.292s
      user    0m0.644s
      sys     0m40.153s
      
      After patch:
      
      $ time ./add_del_unshare.sh
      net_namespace        126    282   5504    1    2 : tunables    8    4    0 : slabdata    126    282      0
      
      real	1m38.965s
      user	0m0.688s
      sys	0m37.017s
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bb401cae
    • Eric Dumazet's avatar
      tcp: batch tcp_net_metrics_exit · 789e6ddb
      Eric Dumazet authored
      When dealing with a list of dismantling netns, we can scan
      tcp_metrics once, saving cpu cycles.
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      789e6ddb
    • Eric Dumazet's avatar
      ipv6: addrlabel: per netns list · a90c9347
      Eric Dumazet authored
      Having a global list of labels do not scale to thousands of
      netns in the cloud era. This causes quadratic behavior on
      netns creation and deletion.
      
      This is time having a per netns list of ~10 labels.
      
      Tested:
      
      $ time perf record (for f in `seq 1 3000` ; do ip netns add tast$f; done)
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 3.637 MB perf.data (~158898 samples) ]
      
      real    0m20.837s # instead of 0m24.227s
      user    0m0.328s
      sys     0m20.338s # instead of 0m23.753s
      
          16.17%       ip  [kernel.kallsyms]  [k] netlink_broadcast_filtered
          12.30%       ip  [kernel.kallsyms]  [k] netlink_has_listeners
           6.76%       ip  [kernel.kallsyms]  [k] _raw_spin_lock_irqsave
           5.78%       ip  [kernel.kallsyms]  [k] memset_erms
           5.77%       ip  [kernel.kallsyms]  [k] kobject_uevent_env
           5.18%       ip  [kernel.kallsyms]  [k] refcount_sub_and_test
           4.96%       ip  [kernel.kallsyms]  [k] _raw_read_lock
           3.82%       ip  [kernel.kallsyms]  [k] refcount_inc_not_zero
           3.33%       ip  [kernel.kallsyms]  [k] _raw_spin_unlock_irqrestore
           2.11%       ip  [kernel.kallsyms]  [k] unmap_page_range
           1.77%       ip  [kernel.kallsyms]  [k] __wake_up
           1.69%       ip  [kernel.kallsyms]  [k] strlen
           1.17%       ip  [kernel.kallsyms]  [k] __wake_up_common
           1.09%       ip  [kernel.kallsyms]  [k] insert_header
           1.04%       ip  [kernel.kallsyms]  [k] page_remove_rmap
           1.01%       ip  [kernel.kallsyms]  [k] consume_skb
           0.98%       ip  [kernel.kallsyms]  [k] netlink_trim
           0.51%       ip  [kernel.kallsyms]  [k] kernfs_link_sibling
           0.51%       ip  [kernel.kallsyms]  [k] filemap_map_pages
           0.46%       ip  [kernel.kallsyms]  [k] memcpy_erms
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a90c9347
    • Eric Dumazet's avatar
      kobject: factorize skb setup in kobject_uevent_net_broadcast() · d464e84e
      Eric Dumazet authored
      We can build one skb and let it be cloned in netlink.
      
      This is much faster, and use less memory (all clones will
      share the same skb->head)
      
      Tested:
      
      time perf record (for f in `seq 1 3000` ; do ip netns add tast$f; done)
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 4.110 MB perf.data (~179584 samples) ]
      
      real    0m24.227s # instead of 0m52.554s
      user    0m0.329s
      sys 0m23.753s # instead of 0m51.375s
      
          14.77%       ip  [kernel.kallsyms]  [k] __ip6addrlbl_add
          14.56%       ip  [kernel.kallsyms]  [k] netlink_broadcast_filtered
          11.65%       ip  [kernel.kallsyms]  [k] netlink_has_listeners
           6.19%       ip  [kernel.kallsyms]  [k] _raw_spin_lock_irqsave
           5.66%       ip  [kernel.kallsyms]  [k] kobject_uevent_env
           4.97%       ip  [kernel.kallsyms]  [k] memset_erms
           4.67%       ip  [kernel.kallsyms]  [k] refcount_sub_and_test
           4.41%       ip  [kernel.kallsyms]  [k] _raw_read_lock
           3.59%       ip  [kernel.kallsyms]  [k] refcount_inc_not_zero
           3.13%       ip  [kernel.kallsyms]  [k] _raw_spin_unlock_irqrestore
           1.55%       ip  [kernel.kallsyms]  [k] __wake_up
           1.20%       ip  [kernel.kallsyms]  [k] strlen
           1.03%       ip  [kernel.kallsyms]  [k] __wake_up_common
           0.93%       ip  [kernel.kallsyms]  [k] consume_skb
           0.92%       ip  [kernel.kallsyms]  [k] netlink_trim
           0.87%       ip  [kernel.kallsyms]  [k] insert_header
           0.63%       ip  [kernel.kallsyms]  [k] unmap_page_range
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d464e84e