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 F24A3C531DC for ; Wed, 21 Aug 2024 18:42:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 827356B017E; Wed, 21 Aug 2024 14:42:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D5F16B017F; Wed, 21 Aug 2024 14:42:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 650F26B0180; Wed, 21 Aug 2024 14:42:17 -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 469A16B017E for ; Wed, 21 Aug 2024 14:42:17 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BCC381210F5 for ; Wed, 21 Aug 2024 18:42:16 +0000 (UTC) X-FDA: 82477122672.18.288D2A7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 9DC9E40032 for ; Wed, 21 Aug 2024 18:42:14 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JFOL0Ozq; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724265718; a=rsa-sha256; cv=none; b=ZkTr4d5xDidMeWl1Z5Bt4Trn1Xmcp+liEyNYPiFOcaaG0QifxnxzrY++PFYTP3nffCLRLg 2Jn0tLmO10YjxxBYe5F7glD69w7e0AUCK9XMzVs2p49AF+nicReoGNI+4AcRM8N1qm18nA Ko5pEgvl4Mk4gImr0bSLpqArdbrdl4E= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JFOL0Ozq; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724265718; 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=bxtRUWPBJDHjggPAMnTH/KRZh2Re9tIX9Caj2lJIIn8=; b=Ah3ndED8xoCSxn8xwfhLxiVZA5q8FaZr6LqOagE3QiaIV8dtv7hDZBKufMEa3lbxP3MbUY REKQfNDyW+6/ndh4XuHkkmFsNjjgoDALjM6h1PMD+Ywrh+BT/k+vFTU8DwPsjKzUb0R8SX uEwJugppWs26C/DxPeXOo9pI/32ChdM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724265733; 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=JFOL0OzqfYjIB1R6V2WhOtEvfYeas7+LowHrbrnZfQl69RcZWOc12NldLgYsa9VHWWmnwT ESEQ8g3o0IBhxOsSqtHlTTYunyvvZ+eTYTcauvTo7fon1tCdfvd5CyMCa76oeQtyAgYOZC PSdMDL+K/yiZpc0KoxtpZU7qjEk7yYk= Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-488-6c_1QLnwOH2G-lU93TFbHQ-1; Wed, 21 Aug 2024 14:42:12 -0400 X-MC-Unique: 6c_1QLnwOH2G-lU93TFbHQ-1 Received: by mail-vk1-f198.google.com with SMTP id 71dfb90a1353d-4f51e384ee3so1972e0c.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=tdDZFb29cntHhvexwwjK2iK6gydhRTJosv9iQk339g1f297JIIJe0qXm8thsofX2Bz kmG8dDaSFa8nRiHgnHi3U5F54vvrWqkp/0v5y9tjo9QgXU6hThYfxoQO5pvJOHzpsF98 Kb+dOC9sODZlzrO8qo+rxc7QVAvMhCutUIICs6IlD9vGCKLAhcGxH9azPkAecXOE1SHs nuOdgDMWM5eibR0Np3jAe1p0USWW6NpA0a1U5xO5/bxCuckfCi1tQdle4RNJ4TbAIqLz AnAjhCySsZwaq8ML3dQIqzYyRANFGyOc7VwBiX5WyppzqIxdNM29SDWwte24MxRhZHYS WHew== X-Forwarded-Encrypted: i=1; AJvYcCWEm1rA9RLN54qMcuCiPsk60Cli360lzKlujv9U4CCqWGMM8DcqNQYv9D4FMzvS2CexNEj977S+iA==@kvack.org X-Gm-Message-State: AOJu0Yw9ak1pGkThN+/p3BN2+NxwtGfDLBrgfcMv1UC5usev29Dvx1cT +qx5PgEq12PCDcwzPuYRnurUUHfdx3a+VRz/bwHyBRDC25+yDw+nzyXPpJV0e3Qr24+11LLbzkv 2hya75ZAK9a7H6AKUNKVOd/PlFBI3lyiHJPzXFIG3fBwyao/S X-Received: by 2002:a05:6122:31aa:b0:4f5:2276:1366 with SMTP id 71dfb90a1353d-4fcf359b050mr3850767e0c.3.1724265732162; 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-Rspam-User: X-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TYGjMb/GNfFn88/FPvsGbigJSEf H+UFOHFt ui5jLjVl58APqQ1xDosoADrtRzBFoq17Vlj59JoQafieZEoQYucnw0fodo8IbstomtS96dCSxwmexC3BPV3/a3rTdU0sT8iqOyMoLqGayuBeNTS4ziURnTyL7l+7GPi06ezjp3bpTY3Od1MD5SQNM5OalVHp+6WikibrgpvEdFzfUPCuPrw5hN3oBDkEepzgCvtKvtAMbw8lTLMEIZmsjVNF+HaXtwT1GVMhNNRZ46jPLBo2UBQAbwoO0CU+SqD+SOV8lCpjT4GBgODUmY60WmHH5FYe1aYJkXTTRf8eb8gcOZEWijlGfvL5V0SI2MWrPZT84TjUGoUtQSVH7U1GwKeYJm7s6CoBUuFJA 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: List-Subscribe: List-Unsubscribe: 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