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 B8764C52D7C for ; Fri, 9 Aug 2024 16:54:55 +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=86nPCx79W6PGHL+fSL/w3sszGXq3z8SJRXsfiXl5Py8=; b=Xj5kVzL0ghdPL/ROlpjqpXA2Xi hWX0ibuCP7v2gdy3cC0JcLtuSqncKNpfvZ9Kd7ZopTsLvhPRW/bHof7uDDjioWlEDwFtwAePuuc87 c/2zjquur2uRa+wdscNeZ05FrhT6QBnv0eeqbvfMWCTxB8vtmEghuiqg/dwtI/naRU+WnLvRaqYTi HLr0Y74tIr7gDpINCaW119O7quRrsg2VmlrCbw1JUXxmvPtYaTVsxLmHnen3Xke5lqWXYDY5U2lh9 4vrFH2IMw1DQMF+wZzRxdPw2i1HiQfGCgDvBnoK3fOj4Oe8WEImFFeE+JGtIpq2ASZSzRQjrr8yce QAfPBp5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scSt2-0000000C0Az-2jIA; Fri, 09 Aug 2024 16:54:44 +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 1scSsS-0000000C02I-3lLq for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2024 16:54:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723222448; 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=86nPCx79W6PGHL+fSL/w3sszGXq3z8SJRXsfiXl5Py8=; b=Yd00n64uRebULzb//ETznVQTiLn5Z8Q6elTJSV2V9WnbH5tjLVLTPms+CeqqtxGQrjBbG8 mxv7c9PV56UwQiXgZMbz4mvxLLYgapoyCC6pvFGMJ2k0DMXb9yVqHat/PFVgMoCPVVMtIs vK+couAIINM7bDaMerWmakfnVHwalxA= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-306-GTcx7kr9N1uItRlkBmAlxw-1; Fri, 09 Aug 2024 12:54:06 -0400 X-MC-Unique: GTcx7kr9N1uItRlkBmAlxw-1 Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-7093752a9f5so503796a34.1 for ; Fri, 09 Aug 2024 09:54:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723222446; x=1723827246; 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=86nPCx79W6PGHL+fSL/w3sszGXq3z8SJRXsfiXl5Py8=; b=NhqKT6B72C1nG5QnV8yTYj9Piow4+gT/0txIo2gOj0YEGLzeoVRdk/aIGoLLXIWzTi 5RMPJ6/P2nMPpWCDzMH1dtBfe6qFaS6JQWrGZEFXt+JMCCvL49nVXYyxvsFn5eQTXLfT 54Lww24RjMs7V4nQZ2Rt7LgDiJae5c+gmSQzdEHb8OKLroFuITo71deQWhX9hDVIUUMJ y4Uy5eivqrprTJsm1tFMfA/2G3Ocxg4aiTt9JhWh4ftMx2Tz/46c2Jd/krexQhMfePnL iMfna5ewCtdAeavT+sRXI2PkKSn+Uxu2/zDAeqy1QRT/hhd4X9pUZTGVq++Kbr6EPJtN UDAA== X-Forwarded-Encrypted: i=1; AJvYcCV3+HNHx9nCZ4hzKvrXbA5umS8gYGAKUV8CsyI6RY9lDT+UhfeFnOZaPrmaXgYqph6rchRoH9jceyivFyJLrI9y@lists.infradead.org X-Gm-Message-State: AOJu0YyokrA/LcaQqpVhtINF6YfgjqJGXARDkPT9+B1cyeMuaprB8NCk rCyI7xpTLbVx/inK3Nc37Lc5pmxzEP7sZ1LMUkLugwNDgTTISz5tpFiuo1yPVcxODXpPdd+I9r2 AkVA/uF2hvhxEl4BSSzZtPXkbk+K0Pzv2+peh23JRwm3BVffsXsCl5gJwV7kqK3KQIH5TQL5O X-Received: by 2002:a05:6830:2b25:b0:703:5c54:ddac with SMTP id 46e09a7af769-70b7470a670mr1628370a34.2.1723222445788; Fri, 09 Aug 2024 09:54:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpuMCJfrpcp3WHIjMj9LLfZZ/K5MFK4Lv5p2xqcXiI3Eo7cosoDQu8/NAx31jVVYmRJIlX7w== X-Received: by 2002:a05:6830:2b25:b0:703:5c54:ddac with SMTP id 46e09a7af769-70b7470a670mr1628345a34.2.1723222445418; Fri, 09 Aug 2024 09:54:05 -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 af79cd13be357-7a3786cce67sm279215085a.116.2024.08.09.09.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 09:54:04 -0700 (PDT) Date: Fri, 9 Aug 2024 12:54:01 -0400 From: Peter Xu To: David Hildenbrand Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sean Christopherson , Oscar Salvador , Jason Gunthorpe , Axel Rasmussen , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Will Deacon , Gavin Shan , Paolo Bonzini , Zi Yan , Andrew Morton , Catalin Marinas , Ingo Molnar , Alistair Popple , Borislav Petkov , Thomas Gleixner , kvm@vger.kernel.org, Dave Hansen , Alex Williamson , Yan Zhao Subject: Re: [PATCH 06/19] mm/pagewalk: Check pfnmap early for folio_walk_start() Message-ID: References: <20240809160909.1023470-1-peterx@redhat.com> <20240809160909.1023470-7-peterx@redhat.com> MIME-Version: 1.0 In-Reply-To: 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-20240809_095409_031069_C183C2CA X-CRM114-Status: GOOD ( 30.67 ) 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 Fri, Aug 09, 2024 at 06:20:06PM +0200, David Hildenbrand wrote: > On 09.08.24 18:08, Peter Xu wrote: > > Pfnmaps can always be identified with special bits in the ptes/pmds/puds. > > However that's unnecessary if the vma is stable, and when it's mapped under > > VM_PFNMAP | VM_IO. > > > > Instead of adding similar checks in all the levels for huge pfnmaps, let > > folio_walk_start() fail even earlier for these mappings. It's also > > something gup-slow already does, so make them match. > > > > Cc: David Hildenbrand > > Signed-off-by: Peter Xu > > --- > > mm/pagewalk.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/mm/pagewalk.c b/mm/pagewalk.c > > index cd79fb3b89e5..fd3965efe773 100644 > > --- a/mm/pagewalk.c > > +++ b/mm/pagewalk.c > > @@ -727,6 +727,11 @@ struct folio *folio_walk_start(struct folio_walk *fw, > > p4d_t *p4dp; > > mmap_assert_locked(vma->vm_mm); > > + > > + /* It has no folio backing the mappings at all.. */ > > + if (vma->vm_flags & (VM_IO | VM_PFNMAP)) > > + return NULL; > > + > > That is in general not what we want, and we still have some places that > wrongly hard-code that behavior. > > In a MAP_PRIVATE mapping you might have anon pages that we can happily walk. > > vm_normal_page() / vm_normal_page_pmd() [and as commented as a TODO, > vm_normal_page_pud()] should be able to identify PFN maps and reject them, > no? Yep, I think we can also rely on special bit. When I was working on this whole series I must confess I am already confused on the real users of MAP_PRIVATE pfnmaps. E.g. we probably don't need either PFNMAP for either mprotect/fork/... at least for our use case, then VM_PRIVATE is even one step further. Here I chose to follow gup-slow, and I suppose you meant that's also wrong? If so, would it make sense we keep them aligned as of now, and change them altogether? Or do you think we should just rely on the special bits? And, just curious: is there any use case you're aware of that can benefit from caring PRIVATE pfnmaps yet so far, especially in this path? As far as I read, none of folio_walk_start() users so far should even stumble on top of a pfnmap, share or private. But that's a fairly quick glimps only. IOW, I was wondering whether I'm just over cautious here. Thanks, -- Peter Xu