Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp651781imc; Sun, 10 Mar 2019 17:26:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwf+Yje38fyXL2h+8bA4Gz9ApZt0K1aGf5rZd+9LR/l7OGLTVyL2UNMYJ9+W5N/wBrUimqT X-Received: by 2002:a63:4a62:: with SMTP id j34mr25886950pgl.97.1552264014355; Sun, 10 Mar 2019 17:26:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552264014; cv=none; d=google.com; s=arc-20160816; b=hFJjug6w7QiNpBzYNyyaTvZtWOKfnchWY2qCgzFaXEczNvA0O3i0Q/r4kE/+7TO2VX 4mp2iTwISEi9WVW00/JEBCQTJ6U2+YtXmKf8EM+UHRsVsj1jsL6eePLBXVxWyAmQ9bN3 vhBnZ8/jotsC4XdqHga6jOOaVFg2XIpgV8CV3ly7LsAJH/Ie+hUz1tltHaYD40c7xR/s 16u6GuzGMVaz2jDc4FPRfBkkstA0M7pmDaz/lwPwUC+cFWTiD8i87U4GDae8cLHj9usF LVTf5AtQPAc6WR6shOej4Xtg3Wcby0eOvz+uMYzVprDFOVr9ztgKHcO7MDn1qhXzdSbK fypg== 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; bh=UCUFSIa7ypNQ0JhntzOmZLHEn/A4vAEyAt7CKsL2rxw=; b=dOEDBRgOHnjfAN3ZoGHrjZHYA0EZYzK0epid8nyFXS0KASC2r2xaSAtQp/sBvMYLln Pfo5uSkcaw2tKcHz6r8mCxfCKr2LeNAbqrsNgE8w9sAUWHJQ9kLCfMWczjSx42sMhlX8 PlZHbRcAMZ584OxuI25FzaC5gZNS1v53XnjwWnt9VqUxuRybQUtzM5pyskF6hQ2Ymxnt VA32jcGq22S8yGKSlt4LW9uaF87t/5nBW5R+6vy7HWbg5SV8l+DRBO8Uochb53DZ5K8B nVwO5S4Bw6FwhfsTTf/In//R+8EJCbwK1LI7iAF9J72PlQmWQQbZJclktJ8JtoC4m6IW 9iqQ== ARC-Authentication-Results: i=1; mx.google.com; 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 bd12si3942094plb.337.2019.03.10.17.26.27; Sun, 10 Mar 2019 17:26:54 -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; 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 S1726974AbfCJWsA (ORCPT + 99 others); Sun, 10 Mar 2019 18:48:00 -0400 Received: from ipmail03.adl2.internode.on.net ([150.101.137.141]:50623 "EHLO ipmail03.adl2.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726758AbfCJWsA (ORCPT ); Sun, 10 Mar 2019 18:48:00 -0400 Received: from ppp59-167-129-252.static.internode.on.net (HELO dastard) ([59.167.129.252]) by ipmail03.adl2.internode.on.net with ESMTP; 11 Mar 2019 09:17:43 +1030 Received: from dave by dastard with local (Exim 4.80) (envelope-from ) id 1h37EM-000788-Dm; Mon, 11 Mar 2019 09:47:42 +1100 Date: Mon, 11 Mar 2019 09:47:42 +1100 From: Dave Chinner To: Christopher Lameter Cc: john.hubbard@gmail.com, Andrew Morton , linux-mm@kvack.org, Al Viro , Christian Benvenuti , Christoph Hellwig , Dan Williams , Dennis Dalessandro , Doug Ledford , Ira Weiny , Jan Kara , Jason Gunthorpe , Jerome Glisse , Matthew Wilcox , Michal Hocko , Mike Rapoport , Mike Marciniszyn , Ralph Campbell , Tom Talpey , LKML , linux-fsdevel@vger.kernel.org, John Hubbard Subject: Re: [PATCH v3 0/1] mm: introduce put_user_page*(), placeholder versions Message-ID: <20190310224742.GK26298@dastard> References: <20190306235455.26348-1-jhubbard@nvidia.com> <010001695b4631cd-f4b8fcbf-a760-4267-afce-fb7969e3ff87-000000@email.amazonses.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <010001695b4631cd-f4b8fcbf-a760-4267-afce-fb7969e3ff87-000000@email.amazonses.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 08, 2019 at 03:08:40AM +0000, Christopher Lameter wrote: > On Wed, 6 Mar 2019, john.hubbard@gmail.com wrote: > > Direct IO > > ========= > > > > Direct IO can cause corruption, if userspace does Direct-IO that writes to > > a range of virtual addresses that are mmap'd to a file. The pages written > > to are file-backed pages that can be under write back, while the Direct IO > > is taking place. Here, Direct IO races with a write back: it calls > > GUP before page_mkclean() has replaced the CPU pte with a read-only entry. > > The race window is pretty small, which is probably why years have gone by > > before we noticed this problem: Direct IO is generally very quick, and > > tends to finish up before the filesystem gets around to do anything with > > the page contents. However, it's still a real problem. The solution is > > to never let GUP return pages that are under write back, but instead, > > force GUP to take a write fault on those pages. That way, GUP will > > properly synchronize with the active write back. This does not change the > > required GUP behavior, it just avoids that race. > > Direct IO on a mmapped file backed page doesnt make any sense. People have used it for many, many years as zero-copy data movement pattern. i.e. mmap the destination file, use direct IO to DMA direct into the destination file page cache pages, fdatasync() to force writeback of the destination file. Now we have copy_file_range() to optimise this sort of data movement, the need for games with mmap+direct IO largely goes away. However, we still can't just remove that functionality as it will break lots of random userspace stuff... Cheers, Dave. -- Dave Chinner david@fromorbit.com