* [PATCH] mm/hugetlb: use some helper functions to cleanup code
@ 2021-02-10 6:53 Miaohe Lin
2021-02-10 8:35 ` David Hildenbrand
0 siblings, 1 reply; 3+ messages in thread
From: Miaohe Lin @ 2021-02-10 6:53 UTC (permalink / raw)
To: akpm, mike.kravetz; +Cc: linux-mm, linux-kernel, linmiaohe
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>
---
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;
--
2.19.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/hugetlb: use some helper functions to cleanup code
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
0 siblings, 1 reply; 3+ messages in thread
From: David Hildenbrand @ 2021-02-10 8:35 UTC (permalink / raw)
To: Miaohe Lin, akpm, mike.kravetz; +Cc: linux-mm, linux-kernel
On 10.02.21 07:53, 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.
>
Another suggestion, please collect and group your cleanups for a
subsystem and send them in a single cleanup patch series where possible.
Again, makes life easier for reviewers and maintainers.
Thanks!
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/hugetlb: use some helper functions to cleanup code
2021-02-10 8:35 ` David Hildenbrand
@ 2021-02-10 8:51 ` Miaohe Lin
0 siblings, 0 replies; 3+ messages in thread
From: Miaohe Lin @ 2021-02-10 8:51 UTC (permalink / raw)
To: David Hildenbrand; +Cc: linux-mm, linux-kernel, akpm, mike.kravetz
On 2021/2/10 16:35, David Hildenbrand wrote:
> On 10.02.21 07:53, 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.
>>
>
> Another suggestion, please collect and group your cleanups for a subsystem and send them in a single cleanup patch series where possible. Again, makes life easier for reviewers and maintainers.
>
Many thanks for your suggestion again. I will keep it in mind. :)
> Thanks!
>
Thanks a lot.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-10 8:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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).