dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Milan Broz <mbroz@redhat.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: Mike Snitzer <snitzer@redhat.com>,
	Andi Kleen <ak@linux.intel.com>,
	device-mapper development <dm-devel@redhat.com>,
	pedrib@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [dm-devel] DM-CRYPT: Scale to multiple CPUs v3
Date: Mon, 11 Oct 2010 11:32:09 +0200	[thread overview]
Message-ID: <4CB2D999.9080002@redhat.com> (raw)
In-Reply-To: <20101010202031.GD21681@basil.fritz.box>

On 10/10/2010 10:20 PM, Andi Kleen wrote:
>> But previously, there were threads per device, so if one IO thread blocks,
>> others stacked mappings can continue
>> Now I see possibility for deadlock there because we have one io thread now
>> (assuming that 1 CPU situation Alasdair mentioned).
> 
> That path calls the crypto worker thread, not the IO worker thread?
> crypto worker should be fine here, only IO worker would be a problem
> I think because crypto doesn't really block on nested IO.

Well, crypt thread can block, this is surely not what we want in async callback
and IO thread cannot call generic_make_request() from this context as well...

But the reads are not problem - system queues IO, then after completion
it calls async crypt. When async crypt is done, kcrypt_crypt_read_done()
is called - and it is safe, there is just bio_endio().

The problem is write path - it allocates bio clone, run async crypto on it
and the final callback queues cloned bio to underlying device.
Because code cannot call generic_make_request() directly here (assuming
it still runs in interrupt mode), it submits new work to io thread.

So there the code behaves the same as before - just instead of queueing into
separate per-device io workqueue we have now just one common queue...
So question is, if this is safe in all stacked situations and cannot deadlock.

Imagine you have stacked one dm-crypt device, which implements uses
alg in sync mode over another one, which run in async mode.
So the common io thread runs both encryption and make_request...
If it can lock itself here, it is regression from previous version here.

(Note I am not blocking the patch - I think this can be solved later somehow,
but either we should know about this problem or prove it is safe.
In normal (sync) mode this path is not used at all - and this is the most
common situation.)

Milan

      reply	other threads:[~2010-10-11  9:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-10 11:59 [PATCH] DM-CRYPT: Scale to multiple CPUs v3 Andi Kleen
2010-10-10 12:38 ` [dm-devel] " Milan Broz
2010-10-10 12:53   ` Milan Broz
2010-10-10 13:09     ` Andi Kleen
2010-10-10 13:08   ` Andi Kleen
2010-10-10 15:34     ` Milan Broz
2010-10-10 16:06       ` Andi Kleen
2010-10-10 16:22       ` Mike Snitzer
2010-10-10 16:41         ` Milan Broz
2010-10-10 17:07           ` Mike Snitzer
2010-10-10 18:56             ` [PATCH] Fix double free and use generic private pointer in per-cpu struct Milan Broz
2010-10-14 19:26               ` [dm-devel] " Milan Broz
2010-10-20 14:20                 ` [dm-devel] [PATCH] DM-CRYPT: Scale to multiple CPUs v3 Milan Broz
2010-10-20 17:32                   ` Alasdair G Kergon
2010-10-10 17:01         ` Alasdair G Kergon
2010-10-10 17:44           ` Andi Kleen
2010-10-10 18:17             ` [dm-devel] " Alasdair G Kergon
2010-10-10 18:48               ` Alasdair G Kergon
2010-10-10 18:51               ` [dm-devel] " Andi Kleen
2010-10-10 19:07                 ` Alasdair G Kergon
2010-10-10 19:16                   ` Andi Kleen
2010-10-10 19:31                     ` Milan Broz
2010-10-10 20:20                       ` Andi Kleen
2010-10-11  9:32                         ` Milan Broz [this message]

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=4CB2D999.9080002@redhat.com \
    --to=mbroz@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=dm-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pedrib@gmail.com \
    --cc=snitzer@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).