Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4293278pxu; Wed, 9 Dec 2020 13:18:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlxEqGxjo0Vp3CPKA3osbhXgZ4JvlvwHJqdwS2cRiO6u4oogiI0S624mYPirwaYfunq0sK X-Received: by 2002:a17:907:1009:: with SMTP id ox9mr3703347ejb.37.1607548720283; Wed, 09 Dec 2020 13:18:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607548720; cv=none; d=google.com; s=arc-20160816; b=nyuls8mzw7SqFfYcurUEeRURmz1MxQ4Q0S1YfgCfotrhFdd6rin8lNC6VWswFeiR2F V8exJvx0m0h3MCB8+WFc7bZh/eQjDWt39QSvFiGg89hiPEjGAGFO6HzfJMx54QXnwmiM vQ3T0H48JvbYgGSCtwq8JWvWilU7AjNeMBPT40UczGRrf+5hX9xIP87zum5JHFwsRLsa gR8IfSUwAoM4NR3Rje7rqR1WRL1IgTopgyXV0zLHtnMnqu+0aF2JXzBX2/J0xoAurlsi EYVmx1EEael4UwGotAHUC8dbPxspg1ffFNqvJdzpZWL8jkBdW0aWhLBvwjSBKCfAcXA6 rKRg== 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=DfjY5G+/DKt1YRwIBvK9K2V0MNaNm5E3THIuQMQzLRw=; b=TuaMDgAkGZZOfya27lrGt8JL6bB1NZJZoPnDqG/l3YgjQbviyjxABgC253ZbDC4/pK vhzL5FvLqYOb4owsTjZ6uo6IfoDyihs0Jk/SIkbmOfUbFceTaIZHFA7KcJbLTEBmFS/z XiAloi2XRvD/yC125FdFCJbP0rchZZrqJEZVUaub0swKMrgQEOQN6Z0dk4xkYHnhF1d1 NQE3v/BOf8jFDQWyBKACHfVZTy4Y71OBdRtsHH5FEdyPpG1ZeDKqCgeRimHpvvMaeNrP +6jv8HAczmwdxdX4ehBkURnYN7I5LGvqLH+ohxP6GkeFcaKL21P6Xr1/6ROKHkpw8dtp 15mg== 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 x14si1561962edq.88.2020.12.09.13.18.18; Wed, 09 Dec 2020 13:18:40 -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 S2388075AbgLIVPq convert rfc822-to-8bit (ORCPT + 99 others); Wed, 9 Dec 2020 16:15:46 -0500 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:59286 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388027AbgLIVPf (ORCPT ); Wed, 9 Dec 2020 16:15:35 -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-1-vL2RsGv_OTGtY0uYhYIEhw-1; Wed, 09 Dec 2020 21:13:55 +0000 X-MC-Unique: vL2RsGv_OTGtY0uYhYIEhw-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, 9 Dec 2020 21:13:54 +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, 9 Dec 2020 21:13:54 +0000 From: David Laight To: 'Pavel Begunkov' , Jens Axboe CC: Alexander Viro , "linux-fsdevel@vger.kernel.org" , "io-uring@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Matthew Wilcox Subject: RE: [PATCH 2/2] block: no-copy bvec for direct IO Thread-Topic: [PATCH 2/2] block: no-copy bvec for direct IO Thread-Index: AQHWzdK4ncolaTTBdk+ENIJV/tZKlanvQ9gw Date: Wed, 9 Dec 2020 21:13:54 +0000 Message-ID: <9e80d0f0adc84cc9995e58e2d6aad580@AcuMS.aculab.com> References: <51905c4fcb222e14a1d5cb676364c1b4f177f582.1607477897.git.asml.silence@gmail.com> In-Reply-To: <51905c4fcb222e14a1d5cb676364c1b4f177f582.1607477897.git.asml.silence@gmail.com> 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: Pavel Begunkov > Sent: 09 December 2020 02:20 > > The block layer spends quite a while in blkdev_direct_IO() to copy and > initialise bio's bvec. However, if we've already got a bvec in the input > iterator it might be reused in some cases, i.e. when new > ITER_BVEC_FLAG_FIXED flag is set. Simple tests show considerable > performance boost, and it also reduces memory footprint. ... > @@ -398,7 +422,11 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_vecs) > bio->bi_end_io = blkdev_bio_end_io; > bio->bi_ioprio = iocb->ki_ioprio; > > - ret = bio_iov_iter_get_pages(bio, iter); > + if (iov_iter_is_bvec(iter) && iov_iter_bvec_fixed(iter)) > + ret = bio_iov_fixed_bvec_get_pages(bio, iter); > + else > + ret = bio_iov_iter_get_pages(bio, iter); > + Is it necessary to check iov_iter_is_bvec() as well as iov_iter_bvec_fixed() ? If so it is probably worth using & not && so the compiler stands a chance of generating a & (B | C) == B instead of 2 conditionals. (I think I saw the bits in the same field being tested. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)