Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp589359pxb; Fri, 8 Jan 2021 12:38:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9C3bxByrynQyUyvIyEtuglb9lah90/xQO6muwvLk3kfXBgLMhrrAusc8KkfYQX9mEE/3k X-Received: by 2002:a17:906:e58:: with SMTP id q24mr3752020eji.438.1610138339191; Fri, 08 Jan 2021 12:38:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610138339; cv=none; d=google.com; s=arc-20160816; b=VWMTux+KAOh8zBxb+oPnGef9pMmyqI0Wx/lrEKnhqOe8o9zOh/L9j2NkhnlJh9hOdJ tRJ8jfBqQabLaRLwz6qonCBQ9f9a4tYAbVc+6HEiHwbJNfc6aW5OnoX7kNdIdpdiQAp/ HfHxMew/dkTu4KtzKZGGdvJwp0nJVhwuPGKKo+bCsfpJ3SSVYgGeXMl7vV4I1zRkX/M7 N5/Hg1EJ6LbXUmRLn4qCXR5Kfulwo6ynIHU6ddXJmdt5INp1df6TTRy3+Gfx4ymi85Li OsQ6rcFCFl8RWMFNLZyPitqUY9O/QXmEnnmvODrOluu+ixf281Lv1RJTdPbwtIB9uSpM mJoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0BDgIONn6TjjQMsa9yNHOZnzgJZxqty6jQ95csWbZak=; b=rLbCrTWbpvGo9A/aeg19+EDDSPusQlIbnHhTyRo+dC2uz3HR5vdDoue2CGGZVoRKDr xicc/ipJ+2UPD1e6WHCgTweBBL+XThpXAnbJ+wneJmdKWOB2TAyUhaBYaKB/KQwb7A+W LzIwUM943J0c5C6TxwISxElEgpZcza0GC60h7qjFppzqjl9ZazE7PzqgbduJ8Zb3eAwN 9Oo99A1nKBcEQ8Ltv5zGZSt0xgujPGv+XoLDPV5XyTHqMtndyviSrkSFBO/+rHMOyH6p +sKLtW2dQ0lgDUMB3r76gJ1aBfXGwodiiQu3IyMkKk8c7uU/q1Gj35UKZcUNptb8Z1pu qYpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=VqtzpDEU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mm28si3831199ejb.138.2021.01.08.12.38.35; Fri, 08 Jan 2021 12:38:59 -0800 (PST) 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=@infradead.org header.s=casper.20170209 header.b=VqtzpDEU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729282AbhAHUgY (ORCPT + 99 others); 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-kernel@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.