• Mike Marciniszyn's avatar
    IB/hfi1: Eliminate synchronize_rcu() in mr delete · b58fc804
    Mike Marciniszyn authored
    The synchronize_rcu() call can be eliminated to improve memory deregistration
    performance.
    
    There are two key fields involved:
    - The rcu pointer itself
    - the lkey_published field
    
    To close the window between the rcu read of the mregion pointer and the
    reference count the code should:
    
    1. To lkey/rkey validation (reader)
    
    Read the rcu pointer.  If the pointer is non-NULL, get a reference.
    
    To the current validation tests use a READ_ONCE() on the lkey_published.
    
    Upon any failure release the reference.
    
    2. To the remove logic (delete)
    
    Insure the published is zeroed prior to setting the pointer to NULL.
    This requires using rcu_assign_pointer() to insure lkey_published
    is written prior to the NULL.
    
    3. To the insert logic (add)
    
    Insure the published is set use an rcu_assign_pointer() to insure the
    pointer is after all MR fields.
    Reviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
    Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
    Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
    Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
    b58fc804
mr.c 23.4 KB