Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1014134ybt; Fri, 19 Jun 2020 21:38:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvUe1zYBx+QoRbMkKvxF8OOo8/Ykxs7tcxmxEKy7MHIMDOSiNxBImXuGEv9ymOjKzH1jtM X-Received: by 2002:a17:906:35cd:: with SMTP id p13mr888845ejb.172.1592627923752; Fri, 19 Jun 2020 21:38:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592627923; cv=none; d=google.com; s=arc-20160816; b=TK5wARuffb+LhiM3MdjDC9ymHF9RPinBM/YgWUYrP17yOWKz8hwzHnoXZyk9faj9zg JFEkVJMzdjk8sBWzLrkMFREKC+tNc18fcVCDyE8guvwTJNuk5E2AkxYF7GRKuWflBtKm 4Wwxzo0p5Z8p8ltOX7Aw2h2qZP77We7gzKyFzTtH6EdpIqyUeNI/e08E0O4JllfLY2QO eNJ2rJu5vrnPQwBzV/cgtp8l6bRxVYkyOVRYguy2AwBCqWofc5DDYxZ27qhfq3LBiyPO 0n4NMsKj1TrkpZT5A8YIQmTQF+MsQeb3UGFwodUUmJX+8r5bxyjADa4BaXHiiEV+eU8x ZbbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Qa/SGQ5p7b66E33hW6+x88Sl1GCC1UqRDbxtplLHMyo=; b=H+Q6/XoG6NkDTtUF6sLN23Z4bCrzhbDKFVOWB5sVI8rM7+QbvUoMjgnkwbmt864jDS gnVn0SZEDV79xX1qE6FyD5gS5WrJIQY7UaS/TVHo55KDwrm6W1GvIYVX0a6+w2L2jKNo Wwace2c6Nz3ZH36jwXoI/iIeS73uzhhvKVhoCbMBU5zR3snvi0TzwgN6bJjND+vec6po MUuCXzOEMgO5Oqosn3OmzSuTbHDy/bS9zNbTIoeIKHP5pbR1EQl2V5kM5yX55jkM4otw abQF52QzR8bWzC59GrcIkoyimhbYguUlCtMGQmDNsm6vRFPiTCm+krX+Fj88lhwRwAz2 rZCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=wvaHmbVc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h20si5749669edj.367.2020.06.19.21.38.21; Fri, 19 Jun 2020 21:38:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=wvaHmbVc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390186AbgFSTpO (ORCPT + 99 others); Fri, 19 Jun 2020 15:45:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389877AbgFSTpM (ORCPT ); Fri, 19 Jun 2020 15:45:12 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88C04C06174E for ; Fri, 19 Jun 2020 12:45:10 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id q2so8369232wrv.8 for ; Fri, 19 Jun 2020 12:45:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Qa/SGQ5p7b66E33hW6+x88Sl1GCC1UqRDbxtplLHMyo=; b=wvaHmbVc03z8sxgT5+NeeKq3DtEy5tOUopJ7aMUNhvLSMwsgffuoLV2dQPsd8V4kqj 8ts2lc6IPfPipbb7WWOFp4dHelewrAYPn4gKiratsUGrHGmu4dDfqDZHH1aWt7m3MY5/ eTAiR8q6MNyw901TqZbnZnp0NFFOCfE2e/+S0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Qa/SGQ5p7b66E33hW6+x88Sl1GCC1UqRDbxtplLHMyo=; b=WFpu9yW+ETyv1xB17XKrKekWduBiWTavHozU6N2yirb/9Z4iRYh5M4rcUraYwBFs66 lHU3DkxL1q+dp2duqsZzBKNYFE6qItyBzCOZxCsMKyslYq/VL53fpb+pyUUjlCdmm33T rwyluFys4DDfDHslngNKSfTqCQzPNNiqkJB/D6BrgsbIi5zrHUXfMwf9GPYDbOiRTZGt YIo3F9RqhQpU8hY+xeRqQmWWr1t3p/OPdA9gu0NmEeS2bNqZEbUF0eFpi04fVIsvIuZ/ wTRnrDQlZrnzVtLMkqQSAj3YVGgM2Cdy5Yp3q/ieFCoePFcYtvy4lUFnaKY+vCteynBB WNgA== X-Gm-Message-State: AOAM532gvCGDYzWKBPIkRMvnNGzWZMOwgoZVkNyswsPWLlqOSgik/Lkm EzU1WnC83J9I0AfurBZGPingiw0hFtluY9c8dXB4xA== X-Received: by 2002:adf:958a:: with SMTP id p10mr5367723wrp.323.1592595908766; Fri, 19 Jun 2020 12:45:08 -0700 (PDT) MIME-Version: 1.0 References: <20200619164132.1648-1-ignat@cloudflare.com> <20200619165548.GA24779@redhat.com> In-Reply-To: From: Ignat Korchagin Date: Fri, 19 Jun 2020 20:44:58 +0100 Message-ID: Subject: Re: [RFC PATCH 0/1] dm-crypt excessive overhead To: Mikulas Patocka Cc: Herbert Xu , "David S. Miller" , Mike Snitzer , agk@redhat.com, dm-devel@redhat.com, dm-crypt@saout.de, linux-kernel , kernel-team Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 19, 2020 at 7:39 PM Mikulas Patocka wrote: > > > > On Fri, 19 Jun 2020, Mike Snitzer wrote: > > > On Fri, Jun 19 2020 at 12:41pm -0400, > > Ignat Korchagin wrote: > > > > > This is a follow up from the long-forgotten [1], but with some more convincing > > > evidence. Consider the following script: > > > > > > [1]: https://www.spinics.net/lists/dm-crypt/msg07516.html > > > [2]: https://blog.cloudflare.com/speeding-up-linux-disk-encryption/ > > > > > > Ignat Korchagin (1): > > > Add DM_CRYPT_FORCE_INLINE flag to dm-crypt target > > > > > > drivers/md/dm-crypt.c | 55 +++++++++++++++++++++++++++++++++---------- > > > 1 file changed, 43 insertions(+), 12 deletions(-) > > > > > > -- > > > 2.20.1 > > > > > > > Hi, > > > > I saw [2] and have been expecting something from cloudflare ever since. > > Nice to see this submission. > > > > There is useful context in your 0th patch header. I'll likely merge > > parts of this patch header with the more terse 1/1 header (reality is > > there only needed to be a single patch submission). > > > > Will review and stage accordingly if all looks fine to me. Mikulas, > > please have a look too. > > > > Thanks, > > Mike > > + if (test_bit(DM_CRYPT_FORCE_INLINE, &cc->flags)) { > + if (in_irq()) { > + /* Crypto API will fail hard in hard IRQ context */ > + tasklet_init(&io->tasklet, kcryptd_crypt_tasklet, (unsigned long)&io->work); > + tasklet_schedule(&io->tasklet); > + } else > + kcryptd_crypt(&io->work); > + } else { > + INIT_WORK(&io->work, kcryptd_crypt); > + queue_work(cc->crypt_queue, &io->work); > + } > > I'm looking at this and I'd like to know why does the crypto API fail in > hard-irq context and why does it work in tasklet context. What's the exact > reason behind this? This comes from https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/crypto/skcipher.c?id=5e857ce6eae7ca21b2055cca4885545e29228fe2#n433 And, I believe, it is there for the same reason kcryptd was introduced in 2005 in dm-crypt: "...because it would be very unwise to do decryption in an interrupt context..." (that is, when other interrupts are disabled). In tasklet however we can still service other interrupts even if we process a large block. > > > Mikulas