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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FAKE_REPLY_A1, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 C2E0CC433DB for ; Tue, 2 Feb 2021 14:41:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 529BC64F4D for ; Tue, 2 Feb 2021 14:41:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 529BC64F4D Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B3C226B0070; Tue, 2 Feb 2021 09:41:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AC5096B0073; Tue, 2 Feb 2021 09:41:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B3B56B007B; Tue, 2 Feb 2021 09:41:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0072.hostedemail.com [216.40.44.72]) by kanga.kvack.org (Postfix) with ESMTP id 7F82F6B0070 for ; Tue, 2 Feb 2021 09:41:01 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4DC4F181AEF1A for ; Tue, 2 Feb 2021 14:41:01 +0000 (UTC) X-FDA: 77773589922.09.print57_3107b6d275cb Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 2D54E180AD801 for ; Tue, 2 Feb 2021 14:41:01 +0000 (UTC) X-HE-Tag: print57_3107b6d275cb X-Filterd-Recvd-Size: 5104 Received: from smtp-fw-4101.amazon.com (smtp-fw-4101.amazon.com [72.21.198.25]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Feb 2021 14:41:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1612276860; x=1643812860; h=to:cc:reply-to:from:subject:message-id:date:mime-version: content-transfer-encoding; bh=7cqYYP4R3zlI/x/sZSDd1rUQJzB7ynhIjJ2NKAncH6E=; b=UadXnr0U5YO0FqCNgSL5o0qny0FosAleZW9OEtZtqT2RaRW0xpY8Gc5r 4An/s/y9aGSQ0A0Q8wXhXVNvCtnGTCnyDotqz5CG574mpzMJK1UdynK/6 pcYpJNh2z4/YlM5EPv6Hg4oHEy4N/lPNSi52fNtRPoX4kVcpNGDGUVIpT 8=; X-IronPort-AV: E=Sophos;i="5.79,395,1602547200"; d="scan'208";a="79309769" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 02 Feb 2021 14:40:53 +0000 Received: from EX13D19EUB003.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com (Postfix) with ESMTPS id 39972A211B; Tue, 2 Feb 2021 14:40:47 +0000 (UTC) Received: from 8c85908914bf.ant.amazon.com (10.43.162.94) by EX13D19EUB003.ant.amazon.com (10.43.166.69) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 2 Feb 2021 14:40:38 +0000 To: Peter Xu , Jason Gunthorpe CC: Linus Torvalds , John Hubbard , 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 , "Zhang, Wei" Reply-To: <20200918161902.GX8409@ziepe.ca> From: Gal Pressman Subject: Re: [PATCH 1/4] mm: Trial do_wp_page() simplification Message-ID: <27564187-4a08-f187-5a84-3df50009f6ca@amazon.com> Date: Tue, 2 Feb 2021 16:40:33 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.43.162.94] X-ClientProxiedBy: EX13D04UWB004.ant.amazon.com (10.43.161.103) To EX13D19EUB003.ant.amazon.com (10.43.166.69) 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 17, 2020 at 03:03:32PM -0400, Peter Xu wrote: > >> Another side effect I can think of is that we'll bring some uncertainty to >> fork() starting from when page_maybe_dma_pinned() is used, since it's sometimes >> bogus (hpage_pincount_available()==false) so some COWs might be triggered >> during fork() even when not necessary if we've got some normal pages with too >> many refcounts (over GUP_PIN_COUNTING_BIAS). But assuming that's not a big >> deal since it should be extremely rare, or is it?.. > > Looking at this a bit more.. A complete implementation will have to > touch all four places doing write protect during fork: > > copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, > pte_t *dst_pte, pte_t *src_pte, struct vm_area_struct *vma, > unsigned long addr, int *rss) > { > [..] > if (is_cow_mapping(vm_flags) && pte_write(pte)) { > ptep_set_wrprotect(src_mm, addr, src_pte); > pte = pte_wrprotect(pte); > > int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, > pmd_t *dst_pmd, pmd_t *src_pmd, unsigned long addr, > struct vm_area_struct *vma) > { > [..] > pmdp_set_wrprotect(src_mm, addr, src_pmd); > pmd = pmd_mkold(pmd_wrprotect(pmd)); > > int copy_huge_pud(struct mm_struct *dst_mm, struct mm_struct *src_mm, > pud_t *dst_pud, pud_t *src_pud, unsigned long addr, > struct vm_area_struct *vma) > { > [..] > pudp_set_wrprotect(src_mm, addr, src_pud); > pud = pud_mkold(pud_wrprotect(pud)); > > int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, > struct vm_area_struct *vma) > { > [..] > if (cow) { > huge_ptep_set_wrprotect(src, addr, src_pte); > > As a regression I'm pretty sure we will hit only the PTE and PMD > cases. > > Most likely the other two could be done outside the rc cycle Hi Peter & Jason, It seems the hugetlb part was overlooked? We're testing if the RDMA fork MADV_DONTFORK stuff can be removed on appropriate kernels, but our tests still fail due to lacking explicit huge pages support [1]. Peter, was it left unchanged on purpose? Are you planning to submit the hugetlb changes as well? [1] https://github.com/linux-rdma/rdma-core/pull/883#issuecomment-770398171