IB/umem: Use the correct mm during ib_umem_release
authorLidong Chen <jemmy858585@gmail.com>
Tue, 8 May 2018 08:50:16 +0000 (16:50 +0800)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 15 May 2018 23:09:10 +0000 (17:09 -0600)
commit8e907ed4882714fd13cfe670681fc6cb5284c780
tree5ce4bf10cbe8129f41020043768d3958eebb2eff
parent3d69191086fc87f202c79eb8873b9c82c2bb065a
IB/umem: Use the correct mm during ib_umem_release

User-space may invoke ibv_reg_mr and ibv_dereg_mr in different threads.

If ibv_dereg_mr is called after the thread which invoked ibv_reg_mr has
exited, get_pid_task will return NULL and ib_umem_release will not
decrease mm->pinned_vm.

Instead of using threads to locate the mm, use the overall tgid from the
ib_ucontext struct instead. This matches the behavior of ODP and
disassociate in handling the mm of the process that called ibv_reg_mr.

Cc: <stable@vger.kernel.org>
Fixes: 87773dd56d54 ("IB: ib_umem_release() should decrement mm->pinned_vm from ib_umem_get")
Signed-off-by: Lidong Chen <lidongchen@tencent.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/umem.c
include/rdma/ib_umem.h