Received: by 10.213.65.68 with SMTP id h4csp441452imn; Tue, 27 Mar 2018 02:11:38 -0700 (PDT) X-Google-Smtp-Source: AG47ELuyg01fKJe3y0bX6rx12S8yNW8vH0uqY4DHoRsE00IEHkG8in1yjub263H//mnWQDHt6qZL X-Received: by 2002:a17:902:d81:: with SMTP id 1-v6mr43180421plv.324.1522141898552; Tue, 27 Mar 2018 02:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522141898; cv=none; d=google.com; s=arc-20160816; b=VkFaSRlrMM1mXxTVs/MxucB39yB4LfjTp3NqjCv+Nu/XOYlLa/3J8rSCwbwiYkRXS3 /QNtLUe9n0P/L0iBIjdDuPRI93V6psoXS47odkwyset/ouzShHoktsjokJ06IbCrO1vp ImbmvN+B+3jigSzupHxGuNch1lyOc5jbe2N6PdiQ/5ni/Ng7CUDjtImZVL+45EsLNLjn feXYStELhBumZucTbnjt1ddPNxNfCFjDjL1mDZ0autOk+VUbRBRcDqZm9Yo1140xDgn9 oxF6KcPce+WQ1Gvue/8XrvKustiDepeAELgIgpLaey5HIoIM25Ar+3uNHWKtZyj53HJN X6gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:content-language :content-transfer-encoding:mime-version:message-id:date:subject :in-reply-to:references:cc:to:from:arc-authentication-results; bh=RjOku1zuYj5QcIkh/GYD8uEGHZFxnq5dkq7PsS2s9wc=; b=d6UWeDtVn9lbXsEb4rGdI8UCY+GHypYoLRxJPtuyDZ2PV9NurPy3WzvA+EX7eJGvDd ybirfQEJdPYzo0Q/rILaeiJLatnV9Fh5p7Wrt4Kl/lXQjVx4UIj3XwoctXVzUEqniDMY pmsNLS0T/kFM6w8lx60o53d3TneFVVt2pISa5Z2W0eqyawj12ZzmKNVGjp0oeuaEVnPq X2SuWAR+cVXsA1DPFunwLV6oBN3iruK5NdC2v1h4NPXB8anhmcfMvjk9xhKESiWFMyPX cEvkiEBDgwjS2smaP1CNgYciKXzuy8kF5vLmSCZXwpgmh6uycSh9VjAZGKtVsWBJBees kJQQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o69si631982pfi.322.2018.03.27.02.11.24; Tue, 27 Mar 2018 02:11:38 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752357AbeC0JKE convert rfc822-to-8bit (ORCPT + 99 others); Tue, 27 Mar 2018 05:10:04 -0400 Received: from foss.arm.com ([217.140.101.70]:51266 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752325AbeC0JKA (ORCPT ); Tue, 27 Mar 2018 05:10:00 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4E4251435; Tue, 27 Mar 2018 02:10:00 -0700 (PDT) Received: from E111387 (unknown [10.46.2.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7809D3F24A; Tue, 27 Mar 2018 02:09:57 -0700 (PDT) From: To: "'Milan Broz'" , "'Eric Biggers'" , "'Mike Snitzer'" Cc: "'Alasdair Kergon'" , , , , "'Yael Chemla'" , , 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> <24539e45-a018-f1e9-feb0-ea7a315e8284@gmail.com> In-Reply-To: <24539e45-a018-f1e9-feb0-ea7a315e8284@gmail.com> Subject: RE: [dm-devel] [PATCH 2/2] md: dm-verity: allow parallel processing of bio blocks Date: Tue, 27 Mar 2018 12:09:54 +0300 Message-ID: <001701d3c5ab$621e9fd0$265bdf70$@foss.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Mailer: Microsoft Outlook 16.0 Content-Language: en-il Thread-Index: AQFItUMWMAamikjrHplfXoGQQvWTaQKnGKjBApP/jaMCRtZUPqS92Ntw Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Milan, I will run veritysetup test on next version of these patches and contact you about verity-compat-test testsuits. Thank you, Yael -----Original Message----- From: Milan Broz Sent: Tuesday, 27 March 2018 11:05 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 Subject: Re: [dm-devel] [PATCH 2/2] md: dm-verity: allow parallel processing of bio blocks 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