From: Mike Kravetz <mike.kravetz@oracle.com>
To: Miaohe Lin <linmiaohe@huawei.com>, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/hugetlb: use some helper functions to cleanup code
Date: Tue, 2 Mar 2021 14:18:53 -0800 [thread overview]
Message-ID: <8fe08844-3f03-539b-a442-580b7b258f5e@oracle.com> (raw)
In-Reply-To: <20210210065346.21958-1-linmiaohe@huawei.com>
On 2/9/21 10:53 PM, Miaohe Lin wrote:
> We could use pages_per_huge_page to get the number of pages per hugepage,
> use get_hstate_idx to calculate hstate index, and use hstate_is_gigantic
> to check if a hstate is gigantic to make code more succinct.
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
These are all straight forward substitutions of open coded calculations
with the appropriate helper routine.
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
> ---
> fs/hugetlbfs/inode.c | 2 +-
> mm/hugetlb.c | 6 +++---
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 701c82c36138..c262566f7c5d 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -1435,7 +1435,7 @@ static int get_hstate_idx(int page_size_log)
>
> if (!h)
> return -1;
> - return h - hstates;
> + return hstate_index(h);
> }
>
> /*
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 8f6c98096476..da347047ea10 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1271,7 +1271,7 @@ static void free_gigantic_page(struct page *page, unsigned int order)
> static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask,
> int nid, nodemask_t *nodemask)
> {
> - unsigned long nr_pages = 1UL << huge_page_order(h);
> + unsigned long nr_pages = pages_per_huge_page(h);
> if (nid == NUMA_NO_NODE)
> nid = numa_mem_id();
>
> @@ -3262,10 +3262,10 @@ static int __init hugepages_setup(char *s)
>
> /*
> * Global state is always initialized later in hugetlb_init.
> - * But we need to allocate >= MAX_ORDER hstates here early to still
> + * But we need to allocate gigantic hstates here early to still
> * use the bootmem allocator.
> */
> - if (hugetlb_max_hstate && parsed_hstate->order >= MAX_ORDER)
> + if (hugetlb_max_hstate && hstate_is_gigantic(parsed_hstate))
> hugetlb_hstate_alloc_pages(parsed_hstate);
>
> last_mhp = mhp;
>
prev parent reply other threads:[~2021-03-02 23:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-10 6:53 [PATCH] mm/hugetlb: use some helper functions to cleanup code Miaohe Lin
2021-02-10 8:35 ` David Hildenbrand
2021-02-10 8:51 ` Miaohe Lin
2021-03-02 11:46 ` Miaohe Lin
2021-03-02 22:18 ` Mike Kravetz [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=8fe08844-3f03-539b-a442-580b7b258f5e@oracle.com \
--to=mike.kravetz@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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