From patchwork Wed Jul 13 08:23:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Yudaken X-Patchwork-Id: 12916258 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 7C84FC43334 for ; Wed, 13 Jul 2022 08:25:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235648AbiGMIZ5 (ORCPT ); Wed, 13 Jul 2022 04:25:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235569AbiGMIZl (ORCPT ); Wed, 13 Jul 2022 04:25:41 -0400 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10D80B7F1 for ; Wed, 13 Jul 2022 01:23:46 -0700 (PDT) Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.17.1.5/8.17.1.5) with ESMTP id 26CLjfsK024585 for ; Wed, 13 Jul 2022 01:23:45 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=facebook; bh=Km0IeZTUL0HdVB6PFs9WNFiXX3rWttJeOF99Ub81JvU=; b=I1yV+zuFIYmC+PvzFbC6Ex5NrZ0KphieOf7IQf2mXLNqI1wOKmdowH5r3ArbZM5WNQS1 Tw/tXBlEwSzy6KkoVZBsVc1gBxO5efdpDXnieaI/ex3s8ji1cG1jKixcQtUXtvN5X9Rw 6rhGuEAqjVjrt9tdft7qaea5ZAVmVYFfVe8= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0089730.ppops.net (PPS) with ESMTPS id 3h9h5etdda-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 13 Jul 2022 01:23:45 -0700 Received: from twshared22934.08.ash9.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 13 Jul 2022 01:23:45 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id 9A5752ED8C1B; Wed, 13 Jul 2022 01:23:41 -0700 (PDT) From: Dylan Yudaken To: Jens Axboe , Pavel Begunkov , , , , , CC: , , Dylan Yudaken Subject: [PATCH v2 for-next 0/3] io_uring: multishot recvmsg Date: Wed, 13 Jul 2022 01:23:18 -0700 Message-ID: <20220713082321.1445020-1-dylany@fb.com> X-Mailer: git-send-email 2.30.2 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: zCdx25nuewnDMmU5qZ3dYfr0SjMsrpPT X-Proofpoint-GUID: zCdx25nuewnDMmU5qZ3dYfr0SjMsrpPT X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-12_14,2022-07-13_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org This series adds multishot support to recvmsg in io_uring. The idea is that you submit a single multishot recvmsg and then receive completions as and when data arrives. For recvmsg each completion also has control data, and this is necessarily included in the same buffer as the payload. In order to do this a new structure is used: io_uring_recvmsg_out. This specifies the length written of the name, control and payload. As well as including the flags. The layout of the buffer is
where the lengths are those specified in the original msghdr used to issue the recvmsg. I suspect this API will be the most contentious part of this series and would appreciate any comments on it. For completeness I considered having the original struct msghdr as the header, but size wise it is much bigger (72 bytes including an iovec vs 16 bytes here). Testing also showed a 1% slowdown in terms of QPS. Using a mini network tester [1] shows 14% QPS improvment using this API, however this is likely to go down to ~8% with the latest allocation cache added by Jens. [1]: https://github.com/DylanZA/netbench/tree/main Patches 1,2 change the copy_msghdr code to take a user_msghdr as input Patch 3 is the multishot feature v2: * Rebase without netbuf recycling provided by io_uring * Fix payload field output with MSG_TRUNC set to match recvmsg(2) Dylan Yudaken (3): net: copy from user before calling __copy_msghdr net: copy from user before calling __get_compat_msghdr io_uring: support multishot in recvmsg include/linux/socket.h | 7 +- include/net/compat.h | 5 +- include/uapi/linux/io_uring.h | 7 ++ io_uring/net.c | 212 ++++++++++++++++++++++++++++------ io_uring/net.h | 6 + net/compat.c | 39 +++---- net/socket.c | 37 +++--- 7 files changed, 228 insertions(+), 85 deletions(-) base-commit: 20898aeac6b82d8eb6247754494584b2f6cafd53