diff mbox series

[v1] IB/core: Warn if can't pin memory

Message ID 20181220093221.6624-1-yuval.shaia@oracle.com (mailing list archive)
State Superseded
Headers show
Series [v1] IB/core: Warn if can't pin memory | expand

Commit Message

Yuval Shaia Dec. 20, 2018, 9:32 a.m. UTC
When memory registration is needed for page count which exceeds the
allowed lock limit the function exits with an error but no error is
printed.
Since this is a case that system administrator can fix (rlimit etc) we
need to give an alert.
This is not a data patch so performance penalty is not a consideration.

Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
---
v0 -> v1:
	* Accept Leon's comment pr_err to pr_err_ratelimited
---
 drivers/infiniband/core/umem.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Gal Pressman Dec. 20, 2018, 9:39 a.m. UTC | #1
On 20-Dec-18 11:32, Yuval Shaia wrote:
> When memory registration is needed for page count which exceeds the
> allowed lock limit the function exits with an error but no error is
> printed.
> Since this is a case that system administrator can fix (rlimit etc) we
> need to give an alert.
> This is not a data patch so performance penalty is not a consideration.
> 
> Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
> ---
> v0 -> v1:
> 	* Accept Leon's comment pr_err to pr_err_ratelimited
> ---
>  drivers/infiniband/core/umem.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
> index c6144df47ea4..73f85cc35418 100644
> --- a/drivers/infiniband/core/umem.c
> +++ b/drivers/infiniband/core/umem.c
> @@ -164,6 +164,8 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
>  	if (check_add_overflow(mm->pinned_vm, npages, &new_pinned) ||
>  	    (new_pinned > lock_limit && !capable(CAP_IPC_LOCK))) {
>  		up_write(&mm->mmap_sem);
> +		pr_err_ratelimited("%s: Can't pin memory, requested %d, limit %d, ipc_lock off\n",
> +				   _func__, new_pinned, lock_limit);

Shouldn't these %d be %lu?

>  		ret = -ENOMEM;
>  		goto out;
>  	}
>
Yuval Shaia Dec. 20, 2018, 9:45 a.m. UTC | #2
On Thu, Dec 20, 2018 at 11:39:54AM +0200, Gal Pressman wrote:
> On 20-Dec-18 11:32, Yuval Shaia wrote:
> > When memory registration is needed for page count which exceeds the
> > allowed lock limit the function exits with an error but no error is
> > printed.
> > Since this is a case that system administrator can fix (rlimit etc) we
> > need to give an alert.
> > This is not a data patch so performance penalty is not a consideration.
> > 
> > Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
> > ---
> > v0 -> v1:
> > 	* Accept Leon's comment pr_err to pr_err_ratelimited
> > ---
> >  drivers/infiniband/core/umem.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
> > index c6144df47ea4..73f85cc35418 100644
> > --- a/drivers/infiniband/core/umem.c
> > +++ b/drivers/infiniband/core/umem.c
> > @@ -164,6 +164,8 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
> >  	if (check_add_overflow(mm->pinned_vm, npages, &new_pinned) ||
> >  	    (new_pinned > lock_limit && !capable(CAP_IPC_LOCK))) {
> >  		up_write(&mm->mmap_sem);
> > +		pr_err_ratelimited("%s: Can't pin memory, requested %d, limit %d, ipc_lock off\n",
> > +				   _func__, new_pinned, lock_limit);
> 
> Shouldn't these %d be %lu?

Make sense, missed that, will fix

> 
> >  		ret = -ENOMEM;
> >  		goto out;
> >  	}
> > 
>
Gal Pressman Dec. 20, 2018, 9:46 a.m. UTC | #3
On 20-Dec-18 11:45, Yuval Shaia wrote:
> On Thu, Dec 20, 2018 at 11:39:54AM +0200, Gal Pressman wrote:
>> On 20-Dec-18 11:32, Yuval Shaia wrote:
>>> When memory registration is needed for page count which exceeds the
>>> allowed lock limit the function exits with an error but no error is
>>> printed.
>>> Since this is a case that system administrator can fix (rlimit etc) we
>>> need to give an alert.
>>> This is not a data patch so performance penalty is not a consideration.

patch should be path.

>>>
>>> Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
>>> ---
>>> v0 -> v1:
>>> 	* Accept Leon's comment pr_err to pr_err_ratelimited
>>> ---
>>>  drivers/infiniband/core/umem.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
>>> index c6144df47ea4..73f85cc35418 100644
>>> --- a/drivers/infiniband/core/umem.c
>>> +++ b/drivers/infiniband/core/umem.c
>>> @@ -164,6 +164,8 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
>>>  	if (check_add_overflow(mm->pinned_vm, npages, &new_pinned) ||
>>>  	    (new_pinned > lock_limit && !capable(CAP_IPC_LOCK))) {
>>>  		up_write(&mm->mmap_sem);
>>> +		pr_err_ratelimited("%s: Can't pin memory, requested %d, limit %d, ipc_lock off\n",
>>> +				   _func__, new_pinned, lock_limit);
>>
>> Shouldn't these %d be %lu?
> 
> Make sense, missed that, will fix

Also, looks like something bad happened to __func__.

> 
>>
>>>  		ret = -ENOMEM;
>>>  		goto out;
>>>  	}
>>>
>>
diff mbox series

Patch

diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index c6144df47ea4..73f85cc35418 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -164,6 +164,8 @@  struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
 	if (check_add_overflow(mm->pinned_vm, npages, &new_pinned) ||
 	    (new_pinned > lock_limit && !capable(CAP_IPC_LOCK))) {
 		up_write(&mm->mmap_sem);
+		pr_err_ratelimited("%s: Can't pin memory, requested %d, limit %d, ipc_lock off\n",
+				   _func__, new_pinned, lock_limit);
 		ret = -ENOMEM;
 		goto out;
 	}