Re: [PATCH] s390/mm: Add missing ctor/dtor on page table upgrade

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23/01/2025 17:03, Alexander Gordeev wrote:
> Commit 78966b550289 ("s390: pgtable: add statistics for PUD and P4D
> level page table") misses the call to pagetable_p4d_ctor() against
> a newly allocated P4D table in crst_table_upgrade();
>
> Commit 68c601de75d8 ("mm: introduce ctor/dtor at PGD level") misses
> the call to pagetable_pgd_ctor() against a newly allocated PGD and
> the call to pagetable_dtor() against a newly allocated P4D that is
> about to be freed on crst_table_upgrade() PGD upgrade fail path.
>
> The missed constructors and destructor break (at least) the page
> table accounting when a process memory space is upgraded.
>
> Reported-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
> Closes: https://lore.kernel.org/all/20250122074954.8685-A-hca@xxxxxxxxxxxxx/
> Suggested-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
> Fixes: 78966b550289 ("s390: pgtable: add statistics for PUD and P4D level page table")
> Fixes: 68c601de75d8 ("mm: introduce ctor/dtor at PGD level")
> Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxxxxx>
> ---
> The patch is against:
>
>   git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git	next-20250123
>   git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm			mm-stable

Thank you for putting together this patch! I was completely unaware of
this "upgrade" path on s390.

> ---
>  arch/s390/mm/pgalloc.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/arch/s390/mm/pgalloc.c b/arch/s390/mm/pgalloc.c
> index a4e761902093..d33f55b7ee98 100644
> --- a/arch/s390/mm/pgalloc.c
> +++ b/arch/s390/mm/pgalloc.c
> @@ -88,12 +88,14 @@ int crst_table_upgrade(struct mm_struct *mm, unsigned long end)
>  		if (unlikely(!p4d))
>  			goto err_p4d;
>  		crst_table_init(p4d, _REGION2_ENTRY_EMPTY);
> +		pagetable_p4d_ctor(virt_to_ptdesc(p4d));

This block seems to be equivalent to p4d_alloc_one(), maybe it would be
preferable to just call p4d_alloc_one() here to avoid further mismatches
in the future (and reduce duplication)?


>  	}
>  	if (end > _REGION1_SIZE) {
>  		pgd = crst_table_alloc(mm);
>  		if (unlikely(!pgd))
>  			goto err_pgd;
>  		crst_table_init(pgd, _REGION1_ENTRY_EMPTY);
> +		pagetable_pgd_ctor(virt_to_ptdesc(pgd));

I was hoping this might be equivalent to pgd_alloc() but it does not
include a call to crst_table_init(). Since adding it would be apparently
undesirable (having read the other thread), it seems reasonable to add
the explicit constructor call.

>  	}
>  
>  	spin_lock_bh(&mm->page_table_lock);
> @@ -130,6 +132,7 @@ int crst_table_upgrade(struct mm_struct *mm, unsigned long end)
>  	return 0;
>  
>  err_pgd:
> +	pagetable_dtor(virt_to_ptdesc(p4d));
>  	crst_table_free(mm, p4d);

Similarly, this could be a call to p4d_free().

- Kevin

>  err_p4d:
>  	return -ENOMEM;





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux