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=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 80393C433E6 for ; Fri, 8 Jan 2021 20:36:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A71F23BAB for ; Fri, 8 Jan 2021 20:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729204AbhAHUgY (ORCPT ); Fri, 8 Jan 2021 15:36:24 -0500 Received: from casper.infradead.org ([90.155.50.34]:50312 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729018AbhAHUgX (ORCPT ); Fri, 8 Jan 2021 15:36:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=0BDgIONn6TjjQMsa9yNHOZnzgJZxqty6jQ95csWbZak=; b=VqtzpDEUiHiNIlsNu1O/yx6KxX LbBd4nXTprs9jRxCfiLT8qrfTU68eKVlHiCFzq3vgfnIntYgs9WeDxbYsFpYFzp0TYe1z/UrbyqnX Z+gprP/3UA3U+ecTAdgGFDt+6i/tGrbEzWXSu3VHz+sIZHQGE8S00RLosjrGr3KyKHbJeRL8kYZ1E v53WctRMSqqioV0Vp+ylJrjmE1x19psmquRxI3q+noZne4ZljZHRSqcweQd5i3S+lPqkoH3ZN+lf+ ovW9vu3XH/DUFguJG2ZgT6hIJS8d2VvA7jxwPdBG2YtE4jjL13TWA+qgbZ/1XObAeenKM4TNPvlJx VEfhfjXQ==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1kxWwf-000A25-U4; Thu, 07 Jan 2021 15:12:09 +0000 Date: Thu, 7 Jan 2021 15:11:25 +0000 From: Matthew Wilcox To: Mikulas Patocka Cc: Andrew Morton , Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny , Jan Kara , Steven Whitehouse , Eric Sandeen , Dave Chinner , Theodore Ts'o , Wang Jianchao , "Kani, Toshi" , "Norton, Scott J" , "Tadakamadla, Rajesh" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org Subject: Expense of read_iter Message-ID: <20210107151125.GB5270@casper.infradead.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Thu, Jan 07, 2021 at 08:15:41AM -0500, Mikulas Patocka wrote: > I'd like to ask about this piece of code in __kernel_read: > if (unlikely(!file->f_op->read_iter || file->f_op->read)) > return warn_unsupported... > and __kernel_write: > if (unlikely(!file->f_op->write_iter || file->f_op->write)) > return warn_unsupported... > > - It exits with an error if both read_iter and read or write_iter and > write are present. > > I found out that on NVFS, reading a file with the read method has 10% > better performance than the read_iter method. The benchmark just reads the > same 4k page over and over again - and the cost of creating and parsing > the kiocb and iov_iter structures is just that high. Which part of it is so expensive? Is it worth, eg adding an iov_iter type that points to a single buffer instead of a single-member iov? +++ b/include/linux/uio.h @@ -19,6 +19,7 @@ struct kvec { enum iter_type { /* iter types */ + ITER_UBUF = 2, ITER_IOVEC = 4, ITER_KVEC = 8, ITER_BVEC = 16, @@ -36,6 +36,7 @@ struct iov_iter { size_t iov_offset; size_t count; union { + void __user *buf; const struct iovec *iov; const struct kvec *kvec; const struct bio_vec *bvec; and then doing all the appropriate changes to make that work.