On Tue, Feb 05, 2019 at 04:19:14PM +0200, Gal Pressman wrote: > 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 > > +++ 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. meh. Some places in the kernel put the space, maby don't. In this case clang-format wants to put the space for all 'for' macros (and who can blame, it for should aways have a space). I hate to fight with clang-format over such trivial things. Especially when there isn't a specific requirement in coding style. Jason