public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 50/62] vfio: convert to idr_alloc()
       [not found] <1359854463-2538-1-git-send-email-tj@kernel.org>
@ 2013-02-03  1:20 ` Tejun Heo
  2013-02-04 16:06   ` Alex Williamson
  2013-02-04 16:48   ` [PATCH v2 " Tejun Heo
  0 siblings, 2 replies; 3+ messages in thread
From: Tejun Heo @ 2013-02-03  1:20 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, rusty, bfields, skinsbursky, ebiederm, jmorris,
	axboe, Tejun Heo, Alex Williamson, kvm

Convert to the much saner new idr interface.

Only compile tested.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: kvm@vger.kernel.org
---
This patch depends on an earlier idr changes and I think it would be
best to route these together through -mm.  Please holler if there's
any objection.  Thanks.

 drivers/vfio/vfio.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 12c264d..0132846 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -139,23 +139,7 @@ EXPORT_SYMBOL_GPL(vfio_unregister_iommu_driver);
  */
 static int vfio_alloc_group_minor(struct vfio_group *group)
 {
-	int ret, minor;
-
-again:
-	if (unlikely(idr_pre_get(&vfio.group_idr, GFP_KERNEL) == 0))
-		return -ENOMEM;
-
-	/* index 0 is used by /dev/vfio/vfio */
-	ret = idr_get_new_above(&vfio.group_idr, group, 1, &minor);
-	if (ret == -EAGAIN)
-		goto again;
-	if (ret || minor > MINORMASK) {
-		if (minor > MINORMASK)
-			idr_remove(&vfio.group_idr, minor);
-		return -ENOSPC;
-	}
-
-	return minor;
+	return idr_alloc(&vfio.group_idr, group, 1, MINORMASK + 1, GFP_KERNEL);
 }
 
 static void vfio_free_group_minor(int minor)
-- 
1.8.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 50/62] vfio: convert to idr_alloc()
  2013-02-03  1:20 ` [PATCH 50/62] vfio: convert to idr_alloc() Tejun Heo
@ 2013-02-04 16:06   ` Alex Williamson
  2013-02-04 16:48   ` [PATCH v2 " Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Williamson @ 2013-02-04 16:06 UTC (permalink / raw)
  To: Tejun Heo
  Cc: akpm, linux-kernel, rusty, bfields, skinsbursky, ebiederm,
	jmorris, axboe, kvm

On Sat, 2013-02-02 at 17:20 -0800, Tejun Heo wrote:
> Convert to the much saner new idr interface.
> 
> Only compile tested.
> 
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: kvm@vger.kernel.org
> ---
> This patch depends on an earlier idr changes and I think it would be
> best to route these together through -mm.  Please holler if there's
> any objection.  Thanks.
> 
>  drivers/vfio/vfio.c | 18 +-----------------
>  1 file changed, 1 insertion(+), 17 deletions(-)
> 
> diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
> index 12c264d..0132846 100644
> --- a/drivers/vfio/vfio.c
> +++ b/drivers/vfio/vfio.c
> @@ -139,23 +139,7 @@ EXPORT_SYMBOL_GPL(vfio_unregister_iommu_driver);
>   */
>  static int vfio_alloc_group_minor(struct vfio_group *group)
>  {
> -	int ret, minor;
> -
> -again:
> -	if (unlikely(idr_pre_get(&vfio.group_idr, GFP_KERNEL) == 0))
> -		return -ENOMEM;
> -
> -	/* index 0 is used by /dev/vfio/vfio */

I'd have preferred to keep this comment.  If you do a v2, please keep
it, otherwise I'll add it back later.

Acked-by: Alex Williamson <alex.williamson@redhat.com>

> -	ret = idr_get_new_above(&vfio.group_idr, group, 1, &minor);
> -	if (ret == -EAGAIN)
> -		goto again;
> -	if (ret || minor > MINORMASK) {
> -		if (minor > MINORMASK)
> -			idr_remove(&vfio.group_idr, minor);
> -		return -ENOSPC;
> -	}
> -
> -	return minor;
> +	return idr_alloc(&vfio.group_idr, group, 1, MINORMASK + 1, GFP_KERNEL);
>  }
>  
>  static void vfio_free_group_minor(int minor)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 50/62] vfio: convert to idr_alloc()
  2013-02-03  1:20 ` [PATCH 50/62] vfio: convert to idr_alloc() Tejun Heo
  2013-02-04 16:06   ` Alex Williamson
@ 2013-02-04 16:48   ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2013-02-04 16:48 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, rusty, bfields, skinsbursky, ebiederm, jmorris,
	axboe, Alex Williamson, kvm

Convert to the much saner new idr interface.

Only compile tested.

v2: Restore accidentally dropped "index 0" comment as suggested by
    Alex.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Cc: kvm@vger.kernel.org
---
 drivers/vfio/vfio.c |   17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -139,23 +139,8 @@ EXPORT_SYMBOL_GPL(vfio_unregister_iommu_
  */
 static int vfio_alloc_group_minor(struct vfio_group *group)
 {
-	int ret, minor;
-
-again:
-	if (unlikely(idr_pre_get(&vfio.group_idr, GFP_KERNEL) == 0))
-		return -ENOMEM;
-
 	/* index 0 is used by /dev/vfio/vfio */
-	ret = idr_get_new_above(&vfio.group_idr, group, 1, &minor);
-	if (ret == -EAGAIN)
-		goto again;
-	if (ret || minor > MINORMASK) {
-		if (minor > MINORMASK)
-			idr_remove(&vfio.group_idr, minor);
-		return -ENOSPC;
-	}
-
-	return minor;
+	return idr_alloc(&vfio.group_idr, group, 1, MINORMASK + 1, GFP_KERNEL);
 }
 
 static void vfio_free_group_minor(int minor)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-02-04 16:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1359854463-2538-1-git-send-email-tj@kernel.org>
2013-02-03  1:20 ` [PATCH 50/62] vfio: convert to idr_alloc() Tejun Heo
2013-02-04 16:06   ` Alex Williamson
2013-02-04 16:48   ` [PATCH v2 " Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox