Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3131467ybz; Mon, 27 Apr 2020 10:30:40 -0700 (PDT) X-Google-Smtp-Source: APiQypJy93vbAfpkZhqGhq1JEcA43FiHzBheGMue4E3OcKrKZUC9lCOx4Ot5xosgxpY1KDqTCJFm X-Received: by 2002:a17:906:7f0d:: with SMTP id d13mr21155244ejr.312.1588008640184; Mon, 27 Apr 2020 10:30:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588008640; cv=none; d=google.com; s=arc-20160816; b=fPWklOFed6GfCFtqO6AeLR0hgAmOnEfG+GMLa/FYNuv0wfNogrQ+51rG6Mcsh4p3el LeBTCdsAvTU8pWa9DCHlFISnw/hbbaOs7KEFMOCrJo7YdKZ9omBSzlINSeRyfSIs/udr 0k29M14mhcd5b2VXMxv9jynomRKGiIj+U1BPye4Y+hF+0/8cbgl06CU7bxEQv4dx+wld FonwPY3uxHJu3n+wqxkaDekPViySd2xMt7STvpDWWL1NqgAI+FEz2K+qeZNMUbG7g5mn 9uBgHVctI52yptFPt5th7+wIFuwI1qfG71ogS7TF0RgHMsg3llF0UiHZzQKAxjQ3wZ8x NPRg== 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=2uE+mNBlryTX8hj4mQm6UWx/K31ONdvabCMIKOLtOyU=; b=FPuSZslaHNFpLQwoCp2NX0ZXACC+N14TFX540C2jKHIc73Lg5XytahNJjQAi0Rh3Mg 75r7npcVJangYUEt+8KCRevCQB44xDOEtAhQZd4/bzLLzEdER8DwonoYlT5WnkpWFYgu PpIKP7+c888jxTwa47gsP1ftrPheD3RjBbFiQuc3O3HVC0vmg8Rrav/WuLav48KPA3uo rrBG7J5s+L96+dNb00UfePPW71v0ZInERzjdRWzJ5tPsSHClAt6XsrjluGJ0QZUt9pgB x/SJ42cEgA7QDGmlqHw4fUpyjBWlsAak8WkYCbRoldg/l1WdMJB3G04GLHaF+BhxT6EV 88lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=xTCYIbf7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id u19si156320edd.364.2020.04.27.10.30.16; Mon, 27 Apr 2020 10:30:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=xTCYIbf7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726509AbgD0R0m (ORCPT + 99 others); Mon, 27 Apr 2020 13:26:42 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:39610 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726262AbgD0R0m (ORCPT ); Mon, 27 Apr 2020 13:26:42 -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 03RHNNun032176; Mon, 27 Apr 2020 17:25:18 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=2uE+mNBlryTX8hj4mQm6UWx/K31ONdvabCMIKOLtOyU=; b=xTCYIbf7r5dai610kYmRfslwcsdHMEa6nYuPYmpMy+7WUkM9840zuWRmT2v1MiaH6Cad +fYWXCh8PyDfm6g+dIyG7BXcw3P9PeZXXougO6mlOLOylsBzYtMAlZzBzlRJJatu4I9N /AveFv2IyJQslCKqyCxuN+21YY9yrbN47PRg98fdwJ2kPrlLeXvj0DTMFDZB9ZWRvRM7 Ed+D9rxwrxjP3D1PFlRuVFcuOx+bDZYZm4iIaDJw0NmlAZ9XtPZO6joC0Rr+di/qtUTo oTv+6hlYH5+uyVoe6FV6yxjUAbpvIRv9bN/idQ6mOzjti7KgZTFrdQJIrHma1+l6CzbV yA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 30p2p00ddv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Apr 2020 17:25:18 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03RHMbqg085782; Mon, 27 Apr 2020 17:25:18 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 30mxpdrdfm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Apr 2020 17:25:18 +0000 Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03RHP5vx008462; Mon, 27 Apr 2020 17:25:05 GMT Received: from [192.168.2.157] (/71.63.128.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 27 Apr 2020 10:25:05 -0700 Subject: Re: [PATCH v3 2/4] hugetlbfs: move hugepagesz= parsing to arch independent code To: Sandipan Das Cc: 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, 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 , Christophe Leroy , Randy Dunlap , Mina Almasry , Peter Xu , Nitesh Narayan Lal , Andrew Morton References: <20200417185049.275845-1-mike.kravetz@oracle.com> <20200417185049.275845-3-mike.kravetz@oracle.com> <7583dfcc-62d8-2a54-6eef-bcb4e01129b3@gmail.com> From: Mike Kravetz Message-ID: <5a380060-38db-b690-1003-678ca0f28f07@oracle.com> Date: Mon, 27 Apr 2020 10:25:02 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <7583dfcc-62d8-2a54-6eef-bcb4e01129b3@gmail.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=9604 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 phishscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004270142 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9604 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 clxscore=1011 bulkscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004270142 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/26/20 10:04 PM, Sandipan Das wrote: > Hi Mike, > > On 18/04/20 12:20 am, Mike Kravetz wrote: >> Now that architectures provide arch_hugetlb_valid_size(), parsing >> of "hugepagesz=" can be done in architecture independent code. >> Create a single routine to handle hugepagesz= parsing and remove >> all arch specific routines. We can also remove the interface >> hugetlb_bad_size() as this is no longer used outside arch independent >> code. >> >> This also provides consistent behavior of hugetlbfs command line >> options. The hugepagesz= option should only be specified once for >> a specific size, but some architectures allow multiple instances. >> This appears to be more of an oversight when code was added by some >> architectures to set up ALL huge pages sizes. >> >> [...] >> >> diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c >> index de54d2a37830..2c3fa0a7787b 100644 >> --- a/arch/powerpc/mm/hugetlbpage.c >> +++ b/arch/powerpc/mm/hugetlbpage.c >> @@ -589,21 +589,6 @@ static int __init add_huge_page_size(unsigned long long size) >> return 0; >> } >> >> -static int __init hugepage_setup_sz(char *str) >> -{ >> - unsigned long long size; >> - >> - size = memparse(str, &str); >> - >> - if (add_huge_page_size(size) != 0) { >> - hugetlb_bad_size(); >> - pr_err("Invalid huge page size specified(%llu)\n", size); >> - } >> - >> - return 1; >> -} >> -__setup("hugepagesz=", hugepage_setup_sz); >> - >> [...] > > This isn't working as expected on powerpc64. > > [ 0.000000] Kernel command line: root=UUID=dc7b49cf-95a2-4996-8e7d-7c64ddc7a6ff hugepagesz=16G hugepages=2 > [ 0.000000] HugeTLB: huge pages not supported, ignoring hugepagesz = 16G > [ 0.000000] HugeTLB: huge pages not supported, ignoring hugepages = 2 > [ 0.284177] HugeTLB registered 16.0 MiB page size, pre-allocated 0 pages > [ 0.284182] HugeTLB registered 16.0 GiB page size, pre-allocated 0 pages > [ 2.585062] hugepagesz=16G > [ 2.585063] hugepages=2 > > The "huge pages not supported" messages are under a !hugepages_supported() > condition which checks if HPAGE_SHIFT is non-zero. On powerpc64, HPAGE_SHIFT > comes from the hpage_shift variable. At this point, it is still zero and yet > to be set. Hence the check fails. The reason being hugetlbpage_init_default(), > which sets hpage_shift, it now called after hugepage_setup_sz(). Thanks for catching this Sandipan. In the new arch independent version of hugepages_setup, I added the following code in patch 4 off this series: > +static int __init hugepages_setup(char *s) > { > unsigned long *mhp; > static unsigned long *last_mhp; > > + if (!hugepages_supported()) { > + pr_warn("HugeTLB: huge pages not supported, ignoring hugepages = %s\n", s); > + return 0; > + } > + > if (!parsed_valid_hugepagesz) { In fact, I added it to the beginning of all the hugetlb command line parsing routines. My 'thought' was to warn early if hugetlb pages were not supported. Previously, the first check for hugepages_supported() was in hugetlb_init() which ran after hugetlbpage_init_default(). The easy solution is to remove all the hugepages_supported() checks from command line parsing routines and rely on the later check in hugetlb_init(). Another reason for adding those early checks was to possibly prevent the preallocation of gigantic pages at command line parsing time. Gigantic pages are allocated at command line parsing time as they need to be allocated with the bootmem allocator. My concern is that there could be some strange configuration where !hugepages_supported(), yet we allocate gigantic pages from bootmem that can not be used or freeed later. powerpc is the only architecture which has it's own alloc_bootmem_huge_page routine. So, it handles this potential issue. I'll send out a fix shortly. -- Mike Kravetz