Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp370063ybt; Wed, 24 Jun 2020 01:03:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPf91yW1zAl6wYuUN6JRtqU0/40i4yM/Jd6UHwPDH4TVBQ+kD21J/zVEoCUT2QEZwB5Hke X-Received: by 2002:aa7:d6c1:: with SMTP id x1mr24977548edr.154.1592985838361; Wed, 24 Jun 2020 01:03:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592985838; cv=none; d=google.com; s=arc-20160816; b=QdVntP4gnEXZwtRZJ+eLkXmZD3BSBR7BVE4bOkZk1Kp5Zf7BUZMOUFO4QeyN+TNdmy 4n2Dr6obClExsUWWNh9M9oWoDqbp0VpMm6fxruI3ilNcTzbzvd85/8S20NQQ3OIOKPJq t7PLOoF/Fyx4S9COv+w+lm546fg2cTTfm6ZbT2N1HB9ccEG43FFehqY4gQ+9em9/feN8 EY8e/ysZQJklhbmDj1O390L8KjB/LN2cHbLY/rA6Gy8X83lCopHz510TppMjRP0hel0o ZjT23J4dEThWC04EFD9IN9nxAddoTMRWlmnSzXxm/efEM0D4r6hs8nt/VmQayxcMl4Ql LUfA== 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=9NQUfNYeK/TI+d0cUiXO3hjD9ZuHGvPoQ56932SRZ4c=; b=lsy54BnXyKakh8WjRiaGepDqqVXQs9JudpTcvYtlVTkWpgCHOiwnts64yTP+Z0zsX0 VRt6uovQlF0abmR96bHupLinW4NGsXlifIyDFM7R4gVoMqAxcVX3RaZZiqUo9HtNjN5I NpEa/1LFncKydebCOyORAKBxMe8iOluaOo8xeApJuqTaGPq/M7cdjvBuCghvLVO5tY5U +zJU+s4G1D2eP4gEg6Rox3fV00EkQxOZ10neKtbi9kNMvYeD7oTuktfDGpKLSr+dWGnN PV86odPPkn6XawCFr71+fkskSq6o0kihMe6za2KQHDaUAZWxl9v/LJTVmc2aHJytw9z8 Pc1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=jdn7CK3z; 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 oy15si11533589ejb.538.2020.06.24.01.03.34; Wed, 24 Jun 2020 01:03:58 -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=jdn7CK3z; 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 S2390222AbgFXICx (ORCPT + 99 others); Wed, 24 Jun 2020 04:02:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387606AbgFXICw (ORCPT ); Wed, 24 Jun 2020 04:02:52 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8837AC061573 for ; Wed, 24 Jun 2020 01:02:52 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id j94so1325769wrj.0 for ; Wed, 24 Jun 2020 01:02:52 -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=9NQUfNYeK/TI+d0cUiXO3hjD9ZuHGvPoQ56932SRZ4c=; b=jdn7CK3zOy66vbV7hrftWuxB9RMgaz4zLIY+DNejBbyJCwC/A3kF8HxRfZqoIHQnqC Xm8pzcWumqbNm9wYfY+p1o49nHRRPKE1I7UwG6u09CTgzeefhvJi7wl0n15zqOx7vVz+ 1ZBedw6K5Kzn1s45v/cGXbV/LJDW3mZbNTrHo= 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=9NQUfNYeK/TI+d0cUiXO3hjD9ZuHGvPoQ56932SRZ4c=; b=hsmrXjvfgarUpT4ZXEgywYNkUcQHLStuqkziJLy/TrjUpFsxDvdvJjH/4RSc3N/0/2 auUvvhYkJiaVYpq/MKvhGrgSY+YtPZzTmkXV6gYUFomjtOmKlNRV8mje5oTtOOy+Y+y0 mKIgb3014X10sL3C6ePkh+JsCAiiJ8AMFFcK8wIDPiebetJj70Hp4uXOh7cEA8KLqiJK RpntOmDrMiXqGJfOHrXya/c3u2e0UIY5uog57IKfhxsnoSkZ6mzXffX9bx74NdZcWjZH oK7e/PWxN20Ocz8QYnjz9OYeILzAyOplqQcJeIlfOcRrleQMhuDc54Ua+Fi1zwVW/985 lPkg== X-Gm-Message-State: AOAM533exl+ueVORNQvUPSS16YZIE5tdi0O5mf6B1U15PcrvLCirxrM/ bzUGsIS8jmoU9cTpUlIGV4Lj9OmFihTbtDXDTGfLnQ== X-Received: by 2002:a5d:4992:: with SMTP id r18mr3868698wrq.323.1592985771104; Wed, 24 Jun 2020 01:02:51 -0700 (PDT) MIME-Version: 1.0 References: <20200619164132.1648-1-ignat@cloudflare.com> <20200619165548.GA24779@redhat.com> <20200623150118.GA19657@redhat.com> <20200623152235.GB19657@redhat.com> <20200624052209.GB23205@redhat.com> In-Reply-To: <20200624052209.GB23205@redhat.com> From: Ignat Korchagin Date: Wed, 24 Jun 2020 09:02:39 +0100 Message-ID: Subject: Re: [RFC PATCH 0/1] dm-crypt excessive overhead To: Mike Snitzer , Damien Le Moal Cc: "kernel-team@cloudflare.com" , "dm-crypt@saout.de" , "linux-kernel@vger.kernel.org" , "dm-devel@redhat.com" , Mikulas Patocka , "agk@redhat.com" 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 Wed, Jun 24, 2020 at 6:22 AM Mike Snitzer wrote: > > On Wed, Jun 24 2020 at 12:54am -0400, > Damien Le Moal wrote: > > > On 2020/06/24 0:23, Mike Snitzer wrote: > > > On Tue, Jun 23 2020 at 11:07am -0400, > > > Ignat Korchagin wrote: > > > > > >> Do you think it may be better to break it in two flags: one for read > > >> path and one for write? So, depending on the needs and workflow these > > >> could be enabled independently? > > > > > > If there is a need to split, then sure. But I think Damien had a hard > > > requirement that writes had to be inlined but that reads didn't _need_ > > > to be for his dm-zoned usecase. Damien may not yet have assessed the > > > performance implications, of not have reads inlined, as much as you > > > have. > > > > We did do performance testing :) > > The results are mixed and performance differences between inline vs workqueues > > depend on the workload (IO size, IO queue depth and number of drives being used > > mostly). In many cases, inlining everything does really improve performance as > > Ignat reported. > > > > In our testing, we used hard drives and so focused mostly on throughput rather > > than command latency. The added workqueue context switch overhead and crypto > > work latency compared to typical HDD IO times is small, and significant only if > > the backend storage as short IO times. > > > > In the case of HDDs, especially for large IO sizes, inlining crypto work does > > not shine as it prevents an efficient use of CPU resources. This is especially > > true with reads on a large system with many drives connected to a single HBA: > > the softirq context decryption work does not lend itself well to using other > > CPUs that did not receive the HBA IRQ signaling command completions. The test > > results clearly show much higher throughputs using dm-crypt as is. > > > > On the other hand, inlining crypto work significantly improves workloads of > > small random IOs, even for a large number of disks: removing the overhead of > > context switches allows faster completions, allowing sending more requests to > > the drives more quickly, keeping them busy. > > > > For SMR, the inlining of write requests is *mandatory* to preserve the issuer > > write sequence, but encryption work being done in the issuer context (writes to > > SMR drives can only be O_DIRECT writes), efficient CPU resource usage can be > > achieved by simply using multiple writer thread/processes, working on different > > zones of different disks. This is a very reasonable model for SMR as writes into > > a single zone have to be done under mutual exclusion to ensure sequentiality. > > > > For reads, SMR drives are essentially exactly the same as regular disks, so > > as-is or inline are both OK. Based on our performance results, allowing the user > > to have the choice of inlining or not reads based on the target workload would > > be great. > > > > Of note is that zone append writes (emulated in SCSI, native with NVMe) are not > > subject to the sequential write constraint, so they can also be executed either > > inline or asynchronously. > > > > > So let's see how Damien's work goes and if he trully doesn't need/want > > > reads to be inlined then 2 flags can be created. > > > > For SMR, I do not need inline reads, but I do want the user to have the > > possibility of using this setup as that can provide better performance for some > > workloads. I think that splitting the inline flag in 2 is exactly what we want: > > > > 1) For SMR, the write-inline flag can be automatically turned on when the target > > device is created if the backend device used is a host-managed zoned drive (scsi > > or NVMe ZNS). For reads, it would be the user choice, based on the target workload. > > 2) For regular block devices, write-inline only, read-inline only or both would > > be the user choice, to optimize for their target workload. > > > > With the split into 2 flags, my SMR support patch becomes very simple. > > OK, thanks for all the context. Was a fun read ;) > > SO let's run with splitting into 2 flags. Ignat would you be up to > tweaking your patch to provide that and post a v2? > > An added bonus would be to consolidate your 0/1 and 1/1 patch headers, > and add in the additional answers you provided in this thread to help > others understand the patch (mainly some more detail about why tasklet > is used). Yes, will do > Thanks, > Mike >