From patchwork Sat May 14 14:35:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 12849831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A195AC433EF for ; Sat, 14 May 2022 14:35:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233331AbiENOfW (ORCPT ); Sat, 14 May 2022 10:35:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233346AbiENOfU (ORCPT ); Sat, 14 May 2022 10:35:20 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 987331FCEE for ; Sat, 14 May 2022 07:35:19 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d22so10514677plr.9 for ; Sat, 14 May 2022 07:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qdGAXSdby4zffm1iNWyctAoBMUKn7tqhTgOmt6ZtLYk=; b=NzTwuHZ2sltYPrY7Qa550g1DAGQv/5Hn6ISNjvELJR86t3dDlNYstvSYiA1sazmS5Y MwrHa+DfuslIaHzAing8DbDqh/yeApfM+RYlPJHve8EsTjt5qGvTwwLlhRnBcWPPX0dl F1gIZZJ1D2Y4p1DDASSoMqP1V8jwcf+Wpbiv9m8AveYMwqpG/8C2mc59aI8tlBvVb//A qsckKHCcyZzFfFSXn2cr3rlfRpkZQpC2I3YtZrgMO4vJHCt4myJyStJHvA6Zz1ayo4dx IbqEukDYSQO8E250abKgoGoPOAVUI8gXIq2wLWoNOaFqpktPHGzcI/1NXz45P+KsRz7g oqBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qdGAXSdby4zffm1iNWyctAoBMUKn7tqhTgOmt6ZtLYk=; b=JKH9xsjmsGkeraTwM/qHA+JyldWTD/B1fJv8G+eYvheQx4CLYmDmSJmJHqrwIQCMmu OcHMLTV0o90KVRj0rYs7kmvDCfQbphTODOxPLmim00nBS44/9QyMw1jzJ6fdozOYo14d 7gRVzuGFN+28t4NyDSJLR6YultbKidK4b35vhfCUbq1wG09ZgjWV5atEQ8chw0piHHQ8 wT7TlkkVfOAl2+K4MyEX4zgiip2k6iiZd/buhBqmnOC+yREmTBdW2J+tpfmjuSusaMfY lKanSf/Sr3CeWwwR398yEOHcbR9QEaKxvVKyfhtcnTdpAJ613Y7fnlES/wjqzn/6W7Zx pAqw== X-Gm-Message-State: AOAM532CzRiYmT0ByTWr8njKnJXrZTPMMddDnrjJxKtrpzjkZb2pLCuy /toeTcMH45rUNIBKru8ifT4rFeEY40PgxNi5 X-Google-Smtp-Source: ABdhPJz9rBnbg+grWSToFpBPnqVnBcB09bDj7Ez9qUqXVrsmOVmpDlrZkq8f1xnZJCCeiJBttooQlw== X-Received: by 2002:a17:90b:1001:b0:1d8:4978:c7d5 with SMTP id gm1-20020a17090b100100b001d84978c7d5mr10219920pjb.167.1652538919064; Sat, 14 May 2022 07:35:19 -0700 (PDT) Received: from HOWEYXU-MB0.tencent.com ([203.205.141.20]) by smtp.gmail.com with ESMTPSA id j13-20020a170902c3cd00b0015ea95948ebsm3762179plj.134.2022.05.14.07.35.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 May 2022 07:35:18 -0700 (PDT) From: Hao Xu To: io-uring@vger.kernel.org Cc: Jens Axboe , Pavel Begunkov Subject: [PATCH 1/6] test/accept.c: close the listen fd at the end of the test Date: Sat, 14 May 2022 22:35:29 +0800 Message-Id: <20220514143534.59162-2-haoxu.linux@gmail.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220514143534.59162-1-haoxu.linux@gmail.com> References: <20220514143534.59162-1-haoxu.linux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Hao Xu Close the listen fd when it goes to the end, otherwise it may causes issues for the next tests Signed-off-by: Hao Xu --- test/accept.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/accept.c b/test/accept.c index c591e761b43b..a0f4a13f5975 100644 --- a/test/accept.c +++ b/test/accept.c @@ -425,9 +425,11 @@ static int test_accept_cancel(unsigned usecs, unsigned int nr) } io_uring_queue_exit(&m_io_uring); + close(fd); return 0; err: io_uring_queue_exit(&m_io_uring); + close(fd); return 1; } From patchwork Sat May 14 14:35:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 12849832 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8C45C433EF for ; Sat, 14 May 2022 14:35:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233346AbiENOfY (ORCPT ); Sat, 14 May 2022 10:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233355AbiENOfW (ORCPT ); Sat, 14 May 2022 10:35:22 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02C1F1FCDF for ; Sat, 14 May 2022 07:35:21 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id e24so10497053pjt.2 for ; Sat, 14 May 2022 07:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SCjl+YC+JNe7Q33BVVsOysWmiV2FuA+j2DYhAMrotF8=; b=ONfgolvi2DASS3lj93zU62f9+c+uDBT501dG90coaEDzFbKILspA6Qo++gqlI/c1Ax e9auEOleqmTww7+kyd2WxzcdKr8QYlxdqDoLcePjR4C6tTZQ0F6U74e6xAt0YTvA6tEC 0fkeGP74J3Gc7Zo8gxJwRzPDgoPbLmrE9BSMthB3US7WwscILEyW6I53aAIp2Px2pE7m 6gF3Zv68H0aAcYokuc5avOaoTu9+/YbrPwBK0jmahcbjRdCfs2j7qMeN7LcXg+9mG1JE 9Lp66WmLmdxykwwq4oLf1pDRtgAv3tqrMUGDEz1rJb8HGNTf8cfgHqwGraTsupHoOcoL qgFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SCjl+YC+JNe7Q33BVVsOysWmiV2FuA+j2DYhAMrotF8=; b=Futn433xi5bSZUfL6YJSVQfMswftzvRnMUVJh8kH7cz5uvvbyAwQ4ZNaGsNqNptEfd +SHMzzLfpcXCwcfLvKABOU7WI4tdDwx7Jd1arrHlSYlxmvvSh6worVzgcQd4Yv8xMayS ZT3q/xqXtvFBbWxb4YM4iLZ217mAUXWGQaNjjjjZGPvzIUt5TdmzbC0lxCBBP9LV22t3 9PWU0GsROnAtRhioZWSAoadgKgdVDXxKUbBKErwSwD9AGf0O+FKwTv5kk7kcnhHWYI2f w2YBBJrNrWgO5Vaj839wWdYAcyRGKC5Azki94jYL1C3evON1cEubf1VpjF64fWDmr1++ 8LuQ== X-Gm-Message-State: AOAM531WkFiovq+Aq/uUjZzNYQqflGMBqfwL8weEowAXCZH81+V8ZYYd VLHQTBrWw28LiaSao5dXCDFzfFd079ZPeTXC X-Google-Smtp-Source: ABdhPJwqLPsAljKSeA5KbV2r1DRM9YlYGQNxplrbuW53jdX+EelLCKESzV5oJ8G+Rmo+eEEloI3gEQ== X-Received: by 2002:a17:90b:350d:b0:1dc:6680:6f1d with SMTP id ls13-20020a17090b350d00b001dc66806f1dmr21395597pjb.27.1652538920429; Sat, 14 May 2022 07:35:20 -0700 (PDT) Received: from HOWEYXU-MB0.tencent.com ([203.205.141.20]) by smtp.gmail.com with ESMTPSA id j13-20020a170902c3cd00b0015ea95948ebsm3762179plj.134.2022.05.14.07.35.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 May 2022 07:35:20 -0700 (PDT) From: Hao Xu To: io-uring@vger.kernel.org Cc: Jens Axboe , Pavel Begunkov Subject: [PATCH 2/6] liburing.h: support multishot accept Date: Sat, 14 May 2022 22:35:30 +0800 Message-Id: <20220514143534.59162-3-haoxu.linux@gmail.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220514143534.59162-1-haoxu.linux@gmail.com> References: <20220514143534.59162-1-haoxu.linux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Hao Xu Add a new api to leverage the multishot mode accept, this feature is to achieve one accept request for all listened events. Signed-off-by: Hao Xu --- src/include/liburing.h | 10 ++++++++++ src/include/liburing/io_uring.h | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/include/liburing.h b/src/include/liburing.h index 5c03061388aa..cf50383c8e63 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -502,6 +502,16 @@ static inline void io_uring_prep_accept_direct(struct io_uring_sqe *sqe, int fd, __io_uring_set_target_fixed_file(sqe, file_index); } +static inline void io_uring_prep_multishot_accept(struct io_uring_sqe *sqe, + int fd, struct sockaddr *addr, + socklen_t *addrlen, int flags) +{ + io_uring_prep_rw(IORING_OP_ACCEPT, sqe, fd, addr, 0, + (__u64) (unsigned long) addrlen); + sqe->accept_flags = (__u32) flags; + sqe->ioprio |= IORING_ACCEPT_MULTISHOT; +} + static inline void io_uring_prep_cancel(struct io_uring_sqe *sqe, __u64 user_data, int flags) { diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h index bfb3548fff96..46765d2697ba 100644 --- a/src/include/liburing/io_uring.h +++ b/src/include/liburing/io_uring.h @@ -434,6 +434,11 @@ struct io_uring_getevents_arg { __u64 ts; }; +/* + * accept flags stored in sqe->ioprio + */ +#define IORING_ACCEPT_MULTISHOT (1U << 0) + #ifdef __cplusplus } #endif From patchwork Sat May 14 14:35:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 12849833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08FD3C433FE for ; Sat, 14 May 2022 14:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233355AbiENOfZ (ORCPT ); Sat, 14 May 2022 10:35:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233357AbiENOfX (ORCPT ); Sat, 14 May 2022 10:35:23 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 712501FCFE for ; Sat, 14 May 2022 07:35:22 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id gj17-20020a17090b109100b001d8b390f77bso13334867pjb.1 for ; Sat, 14 May 2022 07:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W80cxWimMtKU9cLCoAUv5V568z3O2luN4gMEXQmQSwY=; b=WazxNFgjBpAIO3emOaKZsfV7cgSyvsI1+fNL25qkJwFeumBgiycrZKkq6nwERK+eFT cuZWPtVZkO2phWTl/hNCecb1TbN6q5kERKDwEZD3E3+5dTo71YltyLZR6DH6boIsdS5P GTo1Xw5R6Rt+kikvVc3zOGZUsaX5EnxBdd4z7M8dlgljAuYf4O1rU87NQV119hnLY8ga NGCvSb2PqBFeIWznJ8TCga/BqOLrRVNFxYMOBiva05wqa4A1SKtZuKN1c9m5EvKJR4K0 vS46zcZXnrdeh3Gt98HZC4rUnr8zYk05socXfdnruAD9hON3uKrXP6VHEfZJE/LFqjsM d5fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W80cxWimMtKU9cLCoAUv5V568z3O2luN4gMEXQmQSwY=; b=TmM70Ywbk02zag6hKM9pGLOMwPIpYdkXdaofazcKwC9nIPm0JTyk262RYd+gF5SCWa A8Z7JmoNh5HA1y9p038AwXzJKZpLM9S1brchkO/Os2dXL7ObAQXEN2G3GUllu4NuDsTQ 4IOLYlisFl+7cXSlPKANdlfzUKMlwQ2JfxJeq6dLIZe0RpPVai6fUU3XxRUWKIelYjxX gWaMMlP22oDzBxg8A5/L4wL7e2fmS0dy31BSWaamraKNfS6YgbRg1aTnVUgfYutSOaii 0/wpxNOWZK2Clbps//ndoQfIQfIvbauqSPs9m06UYrD/XquYy/GeC6a68vYTdZf4uLOG BKXA== X-Gm-Message-State: AOAM530St/CtHBBfdT2kSg3NPToxJNK9DXH/mgpm0a1lHM0/Qp8niCeR JXg10Ww6AA2XOJkK/zaJvrbxVW4DrQjXvmK+ X-Google-Smtp-Source: ABdhPJzJPbqxSPY2ASxobL/ViJZRRzA9TTFVcsQG+MrUAsFbM8DCZfqSgOdcxmnUPwLZEZgJhEu7mA== X-Received: by 2002:a17:90a:f48e:b0:1dc:8ed1:f5ae with SMTP id bx14-20020a17090af48e00b001dc8ed1f5aemr10029064pjb.182.1652538921874; Sat, 14 May 2022 07:35:21 -0700 (PDT) Received: from HOWEYXU-MB0.tencent.com ([203.205.141.20]) by smtp.gmail.com with ESMTPSA id j13-20020a170902c3cd00b0015ea95948ebsm3762179plj.134.2022.05.14.07.35.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 May 2022 07:35:21 -0700 (PDT) From: Hao Xu To: io-uring@vger.kernel.org Cc: Jens Axboe , Pavel Begunkov Subject: [PATCH 3/6] liburing.h: add api to support multishot accept direct Date: Sat, 14 May 2022 22:35:31 +0800 Message-Id: <20220514143534.59162-4-haoxu.linux@gmail.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220514143534.59162-1-haoxu.linux@gmail.com> References: <20220514143534.59162-1-haoxu.linux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Hao Xu This is to support the multishot accept directly to the fixed table, the file_Index should be set to IORING_FILE_INDEX_ALLOC in this case. Signed-off-by: Hao Xu --- src/include/liburing.h | 11 +++++++++++ src/include/liburing/io_uring.h | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/src/include/liburing.h b/src/include/liburing.h index cf50383c8e63..9065555d39f4 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -512,6 +512,17 @@ static inline void io_uring_prep_multishot_accept(struct io_uring_sqe *sqe, sqe->ioprio |= IORING_ACCEPT_MULTISHOT; } +/* multishot accept directly into the fixed file table */ +static inline void io_uring_prep_multishot_accept_direct(struct io_uring_sqe *sqe, + int fd, + struct sockaddr *addr, + socklen_t *addrlen, + int flags) +{ + io_uring_prep_multishot_accept(sqe, fd, addr, addrlen, flags); + __io_uring_set_target_fixed_file(sqe, IORING_FILE_INDEX_ALLOC - 1); +} + static inline void io_uring_prep_cancel(struct io_uring_sqe *sqe, __u64 user_data, int flags) { diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h index 46765d2697ba..6260e0d1f4ef 100644 --- a/src/include/liburing/io_uring.h +++ b/src/include/liburing/io_uring.h @@ -67,6 +67,15 @@ struct io_uring_sqe { __u64 __pad2[2]; }; +/* + * If sqe->file_index is set to this for opcodes that instantiate a new + * direct descriptor (like openat/openat2/accept), then io_uring will allocate + * an available direct descriptor instead of having the application pass one + * in. The picked direct descriptor will be returned in cqe->res, or -ENFILE + * if the space is full. + */ +#define IORING_FILE_INDEX_ALLOC (~0U) + enum { IOSQE_FIXED_FILE_BIT, IOSQE_IO_DRAIN_BIT, From patchwork Sat May 14 14:35:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 12849834 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D37DC433F5 for ; Sat, 14 May 2022 14:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233360AbiENOf1 (ORCPT ); Sat, 14 May 2022 10:35:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233358AbiENOf0 (ORCPT ); Sat, 14 May 2022 10:35:26 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F14D020196 for ; Sat, 14 May 2022 07:35:23 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id b12so1163255pju.3 for ; Sat, 14 May 2022 07:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vKvTHZjA5w7vmkGFyn6Ks44vmbW82kOdrzA0+97MO48=; b=IAQsbwwcK56J/VZgoF0+cbMRMCvsaxWf+Mje5M2rLDUfy8Jed2mHlKifO38Whzjhtm ANmvttVUVKQygk0M3iAq87AOwPc5prp7IkPusDsMLmCV0CqHu84WvFFcSB0XUCk7mQeP a2UIxzyK+51f+m0xJHbMQwFfnoOZfCQ6zsxmaBSo8NA4xKinBoBws7kdrS5kdCfeghVn +WTRDDNikUtOjusKxB7jHTh+OBI3fsf+pBpzOeC0SMurRSJxIAm1m3XdCtB2t7azJA1a NtHvHIV0G4a3bmG3WEukWDONhGbVMOlUy0SkqfKjZam0NWfxi1Yo0zZy9Nm9JULQlkn/ fH2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vKvTHZjA5w7vmkGFyn6Ks44vmbW82kOdrzA0+97MO48=; b=zoD97+rxUryFYHOdGFE4WKGtMkTtQAmRYi/h1PA0NILHMFm7IkadHC/bJx+9/ybu/b CDPjeo6F8D1gDVWyLc8iBbwkzQTczU0LDpAOb4QPiR8IeQxid0QorXT6huyXAwkzRSZi 0gahU+GvGVGo7tXRwFj7b+dPJnZhsLlruu9MfBe13c2j6UtTXW+uCYrzPNlGnTIU4wRZ YN5TA3LnKFwqvWxr77FHNJkSL1MkrH5i1W631Sy2MjQATn5ioAFABALl1uij4t2AthTN rbBB3RtOp/VTnOzp206CrOslJh0Z4vi9PmWzHdtLua561ySPGXqS5gPpDjBEg1M2ewRi 3aZA== X-Gm-Message-State: AOAM532NO1pC/gm2X7pS7GCDB1lWLQE5ekuhfZMEy8umkS4cTy8LvfLe plku3H0QtwG38FLEG5pwTS7bc6OTFbb4yS5P X-Google-Smtp-Source: ABdhPJxfzpwA/SuSxKgze30iDWXZHJddUjvafTvtEAwGWKfjcdwH1iSHiXr0vj5jDzY1VnTqYnFoGw== X-Received: by 2002:a17:902:7444:b0:161:5a62:cf8b with SMTP id e4-20020a170902744400b001615a62cf8bmr1607052plt.77.1652538923293; Sat, 14 May 2022 07:35:23 -0700 (PDT) Received: from HOWEYXU-MB0.tencent.com ([203.205.141.20]) by smtp.gmail.com with ESMTPSA id j13-20020a170902c3cd00b0015ea95948ebsm3762179plj.134.2022.05.14.07.35.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 May 2022 07:35:23 -0700 (PDT) From: Hao Xu To: io-uring@vger.kernel.org Cc: Jens Axboe , Pavel Begunkov Subject: [PATCH 4/6] test/accept.c: add test for multishot mode accept Date: Sat, 14 May 2022 22:35:32 +0800 Message-Id: <20220514143534.59162-5-haoxu.linux@gmail.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220514143534.59162-1-haoxu.linux@gmail.com> References: <20220514143534.59162-1-haoxu.linux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Hao Xu Add an test for multishot mode accept Signed-off-by: Hao Xu --- test/accept.c | 281 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 216 insertions(+), 65 deletions(-) diff --git a/test/accept.c b/test/accept.c index a0f4a13f5975..897278a2a3c3 100644 --- a/test/accept.c +++ b/test/accept.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -22,6 +23,7 @@ #include "helpers.h" #include "liburing.h" +#define MAX_FDS 32 static int no_accept; struct data { @@ -29,6 +31,15 @@ struct data { struct iovec iov; }; +struct accept_test_args { + int accept_should_error; + bool fixed; + bool nonblock; + bool queue_accept_before_connect; + bool multishot; + int extra_loops; +}; + static void queue_send(struct io_uring *ring, int fd) { struct io_uring_sqe *sqe; @@ -59,20 +70,32 @@ static void queue_recv(struct io_uring *ring, int fd, bool fixed) sqe->flags |= IOSQE_FIXED_FILE; } -static void queue_accept_conn(struct io_uring *ring, - int fd, int fixed_idx, - int count) +static void queue_accept_conn(struct io_uring *ring, int fd, + struct accept_test_args args) { struct io_uring_sqe *sqe; int ret; + int fixed_idx = args.fixed ? 0 : -1; + int count = 1 + args.extra_loops; + bool multishot = args.multishot; while (count--) { sqe = io_uring_get_sqe(ring); - if (fixed_idx < 0) - io_uring_prep_accept(sqe, fd, NULL, NULL, 0); - else - io_uring_prep_accept_direct(sqe, fd, NULL, NULL, 0, - fixed_idx); + if (fixed_idx < 0) { + if (!multishot) + io_uring_prep_accept(sqe, fd, NULL, NULL, 0); + else + io_uring_prep_multishot_accept(sqe, fd, NULL, + NULL, 0); + } else { + if (!multishot) + io_uring_prep_accept_direct(sqe, fd, NULL, NULL, + 0, fixed_idx); + else + io_uring_prep_multishot_accept_direct(sqe, fd, + NULL, NULL, + 0); + } ret = io_uring_submit(ring); assert(ret != -1); @@ -131,71 +154,103 @@ static int start_accept_listen(struct sockaddr_in *addr, int port_off, return fd; } -struct accept_test_args { - int accept_should_error; - bool fixed; - bool nonblock; - bool queue_accept_before_connect; - int extra_loops; -}; - - -static int test_loop(struct io_uring *ring, - struct accept_test_args args, - int recv_s0, - struct sockaddr_in *addr) +static int set_client_fd(struct sockaddr_in *addr) { - struct io_uring_cqe *cqe; - uint32_t head, count = 0; - int ret, p_fd[2], done = 0; int32_t val; + int fd, ret; - p_fd[1] = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP); + fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP); val = 1; - ret = setsockopt(p_fd[1], IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); + ret = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); assert(ret != -1); - int32_t flags = fcntl(p_fd[1], F_GETFL, 0); + int32_t flags = fcntl(fd, F_GETFL, 0); assert(flags != -1); flags |= O_NONBLOCK; - ret = fcntl(p_fd[1], F_SETFL, flags); + ret = fcntl(fd, F_SETFL, flags); assert(ret != -1); - ret = connect(p_fd[1], (struct sockaddr *)addr, sizeof(*addr)); + ret = connect(fd, (struct sockaddr *)addr, sizeof(*addr)); assert(ret == -1); - flags = fcntl(p_fd[1], F_GETFL, 0); + flags = fcntl(fd, F_GETFL, 0); assert(flags != -1); flags &= ~O_NONBLOCK; - ret = fcntl(p_fd[1], F_SETFL, flags); + ret = fcntl(fd, F_SETFL, flags); assert(ret != -1); - if (!args.queue_accept_before_connect) - queue_accept_conn(ring, recv_s0, args.fixed ? 0 : -1, 1); + return fd; +} - p_fd[0] = accept_conn(ring, args.fixed ? 0 : -1); - if (p_fd[0] == -EINVAL) { - if (args.accept_should_error) +static int test_loop(struct io_uring *ring, + struct accept_test_args args, + int recv_s0, + struct sockaddr_in *addr) +{ + struct io_uring_cqe *cqe; + uint32_t head, count = 0; + int i, ret, s_fd[MAX_FDS], c_fd[MAX_FDS], done = 0; + bool fixed = args.fixed; + bool multishot = args.multishot; + unsigned int multishot_mask = 0; + + for (i = 0; i < MAX_FDS; i++) { + c_fd[i] = set_client_fd(addr); + if (!multishot) + break; + } + + if (!args.queue_accept_before_connect) + queue_accept_conn(ring, recv_s0, args); + + for (i = 0; i < MAX_FDS; i++) { + s_fd[i] = accept_conn(ring, args.fixed ? 0 : -1); + if (s_fd[i] == -EINVAL) { + if (args.accept_should_error) + goto out; + fprintf(stdout, + "%s %s Accept not supported, skipping\n", + fixed ? "Fixed" : "", + multishot ? "Multishot" : ""); + no_accept = 1; goto out; - if (args.fixed) - fprintf(stdout, "Fixed accept not supported, skipping\n"); - else - fprintf(stdout, "Accept not supported, skipping\n"); - no_accept = 1; + } else if (s_fd[i] < 0) { + if (args.accept_should_error && + (s_fd[i] == -EBADF || s_fd[i] == -EINVAL)) + goto out; + fprintf(stderr, "%s %s Accept[%d] got %d\n", + fixed ? "Fixed" : "", + multishot ? "Multishot" : "", + i, s_fd[i]); + goto err; + } + + if (multishot && fixed) { + if (s_fd[i] >= MAX_FDS) { + fprintf(stderr, + "Fixed Multishot Accept[%d] got outbound index: %d\n", + i, s_fd[i]); + goto err; + } + multishot_mask |= (1 << (s_fd[i] - 1)); + } + if (!multishot) + break; + } + + if (multishot) { + if (fixed && multishot_mask != UINT_MAX) { + fprintf(stderr, "Fixed Multishot Accept misses events\n"); + goto err; + } goto out; - } else if (p_fd[0] < 0) { - if (args.accept_should_error && - (p_fd[0] == -EBADF || p_fd[0] == -EINVAL)) - goto out; - fprintf(stderr, "Accept got %d\n", p_fd[0]); - goto err; } - queue_send(ring, p_fd[1]); - queue_recv(ring, p_fd[0], args.fixed); + queue_send(ring, c_fd[0]); + queue_recv(ring, s_fd[0], args.fixed); ret = io_uring_submit_and_wait(ring, 2); assert(ret != -1); @@ -219,14 +274,32 @@ static int test_loop(struct io_uring *ring, } out: - if (!args.fixed) - close(p_fd[0]); - close(p_fd[1]); + if (!args.fixed) { + for (i = 0; i < MAX_FDS; i++) { + close(s_fd[i]); + if (!multishot) + break; + } + } + for (i = 0; i < MAX_FDS; i++) { + close(c_fd[i]); + if (!multishot) + break; + } return 0; err: - if (!args.fixed) - close(p_fd[0]); - close(p_fd[1]); + if (!args.fixed) { + for (i = 0; i < MAX_FDS; i++) { + close(s_fd[i]); + if (!multishot) + break; + } + } + for (i = 0; i < MAX_FDS; i++) { + close(c_fd[i]); + if (!multishot) + break; + } return 1; } @@ -238,8 +311,7 @@ static int test(struct io_uring *ring, struct accept_test_args args) int32_t recv_s0 = start_accept_listen(&addr, 0, args.nonblock ? O_NONBLOCK : 0); if (args.queue_accept_before_connect) - queue_accept_conn(ring, recv_s0, args.fixed ? 0 : -1, - 1 + args.extra_loops); + queue_accept_conn(ring, recv_s0, args); for (loop = 0; loop < 1 + args.extra_loops; loop++) { ret = test_loop(ring, args, recv_s0, &addr); if (ret) @@ -364,7 +436,7 @@ out: return ret; } -static int test_accept_cancel(unsigned usecs, unsigned int nr) +static int test_accept_cancel(unsigned usecs, unsigned int nr, bool multishot) { struct io_uring m_io_uring; struct io_uring_cqe *cqe; @@ -378,7 +450,10 @@ static int test_accept_cancel(unsigned usecs, unsigned int nr) for (i = 1; i <= nr; i++) { sqe = io_uring_get_sqe(&m_io_uring); - io_uring_prep_accept(sqe, fd, NULL, NULL, 0); + if (!multishot) + io_uring_prep_accept(sqe, fd, NULL, NULL, 0); + else + io_uring_prep_multishot_accept(sqe, fd, NULL, NULL, 0); sqe->user_data = i; ret = io_uring_submit(&m_io_uring); assert(ret == 1); @@ -449,6 +524,23 @@ static int test_accept(int count, bool before) return ret; } +static int test_multishot_accept(int count, bool before) +{ + struct io_uring m_io_uring; + int ret; + struct accept_test_args args = { + .queue_accept_before_connect = before, + .multishot = true, + .extra_loops = count - 1 + }; + + ret = io_uring_queue_init(MAX_FDS + 10, &m_io_uring, 0); + assert(ret >= 0); + ret = test(&m_io_uring, args); + io_uring_queue_exit(&m_io_uring); + return ret; +} + static int test_accept_nonblock(bool queue_before_connect, int count) { struct io_uring m_io_uring; @@ -483,6 +575,25 @@ static int test_accept_fixed(void) return ret; } +static int test_multishot_fixed_accept(void) +{ + struct io_uring m_io_uring; + int ret, fd[100]; + struct accept_test_args args = { + .fixed = true, + .multishot = true + }; + + memset(fd, -1, sizeof(fd)); + ret = io_uring_queue_init(MAX_FDS + 10, &m_io_uring, 0); + assert(ret >= 0); + ret = io_uring_register_files(&m_io_uring, fd, MAX_FDS); + assert(ret == 0); + ret = test(&m_io_uring, args); + io_uring_queue_exit(&m_io_uring); + return ret; +} + static int test_accept_sqpoll(void) { struct io_uring m_io_uring; @@ -512,7 +623,6 @@ int main(int argc, char *argv[]) if (argc > 1) return 0; - ret = test_accept(1, false); if (ret) { fprintf(stderr, "test_accept failed\n"); @@ -557,36 +667,78 @@ int main(int argc, char *argv[]) return ret; } + ret = test_multishot_fixed_accept(); + if (ret) { + fprintf(stderr, "test_multishot_fixed_accept failed\n"); + return ret; + } + ret = test_accept_sqpoll(); if (ret) { fprintf(stderr, "test_accept_sqpoll failed\n"); return ret; } - ret = test_accept_cancel(0, 1); + ret = test_accept_cancel(0, 1, false); if (ret) { fprintf(stderr, "test_accept_cancel nodelay failed\n"); return ret; } - ret = test_accept_cancel(10000, 1); + ret = test_accept_cancel(10000, 1, false); if (ret) { fprintf(stderr, "test_accept_cancel delay failed\n"); return ret; } - ret = test_accept_cancel(0, 4); + ret = test_accept_cancel(0, 4, false); if (ret) { fprintf(stderr, "test_accept_cancel nodelay failed\n"); return ret; } - ret = test_accept_cancel(10000, 4); + ret = test_accept_cancel(10000, 4, false); if (ret) { fprintf(stderr, "test_accept_cancel delay failed\n"); return ret; } + ret = test_accept_cancel(0, 1, true); + if (ret) { + fprintf(stderr, "test_accept_cancel multishot nodelay failed\n"); + return ret; + } + + ret = test_accept_cancel(10000, 1, true); + if (ret) { + fprintf(stderr, "test_accept_cancel multishot delay failed\n"); + return ret; + } + + ret = test_accept_cancel(0, 4, true); + if (ret) { + fprintf(stderr, "test_accept_cancel multishot nodelay failed\n"); + return ret; + } + + ret = test_accept_cancel(10000, 4, true); + if (ret) { + fprintf(stderr, "test_accept_cancel multishot delay failed\n"); + return ret; + } + + ret = test_multishot_accept(1, false); + if (ret) { + fprintf(stderr, "test_multishot_accept(1, false) failed\n"); + return ret; + } + + ret = test_multishot_accept(1, true); + if (ret) { + fprintf(stderr, "test_multishot_accept(1, true) failed\n"); + return ret; + } + ret = test_accept_many((struct test_accept_many_args) {}); if (ret) { fprintf(stderr, "test_accept_many failed\n"); @@ -621,6 +773,5 @@ int main(int argc, char *argv[]) fprintf(stderr, "test_accept_pending_on_exit failed\n"); return ret; } - return 0; } From patchwork Sat May 14 14:35:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 12849835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38237C433EF for ; Sat, 14 May 2022 14:35:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233358AbiENOf2 (ORCPT ); Sat, 14 May 2022 10:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233361AbiENOf1 (ORCPT ); Sat, 14 May 2022 10:35:27 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3652020199 for ; Sat, 14 May 2022 07:35:25 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d17so10564323plg.0 for ; Sat, 14 May 2022 07:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kqTCYzXPj2qvNDeP69xecjDJXh7/toCrwC41GgwtH4k=; b=fHLaUuUKJu0aPXHPeZnjZGTh4T/kzGSQyqAEcOyj3O6lLAE6ERApZMwPg9kXf6QEU3 4NK39YEyqntxMsk2wmSfV80rHMibiXrukijfrwln/mBQBhdjJseh0sXL5f1mgeAPQret R8amBzcHKK6Xq3NJUsAOmDN5JnBmP89KYHF1jplGxhPXIk16V5nzx6LwFEN2lI8cu5+J 6SXOdgsJS8IqFZdiVcJKy3iwcTjOmOP2SNEosaMO/Namu0ppN+WrQsC+mR5JU+Xwbyl4 w23JMA0v6WQJMFvm+IIBFoejTJuBtExmq/w95bZItdrrCHymg3sQz8w4HPi93Qmd6aWD ZvQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kqTCYzXPj2qvNDeP69xecjDJXh7/toCrwC41GgwtH4k=; b=NVzPsFoaLAVQKktvpZte93GMaeWBqPGNUaA2MSaPnAAi1Ni2dJLFm9TRZOx9mZoYos lkkglpSdUWQ8n/CwbliXyF9/REqd9BDTQCSSCP+FwcZBfyNif388w81Op2VLQWiD628B AFftbEYL+GIkxqJAhw8a47d5wTRUlpx3KVNXukznBbV0jrHaDz+7El4zjRBrT+r1LUYA Xrc9YZpPLx7vT+Qq9yvbervhvjF2TLk5mOhK80ec/6IWt1ndI1kbmRSDDia/C3NkPfI1 byi8T/GJ6VTsPcuwr6+y/GmWZK+fc1VG7ahU7mnK01n2cjt5eASFB2LghlwHLXeXgG6w ayTQ== X-Gm-Message-State: AOAM533PYqlwfvuLY0MzRsUtSuRgfHpIFDBBbigjeIn/107KT185rXMs 0p7kPFR8/yJW2/jYzXzAYzOPVFUsBdaRxFjQ X-Google-Smtp-Source: ABdhPJxjYZKtAo01RpOhCmcxPWN1zTVe+bU9fRwjR9IqC4GUG3FyDj+3uELo4JoXp8LAoNQw+CHqbQ== X-Received: by 2002:a17:90b:3a86:b0:1dc:2343:2429 with SMTP id om6-20020a17090b3a8600b001dc23432429mr10147810pjb.206.1652538924684; Sat, 14 May 2022 07:35:24 -0700 (PDT) Received: from HOWEYXU-MB0.tencent.com ([203.205.141.20]) by smtp.gmail.com with ESMTPSA id j13-20020a170902c3cd00b0015ea95948ebsm3762179plj.134.2022.05.14.07.35.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 May 2022 07:35:24 -0700 (PDT) From: Hao Xu To: io-uring@vger.kernel.org Cc: Jens Axboe , Pavel Begunkov Subject: [PATCH 5/6] test/accept.c: test for multishot direct accept with wrong arg Date: Sat, 14 May 2022 22:35:33 +0800 Message-Id: <20220514143534.59162-6-haoxu.linux@gmail.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220514143534.59162-1-haoxu.linux@gmail.com> References: <20220514143534.59162-1-haoxu.linux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Hao Xu Add a test for multishot direct accept, where don't set the file index to IORING_FILE_INDEX_ALLOC. Signed-off-by: Hao Xu --- test/accept.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/accept.c b/test/accept.c index 897278a2a3c3..921c79b862db 100644 --- a/test/accept.c +++ b/test/accept.c @@ -541,6 +541,43 @@ static int test_multishot_accept(int count, bool before) return ret; } +static int test_accept_multishot_wrong_arg() +{ + struct io_uring m_io_uring; + struct io_uring_cqe *cqe; + struct io_uring_sqe *sqe; + int fd, ret; + + ret = io_uring_queue_init(4, &m_io_uring, 0); + assert(ret >= 0); + + fd = start_accept_listen(NULL, 0, 0); + + sqe = io_uring_get_sqe(&m_io_uring); + io_uring_prep_multishot_accept_direct(sqe, fd, NULL, NULL, 0); + sqe->file_index = 1; + ret = io_uring_submit(&m_io_uring); + assert(ret == 1); + + ret = io_uring_wait_cqe(&m_io_uring, &cqe); + assert(!ret); + if (cqe->res != -EINVAL) { + fprintf(stderr, "file index should be IORING_FILE_INDEX_ALLOC \ + if its accept in multishot direct mode\n"); + goto err; + } + io_uring_cqe_seen(&m_io_uring, cqe); + + io_uring_queue_exit(&m_io_uring); + close(fd); + return 0; +err: + io_uring_queue_exit(&m_io_uring); + close(fd); + return 1; +} + + static int test_accept_nonblock(bool queue_before_connect, int count) { struct io_uring m_io_uring; @@ -673,6 +710,12 @@ int main(int argc, char *argv[]) return ret; } + ret = test_accept_multishot_wrong_arg(); + if (ret) { + fprintf(stderr, "test_accept_multishot_wrong_arg failed\n"); + return ret; + } + ret = test_accept_sqpoll(); if (ret) { fprintf(stderr, "test_accept_sqpoll failed\n"); From patchwork Sat May 14 14:35:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Xu X-Patchwork-Id: 12849836 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E203C433FE for ; Sat, 14 May 2022 14:35:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233382AbiENOf3 (ORCPT ); Sat, 14 May 2022 10:35:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233371AbiENOf2 (ORCPT ); Sat, 14 May 2022 10:35:28 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD767201AC for ; Sat, 14 May 2022 07:35:26 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id n8so10541365plh.1 for ; Sat, 14 May 2022 07:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ke3NsMb/k6GmJxHAaVqzEhETE1JXVl1Gx40uFduFsTM=; b=cjEN0irl/DPst1CLee+zIuurLTXP5xW69YpdZqiBPe/EtXm1AyxPzYjinB+P0M8UQw o9MbEYXDwJ7O/oFgMMnYvwIqzUO0eTfOi8odU9WyUvtx8e8v85lusIkSHdjVs/swZ28L CPBp5Mw3byXScHuNSImNWGNDD3GvubA4i+0o4/h7L0qYLHRu+2i7PsaG8WN4JkRbe38x z6ER/xf6oCrj9PgiJ0iv6U7PO2/HFR4ofqgKMXSIUWsnU1k/EsmsjpxSR/y0WkaUciu3 TLKDr+wjRq9SmiGMwoMczavhP7jrW6Ceu9PcoRhAl3YMj+27ZINq2gCsXP7UwCNFQdWj taXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ke3NsMb/k6GmJxHAaVqzEhETE1JXVl1Gx40uFduFsTM=; b=t7B9Gilbx0O+qccvV7idGLUzQrEJLNQ0TqrGOp7KfZqD23sqfpfLLS8b48QjSanzwM HO62FC3oxwfx90Tm1cg4BRqX4QK8ZatGoIR4ApMbs8M87iUTeU/AMYO0vmqYbI+buUJ1 DCep9V3Ncbz8PIvaIwUR+Wduv7SXyXvDaZ+3moESUN+FdPqCpIhIO1jLG9xFj4TNMdgr My0T3u8UaJw+Afb72NJYyPKmHDdFapW4vJzkFVfbuwoMfGDzWJXSI4x0xOqGT9SGqPFe Lv7XqfDtDeQgtpXC8c8g864V9lias0T32hJz3eMz2QnWLg4FcpZfvEUh3hZ6sNQw0VUs Iu1A== X-Gm-Message-State: AOAM530ENfjn8qc3Gbcwdss/aeb3gGR7nCnjkZQ/eZx1W2435Jh424vr nArZceJndEt2r87+lYb8X1/9Rpy7FwdrLdL5 X-Google-Smtp-Source: ABdhPJy5OXhIeaSj+8q9Zjm4juW/K1Ni9NU47SE25ivoACiR5yWF3CyVkl4jHHfq6UX+QdAtRpCZmQ== X-Received: by 2002:a17:902:f64c:b0:156:4349:7e9b with SMTP id m12-20020a170902f64c00b0015643497e9bmr9682964plg.139.1652538926330; Sat, 14 May 2022 07:35:26 -0700 (PDT) Received: from HOWEYXU-MB0.tencent.com ([203.205.141.20]) by smtp.gmail.com with ESMTPSA id j13-20020a170902c3cd00b0015ea95948ebsm3762179plj.134.2022.05.14.07.35.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 May 2022 07:35:26 -0700 (PDT) From: Hao Xu To: io-uring@vger.kernel.org Cc: Jens Axboe , Pavel Begunkov Subject: [PATCH 6/6] man/io_uring_prep_accept.3: add man info for multishot accept Date: Sat, 14 May 2022 22:35:34 +0800 Message-Id: <20220514143534.59162-7-haoxu.linux@gmail.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220514143534.59162-1-haoxu.linux@gmail.com> References: <20220514143534.59162-1-haoxu.linux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Hao Xu Add man info for multishot accept APIs, including non-direct and direct. Signed-off-by: Hao Xu --- man/io_uring_prep_accept.3 | 51 +++++++++++++++++---- man/io_uring_prep_multishot_accept.3 | 1 + man/io_uring_prep_multishot_accept_direct.3 | 1 + 3 files changed, 44 insertions(+), 9 deletions(-) create mode 120000 man/io_uring_prep_multishot_accept.3 create mode 120000 man/io_uring_prep_multishot_accept_direct.3 diff --git a/man/io_uring_prep_accept.3 b/man/io_uring_prep_accept.3 index 779bcd92fd2f..e52c13ee1288 100644 --- a/man/io_uring_prep_accept.3 +++ b/man/io_uring_prep_accept.3 @@ -18,11 +18,23 @@ io_uring_prep_accept - prepare an accept request .BI " int " flags ");" .BI " .BI "void io_uring_prep_accept_direct(struct io_uring_sqe *" sqe "," -.BI " int " sockfd "," -.BI " struct sockaddr *" addr "," -.BI " socklen_t " addrlen "," -.BI " int " flags "," -.BI " unsigned int " file_index ");" +.BI " int " sockfd "," +.BI " struct sockaddr *" addr "," +.BI " socklen_t " addrlen "," +.BI " int " flags "," +.BI " unsigned int " file_index ");" +.BI " +.BI "void io_uring_prep_multishot_accept(struct io_uring_sqe *" sqe "," +.BI " int " sockfd "," +.BI " struct sockaddr *" addr "," +.BI " socklen_t " addrlen "," +.BI " int " flags ");" +.BI " +.BI "void io_uring_prep_multishot_accept_direct(struct io_uring_sqe *" sqe "," +.BI " int " sockfd "," +.BI " struct sockaddr *" addr "," +.BI " socklen_t " addrlen "," +.BI " int " flags ");" .PP .SH DESCRIPTION .PP @@ -72,6 +84,25 @@ CQE .I res return. +For a direct descriptor accept request, the +.I file_index +argument can be set to +.B IORING_FILE_INDEX_ALLOC +In this case a free entry in io_uring file table will +be used automatically and the file index will be returned as CQE +.I res. +.B -ENFILE +is otherwise returned if there is no free entries in the io_uring file table. + +The multishot version accept and accept_direct perform a bit different with the +normal ones. Users only need to issue one this kind of request to listen all +the comming fds, each fd accepted is returned in a CQE. One thing to notice is +io_uring_prep_multishot_accept_direct() only works in +.B IORING_FILE_INDEX_ALLOC +mode, which means the CQE +.I res +returned is a file index counted from 1 not a real fd. + This function prepares an async .BR accept4 (2) request. See that man page for details. @@ -81,12 +112,14 @@ None .SH ERRORS The CQE .I res -field will contain the result of the operation. While the non-direct accept -returns the installed file descriptor as its value, the direct accept -returns +field will contain the result of the operation. For singleshot accept,the +non-direct accept returns the installed file descriptor as its value, the +direct accept returns .B 0 on success. The caller must know which direct descriptor was picked for this -request. See the related man page for details on possible values for the +request. For multishot accept, the non-direct accept returns the installed +file descriptor as its value, the direct accept returns the file index used on +success. See the related man page for details on possible values for the non-direct accept. Note that where synchronous system calls will return .B -1 on failure and set diff --git a/man/io_uring_prep_multishot_accept.3 b/man/io_uring_prep_multishot_accept.3 new file mode 120000 index 000000000000..0404bf59f71a --- /dev/null +++ b/man/io_uring_prep_multishot_accept.3 @@ -0,0 +1 @@ +io_uring_prep_accept.3 \ No newline at end of file diff --git a/man/io_uring_prep_multishot_accept_direct.3 b/man/io_uring_prep_multishot_accept_direct.3 new file mode 120000 index 000000000000..0404bf59f71a --- /dev/null +++ b/man/io_uring_prep_multishot_accept_direct.3 @@ -0,0 +1 @@ +io_uring_prep_accept.3 \ No newline at end of file