Re: [PATCH rdma-rc 12/15] IB/uverbs: Tidy lockdep_check

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

 



On Tue, Feb 13, 2018 at 12:10:35PM -0500, Dennis Dalessandro wrote:
> On 2/13/2018 5:18 AM, Leon Romanovsky wrote:
> >From: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
> >
> >This is really being used as an asssert that the expected usecnt
> >is being held and implicitly that the usecnt is valid. Rename it to
> >assert_uverbs_usecnt and tighten the checks to only accept valid
> >values of usecnt (eg 0 and < -1 are invalid).
> >
> >Fixes: 3832125624b7 ("IB/core: Add support for idr types")
> >Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
> >Signed-off-by: Leon Romanovsky <leon@xxxxxxxxxx>
> >  drivers/infiniband/core/rdma_core.c | 14 +++++++-------
> >  1 file changed, 7 insertions(+), 7 deletions(-)
> >
> >diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c
> >index 3ec5c7926f1c..7aee1c0b9884 100644
> >+++ b/drivers/infiniband/core/rdma_core.c
> >@@ -412,13 +412,13 @@ static int __must_check remove_commit_fd_uobject(struct ib_uobject *uobj,
> >  	return ret;
> >  }
> >-static void lockdep_check(struct ib_uobject *uobj, bool exclusive)
> >+static void assert_uverbs_usecnt(struct ib_uobject *uobj, bool exclusive)
> >  {
> >  #ifdef CONFIG_LOCKDEP
> >  	if (exclusive)
> >-		WARN_ON(atomic_read(&uobj->usecnt) > 0);
> >+		WARN_ON(atomic_read(&uobj->usecnt) != -1);
> >  	else
> >-		WARN_ON(atomic_read(&uobj->usecnt) == -1);
> >+		WARN_ON(atomic_read(&uobj->usecnt) <= 0);
> >  #endif
> >  }
> >@@ -457,7 +457,7 @@ int __must_check rdma_remove_commit_uobject(struct ib_uobject *uobj)
> >  		WARN(true, "ib_uverbs: Cleanup is running while removing an uobject\n");
> >  		return 0;
> >  	}
> >-	lockdep_check(uobj, true);
> >+	assert_uverbs_usecnt(uobj, true);
> >  	ret = _rdma_remove_commit_uobject(uobj, RDMA_REMOVE_DESTROY);
> >  	up_read(&ucontext->cleanup_rwsem);
> >@@ -487,7 +487,7 @@ int rdma_explicit_destroy(struct ib_uobject *uobject)
> >  		WARN(true, "ib_uverbs: Cleanup is running while removing an uobject\n");
> >  		return 0;
> >  	}
> >-	lockdep_check(uobject, true);
> >+	assert_uverbs_usecnt(uobject, true);
> >  	ret = uobject->type->type_class->remove_commit(uobject,
> >  						       RDMA_REMOVE_DESTROY);
> >  	if (ret)
> >@@ -541,7 +541,7 @@ int rdma_alloc_commit_uobject(struct ib_uobject *uobj)
> >  	}
> >  	/* matches atomic_set(-1) in alloc_uobj */
> >-	lockdep_check(uobj, true);
> >+	assert_uverbs_usecnt(uobj, true);
> >  	atomic_set(&uobj->usecnt, 0);
> >  	uobj->type->type_class->alloc_commit(uobj);
> >@@ -578,7 +578,7 @@ static void lookup_put_fd_uobject(struct ib_uobject *uobj, bool exclusive)
> >  void rdma_lookup_put_uobject(struct ib_uobject *uobj, bool exclusive)
> >  {
> >-	lockdep_check(uobj, exclusive);
> >+	assert_uverbs_usecnt(uobj, exclusive);
> >  	uobj->type->type_class->lookup_put(uobj, exclusive);
> >  	/*
> >  	 * In order to unlock an object, either decrease its usecnt for
> >
> 
> -rc material?

This one is a bit border line - but as coded the asserts were not
working right, eg:

 -		WARN_ON(atomic_read(&uobj->usecnt) > 0);
 +		WARN_ON(atomic_read(&uobj->usecnt) != -1);

Didn't trigger if usecnt == 0, which is wrong.

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



[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