Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp653079pxb; Tue, 2 Feb 2021 14:27:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcFkJUGRnYLov4JT8JiYgfjYpx1BjLTAMGZCriHi966dLwBqCh9BiLI0Csqwr7ykLtZN0y X-Received: by 2002:a05:6402:2690:: with SMTP id w16mr263907edd.304.1612304833575; Tue, 02 Feb 2021 14:27:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612304833; cv=none; d=google.com; s=arc-20160816; b=ft/7ppYMdWUtey9HWoftQ+qHivyGxlZRiEEGNFS37PrnGX/t4AVrQTTQRfdPm7Fejd gp21L72+if77Lz0TkxOSjtb3UQT3yWRv5/JiGQTzBAsvvH1pvrkwmx4w8sJGi4JjUkrm yWAYnSoUibnOhbg4f/AVNPevmtaVTfWgFiXhZ3VlCo3Xk5KGs3qOUuFEL5Yncgdwo0UB AD1x+zmgyMaIZ7hNU+rbGTnOgQh1knEtIGmpuDX5vKN8LJVc8xrj8QQVa/y8OR2qXB/E d95DbqtTEkMMdT9ulMch5u9Vea0A3dtXh/GzJtULgUkpKn1UMvIJ0ej4CEkU4KxdrwFx 7Uow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:user-agent:date:message-id:subject:from:reply-to:cc:to :dkim-signature; bh=7cqYYP4R3zlI/x/sZSDd1rUQJzB7ynhIjJ2NKAncH6E=; b=CHPjIoqpNlwJZwg1d8ng8ixe9MIeLNjc4D3hxz85ONLq9TfC5P7iONHeS4Ire3WqxD nE74d/d/518OrNljMzQui2LiwYz6KMiGXawIFg83qytp/ppy0i6l14MQAoONVuyEFp9S 31SzYdl08wsKBLLU0oP1xwyTNnCUTUU34OCN22mbhUCWZtPchf6N8T6aBz8mKimc+jOP SkyDP4XZ7nIjmdANJwj0T7l0I94YNg1GGdWaWiGZW8uB6zwKOws8DfHHDY1Eg/Jm5Pmn fADIsNEL52mj+dqr7AgGmNNpQnzABCsscNW+24NzYjLIgKzbkZE8IWvOXs6v6q05s0mk KYDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=cBgV+Ims; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y90si76526edy.314.2021.02.02.14.26.41; Tue, 02 Feb 2021 14:27:13 -0800 (PST) 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=@amazon.com header.s=amazon201209 header.b=cBgV+Ims; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232966AbhBBOnF (ORCPT + 99 others); Tue, 2 Feb 2021 09:43:05 -0500 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:61460 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234699AbhBBOlQ (ORCPT ); Tue, 2 Feb 2021 09:41:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1612276876; x=1643812876; h=to:cc:reply-to:from:subject:message-id:date:mime-version: content-transfer-encoding; bh=7cqYYP4R3zlI/x/sZSDd1rUQJzB7ynhIjJ2NKAncH6E=; b=cBgV+Ims3ttRvt3IuAvWRJ2dIHcCa/J9MpH/xS5ZChi9BXF1lJCJOxE8 hqWdvJKIvQedPiPoslcu6AFFcCx3iJrtN4jt6YVViAOnui+/biII+z40V VYZDq5iByiXp6kcaOWy94wcmOm0VIj++eJkxOSWG638xbrqFFbk3NaK7B s=; 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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