All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ignat Korchagin <ignat@cloudflare.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: device-mapper development <dm-devel@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Mike Snitzer <snitzer@redhat.com>,
	Alasdair Kergon <agk@redhat.com>
Subject: Re: [dm-devel] [PATCH 4/6] dm crypt: Revisit the atomic argument passed to crypt_convert().
Date: Sat, 13 Feb 2021 14:52:30 +0000	[thread overview]
Message-ID: <CALrw=nEtYqXX_cjwYA_F40gPy8BVFMBFr8+ownbXHGPmuDLJ8A@mail.gmail.com> (raw)
In-Reply-To: <20210213111146.3080152-5-bigeasy@linutronix.de>

On Sat, Feb 13, 2021 at 11:11 AM Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
>
> The atomic argument of crypto_convert() is used to decide if
> cond_resched() may be invoked.
>
> kcryptd_crypt_write_continue() and kcryptd_crypt_read_continue() pass
> true here but both are invoked by a worker where scheduling is possible.
>
> kcryptd_crypt_write_convert() is invoked from preemptible context even
> if DM_CRYPT_NO_WRITE_WORKQUEUE is set.
>
> Set the atomic argument to false in the three cases because
> cond_resched() is not forbidden.

"atomic" parameter name might be confusing here as usually it is
related to the execution context.
But here it has additional meaning - it is also bound to the
DM_NO_*_WORKQUEUE flags. Basically,
as a user, if I set these flags - my intention is that dm-crypt should
process requests ASAP, so I don't
want it to voluntarily yield CPU even if the context is preemptible.

> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  drivers/md/dm-crypt.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
> index f5eafc32d32c5..1151a0108ae78 100644
> --- a/drivers/md/dm-crypt.c
> +++ b/drivers/md/dm-crypt.c
> @@ -2019,7 +2019,7 @@ static void kcryptd_crypt_write_continue(struct work_struct *work)
>         wait_for_completion(&ctx->restart);
>         reinit_completion(&ctx->restart);
>
> -       r = crypt_convert(cc, &io->ctx, true, false);
> +       r = crypt_convert(cc, &io->ctx, false, false);
>         if (r)
>                 io->error = r;
>         crypt_finished = atomic_dec_and_test(&ctx->cc_pending);
> @@ -2065,8 +2065,7 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
>         sector += bio_sectors(clone);
>
>         crypt_inc_pending(io);
> -       r = crypt_convert(cc, ctx,
> -                         test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags), true);
> +       r = crypt_convert(cc, ctx, false, true);
>         /*
>          * Crypto API backlogged the request, because its queue was full
>          * and we're in softirq context, so continue from a workqueue
> @@ -2110,7 +2109,7 @@ static void kcryptd_crypt_read_continue(struct work_struct *work)
>         wait_for_completion(&io->ctx.restart);
>         reinit_completion(&io->ctx.restart);
>
> -       r = crypt_convert(cc, &io->ctx, true, false);
> +       r = crypt_convert(cc, &io->ctx, false, false);
>         if (r)
>                 io->error = r;
>
> --
> 2.30.0
>

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


  reply	other threads:[~2021-02-13 14:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-13 11:11 [dm-devel] [PATCH 0/6] dm crypt: Replace the usage of in_interrupt() Sebastian Andrzej Siewior
2021-02-13 11:11 ` [dm-devel] [PATCH 1/6] dm crypt: Use tasklet_setup() Sebastian Andrzej Siewior
2021-02-13 11:11 ` [dm-devel] [PATCH 2/6] dm crypt: Handle DM_CRYPT_NO_*_WORKQUEUE more explicit Sebastian Andrzej Siewior
2021-02-13 14:31   ` Ignat Korchagin
2021-03-11 18:25     ` Mike Snitzer
2021-03-11 21:28       ` Ignat Korchagin
2021-02-13 11:11 ` [dm-devel] [PATCH 3/6] dm crypt: Add 'atomic' argument to kcryptd_crypt_read_convert() Sebastian Andrzej Siewior
2021-02-13 11:11 ` [dm-devel] [PATCH 4/6] dm crypt: Revisit the atomic argument passed to crypt_convert() Sebastian Andrzej Siewior
2021-02-13 14:52   ` Ignat Korchagin [this message]
2021-02-13 11:11 ` [dm-devel] [PATCH 5/6] dm crypt: Replace the in_interrupt() usage in crypt_convert() Sebastian Andrzej Siewior
2021-02-13 11:11 ` [dm-devel] [PATCH 6/6] dm crypt: Use `atomic' argument for memory allocation Sebastian Andrzej Siewior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALrw=nEtYqXX_cjwYA_F40gPy8BVFMBFr8+ownbXHGPmuDLJ8A@mail.gmail.com' \
    --to=ignat@cloudflare.com \
    --cc=agk@redhat.com \
    --cc=bigeasy@linutronix.de \
    --cc=dm-devel@redhat.com \
    --cc=snitzer@redhat.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.