Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp324881pxb; Wed, 20 Jan 2021 07:54:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzs0OtgSc+k9+R2CCozdZ+KSXmm32A47Z2YxIyIVrw5/xhF5YjPDP41K2vizDwn8Dn+uPrk X-Received: by 2002:a05:6402:22e9:: with SMTP id dn9mr7785874edb.61.1611158047343; Wed, 20 Jan 2021 07:54:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611158047; cv=none; d=google.com; s=arc-20160816; b=ROuIc+d08te+LCw7JctOyEIKpIGqjzoSPs8WwaKnTkl1s9iNDx0Dt3EtK0XGUi/S75 M+G3Ga+4J546vxhK6usJWIlTyNNtkhU4QkiHpbw6G+/UrUJ0qWGdy4w0YIJY8sdRbA2G AmAvpAwtdPX46gn8JaKuxO4J4Roc7ef/3UcMXE3Z025TsuKTRvBJEPYnzjIq7ADpYNhx XlZsnktoysu0zMeX9fMttjYGmoT16PjTyUIFen1NIZul8j+k5xF1yv0+Twak4bl5T6Iq 7ZEWEvA6GCiQpnQ9hgNADlHdHZoSzRGTtqg/Y8s+etzCaTfFnzJ2TegdDMGMJRPdYzCK cF8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=UFVHKM49LTgg2v01YOb+UQxyjRn88+Y/656A0hUrlRA=; b=cFeluqj/qGX9Vx8OD9fJ0NjR+9ztSPD92Pe9+DjEdBJP4pL1Bec1MP4Cn1iyaRUnZM Aywc35q8568JgOfRBxWjzbMflY2qitupmBrvCK901RwxHtFAjDWQCcIb8c+8g8dnV9c4 70FVfMYFTI4jFcddXUH7F3B2NpJfZVwExKY9DhgQm+Lgh4A929jGc0nmiH16SRVwStYG M8T3+lMZvxBaJvfLze2VwbVsABWtAnPpKqRhGQ2+hz9eLNrjciqUQXlPfqNm7dr3pRRa fUWkdAvE6P7waxdi1DW6P0kw4cNvegTF9TLP9sfuOhQXfp5OVCa7vXUdBW8hWalk2XGX zxEQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q16si781805ejc.575.2021.01.20.07.53.42; Wed, 20 Jan 2021 07:54:07 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391118AbhATPve convert rfc822-to-8bit (ORCPT + 99 others); Wed, 20 Jan 2021 10:51:34 -0500 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:45324 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391006AbhATPqU (ORCPT ); Wed, 20 Jan 2021 10:46:20 -0500 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-29-eILD036iMCOERidD8eAmqg-1; Wed, 20 Jan 2021 15:44:40 +0000 X-MC-Unique: eILD036iMCOERidD8eAmqg-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 20 Jan 2021 15:44:38 +0000 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Wed, 20 Jan 2021 15:44:38 +0000 From: David Laight To: 'Mikulas Patocka' , Jan Kara CC: Dave Chinner , Zhongwei Cai , Theodore Ts'o , Matthew Wilcox , "Mingkai Dong" , Andrew Morton , Steven Whitehouse , Eric Sandeen , Dave Chinner , Wang Jianchao , Rajesh Tadakamadla , linux-kernel , linux-fsdevel , linux-nvdimm Subject: RE: Expense of read_iter Thread-Topic: Expense of read_iter Thread-Index: AQHW7z6gIbHKRyPAmU2nz0K77h3r46owpQfA Date: Wed, 20 Jan 2021 15:44:38 +0000 Message-ID: <08ea15c321bb42c2b2c941c8c741b268@AcuMS.aculab.com> References: <20210107151125.GB5270@casper.infradead.org> <17045315-CC1F-4165-B8E3-BA55DD16D46B@gmail.com> <2041983017.5681521.1610459100858.JavaMail.zimbra@sjtu.edu.cn> <1224425872.715547.1610703643424.JavaMail.zimbra@sjtu.edu.cn> <20210120044700.GA4626@dread.disaster.area> <20210120141834.GA24063@quack2.suse.cz> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mikulas Patocka > Sent: 20 January 2021 15:12 > > On Wed, 20 Jan 2021, Jan Kara wrote: > > > Yeah, I agree. I'm against ext4 private solution for this read problem. And > > I'm also against duplicating ->read_iter functionatily in ->read handler. > > The maintenance burden of this code duplication is IMHO just too big. We > > rather need to improve the generic code so that the fast path is faster. > > And every filesystem will benefit because this is not ext4 specific > > problem. > > > > Honza > > Do you have some idea how to optimize the generic code that calls > ->read_iter? > > vfs_read calls ->read if it is present. If not, it calls new_sync_read. > new_sync_read's frame size is 128 bytes - it holds the structures iovec, > kiocb and iov_iter. new_sync_read calls ->read_iter. > > I have found out that the cost of calling new_sync_read is 3.3%, Zhongwei > found out 3.9%. (the benchmark repeatedy reads the same 4k page) > > I don't see any way how to optimize new_sync_read or how to reduce its > frame size. Do you? Why is the 'read_iter' path not just the same as the 'read' one but calling copy_to_iter() instead of copy_to_user(). For a single fragment iov[] the difference might just be measurable for a single byte read. But by the time you are transferring 4k it ought to be miniscule. It isn't as though you have the cost of reading the iov[] from userspace. (That hits sendmsg() v send().) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)