Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp911085imw; Fri, 15 Jul 2022 15:34:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u0wmFmjr8XL4nZk3PnvmDlS9B6yL8DwEp8W3648FsDFM3RSE2HS5BaJTTq8gPf7bBenK8X X-Received: by 2002:a63:1220:0:b0:411:f661:f819 with SMTP id h32-20020a631220000000b00411f661f819mr14402945pgl.250.1657924471928; Fri, 15 Jul 2022 15:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657924471; cv=none; d=google.com; s=arc-20160816; b=jqSz5C5XOUlBq4O0T2OLThgCd49ft3JC8U/0LGr0SAVZMG/dTXHEDizr5W4NcTiKmU 3B/RlLosOY2nWvYOrNco6WwsQ0MVHOFrEJ8yJy1ik2oXSaqXownDz4FuZ9DgP2HziKlM XWOIpxOvaSLss8wlxKi54XfKbRTqzsSyAPHxI67Z8RZ8W2ypGYWagWV5ekYXP5J6fDRD tOMzuaPkczCArrrjmoKRFu3oxAVcBdcRoCnZsk+2HUGgnInW8FR2nLZBE9gMuN4eGxsd rB5ULwPIJARrTk/0PRyIDn7esd+dXgDjMH5DRnHKDw7vOVNqpt/JHmXdVI0YBU9AJvYm v8fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Uc9JvdGtnz1cDXKpEDUcIxRWMtP2VMyjnf747zqikT8=; b=apVRPEMnux8b5utxcMQd5NGEx1a70QRM5eM1UjLJUHuXxfNuvfLz45i7pKDpzPDm+b 6zJoJKNNV80LueUp4H7FIDytYvEOZT41J+6Yd/nWJkp9zmGpHBXzVxIck1Zlqq5Ehv9V 5JpP39tRO05Tv0XtCvMXhFxmOKGCEIqU+/bPUUvtjsJd/OKOtL2AwsFFE0Cop38uks64 A/uzQohR7mZZpyBGm9hfqnu8rvDpSitfEzN8iLzK94LNWjmiGF95J2apcxHLRVuZAarD 7gncn/YSRQrkaHEBikcIayJRQrQDWUyRx+J7htyRFoGO/IlRWhBdRna54gyoTMDh87My R6uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=IJ2Q+vAc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ck7-20020a056a00328700b0051bbac76b99si6087470pfb.195.2022.07.15.15.34.16; Fri, 15 Jul 2022 15:34:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=IJ2Q+vAc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231699AbiGOVjv (ORCPT + 99 others); Fri, 15 Jul 2022 17:39:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229955AbiGOVjt (ORCPT ); Fri, 15 Jul 2022 17:39:49 -0400 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FC3A45F74 for ; Fri, 15 Jul 2022 14:39:49 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id u6so4872640iop.5 for ; Fri, 15 Jul 2022 14:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Uc9JvdGtnz1cDXKpEDUcIxRWMtP2VMyjnf747zqikT8=; b=IJ2Q+vAcfQe9RtZffLh4MCy7kJfCZmgPGturk9SuapdVnvK2bDmK6MJJxytIcIgDbX 3+fQ04LCQS6ZVbpSOdlTBQg9Kw8KSVVZgV4a1G6OqoDFcMv7ocgmeigy2qIYASFqmJcf JRafmCUDHDp7WRDTAoJmqlfE1rsIr2PvE8TcxPtJirJnMkcUV5Mq67xJY2PjHiT+mwM0 fMXT/WYl9hmU4W6mT/1fhIRdPAZ9kc1F7G2eL2uzmehQWIKIciAKG4zzFVj621a8WOEe CUdNbsaxRAJP7j7qt8gpQdEG+z8hrvm799iBGjiccZgoZEJ0dZAzAYFPtQPdHN9v6+cC eE/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Uc9JvdGtnz1cDXKpEDUcIxRWMtP2VMyjnf747zqikT8=; b=a6PfPf0aMahSi1TSWcCmVBWB0m6uPF++ENlmtwrgzYuopTJlpsisocIXsjyqMnKRRE 2JnMhINUvDmgkzj+qxLtOtimSGddo+vqvEU9u5YEskYJ797QrRPzTQQzpA/4ZnEHl0i9 MOpaPFl+UP6sIeMok50ZaANxbUu+BnbMfeOff+ioZlGtAZljg78qRcgyB/I9WlHORORq iFDUyTg3z76wMwku3xKc42z0WLfzduz3rLVNnlYq7foIaCB26DS1U/sKvGmmRFY+ulyw MWjSxo1VMuGPQNgstuYR1zcSZhJfjjY65EKm6Yww/P2DHCvZmcWMAkUpJmDIPGJ2d8co tdTg== X-Gm-Message-State: AJIora9e9iCM9lLu3LHQZ2IDqDaTR3W98VsF5f41wc5C7r2xv+TpoSrA fiRPQB0L6/20pKtVXW/gv7V+NIgHYecKnnIskZf1JQ== X-Received: by 2002:a05:6602:1644:b0:678:8ba4:8df6 with SMTP id y4-20020a056602164400b006788ba48df6mr7849416iow.138.1657921188370; Fri, 15 Jul 2022 14:39:48 -0700 (PDT) MIME-Version: 1.0 References: <20220624173656.2033256-1-jthoughton@google.com> <20220624173656.2033256-20-jthoughton@google.com> In-Reply-To: From: Axel Rasmussen Date: Fri, 15 Jul 2022 14:39:12 -0700 Message-ID: Subject: Re: [RFC PATCH 19/26] hugetlb: add HGM support for copy_hugetlb_page_range To: Mike Kravetz Cc: James Houghton , Muchun Song , Peter Xu , David Hildenbrand , David Rientjes , Mina Almasry , Jue Wang , Manish Mishra , "Dr . David Alan Gilbert" , Linux MM , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 12, 2022 at 11:07 AM Mike Kravetz wrote: > > On 07/12/22 10:19, James Houghton wrote: > > On Mon, Jul 11, 2022 at 4:41 PM Mike Kravetz wrote: > > > > > > On 06/24/22 17:36, James Houghton wrote: > > > > This allows fork() to work with high-granularity mappings. The page > > > > table structure is copied such that partially mapped regions will remain > > > > partially mapped in the same way for the new process. > > > > > > > > Signed-off-by: James Houghton > > > > --- > > > > mm/hugetlb.c | 74 +++++++++++++++++++++++++++++++++++++++++----------- > > > > 1 file changed, 59 insertions(+), 15 deletions(-) > > > > > > FYI - > > > With https://lore.kernel.org/linux-mm/20220621235620.291305-5-mike.kravetz@oracle.com/ > > > copy_hugetlb_page_range() should never be called for shared mappings. > > > Since HGM only works on shared mappings, code in this patch will never > > > be executed. > > > > > > I have a TODO to remove shared mapping support from copy_hugetlb_page_range. > > > > Thanks Mike. If I understand things correctly, it seems like I don't > > have to do anything to support fork() then; we just don't copy the > > page table structure from the old VMA to the new one. > > Yes, for now. We will not copy the page tables for shared mappings. > When adding support for private mapping, we will need to handle the > HGM case. > > > That is, as > > opposed to having the same bits of the old VMA being mapped in the new > > one, the new VMA will have an empty page table. This would slightly > > change how userfaultfd's behavior on the new VMA, but that seems fine > > to me. > > Right. Since the 'mapping size information' is essentially carried in > the page tables, it will be lost if page tables are not copied. > > Not sure if anyone would depend on that behavior. > > Axel, this may also impact minor fault processing. Any concerns? > Patch is sitting in Andrew's tree for next merge window. Sorry for the slow response, just catching up a bit here. :) If I understand correctly, let's say we have a process where some hugetlb pages are fully mapped (pages are in page cache, page table entries exist). Once we fork(), we in the future won't copy the page table entries, but I assume we do setup the underlying pages for CoW still. So I guess this means in the old process no fault would happen if the memory was touched, but in the forked process it would generate a minor fault? To me that seems fine. When userspace gets a minor fault it's always fine for it to just say "don't care, just UFFDIO_CONTINUE, no work needed". For VM migration I don't think it's unreasonable to expect userspace to remember whether or not the page is clean (it already does this anyway) and whether or not a fork (without exec) had happened. It seems to me it should work fine. > -- > Mike Kravetz