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 21B85C52D7C for ; Wed, 21 Aug 2024 18:43: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=bxtRUWPBJDHjggPAMnTH/KRZh2Re9tIX9Caj2lJIIn8=; b=ZuLXv/uglQ+9atwtfejEeAkd59 Qj7Kfbl2dvD871Lks6fExOJixy9nDD0J7ENwT6IdS03p4btmUQkxPmaH23x8z7E3aB5CROgYBhou/ 3POAqeFc9JAhhXaMYbaQYvUJa6p+XM2Bs5kCHuWd9IVekYEp1u+zKjuZ/E5C48ahOhEQc354bJU7r NEruixADzgnBBqrwo0gki5lfIrY8EfUHil+uZOKndCuEnFgxUGPFFcWrbU/MTFb+DoA6K3/SBdeA8 UBIWd1zQ2peYfvvbfy6Y9K3RLpHiwP6mK50W1f+07/VFHWD48jXMJUzUAmwFfCcne9/cP0Vx+BSFs cg9fW8Xw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgqIc-0000000A5kZ-0MnO; Wed, 21 Aug 2024 18:43:14 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgqHi-0000000A5VH-1E1s for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 18:42:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724265734; 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=bxtRUWPBJDHjggPAMnTH/KRZh2Re9tIX9Caj2lJIIn8=; b=KhnrU+u1SBPArje1RW1IRIyP/5NCy6pkkTejvIRDyTNLrUu5DBpi7dGX2v+PHUQg/HOc1M q14dLm+cpuqBVQEZxJCGs1e+1PfZUvH5f8LR0mpYPebtHqeJaaHWK7yK8Fhr9HSo4fnHmW ExsHArgxdgf6Qp+/R7+neSQW+hF7uBM= Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-173-jVzQqXEQNKamISWkxT70Xg-1; Wed, 21 Aug 2024 14:42:12 -0400 X-MC-Unique: jVzQqXEQNKamISWkxT70Xg-1 Received: by mail-ua1-f69.google.com with SMTP id a1e0cc1a2514c-842f0cb28efso2931241.2 for ; Wed, 21 Aug 2024 11:42:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724265732; x=1724870532; 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=bxtRUWPBJDHjggPAMnTH/KRZh2Re9tIX9Caj2lJIIn8=; b=CJJf+FgJndSj6nnakUVu+YruMYdxnWOY9b0/phInrEt3pdMx0CIMIfIbxCP6MX1+Ww S7Pg8/uXXKrERNgUDEm5pXJEE55J2rAVFeHGpZdyiiipvTq3Mu8Rgv1qgiCeZOgJdp43 dx/Y4LdB6XkSGE33flUEGiH+MCdmaeBNb3+O1l6YfrE76I2nsfbNGrzq9iXwVyzjKmr5 p9jrZfT2t9yjfppDXjEB9h87/RnhL2+llvzAPY9mbzLQTG0PXZZOrvE4R4Vpmf/FZ0tw klkIW8h6vLUfWzkpu4aynXgQUDXxOUSXsFkhg2Mb1XopikTkUGJf3PnBFDeTnOHGmoCD aC0Q== X-Forwarded-Encrypted: i=1; AJvYcCUbrIYMpm99o40p1w/5tNBqauOq9JuH4PyW5OESRqYrkQyw1MtibxzKIW/KvD5zQAAqEf1n4xFQQNMh/pzQ28RR@lists.infradead.org X-Gm-Message-State: AOJu0Yz0/t3VDm1m/3vE6ePsr0Uw8mf7NrT3tP2Z6Rz0BFxDjaAm9b7I 0LDee9nzzwa1w5Wjf9AWv1o06r0CLxiFvPfWDs+5aHEKmOkeHNg983RZp2i1aPFzgnB+zU2MY8w iH8bhamQ3UmvBuaUIpLO8I4DUxzA+YK5T3mkw1CNq74Es1cp6zBtAzjnVZKNIUpOY5ilKV3Iq X-Received: by 2002:a05:6122:31aa:b0:4f5:2276:1366 with SMTP id 71dfb90a1353d-4fcf359b050mr3850782e0c.3.1724265732175; Wed, 21 Aug 2024 11:42:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2LW4+n8nTAfSzrfkkM6791Kkp4/ULsaTSZO+hvp6iv7hAwAb2/BkSllzEF9UW3wJdZt4VMA== X-Received: by 2002:a05:6122:31aa:b0:4f5:2276:1366 with SMTP id 71dfb90a1353d-4fcf359b050mr3850745e0c.3.1724265731697; Wed, 21 Aug 2024 11:42:11 -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 6a1803df08f44-6bf6ff0fbb8sm63382556d6.144.2024.08.21.11.42.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 11:42:11 -0700 (PDT) Date: Wed, 21 Aug 2024 14:42:08 -0400 From: Peter Xu To: Jason Gunthorpe Cc: David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sean Christopherson , Oscar Salvador , 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> <20240814130525.GH2032816@nvidia.com> <81080764-7c94-463f-80d3-e3b2968ddf5f@redhat.com> <20240816173836.GD2032816@nvidia.com> MIME-Version: 1.0 In-Reply-To: <20240816173836.GD2032816@nvidia.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-20240821_114218_447643_1E5FCAA1 X-CRM114-Status: GOOD ( 32.63 ) 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 16, 2024 at 02:38:36PM -0300, Jason Gunthorpe wrote: > On Fri, Aug 16, 2024 at 10:21:17AM -0400, Peter Xu wrote: > > On Fri, Aug 16, 2024 at 11:30:31AM +0200, David Hildenbrand wrote: > > > On 14.08.24 15:05, Jason Gunthorpe wrote: > > > > On Fri, Aug 09, 2024 at 07:25:36PM +0200, David Hildenbrand wrote: > > > > > > > > > > > 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. > > > > > > > > It is more than just relying on the special bit.. > > > > > > > > VM_PFNMAP/VM_MIXEDMAP should really only be used inside > > > > vm_normal_page() because thay are, effectively, support for a limited > > > > emulation of the special bit on arches that don't have them. There are > > > > a bunch of weird rules that are used to try and make that work > > > > properly that have to be followed. > > > > > > > > On arches with the sepcial bit they should possibly never be checked > > > > since the special bit does everything you need. > > > > > > > > Arguably any place reading those flags out side of vm_normal_page/etc > > > > is suspect. > > > > > > IIUC, your opinion matches mine: VM_PFNMAP/VM_MIXEDMAP and pte_special()/... > > > usage should be limited to vm_normal_page/vm_normal_page_pmd/ ... of course, > > > GUP-fast is special (one of the reason for "pte_special()" and friends after > > > all). > > > > The issue is at least GUP currently doesn't work with pfnmaps, while > > there're potentially users who wants to be able to work on both page + > > !page use cases. Besides access_process_vm(), KVM also uses similar thing, > > and maybe more; these all seem to be valid use case of reference the vma > > flags for PFNMAP and such, so they can identify "it's pfnmap" or more > > generic issues like "permission check error on pgtable". > > Why are those valid compared with calling vm_normal_page() per-page > instead? > > What reason is there to not do something based only on the PFNMAP > flag? My comment was for answering "why VM_PFNMAP flags is needed outside vm_normal_page()", because GUP lacks supports of it. Are you suggesting we should support VM_PFNMAP in GUP, perhaps? Thanks, -- Peter Xu