Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5098798img; Wed, 27 Mar 2019 01:58:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzr27vjPCA0AvmY2WbWj3WPEZreL9iAhax04a7+NlYJPAr3pLtHhamjkH/rHRHNcWiqP5aF X-Received: by 2002:a17:902:7242:: with SMTP id c2mr212121pll.245.1553677086084; Wed, 27 Mar 2019 01:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553677086; cv=none; d=google.com; s=arc-20160816; b=HvsoV8RnwjbGUBO+sA8MZfc3IKy65c8MO4mLko1jfMIpaZTStuSnDUkxUYoXSmDqI/ 4KhtocE839oHvOXHT8/tHDZznvkTSAMEqjXFWg5ZD/9XWWA8SnxNbSbhYJexexFAOPIB 8bpvLVfNp7Uq53HgQahC66lKPNdBt7Y9+zjEPWHl9797xUpeHw7kSPUTlwcdd0vKJ92S DKDWqEC729YrM3q3jKbHi31z2rWkRvqZ4b+ggFihzCQK55MYozm21qyJRyfm4f/xT1FY pgp2eayDTCjXCdpyqTq+asM1bnFWI78TljtjswktUJT8krVIj+i8emDI6m4TzTCiPzUi cN4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:from :references:to:subject; bh=JDZinxg0OFUS7XIsBd8v6a/rMcz29fIEzBnJEif35Ig=; b=Q0MH6t5VJZ70DyU6Je/loTzngCec6C5lBKdHLTvkZMpISWI6VI8xvo7TN7Dk+BIGUE wX/eSVtqWHpjgnZ3yuEbtikFe5zkF3snUVJhiubgu6WseAbdUg3dmzKPErdJdvhgAZlm NNi5ocjmLhbZuCcVBHxX4Ob4kasP6DtL2NvbQfCdqYEiBBUQ1EmIlHKRpBEASngqLN0D ZrMevIw6tO7IxJK9cew1MWIcOx56+F6B048oWrpAeHrkamojarLmcWMC9IRHfdsw05eA CMsJ5r9Vv4VbaZ/rTqJLW89mgcgCmUoAplehK6v3CgV3k8+8gae0XRqNQPmmPJ5JitXL wSDQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si4320107pgi.449.2019.03.27.01.57.51; Wed, 27 Mar 2019 01:58:06 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732177AbfC0I4B (ORCPT + 99 others); Wed, 27 Mar 2019 04:56:01 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34928 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726241AbfC0I4B (ORCPT ); Wed, 27 Mar 2019 04:56:01 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2R8mpgH034111 for ; Wed, 27 Mar 2019 04:56:00 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2rg3ykdb7n-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Mar 2019 04:55:59 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Mar 2019 08:55:59 -0000 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 27 Mar 2019 08:55:52 -0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2R8tnDw14680118 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Mar 2019 08:55:49 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49C8FC6055; Wed, 27 Mar 2019 08:55:49 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 10CF9C6059; Wed, 27 Mar 2019 08:55:39 +0000 (GMT) Received: from [9.102.0.57] (unknown [9.102.0.57]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 27 Mar 2019 08:55:39 +0000 (GMT) Subject: Re: [PATCH v8 4/4] hugetlb: allow to free gigantic pages regardless of the configuration To: Alexandre Ghiti , mpe@ellerman.id.au, Andrew Morton , Vlastimil Babka , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Paul Mackerras , Martin Schwidefsky , Heiko Carstens , Yoshinori Sato , Rich Felker , "David S . Miller" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, Dave Hansen , Andy Lutomirski , Peter Zijlstra , Mike Kravetz , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-mm@kvack.org References: <20190327063626.18421-1-alex@ghiti.fr> <20190327063626.18421-5-alex@ghiti.fr> From: "Aneesh Kumar K.V" Date: Wed, 27 Mar 2019 14:25:38 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19032708-8235-0000-0000-00000E73BD0A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010822; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000282; SDB=6.01180325; UDB=6.00617688; IPR=6.00961042; MB=3.00026176; MTD=3.00000008; XFM=3.00000015; UTC=2019-03-27 08:55:58 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19032708-8236-0000-0000-000044ECBA18 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-27_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903270065 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/27/19 2:14 PM, Alexandre Ghiti wrote: > > > On 03/27/2019 08:01 AM, Aneesh Kumar K.V wrote: >> On 3/27/19 12:06 PM, Alexandre Ghiti wrote: >>> On systems without CONTIG_ALLOC activated but that support gigantic >>> pages, >>> boottime reserved gigantic pages can not be freed at all. This patch >>> simply enables the possibility to hand back those pages to memory >>> allocator. >>> >>> Signed-off-by: Alexandre Ghiti >>> Acked-by: David S. Miller [sparc] >>> >>> diff --git a/arch/powerpc/include/asm/book3s/64/hugetlb.h >>> b/arch/powerpc/include/asm/book3s/64/hugetlb.h >>> index ec2a55a553c7..7013284f0f1b 100644 >>> --- a/arch/powerpc/include/asm/book3s/64/hugetlb.h >>> +++ b/arch/powerpc/include/asm/book3s/64/hugetlb.h >>> @@ -36,8 +36,8 @@ static inline int hstate_get_psize(struct hstate >>> *hstate) >>>       } >>>   } >>>   -#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE >>> -static inline bool gigantic_page_supported(void) >>> +#define __HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED >>> +static inline bool gigantic_page_runtime_supported(void) >>>   { >>>       /* >>>        * We used gigantic page reservation with hypervisor assist in >>> some case. >>> @@ -49,7 +49,6 @@ static inline bool gigantic_page_supported(void) >>>         return true; >>>   } >>> -#endif >>>     /* hugepd entry valid bit */ >>>   #define HUGEPD_VAL_BITS        (0x8000000000000000UL) >> >> Is that correct when CONTIG_ALLOC is not enabled? I guess we want >> >> gigantic_page_runtime_supported to return false when CONTIG_ALLOC is >> not enabled on all architectures and on POWER when it is enabled we >> want it to be conditional as it is now. >> >> -aneesh >> > > CONFIG_ARCH_HAS_GIGANTIC_PAGE is set by default when an architecture > supports gigantic > pages: on its own, it allows to allocate boottime gigantic pages AND to > free them at runtime > (this is the goal of this series), but not to allocate runtime gigantic > pages. > If CONTIG_ALLOC is set, it allows in addition to allocate runtime > gigantic pages. > > I re-introduced the runtime checks because we can't know at compile time > if powerpc can > or not support gigantic pages. > > So for all architectures, gigantic_page_runtime_supported only depends on > CONFIG_ARCH_HAS_GIGANTIC_PAGE enabled or not. The possibility to > allocate runtime > gigantic pages is dealt with after those runtime checks. > you removed that #ifdef in the patch above. ie we had #ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE static inline bool gigantic_page_supported(void) { /* * We used gigantic page reservation with hypervisor assist in some case. * We cannot use runtime allocation of gigantic pages in those platforms * This is hash translation mode LPARs. */ if (firmware_has_feature(FW_FEATURE_LPAR) && !radix_enabled()) return false; return true; } #endif This is now #define __HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED static inline bool gigantic_page_runtime_supported(void) { if (firmware_has_feature(FW_FEATURE_LPAR) && !radix_enabled()) return false; return true; } I am wondering whether it should be #define __HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED static inline bool gigantic_page_runtime_supported(void) { if (!IS_ENABLED(CONFIG_CONTIG_ALLOC)) return false; if (firmware_has_feature(FW_FEATURE_LPAR) && !radix_enabled()) return false; return true; } or add that #ifdef back. > By the way, I forgot to ask you why you think that if an arch cannot > allocate runtime gigantic > pages, it should not be able to free boottime gigantic pages ? > on virtualized platforms like powervm which use a paravirtualized page table update mechanism (we dont' have two level table). The ability to map a page huge depends on how hypervisor allocated the guest ram. Hypervisor also allocates the guest specific page table of a specific size depending on how many pages are going to be mapped by what page size. on POWER we indicate possible guest real address that can be mapped via hugepage (in this case 16G) using a device tree node (ibm,expected#pages) . It is expected that we will map these pages only as 16G pages. Hence we cannot free them back to the buddy where it could get mapped via 64K page size. -aneesh