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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39825C54FD2 for ; Wed, 25 Mar 2020 02:58:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EF81720724 for ; Wed, 25 Mar 2020 02:58:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF81720724 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9ABC36B000A; Tue, 24 Mar 2020 22:58:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 95C736B000C; Tue, 24 Mar 2020 22:58:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 879986B000D; Tue, 24 Mar 2020 22:58:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0024.hostedemail.com [216.40.44.24]) by kanga.kvack.org (Postfix) with ESMTP id 6EF8A6B000A for ; Tue, 24 Mar 2020 22:58:56 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1415C8248047 for ; Wed, 25 Mar 2020 02:58:56 +0000 (UTC) X-FDA: 76632377472.09.game09_13b0c69849f27 X-HE-Tag: game09_13b0c69849f27 X-Filterd-Recvd-Size: 4775 Received: from huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Wed, 25 Mar 2020 02:58:55 +0000 (UTC) Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 2FC8EC61B4371320B3C4; Wed, 25 Mar 2020 10:58:52 +0800 (CST) Received: from [10.173.228.124] (10.173.228.124) by smtp.huawei.com (10.3.19.211) with Microsoft SMTP Server (TLS) id 14.3.487.0; Wed, 25 Mar 2020 10:58:47 +0800 Subject: Re: [PATCH 1/4] hugetlbfs: add arch_hugetlb_valid_size To: Mike Kravetz , Dave Hansen , , , , , , , , CC: Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , "Christian Borntraeger" , David S.Miller , Thomas Gleixner , Ingo Molnar , "Dave Hansen" , Jonathan Corbet , Andrew Morton References: <20200318220634.32100-1-mike.kravetz@oracle.com> <20200318220634.32100-2-mike.kravetz@oracle.com> <831a0773-1ba6-4d72-44b9-7472123b8528@intel.com> <5aceea6a-8dc0-a44b-80c6-94511b5c75ca@oracle.com> From: "Longpeng (Mike, Cloud Infrastructure Service Product Dept.)" Message-ID: <5ea6313e-ec4f-a043-632b-ef2901ce2cc9@huawei.com> Date: Wed, 25 Mar 2020 10:58:46 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <5aceea6a-8dc0-a44b-80c6-94511b5c75ca@oracle.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.173.228.124] X-CFilter-Loop: Reflected 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 2020/3/19 6:52, Mike Kravetz wrote: > On 3/18/20 3:15 PM, Dave Hansen wrote: >> Hi Mike, >> >> The series looks like a great idea to me. One nit on the x86 bits, >> though... >> >>> diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c >>> index 5bfd5aef5378..51e6208fdeec 100644 >>> --- a/arch/x86/mm/hugetlbpage.c >>> +++ b/arch/x86/mm/hugetlbpage.c >>> @@ -181,16 +181,25 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr, >>> #endif /* CONFIG_HUGETLB_PAGE */ >>> >>> #ifdef CONFIG_X86_64 >>> +bool __init arch_hugetlb_valid_size(unsigned long long size) >>> +{ >>> + if (size == PMD_SIZE) >>> + return true; >>> + else if (size == PUD_SIZE && boot_cpu_has(X86_FEATURE_GBPAGES)) >>> + return true; >>> + else >>> + return false; >>> +} >> >> I'm pretty sure it's possible to have a system without 2M/PMD page >> support. We even have a handy-dandy comment about it in >> arch/x86/include/asm/required-features.h: >> >> #ifdef CONFIG_X86_64 >> #ifdef CONFIG_PARAVIRT >> /* Paravirtualized systems may not have PSE or PGE available */ >> #define NEED_PSE 0 >> ... >> >> I *think* you need an X86_FEATURE_PSE check here to be totally correct. >> >> if (size == PMD_SIZE && cpu_feature_enabled(X86_FEATURE_PSE)) >> return true; >> >> BTW, I prefer cpu_feature_enabled() to boot_cpu_has() because it >> includes disabled-features checking. I don't think any of it matters >> for these specific features, but I generally prefer it on principle. > > Sounds good. I'll incorporate those changes into a v2, unless someone > else with has a different opinion. > > BTW, this patch should not really change the way the code works today. > It is mostly a movement of code. Unless I am missing something, the > existing code will always allow setup of PMD_SIZE hugetlb pages. > Hi Mike, Inspired by Dave's opinion, it seems the x86-specific hugepages_supported should also need to use cpu_feature_enabled instead. Also, I wonder if the hugepages_supported is correct ? There're two arch specific hugepages_supported: x86: #define hugepages_supported() boot_cpu_has(X86_FEATURE_PSE) and s390: #define hugepages_supported() (MACHINE_HAS_EDAT1) Is it possible that x86 has X86_FEATURE_GBPAGES but hasn't X86_FEATURE_GBPAGES or s390 has MACHINE_HAS_EDAT2 but hasn't MACHINE_HAS_EDAT1 ? --- Regards, Longpeng(Mike)