From: David Hildenbrand <david@redhat.com>
To: Miaohe Lin <linmiaohe@huawei.com>,
akpm@linux-foundation.org, mike.kravetz@oracle.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm/hugetlb: use helper huge_page_size() to get hugepage size
Date: Fri, 12 Feb 2021 10:50:02 +0100 [thread overview]
Message-ID: <357ade66-8176-8ea6-92bd-f18fa540af93@redhat.com> (raw)
In-Reply-To: <20210209021803.49211-1-linmiaohe@huawei.com>
On 09.02.21 03:18, Miaohe Lin wrote:
> We can use helper huge_page_size() to get the hugepage size directly to
> simplify the code slightly.
>
> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
> v1 -> v2
> change huge_page_size(h) >> 10 to huge_page_size(h) / SZ_1K
> collect Reviewed-by tag
> ---
> mm/hugetlb.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 18628f8dbfb0..06719fdf9fd6 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -3199,7 +3199,7 @@ void __init hugetlb_add_hstate(unsigned int order)
> BUG_ON(order == 0);
> h = &hstates[hugetlb_max_hstate++];
> h->order = order;
> - h->mask = ~((1ULL << (order + PAGE_SHIFT)) - 1);
> + h->mask = ~(huge_page_size(h) - 1);
> for (i = 0; i < MAX_NUMNODES; ++i)
> INIT_LIST_HEAD(&h->hugepage_freelists[i]);
> INIT_LIST_HEAD(&h->hugepage_activelist);
> @@ -3474,7 +3474,7 @@ void hugetlb_report_meminfo(struct seq_file *m)
> for_each_hstate(h) {
> unsigned long count = h->nr_huge_pages;
>
> - total += (PAGE_SIZE << huge_page_order(h)) * count;
> + total += huge_page_size(h) * count;
>
> if (h == &default_hstate)
> seq_printf(m,
> @@ -3487,10 +3487,10 @@ void hugetlb_report_meminfo(struct seq_file *m)
> h->free_huge_pages,
> h->resv_huge_pages,
> h->surplus_huge_pages,
> - (PAGE_SIZE << huge_page_order(h)) / 1024);
> + huge_page_size(h) / SZ_1K);
> }
>
> - seq_printf(m, "Hugetlb: %8lu kB\n", total / 1024);
> + seq_printf(m, "Hugetlb: %8lu kB\n", total / SZ_1K);
> }
>
> int hugetlb_report_node_meminfo(char *buf, int len, int nid)
> @@ -3524,7 +3524,7 @@ void hugetlb_show_meminfo(void)
> h->nr_huge_pages_node[nid],
> h->free_huge_pages_node[nid],
> h->surplus_huge_pages_node[nid],
> - 1UL << (huge_page_order(h) + PAGE_SHIFT - 10));
> + huge_page_size(h) / SZ_1K);
> }
>
> void hugetlb_report_usage(struct seq_file *m, struct mm_struct *mm)
> @@ -3647,9 +3647,7 @@ static int hugetlb_vm_op_split(struct vm_area_struct *vma, unsigned long addr)
>
> static unsigned long hugetlb_vm_op_pagesize(struct vm_area_struct *vma)
> {
> - struct hstate *hstate = hstate_vma(vma);
> -
> - return 1UL << huge_page_shift(hstate);
> + return huge_page_size(hstate_vma(vma));
> }
>
> /*
>
Reviewed-by: David Hildenbrand <david@redhat.com>
Thanks!
--
Thanks,
David / dhildenb
prev parent reply other threads:[~2021-02-12 9:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 2:18 [PATCH v2] mm/hugetlb: use helper huge_page_size() to get hugepage size Miaohe Lin
2021-02-12 9:50 ` David Hildenbrand [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=357ade66-8176-8ea6-92bd-f18fa540af93@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.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;
as well as URLs for NNTP newsgroup(s).