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=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 2CBEBC43461 for ; Tue, 15 Sep 2020 14:50:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6067B206DC for ; Tue, 15 Sep 2020 14:50:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jHD5cR06" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6067B206DC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7FE556B00E0; Tue, 15 Sep 2020 10:50:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 786E46B00E1; Tue, 15 Sep 2020 10:50:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6285590001B; Tue, 15 Sep 2020 10:50:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0049.hostedemail.com [216.40.44.49]) by kanga.kvack.org (Postfix) with ESMTP id 469F56B00E0 for ; Tue, 15 Sep 2020 10:50:50 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id DEA973645 for ; Tue, 15 Sep 2020 14:50:49 +0000 (UTC) X-FDA: 77265582618.06.camp19_5d021dd27112 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id A66F7100355DF for ; Tue, 15 Sep 2020 14:50:49 +0000 (UTC) X-HE-Tag: camp19_5d021dd27112 X-Filterd-Recvd-Size: 6268 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Sep 2020 14:50:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600181448; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0IeOuE/eucNmDyKjklVh+oXew31k55u++qjTKn6Ndgk=; b=jHD5cR069M8b56cukVxmfqSVKnH4nEwmNIcR0kJEtEpp09qmLlWQOWKPe+b+2ngMSNHwHa 8gBtgeMzWki1okzjlU/Wl49RYFnGGNwAsFx+N4jhs/0KYr01fZk62cuU4hZsanoSsAbnn7 DxVV7RCwGY5hqzn9mg0TLjNQ6uuOiGc= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-97-pfJQv3BKPR-vmkWB68a2QQ-1; Tue, 15 Sep 2020 10:50:43 -0400 X-MC-Unique: pfJQv3BKPR-vmkWB68a2QQ-1 Received: by mail-qv1-f70.google.com with SMTP id o14so2290764qve.7 for ; Tue, 15 Sep 2020 07:50:43 -0700 (PDT) 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=0IeOuE/eucNmDyKjklVh+oXew31k55u++qjTKn6Ndgk=; b=UVDZ27iwJwecpVM0g9XcoofFyWFNRbtu9bvqlKuGcyiWmheaav/hIA2jy1nXoBYhpG yyhQskAxUVsP7v/rM/y1CoM/cGqXY0KY2FJoJQlPa6FR1WBq8LoGfelfbZ6P9VZCC8ZI vyoeH5dYszR8jr6a/pF3227obP00o5amrhgnsLkJ+vY/CToUNBStYawBJzD1PYuwmxEW GrnQ1Vqxr+kOy5QccXlPPbKCXPEMucJKUG0QnY48FkrS4IqwwfWu///vmalsmt6a9Nie Re29cAWLp/moNc8ezoQBAhhyKbUEVWlheQdRE9wxcee0jiD61vAt8Sr2DCpKuYqUNs5F JPCQ== X-Gm-Message-State: AOAM531Rg7QtvqOiu17DPHRMLlj6j1FrhtGoQUjwoi7lxmP1V4F2/hwE eD0HNC8zVbZSg/sKHyCtzzA5SqzXD+vgzEKOsU6VQCv4gtjZJ9MLX0o6AyZgtBgRULe6eW2Ia4Y i18/y6qbZvBA= X-Received: by 2002:a37:a607:: with SMTP id p7mr17981470qke.118.1600181443290; Tue, 15 Sep 2020 07:50:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyX89VeEcyYah7vIMd6ubVQ5qehawQV+yskQYeFf8uxjnN6Ls8a2jrU0yhVlUOW3iBrQR8l0g== X-Received: by 2002:a37:a607:: with SMTP id p7mr17981446qke.118.1600181443033; Tue, 15 Sep 2020 07:50:43 -0700 (PDT) Received: from xz-x1 (bras-vprn-toroon474qw-lp130-11-70-53-122-15.dsl.bell.ca. [70.53.122.15]) by smtp.gmail.com with ESMTPSA id f24sm8179157qka.5.2020.09.15.07.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 07:50:42 -0700 (PDT) Date: Tue, 15 Sep 2020 10:50:40 -0400 From: Peter Xu To: Jason Gunthorpe Cc: Linus Torvalds , Leon Romanovsky , Linux-MM , Linux Kernel Mailing List , "Maya B . Gokhale" , Yang Shi , Marty Mcfadden , Kirill Shutemov , Oleg Nesterov , Jann Horn , Jan Kara , Kirill Tkhai , Andrea Arcangeli , Christoph Hellwig , Andrew Morton Subject: Re: [PATCH 1/4] mm: Trial do_wp_page() simplification Message-ID: <20200915145040.GA2949@xz-x1> References: <20200821234958.7896-1-peterx@redhat.com> <20200821234958.7896-2-peterx@redhat.com> <20200914143829.GA1424636@nvidia.com> <20200914183436.GD30881@xz-x1> <20200914211515.GA5901@xz-x1> <20200914225542.GO904879@nvidia.com> <20200914232851.GH1221970@ziepe.ca> MIME-Version: 1.0 In-Reply-To: <20200914232851.GH1221970@ziepe.ca> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Queue-Id: A66F7100355DF X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: Hi, all, I prepared another version of the FOLL_PIN enforced cow patch attached, just in case it would still be anything close to useful (though now I highly doubt it considering below...). I took care of !USERFAULTFD as suggested by Leon, and also the fast gup path. However... On Mon, Sep 14, 2020 at 08:28:51PM -0300, Jason Gunthorpe wrote: > Yes, this stuff does pin_user_pages_fast() and MADV_DONTFORK > together. It sets FOLL_FORCE and FOLL_WRITE to get an exclusive copy > of the page and MADV_DONTFORK was needed to ensure that a future fork > doesn't establish a COW that would break the DMA by moving the > physical page over to the fork. DMA should stay with the process that > called pin_user_pages_fast() (Is MADV_DONTFORK still needed with > recent years work to GUP/etc? It is a pretty terrible ancient thing) ... Now I'm more confused on what has happened. If we're with FORCE|WRITE, iiuc it should guarantee that the page will trigger COW during gup even if it is shared, so no problem on the gup side. Then I'm quite confused on why the write bit is not set when cow triggered. E.g., in wp_page_copy(), if I'm not wrong, the write bit is only controlled by (besides the fix patch, though I believe the rdma test should have nothing to do with uffd-wp after all so it should be the same anyways): entry = maybe_mkwrite(pte_mkdirty(entry), vma); It means, as long as the rdma region has VM_WRITE set (which I think of no reason on why it shouldn't...), then it should have the write bit in the COWed page entry. If so, the page should be stable and I don't undersdand why another COW could even trigger and how the code path in the "trial cow" patch is triggered. Or, the VMA is without VM_WRITE due to some reason? Sorry I probably know nothing about RDMA, more information on that side might help too. E.g., is the hardware going to walk the software process page table too when doing RDMA (or is IOMMU page table used, or none)? Thanks, -- Peter Xu