Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3559185pxj; Tue, 1 Jun 2021 08:03:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDYKX1qJZSg5h3OvlJx71ukKq0EnfH2WPqZWL3DURG2wSPcmNJGOmzffzssMzkv11q9K6J X-Received: by 2002:aa7:d2d4:: with SMTP id k20mr32317800edr.384.1622559798863; Tue, 01 Jun 2021 08:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622559798; cv=none; d=google.com; s=arc-20160816; b=YVU5/NC+xJOls8028SjYWpuhv2dfa6wH1y+0BrVh5lkfzVTubZ/GDHEKpeqttNVX8v Dg6dPIxemSaJbzYpEING0V+LBSz4gN0Q/qOi5CMCyYmJFlZZmiWfkLrGQd8S8Yxk86o+ 19TEGrFa11qyuPbrtcFvLSGTcVHz1Gd/4VHb3Sto9khn7bksNp5vjmdtl+0fOLvAInPG bXd0IFC3y5dZl9fbzu/uo4s44LQUPkAwLd+3wbkqEAFIkqxAtewq4NUgDhtHINxUyz6U r4A68Jspi0zjRj6oxSBlnDLzGJqxwQLI3We7xLwyFBcJbTwa0S5ZFCbSURO46Yb9ITzi lPGw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8aZF279l5sMd1KIDSXbVbrhslN7qg7ZkVtQa3TiO424=; b=y1+xpQi/lcDd44qOq37t6Ta0aWSgPSRrK0IvM11TLBgVOJqHRMpCc6ZnAtphbBJogV EpE2SqxqvXy4LTkv62dSUlpcYXG/GjpB1oPyQg2gvkeKjaOEPezf/UCM4Sk9TesuRD7c xX+uizPEZjuxE2qfm/1XLbYl31jmQASVuLkkLt3rO0V+C1dtwQQVC3tcSd+v2ioZPrUD 4YjNVIsQvdsE/VnZo3m4uD+AAAERekdhFVCWMKx/w+vbedhmWcDzAGMcZ7KacQNmpShr COI/2TkJIyYlOwJdgfjU0I/l7S2gJw2hg+r3XCbgaBrRYk2W9I0rq//mbNnQRuPBBfyN rZpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AdV2MBsg; 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 r15si13464479eju.627.2021.06.01.08.02.55; Tue, 01 Jun 2021 08:03:18 -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=AdV2MBsg; 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 S234375AbhFAPAm (ORCPT + 99 others); Tue, 1 Jun 2021 11:00:42 -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-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