Skip to content
  1. Jan 06, 2016
    • David S. Miller's avatar
      Merge branch 'sctp-transport-rhashtable' · 33c15297
      David S. Miller authored
      
      
      Xin Long says:
      
      ====================
      sctp: use transport hashtable to replace association's with rhashtable
      
      for telecom center, the usual case is that a server is connected by thousands
      of clients. but if the server with only one enpoint(udp style) use the same
      sport and dport to communicate with every clients, and every assoc in server
      will be hashed in the same chain of global assoc hashtable due to currently we
      choose dport and sport as the hash key.
      
      when a packet is received, sctp_rcv try to find the assoc with sport and dport,
      since that chain is too long to find it fast, it make the performance turn to
      very low, some test data is as follow:
      
      in server:
      $./ss [start a udp style server there]
      in client:
      $./cc [start 2500 sockets to connect server with same port and different ip,
             and use one of them to send data to server]
      
      ===== test on net-next
      -- perf top
      server:
        55.73%  [kernel]             [k] sctp_assoc_is_match
         6.80%  [kernel]             [k] sctp_assoc_lookup_paddr
         4.81%  [kernel]             [k] sctp_v4_cmp_addr
         3.12%  [kernel]             [k] _raw_spin_unlock_irqrestore
         1.94%  [kernel]             [k] sctp_cmp_addr_exact
      
      client:
        46.01%  [kernel]                    [k] sctp_endpoint_lookup_assoc
         5.55%  libc-2.17.so                [.] __libc_calloc
         5.39%  libc-2.17.so                [.] _int_free
         3.92%  libc-2.17.so                [.] _int_malloc
         3.23%  [kernel]                    [k] __memset
      
      -- spent time
      time is 487s, send pkt is 10000000
      
      we need to change the way to calculate the hash key, to use lport +
      rport + paddr as the hash key can avoid this issue.
      
      besides, this patchset will use transport hashtable to replace
      association hashtable to lookup with rhashtable api. get transport
      first then get association by t->asoc. and also it will make tcp
      style work better.
      
      ===== test with this patchset:
      -- perf top
      server:
        15.98%  [kernel]                 [k] _raw_spin_unlock_irqrestore
         9.92%  [kernel]                 [k] __pv_queued_spin_lock_slowpath
         7.22%  [kernel]                 [k] copy_user_generic_string
         2.38%  libpthread-2.17.so       [.] __recvmsg_nocancel
         1.88%  [kernel]                 [k] sctp_recvmsg
      
      client:
        11.90%  [kernel]                   [k] sctp_hash_cmp
         8.52%  [kernel]                   [k] rht_deferred_worker
         4.94%  [kernel]                   [k] __pv_queued_spin_lock_slowpath
         3.95%  [kernel]                   [k] sctp_bind_addr_match
         2.49%  [kernel]                   [k] __memset
      
      -- spent time
      time is 22s, send pkt is 10000000
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      33c15297
    • Xin Long's avatar
      sctp: remove the local_bh_disable/enable in sctp_endpoint_lookup_assoc · c79c0666
      Xin Long authored
      
      
      sctp_endpoint_lookup_assoc is called in the protection of sock lock
      there is no need to call local_bh_disable in this function. so remove
      them.
      
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c79c0666
    • Xin Long's avatar
      sctp: drop the old assoc hashtable of sctp · b5eff712
      Xin Long authored
      
      
      transport hashtable will replace the association hashtable,
      so association hashtable is not used in sctp any more, so
      drop the codes about that.
      
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b5eff712
    • Xin Long's avatar
      sctp: apply rhashtable api to sctp procfs · 39f66a7d
      Xin Long authored
      
      
      Traversal the transport rhashtable, get the association only once through
      the condition assoc->peer.primary_path != transport.
      
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      39f66a7d
    • Xin Long's avatar
      sctp: apply rhashtable api to send/recv path · 4f008781
      Xin Long authored
      
      
      apply lookup apis to two functions, for __sctp_endpoint_lookup_assoc
      and __sctp_lookup_association, it's invoked in the protection of sock
      lock, it will be safe, but sctp_lookup_association need to call
      rcu_read_lock() and to detect the t->dead to protect it.
      
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4f008781
    • Xin Long's avatar
      sctp: add the rhashtable apis for sctp global transport hashtable · d6c0256a
      Xin Long authored
      
      
      tranport hashtbale will replace the association hashtable to do the
      lookup for transport, and then get association by t->assoc, rhashtable
      apis will be used because of it's resizable, scalable and using rcu.
      
      lport + rport + paddr will be the base hashkey to locate the chain,
      with net to protect one netns from another, then plus the laddr to
      compare to get the target.
      
      this patch will provider the lookup functions:
      - sctp_epaddr_lookup_transport
      - sctp_addrs_lookup_transport
      
      hash/unhash functions:
      - sctp_hash_transport
      - sctp_unhash_transport
      
      init/destroy functions:
      - sctp_transport_hashtable_init
      - sctp_transport_hashtable_destroy
      
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d6c0256a
  2. Jan 05, 2016
  3. Jan 01, 2016