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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AB13C43334 for ; Fri, 15 Jul 2022 21:39:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF779940214; Fri, 15 Jul 2022 17:39:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA6109401FB; Fri, 15 Jul 2022 17:39:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6CCF940214; Fri, 15 Jul 2022 17:39:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A80EE9401FB for ; Fri, 15 Jul 2022 17:39:49 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7D23761642 for ; Fri, 15 Jul 2022 21:39:49 +0000 (UTC) X-FDA: 79690651698.22.658A9D3 Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) by imf27.hostedemail.com (Postfix) with ESMTP id 2AE044008A for ; Fri, 15 Jul 2022 21:39:49 +0000 (UTC) Received: by mail-io1-f44.google.com with SMTP id p128so4880712iof.1 for ; Fri, 15 Jul 2022 14:39:48 -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=JhgW6tL6FgjSZJKTGWDqu+tY+LLzUFXd6r8a/1eT44d87jzw8HJkpOlLC1riN17phX T7cU5NN+KUE6aD5H6m/yyeDnEaDTwWuU94ImChw2Tt5yFrddKdscqfD/Sl2VRRTa0jrL HEXaRhymvR7as5MYCM0ZfVJ9lgHqii8gRodqJyXXNd/0PG04aGXHLA6v0qjLubDxGKI2 +wN/tYdpTQsMrmqcel0hXpweC27e7sOTtXCQF6VtW8QAytSSovY054cjfF/+UGQGufQ4 PbKLSfbs8SOGxHyaIQS9lCG2MJkuc/J45aSMlYwYgcY42DwgWRYcakuouS2QmL0CMhel uQ1A== X-Gm-Message-State: AJIora8e5O+WjQ6lOQWIAmJTM7d320PIJ7N/s4wDQqA1R0qfNCaydeJA QqaYT8Pd8p0L9OHyNxz6Fe+jBy55VhIpMEY+Ch81tA== X-Google-Smtp-Source: AGRyM1tx9DmhVc6Le8ZEuPg6+4G/yQrWP+fnjYsp11lPImuBLrU6K1uGKVrIc7EmFI04BGNaPnRmiVG/oX22EU/qt2s= 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" ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=IJ2Q+vAc; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf27.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.166.44 as permitted sender) smtp.mailfrom=axelrasmussen@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657921189; a=rsa-sha256; cv=none; b=hirb1tdRSWeyKH7Y7g50pwXzMp/Ui8DlTQ3slLcY5XOXtIQ3ePiRIUALEMilXMfbBp5058 X6HLtMWhkI294AYcrrT2ryzvyqVsIxfRFm6R4hGOj5bs/V6iCGDC/zvDX+OhEDHoC7qoxn uB3RCkxxMCRqwayI6hz1TCQ7cSYFQko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657921189; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Uc9JvdGtnz1cDXKpEDUcIxRWMtP2VMyjnf747zqikT8=; b=GNB6R7OW4f9hxazZiLU3G0CdwMzk/IpbDmKKagw1OgVx/2CyejyhnT4La3ze/l3EqLH89w Q1QTucAxKvjGOPaJnMSVBwnFTuhzdc9SefuMQBq1YnBYvloWtn1+LBcTiXppB/aExOgfkq 5FMrDVKBgn6RWfGeMNMi8yaRWQOaJgM= Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=IJ2Q+vAc; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf27.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.166.44 as permitted sender) smtp.mailfrom=axelrasmussen@google.com X-Rspam-User: X-Stat-Signature: e7i9ecjhat1kxf6nuj1oju6teu4ofhwm X-Rspamd-Queue-Id: 2AE044008A X-Rspamd-Server: rspam03 X-HE-Tag: 1657921189-258732 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 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