Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1226337 > unrolled thread

[PATCH 06/17] Update the infiniband uverbs driver to use idr helper functions.

Started byLee Duncan <lduncan@suse.com>
First post2015-09-16 20:00 +0200
Last post2015-09-16 20:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 06/17] Update the infiniband uverbs driver to use idr helper functions. Lee Duncan <lduncan@suse.com> - 2015-09-16 20:00 +0200
    Re: [PATCH 06/17] Update the infiniband uverbs driver to use idr  helper functions. Doug Ledford <dledford@redhat.com> - 2015-09-16 20:50 +0200

#1226337 — [PATCH 06/17] Update the infiniband uverbs driver to use idr helper functions.

FromLee Duncan <lduncan@suse.com>
Date2015-09-16 20:00 +0200
Subject[PATCH 06/17] Update the infiniband uverbs driver to use idr helper functions.
Message-ID<q9p9W-3ca-59@gated-at.bofh.it>
Signed-off-by: Lee Duncan <lduncan@suse.com>
---
 drivers/infiniband/core/uverbs_cmd.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index bbb02ffe87df..1e5b2a66a501 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -120,24 +120,16 @@ static int idr_add_uobj(struct idr *idr, struct ib_uobject *uobj)
 {
 	int ret;
 
-	idr_preload(GFP_KERNEL);
-	spin_lock(&ib_uverbs_idr_lock);
-
-	ret = idr_alloc(idr, uobj, 0, 0, GFP_NOWAIT);
+	ret = idr_get_index(idr, &ib_uverbs_idr_lock, uobj);
 	if (ret >= 0)
 		uobj->id = ret;
 
-	spin_unlock(&ib_uverbs_idr_lock);
-	idr_preload_end();
-
 	return ret < 0 ? ret : 0;
 }
 
 void idr_remove_uobj(struct idr *idr, struct ib_uobject *uobj)
 {
-	spin_lock(&ib_uverbs_idr_lock);
-	idr_remove(idr, uobj->id);
-	spin_unlock(&ib_uverbs_idr_lock);
+	idr_put_index(idr, &ib_uverbs_idr_lock, uobj->id);
 }
 
 static struct ib_uobject *__idr_get_uobj(struct idr *idr, int id,
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1226390 — Re: [PATCH 06/17] Update the infiniband uverbs driver to use idr helper functions.

FromDoug Ledford <dledford@redhat.com>
Date2015-09-16 20:50 +0200
SubjectRe: [PATCH 06/17] Update the infiniband uverbs driver to use idr helper functions.
Message-ID<q9pWi-4mk-11@gated-at.bofh.it>
In reply to#1226337

[Multipart message — attachments visible in raw view] — view raw

On 09/16/2015 01:50 PM, Lee Duncan wrote:
> Signed-off-by: Lee Duncan <lduncan@suse.com>

Looks OK to me.  The setting of uobj->id is no longer under the lock,
but we won't succeed at an idr lookup until it is set, which means it
won't be found and can't be used in idr_remove_uobj() until after the
uobj->id is set regardless of the lock.

Acked-by: Doug Ledford <dledford@redhat.com>

> ---
>  drivers/infiniband/core/uverbs_cmd.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> index bbb02ffe87df..1e5b2a66a501 100644
> --- a/drivers/infiniband/core/uverbs_cmd.c
> +++ b/drivers/infiniband/core/uverbs_cmd.c
> @@ -120,24 +120,16 @@ static int idr_add_uobj(struct idr *idr, struct ib_uobject *uobj)
>  {
>  	int ret;
>  
> -	idr_preload(GFP_KERNEL);
> -	spin_lock(&ib_uverbs_idr_lock);
> -
> -	ret = idr_alloc(idr, uobj, 0, 0, GFP_NOWAIT);
> +	ret = idr_get_index(idr, &ib_uverbs_idr_lock, uobj);
>  	if (ret >= 0)
>  		uobj->id = ret;
>  
> -	spin_unlock(&ib_uverbs_idr_lock);
> -	idr_preload_end();
> -
>  	return ret < 0 ? ret : 0;
>  }
>  
>  void idr_remove_uobj(struct idr *idr, struct ib_uobject *uobj)
>  {
> -	spin_lock(&ib_uverbs_idr_lock);
> -	idr_remove(idr, uobj->id);
> -	spin_unlock(&ib_uverbs_idr_lock);
> +	idr_put_index(idr, &ib_uverbs_idr_lock, uobj->id);
>  }
>  
>  static struct ib_uobject *__idr_get_uobj(struct idr *idr, int id,
> 


-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD


[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web