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 7EF58C433FE for ; Mon, 16 May 2022 13:03:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E37B06B0071; Mon, 16 May 2022 09:03:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DBE8D6B0072; Mon, 16 May 2022 09:03:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5F496B0073; Mon, 16 May 2022 09:03:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B89836B0071 for ; Mon, 16 May 2022 09:03:25 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9A7DF61BDA for ; Mon, 16 May 2022 13:03:25 +0000 (UTC) X-FDA: 79471622370.06.794CC53 Received: from outbound-smtp24.blacknight.com (outbound-smtp24.blacknight.com [81.17.249.192]) by imf26.hostedemail.com (Postfix) with ESMTP id C8BD91400C3 for ; Mon, 16 May 2022 13:03:21 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp24.blacknight.com (Postfix) with ESMTPS id 89975C0B68 for ; Mon, 16 May 2022 14:03:23 +0100 (IST) Received: (qmail 2770 invoked from network); 16 May 2022 13:03:23 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.198.246]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 16 May 2022 13:03:23 -0000 Date: Mon, 16 May 2022 14:03:20 +0100 From: Mel Gorman To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Dave Hansen , Tom Lendacky , Rick Edgecombe , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , "Kirill A. Shutemov" , Tianyu Lan , "Aneesh Kumar K.V" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, vbabka@suse.cz, akpm@linux-foundation.org, willy@infradead.org Subject: Re: Is _PAGE_PROTNONE set only for user mappings? Message-ID: <20220516130319.GM3441@techsingularity.net> References: <20220506051940.156952-1-42.hyeyoo@gmail.com> <56f89895-601e-44c9-bda4-5fae6782e27e@amd.com> <5fe161cb-6c55-6c4d-c208-16c77e115d3f@amd.com> <8c2735ac-0335-6e2a-8341-8266d5d13c30@intel.com> <20220512103748.GH3441@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C8BD91400C3 Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of mgorman@techsingularity.net designates 81.17.249.192 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net; dmarc=none X-Rspam-User: X-Stat-Signature: u83tg4wggxk97766oh7cdt53nsoxnohk X-HE-Tag: 1652706201-977916 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: On Fri, May 13, 2022 at 02:33:38PM +0900, Hyeonggon Yoo wrote: > On Thu, May 12, 2022 at 11:37:48AM +0100, Mel Gorman wrote: > > On Wed, May 11, 2022 at 02:20:45PM +0900, Hyeonggon Yoo wrote: > > > > pgprot_t vm_get_page_prot(unsigned long vm_flags) > > > > { > > > > pgprot_t ret = __pgprot(pgprot_val(protection_map[vm_flags & > > > > (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) | > > > > pgprot_val(arch_vm_get_page_prot(vm_flags))); > > > > > > > > return arch_filter_pgprot(ret); > > > > } > > > > EXPORT_SYMBOL(vm_get_page_prot); > > > > > > I guess it's only set for processes' VMA if no caller is abusing > > > vm_get_page_prot() for kernel mappings. > > > > > > But yeah, just quick guessing does not make us convinced. > > > Let's Cc people working on mm. > > > > > > If kernel never uses _PAGE_PROTNONE for kernel mappings, it's just okay > > > not to clear _PAGE_GLOBAL at first in __change_page_attr() if it's not user address, > > > because no user will confuse _PAGE_GLOBAL as _PAGE_PROTNONE if it's kernel > > > address. right? > > > > > > > I'm not aware of a case where _PAGE_BIT_PROTNONE is used for a kernel > > address expecting PROT_NONE semantics instead of the global bit. NUMA > > Balancing is not going to accidentally treat a kernel address as if it's > > a NUMA hinting fault. By the time a fault is determining if a PTE access > > is a numa hinting fault or accesssing a PROT_NONE region, it has been > > established that it is a userspace address backed by a valid VMA. > > > > Thanks Mel, and IIUC nor does do_kern_addr_fault() in arch/x86/mm/fault.c > expect _PAGE_PROTNONE instead of _PAGE_GLOBAL. I want to make it clear > in the code that _PAGE_PROTNONE is only used for user mappings. > > How does below look? > I've no strong objections. I worry that this somehow could be used to set PAGE_USER on a kernel mapping page and maybe a comment would be more appropriate. However, I'm failing to imagine how NUMA balancing could be fooled into doing that. -- Mel Gorman SUSE Labs