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 X-Spam-Level: X-Spam-Status: No, score=-2.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 645CFC2BA83 for ; Sun, 9 Feb 2020 17:54:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 266362081E for ; Sun, 9 Feb 2020 17:54:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f5DaPtYZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727397AbgBIRyA (ORCPT ); Sun, 9 Feb 2020 12:54:00 -0500 Received: from mail-ed1-f45.google.com ([209.85.208.45]:37187 "EHLO mail-ed1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727388AbgBIRyA (ORCPT ); Sun, 9 Feb 2020 12:54:00 -0500 Received: by mail-ed1-f45.google.com with SMTP id cy15so5983216edb.4 for ; Sun, 09 Feb 2020 09:53:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:references:from:autocrypt:subject:message-id:date:user-agent :mime-version:in-reply-to; bh=xl4dm8ZfjMprt0bSA25UxTZiV4P5FcGuUHuCYSbVL2g=; b=f5DaPtYZwdHG+B0SJRhlAHmyPX0qK7Eb2B1Ngq8FXUhCJUBoOZQxrHOlhkZOt4NcL7 hmRNqzE/qK7RRWpPezO5ANU34fGceToKqrJLSi6mLOt8GRG+f5FtL/AUYF3anvAEuagB LOUWx4Hy5AP3U6VfdmN3JhiWf7Iw3/HTFXvZYuQR6XdVdrvpb8HbYUxypzp7sgP7YP+r sCx2C+QyBGwbWWDzXDNBncA3sYLDkUv5IY1RD2XzKNvqMIbEnXHGjPI9hQpIbkiZPgcH ujlaQGWA+DAjYHqm3LcubeHD0RZKQ5mBGsLmlDyx6Cf3IzigU1xPL/VK8S10Zvi02UwK MaGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:references:from:autocrypt:subject:message-id :date:user-agent:mime-version:in-reply-to; bh=xl4dm8ZfjMprt0bSA25UxTZiV4P5FcGuUHuCYSbVL2g=; b=d5jWvAe1CNEMvhvWNjfWSS8cRWJU6GfFN8ymllAGivBGGmNswbhP4bj7upBBRqwyiK ouYazSCxasoODPotvpc301fGmpcDn2kEAovUKSZD7BBd40S7t9z511gPVgJfmtI4G4Bi MqY8K+1EobV1xhX8pxo30p3b+0cLjWvYDwFuxrzkIPtjtPUaJ/EHJPV/vH2Jq0/dWqg8 cHwQi8b1pFn9xv6ELjYnSNnoUz1RZ3wPjbptSvZBXwNu4zHSZ2W+FZY6uQb8JA0siSWV euxJOya0Hl8djV0qXdZZJyTCqzPvWAwTgANy2Q7SWAw/eXDXthcwyoVDEOKRAlwn06TC Ndrw== X-Gm-Message-State: APjAAAUCq5j8wLe+EAq++pAAZbPNsKmw5/abS2QMOkhc4pO2WwoWxJQs 6xL6BiH7gwv9MuP9/LZlV/DaDqHo X-Google-Smtp-Source: APXvYqxI4OQA1eQiA+twDhj8ySd7Eu3nhTqirfkP6yQJ7dAysphcpgl6kepbCIWRZS81LSWEWlBj1Q== X-Received: by 2002:a17:906:49c4:: with SMTP id w4mr8243324ejv.158.1581270836748; Sun, 09 Feb 2020 09:53:56 -0800 (PST) Received: from [192.168.43.63] ([109.126.145.62]) by smtp.gmail.com with ESMTPSA id cf5sm1385148ejb.60.2020.02.09.09.53.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 09 Feb 2020 09:53:56 -0800 (PST) To: Jens Axboe , io-uring References: <8ac7e520-c94e-22e1-3518-db8432debb6b@gmail.com> From: Pavel Begunkov Autocrypt: addr=asml.silence@gmail.com; prefer-encrypt=mutual; keydata= mQINBFmKBOQBEAC76ZFxLAKpDw0bKQ8CEiYJRGn8MHTUhURL02/7n1t0HkKQx2K1fCXClbps bdwSHrhOWdW61pmfMbDYbTj6ZvGRvhoLWfGkzujB2wjNcbNTXIoOzJEGISHaPf6E2IQx1ik9 6uqVkK1OMb7qRvKH0i7HYP4WJzYbEWVyLiAxUj611mC9tgd73oqZ2pLYzGTqF2j6a/obaqha +hXuWTvpDQXqcOZJXIW43atprH03G1tQs7VwR21Q1eq6Yvy2ESLdc38EqCszBfQRMmKy+cfp W3U9Mb1w0L680pXrONcnlDBCN7/sghGeMHjGKfNANjPc+0hzz3rApPxpoE7HC1uRiwC4et83 CKnncH1l7zgeBT9Oa3qEiBlaa1ZCBqrA4dY+z5fWJYjMpwI1SNp37RtF8fKXbKQg+JuUjAa9 Y6oXeyEvDHMyJYMcinl6xCqCBAXPHnHmawkMMgjr3BBRzODmMr+CPVvnYe7BFYfoajzqzq+h EyXSl3aBf0IDPTqSUrhbmjj5OEOYgRW5p+mdYtY1cXeK8copmd+fd/eTkghok5li58AojCba jRjp7zVOLOjDlpxxiKhuFmpV4yWNh5JJaTbwCRSd04sCcDNlJj+TehTr+o1QiORzc2t+N5iJ NbILft19Izdn8U39T5oWiynqa1qCLgbuFtnYx1HlUq/HvAm+kwARAQABtDFQYXZlbCBCZWd1 bmtvdiAoc2lsZW5jZSkgPGFzbWwuc2lsZW5jZUBnbWFpbC5jb20+iQJOBBMBCAA4FiEE+6Ju PTjTbx479o3OWt5b1Glr+6UFAlmKBOQCGwMFCwkIBwIGFQgJCgsCBBYC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actyNtF8jZQbhMCC8vMGukZtWaAwpjWiiH bA== Subject: Re: [RFC] fixed files Message-ID: <4b898e0a-f178-a3ab-b6a1-efb43e27db52@gmail.com> Date: Sun, 9 Feb 2020 20:53:10 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="bFO9PIXkG4sufcpyozwAoRmER3uxix6PS" Sender: io-uring-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --bFO9PIXkG4sufcpyozwAoRmER3uxix6PS Content-Type: multipart/mixed; boundary="U8vxAav3OPFFm48tidYpdEgdG5qXqK1lk"; protected-headers="v1" From: Pavel Begunkov To: Jens Axboe , io-uring Message-ID: <4b898e0a-f178-a3ab-b6a1-efb43e27db52@gmail.com> Subject: Re: [RFC] fixed files References: <8ac7e520-c94e-22e1-3518-db8432debb6b@gmail.com> In-Reply-To: --U8vxAav3OPFFm48tidYpdEgdG5qXqK1lk Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 09/02/2020 20:04, Jens Axboe wrote: > On 2/9/20 5:18 AM, Pavel Begunkov wrote: >> On 2/8/2020 11:15 PM, Jens Axboe wrote: >>> On 2/8/20 6:28 AM, Pavel Begunkov wrote: >>>> Hi, >>>> >>>> As you remember, splice(2) needs two fds, and it's a bit of a pain >>>> finding a place for the second REQ_F_FIXED_FILE flag. So, I was >>>> thinking, can we use the last (i.e. sign) bit to mark an fd as fixed= ? A >>>> lot of userspace programs consider any negative result of open() as = an >>>> error, so it's more or less safe to reuse it. >>>> >>>> e.g. >>>> fill_sqe(fd) // is not fixed >>>> fill_sqe(buf_idx | LAST_BIT) // fixed file >>> >>> Right now we only support 1024 fixed buffers anyway, so we do have so= me >>> space there. If we steal a bit, it'll still allow us to expand to 32K= of >>> fixed buffers in the future. >>> >>> It's a bit iffy, but like you, I don't immediately see a better way t= o >>> do this that doesn't include stealing an IOSQE bit or adding a specia= l >>> splice flag for it. Might still prefer the latter, to be honest... >> >> "fixed" is clearly a per-{fd,buffer} attribute. If I'd now design it >> from the scratch, I would store fixed-resource index in the same field= >> as fds and addr (but not separate @buf_index), and have per-resource >> switch-flag somewhere. And then I see 2 convenient ways: >> >> 1. encode the fixed bit into addr and fd, as supposed above. >> >> 2. Add N generic IOSQE_FIXED bits (i.e. IOSQE_FIXED_RESOURSE{1,2,...})= , >> which correspond to resources (fd, buffer, etc) in order of occurrence= >> in an sqe. I wouldn't expect having more than 3-4 flags. >> >> And then IORING_OP_{READ,WRITE}_FIXED would have been the same opcode = as >> the corresponding non-fixed version. But backward-compatibility is a p= ain. >=20 > It's always much easier looking back, hindsight is much clearer. I'd al= so > expand the sqe flags bits to 16 at least, but oh well. Totally agree. And I didn't meant I could have done better BTW, we can extend sqe flags into free bits at the end of sqe, would need= a bit of packing/unpacking though. e.g. int flags =3D sqe1_flags | (sqe2_flags << 8) > I do think that for this particular case we add a SPLICE_F_FD1_FIXED an= d > ditto for fd2, and just have the direct splice/vmsplice syscalls reject= > them as invalid. Both splice and vmsplice -EINVAL for unknown flags, > which makes this possible. Yes, I remember that from the splice thread. > That seems cleaner to me than trying to shoe-horn this information into= > the sqe itself, and it can easily be done as a prep patch to adding > splice support. >=20 --=20 Pavel Begunkov --U8vxAav3OPFFm48tidYpdEgdG5qXqK1lk-- --bFO9PIXkG4sufcpyozwAoRmER3uxix6PS Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEE+6JuPTjTbx479o3OWt5b1Glr+6UFAl5ARw0ACgkQWt5b1Glr +6ViIw//cPRxa4bXfENan13w3LM32HRsmValywsG0RZC29DveE1mtr5Kkynvd59B h/lmrhajrv1GQsi32XjQcAsYXobw2hABWZoVH4QRjPPqxcNqZGljPCFukW1gsmoX M0ZNrEgZDmrU1GiZ2Bf85toERvPL0j3jdlZGdNXBo/zcIXj3+rD6i9xmoF4eM/r2 J4qoahZN1pGOtW3jO6iJt2hHTbeFZEyvaj2qNu6vYpx834MEtUsc5czu8lA3bAxS rcSfI+mAC0MPrmgB+iQDZ/bJOuUy8aTmMhJs1ngMXC1NQhnn1DZKJe84yA5zO/fR d1gQg6YvU9qVJZ0+d6VC2cv+qRIzjd4n+n9smYpHvNVFoOzjS/Or/oyYMDlvObWF JbMQPGjEuSbMvIAW70jbo6qD+ORijpPke0sfyWNHdwbT5GZEsFwLhEGwkp8jfoQn iIGJS4zOIMgVxJ9jQS3HDC5BqX08vY0Ag/pq9kRZs1Cf7gRACpBAoBna/gbMES7G Ffwd63JzA+KY73DMiAMNL70D7sWggQ0DvpecsjrUTFSxHKH8KLiQJFMiAQwJ7X0Z nOExw8cWM55WR1V2NExOVHqcU3mwhz7Tk72ydt3PlFamOIynyiBRh6F7+AvBIklp 8CoafWhFtU6IHXTa9wM4/YRxSU92BcLOSH2jnLYO/GHcq1p+JRw= =wRtw -----END PGP SIGNATURE----- --bFO9PIXkG4sufcpyozwAoRmER3uxix6PS--