* [PATCH 1/1] RDMA/rxe: Return the correct errno
@ 2024-04-08 14:21 Zhu Yanjun
2024-04-11 9:11 ` Zhijian Li (Fujitsu)
2024-04-11 11:47 ` Leon Romanovsky
0 siblings, 2 replies; 4+ messages in thread
From: Zhu Yanjun @ 2024-04-08 14:21 UTC (permalink / raw)
To: zyjzyj2000, jgg, leon, linux-rdma; +Cc: Zhu Yanjun
In the function __rxe_add_to_pool, the function xa_alloc_cyclic is
called. The return value of the function xa_alloc_cyclic is as below:
"
Return: 0 if the allocation succeeded without wrapping. 1 if the
allocation succeeded after wrapping, -ENOMEM if memory could not be
allocated or -EBUSY if there are no free entries in @limit.
"
But now the function __rxe_add_to_pool only returns -EINVAL. All the
returned error value should be returned to the caller.
Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
---
drivers/infiniband/sw/rxe/rxe_pool.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
index 6215c6de3a84..43ba0277bd7b 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.c
+++ b/drivers/infiniband/sw/rxe/rxe_pool.c
@@ -122,8 +122,10 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem,
int err;
gfp_t gfp_flags;
- if (atomic_inc_return(&pool->num_elem) > pool->max_elem)
+ if (atomic_inc_return(&pool->num_elem) > pool->max_elem) {
+ err = -EINVAL;
goto err_cnt;
+ }
elem->pool = pool;
elem->obj = (u8 *)elem - pool->elem_offset;
@@ -147,7 +149,7 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem,
err_cnt:
atomic_dec(&pool->num_elem);
- return -EINVAL;
+ return err;
}
void *rxe_pool_get_index(struct rxe_pool *pool, u32 index)
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/1] RDMA/rxe: Return the correct errno
2024-04-08 14:21 [PATCH 1/1] RDMA/rxe: Return the correct errno Zhu Yanjun
@ 2024-04-11 9:11 ` Zhijian Li (Fujitsu)
2024-04-11 10:55 ` Zhu Yanjun
2024-04-11 11:47 ` Leon Romanovsky
1 sibling, 1 reply; 4+ messages in thread
From: Zhijian Li (Fujitsu) @ 2024-04-11 9:11 UTC (permalink / raw)
To: Zhu Yanjun, zyjzyj2000@gmail.com, jgg@ziepe.ca, leon@kernel.org,
linux-rdma@vger.kernel.org
On 08/04/2024 22:21, Zhu Yanjun wrote:
> In the function __rxe_add_to_pool, the function xa_alloc_cyclic is
> called. The return value of the function xa_alloc_cyclic is as below:
> "
> Return: 0 if the allocation succeeded without wrapping. 1 if the
> allocation succeeded after wrapping, -ENOMEM if memory could not be
> allocated or -EBUSY if there are no free entries in @limit.
> "
> But now the function __rxe_add_to_pool only returns -EINVAL. All the
> returned error value should be returned to the caller.
>
make sense.
> Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
> ---
> drivers/infiniband/sw/rxe/rxe_pool.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
> index 6215c6de3a84..43ba0277bd7b 100644
> --- a/drivers/infiniband/sw/rxe/rxe_pool.c
> +++ b/drivers/infiniband/sw/rxe/rxe_pool.c
> @@ -122,8 +122,10 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem,
> int err;
I'd like to assign 'err' a default error code: -EINVAL
Thanks
Zhijian
> gfp_t gfp_flags;
>
> - if (atomic_inc_return(&pool->num_elem) > pool->max_elem)
> + if (atomic_inc_return(&pool->num_elem) > pool->max_elem) {
> + err = -EINVAL;
> goto err_cnt;
> + }
>
> elem->pool = pool;
> elem->obj = (u8 *)elem - pool->elem_offset;
> @@ -147,7 +149,7 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem,
>
> err_cnt:
> atomic_dec(&pool->num_elem);
> - return -EINVAL;
> + return err;
> }
>
> void *rxe_pool_get_index(struct rxe_pool *pool, u32 index)
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/1] RDMA/rxe: Return the correct errno
2024-04-11 9:11 ` Zhijian Li (Fujitsu)
@ 2024-04-11 10:55 ` Zhu Yanjun
0 siblings, 0 replies; 4+ messages in thread
From: Zhu Yanjun @ 2024-04-11 10:55 UTC (permalink / raw)
To: Zhijian Li (Fujitsu), zyjzyj2000@gmail.com, jgg@ziepe.ca,
leon@kernel.org, linux-rdma@vger.kernel.org
在 2024/4/11 11:11, Zhijian Li (Fujitsu) 写道:
>
> On 08/04/2024 22:21, Zhu Yanjun wrote:
>> In the function __rxe_add_to_pool, the function xa_alloc_cyclic is
>> called. The return value of the function xa_alloc_cyclic is as below:
>> "
>> Return: 0 if the allocation succeeded without wrapping. 1 if the
>> allocation succeeded after wrapping, -ENOMEM if memory could not be
>> allocated or -EBUSY if there are no free entries in @limit.
>> "
>> But now the function __rxe_add_to_pool only returns -EINVAL. All the
>> returned error value should be returned to the caller.
>>
> make sense.
>
>
>> Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
>> ---
>> drivers/infiniband/sw/rxe/rxe_pool.c | 6 ++++--
>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
>> index 6215c6de3a84..43ba0277bd7b 100644
>> --- a/drivers/infiniband/sw/rxe/rxe_pool.c
>> +++ b/drivers/infiniband/sw/rxe/rxe_pool.c
>> @@ -122,8 +122,10 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem,
>> int err;
> I'd like to assign 'err' a default error code: -EINVAL
Thanks a lot for your comments.
Before the local variable err is used, this variable err has already
been set.
As such, it is not necessary to initialize this local variable when it
is declared.
Best Regards,
Zhu Yanjun
>
>
> Thanks
> Zhijian
>
>
>
>> gfp_t gfp_flags;
>>
>> - if (atomic_inc_return(&pool->num_elem) > pool->max_elem)
>> + if (atomic_inc_return(&pool->num_elem) > pool->max_elem) {
>> + err = -EINVAL;
>> goto err_cnt;
>> + }
>>
>> elem->pool = pool;
>> elem->obj = (u8 *)elem - pool->elem_offset;
>> @@ -147,7 +149,7 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem,
>>
>> err_cnt:
>> atomic_dec(&pool->num_elem);
>> - return -EINVAL;
>> + return err;
>> }
>>
>> void *rxe_pool_get_index(struct rxe_pool *pool, u32 index)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] RDMA/rxe: Return the correct errno
2024-04-08 14:21 [PATCH 1/1] RDMA/rxe: Return the correct errno Zhu Yanjun
2024-04-11 9:11 ` Zhijian Li (Fujitsu)
@ 2024-04-11 11:47 ` Leon Romanovsky
1 sibling, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2024-04-11 11:47 UTC (permalink / raw)
To: zyjzyj2000, jgg, linux-rdma, Zhu Yanjun
On Mon, 08 Apr 2024 16:21:42 +0200, Zhu Yanjun wrote:
> In the function __rxe_add_to_pool, the function xa_alloc_cyclic is
> called. The return value of the function xa_alloc_cyclic is as below:
> "
> Return: 0 if the allocation succeeded without wrapping. 1 if the
> allocation succeeded after wrapping, -ENOMEM if memory could not be
> allocated or -EBUSY if there are no free entries in @limit.
> "
> But now the function __rxe_add_to_pool only returns -EINVAL. All the
> returned error value should be returned to the caller.
>
> [...]
Applied, thanks!
[1/1] RDMA/rxe: Return the correct errno
https://git.kernel.org/rdma/rdma/c/dfcdb38b21e4fb
Best regards,
--
Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-11 11:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-08 14:21 [PATCH 1/1] RDMA/rxe: Return the correct errno Zhu Yanjun
2024-04-11 9:11 ` Zhijian Li (Fujitsu)
2024-04-11 10:55 ` Zhu Yanjun
2024-04-11 11:47 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox