Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1771200rwn; Thu, 15 Sep 2022 23:55:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4fOaOO5vHW6y+JfmZjRnDefG4idLPnb4bzuqa21bWXWMkCghHOeNmD5nidDczUU7GOzHX+ X-Received: by 2002:a17:906:8468:b0:77a:5905:81aa with SMTP id hx8-20020a170906846800b0077a590581aamr2535929ejc.481.1663311314935; Thu, 15 Sep 2022 23:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663311314; cv=none; d=google.com; s=arc-20160816; b=n5R/luTiq3/uUfgbH6grXv/s8aW9tw5As1Ypc8ri/n2htQ/5CFObI98hTHbViIcW6r 66dSFuHSa6NzWIJawQDuzXg+GH1nblCX/pu38UkDqOylm9KFVmTXgx8IG62g8JYY7wYR K7X/46Jxzj8sSZSmhHSXx6649glcN0YNX20bWa0SWKKGF4i2ORfxC6DlZMvStVVB6j3c 4ScqAhnbOKmdLm6rd5hbwR3WPOXdq3jsHrLfy9rZIZze9eSomVEkvgSHisk8zx3vQlSn 1Ygku+f7fpA8EUSxO8/E0uiuFsBILcSz02vpOea/xrXIhqeLBYSy/rI8csAZK2PRuIca 799Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=TzdfP3UF8VAg/MShgGMLy+AoSjz8L15CB+k1fd5LeMo=; b=U/xGJpKqY25UCKrnKpiSVxpJ23j01g4XwA6C/0Gkf4wtxyEUYx7HKg++Fcazk414bQ TLMEBExyWpjOI4ZVzOnWkeVYk9/WDgeSHzYlV87AGTknsjOJCKcSsiiGujHlGYVrrVPR ipNxK98I2hx34g4Ca7dFIcKmE6kwAEe+hVFUnhfO8WYlCjcavuXUeoD1fYo3AP0E+GQ3 3f01krm6hztmYTTBwa9U8aTJKkEE5MubHQNVJvxMKe+P/VTf7qoLQlNODjcznTXojgFe xWxunzdm4PdtEI83djH0dynuyta3TtCud/6OfY0rKE+a3oCt8e+YcdhVrAixd8GepRYi CzLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w1-20020a1709061f0100b0077945c44b7fsi13047111ejj.856.2022.09.15.23.54.48; Thu, 15 Sep 2022 23:55:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230035AbiIPGj0 (ORCPT + 99 others); Fri, 16 Sep 2022 02:39:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229919AbiIPGjY (ORCPT ); Fri, 16 Sep 2022 02:39:24 -0400 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E031DA2A85 for ; Thu, 15 Sep 2022 23:39:23 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0VPw-h1-_1663310360; Received: from 30.240.97.224(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VPw-h1-_1663310360) by smtp.aliyun-inc.com; Fri, 16 Sep 2022 14:39:21 +0800 Message-ID: Date: Fri, 16 Sep 2022 14:39:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [PATCH] mm/hugetlb: add mis_resv_equal_free() func To: mike.kravetz@oracle.com Cc: songmuchun@bytedance.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220916063550.1650-1-xhao@linux.alibaba.com> From: haoxin In-Reply-To: <20220916063550.1650-1-xhao@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/9/16 下午2:35, Xin Hao 写道: > In hugetlb.c file, there are several places to compare the values of > 'h->free_huge_pages' and 'h->resv_huge_pages', it looks a bit messy, so > there add a new mis_resv_equal_free() func to do these. Sorry there make a mistake,  it add an extra letter 'm' mis_resv_equal_free,  i will send a new version,  please ignore this patch. > > Signed-off-by: Xin Hao > --- > mm/hugetlb.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 66496fc424f4..db6f63fb083f 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1191,6 +1191,11 @@ static struct page *dequeue_huge_page_nodemask(struct hstate *h, gfp_t gfp_mask, > return NULL; > } > > +static inline bool is_resv_equal_free(struct hstate *h) > +{ > + return (h->free_huge_pages - h->resv_huge_pages == 0) ? true : false; > +} > + > static struct page *dequeue_huge_page_vma(struct hstate *h, > struct vm_area_struct *vma, > unsigned long address, int avoid_reserve, > @@ -1207,12 +1212,11 @@ static struct page *dequeue_huge_page_vma(struct hstate *h, > * have no page reserves. This check ensures that reservations are > * not "stolen". The child may still get SIGKILLed > */ > - if (!vma_has_reserves(vma, chg) && > - h->free_huge_pages - h->resv_huge_pages == 0) > + if (!vma_has_reserves(vma, chg) && is_resv_equal_free(h)) > goto err; > > /* If reserves cannot be used, ensure enough pages are in the pool */ > - if (avoid_reserve && h->free_huge_pages - h->resv_huge_pages == 0) > + if (avoid_reserve && is_resv_equal_free(h)) > goto err; > > gfp_mask = htlb_alloc_mask(h); > @@ -2105,7 +2109,7 @@ int dissolve_free_huge_page(struct page *page) > if (!page_count(page)) { > struct page *head = compound_head(page); > struct hstate *h = page_hstate(head); > - if (h->free_huge_pages - h->resv_huge_pages == 0) > + if (is_resv_equal_free(h)) > goto out; > > /* > @@ -2315,7 +2319,7 @@ struct page *alloc_huge_page_nodemask(struct hstate *h, int preferred_nid, > nodemask_t *nmask, gfp_t gfp_mask) > { > spin_lock_irq(&hugetlb_lock); > - if (h->free_huge_pages - h->resv_huge_pages > 0) { > + if (!is_resv_equal_free(h)) { > struct page *page; > > page = dequeue_huge_page_nodemask(h, gfp_mask, preferred_nid, nmask);