Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/umem: Avoid synchronize_srcu in the ODP MR destruction path

synchronize_rcu is slow enough that it should be avoided on the syscall
path when user space is destroying MRs. After all the rework we can now
trivially do this by having call_srcu kfree the per_mm.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>

authored by

Jason Gunthorpe and committed by
Doug Ledford
56ac9dd9 be7a57b4

+9 -2
+8 -2
drivers/infiniband/core/umem_odp.c
··· 307 307 return 0; 308 308 } 309 309 310 + static void free_per_mm(struct rcu_head *rcu) 311 + { 312 + kfree(container_of(rcu, struct ib_ucontext_per_mm, rcu)); 313 + } 314 + 310 315 void put_per_mm(struct ib_umem_odp *umem_odp) 311 316 { 312 317 struct ib_ucontext_per_mm *per_mm = umem_odp->per_mm; ··· 339 334 per_mm->active = false; 340 335 up_write(&per_mm->umem_rwsem); 341 336 342 - mmu_notifier_unregister(&per_mm->mn, per_mm->mm); 337 + WARN_ON(!RB_EMPTY_ROOT(&per_mm->umem_tree.rb_root)); 338 + mmu_notifier_unregister_no_release(&per_mm->mn, per_mm->mm); 343 339 put_pid(per_mm->tgid); 344 - kfree(per_mm); 340 + mmu_notifier_call_srcu(&per_mm->rcu, free_per_mm); 345 341 } 346 342 347 343 struct ib_umem_odp *ib_alloc_odp_umem(struct ib_ucontext_per_mm *per_mm,
+1
include/rdma/ib_umem_odp.h
··· 99 99 unsigned int odp_mrs_count; 100 100 101 101 struct list_head ucontext_list; 102 + struct rcu_head rcu; 102 103 }; 103 104 104 105 int ib_umem_odp_get(struct ib_umem_odp *umem_odp, int access);