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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C046C001B0 for ; Wed, 16 Aug 2023 10:17:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E35FD8D002E; Wed, 16 Aug 2023 06:17:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE6748D0001; Wed, 16 Aug 2023 06:17:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD58C8D002E; Wed, 16 Aug 2023 06:17:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id BF39A8D0001 for ; Wed, 16 Aug 2023 06:17:35 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7FED7A0EC3 for ; Wed, 16 Aug 2023 10:17:35 +0000 (UTC) X-FDA: 81129566070.13.20B9CD4 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by imf27.hostedemail.com (Postfix) with ESMTP id 9001740002 for ; Wed, 16 Aug 2023 10:17:31 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692181053; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kONXLVnXL5lRRzBeUVdxTvvpDXWDRd1WIDeu7PiP19Y=; b=wB8HMvagO0HJ1QjLLSIfzPpUbZsbTg08GiZw+PMGE+FPEdS1jiJOqhxASgA7a0TVI7xeDj WHqRNarXsaQ8Cem6sIdGPZvPICJ8zQCk213xQHpMGaNVpeympDMXncNoc4ABGfTzcPSJmZ BTsDwXdmaokg3hEObt8eyLpqn6aAOmI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692181053; a=rsa-sha256; cv=none; b=orsdbdqM/+vwummTbqxkutZLCra6bvHNnaKV5uhSTssotIMtXtvVrpxesOETSQ95sS69x3 BtNZBi2lIIlXv5gsMECyFjy+SjcWXZJUYdy0OkMrQIDanJ6+qqe2lQBRMXUCLktM6uUcyg vJYYud1cWeT44K2oyp35U5IR64lCP+g= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com 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-263-B9QQiW5KPp2z-0gqw5gR7Q-1; Wed, 16 Aug 2023 11:17:27 +0100 X-MC-Unique: B9QQiW5KPp2z-0gqw5gR7Q-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; Wed, 16 Aug 2023 11:17:23 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Wed, 16 Aug 2023 11:17:23 +0100 From: David Laight To: 'David Howells' CC: Linus Torvalds , Alexander Viro , Jens Axboe , Christoph Hellwig , Christian Brauner , Matthew Wilcox , "jlayton@kernel.org" , "linux-block@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: RE: [RFC PATCH v2] iov_iter: Convert iterate*() to inline funcs Thread-Topic: [RFC PATCH v2] iov_iter: Convert iterate*() to inline funcs Thread-Index: AQHZzvgmq2lQZxPz+UuF+eoksadYZ6/rhpfwgAEYzACAABNV8A== Date: Wed, 16 Aug 2023 10:17:23 +0000 Message-ID: References: <8722207799c342e780e1162a983dc48b@AcuMS.aculab.com> <855.1692047347@warthog.procyon.org.uk> <5247.1692049208@warthog.procyon.org.uk> <440141.1692179410@warthog.procyon.org.uk> In-Reply-To: <440141.1692179410@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: quoted-printable X-Rspamd-Queue-Id: 9001740002 X-Rspam-User: X-Stat-Signature: 6a11i9mmnghgoqd5p79kzxjkj8jbz9xn X-Rspamd-Server: rspam03 X-HE-Tag: 1692181051-258363 X-HE-Meta: U2FsdGVkX1/vLb5SSJ0yTh1AciApSq9JnoyBClyjWB+VudLdKj64CgxAmr3fEr3hXFPe494D8K2YervAD52vrg6pzDDORO9C1EjHn4hmJdZLk3XgGabOOUV9Zm+WWfprDLTlPrKPGc/OoOUE3ZzZZZmto1IxBD2m9ieJcy/9FYEDLwMZy1QSzSMj0Rmu/nQwJJJggQwwCLPuKzcz5mc2B00LneBdJ8z+zw6L3V4Ue2yDvigY1temTvorD8Xbxlbs+vAN8pCRK/rvRSnWFMuFcDqgmoKhcxETRJm3gjB/GckfU2RQzLFweQPSp6PwkjbZx3ayB1ongrzNtx64WsTIGlP0JWBcqAPzIaPzf6lYCHMrjsDORrhY9j/suMMeRmdR7e+SUSpt4YlMssUMjn+afgl5C/I3Ol8os6V70PjVB3PsOVEKROvMu6Jz1QZg3hncLY8bXC1V9DYwYYDPnt1TWLfMAxeQhS0u+8VyZHLnDCHQaG2f8ws9c4YVOD9ZwZ36V92gTASlrql1xT0BA5DDJZdTaYGCg5qIrHEPyeS+n2kyRsDPkFFNzDENdsooE/yBtskka7Z2UzbZtyWUt56ZRywSLJkxvyq8PP50T0TkNXcYiT2RwulVJKqkGTxM1nKdwgTX/U2zlXXoyuBfV/QJSqqBz16uAljWV/ZXDGiG+2FhB24+xE52AyYlzmcvZX3A9up+5eMP1w5DeB/liFlRGEoH4yrli9YmYKxuSEYoENRok6AvzrYsf9r4j+jnOctMyLbjczsA0ZkAnOmftJfTvLLYyuAio2T08QziK5i0/L/2nFykMCei6uRbbKsrC6giOBhSPsr0jBbThgEZ8nonp6GvtXBdrxPqxEo4Lau3pgL++e7qW2HiSgi4/RGHAyTugjCvzfTe/Gbg6nwLg2ZqeDbyo8WvwF/Lcl4uUOuQaknkPsG5xeeoRZ6HOZhv1qH+oZNfPWpcXrVJ/yj7WW1 F2DLicvB p1hXUGUrXnoh+wOGGFePkNmrwG2+LqSbMxRBEr3aaCcY6ktxpfsqPA4TP7Wx7ykBU1oIOXL57FjQz/7NwcUVwIpWw7x8Nt1RymVNNI7wpLb8H0neSN9MwN8DrjDmkym8RMAypEPd531e3Rhguay3GnPfhrUIJSyeyynGUeKrhexiaCJ4f6Tb7ilviZgpGq78ldsQIzFi0aU6OHjgQAEqlChcu4Zgml6Dck7+Qy4c6BmNb3WAlWJd/UTY9ngilJwTsQEvWqcaBzXPTJMfQ2cATmmUx2hJmJ0ohNH+vIy8ZBSSeZ1JNk0QU1Dm6S5Xr7dxCgEKpWsnoVeTg+RnKN9/e1JAj1A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: David Howells > Sent: Wednesday, August 16, 2023 10:50 AM >=20 > David Laight wrote: >=20 > > It is harder to compare because of some of the random name changes. >=20 > I wouldn't say 'random' exactly, but if you prefer, some of the name chan= ging > can be split out into a separate patch. The macros are kind of the worst > since they picked up variable names from the callers. >=20 > > The version of the source I found seems to pass priv2 to functions > > that don't use it? >=20 > That can't be avoided if I convert everything to inline functions and fun= ction > pointers - but the optimiser can get rid of it where it can inline the st= ep > function. AFAICT the IOVEC one was only called directly. > I tried passing the iterator to the step functions instead, but that just= made > things bigger. memcpy_from_iter_mc() is interesting to deal with. I wou= ld > prefer to deal with it in the caller so we only do the check once, but th= at > might mean duplicating the caller. You could try something slightly horrid that the compiler might optimise for you. Instead of passing in a function pointer pass a number. Then do something like: #define call_iter(id, ...) \ =09(id =3D=3D x ? fn_x(__VA_ARGS__) : id =3D=3D y ? fn_y(__VA_ARGS) ...) constant folding on the inline should kill the function pointer. You might get away with putting the args on the end. ... > > I rather hope the should_fail_usercopy() and instrument_copy_xxx() > > calls are usually either absent or, at most, nops. >=20 > Okay - it's probably worth marking those too, then. Thinking I'm sure they are KASAN annotations. The are few enough calls that I suspect that replicating them won't affect KASAN (etc) builds. > > This all seems to have a lot fewer options than last time I looked. >=20 > I'm not sure what you mean by 'a lot fewer options'? It might just be ITER_PIPE that has gone. > > Is it worth optimising the KVEC case with a single buffer? >=20 > You mean an equivalent of UBUF? Maybe. There are probably a whole bunch= of > netfs places that do single-kvec writes, though I'm trying to convert the= se > over to bvec arrays, combining them with their data, and MSG_SPLICE_PAGES= . I'm thinking of what happens with kernel callers of things like the socket code - especially for address/option buffers. Probably io_uring and bpf (and my out of tree drivers!). Could be the equivalent of UBUF, but checking for KVEC with a count of 1 wouldn't really add any more cmp/jmp pairs. I've also noticed in the past that some of this code seems to be optimised for zero length buffers/fragments. Surely they just need to work? =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)