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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D4601C87FD6 for ; Thu, 29 Aug 2024 20:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:In-Reply-To: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=a6YgJDRtCG6NqNHvxBGwLph56rsiY6btQEOiIVWjksU=; b=dWm2I47+OaMLAn9b0YquFv1VhV z/ocns+IIgrHYJHzLWMioavB6nrtTJuzICuDqlXtRiIEMc4cHBBLTWzmDkow6ncJpBtjeTI6Ws6EM sF4uHm0tm+ZPgkcN5OZ/Dwadyhe8Qx+wtSRvxF5l4M6s+1iA+xY6uP3ff8f7SBVLJYQ9VBGP5soiu Xx3O9xlGlHpLTD3CkGCa9txaTsUy0bZcYDLTb7VjbsOkESbxIhAq3BqgI/qjMiAwgamavpthfQzYD Fwpx1syNOGRJZdjNB4PlPYr3bduob36dB4Uuq9bbMOkfPklyXCIVb6SVVF3nNvSskzzZEKYECWGuy prSHKNjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjlLU-00000003TXK-2CyF; Thu, 29 Aug 2024 20:02:16 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjlKc-00000003TPn-44vC for linux-arm-kernel@lists.infradead.org; Thu, 29 Aug 2024 20:01:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724961681; 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: in-reply-to:in-reply-to:references:references; bh=a6YgJDRtCG6NqNHvxBGwLph56rsiY6btQEOiIVWjksU=; b=E7PHpqbMkdOfmPVdbwmHFOvXEmwTZuM3hgJKeR3EfaH/WF9P4BFezWc9TnvLFyvydmKFcn 0SDdQ24WEXU4YST3yFhj5ffFRQfQ7uirv0upcZ86b5BAIELInjx2qyAFcW5xvDO+Mjbtlp NgyDLTFaHP7iKrWM2vYZbsKKOeUQDh4= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-14-90YLUDw-MliZm5_lBDxO7w-1; Thu, 29 Aug 2024 16:01:18 -0400 X-MC-Unique: 90YLUDw-MliZm5_lBDxO7w-1 Received: by mail-oo1-f71.google.com with SMTP id 006d021491bc7-5dc96240f1dso1055131eaf.0 for ; Thu, 29 Aug 2024 13:01:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724961677; x=1725566477; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=a6YgJDRtCG6NqNHvxBGwLph56rsiY6btQEOiIVWjksU=; b=OyvauNFp3lt15XHOvAqrvzNOZMFM2XvFF0nPMs8zVOYNxA2QmmuzJSpWypLWH2D9ha z2KjOtYVMlOec5mMQZi6hQaSWpypPNock939nga5SO2pLpUo4eQHirik0QDiPjsM36GD m1ZCEA4zwf26uVUnHYJ+Ds1fKfxEwBxj3Oq1uU3wWq5KOc9EwRKfezNh/Iz3/rRLcbpB a2agtFD7CoHhPylTXmZwKkeesRSiwplqm6KHh061+fwgxgL8sd5W5c0Os1MGECxrCDpC e/M85glZ2Q+DRqAoEz8Jj88TLVI1u1bls+1TcbkkvGFvYsNzXzlocweroXUC2RgbgU4N lH+A== X-Forwarded-Encrypted: i=1; AJvYcCXfUTbEDbElJFflPjQLXaxpUSCcUaOTa6ZsztU1W47gpxYFFuuejztDqbvGciucurETfz1BraE3suXhp/CxdvVy@lists.infradead.org X-Gm-Message-State: AOJu0YyYdkijbRE34ziWGFc5wgeiZtd2qFQIygd6aSK+FtwE3e6FuSgy F/Xd9/U2yxOvbsKUU/Kg7wSyQldB8OJ6ijcmV5uczAt1IpkAAlhjAGn2zGZamGnMY1al6xD0sui 9CU46NuViMkuGtSlhT9qOSFYhemwlAuTQJ6Gjv4m53Ayb4Fuq1eu88f2RiINWHbOCdwIWqKaE X-Received: by 2002:a05:6820:168d:b0:5df:81ed:2655 with SMTP id 006d021491bc7-5dfacd7a869mr90164eaf.1.1724961677314; Thu, 29 Aug 2024 13:01:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGK7ZWE97qlIasXgZMNuMbAVeGSN/jRz09m4SD8T+Wcq60efkSETyErTr9KSiO3wUuWWJ5s/g== X-Received: by 2002:a05:6820:168d:b0:5df:81ed:2655 with SMTP id 006d021491bc7-5dfacd7a869mr90109eaf.1.1724961676881; Thu, 29 Aug 2024 13:01:16 -0700 (PDT) Received: from x1n (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5dfa04e8aadsm341894eaf.28.2024.08.29.13.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 13:01:16 -0700 (PDT) Date: Thu, 29 Aug 2024 16:01:09 -0400 From: Peter Xu To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Gavin Shan , Catalin Marinas , x86@kernel.org, Ingo Molnar , Andrew Morton , Paolo Bonzini , Dave Hansen , Thomas Gleixner , Alistair Popple , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sean Christopherson , Oscar Salvador , Jason Gunthorpe , Borislav Petkov , Zi Yan , Axel Rasmussen , Yan Zhao , Will Deacon , Kefeng Wang , Alex Williamson Subject: Re: [PATCH v2 07/19] mm/fork: Accept huge pfnmap entries Message-ID: References: <20240826204353.2228736-1-peterx@redhat.com> <20240826204353.2228736-8-peterx@redhat.com> <78d77162-11df-4437-b70b-fa04f868a494@redhat.com> <32a451ee-6836-4d4d-814c-752c15415aae@redhat.com> MIME-Version: 1.0 In-Reply-To: <32a451ee-6836-4d4d-814c-752c15415aae@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240829_130123_416920_A63D8511 X-CRM114-Status: GOOD ( 31.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Aug 29, 2024 at 09:44:01PM +0200, David Hildenbrand wrote: > On 29.08.24 20:26, Peter Xu wrote: > > On Thu, Aug 29, 2024 at 05:10:42PM +0200, David Hildenbrand wrote: > > > On 26.08.24 22:43, Peter Xu wrote: > > > > Teach the fork code to properly copy pfnmaps for pmd/pud levels. Pud is > > > > much easier, the write bit needs to be persisted though for writable and > > > > shared pud mappings like PFNMAP ones, otherwise a follow up write in either > > > > parent or child process will trigger a write fault. > > > > > > > > Do the same for pmd level. > > > > > > > > Signed-off-by: Peter Xu > > > > --- > > > > mm/huge_memory.c | 29 ++++++++++++++++++++++++++--- > > > > 1 file changed, 26 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > > > > index e2c314f631f3..15418ffdd377 100644 > > > > --- a/mm/huge_memory.c > > > > +++ b/mm/huge_memory.c > > > > @@ -1559,6 +1559,24 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, > > > > pgtable_t pgtable = NULL; > > > > int ret = -ENOMEM; > > > > + pmd = pmdp_get_lockless(src_pmd); > > > > + if (unlikely(pmd_special(pmd))) { > > > > > > I assume I have to clean up your mess here as well? > > > > Can you leave meaningful and explicit comment? I'll try to address. > > Sorry Peter, but I raised all that as reply to v1. For example, I stated > that vm_normal_page_pmd() already *exist* and why these pmd_special() checks > should be kept there. We discussed the usage of pmd_page() but I don't think this is clear you suggest it to be used there. IOW, copy_huge_pmd() doesn't use vm_normal_page_pmd() yet so far and I'm not sure whether it's always safe. E.g. at least one thing I spot is vm_normal_page_pmd() returns NULL for huge zeropage pmd but here in fork() we need to take a ref with mm_get_huge_zero_folio(). > > I hear you, you're not interested in cleaning that up. So at this point it's > easier for me to clean it up myself. It might be easier indeed you provide a patch that you think the best. Then I'll leave that to you, and I'll send the solo fixup patch to be squashed soon to the list. -- Peter Xu