From: haoxin <xhao@linux.alibaba.com>
To: mike.kravetz@oracle.com
Cc: songmuchun@bytedance.com, akpm@linux-foundation.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/hugetlb: add mis_resv_equal_free() func
Date: Fri, 16 Sep 2022 14:39:19 +0800 [thread overview]
Message-ID: <bf5b8a5b-4a0f-a258-f0ba-5339b7382ec6@linux.alibaba.com> (raw)
In-Reply-To: <20220916063550.1650-1-xhao@linux.alibaba.com>
在 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 <xhao@linux.alibaba.com>
> ---
> 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);
prev parent reply other threads:[~2022-09-16 6:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 6:35 Xin Hao
2022-09-16 6:39 ` haoxin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bf5b8a5b-4a0f-a258-f0ba-5339b7382ec6@linux.alibaba.com \
--to=xhao@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=songmuchun@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox