From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E32F9C33C9E for ; Tue, 14 Jan 2020 21:32:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B290224670 for ; Tue, 14 Jan 2020 21:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579037529; bh=1BLiOHY3+U5mgGQo0sq5tDdGfHavHOxZk/eO8aynUDY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=XHDAj53QA6jnWAcK/UOJ+49nQ677P+jzzebQBYLKDiM/LPDMwQY2oOzUkq2utyjwB 2Pn5dRIuZhB9Me8+J/DAHNnBtE3wxMiEjpDVkwbEOLP5uPVaFcVOq7U+TPUC3sCxEV XyILcJNVbOnGuLxcWpJO7o8Lk1eqpeAYROwlz7sc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728894AbgANVcJ (ORCPT ); Tue, 14 Jan 2020 16:32:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:42850 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726491AbgANVcI (ORCPT ); Tue, 14 Jan 2020 16:32:08 -0500 Received: from gmail.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1F10824656; Tue, 14 Jan 2020 21:32:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579037528; bh=1BLiOHY3+U5mgGQo0sq5tDdGfHavHOxZk/eO8aynUDY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pFAbY7RhdWOk14PGf8+P83JLb5NFJ0dIyAnlJOVYqj+j9q4AXhxPdWEQ5YxFbPRux 3jJ4P2cwG2NOCfpyDCukOWJQ+2fbb0qD5N1hWCW+nD6sv8nKPhcdGIHj1Aq4Eidi00 k14FYq1As+ta64nKhGMRtDCzi9Ke8z9/5k4Ckrtk= Date: Tue, 14 Jan 2020 13:32:06 -0800 From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Victor Hsieh , linux-f2fs-devel@lists.sourceforge.net Subject: Re: [PATCH v3] fs-verity: implement readahead for FS_IOC_ENABLE_VERITY Message-ID: <20200114213206.GH41220@gmail.com> References: <20200106205410.136707-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200106205410.136707-1-ebiggers@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Jan 06, 2020 at 12:54:10PM -0800, Eric Biggers wrote: > From: Eric Biggers > > When it builds the first level of the Merkle tree, FS_IOC_ENABLE_VERITY > sequentially reads each page of the file using read_mapping_page(). > This works fine if the file's data is already in pagecache, which should > normally be the case, since this ioctl is normally used immediately > after writing out the file. > > But in any other case this implementation performs very poorly, since > only one page is read at a time. > > Fix this by implementing readahead using the functions from > mm/readahead.c. > > This improves performance in the uncached case by about 20x, as seen in > the following benchmarks done on a 250MB file (on x86_64 with SHA-NI): > > FS_IOC_ENABLE_VERITY uncached (before) 3.299s > FS_IOC_ENABLE_VERITY uncached (after) 0.160s > FS_IOC_ENABLE_VERITY cached 0.147s > sha256sum uncached 0.191s > sha256sum cached 0.145s > > Note: we could instead switch to kernel_read(). But that would mean > we'd no longer be hashing the data directly from the pagecache, which is > a nice optimization of its own. And using kernel_read() would require > allocating another temporary buffer, hashing the data and tree pages > separately, and explicitly zero-padding the last page -- so it wouldn't > really be any simpler than direct pagecache access, at least for now. > > Signed-off-by: Eric Biggers > --- > > Changed v2 => v3: > - Ensure that the pages continue being marked accessed when they're > already cached and Uptodate. > > Changed v1 => v2: > - Only do sync readahead when the page wasn't found in the pagecache > at all. > - Use ->f_mapping so that the inode doesn't have to be passed. > > fs/verity/enable.c | 45 +++++++++++++++++++++++++++++++++++++++------ > 1 file changed, 39 insertions(+), 6 deletions(-) Applied to fscrypt.git#fsverity for 5.6. - Eric