linux/drivers/infiniband/core
Shawn Bohrer 87773dd56d IB: ib_umem_release() should decrement mm->pinned_vm from ib_umem_get
In debugging an application that receives -ENOMEM from ib_reg_mr(), I
found that ib_umem_get() can fail because the pinned_vm count has
wrapped causing it to always be larger than the lock limit even with
RLIMIT_MEMLOCK set to RLIM_INFINITY.

The wrapping of pinned_vm occurs because the process that calls
ib_reg_mr() will have its mm->pinned_vm count incremented.  Later a
different process with a different mm_struct than the one that
allocated the ib_umem struct ends up releasing it which results in
decrementing the new processes mm->pinned_vm count past zero and
wrapping.

I'm not entirely sure what circumstances cause a different process to
release the ib_umem than the one that allocated it but the kernel
stack trace of the freeing process from my situation looks like the
following:

    Call Trace:
     [<ffffffff814d64b1>] dump_stack+0x19/0x1b
     [<ffffffffa0b522a5>] ib_umem_release+0x1f5/0x200 [ib_core]
     [<ffffffffa0b90681>] mlx4_ib_destroy_qp+0x241/0x440 [mlx4_ib]
     [<ffffffffa0b4d93c>] ib_destroy_qp+0x12c/0x170 [ib_core]
     [<ffffffffa0cc7129>] ib_uverbs_close+0x259/0x4e0 [ib_uverbs]
     [<ffffffff81141cba>] __fput+0xba/0x240
     [<ffffffff81141e4e>] ____fput+0xe/0x10
     [<ffffffff81060894>] task_work_run+0xc4/0xe0
     [<ffffffff810029e5>] do_notify_resume+0x95/0xa0
     [<ffffffff814e3dd0>] int_signal+0x12/0x17

The following patch fixes the issue by storing the pid struct of the
process that calls ib_umem_get() so that ib_umem_release and/or
ib_umem_account() can properly decrement the pinned_vm count of the
correct mm_struct.

Signed-off-by: Shawn Bohrer <sbohrer@rgmadvisors.com>
Reviewed-by: Shachar Raindel <raindel@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2014-09-19 09:55:42 -07:00
..
addr.c IB/core: Ethernet L2 attributes in verbs/cm structures 2014-01-14 14:20:54 -08:00
agent.c IB/mad: add new ioctl to ABI to support new registration options 2014-08-10 20:36:00 -07:00
agent.h
cache.c IB/core: Add ib_find_exact_cached_pkey() 2012-09-30 20:33:30 -07:00
cm_msgs.h IB/core: Move CM_xxx_ATTR_ID macros from cm_msgs.h to ib_cm.h 2012-07-08 18:05:06 -07:00
cm.c IB/mad: add new ioctl to ABI to support new registration options 2014-08-10 20:36:00 -07:00
cma.c RDMA/core: Add support for iWARP Port Mapper user space service 2014-06-10 10:11:45 -07:00
core_priv.h IB/core: Resolve Ethernet L2 addresses when modifying QP 2014-01-19 15:14:04 -08:00
device.c IB/core: Handle table with full and partial membership for the same P_Key 2012-09-30 20:33:29 -07:00
fmr_pool.c hlist: drop the node parameter from iterators 2013-02-27 19:10:24 -08:00
iwcm.c RDMA/iwcm: Use a default listen backlog if needed 2014-08-05 07:33:24 -07:00
iwcm.h
iwpm_msg.c RDMA/core: Add support for iWARP Port Mapper user space service 2014-06-10 10:11:45 -07:00
iwpm_util.c RDMA/core: Add support for iWARP Port Mapper user space service 2014-06-10 10:11:45 -07:00
iwpm_util.h RDMA/core: Add support for iWARP Port Mapper user space service 2014-06-10 10:11:45 -07:00
mad_priv.h IB/mad: Update module to [pr|dev]_* style print messages 2014-08-10 20:35:39 -07:00
mad_rmpp.c
mad_rmpp.h
mad.c IB/mad: Add user space RMPP support 2014-08-10 20:36:00 -07:00
Makefile RDMA/core: Add support for iWARP Port Mapper user space service 2014-06-10 10:11:45 -07:00
multicast.c
netlink.c RDMA/core: Add support for iWARP Port Mapper user space service 2014-06-10 10:11:45 -07:00
packer.c
sa_query.c IB/mad: add new ioctl to ABI to support new registration options 2014-08-10 20:36:00 -07:00
sa.h
smi.c
smi.h
sysfs.c IB/core: Fix kobject leak on device register error flow 2014-06-05 09:37:10 -07:00
ucm.c IB/core: convert to idr_alloc() 2013-02-27 19:10:16 -08:00
ucma.c IB/cma: IBoE (RoCE) IP-based GID addressing 2014-01-18 14:12:35 -08:00
ud_header.c
umem.c IB: ib_umem_release() should decrement mm->pinned_vm from ib_umem_get 2014-09-19 09:55:42 -07:00
user_mad.c IB/mad: Add user space RMPP support 2014-08-10 20:36:00 -07:00
uverbs_cmd.c IB/core: Add user MR re-registration support 2014-08-01 15:11:13 -07:00
uverbs_main.c IB/core: Add user MR re-registration support 2014-08-01 15:11:13 -07:00
uverbs_marshall.c
uverbs.h IB/core: Add user MR re-registration support 2014-08-01 15:11:13 -07:00
verbs.c IB/core: Fix sparse warnings about redeclared functions 2014-06-04 10:01:42 -07:00