1. 15 2月, 2018 1 次提交
  2. 14 2月, 2018 26 次提交
  3. 13 2月, 2018 13 次提交
    • D
      Merge branch 'Replacing-net_mutex-with-rw_semaphore' · 885842d8
      David S. Miller 提交于
      Kirill Tkhai says:
      
      ====================
      Replacing net_mutex with rw_semaphore
      
      this is the third version of the patchset introducing net_sem
      instead of net_mutex. The patchset adds net_sem in addition
      to net_mutex and allows pernet_operations to be "async". This
      flag means, the pernet_operations methods are safe to be
      executed with any other pernet_operations (un)initializing
      another net.
      
      If there are only async pernet_operations in the system,
      net_mutex is not used either for setup_net() or for cleanup_net().
      
      The pernet_operations converted in this patchset allow
      to create minimal .config to have network working, and
      the changes improve the performance like you may see
      below:
      
          %for i in {1..10000}; do unshare -n bash -c exit; done
      
          *before*
          real 1m40,377s
          user 0m9,672s
          sys 0m19,928s
      
          *after*
          real 0m17,007s
          user 0m5,311s
          sys 0m11,779
      
          (5.8 times faster)
      
      In the future, when all pernet_operations become async,
      we'll just remove this "async" field tree-wide.
      
      All the new logic is concentrated in patches [1-5/32].
      The rest of patches converts specific operations:
      review, rationale of they can be converted, and setting
      of async flag.
      
      Kirill
      
      v3: Improved patches descriptions. Added comment into [5/32].
      Added [32/32] converting netlink_tap_net_ops (new pernet operations
      introduced in 2018).
      
      v2: Single patch -> patchset with rationale of every conversion
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      885842d8
    • K
      net: Convert netlink_tap_net_ops · b86b47a3
      Kirill Tkhai 提交于
      These pernet_operations init just allocated net memory,
      and they obviously can be executed in parallel in any
      others.
      
      v3: New
      Signed-off-by: NKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: NAndrei Vagin <avagin@virtuozzo.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b86b47a3
    • K
      net: Convert diag_net_ops · 59a51358
      Kirill Tkhai 提交于
      These pernet operations just create and destroy netlink
      socket. The socket is pernet and else operations don't
      touch it.
      Signed-off-by: NKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: NAndrei Vagin <avagin@virtuozzo.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      59a51358
    • K
      net: Convert default_device_ops · 2608e6b7
      Kirill Tkhai 提交于
      These pernet operations consist of exit() and exit_batch() methods.
      
      default_device_exit() moves not-local and virtual devices to init_net.
      There is nothing exciting, because this may happen in any time
      on a working system, and rtnl_lock() and synchronize_net() protect
      us from all cases of external dereference.
      
      The same for default_device_exit_batch(). Similar unregisteration
      may happen in any time on a system. Here several lists (like todo_list),
      which are accessed under rtnl_lock(). After rtnl_unlock() and
      netdev_run_todo() all the devices are flushed.
      Signed-off-by: NKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: NAndrei Vagin <avagin@virtuozzo.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2608e6b7
    • K
      net: Convert loopback_net_ops · 9a4d105d
      Kirill Tkhai 提交于
      These pernet_operations have only init() method. It allocates
      memory for net_device, calls register_netdev() and assigns
      net::loopback_dev.
      
      register_netdev() is allowed be used without additional locks,
      as it's synchronized on rtnl_lock(). There are many examples
      of using this functon directly from ioctl().
      
      The only difference, compared to ioctl(), is that net is not
      completely alive at this moment. But it looks like, there is
      no way for parallel pernet_operations to dereference
      the net_device, as the most of struct net_device lists,
      where it's linked, are related to net, and the net is not liked.
      
      The exceptions are net_device::unreg_list, close_list, todo_list,
      used for unregistration, and ::link_watch_list, where net_device
      may be linked to global lists.
      
      Unregistration of loopback_dev obviously can't happen, when
      loopback_net_init() is executing, as the net as alive. It occurs
      in default_device_ops, which currently requires net_mutex,
      and it behaves as a barrier at the moment. It will be considered
      in next patch.
      
      Speaking about link_watch_list, it seems, there is no way
      for loopback_dev at time of registration to be linked in lweventlist
      and be available for another pernet_operations.
      Signed-off-by: NKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: NAndrei Vagin <avagin@virtuozzo.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9a4d105d
    • K
      net: Convert addrconf_ops · 0bc9be67
      Kirill Tkhai 提交于
      These pernet_operations (un)register sysctl, which
      are not touched by anybody else.
      
      So, it's safe to make them async.
      Signed-off-by: NKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: NAndrei Vagin <avagin@virtuozzo.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0bc9be67
    • K
      net: Convert ipv4_sysctl_ops · 22769a2a
      Kirill Tkhai 提交于
      These pernet_operations create and destroy sysctl,
      which are not touched by anybody else.
      Signed-off-by: NKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: NAndrei Vagin <avagin@virtuozzo.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      22769a2a
    • K
      net: Convert packet_net_ops · cb5e3400
      Kirill Tkhai 提交于
      These pernet_operations just create and destroy /proc entry,
      and another operations do not touch it.
      
      Also, nobody else are interested in foreign net::packet::sklist.
      Signed-off-by: NKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: NAndrei Vagin <avagin@virtuozzo.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      cb5e3400
    • K
      net: Convert unix_net_ops · 167f7ac7
      Kirill Tkhai 提交于
      These pernet_operations are just create and destroy
      /proc and sysctl entries, and are not touched by
      foreign pernet_operations.
      
      So, we are able to make them async.
      Signed-off-by: NKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: NAndrei Vagin <avagin@virtuozzo.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      167f7ac7
    • K
      net: Convert pernet_subsys, registered from inet_init() · f84c6821
      Kirill Tkhai 提交于
      arp_net_ops just addr/removes /proc entry.
      
      devinet_ops allocates and frees duplicate of init_net tables
      and (un)registers sysctl entries.
      
      fib_net_ops allocates and frees pernet tables, creates/destroys
      netlink socket and (un)initializes /proc entries. Foreign
      pernet_operations do not touch them.
      
      ip_rt_proc_ops only modifies pernet /proc entries.
      
      xfrm_net_ops creates/destroys /proc entries, allocates/frees
      pernet statistics, hashes and tables, and (un)initializes
      sysctl files. These are not touched by foreigh pernet_operations
      
      xfrm4_net_ops allocates/frees private pernet memory, and
      configures sysctls.
      
      sysctl_route_ops creates/destroys sysctls.
      
      rt_genid_ops only initializes fields of just allocated net.
      
      ipv4_inetpeer_ops allocated/frees net private memory.
      
      igmp_net_ops just creates/destroys /proc files and socket,
      noone else interested in.
      
      tcp_sk_ops seems to be safe, because tcp_sk_init() does not
      depend on any other pernet_operations modifications. Iteration
      over hash table in inet_twsk_purge() is made under RCU lock,
      and it's safe to iterate the table this way. Removing from
      the table happen from inet_twsk_deschedule_put(), but this
      function is safe without any extern locks, as it's synchronized
      inside itself. There are many examples, it's used in different
      context. So, it's safe to leave tcp_sk_exit_batch() unlocked.
      
      tcp_net_metrics_ops is synchronized on tcp_metrics_lock and safe.
      
      udplite4_net_ops only creates/destroys pernet /proc file.
      
      icmp_sk_ops creates percpu sockets, not touched by foreign
      pernet_operations.
      
      ipmr_net_ops creates/destroys pernet fib tables, (un)registers
      fib rules and /proc files. This seem to be safe to execute
      in parallel with foreign pernet_operations.
      
      af_inet_ops just sets up default parameters of newly created net.
      
      ipv4_mib_ops creates and destroys pernet percpu statistics.
      
      raw_net_ops, tcp4_net_ops, udp4_net_ops, ping_v4_net_ops
      and ip_proc_ops only create/destroy pernet /proc files.
      
      ip4_frags_ops creates and destroys sysctl file.
      
      So, it's safe to make the pernet_operations async.
      Signed-off-by: NKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: NAndrei Vagin <avagin@virtuozzo.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f84c6821
    • K
      net: Convert sysctl_core_ops · 232cf06c
      Kirill Tkhai 提交于
      These pernet_operations register and destroy sysctl
      directory, and it's not interesting for foreign
      pernet_operations.
      Signed-off-by: NKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: NAndrei Vagin <avagin@virtuozzo.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      232cf06c
    • K
      net: Convert wext_pernet_ops · 6c0075d0
      Kirill Tkhai 提交于
      These pernet_operations initialize and purge net::wext_nlevents
      queue, and are not touched by foreign pernet_operations.
      
      Mark them async.
      Signed-off-by: NKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: NAndrei Vagin <avagin@virtuozzo.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6c0075d0
    • K
      net: Convert genl_pernet_ops · 83caf62c
      Kirill Tkhai 提交于
      This pernet_operations create and destroy net::genl_sock.
      Foreign pernet_operations don't touch it.
      Signed-off-by: NKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: NAndrei Vagin <avagin@virtuozzo.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      83caf62c