Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp946296pxb; Fri, 13 Aug 2021 09:45:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUtt3Ljskts1BjJR4JXehHdJeQTYMmMfiTeumzByHdeYDMcu7I9xRCf9N49prgAHgAfQtJ X-Received: by 2002:a17:907:1c01:: with SMTP id nc1mr3306698ejc.504.1628873136143; Fri, 13 Aug 2021 09:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628873136; cv=none; d=google.com; s=arc-20160816; b=GrULnPaSctApPCzbHnFzbkdrJmjFRAEwUSp3LADHceYMFGvw9PwUENObpfyQ61dGcn 7DZFZL+XwQes/ULnuNu03C7nu4biVI5vlnR2+LtqedbcoAuujCrRcwp8mRzQ8awX7IiR k08t9BggPfven7VUHr2AxBEQ6nhxihRnG41FEAQ2bZBwAnF6Z1ktS3eTjeMM8bbFOPbn BuvRGwQppzecry3iq3lYySiODg98k6E9R+KbKU+IAUbKD5YhLBVzOqdLsodJtiXBO6vN 9BBHOfmF6Gf42sex/mshwfrxlYBbhh/UV59nQE9iq4GQeLOWpv8Qps27FMweD/UqZvkl k8oA== 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=tTtxt0HccECn9JoP7tPP5lmd6vJWaG+/hAvUwgP25po=; b=X+OweOnpBWbHoogFl7cwJ4IK5UTUGzWW893z2uszKGNptWBW9k7e4NPW4do2L08wv+ FzV1GQD1rtur0ph+w9YKC8zNFzMvWi+yOX+h2xyDPpUMpsdzuMbe/YUz+4AzUFXKqq2q Nx6jN3qyQAbLLSlvcVqbGxSwKtDfGeUj/VJ/VwE0gDdY+oqzTA4g7V1bYWHekCvquT4B A48qioJgy1Fym+G6BkfZoHCrN8nWgDJSr42cER7cQlhYWZQtY/LkusktNMfgi8hCkEyh 2DVaM9ZkvFR0egH2ULR+23RVt67lXdKE06JZqbSy/1FSPDxpQWAYITSyitqze4nG2pqr lRLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TbSOfuEX; 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 v12si2082581eds.540.2021.08.13.09.45.11; Fri, 13 Aug 2021 09:45:36 -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=TbSOfuEX; 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 S236320AbhHMQoT (ORCPT + 99 others); Fri, 13 Aug 2021 12:44:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236205AbhHMQoS (ORCPT ); Fri, 13 Aug 2021 12:44:18 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 388A9C0617AD; Fri, 13 Aug 2021 09:43:51 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id x10so7802819wrt.8; Fri, 13 Aug 2021 09:43:51 -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=tTtxt0HccECn9JoP7tPP5lmd6vJWaG+/hAvUwgP25po=; b=TbSOfuEXfhis1AmXSoz50XxA+hf3EYvt9WVVOwZWaRE8Gf3MMP+GPGIL1yo8fs3Xfj 2j/E3eMiAd+DXmgLCYE89ISuA00lvBy6GN9v3tKvZoXR7t6gbw9btZeRGsKvqrIjBbWl 9O1XUY7uFIb5oah61Gunjr6BJ2/CF9s/OWVswEBi29LEZhZlRl4GHeLw3giiT40Th9sF GrfoQ6q3DbbKFQy6VjeD3BWjdxwYNxmoHCwSCEuQAYGwnaA3lzxYdUr+oEPqMNAyDR++ 2hojKoRM4xNSxj8VPWXr25kbn2dXmBIXQVXb3xdUEF6Av/4jjZh5eUANe1lw1/540JnY fikQ== 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=tTtxt0HccECn9JoP7tPP5lmd6vJWaG+/hAvUwgP25po=; b=RlDLaHVK4j+cQ0FoVn9D549AR9b/ywA6ff/PG9TGWfN+jZW4fkf4ZoVtvMW0M74uxD mhYuV8BywfHi2kFayQYEb4ew0vrzIEQWgaiTEWKGf+jMAPz1iCiTd0tChT+PE69dg1tV 6pULr1IUA9OtQu8m0u0XqUd9GWQMtHAjsxJQrBhH/jfod74eBTo0K40IO/MEkrOA8YXb dOPBrOt6Xr/UPsmjwGgSmuYC3PqxrnucofpUSthn3DJUNG2Oh+gjq3hh++8jvIVcd45A R/jQSDca2EYkVs7QH8wZK0kPr/eKbEa51G5pYZ6FLKtyOOw40CAU7xVkOSE+PSuPSvyD gQZw== X-Gm-Message-State: AOAM530seqOP0GhKNQYsVzYYt2gwwIbiUkLRKWgUVaqlASHMdVPmQmZu QcdYf+v8YMe21NYXg1GQV6I= X-Received: by 2002:a5d:4808:: with SMTP id l8mr4215129wrq.349.1628873029830; Fri, 13 Aug 2021 09:43:49 -0700 (PDT) Received: from localhost.localdomain ([148.252.132.210]) by smtp.gmail.com with ESMTPSA id s10sm2495829wrv.54.2021.08.13.09.43.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 09:43:49 -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 v2 0/4] open/accept directly into io_uring fixed file table Date: Fri, 13 Aug 2021 17:43:09 +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 = prep_[open,accept](...); cqe = submit_and_wait(sqe); // error handling io_uring_register_files_update(uring_idx, (fd = cqe->res)); // optionally close((fd = cqe->res)); The idea in pretty old, and was brough up and implemented a year ago by Josh Triplett, though haven't sought the light for some reasons. Tested on basic cases, will be sent out as liburing patches later. A copy paste from 2/2 describing user API and some notes: The behaviour is controlled by setting sqe->file_index, where 0 implies the old behaviour. 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 1: we can't use IOSQE_FIXED_FILE to switch between modes, because accept takes a file, and it already uses the flag with a different meaning. Note 2: it's u16, where in theory the limit for fixed file tables might get increased in the future. If would ever happen so, we'll better workaround later, e.g. by making ioprio to represent upper bits 16 bits. The layout for open is tight already enough. since RFC: - added attribution - updated descriptions - rebased 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 | 114 +++++++++++++++++++++++++++++----- include/linux/socket.h | 3 + include/uapi/linux/io_uring.h | 2 + net/socket.c | 71 +++++++++++---------- 4 files changed, 139 insertions(+), 51 deletions(-) -- 2.32.0