From patchwork Mon Nov 7 17:56:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13035041 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 1A68FC433FE for ; Mon, 7 Nov 2022 18:00:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231946AbiKGSAO (ORCPT ); Mon, 7 Nov 2022 13:00:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232236AbiKGR7s (ORCPT ); Mon, 7 Nov 2022 12:59:48 -0500 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A35D52A944 for ; Mon, 7 Nov 2022 09:56:24 -0800 (PST) Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A7Glivp023222 for ; Mon, 7 Nov 2022 09:56:22 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=s2048-2021-q4; bh=L3jw1UOj6ixjglp00dy1V087hjPkrNjvSa5Six2yGI0=; b=M9ZqP5hok/+fvIkhOQjZnDGyICKctDvZD2af06hYRhVQrIT0I5R1DwRvlKCf/iwVMeot rOMpxVG2phTo7Fd6Uo1xnrNJ8keushyttYBf70d3Q/K7ZzrxZ+FuN2rUNLTXzEO8tGwp IB/7roO7MZ1RswdW3hQ/SonoJEaCrltoU3uGWjTuf+yWw0CxokdpWL8JjGCTvmPQSMXO J7EtxuaOOQ5Da/56zqXZYAXggZWHAcmgb7EyTlRCi4lT+LzM9wlDKx1wd50+mL/Cg70W v5nHCwXQFaqCO4tLF4LCKyKOraPGt+gT9sK8epBYU/ctZM23trjAHzCrISX6LXHuBwaa aQ== Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3knnbyrfye-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 07 Nov 2022 09:56:22 -0800 Received: from twshared5287.03.ash8.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 7 Nov 2022 09:56:20 -0800 Received: by devbig007.nao1.facebook.com (Postfix, from userid 544533) id 7EDBDADF1C9B; Mon, 7 Nov 2022 09:56:11 -0800 (PST) From: Keith Busch To: , , CC: , , Keith Busch Subject: [PATCH 2/4] io_uring: switch network send/recv to ITER_UBUF Date: Mon, 7 Nov 2022 09:56:08 -0800 Message-ID: <20221107175610.349807-3-kbusch@meta.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221107175610.349807-1-kbusch@meta.com> References: <20221107175610.349807-1-kbusch@meta.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: 5qVPEtRoFFygW6Rg0P03xJCuQZVZxqvU X-Proofpoint-GUID: 5qVPEtRoFFygW6Rg0P03xJCuQZVZxqvU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-07_08,2022-11-07_02,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Jens Axboe This is more efficient than ITER_IOVEC. Signed-off-by: Jens Axboe [merged to 6.1] Signed-off-by: Keith Busch --- io_uring/net.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/io_uring/net.c b/io_uring/net.c index 9a07e79cc0e6..12c68b5ec62d 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -170,7 +170,7 @@ static int io_setup_async_msg(struct io_kiocb *req, if (async_msg->msg.msg_name) async_msg->msg.msg_name = &async_msg->addr; /* if were using fast_iov, set it to the new one */ - if (!kmsg->free_iov) { + if (iter_is_iovec(&kmsg->msg.msg_iter) && !kmsg->free_iov) { size_t fast_idx = kmsg->msg.msg_iter.iov - kmsg->fast_iov; async_msg->msg.msg_iter.iov = &async_msg->fast_iov[fast_idx]; } @@ -333,7 +333,6 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags) struct sockaddr_storage __address; struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg); struct msghdr msg; - struct iovec iov; struct socket *sock; unsigned flags; int min_ret = 0; @@ -367,7 +366,7 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags) if (unlikely(!sock)) return -ENOTSOCK; - ret = import_single_range(WRITE, sr->buf, sr->len, &iov, &msg.msg_iter); + ret = import_ubuf(WRITE, sr->buf, sr->len, &msg.msg_iter); if (unlikely(ret)) return ret; @@ -752,10 +751,7 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags) } } - kmsg->fast_iov[0].iov_base = buf; - kmsg->fast_iov[0].iov_len = len; - iov_iter_init(&kmsg->msg.msg_iter, READ, kmsg->fast_iov, 1, - len); + iov_iter_ubuf(&kmsg->msg.msg_iter, READ, buf, len); } flags = sr->msg_flags; @@ -824,7 +820,6 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags) struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg); struct msghdr msg; struct socket *sock; - struct iovec iov; unsigned int cflags; unsigned flags; int ret, min_ret = 0; @@ -849,7 +844,7 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags) sr->buf = buf; } - ret = import_single_range(READ, sr->buf, len, &iov, &msg.msg_iter); + ret = import_ubuf(READ, sr->buf, len, &msg.msg_iter); if (unlikely(ret)) goto out_free;