> -----Original Message----- > From: Jason Gunthorpe [mailto:jgg@xxxxxxxx] > Sent: Tuesday, May 15, 2018 12:36 PM > To: Leon Romanovsky <leon@xxxxxxxxxx> > Cc: Doug Ledford <dledford@xxxxxxxxxx>; Leon Romanovsky > <leonro@xxxxxxxxxxxx>; RDMA mailing list <linux-rdma@xxxxxxxxxxxxxxx>; > Parav Pandit <parav@xxxxxxxxxxxx> > Subject: Re: [PATCH rdma-next 06/12] IB/core: Introduce GID attribute get, put > and hold APIs > > On Mon, May 14, 2018 at 11:11:12AM +0300, Leon Romanovsky wrote: > > +/** > > + * rdma_put_gid_attr - Release reference to the GID attribute > > + * @attr: Pointer to the GID attribute whose reference > > + * needs to be released. > > + * > > + * rdma_put_gid_attr() must be used to release reference whose > > + * reference is acquired using rdma_get_gid_attr() or any APIs > > + * which returns pointer to the ib_gid_attr regardless of link layer > > + * of IB or RoCE. > > + * > > + */ > > +void rdma_put_gid_attr(const struct ib_gid_attr *attr) { > > + struct ib_gid_table_entry *entry = > > + container_of(attr, struct ib_gid_table_entry, attr); > > + struct ib_device *device = entry->attr.device; > > + u8 port_num = entry->attr.port_num; > > + struct ib_gid_table *table; > > + > > + if (!rdma_protocol_roce(device, port_num)) > > + return; > > + table = device->cache.ports[port_num - rdma_start_port(device)].gid; > > + > > + write_lock_irq(&table->rwlock); > > + kref_put(&entry->kref, schedule_free_roce_gid); > > + write_unlock_irq(&table->rwlock); > > Holding a lock here doesn't make any sense to me... > I followed the comment kref_get_unless_zero() to protect kref_put() with write lock. But in this case it appears to be safe to not hold the lock while doing kref_put(). So I agree. Will send v1 with some more changes which includes, 1. is_free(), is_valid() to have prefix of _locked 2. simplify this lock around kref_put 3. remove inline from is_free(), is_valid() functions 4. clear_gid_entry to have lockdep assert 5. clear_gid_entry to mark free after zero out > Jason -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html