Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp652406imb; Fri, 1 Mar 2019 10:14:03 -0800 (PST) X-Google-Smtp-Source: APXvYqwZMgDOccZEO1VG4V+AwA5Qu1UTxWb7YqbMRn9Y65Q7pYjMR4uFr8prlQyW7jTACikZqogJ X-Received: by 2002:a17:902:8504:: with SMTP id bj4mr6576516plb.200.1551464042983; Fri, 01 Mar 2019 10:14:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551464042; cv=none; d=google.com; s=arc-20160816; b=SAVfgFkXClHmF5KTcF5jxSE+4HWVcCzhmZXZ6UWyV8/Yu6DeP0V9rxhZRCoN86GNZz DPxLoR4ePH7qROHFN9VRAfEwctHmxrCfGZyDMIYPms2d1aLpS59bPRxPtyaOzbu9PgfE XB6gjE4GoeYOvt5Vs+mY32CHlOJjrZGXxm9cUZtnseqTlvJoBBqu331ZUHfd/T8ECW8W kaDdnWmtxghwdFUBMPUJH128z+tKfZMFT0hph+TM8gybsHxR2fgd6/IRwxsStoATPmsb vmqhMNkV6MnurO7jV69RCWIlSJJzXaBt4tPG1TP2CQ6wrh+OvJZP5J30C8+up/x99NfZ PtpQ== 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=NpucD7YBrSs74vzv0AXK91DfS+GP9Fp13cRwteMq25o=; b=AUQhrLfU0IQjFft+Jb0NjXdm9yD2QSRlBPwKPAcjDRHnN7z14s9yLzh18B3mHxANUg 8zSCeLNs/8kp+sRhYZNVt4Nt7PKHmRNdICkJe3aj1iPtcpePMDtSCKLzlnLKX0GFb9Tl KVoH21z9o69O4SCiYB4budHlzR3MRRBB8mrhH1I1Z54ujCTIn4p8ZVw91fKSfgUCfibC BGc/mCj2JC57iE1cfTgEEumq3CiqPal01MUf1xmDbc3LbiQM1resC0gtL8ffXtUlV6I2 xQOr/S37q+cNaJVf5BytOp72NZmBzBPdfdF23cDS3hsFiL4YHJBurH30uNGZDMf9YzjB TFwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=JEyoc1et; 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 90si20955836pfs.173.2019.03.01.10.13.46; Fri, 01 Mar 2019 10:14:02 -0800 (PST) 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-2018-07-02 header.b=JEyoc1et; 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 S2389606AbfCARxX (ORCPT + 99 others); Fri, 1 Mar 2019 12:53:23 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:48402 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728212AbfCARxX (ORCPT ); Fri, 1 Mar 2019 12:53:23 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x21Hn5jo062465; Fri, 1 Mar 2019 17:52:05 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-2018-07-02; bh=NpucD7YBrSs74vzv0AXK91DfS+GP9Fp13cRwteMq25o=; b=JEyoc1et9IUl4twUIN7FXN5HbH3g9uCVH6yniiL/mlA6a0Njg1bpBZ3TlW/+rOgFgtnF ko5cw+9Y4gGEflsAEaeReQSQLLwb2eggXY+2FMlDTVmt6CYjXsVNDeFG98zGMtCKt5Yk Fq4OLiaoXpNOX1gKniCDuEEuTulYVV8O4rJtPTOzt7Zmk+uIuAf9vwbyJJP62RWCqIT5 LOD5TRMphV1Ye90VpvGC3k6o0NTQHttJ9NOYRiULbbMt/NfT8zOxJp1fnVOccCAGJLOO ID0LYvleQ2Yn00z94C+aNxpOC9QHc40ZkLvYPu8TkCUHlAEp+QFfTOy1fisakExP8i21 Sg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2qtupervyr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Mar 2019 17:52:04 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x21HpwU5007124 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Mar 2019 17:51:58 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x21Hpqdx018558; Fri, 1 Mar 2019 17:51:53 GMT Received: from [192.168.1.164] (/50.38.38.67) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Mar 2019 09:51:52 -0800 Subject: Re: [PATCH v4 4/4] hugetlb: allow to free gigantic pages regardless of the configuration To: Alexandre Ghiti Cc: Dave Hansen , Yoshinori Sato , Rich Felker , "David S . Miller" , Vlastimil Babka , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Martin Schwidefsky , Heiko Carstens , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, Dave Hansen , Andy Lutomirski , 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: <20190228063604.15298-1-alex@ghiti.fr> <20190228063604.15298-5-alex@ghiti.fr> <9a385cc8-581c-55cf-4a85-10b5c4dd178c@intel.com> <31212559-d397-88fb-eaec-60f6417436c8@oracle.com> <6c842251-1bed-4d79-bf6d-997006ec72e2@intel.com> <6ea4119a-0ecb-511d-3aab-269004245a08@oracle.com> <1cfaca88-a219-d057-3ab8-37fb1c1687d6@ghiti.fr> From: Mike Kravetz Message-ID: <0d3de196-bd71-3ec9-00cd-f8274c9c5f53@oracle.com> Date: Fri, 1 Mar 2019 09:51:50 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9182 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 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-1903010124 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/1/19 5:21 AM, Alexandre Ghiti wrote: > On 03/01/2019 07:25 AM, Alex Ghiti wrote: >> On 2/28/19 5:26 PM, Mike Kravetz wrote: >>> On 2/28/19 12:23 PM, Dave Hansen wrote: >>>> On 2/28/19 11:50 AM, Mike Kravetz wrote: >>>>> On 2/28/19 11:13 AM, Dave Hansen wrote: >>>>>>> + if (hstate_is_gigantic(h) && !IS_ENABLED(CONFIG_CONTIG_ALLOC)) { >>>>>>> + spin_lock(&hugetlb_lock); >>>>>>> + if (count > persistent_huge_pages(h)) { >>>>>>> + spin_unlock(&hugetlb_lock); >>>>>>> + return -EINVAL; >>>>>>> + } >>>>>>> + goto decrease_pool; >>>>>>> + } >>>>>> This choice confuses me. The "Decrease the pool size" code already >>>>>> works and the code just falls through to it after skipping all the >>>>>> "Increase the pool size" code. >>>>>> >>>>>> Why did did you need to add this case so early? Why not just let it >>>>>> fall through like before? >>>>> I assume you are questioning the goto, right? You are correct in that >>>>> it is unnecessary and we could just fall through. >>>> Yeah, it just looked odd to me. > >> I'd rather avoid useless checks when we already know they won't >> be met and I think that makes the code more understandable. >> >> But that's up to you for the next version. I too find some value in the goto. It tells me this !CONFIG_CONTIG_ALLOC case is special and we are skipping the normal checks. But, removing the goto is not a requirement for me. >>>>> However, I wonder if we might want to consider a wacky condition that the >>>>> above check would prevent. Consider a system/configuration with 5 gigantic ... >> >> If I may, I think that this is the kind of info the user wants to have and we should >> return an error when it is not possible to allocate runtime huge pages. >> I already noticed that if someone asks for 10 huge pages, and only 5 are allocated, >> no error is returned to the user and I found that surprising. Upon further thought, let's not consider this wacky permanent -> surplus -> permanent case. I just can't see it being an actual use case. IIUC, that 'no error' behavior is somewhat expected. I seem to recall previous discussions about changing with the end result to leave as is. >>>> @@ -2428,7 +2442,9 @@ static ssize_t __nr_hugepages_store_common(bool obey_mempolicy, >>>> } else >>>> nodes_allowed = &node_states[N_MEMORY]; >>>> - h->max_huge_pages = set_max_huge_pages(h, count, nodes_allowed); >>>> + err = set_max_huge_pages(h, count, nodes_allowed); >>>> + if (err) >>>> + goto out; >>>> if (nodes_allowed != &node_states[N_MEMORY]) >>>> NODEMASK_FREE(nodes_allowed); >>> Do note that I beleive there is a bug the above change. The code after >>> the out label is: >>> >>> out: >>> NODEMASK_FREE(nodes_allowed); >>> return err; >>> } >>> >>> With the new goto, we need the same >>> if (nodes_allowed != &node_states[N_MEMORY]) before NODEMASK_FREE(). >>> >>> Sorry, I missed this in previous versions. >> >> Oh right, I'm really sorry I missed that, thank you for noticing. This is the only issue I have with the code in hugetlb.c. For me, the goto can stay or go. End result is the same. -- Mike Kravetz