diff mbox series

[v2,8/8] mm: hugetlb_vmemmap: use PTRS_PER_PTE instead of PMD_SIZE / PAGE_SIZE

Message ID 20220628092235.91270-9-songmuchun@bytedance.com (mailing list archive)
State New
Headers show
Series Simplify hugetlb vmemmap and improve its readability | expand

Commit Message

Muchun Song June 28, 2022, 9:22 a.m. UTC
There is already a macro PTRS_PER_PTE to represent the number of page table
entries, just use it.

Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
 mm/hugetlb_vmemmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mike Kravetz June 29, 2022, 12:39 a.m. UTC | #1
On 06/28/22 17:22, Muchun Song wrote:
> There is already a macro PTRS_PER_PTE to represent the number of page table
> entries, just use it.
> 
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
>  mm/hugetlb_vmemmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
> index 6bbc445b1a66..65b527e1799c 100644
> --- a/mm/hugetlb_vmemmap.c
> +++ b/mm/hugetlb_vmemmap.c
> @@ -48,7 +48,7 @@ static int __split_vmemmap_huge_pmd(pmd_t *pmd, unsigned long start)
>  
>  	pmd_populate_kernel(&init_mm, &__pmd, pgtable);
>  
> -	for (i = 0; i < PMD_SIZE / PAGE_SIZE; i++, addr += PAGE_SIZE) {
> +	for (i = 0; i < PTRS_PER_PTE; i++, addr += PAGE_SIZE) {
>  		pte_t entry, *pte;
>  		pgprot_t pgprot = PAGE_KERNEL;
>  
> -- 
> 2.11.0
> 

That certainly seems like right macro/value to use.

Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
diff mbox series

Patch

diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index 6bbc445b1a66..65b527e1799c 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -48,7 +48,7 @@  static int __split_vmemmap_huge_pmd(pmd_t *pmd, unsigned long start)
 
 	pmd_populate_kernel(&init_mm, &__pmd, pgtable);
 
-	for (i = 0; i < PMD_SIZE / PAGE_SIZE; i++, addr += PAGE_SIZE) {
+	for (i = 0; i < PTRS_PER_PTE; i++, addr += PAGE_SIZE) {
 		pte_t entry, *pte;
 		pgprot_t pgprot = PAGE_KERNEL;