• Doug Ledford's avatar
    RDMA/umem: Minor optimizations · 3312d1c6
    Doug Ledford authored
    Noticed while reviewing commit d4b4dd1b ("RDMA/umem: Do not use
    current->tgid to track the mm_struct") patch.  Why would we take a lock,
    adjust a protected variable, drop the lock, and *then* check the input
    into our protected variable adjustment?  Then we have to take the lock
    again on our error unwind.  Let's just check the input early and skip
    taking the locks needlessly if the input isn't valid.
    
    It was also noticed that we set mm = current->mm, we then never modify
    mm, but we still go back and reference current->mm a number of times
    needlessly.  Be consistent in using the stored reference in mm.
    Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
    Reviewed-by: default avatarLeon Romanovsky <leonro@mellanox.com>
    Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
    3312d1c6
umem.c 8.83 KB