linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] s390: Fix runtime warning about negative pgtables_bytes
@ 2018-03-01 22:40 Guenter Roeck
  2018-03-02 11:48 ` Martin Schwidefsky
  0 siblings, 1 reply; 2+ messages in thread
From: Guenter Roeck @ 2018-03-01 22:40 UTC (permalink / raw)
  To: Martin Schwidefsky
  Cc: linux-s390, linux-kernel, Guenter Roeck, Kirill A . Shutemov,
	Heiko Carstens

When running s390 images with 'compat' processes, the following
BUG is seen repeatedly.

BUG: non-zero pgtables_bytes on freeing mm: -16384

Bisect points to commit b4e98d9ac775 ("mm: account pud page tables").
Analysis shows that init_new_context() is called with
mm->context.asce_limit set to _REGION3_SIZE. In this situation,
pgtables_bytes remains set to 0 and is not increased. The message is
displayed when the affected process dies and mm_dec_nr_puds() is called.

Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Fixes: b4e98d9ac775 ("mm: account pud page tables")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
RFC since I have no idea if this is correct (or complete, for that matter).
All I can say is that the message is no longer seen after the patch is
applied.

 arch/s390/include/asm/mmu_context.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h
index 65154eaa3714..6c8ce15cde7b 100644
--- a/arch/s390/include/asm/mmu_context.h
+++ b/arch/s390/include/asm/mmu_context.h
@@ -63,6 +63,7 @@ static inline int init_new_context(struct task_struct *tsk,
 				   _ASCE_USER_BITS | _ASCE_TYPE_SEGMENT;
 		/* pgd_alloc() did not account this pmd */
 		mm_inc_nr_pmds(mm);
+		mm_inc_nr_puds(mm);
 	}
 	crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm));
 	return 0;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC PATCH] s390: Fix runtime warning about negative pgtables_bytes
  2018-03-01 22:40 [RFC PATCH] s390: Fix runtime warning about negative pgtables_bytes Guenter Roeck
@ 2018-03-02 11:48 ` Martin Schwidefsky
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Schwidefsky @ 2018-03-02 11:48 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-s390, linux-kernel, Kirill A . Shutemov, Heiko Carstens

On Thu,  1 Mar 2018 14:40:52 -0800
Guenter Roeck <linux@roeck-us.net> wrote:

> When running s390 images with 'compat' processes, the following
> BUG is seen repeatedly.
> 
> BUG: non-zero pgtables_bytes on freeing mm: -16384
> 
> Bisect points to commit b4e98d9ac775 ("mm: account pud page tables").
> Analysis shows that init_new_context() is called with
> mm->context.asce_limit set to _REGION3_SIZE. In this situation,
> pgtables_bytes remains set to 0 and is not increased. The message is
> displayed when the affected process dies and mm_dec_nr_puds() is called.
> 
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> Fixes: b4e98d9ac775 ("mm: account pud page tables")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> RFC since I have no idea if this is correct (or complete, for that matter).
> All I can say is that the message is no longer seen after the patch is
> applied.
> 
>  arch/s390/include/asm/mmu_context.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h
> index 65154eaa3714..6c8ce15cde7b 100644
> --- a/arch/s390/include/asm/mmu_context.h
> +++ b/arch/s390/include/asm/mmu_context.h
> @@ -63,6 +63,7 @@ static inline int init_new_context(struct task_struct *tsk,
>  				   _ASCE_USER_BITS | _ASCE_TYPE_SEGMENT;
>  		/* pgd_alloc() did not account this pmd */
>  		mm_inc_nr_pmds(mm);
> +		mm_inc_nr_puds(mm);
>  	}
>  	crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm));
>  	return 0;

The page table folding always makes a knot in my brain. After staring
at the code for a while I am now convinced that your patch is correct.
On free of a 2 level page table free_pud_range() does a p4d_clear()
which is turned into a nop as the page table is folded. But the
mm_dec_nr_puds() is done unconditionally and that is where the imbalance
comes from. Adding a counter mm_inc_nr_puds to init_new_context fixes
it.

Applied to s390/linux:fixes. Thanks.

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-02 11:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-01 22:40 [RFC PATCH] s390: Fix runtime warning about negative pgtables_bytes Guenter Roeck
2018-03-02 11:48 ` Martin Schwidefsky

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).