Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp469604pxk; Thu, 24 Sep 2020 09:55:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz85dPAHAkcbYW2pOBX3ZfyodGzIV4o4m9t1oydZaEWCgNxwRWOHjXsOUD+WH5BXk2xraZN X-Received: by 2002:a17:906:33d8:: with SMTP id w24mr849522eja.224.1600966537837; Thu, 24 Sep 2020 09:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600966537; cv=none; d=google.com; s=arc-20160816; b=o7tzZK1FHHHBvNksxSTvfa7CZjvC3cKYjIf2GhkNmuv8M30p2ECel2IqvnkTR2NIoW Lm7SxCa2Hxtqw8IdtbFh4bgdbhUCUgWuLTSCsUocSAdJlxUyrkmPKLmxlgvSK3D1AsNF EF4J9BpIG1h11t8aTtDyOFfbwV2UI+4+zkuOwDJO1hEY2+yhrxbntlK5cu3D4jNHRnaq GFq15uzPLypX8++wS1Dav5r2z7q+iw2t/zV4+R5I+SadFDb5L6zG3gj3GNFyMXVu3+O5 4DkCCoTYKL3V4po11+ijVyvO/LdV/mixCy1AFPcwK9UeaV5lG+c/b+LLidpl+9i/thU9 N/Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2HIyXx3s73LRrQkm+2xnUYOIMGnUAb5vPH458q/eHM0=; b=n39j750DWZPl+/1lgqUDKEbTxeUsaqxVQJ6rcVUImZbLViIWeM8N5+k8iia/KHrs1C E/y/yv4tiGCIryCMaFLcOpDjEkbqVAlKY2/4YWb8v/aIv6W7uy8zHOi3+4NI97SU9+1t mf4tGRR3xQQcPk3ur6UflnDJtJlH64wOFMA1IRsAdlB4MxvVBdEMm/Xwlz2Y0lTtgB2E V50Eq4nngYnylQKA74QhjysyTmD7PvdXCReYtD84P/DAXRAdkbauEp6OYX7sFe+29zSB Irg9+wA04pHcjTiKB7YrWMKNE2BbcI62Z4BsNmbuw5cpAvs1D+tJeCES06KBqnJzCbjz p2mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b="Gq2CkCU/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id by20si51797ejc.416.2020.09.24.09.55.13; Thu, 24 Sep 2020 09:55:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b="Gq2CkCU/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728548AbgIXQvz (ORCPT + 99 others); Thu, 24 Sep 2020 12:51:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726993AbgIXQvy (ORCPT ); Thu, 24 Sep 2020 12:51:54 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA3E2C0613CE for ; Thu, 24 Sep 2020 09:51:54 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id p65so3527651qtd.2 for ; Thu, 24 Sep 2020 09:51:54 -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; bh=2HIyXx3s73LRrQkm+2xnUYOIMGnUAb5vPH458q/eHM0=; b=Gq2CkCU/WyZ8U9hNjFyGbyFkvcjO2IImWCtlNVUwFsk4OSpRT2+Ky4ZbxhcCDzjD6B oYjO45xmtz0QBGgkzoUXJHwwvYWyJCHHI0ppI7NyH8Y75C1KnRCfOlMBfol31Sx+U2P0 b4euqbEfeTluR4QA0tF55NF3HBeiudHAz7KH/Qye52L5i8LUQE9QW4Dcho02AmXs4HAJ 9bL19BsXzDzayge1UqgbS0l8ooJ1QIAM0qYBDK4mxzv3JmQg5bhz2hEXMgiXhCaAhbNi YMCUviz/wBdE+prxnw9QtQtC4IUoGSeelRDljLQljzo1CKEQYeADvKz8s3jYvKmdfpF2 UcYw== 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; bh=2HIyXx3s73LRrQkm+2xnUYOIMGnUAb5vPH458q/eHM0=; b=gmyDSek2WjgxkidwC6DK+ln3NusJunBlqV2OdposL7VwSbefhKJkilwaZmSTIcEKGO xhvU6MxGPfHC+Gbw4Y040DXtjT3BP/YCf/ofvUgC/U4VriRTy7BFB8Rsin7iTf+VRx9Z HrcW8rixftD/8c1NKqVkWTwGuE8k/yB15LM0TFyiDirh4M0+AbRw1mWQbhC7hKF9mhN9 P65ZHRNk+omV0KHvhydbSpBzu/PfL/1K5eWTdHBORhT5+oy/+nC3Bif+qwLA08G3MbWg p8WUWO9eoX9y5kDWWAeLgafrTPx7hLXbckV7rA8fehuGrxrmW7UXZIJ9ruCWtAGg7lVH btcQ== X-Gm-Message-State: AOAM530ts6/1GJDTOc494I38hzqPIvy04WYTRGMRcqeFJJpbjFnuvqxA 8pRr/QrRrrZFIyHNoILebsIc/g== X-Received: by 2002:ac8:6ec2:: with SMTP id f2mr482171qtv.159.1600966313832; Thu, 24 Sep 2020 09:51:53 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id c28sm62266qtk.18.2020.09.24.09.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 09:51:53 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kLUTI-000NmG-1K; Thu, 24 Sep 2020 13:51:52 -0300 Date: Thu, 24 Sep 2020 13:51:52 -0300 From: Jason Gunthorpe To: Peter Xu Cc: John Hubbard , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Jan Kara , Michal Hocko , Kirill Tkhai , Kirill Shutemov , Hugh Dickins , Christoph Hellwig , Andrea Arcangeli , Oleg Nesterov , Leon Romanovsky , Linus Torvalds , Jann Horn Subject: Re: [PATCH 1/5] mm: Introduce mm_struct.has_pinned Message-ID: <20200924165152.GE9916@ziepe.ca> References: <20200921211744.24758-1-peterx@redhat.com> <20200921211744.24758-2-peterx@redhat.com> <224908c1-5d0f-8e01-baa9-94ec2374971f@nvidia.com> <20200922151736.GD19098@xz-x1> <20200922161046.GB731578@ziepe.ca> <20200922175415.GI19098@xz-x1> <20200922191116.GK8409@ziepe.ca> <20200923002735.GN19098@xz-x1> <20200923170759.GA9916@ziepe.ca> <20200924143517.GD79898@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200924143517.GD79898@xz-x1> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 24, 2020 at 10:35:17AM -0400, Peter Xu wrote: > If so, I'd hope you won't disagree that I still move the get_page() out of the > "if (wp)". Not only it's a shared operation no matter whether "if (wp)" or > not, but I'm afraid it would confuse future readers on a special ordering on > the get_page() and the wrprotect(), especially with the comment above. Sure, you could add a comment before the page_maybe_dma_pinned that it could be fused with get_page() > Yes. It's kind of related here on whether we can still use wrprotect() to > guard against fast-gup, though. So my understanding is that we should still at > least need the other patch [1] that I proposed in the other thread to force > break-cow for read-only gups (that patch is not only for fast-gup, of course). Probably, I haven't intensively studied that patch, and it should go along with edits to some of the callers.. > But I agree that should be another bigger topic. I hope we don't need to pick > that patch up someday by another dma report on read-only pinned pages... In RDMA we found long ago that read only pins don't work well, I think most other places are likely the same - the problems are easy enough to hit. Something like your COW break patch on read is really needed to allow read-only GUP. > Regarding the solution here, I think we can also cover read-only fast-gup too > in the future - IIUC what we need to do is to make it pte_protnone() instead of > pte_wrprotect(), then in the fault handler we should identify this special > pte_protnone() against numa balancing (change_prot_numa()). I think it should > work fine too, iiuc, because I don't think we should migrate a page at all if > it's pinned for any reason... With your COW breaking patch the read only fast-gup should break the COW because of the write protect, just like for the write side. Not seeing why we need to do something more? Jason