• Kuniyuki Iwashima's avatar
    af_unix: Replace the big lock with small locks. · afd20b92
    Kuniyuki Iwashima authored
    The hash table of AF_UNIX sockets is protected by the single lock.  This
    patch replaces it with per-hash locks.
    
    The effect is noticeable when we handle multiple sockets simultaneously.
    Here is a test result on an EC2 c5.24xlarge instance.  It shows latency
    (under 10us only) in unix_insert_unbound_socket() while 64 CPUs creating
    1024 sockets for each in parallel.
    
      Without this patch:
    
         nsec          : count     distribution
            0          : 179      |                                        |
            500        : 3021     |*********                               |
            1000       : 6271     |*******************                     |
            1500       : 6318     |*******************                     |
            2000       : 5828     |*****************                       |
            2500       : 5124     |***************                         |
            3000       : 4426     |*************                           |
            3500       : 3672     |***********                             |
            4000       : 3138     |*********                               |
            4500       : 2811     |********                                |
            5000       : 2384     |*******                                 |
            5500       : 2023     |******                                  |
            6000       : 1954     |*****                                   |
            6500       : 1737     |*****                                   |
            7000       : 1749     |*****                                   |
            7500       : 1520     |****                                    |
            8000       : 1469     |****                                    |
            8500       : 1394     |****                                    |
            9000       : 1232     |***                                     |
            9500       : 1138     |***                                     |
            10000      : 994      |***                                     |
    
      With this patch:
    
         nsec          : count     distribution
            0          : 1634     |****                                    |
            500        : 13170    |****************************************|
            1000       : 13156    |*************************************** |
            1500       : 9010     |***************************             |
            2000       : 6363     |*******************                     |
            2500       : 4443     |*************                           |
            3000       : 3240     |*********                               |
            3500       : 2549     |*******                                 |
            4000       : 1872     |*****                                   |
            4500       : 1504     |****                                    |
            5000       : 1247     |***                                     |
            5500       : 1035     |***                                     |
            6000       : 889      |**                                      |
            6500       : 744      |**                                      |
            7000       : 634      |*                                       |
            7500       : 498      |*                                       |
            8000       : 433      |*                                       |
            8500       : 355      |*                                       |
            9000       : 336      |*                                       |
            9500       : 284      |                                        |
            10000      : 243      |                                        |
    Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.co.jp>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    afd20b92
diag.c 7.55 KB