All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Use wait_event in put_pasid_state_wait
@ 2015-02-04 15:10 Joerg Roedel
  2015-02-04 16:34   ` Peter Zijlstra
  0 siblings, 1 reply; 7+ messages in thread
From: Joerg Roedel @ 2015-02-04 15:10 UTC (permalink / raw)
  To: iommu
  Cc: Peter Zijlstra, Benjamin LaHaise, Jesse Barnes, linux-aio,
	linux-kernel, Oded Gabbay, jroedel, joro

From: Joerg Roedel <jroedel@suse.de>

Now that I learned about possible spurious wakeups this
place needs fixing too. Replace the self-coded sleep variant
with the generic wait_event() helper.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/amd_iommu_v2.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
index b6398d7..5cc1409 100644
--- a/drivers/iommu/amd_iommu_v2.c
+++ b/drivers/iommu/amd_iommu_v2.c
@@ -266,14 +266,7 @@ static void put_pasid_state(struct pasid_state *pasid_state)
 
 static void put_pasid_state_wait(struct pasid_state *pasid_state)
 {
-	DEFINE_WAIT(wait);
-
-	prepare_to_wait(&pasid_state->wq, &wait, TASK_UNINTERRUPTIBLE);
-
-	if (!atomic_dec_and_test(&pasid_state->count))
-		schedule();
-
-	finish_wait(&pasid_state->wq, &wait);
+	wait_event(pasid_state->wq, !atomic_read(&pasid_state->count));
 	free_pasid_state(pasid_state);
 }
 
-- 
1.8.4.5


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

* Re: [PATCH] iommu/amd: Use wait_event in put_pasid_state_wait
  2015-02-04 15:10 [PATCH] iommu/amd: Use wait_event in put_pasid_state_wait Joerg Roedel
@ 2015-02-04 16:34   ` Peter Zijlstra
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2015-02-04 16:34 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: iommu, Benjamin LaHaise, Jesse Barnes, linux-aio, linux-kernel,
	Oded Gabbay, jroedel

On Wed, Feb 04, 2015 at 04:10:22PM +0100, Joerg Roedel wrote:
> From: Joerg Roedel <jroedel@suse.de>
> 
> Now that I learned about possible spurious wakeups this
> place needs fixing too. Replace the self-coded sleep variant
> with the generic wait_event() helper.
> 
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
>  drivers/iommu/amd_iommu_v2.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
> index b6398d7..5cc1409 100644
> --- a/drivers/iommu/amd_iommu_v2.c
> +++ b/drivers/iommu/amd_iommu_v2.c
> @@ -266,14 +266,7 @@ static void put_pasid_state(struct pasid_state *pasid_state)
>  
>  static void put_pasid_state_wait(struct pasid_state *pasid_state)
>  {
> -	DEFINE_WAIT(wait);
> -
> -	prepare_to_wait(&pasid_state->wq, &wait, TASK_UNINTERRUPTIBLE);
> -
> -	if (!atomic_dec_and_test(&pasid_state->count))
> -		schedule();
> -
> -	finish_wait(&pasid_state->wq, &wait);
> +	wait_event(pasid_state->wq, !atomic_read(&pasid_state->count));
>  	free_pasid_state(pasid_state);
>  }

You just lost your atomic_dec.

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

* Re: [PATCH] iommu/amd: Use wait_event in put_pasid_state_wait
@ 2015-02-04 16:34   ` Peter Zijlstra
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2015-02-04 16:34 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: iommu, Benjamin LaHaise, Jesse Barnes, linux-aio, linux-kernel,
	Oded Gabbay, jroedel

On Wed, Feb 04, 2015 at 04:10:22PM +0100, Joerg Roedel wrote:
> From: Joerg Roedel <jroedel@suse.de>
> 
> Now that I learned about possible spurious wakeups this
> place needs fixing too. Replace the self-coded sleep variant
> with the generic wait_event() helper.
> 
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
>  drivers/iommu/amd_iommu_v2.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
> index b6398d7..5cc1409 100644
> --- a/drivers/iommu/amd_iommu_v2.c
> +++ b/drivers/iommu/amd_iommu_v2.c
> @@ -266,14 +266,7 @@ static void put_pasid_state(struct pasid_state *pasid_state)
>  
>  static void put_pasid_state_wait(struct pasid_state *pasid_state)
>  {
> -	DEFINE_WAIT(wait);
> -
> -	prepare_to_wait(&pasid_state->wq, &wait, TASK_UNINTERRUPTIBLE);
> -
> -	if (!atomic_dec_and_test(&pasid_state->count))
> -		schedule();
> -
> -	finish_wait(&pasid_state->wq, &wait);
> +	wait_event(pasid_state->wq, !atomic_read(&pasid_state->count));
>  	free_pasid_state(pasid_state);
>  }

You just lost your atomic_dec.

--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to majordomo@kvack.org.  For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>

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

* Re: [PATCH] iommu/amd: Use wait_event in put_pasid_state_wait
  2015-02-04 16:34   ` Peter Zijlstra
  (?)
@ 2015-02-04 16:36   ` Joerg Roedel
  -1 siblings, 0 replies; 7+ messages in thread
From: Joerg Roedel @ 2015-02-04 16:36 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: iommu, Benjamin LaHaise, Jesse Barnes, linux-aio, linux-kernel,
	Oded Gabbay, jroedel

On Wed, Feb 04, 2015 at 05:34:50PM +0100, Peter Zijlstra wrote:
> On Wed, Feb 04, 2015 at 04:10:22PM +0100, Joerg Roedel wrote:
> > From: Joerg Roedel <jroedel@suse.de>
> > 
> > Now that I learned about possible spurious wakeups this
> > place needs fixing too. Replace the self-coded sleep variant
> > with the generic wait_event() helper.
> > 
> > Signed-off-by: Joerg Roedel <jroedel@suse.de>
> > ---
> >  drivers/iommu/amd_iommu_v2.c | 9 +--------
> >  1 file changed, 1 insertion(+), 8 deletions(-)
> > 
> > diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
> > index b6398d7..5cc1409 100644
> > --- a/drivers/iommu/amd_iommu_v2.c
> > +++ b/drivers/iommu/amd_iommu_v2.c
> > @@ -266,14 +266,7 @@ static void put_pasid_state(struct pasid_state *pasid_state)
> >  
> >  static void put_pasid_state_wait(struct pasid_state *pasid_state)
> >  {
> > -	DEFINE_WAIT(wait);
> > -
> > -	prepare_to_wait(&pasid_state->wq, &wait, TASK_UNINTERRUPTIBLE);
> > -
> > -	if (!atomic_dec_and_test(&pasid_state->count))
> > -		schedule();
> > -
> > -	finish_wait(&pasid_state->wq, &wait);
> > +	wait_event(pasid_state->wq, !atomic_read(&pasid_state->count));
> >  	free_pasid_state(pasid_state);
> >  }
> 
> You just lost your atomic_dec.

Right, thanks.


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

* [PATCH v2] iommu/amd: Use wait_event in put_pasid_state_wait
  2015-02-04 16:34   ` Peter Zijlstra
  (?)
  (?)
@ 2015-02-05 11:40   ` Joerg Roedel
  2015-02-05 12:23       ` Oded Gabbay
  -1 siblings, 1 reply; 7+ messages in thread
From: Joerg Roedel @ 2015-02-05 11:40 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: iommu, Benjamin LaHaise, Jesse Barnes, linux-aio, linux-kernel,
	Oded Gabbay, jroedel

On Wed, Feb 04, 2015 at 05:34:50PM +0100, Peter Zijlstra wrote:
> You just lost your atomic_dec.

So this should be the correct version then.

>From 2a52250e542d8964c8285a37b71fe838a44c05c4 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Wed, 4 Feb 2015 15:50:38 +0100
Subject: [PATCH 1/2] iommu/amd: Use wait_event in put_pasid_state_wait

Now that I learned about possible spurious wakeups this
place needs fixing too. Replace the self-coded sleep variant
with the generic wait_event() helper.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/amd_iommu_v2.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
index b6398d7..e01bc8f 100644
--- a/drivers/iommu/amd_iommu_v2.c
+++ b/drivers/iommu/amd_iommu_v2.c
@@ -266,14 +266,13 @@ static void put_pasid_state(struct pasid_state *pasid_state)
 
 static void put_pasid_state_wait(struct pasid_state *pasid_state)
 {
-	DEFINE_WAIT(wait);
+	/* Drop our reference */
+	atomic_dec(&pasid_state->count);
 
-	prepare_to_wait(&pasid_state->wq, &wait, TASK_UNINTERRUPTIBLE);
+	/* Wait for others to drop their references */
+	wait_event(pasid_state->wq, !atomic_read(&pasid_state->count));
 
-	if (!atomic_dec_and_test(&pasid_state->count))
-		schedule();
-
-	finish_wait(&pasid_state->wq, &wait);
+	/* Get rid of it */
 	free_pasid_state(pasid_state);
 }
 
-- 
1.8.4.5


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

* Re: [PATCH v2] iommu/amd: Use wait_event in put_pasid_state_wait
  2015-02-05 11:40   ` [PATCH v2] " Joerg Roedel
@ 2015-02-05 12:23       ` Oded Gabbay
  0 siblings, 0 replies; 7+ messages in thread
From: Oded Gabbay @ 2015-02-05 12:23 UTC (permalink / raw)
  To: Joerg Roedel, Peter Zijlstra
  Cc: iommu, Benjamin LaHaise, Jesse Barnes, linux-aio, linux-kernel, jroedel



On 02/05/2015 01:40 PM, Joerg Roedel wrote:
> So this should be the correct version then.
>
>  From 2a52250e542d8964c8285a37b71fe838a44c05c4 Mon Sep 17 00:00:00 2001
> From: Joerg Roedel<jroedel@suse.de>
> Date: Wed, 4 Feb 2015 15:50:38 +0100
> Subject: [PATCH 1/2] iommu/amd: Use wait_event in put_pasid_state_wait
>
> Now that I learned about possible spurious wakeups this
> place needs fixing too. Replace the self-coded sleep variant
> with the generic wait_event() helper.
>
> Signed-off-by: Joerg Roedel<jroedel@suse.de>

Tested-by: Oded Gabbay <oded.gabbay@amd.com>

	Oded

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

* Re: [PATCH v2] iommu/amd: Use wait_event in put_pasid_state_wait
@ 2015-02-05 12:23       ` Oded Gabbay
  0 siblings, 0 replies; 7+ messages in thread
From: Oded Gabbay @ 2015-02-05 12:23 UTC (permalink / raw)
  To: Joerg Roedel, Peter Zijlstra
  Cc: iommu, Benjamin LaHaise, Jesse Barnes, linux-aio, linux-kernel, jroedel



On 02/05/2015 01:40 PM, Joerg Roedel wrote:
> So this should be the correct version then.
>
>  From 2a52250e542d8964c8285a37b71fe838a44c05c4 Mon Sep 17 00:00:00 2001
> From: Joerg Roedel<jroedel@suse.de>
> Date: Wed, 4 Feb 2015 15:50:38 +0100
> Subject: [PATCH 1/2] iommu/amd: Use wait_event in put_pasid_state_wait
>
> Now that I learned about possible spurious wakeups this
> place needs fixing too. Replace the self-coded sleep variant
> with the generic wait_event() helper.
>
> Signed-off-by: Joerg Roedel<jroedel@suse.de>

Tested-by: Oded Gabbay <oded.gabbay@amd.com>

	Oded

--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to majordomo@kvack.org.  For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>

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

end of thread, other threads:[~2015-02-05 12:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-04 15:10 [PATCH] iommu/amd: Use wait_event in put_pasid_state_wait Joerg Roedel
2015-02-04 16:34 ` Peter Zijlstra
2015-02-04 16:34   ` Peter Zijlstra
2015-02-04 16:36   ` Joerg Roedel
2015-02-05 11:40   ` [PATCH v2] " Joerg Roedel
2015-02-05 12:23     ` Oded Gabbay
2015-02-05 12:23       ` Oded Gabbay

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.