From patchwork Mon Oct 24 11:34:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9508 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp481567wru; Mon, 24 Oct 2022 07:23:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6T6C1cmcL4XsxxgSK44sMmgd8+CGzT72Wi/FE75FR4bcGujciYwYxIRfaifhrcCm4t9BbS X-Received: by 2002:a17:906:cc4a:b0:7a0:71f0:3b25 with SMTP id mm10-20020a170906cc4a00b007a071f03b25mr11186458ejb.595.1666621403093; Mon, 24 Oct 2022 07:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666621403; cv=none; d=google.com; s=arc-20160816; b=hOYWT7v35p6k+++120ZB1tARONgEzkiYSN+sJLzORrg3cn2V09yjHNRlcirmnoa82L B7TtKD5CeS9a3hV9lr60Ku7FV7j4W3z3PKdYUy398/6F30YE6gN46FweSH1MI6dFQZpO vNp1zdaC05MfjkCtG6fP0kkxAySV4uGeuK0acb1vSgu7R2yCKj4m+nPGCtD4Jc2v3Otm Chgout4YSkE5kbWuSEpauIc1bPs5mMDQLYgFv4+qy/iwhOO8eIvSY9BF5WGRIAlkVWQC 7IeLW7rbyl91+oPdCOK2W9pX/0GEZocVUtVdiK2XgpSgNEPT4anR5rVhTFEm+kWUGi2j bG1w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cs4RaMlR9JOIzCpix3k6Rl/rVnaHj0mOZy+p4dP9mRQ=; b=dr5ljCaVdSdAfaZ8hMkozQ+QSIdZ48hoNUmZnucgc4pSdBW/a3rFIK61lzMeBu1hbB PW+tryV5FzQ0aP/qyW+lrTAc3Ka2X2PKqZJedAgBShegNIoC/JsIq4QLzYJvmFYq/ml8 n9DN1rqYuVZ8zJ2lCVAMxw2ODKRJ7DHxNx7/UwYoeD5hQ7s0MC0v0QGg6pgDXeYIFgmp WRcvzSghkoMWDSN95dNyXyNl/54fHU5644GMkGh2CLyuakZPl4Id/4MxLqUIRH+aSO1K e4oa0E0gmBmPxA4Qc8cF3Q0sLvkmcy2tOPixwa4ttw2Uwf2DNtred2GUocyN8GeEURUZ XnGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Quq9yBF6; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020a50cb84000000b00453688643fasi24971609edi.260.2022.10.24.07.22.58; Mon, 24 Oct 2022 07:23:23 -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=@linuxfoundation.org header.s=korg header.b=Quq9yBF6; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231635AbiJXOV7 (ORCPT + 99 others); Mon, 24 Oct 2022 10:21:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237190AbiJXOQH (ORCPT ); Mon, 24 Oct 2022 10:16:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0923A64D8; Mon, 24 Oct 2022 05:55:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4C35961350; Mon, 24 Oct 2022 12:55:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 588E8C433C1; Mon, 24 Oct 2022 12:55:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666616127; bh=1HKoA20yZ1RA4LqmUTNBHh0p4auKpm9/eOH07oDCRqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Quq9yBF6SrqhSqJjP+/fYkpO5DzbFaiQVMXMnqDTamjHgSkhpGJOP7TPs6uqoaEr1 9ZvNp17dXpnrvWK9+oJCpfbGcWW29e8t10dq9mwiU6Gvyf+KYyvg+eDnteqdSL18O1 oy2SQ8DxCSqppMujr//YZIlFuvBbNb1KwW7zl7bA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Stable@vger.kernel.org, Pavel Begunkov , Jens Axboe Subject: [PATCH 5.15 512/530] io_uring: correct pinned_vm accounting Date: Mon, 24 Oct 2022 13:34:16 +0200 Message-Id: <20221024113108.207176381@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747579203888459206?= X-GMAIL-MSGID: =?utf-8?q?1747579203888459206?= From: Pavel Begunkov [ upstream commit 42b6419d0aba47c5d8644cdc0b68502254671de5 ] ->mm_account should be released only after we free all registered buffers, otherwise __io_sqe_buffers_unregister() will see a NULL ->mm_account and skip locked_vm accounting. Cc: Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/6d798f65ed4ab8db3664c4d3397d4af16ca98846.1664849932.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -9303,11 +9303,6 @@ static void io_ring_ctx_free(struct io_r { io_sq_thread_finish(ctx); - if (ctx->mm_account) { - mmdrop(ctx->mm_account); - ctx->mm_account = NULL; - } - /* __io_rsrc_put_work() may need uring_lock to progress, wait w/o it */ io_wait_rsrc_data(ctx->buf_data); io_wait_rsrc_data(ctx->file_data); @@ -9343,6 +9338,11 @@ static void io_ring_ctx_free(struct io_r #endif WARN_ON_ONCE(!list_empty(&ctx->ltimeout_list)); + if (ctx->mm_account) { + mmdrop(ctx->mm_account); + ctx->mm_account = NULL; + } + io_mem_free(ctx->rings); io_mem_free(ctx->sq_sqes);