Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1138850ybh; Wed, 18 Mar 2020 15:56:24 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuQetD3fpJWRi0lhb+GNfE8i5QdNTWEYfW2Qs++fJUC3ixckpmS8fQDLhUqKWfsCNfkXZSv X-Received: by 2002:a9d:67c7:: with SMTP id c7mr6028716otn.85.1584572184532; Wed, 18 Mar 2020 15:56:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584572184; cv=none; d=google.com; s=arc-20160816; b=rC53jTgvdZZMMUcGLb9h5TkN+fDUmzJuoCZ2Z6x3OiarW5IGMCogVf/+jRtb+CTXuI feBc/g4EnzMaR3j1RyWsJV6+ATEQ2X9uNQDS97kJ4EijJUodN0KB74rWs+k2WuPIFvN4 u20H5rO1b9hxYDxwbo+Ht1/uQVsxRGaPCVJP/xkMNNAQVLwy+d1XdlHss/FF1j9dSNE6 MB3MSaxOo89JZpXY+Q5rG1BFOeo1eZmNxH0HZzSBP4stiCpZDho4bIG6AS2GXSSgSqBE waaQxYUBlRfwB2txvxlQJi5VUhj70zyPmj9xvaqvn7+tQnGNkGuhqfFAw8u7SdYwI9y0 T7Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=k6GRUsKzVXLcCjYW1URm4LWEsIVLbuUR75pRpcs7jfc=; b=rqkOFA9KEV0rzMJN8cga83q1xXrkrBmnZRM6aHT/ZwpWSaeeiZEpGjM7EiYJlkJT4a A1G7O24EUs+ZO18cg1ZHJ4tQWBLO4+uaHW9T/65MEFgjmilIo+rHL7SyzcpsZ22/Ump7 zhZJtTMwTdqNVGnEjA3PgS/AthDnf5sodTDVcAn5Q092X9bZYIrMKjRR5waxCd0Xqj9V 71rmGze3Vlvl9Iu3Y59kKQPFTdg7eVVw6i7ncRP3hNHJ2qhBlEFeu8qBcxTk0viIEuaT Os76vw/0SSv6Pakwv2thq0yVkTkZqFNlKOxAMgGCof2qxivxq3ObmpmSG7KUK8/GfaF3 b/XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Ce2szXcq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c8si214583otn.45.2020.03.18.15.56.11; Wed, 18 Mar 2020 15:56:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Ce2szXcq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727356AbgCRWzg (ORCPT + 99 others); Wed, 18 Mar 2020 18:55:36 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:36380 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726704AbgCRWzg (ORCPT ); Wed, 18 Mar 2020 18:55:36 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02IMrlf6071331; Wed, 18 Mar 2020 22:54:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=k6GRUsKzVXLcCjYW1URm4LWEsIVLbuUR75pRpcs7jfc=; b=Ce2szXcqKXTI+HYLH8FYP/wXV6iZiiKOFiXrEFWqdPJZZGa+j5A6up1nM+H+PFvqAruq 2bmtsY7uC4VN2eaTZy/ynVjVztGCL0aB3JQxl3COHF0Ov0PwR4HlLwExDxRFMh2/cNXG i1ybAR233CYhUfDGv/pxrloIrywaQulPtyk7ClLHZs9yCHfZzR5cpSIIIa+WT1rA5dzF NFd4ZArbsmv7PEUgi2CZJ24KAFXN2HF//8sIVskEaOldoq6xbpUb/mM3QxImkymGPtMk aIwWY1Fs+z9eC6yx+apJdCdvWN5RNRjcCWh+OF3G1lU2Pog392rIPJcyhg+sABAAxpu/ Rg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2yub2757m3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Mar 2020 22:54:54 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02IMq3hY125264; Wed, 18 Mar 2020 22:52:53 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2ys92j3h77-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Mar 2020 22:52:53 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02IMqo0j011508; Wed, 18 Mar 2020 22:52:50 GMT Received: from [192.168.1.206] (/71.63.128.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 18 Mar 2020 15:52:49 -0700 Subject: Re: [PATCH 1/4] hugetlbfs: add arch_hugetlb_valid_size To: Dave Hansen , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-doc@vger.kernel.org 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 , Longpeng , Andrew Morton References: <20200318220634.32100-1-mike.kravetz@oracle.com> <20200318220634.32100-2-mike.kravetz@oracle.com> <831a0773-1ba6-4d72-44b9-7472123b8528@intel.com> From: Mike Kravetz Message-ID: <5aceea6a-8dc0-a44b-80c6-94511b5c75ca@oracle.com> Date: Wed, 18 Mar 2020 15:52:46 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <831a0773-1ba6-4d72-44b9-7472123b8528@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9564 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 mlxscore=0 spamscore=0 bulkscore=0 adultscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003180098 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9564 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 impostorscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003180098 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- Mike Kravetz