Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4926443imm; Tue, 19 Jun 2018 02:04:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK3DoEcIXy+Y+UPH/eciseGiFPGHViZGVwl5bVbGT+JgHQQ2rP8Vlg5CK3qXsAwAr+pD4W3 X-Received: by 2002:a63:3dcc:: with SMTP id k195-v6mr14134588pga.254.1529399085469; Tue, 19 Jun 2018 02:04:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529399085; cv=none; d=google.com; s=arc-20160816; b=kzB4aBiIH4IXK0aPgPJI9kh7QRGdZnLOMgPmaxiBKt+Otc4yiU4YFHpksX0f+Y//0D NkHGOrO7s/FSyv+8F0QC5ZDsdlMPPfT+qsEsRIdnchGR/BHj3osE5+WX5OINipCySRXH REJdDGhk15c2PMZF0Rx8iIzX226Cye+ifOztOw2MB5AQ4TXXKyOHEDp4GGCKUjaMsuye PtYJBlpA3FCefcF+MCvWlnB48IOJthvsg8bPvT1PNeiOFyJXjz2q6LzPCRwhgVRJF6Hn LVS4bNXcT4fjrYEMsiUwZC21wiz5MxFb+mc3iInVU9BGC01SfnyBtmymtXVsf3pIBhJM Ye+Q== 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=J0rYBzZdgJuklfSmS0e1qKxSub3Cx5Lqcz2HUrE9S7g=; b=GDf1Og2/FgI5I4Ey+P70gDGb6GDGjYo7FycWrhiQaeEecqNq57TeVo8/qZw3eV7mU8 Ny7ypVx2txOdqldTqmkTY5JaOObDnXSzGIsQDx5ctxjjdaR7zxmXctOLuN61LDq7szA2 x30k0Dz3YahjZK1sFyaKWEXIlWOcEC7+biPM94/imja9rF8d1zcrz5ezrlMRhO4eXO2Y TuEjl5fEIQr1jk1b8fzMsXIQsAazMukqzLH5ehFLmAuNHOaXpPdO3qivss6ey/UjA7BH xXeqDKOmKfhwDnxwgK0wiGVTEeEZkYXgXPUNOtu9ohFrgoevfyNA5wQ4qoLbyU2Z6tzA v3LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=dqXVPibe; 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 i1-v6si14130687pgc.100.2018.06.19.02.04.31; Tue, 19 Jun 2018 02:04:45 -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=dqXVPibe; 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 S937472AbeFSJDD (ORCPT + 99 others); Tue, 19 Jun 2018 05:03:03 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57990 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756178AbeFSJDB (ORCPT ); Tue, 19 Jun 2018 05:03:01 -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=J0rYBzZdgJuklfSmS0e1qKxSub3Cx5Lqcz2HUrE9S7g=; b=dqXVPibe5aTXn+LKzTfTylAla tCDh74WvAh7TCroDSjM+RJwQpXPTDv/1qZjidbVJobx6JOsVgflG+xJ+o+UpyoYgraNaaCndc3PDX yimhR9SzLsUZ5IPW/32gZAww27FXATtW5ObkL3LSwbWYEm4a4/cZL+9anZ8MWX5UkAiMVXmE6OHY8 UbU6Jf2TlEQqFA1e+gOBdrfx4sDv0N4fVXXObj6lqZkrIrwx32tCmCrNbO7jPJduiTm7ba/TyMumU fQ+lEGUId1bm3PtMPj9A82/Esn9BUN3FgnM54KsF5cbCuw/VizdC3ypxzdw/XvOZ6iOqHoMhf5Ogf CJd17sa2w==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVCXP-0008U6-Sw; Tue, 19 Jun 2018 09:02:55 +0000 Date: Tue, 19 Jun 2018 02:02:55 -0700 From: Matthew Wilcox To: Jan Kara Cc: John Hubbard , Dan Williams , Christoph Hellwig , Jason Gunthorpe , John Hubbard , Michal Hocko , Christopher Lameter , Linux MM , LKML , linux-rdma Subject: Re: [PATCH 2/2] mm: set PG_dma_pinned on get_user_pages*() Message-ID: <20180619090255.GA25522@bombadil.infradead.org> References: <20180617200432.krw36wrcwidb25cj@ziepe.ca> <311eba48-60f1-b6cc-d001-5cc3ed4d76a9@nvidia.com> <20180618081258.GB16991@lst.de> <3898ef6b-2fa0-e852-a9ac-d904b47320d5@nvidia.com> <0e6053b3-b78c-c8be-4fab-e8555810c732@nvidia.com> <20180619082949.wzoe42wpxsahuitu@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180619082949.wzoe42wpxsahuitu@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 Tue, Jun 19, 2018 at 10:29:49AM +0200, Jan Kara wrote: > And for record, the problem with page cache pages is not only that > try_to_unmap() may unmap them. It is also that page_mkclean() can > write-protect them. And once PTEs are write-protected filesystems may end > up doing bad things if DMA then modifies the page contents (DIF/DIX > failures, data corruption, oopses). As such I don't think that solutions > based on page reference count have a big chance of dealing with the > problem. > > And your page flag approach would also need to take page_mkclean() into > account. And there the issue is that until the flag is cleared (i.e., we > are sure there are no writers using references from GUP) you cannot > writeback the page safely which does not work well with your idea of > clearing the flag only once the page is evicted from page cache (hint, page > cache page cannot get evicted until it is written back). > > So as sad as it is, I don't see an easy solution here. Pages which are "got" don't need to be on the LRU list. They'll be marked dirty when they're put, so we can use page->lru for fun things like a "got" refcount. If we use bit 1 of page->lru for PageGot, we've got 30/62 bits in the first word and a full 64 bits in the second word.