Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp33512imw; Tue, 12 Jul 2022 14:06:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sGDAwjKtO/RCgS6LEJkYJBp2yMa+rgf+gnWfrWPqbuF3xh1nQF6jImuh6kV8fJwUBHvbRw X-Received: by 2002:a05:6402:4301:b0:43a:e374:1557 with SMTP id m1-20020a056402430100b0043ae3741557mr20102edc.229.1657659979303; Tue, 12 Jul 2022 14:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657659979; cv=none; d=google.com; s=arc-20160816; b=ziFK6HgnLZz64BlJCdJz6hMoGt0rAV9csUsnFcWPEmpvj2wSdT02/8XmJPYqSEAWWR rok39KZV16agDgC1EVo58W5YBjILzkAXUfe9BjZ/YuROkECGeHYH/vYMUtHwkiGLXTLp xIYCM6gvvTnB9aUgUjJq8IxzOdZREIHWLi1FB0WjpSJDzRecAq1wQNsIRjVVpPQ4kPKE kDtnMGx4LuqzmZxfqimkLyvGDyHmuB3PSJokHOJb6nZ5n5qr6ae9aCuqMQkC7umS0ZgL jkeLz+WbEP1vEy7TuIkQ+7oL1fdz7ieL6T8kF1OpousCKzfyG8IwArSeql4BAvbtHDat 4Tfg== 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=u1S2AivxVWXdd+4RPf9USNps4dL740oJjGqqaX0bN80=; b=m2NStbCuc8KY/4CPEbmwL6M3JSbSZL2jo8hOCraR92MO5rzoxqgAkl20jlhJMYwBXx QxThsITPN9O52Pi8XuJM4v3Rz/KUrz5Y6+BqgKPrs5NqtPZl7d2p/tRnAGxr4YHZpqnR qdoBx+e0FCpiPKQq9v7+qHnqhrdT2Qx3OZUb+Y5NyZK74+SZB/JkdQ9u5Yp3N2UQBNfc 6IB/xpOuJyoI1jMs3bKeZezf7VbeJCnxb0J1Bw5FOYoRdRa+6VO8N3jAB6T20EfSN/MX j0mbhP544+gWPNTCJ1w9E6obcrEfbAcPnA5VSgUCA6zo32j8JssQ8EeXO+uUN8sHCe5t LojA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AfNA+WmP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb38-20020a170907962600b0072b8ac605e1si2408684ejc.267.2022.07.12.14.05.53; Tue, 12 Jul 2022 14:06:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AfNA+WmP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231567AbiGLUzt (ORCPT + 99 others); Tue, 12 Jul 2022 16:55:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234107AbiGLUyh (ORCPT ); Tue, 12 Jul 2022 16:54:37 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BF616387; Tue, 12 Jul 2022 13:53:34 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id b26so12831204wrc.2; Tue, 12 Jul 2022 13:53:33 -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=u1S2AivxVWXdd+4RPf9USNps4dL740oJjGqqaX0bN80=; b=AfNA+WmPd/ODqSuz0pd5DC7lj+/T4z/EeKuS84uKE9jZwUFV2vy/bvq29V+qjT+VSy UrlX0Chn/ehVo1QPRzLxUFKXsFnKZgwz0rxVxURd3WuQSiATfDYJM5knQVQ40MeN/+mF w2MShjYqFQp4Xn3dqjJZIOi+37r+gQ+u5Ehtjk57x4GGczaUUuZXRR4v0ifQ63d8Ke0q AFY/uXn12dRps575KClC664t0nwgVTUbAE5e3bH27BO0u3/TQLLn8davgOCSWrqKanfj YoWpS6iM4d1qT+yogHZNqMQcH76ALBGbgrl1L61ekH8JtMlJmUQaY+hupfiUSkIg5U7l KeZA== 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=u1S2AivxVWXdd+4RPf9USNps4dL740oJjGqqaX0bN80=; b=cuCnOPl9frvjoBz5jy49LySVDwo6jUITEPPSgiZlszL+wnnb1WnNAlm/d/r1dcIrV+ ZCtDYaAH5iMcitj63H82nss3IqWoiinDgPrSmjie+iWLOGVGu0mun6MAo0cAXaQtFqCf HUQVGsy5iBeo3j1Td/bZ7CL6aOXfOabENecQco02K+h4pVLL7LN7Xmg4lWgSj5W/7kHx yhf3+69AVkPVqdmpmzLlJkuHk7/10OfIqilj4Jw4yEebjHjVVSjxoQNWqDdVSP3D0okH 1gnMbg64YYkNo2EB9ToWloSe+GdVYjLC/r5ZwCr9mBEIJ9xCcybJzbVeblAs3s5GWoIr 2TNg== X-Gm-Message-State: AJIora/iimZQfKBgGjPuz8xklw9aQCtk9/xyqisjx4O3jCVe5l0cySoW e6FA7i6QCNB/Jcs+aowOpvRxESf50Rw= X-Received: by 2002:a5d:4c91:0:b0:21d:8293:66dc with SMTP id z17-20020a5d4c91000000b0021d829366dcmr25537183wrs.30.1657659211786; Tue, 12 Jul 2022 13:53:31 -0700 (PDT) Received: from 127.0.0.1localhost (188.28.125.106.threembb.co.uk. [188.28.125.106]) by smtp.gmail.com with ESMTPSA id c14-20020a7bc00e000000b003a044fe7fe7sm89833wmb.9.2022.07.12.13.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 13:53:31 -0700 (PDT) From: Pavel Begunkov To: io-uring@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "David S . Miller" , Jakub Kicinski , Jonathan Lemon , Willem de Bruijn , Jens Axboe , David Ahern , kernel-team@fb.com, Pavel Begunkov Subject: [PATCH net-next v5 20/27] io_uring: account locked pages for non-fixed zc Date: Tue, 12 Jul 2022 21:52:44 +0100 Message-Id: <19b6e3975440f59f1f6199c7ee7acf977b4eecdc.1657643355.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fixed buffers are RLIMIT_MEMLOCK accounted, however it doesn't cover iovec based zerocopy sends. Do the accounting on the io_uring side. Signed-off-by: Pavel Begunkov --- io_uring/net.c | 1 + io_uring/notif.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/io_uring/net.c b/io_uring/net.c index 399267e8f1ef..69273d4f4ef0 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -724,6 +724,7 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags) ret = import_single_range(WRITE, zc->buf, zc->len, &iov, &msg.msg_iter); if (unlikely(ret)) return ret; + mm_account_pinned_pages(¬if->uarg.mmp, zc->len); msg_flags = zc->msg_flags | MSG_ZEROCOPY; if (issue_flags & IO_URING_F_NONBLOCK) diff --git a/io_uring/notif.c b/io_uring/notif.c index e6d98dc208c7..c5179e5c1cd6 100644 --- a/io_uring/notif.c +++ b/io_uring/notif.c @@ -14,7 +14,13 @@ static void __io_notif_complete_tw(struct callback_head *cb) struct io_notif *notif = container_of(cb, struct io_notif, task_work); struct io_rsrc_node *rsrc_node = notif->rsrc_node; struct io_ring_ctx *ctx = notif->ctx; + struct mmpin *mmp = ¬if->uarg.mmp; + if (mmp->user) { + atomic_long_sub(mmp->num_pg, &mmp->user->locked_vm); + free_uid(mmp->user); + mmp->user = NULL; + } if (likely(notif->task)) { io_put_task(notif->task, 1); notif->task = NULL; -- 2.37.0