Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1372578imw; Tue, 5 Jul 2022 08:19:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tVQ76OqTqbUrsj10NibeTmDk6C1toNr7HdzcQLI8EfAAQ7VcIKPRU0w3PQ+1K040fdS4g4 X-Received: by 2002:a63:fb44:0:b0:40d:1b0d:bfb4 with SMTP id w4-20020a63fb44000000b0040d1b0dbfb4mr29984598pgj.335.1657034358273; Tue, 05 Jul 2022 08:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657034358; cv=none; d=google.com; s=arc-20160816; b=pgjo07HdbyEGeokR7dU/6LeufRoAD0y1JdFUOQZH3FXbBv3n1zq3u1R+EMspp32dKI XCVWYfD8oc+GwFLQ5FAkXMYYGmdslwHuYI2yN2uGiHRSR571tjA77/5RrX7NWUZECnAO CS1S8eYgobmzrq5rTY3cqMte/r8evnLFGnGPLeaVE/pVYj28M+qBGU+6HNyJUY7lsi2M Q+djRHvkmR0QHB/dNlBC7XpSnrT4qj9v7ruWUPHqV/0SkJ/IMKLHTPHHzNG/tS6/skAd w5XUrO7mNAmIfAL6ML59Su2gY6VudRDnutmweI0I37MMQ5DU0DXFv/X8FB/w+4WnRXpA RcMQ== 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=OyzXlHlPpUF+PH3cvr0acLEzu0fqzPDm7G8p3eUY1iQ=; b=CE/C8N/HOBJulHEtY+Zvz/cr1I6vUq7Cm2LgJrIBGdYk0z0v5S1sBBeJ0R+jEG8l+2 LRR4K5/zZJnW/wMPAbubh7UPGka7NgKbUJ9hTnmVwmuw5vo8cunFvhJWOn94hR+mR/TY ulME3CV+B+yN6ILDual4o8o61+z9/CxAP27NQZ0PgCVPt209DpHvif7e+2+rOz/c1JA+ LdwfWBy9esckRezJDRiDc7lLthbpCqtjI4RY/4UkSx0Q1hytF3MxPDxvS+FX6Hk75lFT 6o7gEbqInqHaPmv3NRq8TTVPupB3eFja9OJ5cvSEs9Ky6dh3aULWTpifGVvFzwrDC/A/ ZMNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oY665IzM; 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 s4-20020a17090a5d0400b001ef88fdea33si6318993pji.180.2022.07.05.08.18.57; Tue, 05 Jul 2022 08:19:18 -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=oY665IzM; 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 S232529AbiGEPEH (ORCPT + 99 others); Tue, 5 Jul 2022 11:04:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232711AbiGEPC3 (ORCPT ); Tue, 5 Jul 2022 11:02:29 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0F7817E1A; Tue, 5 Jul 2022 08:02:10 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id f2so12596507wrr.6; Tue, 05 Jul 2022 08:02:10 -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=OyzXlHlPpUF+PH3cvr0acLEzu0fqzPDm7G8p3eUY1iQ=; b=oY665IzMEMc069+iaFhE806eybX+Vi7JUUgzz76HgKm/BEi8RmiLw8O6vaotDBWZh4 sr7Jb9AaZLI5BkhrQO7WmZBhYcwGiX3CVB+Ikj/pQ1o3bWaMJZ2CmsCyaVxhx6YDSr4W e8uSk10DtnKW5qW7MXWlMgAryd6QG0MBYPdtpP7azjixrYMQ4bV4ip2DEr/u9O7VllAO fKHZVIR46xsXb/deGjNUeximHFKEbm/ftuNyOnndXgs3owWc4QYhAoG0cSRX/kNkeLVT LlwNyaYkeSw2SdI93JnMa6W7np8fjV2Q7t8s6HXMMGYlVPu+Fr0+rghlsiZXGH06tmY8 E8Vw== 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=OyzXlHlPpUF+PH3cvr0acLEzu0fqzPDm7G8p3eUY1iQ=; b=qbz0V9Nbr5zwjyG6llzU9KSQxclGcke0cDDQzG8cJPz2XfxwW2ECfOpHQKVDghFrTm M19XkIzEA7xeyxl3Gkh5FaTctJot925sx+qVKBiFzzBMHSGF6RPPd6BJq6NdZz7Gc/s8 yrWo+I9w3/IoBd+jIQng+e6Xqqrtb+feqJCbmqFxmjOjnuSHAbsawJeIyli9dZXsKeEH A1KUvaeOtobxG0E4m3CRka7R45h3TysratNVekRWdqLf+vx6wk/8w1/ZX3r/IahASHbh sji/3WBExPVKVp6XLsbNWPhg/0LbDUUJiY6mXGo62z0lodJlpGPpOZsVHDhhzaaXSco3 glIg== X-Gm-Message-State: AJIora8zKZm8UkPtHqdgywyrI3XDehKe12cYRz0Vg9Zq17+dmtzWJHzb +IatkU1JfnByE3EPjf4f7t5dkkijANcKQA== X-Received: by 2002:a05:6000:1282:b0:21d:6afa:35ca with SMTP id f2-20020a056000128200b0021d6afa35camr10615518wrx.452.1657033330047; Tue, 05 Jul 2022 08:02:10 -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 k27-20020adfd23b000000b0021d728d687asm2518200wrh.36.2022.07.05.08.02.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 08:02:09 -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 v3 18/25] io_uring: account locked pages for non-fixed zc Date: Tue, 5 Jul 2022 16:01:18 +0100 Message-Id: <8b9d08b0ef818070564864036419550d5d767911.1656318994.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.36.1 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 ef492f1360c8..d5b00e07e72b 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -834,6 +834,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 2e9329f97d2c..0a03d04c010b 100644 --- a/io_uring/notif.c +++ b/io_uring/notif.c @@ -12,7 +12,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_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.36.1