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 31509C4727D for ; Thu, 24 Sep 2020 16:51:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8D0AA2395C 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/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D0AA2395C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9A7ED6B005C; Thu, 24 Sep 2020 12:51:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9300E6B005D; Thu, 24 Sep 2020 12:51:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D1916B0062; Thu, 24 Sep 2020 12:51:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id 642446B005C for ; Thu, 24 Sep 2020 12:51:55 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2A708824999B for ; Thu, 24 Sep 2020 16:51:55 +0000 (UTC) X-FDA: 77298546990.01.hand62_5c1753a27160 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 04E851004EF41 for ; Thu, 24 Sep 2020 16:51:54 +0000 (UTC) X-HE-Tag: hand62_5c1753a27160 X-Filterd-Recvd-Size: 5698 Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Thu, 24 Sep 2020 16:51:54 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id g3so3478989qtq.10 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=lp9d1LcXFtI7zPJnrNtYzNVRlCkMMp7+6kz2z6l6cQbx1++T5FKmW6yC1phRFTCsRR 98zhsGSTdYD4fZUq8qH43PpGzZ6q1CgeI+mEHGUwsUzd86yJamn0pE7m57CZie9jE6Ii arykdZA9EbOhI+sgbvFB9gCDwEJ1t0iLdPPmvotthff6zfmYVc69JsKX7cymj+mKKs16 s7gcsuSkxLaJk4HZ9/gPMO7Yx8aUM76s5jQwo9OMYRShJKUOCkX11dff3BZy0ncqY4pt h/CiY8LXhyAbmi6ne4ACY4NfS6v94fXCVXWuc94YhmKoaJwy0KHivl0Md6M+s6P+I+fr 5M3w== X-Gm-Message-State: AOAM533haqXtCsoJPoDHk/tvB1fcNbYQobWttcYL2RPko9DiSKVP3gyQ Ur/BFfz6Gcn+ZJ51Zi9OKIsv8w== 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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