From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD1D1C4363D for ; Thu, 24 Sep 2020 16:51:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A13D22208 for ; Thu, 24 Sep 2020 16:51:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="Gq2CkCU/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728563AbgIXQvz (ORCPT ); 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-Google-Smtp-Source: ABdhPJxCjmf5BK+Jx3OZvHqqLVtzy1xfkcJEWZVBAiNudjZaGbj8d6kJUM9EMXaX9ojj8gbHS+RhuQ== 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