Re: [PATCH 6/8] RDMA/devices: Use xarray to store the clients

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

 



On 04-Feb-19 23:17, Jason Gunthorpe wrote:
> From: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
> 
> This gives each client a unique ID and will let us move client_data to use
> xarray, and revise the locking scheme.
> 
> clients have to be add/removed in strict FIFO/LIFO order as they
> interdepend. To support this the client_ids are assigned to increase in
> FIFO order. The existing linked list is kept to support reverse iteration
> until xarray can get a reverse iteration API.
> 
> Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
> Reviewed-by: Parav Pandit <parav@xxxxxxxxxxxx>
> ---
>  drivers/infiniband/core/device.c | 50 ++++++++++++++++++++++++++++----
>  include/rdma/ib_verbs.h          |  3 +-
>  2 files changed, 47 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> index 300a36beaa300c..f485e77223d429 100644
> --- a/drivers/infiniband/core/device.c
> +++ b/drivers/infiniband/core/device.c
> @@ -65,15 +65,17 @@ struct workqueue_struct *ib_comp_unbound_wq;
>  struct workqueue_struct *ib_wq;
>  EXPORT_SYMBOL_GPL(ib_wq);
>  
> -/* The device_list and client_list contain devices and clients after their
> +/* The device_list and clients contain devices and clients after their
>   * registration has completed, and the devices and clients are removed
>   * during unregistration. */
>  static LIST_HEAD(device_list);
>  static LIST_HEAD(client_list);
> +#define CLIENT_REGISTERED XA_MARK_1
> +static DEFINE_XARRAY_FLAGS(clients, XA_FLAGS_ALLOC);
>  
>  /*
>   * device_mutex and lists_rwsem protect access to both device_list and
> - * client_list.  device_mutex protects writer access by device and client
> + * clients.  device_mutex protects writer access by device and client
>   * registration / de-registration.  lists_rwsem protects reader access to
>   * these lists.  Iterators of these lists must lock it for read, while updates
>   * to the lists must be done with a write lock. A special case is when the
> @@ -563,6 +565,7 @@ int ib_register_device(struct ib_device *device, const char *name)
>  {
>  	int ret;
>  	struct ib_client *client;
> +	unsigned long index;
>  
>  	setup_dma_device(device);
>  
> @@ -607,7 +610,7 @@ int ib_register_device(struct ib_device *device, const char *name)
>  
>  	refcount_set(&device->refcount, 1);
>  
> -	list_for_each_entry(client, &client_list, list)
> +	xa_for_each_marked (&clients, index, client, CLIENT_REGISTERED)

nit: extra space after xa_for_each_marked.



[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