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 3B45FECAAD8 for ; Fri, 23 Sep 2022 03:20:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C860E8000D; Thu, 22 Sep 2022 23:20:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C36968000A; Thu, 22 Sep 2022 23:20:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFE6D8000D; Thu, 22 Sep 2022 23:20:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A121E8000A for ; Thu, 22 Sep 2022 23:20:13 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 79A161C6180 for ; Fri, 23 Sep 2022 03:20:13 +0000 (UTC) X-FDA: 79941896706.29.FF68004 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) by imf15.hostedemail.com (Postfix) with ESMTP id EC301A000C for ; Fri, 23 Sep 2022 03:20:12 +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=Q+FM57iduMogJtSFwZB4LfTdEsChuEHae2/DVlkArcM=; b=sk/KR0xPUKPHHKWolvPzsqAt4o o9FlyBUe1wX2zq2RbXWaAJTiFJqpuaVPHn1hI4kFCMLxmK2i4rRcZyBQ7i8qSoGeGHFgdH3ZJ0UN5 dLNBxE5Tu66mnNUVk9JDrYHLUSZ5tR8FUBrd6EieY3EtTeOzsSdqmQkk2T5jFMG+0yVorDIOTv6BI x2e9UgKUZKYh/UhIHRV8YFxRZVu+ZhV9ughRdGArDVjBkXAu9QUFk9H7Msq1b4dF/F8zWJ6sfxbPX 1KW1gnVTo+E89ZNUi1kmPsIS+V0iIkxK6dzo7GQGwpv2V3hXCjpWSwrQMvlVc1ZMa41+fwRncsoTL 6/jkjISg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1obZE6-002eVa-0R; Fri, 23 Sep 2022 03:19:42 +0000 Date: Fri, 23 Sep 2022 04:19:42 +0100 From: Al Viro To: Jan Kara Cc: John Hubbard , Christoph Hellwig , 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: <20220906102106.q23ovgyjyrsnbhkp@quack3> <20220914145233.cyeljaku4egeu4x2@quack3> <20220915081625.6a72nza6yq4l5etp@quack3> <20220922112935.pep45vfqfw5766gq@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220922112935.pep45vfqfw5766gq@quack3> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663903213; a=rsa-sha256; cv=none; b=j0O98RDULtGmf0VitrF+CYj/hmd+5rwG1QqaCmCoBCWmDNaNONUANCZOb1OrhK8kD6tja6 VpsLs3qJ+XN5NHY5bHLAN1AO9H115aVHmUVn+WIqmeEwxs4nC1dCBWRzPIz+iRV6hfhbt/ UAWSzPC98NzGudOhD41o/T2Z3lzbJkc= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=linux.org.uk header.s=zeniv-20220401 header.b="sk/KR0xP"; dmarc=pass (policy=none) header.from=zeniv.linux.org.uk; spf=none (imf15.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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663903213; 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=Q+FM57iduMogJtSFwZB4LfTdEsChuEHae2/DVlkArcM=; b=m+Qa2sspBsKS+LBePkAtjV7LlutOjHWTVWDDCm8z/jSQaGhva790HMH//JjNZhl35sPDOh Im++eIUge/QaLG89+VWfWa6ozK/r/QBSaike3Gi0EpZSY2dacGr2Setv/X/RFJVw/26Nlv YiAngk/RyhlaV5EsW1RBd3uIsWTTwQ4= X-Rspamd-Server: rspam04 X-Rspam-User: X-Rspamd-Queue-Id: EC301A000C Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux.org.uk header.s=zeniv-20220401 header.b="sk/KR0xP"; dmarc=pass (policy=none) header.from=zeniv.linux.org.uk; spf=none (imf15.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-Stat-Signature: 6w7s5werp68s5a3oohd1ioig9g1rbrci X-HE-Tag: 1663903212-931104 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 Thu, Sep 22, 2022 at 01:29:35PM +0200, Jan Kara wrote: > > This rule would mostly work, as long as we can relax it in some cases, to > > allow pinning of both source and dest pages, instead of just destination > > pages, in some cases. In particular, bio_release_pages() has lost all > > context about whether it was a read or a write request, as far as I can > > tell. And bio_release_pages() is the primary place to unpin pages for > > direct IO. > > Well, we already do have BIO_NO_PAGE_REF bio flag that gets checked in > bio_release_pages(). I think we can easily spare another bio flag to tell > whether we need to unpin or not. So as long as all the pages in the created > bio need the same treatment, the situation should be simple. Yes. Incidentally, the same condition is already checked by the creators of those bio - see the assorted should_dirty logics. While we are at it - how much of the rationale around bio_check_pages_dirty() doing dirtying is still applicable with pinning pages before we stick them into bio? We do dirty them before submitting bio, then on completion bio_check_pages_dirty() checks if something has marked them clean while we'd been doing IO; if all of them are still dirty we just drop the pages (well, unpin and drop), otherwise we arrange for dirty + unpin + drop done in process context (via schedule_work()). Can they be marked clean by anyone while they are pinned? After all, pinning is done to prevent writeback getting done on them while we are modifying the suckers...