Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp771314imm; Mon, 9 Jul 2018 10:18:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfE7AmuFsnQu/krOmGr9AQAcaWL9bD5A86LfR0tLQyf5IwfzbXZZlOQlaIM1BK8K5YgbQYq X-Received: by 2002:a63:314f:: with SMTP id x76-v6mr19315846pgx.373.1531156692265; Mon, 09 Jul 2018 10:18:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531156692; cv=none; d=google.com; s=arc-20160816; b=kyFkIzIUjauveu//yIPpRbvJ9Xa46lgjHA5tfXqgzF5dyS+hgdJdFEKt2JpZoidOVV CvN/yFnq88AvuHaY1Q7YgaHrt7RpbxGL7niHDYoU3QFNhceg0sFGWeqFkQDmRWnoLdwm q7/AtOKMZALtVq5GfOMPugYZ0u1Xi0F3qjj5L8A3GGVFTWG3Gj0QDXC7vWGs6rOi15+/ pWlf/2LbSJuttMvy8/wXzXEFNMyYVZkFFLYWsEXme7rN8UiaOp4R5WXc7bpbqn7oDn2r +n/o4a67wAH/GgckXXC8bq2VkroGna08GYg2kVM1IMmcq2BYu2/7IXSzE+P+UxdF9BSI uFzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=Vtl3Y9imDZmQ7+6XdYG00VazHoTvtH5RQr2hn6d4imY=; b=cpzGXcGuiXNLxyEihBUf/Ogstpmxkm5nw/uRYZ5eLk1bTZfPMrzTTgdFL54FN3ci6C f/kS4rXIzXQ8cUbMb6amfoVyNr5KYMzXqIOFfy6e3xQfTMYiLe8k+eYG9lpaVCln8cxz qxsLIGsXech6z8kq1X9SyJTZnqaAqyy0PMVGph6527B/371Kp4sP58jhal4p0B5z03TQ uy29ExWybhsBg8bU0AAt/2RLtrgp3wkoN/Q0Y38LsfE8FuEMP3jXwZ8Q6qrWpWYuLDtY llLuiiftPd+1PiWXgRb2Zglb1C3/MT91j1xlyGpzh13bJGLOBWKsq+GM4hKEWwp5trX7 qUKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Cb+PKYnA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v38-v6si14282253pgn.431.2018.07.09.10.17.57; Mon, 09 Jul 2018 10:18:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Cb+PKYnA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933686AbeGIRRA (ORCPT + 99 others); Mon, 9 Jul 2018 13:17:00 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:52416 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933360AbeGIRQ7 (ORCPT ); Mon, 9 Jul 2018 13:16:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Vtl3Y9imDZmQ7+6XdYG00VazHoTvtH5RQr2hn6d4imY=; b=Cb+PKYnAgMYYwZo8dDaMNOpqb tIm5lwTQEYAu/nz7O/FFVIDN08vHZmLfzV5/Qm4OmN7p/itbkWC7Ytfd3MyBGxprk0twIgzjHbDB0 jtSiqhnJeIgW6WYnJ29EQS4WJe5RlNIQSDNdX41hyQqFSsmqs1titXJm4giB60bKiyT/mTPITgURB o+bsIGefgYP+fIjrq+vE6CuWmnpxsR3hTWMoxjWJA4mXVBE1H/9iAQOSyxgtBTQgmpOPeHzCNWTQI BA583gSswYh5y1+QEmLNiJWErMYGp4WE5J4H4A1PtZhXCqmAzoWiM5397SuOpuDj/kQbkL00mv3Xu BaabcpjxQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fcZmP-0000aa-2m; Mon, 09 Jul 2018 17:16:53 +0000 Date: Mon, 9 Jul 2018 10:16:51 -0700 From: Matthew Wilcox To: Jan Kara Cc: Nicholas Piggin , john.hubbard@gmail.com, Michal Hocko , Christopher Lameter , Jason Gunthorpe , Dan Williams , Al Viro , linux-mm@kvack.org, LKML , linux-rdma , linux-fsdevel@vger.kernel.org, John Hubbard Subject: Re: [PATCH 0/2] mm/fs: put_user_page() proposal Message-ID: <20180709171651.GE2662@bombadil.infradead.org> References: <20180709080554.21931-1-jhubbard@nvidia.com> <20180709184937.7a70c3aa@roar.ozlabs.ibm.com> <20180709160806.xjt2l2pbmyiutbyi@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180709160806.xjt2l2pbmyiutbyi@quack2.suse.cz> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 09, 2018 at 06:08:06PM +0200, Jan Kara wrote: > On Mon 09-07-18 18:49:37, Nicholas Piggin wrote: > > The problem with blocking in clear_page_dirty_for_io is that the fs is > > holding the page lock (or locks) and possibly others too. If you > > expect to have a bunch of long term references hanging around on the > > page, then there will be hangs and deadlocks everywhere. And if you do > > not have such log term references, then page lock (or some similar lock > > bit) for the duration of the DMA should be about enough? > > There are two separate questions: > > 1) How to identify pages pinned for DMA? We have no bit in struct page to > use and we cannot reuse page lock as that immediately creates lock > inversions e.g. in direct IO code (which could be fixed but then good luck > with auditing all the other GUP users). Matthew had an idea and John > implemented it based on removing page from LRU and using that space in > struct page. So we at least have a way to identify pages that are pinned > and can track their pin count. > > 2) What to do when some page is pinned but we need to do e.g. > clear_page_dirty_for_io(). After some more thinking I agree with you that > just blocking waiting for page to unpin will create deadlocks like: Why are we trying to writeback a page that is pinned? It's presumed to be continuously redirtied by its pinner. We can't evict it. > ext4_writepages() ext4_direct_IO_write() > __blockdev_direct_IO() > iov_iter_get_pages() > - pins page > handle = ext4_journal_start_with_reserve(inode, ...) > - starts transaction > ... > lock_page(page) > mpage_submit_page() > clear_page_dirty_for_io(page) -> blocks on pin I don't think it should block. It should fail.