Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp431998pxb; Wed, 25 Aug 2021 06:42:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyp/cTkR8JCHDZ+V1DChqfs8Vo4+gOfD/Im7HfHOqlnN2Q5AYjYHSkUpQL8c9VJQEbX2+ma X-Received: by 2002:a92:ca85:: with SMTP id t5mr22820738ilo.109.1629898966510; Wed, 25 Aug 2021 06:42:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629898966; cv=none; d=google.com; s=arc-20160816; b=zA5el4ydaLAr01Znaf42PifzTzEivBNQPbRIv9XullX8FCdCCVgTnmceSsOI3AsdVL BL7Ktm09pBLxZwtxDVITZMmD7OsQR0oZepaObZe0z17Q2KLu7w6uCM3uAcytHwUUzo72 BeyELOoFmZdQChclXk+wxtGIWWDTl+ODrfuv80eVjM1CodLgRQ2j2piFyyauDOod6CsV QKngFcVej9SaogVlakDEyIiaSDWaX/470oldwaejZCNjxadlVKQ4g7VdNjmCFoKTzZVB R9Vk2CqB394inPecT+qQj3+HpHmU8kNSvGbp9TMGMT4dxs6CW3GigIwyeEYpEFgdC/T9 6Mgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=IP1bVLY+A67NAQN0X5sEJAXxtYP4QJq3m3qkSSmNl3c=; b=oXgoeGdCQTD+9+AYyCeKSja7huKDcWW1PnoHdJoud6vztjwqTmoFgLvqlrZnr7BCvT 9wVvP/KzXaaaDU6/d4fs0/Hw8xToFJe6wS/g4LeBpJ5Ckq5b1ttqWM88OoDtQOLIlWgP 4xHuNTCbMgTU0y8YyXM5wPXI+SZsbhJBg2rpchXxCfzVSIsu3ux+O+vsa57Jkg206JJ0 6w2b4a7cdpdmGLKy7MCvJN4DxOXKAbm0xPighagOIstnDs1HGW/lxEE+dmid+YYhF6Gw Q1hSRZQkOZo7K/vzTjqcR9U3Giw3lTL4tztgktdqq73cF+xkDgcFgrb8nYHSiQglYISR EDmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HQ5tV7Kc; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d3si4097908jak.6.2021.08.25.06.42.31; Wed, 25 Aug 2021 06:42:46 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HQ5tV7Kc; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239768AbhHYL1N (ORCPT + 99 others); Wed, 25 Aug 2021 07:27:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236784AbhHYL1M (ORCPT ); Wed, 25 Aug 2021 07:27:12 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43C88C061757; Wed, 25 Aug 2021 04:26:26 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id c129-20020a1c35870000b02902e6b6135279so4378075wma.0; Wed, 25 Aug 2021 04:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IP1bVLY+A67NAQN0X5sEJAXxtYP4QJq3m3qkSSmNl3c=; b=HQ5tV7Kc225JC6kECs1YeP9OyyGdqZO0Bnt0MWSXhpqEtojn3T5+LLKo8a+e/RpKPT wfgjWTg8r81bOjlq3ATnttQ0xZnMYtTy/OqA7wckVD5dyQXUYGC/Qt1i7jnJJf5NkXrB xbFb/XrlOIqhmM4+R2XZmnPktF0kmWOl0hSQzsNZr+ZnG/EZo29xRACiPVFwHFlnz3JS NhgF7Y1RyGL2hX2Mq/A66l1pdUi8HqG4eYJnDiDPAFAd5oP3GR+qNhtppR4ih7b+RW6J xsedcx4MuEtKrhet1zw7pnE4J3PI/GBRpfu03eyZjkkdT/U9X1IoODCZxBYRa/bgvrIL arew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IP1bVLY+A67NAQN0X5sEJAXxtYP4QJq3m3qkSSmNl3c=; b=sdjyqZ+VYZGlVNRhkST8/hJpxqjMdAFFj//O1LgB14DMv4rBpGssWAypnRsf/Yj52U 5iqJ5GYmbwxrVE8dgVzDNSvVLA5v1O75Hwu0CdZGt73JVLoIx1zMbDzWGA0YGhCnPvKN pRZ1INIrmkCoFurHYq7zqTAfdsfI4ACKxiVuXItELG2UXjSPG58jFePdcslMD7D1EiEr dBTvGVzuA2ZHrrAc+6gqgchdtroW+m2x0KS1EChOSsLXiSKERayC4yHLgiSwWpl3meWm pimR2xTmWddjFLSFIKwTb6Cdu4OOuxVbWQlXpCLyX4sHOYAfn0XKFz/ogcjiw6qapGJI aFNw== X-Gm-Message-State: AOAM532PfLV5LGjS6dMWWoA3tWfqVz8GM4WrA38QO0N2nna1ylPJtXOk KVNwvHczdHRAQD8KEh4o16s= X-Received: by 2002:a7b:c0c7:: with SMTP id s7mr8452702wmh.66.1629890784854; Wed, 25 Aug 2021 04:26:24 -0700 (PDT) Received: from localhost.localdomain ([85.255.232.117]) by smtp.gmail.com with ESMTPSA id b12sm25113730wrx.72.2021.08.25.04.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 04:26:24 -0700 (PDT) From: Pavel Begunkov To: Jens Axboe , io-uring@vger.kernel.org, Josh Triplett Cc: "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Stefan Metzmacher Subject: [PATCH v4 0/4] open/accept directly into io_uring fixed file table Date: Wed, 25 Aug 2021 12:25:43 +0100 Message-Id: X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add an optional feature to open/accept directly into io_uring's fixed file table bypassing the normal file table. Same behaviour if as the snippet below, but in one operation: sqe = io_uring_[open|accept]_prep(); io_uring_submit(sqe); // ... once we get a CQE back io_uring_register_files_update(uring_idx, (fd = cqe->res)); close((fd = cqe->res)); The idea is old, and was brough up and implemented a year ago by Josh Triplett, though haven't sought the light. The behaviour is controlled by setting sqe->file_index, where 0 implies the old behaviour using normal file tables. If non-zero value is specified, then it will behave as described and place the file into a fixed file slot sqe->file_index - 1. A file table should be already created, the slot should be valid and empty, otherwise the operation will fail. note: IOSQE_FIXED_FILE can't be used as a mode switch, because accept takes a file, and it already uses the flag with a different meaning. v2, since RFC: - added attribution - updated descriptions - rebased v3: - EBADF if slot is already used (Josh Triplett) - alias index with splice_fd_in (Josh Triplett) - fix a bound check bug v4: - separate u32 fields to internally store indexes (Jens, Josh) Pavel Begunkov (4): net: add accept helper not installing fd io_uring: openat directly into fixed fd table io_uring: hand code io_accept() fd installing io_uring: accept directly into fixed file table fs/io_uring.c | 115 +++++++++++++++++++++++++++++----- include/linux/socket.h | 3 + include/uapi/linux/io_uring.h | 5 +- net/socket.c | 71 +++++++++++---------- 4 files changed, 143 insertions(+), 51 deletions(-) -- 2.32.0