From patchwork Mon Aug 15 12:42:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12943509 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 85E86C25B0E for ; Mon, 15 Aug 2022 12:44:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231543AbiHOMoG (ORCPT ); Mon, 15 Aug 2022 08:44:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242251AbiHOMoG (ORCPT ); Mon, 15 Aug 2022 08:44:06 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43CB6DEE1 for ; Mon, 15 Aug 2022 05:44:05 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id d5so1506152wms.5 for ; Mon, 15 Aug 2022 05:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=FDcCBpO861fd0OK08nWM230qdzeMboYjo2plhdkxVSw=; b=gNZzoh3RsBd1XnhyJa88P8+2Q3i/QybIpvWulyCJpyvJhg/OmfFOxbkJNPNMIFYdFa cui69IDtGp0eIC9qvhabWdGoND+NaEMXFzE47T5y3EffhCbfoshsiZkQ0SUeI62jSrxY 4XJQ/8VHWex6Q93nyzsuJafDGDyDcKZBMhZ9zpetO3yCW9j02/mpT7JowKr7UKyrG8QJ vp+AJV35SBE+I49HuXws7UsUFN5UsiwMFn/sCfgRi6WQMpTgTixO2Rb66XQYjh/Ht/Fo q039Idqj6Rpo7Am7FQSF2yKccPLEfaHZxlRJxcjjW6nERZ48fE3K1eRSspUWWDp6eWSC 00wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=FDcCBpO861fd0OK08nWM230qdzeMboYjo2plhdkxVSw=; b=ADkhkQVf7RIcErfNstBQ+8u3En+LRmXTkess3QmqotMRrhtFvY4scSbWzgOWJJ+XXR 3sAAGWpVrvxCNE3u7JB7RWFX52zuvXbKrBmKNeIQCdci4n2ClbDtQaBL3iY2/zcbp+eH C75yJoXccEpDAlFqhHzgHlf4voJDq/+MBqy+/iwBTwZADYiDUbMn1mzByo5ayVeVuyH5 3usrpZ0flIAsVVgsI9jtCK7B9mLWIsCunBG39mjgzOsXgogh46N52IDQ4uYvLJNEyY1m Jkx6pOd70vDIjvOZMqYKtEEuP44VArq6yf63U3aFKVlydOFgMA+oBBcxVM5suZj0S0Ws LCnw== X-Gm-Message-State: ACgBeo0vpkOpuVoNL4OiU3s9HObmCzxqJVrYprQ20Puc/Cw0330MxSqX USzxTPK5VqpBAcJuDGQ2nOCRN4UnsPk= X-Google-Smtp-Source: AA6agR6S1z4L/VIvCQytKoQ4+Vx2nJOLvUV6EaeW/3Ak2SMR7Qxefeghl6cot/1TxaduVMak7j74Bw== X-Received: by 2002:a05:600c:384c:b0:3a4:a146:2a04 with SMTP id s12-20020a05600c384c00b003a4a1462a04mr9838353wmr.176.1660567443390; Mon, 15 Aug 2022 05:44:03 -0700 (PDT) Received: from 127.0.0.1localhost.com ([2620:10d:c092:600::2:5fc6]) by smtp.gmail.com with ESMTPSA id f13-20020a05600c154d00b003a54fffa809sm10296109wmg.17.2022.08.15.05.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 05:44:03 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH for-5.20 1/3] io_uring/net: use right helpers for async recycle Date: Mon, 15 Aug 2022 13:42:00 +0100 Message-Id: X-Mailer: git-send-email 2.37.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org We have a helper that checks for whether a request contains anything in ->async_data or not, namely req_has_async_data(). It's better to use it as it might have some extra considerations. Fixes: 43e0bbbd0b0e3 ("io_uring: add netmsg cache") Signed-off-by: Pavel Begunkov --- io_uring/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_uring/net.c b/io_uring/net.c index 6d71748e2c5a..2129562bfd9f 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -116,7 +116,7 @@ static void io_netmsg_recycle(struct io_kiocb *req, unsigned int issue_flags) { struct io_async_msghdr *hdr = req->async_data; - if (!hdr || issue_flags & IO_URING_F_UNLOCKED) + if (!req_has_async_data(req) || issue_flags & IO_URING_F_UNLOCKED) return; /* Let normal cleanup path reap it if we fail adding to the cache */ From patchwork Mon Aug 15 12:42:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12943510 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 817BFC25B06 for ; Mon, 15 Aug 2022 12:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242251AbiHOMoH (ORCPT ); Mon, 15 Aug 2022 08:44:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242180AbiHOMoH (ORCPT ); Mon, 15 Aug 2022 08:44:07 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEEEADEE7 for ; Mon, 15 Aug 2022 05:44:05 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id p12-20020a7bcc8c000000b003a5360f218fso7756507wma.3 for ; Mon, 15 Aug 2022 05:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=MsasM6XB4EDhVmKSN0djCwN82ilWc2CKpoiQ2edatCs=; b=M2K184tVQWwrs5Msc4k/hhvFJDb1TV/9WW7WttwsbMNPzQi5b6qQ+9qVKrvCXiT7kw eOE/IIEzcjEsE40shJ1v7eJI4Vnyi9BcpAjSsgDN8YUhHDKVoPWGvO/4ULl0WvFLCalg lodR3LSkJKPBKugn6PzDRD/wGyhUGA616XR3xhsA0kWZQD8KQu3+0FXKpJpCabaDLBRV jqNQ4KFefLszoSq3+nYyK0QxwgBryDFG2XodcJ14T2OC2lOm54X2H3o7F/6rNTKlsaGs 7H5l+7O8QW3sEqIxuLCbSNl+k5dgU9TjcJRmCySLL3xlterdPUO9b/A2Xo3slu+TGR8z 2msA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=MsasM6XB4EDhVmKSN0djCwN82ilWc2CKpoiQ2edatCs=; b=N1CdHGT6me3HE2ctDIo5jaAfNrw4lxuh/FbUgD+oPCvcyi1ydN5HbblrLO1TQLTG18 6+vQsjHof/vVXUqfdNqzo4WkAQAcMN0aRNfrlvpcowZR4nHEbwXNiQsqTVReyUAqGAPs pONsXnrKIZkA//oGkp4pX87F0TYZDASsCC2pZtGMDHY9mHMfKApi1xDZhFkPlJIr1kpw uxHZFvy5RAI3OI092Ps8Ixuk7nJqxcyAnP0nfWzLY3Eb6kFlT/xQMSk23BViR1Anhyxe jgnzUQHMOycskJee7zsR+rERAWqhJqxyM+diPS6Q15Bz64gSb0EIsSIEY9uyxtxSeohC 35TA== X-Gm-Message-State: ACgBeo1kbzACNPAJ3kfI0LE4V+WJDtPtw7ylq+pGPJMnkuIGWj3cEcxK HxIBuuIhxnRBJandWUPqgb5uLrLQVhw= X-Google-Smtp-Source: AA6agR4irOPzacWr0/RDZa3n40DiReXvyWUNJmaRGe6U0oh4RTdNY5c5VYaT0lPgGDytoHvisKc+SQ== X-Received: by 2002:a05:600c:b57:b0:3a5:3c06:f287 with SMTP id k23-20020a05600c0b5700b003a53c06f287mr15861073wmr.148.1660567444234; Mon, 15 Aug 2022 05:44:04 -0700 (PDT) Received: from 127.0.0.1localhost.com ([2620:10d:c092:600::2:5fc6]) by smtp.gmail.com with ESMTPSA id f13-20020a05600c154d00b003a54fffa809sm10296109wmg.17.2022.08.15.05.44.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 05:44:03 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH for-5.20 2/3] io_uring/net: improve zc addr import error handling Date: Mon, 15 Aug 2022 13:42:01 +0100 Message-Id: X-Mailer: git-send-email 2.37.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org We may account memory to a memcg of a request that didn't even got to the network layer. It's not a bug as it'll be routinely cleaned up on flush, but it might be confusing for the userspace. Signed-off-by: Pavel Begunkov --- io_uring/net.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/io_uring/net.c b/io_uring/net.c index 2129562bfd9f..f7cbd716817f 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -977,6 +977,14 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags) msg.msg_controllen = 0; msg.msg_namelen = 0; + if (zc->addr) { + ret = move_addr_to_kernel(zc->addr, zc->addr_len, &address); + if (unlikely(ret < 0)) + return ret; + msg.msg_name = (struct sockaddr *)&address; + msg.msg_namelen = zc->addr_len; + } + if (zc->flags & IORING_RECVSEND_FIXED_BUF) { ret = io_import_fixed(WRITE, &msg.msg_iter, req->imu, (u64)(uintptr_t)zc->buf, zc->len); @@ -992,14 +1000,6 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags) return ret; } - if (zc->addr) { - ret = move_addr_to_kernel(zc->addr, zc->addr_len, &address); - if (unlikely(ret < 0)) - return ret; - msg.msg_name = (struct sockaddr *)&address; - msg.msg_namelen = zc->addr_len; - } - msg_flags = zc->msg_flags | MSG_ZEROCOPY; if (issue_flags & IO_URING_F_NONBLOCK) msg_flags |= MSG_DONTWAIT; From patchwork Mon Aug 15 12:42:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12943511 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 D98EFC00140 for ; Mon, 15 Aug 2022 12:44:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242284AbiHOMoJ (ORCPT ); Mon, 15 Aug 2022 08:44:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242180AbiHOMoI (ORCPT ); Mon, 15 Aug 2022 08:44:08 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11184DEF4 for ; Mon, 15 Aug 2022 05:44:07 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id p12-20020a7bcc8c000000b003a5360f218fso7756522wma.3 for ; Mon, 15 Aug 2022 05:44:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=ERqPKONVQJ131A8xPa0b9ax3YX2g6jPp6AbgfsU/eyY=; b=nkTlWqvuNIqozjLQZaSgd3mmaAJlO0mHdxuQ3UhQHbf4JUrTnC95bKJ00e4RYzQ+OH yUilKHnDni+r+BQcaG3dLYgboujH5ObDlTyluLv0fkW17lYsDtTQd61pUN5UkSUG3Ma4 caOK0n+vUL5J/i04psX+uQID/0QJo+MCIxmZ4QWUZGxHg4IMl4HbyFYJUCZl5U+uItXM 8r6RCAO2vZxkv2WWDfeHzX7nExhNLYf7yQSRb3cPUZArtOsE2WK8BTJlTIYmWQFMY+V7 u3XtIWuzw7QNOR0tZVpcEptLh4ZGGIdyTwkMNlLD3THGVtjVxiYUVDw4tY0UXMlhnU2L 7NJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=ERqPKONVQJ131A8xPa0b9ax3YX2g6jPp6AbgfsU/eyY=; b=kBJsLvNvjryTU4WScBIFS2U/xJsWIMJ0T+JFAfjVpoLA8cQ0SuK19TwqK6n5QoD99N RreZVrUxlm5Vl87LWVhr0JJBT8Z/w5zG8NkdC0vWzRWfbgNp2+VUpn+U6YWqR0Zxxqhf unQVRH85a81QcZZDp5bsLKS6E0GCucfvz4QuciJqmHpunhG8nD74dG+I8fLU7yt12ZXQ J/qkIKvi9DV1A083uf57F0VgfxpcvOclOZY79lOFKtFmqoM206+hphbWBNBsI3j15TNO v/HVeUW5PcK0CC4lTBH+ttuaA+SYmdWMBkz7yD9NI2nS2s4tMCVGzeT4sFXNAB+lsIIq VH7w== X-Gm-Message-State: ACgBeo0nKkFSMRc//uGIrQPaI+lGS6MSx4tWxdvBZu2Voeu7I7CiDLq0 7QKtDsZPwau/p+Q6+swvIXX8chYWDX4= X-Google-Smtp-Source: AA6agR6k2ZCGQDP8Q0berMuW6o38LUI+xXDtzMmyTTzKijrSAqvGnlnglR1kv43N3Ps3klt3a4q3WA== X-Received: by 2002:a05:600c:210b:b0:3a5:bb92:d22d with SMTP id u11-20020a05600c210b00b003a5bb92d22dmr10007477wml.99.1660567445234; Mon, 15 Aug 2022 05:44:05 -0700 (PDT) Received: from 127.0.0.1localhost.com ([2620:10d:c092:600::2:5fc6]) by smtp.gmail.com with ESMTPSA id f13-20020a05600c154d00b003a54fffa809sm10296109wmg.17.2022.08.15.05.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 05:44:04 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: Jens Axboe , asml.silence@gmail.com Subject: [PATCH for-5.20 3/3] io_uring/notif: raise limit on notification slots Date: Mon, 15 Aug 2022 13:42:02 +0100 Message-Id: X-Mailer: git-send-email 2.37.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org 1024 notification slots is rather an arbitrary value, raise it up, everything is accounted to memcg. Signed-off-by: Pavel Begunkov --- io_uring/notif.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io_uring/notif.h b/io_uring/notif.h index 65f0b42f2555..80f6445e0c2b 100644 --- a/io_uring/notif.h +++ b/io_uring/notif.h @@ -8,7 +8,7 @@ #include "rsrc.h" #define IO_NOTIF_SPLICE_BATCH 32 -#define IORING_MAX_NOTIF_SLOTS (1U << 10) +#define IORING_MAX_NOTIF_SLOTS (1U << 15) struct io_notif_data { struct file *file;