From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EEBFC07E9D for ; Mon, 26 Sep 2022 19:55:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D6CE8E007F; Mon, 26 Sep 2022 15:55:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3861C8E0066; Mon, 26 Sep 2022 15:55:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24D2C8E007F; Mon, 26 Sep 2022 15:55:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 154768E0066 for ; Mon, 26 Sep 2022 15:55:30 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D5BC716060D for ; Mon, 26 Sep 2022 19:55:29 +0000 (UTC) X-FDA: 79955291178.29.3A7AFDB Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) by imf20.hostedemail.com (Postfix) with ESMTP id 6A55D1C0017 for ; Mon, 26 Sep 2022 19:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=BCNxkn1cjjmSTz0F2QcnuWmtFkHDRw/dUVSXShbYPtk=; b=ofdS4CZ7qJGuelZ07G6x4wyeEq o4+hP4T1gJZQnEOjyxGireIZZ1+MEg9aoxeDeG/R2AvDSx4S7qCp8P5aZVOnHfxeOFc8cMCjgbXXk Z07GM4aucnTmj7FnuBlJNT9iTC861d2/5SW4rZtQ98JFH0QB7wuN5CKl7YicCNrwYElAn1ggLn9Ve 3hSS4/UMsj31cJRSiaLYOkcjjsgeIhghk7MnSbCwU+QqyAt2lz7kiBvCnwOP1+RtF0dnUSI/UdcwZ jgaZXePZnUP3ebMoUoLAECO5gB01LB4t609jzxdzCKZe6oVVhGyVslpBCj8yWuLLW8GQi5ebLXOS9 /ef2RS2g==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1ocuC1-0048RF-0x; Mon, 26 Sep 2022 19:55:05 +0000 Date: Mon, 26 Sep 2022 20:55:05 +0100 From: Al Viro To: Christoph Hellwig Cc: Jan Kara , John Hubbard , Andrew Morton , Jens Axboe , Miklos Szeredi , "Darrick J . Wong" , Trond Myklebust , Anna Schumaker , David Hildenbrand , Logan Gunthorpe , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, LKML Subject: Re: [PATCH v2 4/7] iov_iter: new iov_iter_pin_pages*() routines Message-ID: References: <20220914145233.cyeljaku4egeu4x2@quack3> <20220915081625.6a72nza6yq4l5etp@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664222129; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BCNxkn1cjjmSTz0F2QcnuWmtFkHDRw/dUVSXShbYPtk=; b=xauTB5eK08ZhWu9FlMP0xJqInICgCRoHB0k36FUcI+bvzoSHExUcpV5mByfO9/AvJl0ekb AKk2Ph/FpTLfUVimHgeK2dWYSCJEEq0Kw0wp080FjAlTPC9a336P2XyxtiA0xR3Qu2OecI /ZNuLNKBfR3k6krbppRgaxgcj/mMW30= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux.org.uk header.s=zeniv-20220401 header.b=ofdS4CZ7; dmarc=pass (policy=none) header.from=zeniv.linux.org.uk; spf=none (imf20.hostedemail.com: domain of viro@ftp.linux.org.uk has no SPF policy when checking 62.89.141.173) smtp.mailfrom=viro@ftp.linux.org.uk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664222129; a=rsa-sha256; cv=none; b=rTKs8u0U79fA6OaqxT9MFu4Od8xmW2acKwWP7yfUsKgcuXA8RlmY7d5EzELUvED9CFK8LF DVzblBCYltqkbLvozS3zBh+E4VsNoRMCtNGLvKzsfShg/MHc4LNyej1m/ZKsap3p5w+wTT wnf3bnxDg1wT6X1HBh9xcBGfS4XD79I= X-Rspam-User: Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.org.uk header.s=zeniv-20220401 header.b=ofdS4CZ7; dmarc=pass (policy=none) header.from=zeniv.linux.org.uk; spf=none (imf20.hostedemail.com: domain of viro@ftp.linux.org.uk has no SPF policy when checking 62.89.141.173) smtp.mailfrom=viro@ftp.linux.org.uk X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 6A55D1C0017 X-Stat-Signature: 4etfzefrw7uc8enyqtzpuzfrgxwbgxnx X-HE-Tag: 1664222129-668545 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Sep 26, 2022 at 08:53:43AM -0700, Christoph Hellwig wrote: > On Fri, Sep 23, 2022 at 05:13:42PM +0100, Al Viro wrote: > > You are mixing two issues here - holding references to pages while using > > iov_iter instance is obvious; holding them until async IO is complete, even > > though struct iov_iter might be long gone by that point is a different > > story. > > But someone needs to hold a refernce until the I/O is completed, because > the I/O obviously needs the pages. Yes, we could say the callers holds > them and can drop the references right after I/O submission, while > the method needs to grab another reference. But that is more > complicated and is more costly than just holding the damn reference. Take a look at __nfs_create_request(). And trace the call chains leading to nfs_clear_request() where the corresponding put_page() happens. What I'm afraid of is something similar in the bowels of some RDMA driver. With upper layers shoving page references into sglist using iov_iter_get_pages(), then passing sglist to some intermediate layer, then *that* getting passed down into a driver which grabs references for its own use and releases them from destructor of some private structure. Done via kref_put(). Have that delayed by, hell - anything, up to and including debugfs shite somewhere in the same driver, iterating through those private structures, grabbing a reference to do some pretty-print into kmalloc'ed buffer, then drooping it. Voila - we have page refs duplicated from ITER_BVEC and occasionally staying around after the ->ki_complete() of async ->write_iter() that got that ITER_BVEC. It's really not a trivial rule change.