Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp906172imm; Mon, 9 Jul 2018 12:58:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc/0tgoBqZr+TrpPlcsIQoJfZumro8LrQybWeKMaJgaiJE1KHDDXQqtbV3ey/piMORm42Xm X-Received: by 2002:a62:642:: with SMTP id 63-v6mr22885623pfg.222.1531166327117; Mon, 09 Jul 2018 12:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531166327; cv=none; d=google.com; s=arc-20160816; b=tz/qXgsMYUQCAS5a4VGbH4JOw6Hc1rf57OvFX2iy+kjxmUSM2TDBgmJeUTHzREHrzi YSZs3j9izw/nd63ik5I3+Px+RWxBkpxGXHSQ+t8b/AGDiC7fdJvtGpOVhYDHwsFHsjgs mdYZQdT/Bp6DQumjPpkW+DsPqBbOckoIVRp9BECGtJIDcl7+Z2FvZXB0S7rw3Nny0QKU 70paegYigKVmmak0va298bspto4/UbRtYhqddSYnJR/FeHGu9jCb8OKnAPWiDx9rs7NH FnN8fWEV5sCpT5RsVYbdDHO3Tjghg0flW5LriKQd4J8D+M4FA0X0PO5pLHucZ2PLfIND rdJA== 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=Eokygey1pVhQjWXKAwh1ee2+cQo+fN3Vb38kP7diwoE=; b=hILVjinKjdMxPQM3PHa8RteJUvl1GzXCfCTLcxKuH7Z4g8zTAaLxhezLldOYg/xjjv myaK7fC6ynYZyzqooxhgrN+XreD0JMAqOroieeKVPESeV4JduqXq9EETSmfRLJz/f8N2 VmUobibR9x/+7B/39w12ym5NLub01p05fJvOq8Xw6RhVwQ86vlrb53iNDLV9GfiOzd7P YI876O3kIVpoG8sFx95MbYEkvyTCsEu2d9e0tY+qfjOPHlSAIuI+ioa7Yo+6Kwg6Gnky EPiWHXdvTbEdBdJla+kDchABW0VNys/lt41YNDx9OrUB5GmARB0NBRpwCWSAte6gxrmW w3Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=Ysb4dviD; 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 a1-v6si15256278plp.247.2018.07.09.12.58.32; Mon, 09 Jul 2018 12:58:47 -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=pass header.i=@ziepe.ca header.s=google header.b=Ysb4dviD; 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 S932993AbeGIT5G (ORCPT + 99 others); Mon, 9 Jul 2018 15:57:06 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:41061 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932764AbeGIT5E (ORCPT ); Mon, 9 Jul 2018 15:57:04 -0400 Received: by mail-wr1-f65.google.com with SMTP id j5-v6so5681687wrr.8 for ; Mon, 09 Jul 2018 12:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Eokygey1pVhQjWXKAwh1ee2+cQo+fN3Vb38kP7diwoE=; b=Ysb4dviDQ1OHdA9CUBRkpTBgRErDuxbOC+UBCSs31ZvEUgcBHttJnB1Fa2utuSqbrL QpnswF+E595ByHJBEf4glB5Q+qFtvknu8sCEXS9qFgpb+TvV4BCdQ6EaP8cLZft0zZcU oxqZxMtdY+x639V1ihv3+1VboJX8Y2p1sHlaOdKXL3fgfOq4p7A+BT8OQGe8hOIj0Voc WGwxJJQCAsbdguedFejOV9bhqWGGZptDm5NgEr6gA2DKA/g7OE1GHAGRjkPAKASs0VMI FJYZ0qb6WWAT+bLTMlQjHd8BvPh/YH8fwdT5wPmlYs0k6Ipv79ZZ9NEE8fbTmkwKl+7W DuMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Eokygey1pVhQjWXKAwh1ee2+cQo+fN3Vb38kP7diwoE=; b=tsFJI/qEV4iXNjPMHt3zHfK7C7dRguD81nyJee+yvc6J72iWpvoLwrOrGWMdCmEwD3 KuIlQ8BlYKLerTztlizv171G2QZZvxe+Qw9/Jt2GBUyPuJEzXr1rm6xjt7IrOV14lmHm WLjRuuMgK71SU0bpmdVfAqvilePcbutMWWDgqW+VMOCbTDCWUE/+v+LeEu0td2bqC9sp 8Uk7RQPSL2dpbXV4CiXHz64g25oL2+lbwKd25nwVrNb+GJx3joD2lanmr3mlZrwNQ/wX 4m3Y5CsnOc2BgtJwP66S1/7T6A+KnWpifkT+OH7ncA5LkLldy0qZsteIpc2L26TKvcO/ PvAQ== X-Gm-Message-State: APt69E0eMkT2JlwfDZHK+tsiZDxqocJcUk1NCnxv+CT8zQVWg8cKaXKY l/4HjMwR5EroZHdJOtmmev+QPg== X-Received: by 2002:a5d:46c6:: with SMTP id g6-v6mr14624626wrs.76.1531166223282; Mon, 09 Jul 2018 12:57:03 -0700 (PDT) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id o4-v6sm19383042wmo.20.2018.07.09.12.57.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 12:57:02 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1fccHJ-0001mr-Q3; Mon, 09 Jul 2018 13:56:57 -0600 Date: Mon, 9 Jul 2018 13:56:57 -0600 From: Jason Gunthorpe To: Jan Kara Cc: Matthew Wilcox , Nicholas Piggin , john.hubbard@gmail.com, Michal Hocko , Christopher Lameter , 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: <20180709195657.GA29026@ziepe.ca> References: <20180709080554.21931-1-jhubbard@nvidia.com> <20180709184937.7a70c3aa@roar.ozlabs.ibm.com> <20180709160806.xjt2l2pbmyiutbyi@quack2.suse.cz> <20180709171651.GE2662@bombadil.infradead.org> <20180709194740.rymbt2fzohbdmpye@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180709194740.rymbt2fzohbdmpye@quack2.suse.cz> User-Agent: Mutt/1.5.24 (2015-08-30) 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 09:47:40PM +0200, Jan Kara wrote: > On Mon 09-07-18 10:16:51, Matthew Wilcox wrote: > > 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. > > So what should be a result of fsync(file), where some 'file' pages are > pinned e.g. by running direct IO? If we just skip those pages, we'll lie to > userspace that data was committed while it was not (and it's not only about > data that has landed in those pages via DMA, you can have first 1k of a page > modified by normal IO in parallel to DMA modifying second 1k chunk). If > fsync(2) returns error, it would be really unexpected by userspace and most > apps will just not handle that correctly. So what else can you do than > block? I think as a userspace I would expect the 'current content' to be flushed without waiting.. If you block fsync() then anyone using a RDMA MR with it will just dead lock. What happens if two processes open the same file and one makes a MR and the other calls fsync()? Sounds bad. Jason