Re: [PATCH for-next v2 5/6] RDMA/rxe: Remove unneeded pool->state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jan 23, 2021 at 3:30 AM Bob Pearson <rpearsonhpe@xxxxxxxxx> wrote:
>
> rxe_pool.c uses the field pool->state to mark a pool as invalid
> when it is shut down and checks it in several pool APIs to verify
> that the pool has not been shut dowm.

s/dowm/down

 This is unneeded because the
> pools are not marked invalid unless the entire driver is being
> removed at which point no functional APIs should or could be
> executing. This patch removes this field and associated code.
>
> Signed-off-by: Bob Pearson <rpearson@xxxxxxx>
> ---
>  drivers/infiniband/sw/rxe/rxe_pool.c | 38 +---------------------------
>  1 file changed, 1 insertion(+), 37 deletions(-)
>
> diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
> index 09d8665c5343..7a03d49b263d 100644
> --- a/drivers/infiniband/sw/rxe/rxe_pool.c
> +++ b/drivers/infiniband/sw/rxe/rxe_pool.c
> @@ -157,24 +157,16 @@ int rxe_pool_init(
>                 pool->key.key_size = rxe_type_info[type].key_size;
>         }
>
> -       pool->state = RXE_POOL_STATE_VALID;
> -
>  out:
>         return err;
>  }
>
>  void rxe_pool_cleanup(struct rxe_pool *pool)
>  {
> -       unsigned long flags;
> -
> -       write_lock_irqsave(&pool->pool_lock, flags);
> -       pool->state = RXE_POOL_STATE_INVALID;
>         if (atomic_read(&pool->num_elem) > 0)
>                 pr_warn("%s pool destroyed with unfree'd elem\n",
>                         pool_name(pool));
> -       write_unlock_irqrestore(&pool->pool_lock, flags);
>
> -       pool->state = RXE_POOL_STATE_INVALID;
>         kfree(pool->index.table);
>  }
>
> @@ -328,9 +320,6 @@ void *rxe_alloc__(struct rxe_pool *pool)
>         struct rxe_pool_entry *elem;
>         u8 *obj;
>
> -       if (pool->state != RXE_POOL_STATE_VALID)
> -               return NULL;
> -
>         if (atomic_inc_return(&pool->num_elem) > pool->max_elem)
>                 goto out_cnt;
>
> @@ -352,19 +341,10 @@ void *rxe_alloc__(struct rxe_pool *pool)
>
>  void *rxe_alloc(struct rxe_pool *pool)
>  {
> -       unsigned long flags;
>         struct rxe_type_info *info = &rxe_type_info[pool->type];
>         struct rxe_pool_entry *elem;
>         u8 *obj;
>
> -       read_lock_irqsave(&pool->pool_lock, flags);
> -       if (pool->state != RXE_POOL_STATE_VALID) {
> -               read_unlock_irqrestore(&pool->pool_lock, flags);
> -               return NULL;
> -       }
> -
> -       read_unlock_irqrestore(&pool->pool_lock, flags);
> -
>         if (atomic_inc_return(&pool->num_elem) > pool->max_elem)
>                 goto out_cnt;
>
> @@ -386,15 +366,6 @@ void *rxe_alloc(struct rxe_pool *pool)
>
>  int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_entry *elem)
>  {
> -       unsigned long flags;
> -
> -       read_lock_irqsave(&pool->pool_lock, flags);
> -       if (pool->state != RXE_POOL_STATE_VALID) {
> -               read_unlock_irqrestore(&pool->pool_lock, flags);
> -               return -EINVAL;
> -       }
> -       read_unlock_irqrestore(&pool->pool_lock, flags);
> -
>         if (atomic_inc_return(&pool->num_elem) > pool->max_elem)
>                 goto out_cnt;
>
> @@ -437,9 +408,6 @@ void *rxe_pool_get_index(struct rxe_pool *pool, u32 index)
>
>         read_lock_irqsave(&pool->pool_lock, flags);
>
> -       if (pool->state != RXE_POOL_STATE_VALID)
> -               goto out;
> -
>         node = pool->index.tree.rb_node;
>
>         while (node) {
> @@ -460,8 +428,8 @@ void *rxe_pool_get_index(struct rxe_pool *pool, u32 index)
>                 obj = NULL;
>         }
>
> -out:
>         read_unlock_irqrestore(&pool->pool_lock, flags);
> +
>         return obj;
>  }
>
> @@ -473,9 +441,6 @@ void *rxe_pool_get_key__(struct rxe_pool *pool, void *key)
>         u8 *obj = NULL;
>         int cmp;
>
> -       if (pool->state != RXE_POOL_STATE_VALID)
> -               goto out;
> -
>         node = pool->key.tree.rb_node;
>
>         while (node) {
> @@ -499,7 +464,6 @@ void *rxe_pool_get_key__(struct rxe_pool *pool, void *key)
>                 obj = NULL;
>         }
>
> -out:
>         return obj;
>  }
>
> --
> 2.27.0
>



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux