2014-12-23 18:00:24

by Nicholas Mc Guire

[permalink] [raw]
Subject: [PATCH] incorrect use of init_completion fixup

The successive init_completion calls should be reinit_completion here.

patch is against 3.18.0 linux-next

Signed-off-by: Nicholas Mc Guire <[email protected]>
---
drivers/dma/ioat/dma_v3.c | 4 +-
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c
index 32eae38..3dbcc42 100644
--- a/drivers/dma/ioat/dma_v3.c
+++ b/drivers/dma/ioat/dma_v3.c
@@ -1353,7 +1353,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *device)
}

async_tx_ack(tx);
- init_completion(&cmp);
+ reinit_completion(&cmp);
tx->callback = ioat3_dma_test_callback;
tx->callback_param = &cmp;
cookie = tx->tx_submit(tx);
@@ -1405,7 +1405,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *device)
}

async_tx_ack(tx);
- init_completion(&cmp);
+ reinit_completion(&cmp);
tx->callback = ioat3_dma_test_callback;
tx->callback_param = &cmp;
cookie = tx->tx_submit(tx);
--
1.7.10.4


2014-12-24 02:14:34

by Ed Cashin

[permalink] [raw]
Subject: Re: [PATCH] incorrect use of init_completion fixup

On Tue, Dec 23, 2014 at 12:44 PM, Nicholas Mc Guire <[email protected]> wrote:
>
> The second init_completion call should be a reinit_completion here.
>
> patch is against 3.18.0 linux-next
>
> Signed-off-by: Nicholas Mc Guire <[email protected]>
> ---
> drivers/block/aoe/aoecmd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
> index 422b7d8..2239513 100644
> --- a/drivers/block/aoe/aoecmd.c
> +++ b/drivers/block/aoe/aoecmd.c
> @@ -1331,7 +1331,7 @@ aoe_ktstart(struct ktstate *k)
> return -ENOMEM;
> k->task = task;
> wait_for_completion(&k->rendez); /* allow kthread to start */
> - init_completion(&k->rendez); /* for waiting for exit later */
> + reinit_completion(&k->rendez); /* for waiting for exit later */
> return 0;
> }

That looks good to me, thanks.

--
Ed Cashin <[email protected]>

2014-12-24 19:02:06

by Prarit Bhargava

[permalink] [raw]
Subject: Re: [PATCH] incorrect use of init_completion fixup



On 12/23/2014 12:52 PM, Nicholas Mc Guire wrote:
> The successive init_completion calls should be reinit_completion here.
>

Hi Nicholas,

I know enough about this code to break it ;) ... what condition did you hit that
led you to this patch?

P.

> patch is against 3.18.0 linux-next
>
> Signed-off-by: Nicholas Mc Guire <[email protected]>
> ---
> drivers/dma/ioat/dma_v3.c | 4 +-
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c
> index 32eae38..3dbcc42 100644
> --- a/drivers/dma/ioat/dma_v3.c
> +++ b/drivers/dma/ioat/dma_v3.c
> @@ -1353,7 +1353,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *device)
> }
>
> async_tx_ack(tx);
> - init_completion(&cmp);
> + reinit_completion(&cmp);
> tx->callback = ioat3_dma_test_callback;
> tx->callback_param = &cmp;
> cookie = tx->tx_submit(tx);
> @@ -1405,7 +1405,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *device)
> }
>
> async_tx_ack(tx);
> - init_completion(&cmp);
> + reinit_completion(&cmp);
> tx->callback = ioat3_dma_test_callback;
> tx->callback_param = &cmp;
> cookie = tx->tx_submit(tx);
> --
> 1.7.10.4
>

2014-12-24 19:11:11

by Nicholas Mc Guire

[permalink] [raw]
Subject: Re: [PATCH] incorrect use of init_completion fixup

On Wed, 24 Dec 2014, Prarit Bhargava wrote:

>
>
> On 12/23/2014 12:52 PM, Nicholas Mc Guire wrote:
> > The successive init_completion calls should be reinit_completion here.
> >
>
> Hi Nicholas,
>
> I know enough about this code to break it ;) ... what condition did you hit that
> led you to this patch?
>

Was writing up documentation for completion (also posted today) and the
intended API is reinit_completion which is just resetting the counter but
not touching the related waitqueu. So the failure scenario would be
a race between accessing elements on the current wait-queue and the
init_completion reinitializing this very wait-queue.

Further if switching from init_completion -> reinit_completion brakes
anything then it really *is* broken now.

thx!
hofrat