]> git.baikalelectronics.ru Git - kernel.git/commit
RDMA/umem: Minor optimizations
authorDoug Ledford <dledford@redhat.com>
Fri, 21 Sep 2018 15:30:12 +0000 (11:30 -0400)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 25 Sep 2018 21:19:06 +0000 (15:19 -0600)
commitec205615ca7702c6baf82ae42113512d338d55db
tree97a27e26c26602a973a30d6c964eb0c17319873a
parent27802ed3054faeffb34c77df3ac86a8a074bf9f7
RDMA/umem: Minor optimizations

Noticed while reviewing commit 13af47d662ae ("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: Doug Ledford <dledford@redhat.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/umem.c