Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4249621iog; Tue, 28 Jun 2022 12:05:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uysgfdIqvm5pS46yehmMMkGzdlFVOipJ8UEMe5Yufl+6NNa4k2q66FqkbynapPSNnbKZsX X-Received: by 2002:a05:6402:847:b0:437:62bd:bbc0 with SMTP id b7-20020a056402084700b0043762bdbbc0mr24803282edz.285.1656443151059; Tue, 28 Jun 2022 12:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656443151; cv=none; d=google.com; s=arc-20160816; b=BXX14gf2Nk/FEglZJZaOXdB+NSfLjYr906dlIcGmKugc4r9glxdaMpcVzWNvbeDYqy xBDnHKNCG/TLYes8o7jVeMBMPxwG2w+1aIpbCnOpW6otSIU+RMUwW70sTabtK4kZ/PSt QrfbMZfE++FsyDyEiSlgkh1ZhOYUxvA6kYa44Dd1ghPrxXHvL+sJtYqMtpdL/dQL8p5b akOIzrgPECDl38aryI7AOm7HVz38Y/RipJMRAhHgdYQD0oxeA9R0dh9SPw3/oN1AF7OU nMQezlcOlSKhf6byvZacWetXBfagcAWyUDcLUfZPJwa5KLAimfHs7fEEdlMq+CWuLDqI SXeQ== 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=HYd55O2NdGLO2Euqz1Nyab6aWjt/DTgixsVymNAk6zI=; b=ZDIv52M3rqIq4KOhkuekvawbeA5qAhdSc/I5eemusT3KwOq4dF6wk33pox+0w9nmBE //rlsQUiFmgUI6p1Ave8KpJRUmjaEnXs9BWXJBDO6wj8tQVKgwAnpD5Mfsa2gzHo5t+1 I01RZb1YoYGQLApqHsdiT1PY0nrDxI+A9MYo+oNPnbGrcydC5EoynJUb2b9kzKy5cpRa VRRiBdRoXEgjRI6PthH0uN6kM6N+wNgNhL6/0TyoLlt1v7qG9uPo9vgyqTE/61Mu5Own AlECjDYkCe3fA2ZTRzHd7+Pd3hybRRUDZDLx/v47d8JNPN9Yjj9DxFp9fILCZjpcUe4G U1Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GSK4pU18; 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 sd7-20020a170906ce2700b006f3b8834625si14787943ejb.423.2022.06.28.12.05.17; Tue, 28 Jun 2022 12:05:51 -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=GSK4pU18; 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 S235289AbiF1TCX (ORCPT + 99 others); Tue, 28 Jun 2022 15:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233559AbiF1TAe (ORCPT ); Tue, 28 Jun 2022 15:00:34 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8691D1CB07; Tue, 28 Jun 2022 12:00:20 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id sb34so27624996ejc.11; Tue, 28 Jun 2022 12:00:20 -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=HYd55O2NdGLO2Euqz1Nyab6aWjt/DTgixsVymNAk6zI=; b=GSK4pU182c9jv4Pa9k0QjVW35qbkMOQ/h9jCjetCYwu/R3LP0mTfoPowza+903LW5G e8fXxUrGqr0gbmnnKjC9xJQCiLrnmGXSLaVcwptfbd/APhuwGXzFVv8CSQ1MlFUpXC0r MNfFw64H1qREZflEXEhkKEN3UR1sVd3my9ZZEUWt8K/eNRBRYCkmFQ+9AU7OdtmargIz c/wAP+qmwpnj/Fh1Gy3Dy+BX4RZJP2iTfq0evYLdPa6tZyYAkXjkh+5t2zz8+i/XgAdN /igFpNVAHcbgwhsP2+QubjUIdYnQyYPVlawovbSZX9xMf8sUrJSRJ6yua3ewfWZwKBRR c4Cg== 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=HYd55O2NdGLO2Euqz1Nyab6aWjt/DTgixsVymNAk6zI=; b=ht5Btv4eO9SijPMIEa1+vROHrEQVPHpmMgdDu9+Mvu+uonbR7IQgQckXl5iUfCuH1b x6NA02y/yur216u04HwfvLtIobqjVZwYXN5e4GXP9j5SD4a02FxR7qu7H+MKPiORrdkz C5YR9KZkGFdXns1deCQoSfJUHV2hcCD2VIoeHCvDKqUqKr7gQVNjk42EB1GyR9YZL4+n j05T8uonCcD+ITG7UwfpXhDkOLoW3wh86LONK8g5SNOK53paLzeIgt8QmWhGGV2TQkYF VVuY/Kb/keO+1lSRtOW60gIfwBkYXjr09R2h0kAM/Ht72q2lUUMQpuxp7vNwUejdpvWM 8RxQ== X-Gm-Message-State: AJIora/0jcaVT5/7y34sRpalafBdv12ZMTgSSRiWJINc5YR8H0Zl+fOU pUE7crhxllgOAHILuBT7ZM60C+uydugugg== X-Received: by 2002:a17:907:94d2:b0:722:e4fa:89f7 with SMTP id dn18-20020a17090794d200b00722e4fa89f7mr18101861ejc.603.1656442818800; Tue, 28 Jun 2022 12:00:18 -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 t21-20020a05640203d500b0043573c59ea0sm9758451edw.90.2022.06.28.12.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 12:00:18 -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 , kernel-team@fb.com, Pavel Begunkov Subject: [RFC net-next v3 22/29] io_uring: account locked pages for non-fixed zc Date: Tue, 28 Jun 2022 19:56:44 +0100 Message-Id: <7b68f8a5291bc512a225b5a876384ebd4dcda1dd.1653992701.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 --- fs/io_uring.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index 4a1a1d43e9b3..838030477456 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2825,7 +2825,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 (unlikely(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; @@ -6616,6 +6622,7 @@ static 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) -- 2.36.1