Received: by 10.213.65.68 with SMTP id h4csp400365imn; Tue, 27 Mar 2018 01:06:44 -0700 (PDT) X-Google-Smtp-Source: AG47ELsea7yUAuNCicRka6rBEa3S4+l1PiXIxSNLAJtUFKen9ihJKHD85peTyrfc9PbocEGC4DJD X-Received: by 10.101.101.139 with SMTP id u11mr24678473pgv.436.1522138004230; Tue, 27 Mar 2018 01:06:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522138004; cv=none; d=google.com; s=arc-20160816; b=K1YmCiY2UUkocNNNKpGWbMuLnGJP7t9xOe70kHyLj7MxCnMk8k/0rCNkJDt6lIVWCt 784AhH/DuX1vUc6U/cSnH3jjrgC3uqx86l92nnFMXvxMXeJZ7/E/yQLlVS0Yh6LCaL3q 83lBREP4ap9LvTKfR3S/vO+ZhIdYcWaeawaSE078Nmlyl7XhNLAAc5AfqN2lmJQu4jMF 4Bj3zZmmDK6pSm48xU8bBwx3MOzwxo1YOaLqB0pGJmx0mjpHvpQstUZurCaElsKWO6pn cROSvcl3rVDCbl01AEjGp6361XGZLP3m/Gj/tF1RZlq5HsHHW0T/cMRJY0D6brPCcmNw IpoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=mXtGtFBWjPmBJS19E8/6ip1dwpiMtQlR9mdGhpi75WE=; b=TQLrW1fjdEfB8PS2O2muvOBBfw9uYeQmd9/vrKRzw998xgUzzqY07J7buTt6WCtpbG 7fmFN9UiUNWZrltFLemdbhpNhQVbVsu45wU7+d8vMN+vF2C9RAdauUN/FYQ/VEdGMObV Cr7va7U6JVJrIDVE2I54OFM/Jcu/wNxtB7C+7Rf6DngnpszMK0CZf/z+Li+psrCFKw9q 9NRJQaHkeBcgdAEQkBpvfQSOiLpyq4XJX9YMIgebSlLHfbaNEy2Pq1Jg+26bJGOTaadJ XRLgSFGZighFitstnLME+SsCFNdeAUWhunId2SSnAnHLNbD4456wBKgnrRfOBHv8LEmS tqEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YuvfojCu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10si382296pgf.833.2018.03.27.01.06.29; Tue, 27 Mar 2018 01:06:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YuvfojCu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752138AbeC0IFY (ORCPT + 99 others); Tue, 27 Mar 2018 04:05:24 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:37850 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752106AbeC0IFR (ORCPT ); Tue, 27 Mar 2018 04:05:17 -0400 Received: by mail-wm0-f67.google.com with SMTP id r131so13083451wmb.2; Tue, 27 Mar 2018 01:05:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=mXtGtFBWjPmBJS19E8/6ip1dwpiMtQlR9mdGhpi75WE=; b=YuvfojCunNbgBeQotOB0877K+VEFTvJWpS0SE8wF8DOHErgavIBd83yyEsbXecLtGv SJPkj0O6d28YQY5nWN8a0GG0eqtiae/Jc+eb4X3ZbBnAUYQGcCIsrKnm55SkM3xfszHI mIxCgQNNlY1n0+gJcAbdl1dFpN3oxyKqr4GNIVUZ8a1XS6HnCiVZRPDnuMPVaxYptiFC TedZsEQ0kQIzGLle2NQcLOfUfygsgKA7FP6XUXUBQ6EBqR0ExLdMHa071yzdFlhtXFm/ PVb5Dhoi2zzPMvIkOah5ugzP4mH/zGkl7zkaRuUXku5Q9uhDJQ1QEKBdmy2ZFp8PcXgK N8Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=mXtGtFBWjPmBJS19E8/6ip1dwpiMtQlR9mdGhpi75WE=; b=JACO5TjnKLNWI3B/3Fvp0dv4N3NHoSBy4HxP71Od6SIOP79TpFAj0L64+uU6zKPHKa bgOO5Q1zD4EEcFsINecaGK/eq+M1baD6y9b8QupuvIE4/PozNDEjc9abPZIeupT6feyN wNRIbLfY/VEd2NxSzaKdr3W3/Snx807fLl5CMRriD3gsiKZKtmROobXuJtP5046pG3gi e2XLhm7TXfcvKjVd5I+oZgEZTBNPwqluICucPB+shmOTPYNH2xuurRloCfypCy9sXVtY GUok+kK0cz9NY46y8wuoLdWBHLMFv423/KH8UXEmr+kksOq1dThpWvNkNbuFJrWU6Mys BeWg== X-Gm-Message-State: AElRT7GgTUkF5CaW/PyQpb/wOKR55jmvRXrBbE/SoEMJ0NPPH7psM+SS RAj/mJl0JsE+narZWAoWgp0= X-Received: by 10.28.108.5 with SMTP id h5mr16652823wmc.35.1522137915929; Tue, 27 Mar 2018 01:05:15 -0700 (PDT) Received: from [10.43.17.143] (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id l34sm1086567wre.14.2018.03.27.01.05.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 01:05:15 -0700 (PDT) Subject: Re: [dm-devel] [PATCH 2/2] md: dm-verity: allow parallel processing of bio blocks To: Eric Biggers , Yael Chemla , Mike Snitzer Cc: Alasdair Kergon , dm-devel@redhat.com, linux-kernel@vger.kernel.org, ofir.drang@gmail.com, Yael Chemla , linux-crypto@vger.kernel.org, gilad@benyossef.com References: <1522003290-27243-1-git-send-email-yael.chemla@foss.arm.com> <1522003290-27243-2-git-send-email-yael.chemla@foss.arm.com> <20180327065519.GA745@sol.localdomain> From: Milan Broz Message-ID: <24539e45-a018-f1e9-feb0-ea7a315e8284@gmail.com> Date: Tue, 27 Mar 2018 10:05:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 In-Reply-To: <20180327065519.GA745@sol.localdomain> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mike and others, did anyone even try to run veritysetup tests? We have verity-compat-test in our testsuite, is has even basic FEC tests included. We just added userspace verification of FEC RS codes to compare if kernel behaves the same. I tried to apply three last dm-verity patches from your tree to Linus mainline. It does even pass the *first* line of the test script and blocks the kernel forever... (Running on 32bit Intel VM.) *NACK* to the last two dm-verity patches. (The "validate hashes once" is ok, despite I really do not like this approach...) And comments from Eric are very valid as well, I think all this need to be fixed before it can go to mainline. Thanks, Milan On 03/27/2018 08:55 AM, Eric Biggers wrote: > [+Cc linux-crypto] > > Hi Yael, > > On Sun, Mar 25, 2018 at 07:41:30PM +0100, Yael Chemla wrote: >> Allow parallel processing of bio blocks by moving to async. completion >> handling. This allows for better resource utilization of both HW and >> software based hash tfm and therefore better performance in many cases, >> depending on the specific tfm in use. >> >> Tested on ARM32 (zynq board) and ARM64 (Juno board). >> Time of cat command was measured on a filesystem with various file sizes. >> 12% performance improvement when HW based hash was used (ccree driver). >> SW based hash showed less than 1% improvement. >> CPU utilization when HW based hash was used presented 10% less context >> switch, 4% less cycles and 7% less instructions. No difference in >> CPU utilization noticed with SW based hash. >> >> Signed-off-by: Yael Chemla > > Okay, I definitely would like to see dm-verity better support hardware crypto > accelerators, but these patches were painful to read. > > There are lots of smaller bugs, but the high-level problem which you need to > address first is that on every bio you are always allocating all the extra > memory to hold a hash request and scatterlist for every data block. This will > not only hurt performance when the hashing is done in software (I'm skeptical > that your performance numbers are representative of that case), but it will also > fall apart under memory pressure. We are trying to get low-end Android devices > to start using dm-verity, and such devices often have only 1 GB or even only 512 > MB of RAM, so memory allocations are at increased risk of failing. In fact I'm > pretty sure you didn't do any proper stress testing of these patches, since the > first thing they do for every bio is try to allocate a physically contiguous > array that is nearly as long as the full bio data itself (n_blocks * > sizeof(struct dm_verity_req_data) = n_blocks * 3264, at least on a 64-bit > platform, mostly due to the 'struct dm_verity_fec_io'), so potentially up to > about 1 MB; that's going to fail a lot even on systems with gigabytes of RAM... > > (You also need to verify that your new code is compatible with the forward error > correction feature, with the "ignore_zero_blocks" option, and with the new > "check_at_most_once" option. From my reading of the code, all of those seemed > broken; the dm_verity_fec_io structures, for example, weren't even being > initialized...) > > I think you need to take a close look at how dm-crypt handles async crypto > implementations, since it seems to do it properly without hurting the common > case where the crypto happens synchronously. What it does, is it reserves space > in the per-bio data for a single cipher request. Then, *only* if the cipher > implementation actually processes the request asynchronously (as indicated by > -EINPROGRESS being returned) is a new cipher request allocated dynamically, > using a mempool (not kmalloc, which is prone to fail). Note that unlike your > patches it also properly handles the case where the hardware crypto queue is > full, as indicated by the cipher implementation returning -EBUSY; in that case, > dm-crypt waits to start another request until there is space in the queue. > > I think it would be possible to adapt dm-crypt's solution to dm-verity. > > Thanks, > > Eric