From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 461F7ECAAD8 for ; Fri, 16 Sep 2022 06:39:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D50AA8D0003; Fri, 16 Sep 2022 02:39:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D00188D0001; Fri, 16 Sep 2022 02:39:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BEED58D0003; Fri, 16 Sep 2022 02:39:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id AFFC48D0001 for ; Fri, 16 Sep 2022 02:39:26 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 89C4041AC7 for ; Fri, 16 Sep 2022 06:39:26 +0000 (UTC) X-FDA: 79916997132.09.3BC8F3E Received: from out199-2.us.a.mail.aliyun.com (out199-2.us.a.mail.aliyun.com [47.90.199.2]) by imf18.hostedemail.com (Postfix) with ESMTP id DEBB81C00A4 for ; Fri, 16 Sep 2022 06:39:24 +0000 (UTC) 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663310365; a=rsa-sha256; cv=none; b=tTkfc+wVe5mD0gsdLZSDhA0dgNg2JiL/flepndNLfPGIqTQpnX0fsAqAJAlu8FT1LJkXBJ 2NWHN+hGK6+hSg8L2bT6xOipew5IYpDLur6yCjxGSlbd2+dqST6Bgli2ve3ETwmY8+9Qig igrlv8m8AON2yJm+1zDaDVl5UbxiH9c= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf18.hostedemail.com: domain of xhao@linux.alibaba.com designates 47.90.199.2 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663310365; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TzdfP3UF8VAg/MShgGMLy+AoSjz8L15CB+k1fd5LeMo=; b=V/da+5HN6DEdy82nHtwfkbPYAnCRG+STokJmCE9Az74wMsYqrRxow/4A8bq5JjpnOr/l/E CnKcl5ZSIwbXmgWjmi2ADedD+oNyxsmkiVLV2M2Jagn6ChToVFJRMPS3m/I4c70U1sKW6Z gmmdpZEXrlAuuTBiCu6uhJHT4vdebNE= X-Stat-Signature: bwnta9y531n46o19z1bpyu3mqn3uapxe X-Rspamd-Queue-Id: DEBB81C00A4 Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf18.hostedemail.com: domain of xhao@linux.alibaba.com designates 47.90.199.2 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com X-Rspamd-Server: rspam01 X-Rspam-User: X-HE-Tag: 1663310364-546639 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 在 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);