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=-8.1 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,USER_AGENT_GIT autolearn=unavailable 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 79C3AC47420 for ; Fri, 25 Sep 2020 22:26:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0A7712087D for ; Fri, 25 Sep 2020 22:26:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RMnv/OIB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A7712087D 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 B239F8E0001; Fri, 25 Sep 2020 18:26:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD2066B0068; Fri, 25 Sep 2020 18:26:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99C356B006C; Fri, 25 Sep 2020 18:26:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0164.hostedemail.com [216.40.44.164]) by kanga.kvack.org (Postfix) with ESMTP id 740486B0062 for ; Fri, 25 Sep 2020 18:26:02 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3F557180AD801 for ; Fri, 25 Sep 2020 22:26:02 +0000 (UTC) X-FDA: 77303017764.17.page71_03010032716b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 1D183180D0184 for ; Fri, 25 Sep 2020 22:26:02 +0000 (UTC) X-HE-Tag: page71_03010032716b X-Filterd-Recvd-Size: 6069 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Fri, 25 Sep 2020 22:26:01 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601072760; 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: content-transfer-encoding:content-transfer-encoding; bh=Sqcc8E/FBubArGSFgfBSxlBTWt3GinXqSL7UaMZLslE=; b=RMnv/OIBBmxL66CzP1iIPc/qCx0M6DnfjPbSW1IqrwmVvjUDtsnutd25ZOTE5G7F65JYJN Y2ZoJQsNvWdc7d1oJ9dmfAXOgnMyCI/Y7Lx1x6LJtOZKq75Zl76QVBWP7UDzQBr6SNs97w Wc28OlpW6lSws9HKMKbNlp9UTnOeDag= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-356-ydywjfFkMvC0FtVTGTHCnA-1; Fri, 25 Sep 2020 18:25:57 -0400 X-MC-Unique: ydywjfFkMvC0FtVTGTHCnA-1 Received: by mail-qk1-f198.google.com with SMTP id y17so3203550qky.0 for ; Fri, 25 Sep 2020 15:25:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Uo8gGRWpJjLrjEh3kZPQ0+a+t3L+ZpORnheEJIOtEYM=; b=nD4oyScZQmRqeCpR1Ky5JfuiNMUO4bHG7GTKKWEOu4nZYsXrErT/vs64xz+VfBM/Km 0+fD4xREx3k5UL5QEdFz58b+t8Y9P+Lu4ho6p4myuRhyYnw2+BCXH2yLZTCXI8a268es w8chNtQlfs6mkOvUnxgvh2AtpGkztXpOOjtcSfruW63AjUzuBaD+/qrEA2yf4L6iRT4N 5PxGbKAWvoVlr8aNx73XGBxys9l+PnJdEj7MHGtfFmG63+ip1DKKamSHCeqdySeF3FIj X14D3KQOyz+eDFKLyWkEOqUc3UGqYTumyOpnUaejCh1oJLTHMTt/mIKxgvP8u76vIyrP bscg== X-Gm-Message-State: AOAM5314IbTUgnzNcFXV3XepUq/JJ9yYvGW7JzpuQfGmFCWnDeJKX3Af Lmwbc/XEtfTvLfNTvE4QdlFjbeaYry8zVw83p/Y0kwrAJG0rJk1fIcjkrNigU0UIin6S3d3eG+f LGvN539vHngk= X-Received: by 2002:a05:620a:63a:: with SMTP id 26mr2277810qkv.68.1601072756655; Fri, 25 Sep 2020 15:25:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxud43W52mkUiayJyz6fs8bzW3AvKTzd0bsDmScGL2fbyiqdiPNW70YHqtR360OXHRhUoTzzA== X-Received: by 2002:a05:620a:63a:: with SMTP id 26mr2277774qkv.68.1601072756331; Fri, 25 Sep 2020 15:25:56 -0700 (PDT) Received: from localhost.localdomain (bras-vprn-toroon474qw-lp130-11-70-53-122-15.dsl.bell.ca. [70.53.122.15]) by smtp.gmail.com with ESMTPSA id w44sm3051471qth.9.2020.09.25.15.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Sep 2020 15:25:55 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: peterx@redhat.com, Jason Gunthorpe , John Hubbard , Andrew Morton , Christoph Hellwig , Yang Shi , Oleg Nesterov , Kirill Tkhai , Kirill Shutemov , Hugh Dickins , Jann Horn , Linus Torvalds , Michal Hocko , Jan Kara , Andrea Arcangeli , Leon Romanovsky Subject: [PATCH v2 0/4] mm: Break COW for pinned pages during fork() Date: Fri, 25 Sep 2020 18:25:56 -0400 Message-Id: <20200925222600.6832-1-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: Due to the rebase to latest rc6, the major pte copy patch changed a lot. S= o=0D maybe not that useful to write a changelog any more. However all the comme= nts=0D should be addressed as long as discussed in previous thread. Please shoot = if I=0D missed anything important.=0D =0D This series is majorly inspired by the previous discussion on the list [1],= =0D starting from the report from Jason on the rdma test failure. Linus propos= ed=0D the solution, which seems to be a very nice approach to avoid the breakage = of=0D userspace apps that didn't use MADV_DONTFORK properly before. More informa= tion=0D can be found in that thread too.=0D =0D I tested it myself with fork() after vfio pinning a bunch of device pages, = and=0D I verified that the new copy pte logic worked as expected at least in the m= ost=0D general path. However I didn't test thp case yet because afaict vfio does = not=0D support thp backed dma pages. Luckily, the pmd/pud thp patch is much more= =0D straightforward than the pte one, so hopefully it can be directly verified = by=0D some code review plus some more heavy-weight rdma tests.=0D =0D Patch 1: Introduce mm.has_pinned=0D Patch 2: Preparation patch=0D Patch 3: Early cow solution for pte copy for pinned pages=0D Patch 4: Same as above, but for thp (pmd/pud).=0D =0D Hugetlbfs fix is still missing, but as planned, that's not urgent so we can= =0D work upon. Comments greatly welcomed.=0D =0D [1] https://lore.kernel.org/lkml/20200914143829.GA1424636@nvidia.com/=0D =0D Thanks.=0D =0D Peter Xu (4):=0D mm: Introduce mm_struct.has_pinned=0D mm/fork: Pass new vma pointer into copy_page_range()=0D mm: Do early cow for pinned pages during fork() for ptes=0D mm/thp: Split huge pmds/puds if they're pinned when fork()=0D =0D include/linux/mm.h | 2 +-=0D include/linux/mm_types.h | 10 +++=0D kernel/fork.c | 3 +-=0D mm/gup.c | 6 ++=0D mm/huge_memory.c | 28 ++++++=0D mm/memory.c | 186 ++++++++++++++++++++++++++++++++++-----=0D 6 files changed, 212 insertions(+), 23 deletions(-)=0D =0D --=20=0D 2.26.2=0D =0D