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 217A8C5B54A for ; Wed, 28 Aug 2024 15:30:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81A286B007B; Wed, 28 Aug 2024 11:30:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C92C6B0082; Wed, 28 Aug 2024 11:30:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 642BC6B0083; Wed, 28 Aug 2024 11:30:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4237C6B007B for ; Wed, 28 Aug 2024 11:30:54 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E474C16030B for ; Wed, 28 Aug 2024 15:30:53 +0000 (UTC) X-FDA: 82502041986.20.7B1A78A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 44E13140011 for ; Wed, 28 Aug 2024 15:30:51 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hxek12ib; spf=pass (imf23.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724858982; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JQrY6fTjtMffITk65cE3lIhCjtNWs7f3wl30Hqmd/6A=; b=we45FWIrsPhLLFGpVIzqsotFYL0Wjjd3HRKoO2/7ehkDvDOxf3v9hiw/5VfCn32RzAGvQD ntLEsGDexevlVjLB29WzSLrtidjx+p/FPWg7Ktm/pCtJxwmkhNm1bdX9fLGL0W45DwElP4 lm/ZAh/G6vYOYQDffi7xeWXFMA6e/Mc= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hxek12ib; spf=pass (imf23.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724858982; a=rsa-sha256; cv=none; b=bElUFs7mEzLDiL4AqAaIfmx7ORKxTLYbd+5nw8SdSvC/LPX2ilE/Z3FF4vjnu5gbtwtKxV 8uwKPo3CidYVOETC3J557Xa/WRoc4/DnDAqlsTdZ7uAymgIUYP5sFb9wRJNGGY9qb19vsz qqqo/+G794QFhP90BwJj403ZRtn0pmY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724859050; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=JQrY6fTjtMffITk65cE3lIhCjtNWs7f3wl30Hqmd/6A=; b=Hxek12ib7LvYmlDsvuEEXRiVmk/XHNR1PfvCVFFYAWR8CYhFLxY/i/GuWWZCFa1LlFKkA/ KUTxFzWZLKvA2p7aT4+OgAcCOOEqc7I+lG5zy0xNyhexUm4TpcFT+gRuahmkxyMar9RW0s UbofoIG1ivnGSGjr+d00JZ9lxFqVmv0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-490-EnqKDeJuOhmcynGNfuvd_g-1; Wed, 28 Aug 2024 11:30:48 -0400 X-MC-Unique: EnqKDeJuOhmcynGNfuvd_g-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42b929d654bso35165895e9.1 for ; Wed, 28 Aug 2024 08:30:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724859047; x=1725463847; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=JQrY6fTjtMffITk65cE3lIhCjtNWs7f3wl30Hqmd/6A=; b=lyu3HaJ0lDsvuX2gbwWfQn1oeYPrTaKOr5UkAv9cDwuL6fclDk2cU6I7q6kwSkqm2M n+FkokQYNnaoaClry76IEbU5VU9xGb0Xg8aCIuMmrGACznbu6V6vrT/Q9oY5Q0/vgHnm C4+blz2iVAKE3PnX2nd34Xbt+07fqjF639/7l/xXJHnPVMTGtCDNaQf91vq/lGbM/PGq KUE+kfz4tITPog4kshjrBPCrBay6IKUNh9GmRM3q2J2fp6gceLT+pRtaR/lLCHa/Ut35 LSZkE0gnBuePJPqKzZ8VW5QT3b6zWhm0KP+RGBlA6SM5iYO3syTfxCfCwdQznNXa7kzs TynQ== X-Forwarded-Encrypted: i=1; AJvYcCVypdzxtNsgGupUhToNz5MVa7Gb7KouyHukMiQRJ1dbHK+29RYzAYWm5SGdGQSL4K72DDCcDkcT7Q==@kvack.org X-Gm-Message-State: AOJu0YzPCJStVdt6vCZu1CUCYwEZOHuAOs+C7hwjAEtFMpWDCQY2hPEf wMPAUTa2Ze08QGWwfWCu+zcsqQoGSDrWZAgaXc1JznT1+iTy1R3IREuX2Gpil4dTiLM4A3wPxLY YVQVPMiT5LwIqG7tnEZfJ9gU5oTc33gpZpeCkOI1oI0hGiufz X-Received: by 2002:a7b:c449:0:b0:42b:aecb:d280 with SMTP id 5b1f17b1804b1-42bb27a1021mr77465e9.27.1724859046900; Wed, 28 Aug 2024 08:30:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcYrQAeqH4qohLw4p+ce1kbOV4E+qFSa8CCj124NKCzqOMjYPmc8sWetHU7svLzvNl292dQQ== X-Received: by 2002:a7b:c449:0:b0:42b:aecb:d280 with SMTP id 5b1f17b1804b1-42bb27a1021mr76905e9.27.1724859045944; Wed, 28 Aug 2024 08:30:45 -0700 (PDT) Received: from ?IPV6:2003:cb:c706:1700:6b81:27cb:c9e2:a09a? (p200300cbc70617006b8127cbc9e2a09a.dip0.t-ipconnect.de. [2003:cb:c706:1700:6b81:27cb:c9e2:a09a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ba639687csm24322545e9.8.2024.08.28.08.30.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Aug 2024 08:30:45 -0700 (PDT) Message-ID: Date: Wed, 28 Aug 2024 17:30:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 06/19] mm/pagewalk: Check pfnmap for folio_walk_start() To: Peter Xu 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 References: <20240826204353.2228736-1-peterx@redhat.com> <20240826204353.2228736-7-peterx@redhat.com> <9f9d7e96-b135-4830-b528-37418ae7bbfd@redhat.com> From: David Hildenbr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dPCC5ynI+1ymZC1ORZKANLnRAb0NH/UCzcsstw2TAkFnMEbo9Zu9w7Kv AxBQXWeXhJI9XQssfrf4Gusdqx8nPEpfOqCtbbwJMATbHyqLt7/oz/5deGuwxgb65pWIzufa N7eop7uh+6bezi+rugUI+w6DABEBAAHCwXwEGAEIACYCGwwWIQQb2cqtc1xMOkYN/MpN3hD3 AP+DWgUCXw7HsgUJEqkpoQAKCRBN3hD3AP+DWrrpD/4qS3dyVRxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Stat-Signature: mmzwop986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qz yPNRjWqH dK+0yQKstPDtqVIyIR2RXo3vwVULlxPP1HYjLxDdaCTn5dxUIZ5Kd5qio7kk9szzJsRuH06yl6krnz2pIouaNm6/3lxNOpcZpj4N1mDBOR+nNfRiD6Q8vAwIS+UB+dcrv6CFERaqFejTtEG0Gh31kYwrDNX6KheGOMSnS9w/HlVfij/ZVfmDeK1+TYljPZJYTjxtU/zO8KBrowqdWWIfcM2kUamlTtY/CfNn+OzbPcIJ9x1Y+/ChxNvatQAxxDoTXbjinya36jAoIKAK4eHtpnyGnbXPIM7qDXNnbrM4QdbIGWaBwLrSgk7zkesLpMQUb9I7fcBKV8Z5iFIHjsXsMdU3k65lihhFCD0LcbrWlgex9OekbYuEDSFDSMQ/wCo0sZMmdJANkr6ZaR9xiGk0T3Ey26nA9fm9khdkhlcP0JodqLsjKnrwfyKdw76R9kLhlaCy0mA7QGAdQdvb6E0h/EtqkLg== 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: > This one is correct; I overlooked this comment which can be obsolete. I > can either refine this patch or add one patch on top to refine the comment > at least. Probably best if you use what you consider reasonable in your patch. > >> + if (IS_ENABLED(CONFIG_ARCH_HAS_PMD_SPECIAL)) { > > We don't yet have CONFIG_ARCH_HAS_PMD_SPECIAL, but I get your point. > >> + if (likely(!pmd_special(pmd))) >> + goto check_pfn; >> + if (vma->vm_ops && vma->vm_ops->find_special_page) >> + return vma->vm_ops->find_special_page(vma, addr); > > Why do we ever need this? This is so far destined to be totally a waste of > cycles. I think it's better we leave that until either xen/gntdev.c or any > new driver start to use it, rather than keeping dead code around. I just copy-pasted what we had in vm_normal_page() to showcase. If not required, good, we can add a comment we this is not required. > >> + if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP)) >> + return NULL; >> + if (is_huge_zero_pmd(pmd)) >> + return NULL; > > This is meaningless too until we make huge zero pmd apply special bit > first, which does sound like to be outside the scope of this series. Again, copy-paste, but ... > >> + if (pmd_devmap(pmd)) >> + /* See vm_normal_page() */ >> + return NULL; > > When will it be pmd_devmap() if it's already pmd_special()? > >> + return NULL; > > And see this one.. it's after: > > if (xxx) > return NULL; > if (yyy) > return NULL; > if (zzz) > return NULL; > return NULL; > > Hmm?? If so, what's the difference if we simply check pmd_special and > return NULL.. Yes, they all return NULL. The compiler likely optimizes it all out. Maybe we have it like that for pure documentation purposes. But yeah, we should simply return NULL and think about cleaning up vm_normal_page() as well, it does look strange. > >> + } >> + >> + /* !CONFIG_ARCH_HAS_PMD_SPECIAL case follows: */ >> + >> if (unlikely(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))) { >> if (vma->vm_flags & VM_MIXEDMAP) { >> if (!pfn_valid(pfn)) >> return NULL; >> + if (is_huge_zero_pmd(pmd)) >> + return NULL; > > I'd rather not touch here as this series doesn't change anything for > MIXEDMAP yet.. Yes, that can be a separate change. > >> goto out; >> } else { >> unsigned long off; >> @@ -692,6 +706,11 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr, >> } >> } >> + /* >> + * For historical reasons, these might not have pmd_special() set, >> + * so we'll check them manually, in contrast to vm_normal_page(). >> + */ >> +check_pfn: >> if (pmd_devmap(pmd)) >> return NULL; >> if (is_huge_zero_pmd(pmd)) >> >> >> >> We should then look into mapping huge zeropages also with pmd_special. >> pmd_devmap we'll leave alone until removed. But that's indeoendent of your series. > > This does look reasonable to match what we do with pte zeropage. Could you > remind me what might be the benefit when we switch to using special bit for > pmd zero pages? See below. It's the way to tell the VM that a page is special, so you can avoid a separate check at relevant places, like GUP-fast or in vm_normal_*. > >> >> I wonder if CONFIG_ARCH_HAS_PTE_SPECIAL is sufficient and we don't need additional >> CONFIG_ARCH_HAS_PMD_SPECIAL. > > The hope is we can always reuse the bit in the pte to work the same for > pmd/pud. > > Now we require arch to select ARCH_SUPPORTS_HUGE_PFNMAP to say "pmd/pud has > the same special bit defined". Note that pte_special() is the way to signalize to the VM that a PTE does not reference a refcounted page, or is similarly special and shall mostly be ignored. It doesn't imply that it is a PFNAMP pte, not at all. The shared zeropage is usually not refcounted (except during GUP FOLL_GET ... but not FOLL_PIN) and the huge zeropage is usually also not refcounted (but FOLL_PIN still does it). Both are special. If you take a look at the history pte_special(), it was introduced for VM_MIXEDMAP handling on s390x, because pfn_valid() to identify "special" pages did not work: commit 7e675137a8e1a4d45822746456dd389b65745bf6 Author: Nicholas Piggin Date: Mon Apr 28 02:13:00 2008 -0700 mm: introduce pte_special pte bit In the meantime, it's required for architectures that wants to support GUP-fast I think, to make GUP-fast bail out and fallback to the slow path where we do a vm_normal_page() -- or fail right at the VMA check for now (VM_PFNMAP). An architecture that doesn't implement pte_special() can support pfnmaps but not GUP-fast. Similarly, an architecture that doesn't implement pmd_special() can support huge pfnmaps, but not GUP-fast. If you take a closer look, really the only two code paths that look at pte_special() are GUP-fast and vm_normal_page(). If we use pmd_special/pud_special in other code than that, we are diverging from the pte_special() model, and are likely doing something wrong. I see how you arrived at the current approach, focusing exclusively on x86. But I think this just adds inconsistency. So my point is that we use the same model, where we limit * pmd_special() to GUP-fast and vm_normal_page_pmd() * pud_special() to GUP-fast and vm_normal_page_pud() And simply do the exact same thing as we do for pte_special(). If an arch supports pmd_special() and pud_special() we can support both types of hugepfn mappings. If not, an architecture *might* support it, depending on support for GUP-fast and maybe depending on MIXEDMAP support (again, just like pte_special()). Not your task to worry about, you will only "unlock" x86. So maybe we do want CONFIG_ARCH_HAS_PMD_SPECIAL as well, maybe it can be glued to CONFIG_ARCH_HAS_PTE_SPECIAL (but I'm afraid it can't unless all archs support both). I'll leave that up to you. > >> >> As I said, if you need someone to add vm_normal_page_pud(), I can handle that. > > I'm pretty confused why we need that for this series alone. See above. > > If you prefer vm_normal_page_pud() to be defined and check pud_special() > there, I can do that. But again, I don't yet see how that can make a > functional difference considering the so far very limited usage of the > special bit, and wonder whether we can do that on top when it became > necessary (and when we start to have functional requirement of such). I hope my explanation why pte_special() even exists and how it is used makes it clearer. It's not that much code to handle it like pte_special(), really. I don't expect you to teach GUP-slow about vm_normal_page() etc. If you want me to just takeover some stuff, let me know. -- Cheers, David / dhildenb