Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4570718rdb; Fri, 15 Sep 2023 06:22:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHrM8p95mGfKKnakPuoeTblfEry5wu8jJJM7gZ3qInDSC7tFsuuh5qcBh9qHBGNp5eYI5bB X-Received: by 2002:a17:903:1107:b0:1c4:3294:74ca with SMTP id n7-20020a170903110700b001c4329474camr1584916plh.17.1694784165594; Fri, 15 Sep 2023 06:22:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694784165; cv=none; d=google.com; s=arc-20160816; b=qScGJ2MdWOcrdbboKAKlLn9uo2eouQueNxigYgeeJBOOTnZy9vIyPRO/woc3wVyeWp NFXpnxZYKPYTG1HzuNnEttoOE51xYtGUJSWWu+ey8pvAIF9AJdMRjoJ5/yhUiUrODglJ HxOId7jriD8hO8NELRDckOn7AQ1Fiv24qtgOi76VaII76HidxsZ7YxT1F/zIl0dCzk2l QfHt11UxbT9FTuw0OeY4mmAe8URAuxcaWMrHQYkkwSWpADSNNfNykixlINEXPzLKtEj6 65uZe7C0JxZk7vet7e75cpOaEqa/K/LMEaXvGr4oHztLApMNMiQlHjVJeJrFLV0wo+VQ lhKw== 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=79Lrbu1QxLEM3eTbbIMNDE99VE2S27mRpJLMGXSb5j4=; fh=FevkPa+mLszS+WfpfHO5nl2iXin1D8MhqgULfFUySnM=; b=lxZX4Vv0muuiLWP/h5ESO4l9R3o9X0R0UickPWUnycEdZLFYXNBXuzz5vkp1gTOWZk VKvkQ/MwAXsdcW5CKGYDFBvEMRGFy+2gMvAcCZQqIhly0g5IJ+xvgUxgjPwdrN8H58xz pi4iAEVfhUslAL3/kiW2DmMlph/QIhy7bwDy4cONd3tA9DwvOIcMWMjGsSwItd/8CC5O 9VjYm9qJl+nf4WzY+ZDhw1b5kri750EwUSXyaV6MtCXMTuvfDzTGYVQUMzpT0F8+v3+o ypK4SPaMiuzeD/RyJ7Eo7aQCKidgFIHsZKLj/0XmaVJrEH8+DQWmv1OpdZvkl1jkv/+c pUyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id w15-20020a170902e88f00b001b87bd2f7b0si3541034plg.402.2023.09.15.06.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 06:22:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 428F3834E754; Fri, 15 Sep 2023 06:09:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235192AbjIONJP convert rfc822-to-8bit (ORCPT + 99 others); Fri, 15 Sep 2023 09:09:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235229AbjIONJO (ORCPT ); Fri, 15 Sep 2023 09:09:14 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EF36519AE for ; Fri, 15 Sep 2023 06:09:07 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-228-gfN89gbnNrWhS9R-wZDH7g-1; Fri, 15 Sep 2023 14:08:45 +0100 X-MC-Unique: gfN89gbnNrWhS9R-wZDH7g-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 15 Sep 2023 14:08:40 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Fri, 15 Sep 2023 14:08:40 +0100 From: David Laight To: 'David Howells' CC: Al Viro , Linus Torvalds , Jens Axboe , "Christoph Hellwig" , Christian Brauner , "Matthew Wilcox" , Brendan Higgins , David Gow , "linux-fsdevel@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-mm@kvack.org" , "netdev@vger.kernel.org" , "linux-kselftest@vger.kernel.org" , "kunit-dev@googlegroups.com" , "linux-kernel@vger.kernel.org" , Andrew Morton , Christian Brauner , "David Hildenbrand" , John Hubbard Subject: RE: [RFC PATCH 9/9] iov_iter: Add benchmarking kunit tests for UBUF/IOVEC Thread-Topic: [RFC PATCH 9/9] iov_iter: Add benchmarking kunit tests for UBUF/IOVEC Thread-Index: AQHZ51kQ26Nrcgq1TkqWWiI5nPv6dLAbdkPggAAj+YCAABqPYP//+bcAgAAdLuD///c+AIAAFogg Date: Fri, 15 Sep 2023 13:08:40 +0000 Message-ID: References: <72e93605b28742c2a496ce4890ecaa80@AcuMS.aculab.com> <5017b9fa177f4deaa5d481a5d8914ab4@AcuMS.aculab.com> <20230914221526.3153402-1-dhowells@redhat.com> <20230914221526.3153402-10-dhowells@redhat.com> <3370515.1694772627@warthog.procyon.org.uk> <3449352.1694776980@warthog.procyon.org.uk> <3585404.1694781366@warthog.procyon.org.uk> In-Reply-To: <3585404.1694781366@warthog.procyon.org.uk> 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 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SPF_TEMPERROR autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 15 Sep 2023 06:09:23 -0700 (PDT) From: David Howells > Sent: 15 September 2023 13:36 > > David Laight wrote: > > > I was thinking of import_iovec() - or whatever its current > > name is. > > That doesn't actually access the buffer described by the iovec[]. > > > That really needs a single structure that contains the iov_iter > > and the cache[] (which the caller pretty much always allocates > > in the same place). > > cache[]? Ah it is usually called iovstack[]. That is the code that reads the iovec[] from user. For small counts there is an on-stack cache[], for large counts it has call kmalloc(). So when the io completes you have to free the allocated buffer. A canonical example is: static ssize_t vfs_readv(struct file *file, const struct iovec __user *vec, unsigned long vlen, loff_t *pos, rwf_t flags) { struct iovec iovstack[UIO_FASTIOV]; struct iovec *iov = iovstack; struct iov_iter iter; ssize_t ret; ret = import_iovec(ITER_DEST, vec, vlen, ARRAY_SIZE(iovstack), &iov, &iter); if (ret >= 0) { ret = do_iter_read(file, &iter, pos, flags); kfree(iov); } return ret; } If 'iter' and 'iovstack' are put together in a structure the calling sequence becomes much less annoying. The kfree() can (probably) check iter.iovec != iovsatack (as an inline). But io_uring manages to allocate the iov_iter and iovstack[] in entirely different places - and then copies them about. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)