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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 E5201C4708F for ; Tue, 1 Jun 2021 14:59:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C872C61263 for ; Tue, 1 Jun 2021 14:59:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234427AbhFAPAo (ORCPT ); Tue, 1 Jun 2021 11:00:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234384AbhFAPAg (ORCPT ); Tue, 1 Jun 2021 11:00:36 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19ADCC061574; Tue, 1 Jun 2021 07:58:54 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id l2so7209597wrw.6; Tue, 01 Jun 2021 07:58:54 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=8aZF279l5sMd1KIDSXbVbrhslN7qg7ZkVtQa3TiO424=; b=AdV2MBsgEc6or7WEa1Z3y/nBsF12MeU5capy2vAd/HcPavf1yLV/bEGPfoJ1r1XPEL Yu/LFXaewmJLrL406Jq1sGfovROJuQDAcgzTpAUPcnkoOqVwn40Zzw9kHibp+RH4H9sg EMsv19I5dVLT3wNXMkoAjVJCKnAN4yqtsGGMoTKHsyJhGX3A/WZu42SRS9vHKW3AMvlS /D7yhIvyzdIpu++CzVWWwbqfbCyLlHinUfIXsxztsUdqF3idGlzBGZMGgIrpW0P/a7b/ zRKLE/LOHc5awDVcZCYNoRs7IvYxQAF86zO9p5z/rDXzZtTJ4eq8C9fWTbCWXNjU/n5s zMNg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=8aZF279l5sMd1KIDSXbVbrhslN7qg7ZkVtQa3TiO424=; b=S45xDwvJ0eg4mQE0ceb82ZHqagKyt7SPvUp4NRPDAP9Q6lGogQl9A86peAjQoHG31Y gv3PZsN3N+q6KvIU8klFHcq13GO8l1Pd5dHLOIpjUTaen7yJqNlp2RQ5AAmpN0Y2CWHF L4RrScNPmFyvHpqcI//X9va+eXW8Z+91rk9ZDQAWqJpbpV31To/GbNgXjhWWDszszPEp vCiPRAF/S6LtsRtoWrwlE8YnEzD1kpBvmAboxoWuBMc1rU1ommMl5ArIAZWDCDECxQ4/ xmtzKGMiAzcIY6vU5gsbbFhIWvG5elzQvFAGfXtGcx3EQrl+JuaDT/vb9NxQgxP8I1xp +UIw== X-Gm-Message-State: AOAM530WDLaOOuDfWE7BKy5gUHZvbkaDT8ihyI6Zmr58nwARVV8KzGLg 5U3EqgR/CZfAT8fVZT+XJXXbjkNcAoS6yg== X-Google-Smtp-Source: ABdhPJxw6PPQwjzRnOnDqsKwOeIQ+0YJMihfTUoCxCA6WhwGViMcNyHDmxrzX6DVHecDZIyrnjONsA== X-Received: by 2002:adf:f98f:: with SMTP id f15mr28901735wrr.4.1622559532358; Tue, 01 Jun 2021 07:58:52 -0700 (PDT) Received: from localhost.localdomain ([85.255.237.139]) by smtp.gmail.com with ESMTPSA id b4sm10697061wmj.42.2021.06.01.07.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 07:58:51 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , Andres Freund , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , Davidlohr Bueso , linux-kernel@vger.kernel.org Subject: [RFC 2/4] io_uring: frame out futex op Date: Tue, 1 Jun 2021 15:58:27 +0100 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add userspace futex request definitions and draft some internal functions. Signed-off-by: Pavel Begunkov --- fs/io_uring.c | 23 +++++++++++++++++++++++ include/uapi/linux/io_uring.h | 9 +++++++++ 2 files changed, 32 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index fc9325472e8d..2c6b14a3a4f6 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -77,6 +77,7 @@ #include #include #include +#include #include #define CREATE_TRACE_POINTS @@ -665,6 +666,10 @@ struct io_unlink { struct filename *filename; }; +struct io_futex { + struct file *file; +}; + struct io_completion { struct file *file; struct list_head list; @@ -809,6 +814,7 @@ struct io_kiocb { struct io_shutdown shutdown; struct io_rename rename; struct io_unlink unlink; + struct io_futex futex; /* use only after cleaning per-op data, see io_clean_op() */ struct io_completion compl; }; @@ -1021,6 +1027,7 @@ static const struct io_op_def io_op_defs[] = { }, [IORING_OP_RENAMEAT] = {}, [IORING_OP_UNLINKAT] = {}, + [IORING_OP_FUTEX] = {}, }; static bool io_disarm_next(struct io_kiocb *req); @@ -5865,6 +5872,16 @@ static int io_files_update(struct io_kiocb *req, unsigned int issue_flags) return 0; } +static int io_futex_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) +{ + return -EINVAL; +} + +static int io_futex(struct io_kiocb *req, unsigned int issue_flags) +{ + return -EINVAL; +} + static int io_req_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) { switch (req->opcode) { @@ -5936,6 +5953,8 @@ static int io_req_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) return io_renameat_prep(req, sqe); case IORING_OP_UNLINKAT: return io_unlinkat_prep(req, sqe); + case IORING_OP_FUTEX: + return io_futex_prep(req, sqe); } printk_once(KERN_WARNING "io_uring: unhandled opcode %d\n", @@ -6203,6 +6222,9 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags) case IORING_OP_UNLINKAT: ret = io_unlinkat(req, issue_flags); break; + case IORING_OP_FUTEX: + ret = io_futex(req, issue_flags); + break; default: ret = -EINVAL; break; @@ -10158,6 +10180,7 @@ static int __init io_uring_init(void) BUILD_BUG_SQE_ELEM(28, __u32, statx_flags); BUILD_BUG_SQE_ELEM(28, __u32, fadvise_advice); BUILD_BUG_SQE_ELEM(28, __u32, splice_flags); + BUILD_BUG_SQE_ELEM(28, __u32, futex_flags); BUILD_BUG_SQE_ELEM(32, __u64, user_data); BUILD_BUG_SQE_ELEM(40, __u16, buf_index); BUILD_BUG_SQE_ELEM(42, __u16, personality); diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index e1ae46683301..6a1af5bb2ddf 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -44,6 +44,7 @@ struct io_uring_sqe { __u32 splice_flags; __u32 rename_flags; __u32 unlink_flags; + __u32 futex_flags; }; __u64 user_data; /* data to be passed back at completion time */ union { @@ -137,6 +138,7 @@ enum { IORING_OP_SHUTDOWN, IORING_OP_RENAMEAT, IORING_OP_UNLINKAT, + IORING_OP_FUTEX, /* this goes last, obviously */ IORING_OP_LAST, @@ -174,6 +176,13 @@ enum { #define IORING_POLL_UPDATE_EVENTS (1U << 1) #define IORING_POLL_UPDATE_USER_DATA (1U << 2) +enum { + IORING_FUTEX_WAKE_OP = 0, + + IORING_FUTEX_LAST, +}; + + /* * IO completion data structure (Completion Queue Entry) */ -- 2.31.1