All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qian Cai <cai@lca.pw>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Christophe Leroy <christophe.leroy@c-s.fr>,
	Linux Memory Management List <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mike Rapoport <rppt@linux.ibm.com>,
	Vineet Gupta <vgupta@synopsys.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"Kirill A . Shutemov" <kirill@shutemov.name>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	linux-snps-arc@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
	linux-s390@vger.kernel.org, linux-riscv@lists.infradead.org,
	the arch/x86 maintainers <x86@kernel.org>,
	linux-arch@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Subject: Re: [PATCH V14] mm/debug: Add tests validating architecture page table helpers
Date: Tue, 3 Mar 2020 20:39:39 -0500	[thread overview]
Message-ID: <12260F9A-695D-40F8-932F-61D86D77D441@lca.pw> (raw)
In-Reply-To: <e8516497-f1b9-b222-e219-73b68880ac75@arm.com>


> Below is slightly modified version of your change above and should still
> prevent the bug on powerpc. Will it be possible for you to re-test this
> ? Once confirmed, will send a patch enabling this test on powerpc64
> keeping your authorship. Thank you.

This works fine on radix MMU but I decided to go a bit future to test hash
MMU. The kernel will stuck here below. I did confirm that pte_alloc_map_lock()
was successful, so I don’t understand hash MMU well enough to tell why
it could still take an interrupt at pte_clear_tests() even before we calls
pte_unmap_unlock()?

[   33.881515][    T1] ok 8 - property-entry
[   33.883653][    T1] debug_vm_pgtable: debug_vm_pgtable: Validating
architecture page table helpers
[   60.418885][    C8] watchdog: BUG: soft lockup - CPU#8 stuck for 23s!
[swapper/0:1]
[   60.418913][    C8] Modules linked in:
[   60.418927][    C8] irq event stamp: 2896762
[   60.418945][    C8] hardirqs last  enabled at (2896761): [<c00000000000dec8>]
fast_exc_return_irq+0x28/0x34
[   60.418960][    C8] hardirqs last disabled at (2896762): [<c00000000000924c>]
decrementer_common+0x10c/0x130
[   60.418985][    C8] softirqs last  enabled at (2896760): [<c0000000009a1bf0>]
__do_softirq+0x640/0x8c8
[   60.419009][    C8] softirqs last disabled at (2896753): [<c000000000113cbc>]
irq_exit+0x16c/0x1d0
[   60.419024][    C8] CPU: 8 PID: 1 Comm: swapper/0 Not tainted 5.6.0-rc4-next-
20200303+ #7
[   60.419055][    C8] NIP:  c00000000103dc14 LR: c00000000103db0c CTR:
0000000000000000
[   60.419076][    C8] REGS: c00000003dd4fa30 TRAP: 0901   Not tainted  (5.6.0-
rc4-next-20200303+)
[   60.419107][    C8] MSR:  9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR:
42000222  XER: 00000000
[   60.419134][    C8] CFAR: c00000000103dc1c IRQMASK: 0 
[   60.419134][    C8] GPR00: c00000000103db0c c00000003dd4fcc0 c000000001657d00
05210001000000c0 
[   60.419134][    C8] GPR04: 8000000000000105 000000000000000a 00000000f4d9864c
0000000000000001 
[   60.419134][    C8] GPR08: 0000000000000000 ffffffffffffffff 0000000000000001
00000000000a0000 
[   60.419134][    C8] GPR12: 0000000000000000 c000001fffff9880 
[   60.419220][    C8] NIP [c00000000103dc14] debug_vm_pgtable+0x7a8/0xbb4
hash__pte_update at arch/powerpc/include/asm/book3s/64/hash.h:159
(inlined by) pte_update at arch/powerpc/include/asm/book3s/64/pgtable.h:359
(inlined by) pte_clear at arch/powerpc/include/asm/book3s/64/pgtable.h:477
(inlined by) pte_clear_tests at mm/debug_vm_pgtable.c:259
(inlined by) debug_vm_pgtable at mm/debug_vm_pgtable.c:368
[   60.419241][    C8] LR [c00000000103db0c] debug_vm_pgtable+0x6a0/0xbb4
pmd_basic_tests at mm/debug_vm_pgtable.c:74
(inlined by) debug_vm_pgtable at mm/debug_vm_pgtable.c:363
[   60.419260][    C8] Call Trace:
[   60.419278][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[   60.419302][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[   60.419325][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[   60.419363][    C8] Instruction dump:
[   60.419382][    C8] 7d075078 7ce74b78 7ce0f9ad 40c2fff0 7e449378 7fc3f378
4b03531d 60000000 
[   60.419416][    C8] 48000080 3920ffff 39400001 39000000 <7e00f8a8> 7e075039
40c2fff8 7e074878 
[   98.908889][    C8] rcu: INFO: rcu_sched self-detected stall on CPU
[   98.908933][    C8] rcu:         8-....: (6500 ticks this GP)
idle=522/1/0x4000000000000002 softirq=132/132 fqs=3250 
[   98.908963][    C8]         (t=6501 jiffies g=-719 q=510)
[   98.908984][    C8] NMI backtrace for cpu 8
[   98.909012][    C8] CPU: 8 PID: 1 Comm: swapper/0 Tainted:
G             L    5.6.0-rc4-next-20200303+ #7
[   98.909025][    C8] Call Trace:
[   98.909046][    C8] [c00000003dd4f360] [c000000000970fe0]
dump_stack+0xf4/0x164 (unreliable)
[   98.909070][    C8] [c00000003dd4f3b0] [c00000000097dcf4]
nmi_cpu_backtrace+0x1b4/0x1e0
[   98.909084][    C8] [c00000003dd4f450] [c00000000097df48]
nmi_trigger_cpumask_backtrace+0x228/0x2c0
[   98.909118][    C8] [c00000003dd4f500] [c000000000057bf8]
arch_trigger_cpumask_backtrace+0x28/0x40
[   98.909152][    C8] [c00000003dd4f520] [c000000000202dd4]
rcu_dump_cpu_stacks+0x1c4/0x234
[   98.909184][    C8] [c00000003dd4f5a0] [c000000000201634]
rcu_sched_clock_irq+0xd54/0x1130
[   98.909207][    C8] [c00000003dd4f6c0] [c000000000217068]
update_process_times+0x48/0xb0
[   98.909239][    C8] [c00000003dd4f6f0] [c0000000002358b4]
tick_sched_handle+0x34/0xb0
[   98.909262][    C8] [c00000003dd4f720] [c0000000002361d8]
tick_sched_timer+0x68/0xe0
[   98.909284][    C8] [c00000003dd4f760] [c000000000219768]
__hrtimer_run_queues+0x528/0xa60
[   98.909306][    C8] [c00000003dd4f880] [c00000000021ab58]
hrtimer_interrupt+0x128/0x330
[   98.909329][    C8] [c00000003dd4f930] [c00000000002e1b4]
timer_interrupt+0x264/0x680
[   98.909352][    C8] [c00000003dd4f9c0] [c000000000009264]
decrementer_common+0x124/0x130
[   98.909366][    C8] --- interrupt: 901 at debug_vm_pgtable+0x7a8/0xbb4
[   98.909366][    C8]     LR = debug_vm_pgtable+0x6a0/0xbb4
[   98.909402][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[   98.909435][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[   98.909467][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[  124.418885][    C8] watchdog: BUG: soft lockup - CPU#8 stuck for 22s!
[swapper/0:1]
[  124.418914][    C8] Modules linked in:
[  124.418926][    C8] irq event stamp: 2937938
[  124.418940][    C8] hardirqs last  enabled at (2937937): [<c00000000000dec8>]
fast_exc_return_irq+0x28/0x34
[  124.418964][    C8] hardirqs last disabled at (2937938): [<c00000000000924c>]
decrementer_common+0x10c/0x130
[  124.418980][    C8] softirqs last  enabled at (2937936): [<c0000000009a1bf0>]
__do_softirq+0x640/0x8c8
[  124.419013][    C8] softirqs last disabled at (2937929): [<c000000000113cbc>]
irq_exit+0x16c/0x1d0
[  124.419036][    C8] CPU: 8 PID: 1 Comm: swapper/0 Tainted:
G             L    5.6.0-rc4-next-20200303+ #7
[  124.419059][    C8] NIP:  c00000000103dc14 LR: c00000000103db0c CTR:
0000000000000000
[  124.419080][    C8] REGS: c00000003dd4fa30 TRAP: 0901   Tainted:
G             L     (5.6.0-rc4-next-20200303+)
[  124.419103][    C8] MSR:  9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR:
42000222  XER: 00000000
[  124.419121][    C8] CFAR: c00000000103dc1c IRQMASK: 0 
[  124.419121][    C8] GPR00: c00000000103db0c c00000003dd4fcc0 c000000001657d00
05210001000000c0 
[  124.419121][    C8] GPR04: 8000000000000105 000000000000000a 00000000f4d9864c
0000000000000001 
[  124.419121][    C8] GPR08: 0000000000000000 ffffffffffffffff 0000000000000001
00000000000a0000 
[  124.419121][    C8] GPR12: 0000000000000000 c000001fffff9880 
[  124.419234][    C8] NIP [c00000000103dc14] debug_vm_pgtable+0x7a8/0xbb4
[  124.419254][    C8] LR [c00000000103db0c] debug_vm_pgtable+0x6a0/0xbb4
[  124.419274][    C8] Call Trace:
[  124.419291][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[  124.419324][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[  124.419347][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[  124.419359][    C8] Instruction dump:
[  124.419378][    C8] 7d075078 7ce74b78 7ce0f9ad 40c2fff0 7e449378 7fc3f378
4b03531d 60000000 
[  124.419412][    C8] 48000080 3920ffff 39400001 39000000 <7e00f8a8> 7e075039
40c2fff8 7e074878

> 
> mm/debug_vm_pgtable.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
> index 96dd7d574cef..c310f52c2b80 100644
> --- a/mm/debug_vm_pgtable.c
> +++ b/mm/debug_vm_pgtable.c
> @@ -250,13 +250,14 @@ static void __init pgd_populate_tests(struct mm_struct *mm, pgd_t *pgdp,
> }
> #endif
> 
> -static void __init pte_clear_tests(struct mm_struct *mm, pte_t *ptep)
> +static void __init pte_clear_tests(struct mm_struct *mm, pte_t *ptep,
> +                                  unsigned long vaddr)
> {
>        pte_t pte = READ_ONCE(*ptep);
> 
>        pte = __pte(pte_val(pte) | RANDOM_ORVALUE);
>        WRITE_ONCE(*ptep, pte);
> -       pte_clear(mm, 0, ptep);
> +       pte_clear(mm, vaddr, ptep);
>        pte = READ_ONCE(*ptep);
>        WARN_ON(!pte_none(pte));
> }
> @@ -302,6 +303,7 @@ static unsigned long __init get_random_vaddr(void)
> void __init debug_vm_pgtable(void)
> {
>        struct mm_struct *mm;
> +       spinlock_t *uninitialized_var(ptl);
>        pgd_t *pgdp;
>        p4d_t *p4dp, *saved_p4dp;
>        pud_t *pudp, *saved_pudp;
> @@ -344,7 +346,7 @@ void __init debug_vm_pgtable(void)
>        p4dp = p4d_alloc(mm, pgdp, vaddr);
>        pudp = pud_alloc(mm, p4dp, vaddr);
>        pmdp = pmd_alloc(mm, pudp, vaddr);
> -       ptep = pte_alloc_map(mm, pmdp, vaddr);
> +       ptep = pte_alloc_map_lock(mm, pmdp, vaddr, &ptl);
> 
>        /*
>         * Save all the page table page addresses as the page table
> @@ -364,13 +366,13 @@ void __init debug_vm_pgtable(void)
>        p4d_basic_tests(p4d_aligned, prot);
>        pgd_basic_tests(pgd_aligned, prot);
> 
> -       pte_clear_tests(mm, ptep);
> +       pte_clear_tests(mm, ptep, vaddr);
>        pmd_clear_tests(mm, pmdp);
>        pud_clear_tests(mm, pudp);
>        p4d_clear_tests(mm, p4dp);
>        pgd_clear_tests(mm, pgdp);
> 
> -       pte_unmap(ptep);
> +       pte_unmap_unlock(ptep, ptl);
> 
>        pmd_populate_tests(mm, pmdp, saved_ptep);
>        pud_populate_tests(mm, pudp, saved_pmdp);
> -- 
> 2.20.1


WARNING: multiple messages have this Message-ID (diff)
From: Qian Cai <cai@lca.pw>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Christophe Leroy <christophe.leroy@c-s.fr>,
	Linux Memory Management List <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mike Rapoport <rppt@linux.ibm.com>,
	Vineet Gupta <vgupta@synopsys.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"Kirill A . Shutemov" <kirill@shutemov.name>,
	Paul Walmsley <paul.walmsley@sifive.com>
Subject: Re: [PATCH V14] mm/debug: Add tests validating architecture page table helpers
Date: Tue, 3 Mar 2020 20:39:39 -0500	[thread overview]
Message-ID: <12260F9A-695D-40F8-932F-61D86D77D441@lca.pw> (raw)
In-Reply-To: <e8516497-f1b9-b222-e219-73b68880ac75@arm.com>


> Below is slightly modified version of your change above and should still
> prevent the bug on powerpc. Will it be possible for you to re-test this
> ? Once confirmed, will send a patch enabling this test on powerpc64
> keeping your authorship. Thank you.

This works fine on radix MMU but I decided to go a bit future to test hash
MMU. The kernel will stuck here below. I did confirm that pte_alloc_map_lock()
was successful, so I don’t understand hash MMU well enough to tell why
it could still take an interrupt at pte_clear_tests() even before we calls
pte_unmap_unlock()?

[   33.881515][    T1] ok 8 - property-entry
[   33.883653][    T1] debug_vm_pgtable: debug_vm_pgtable: Validating
architecture page table helpers
[   60.418885][    C8] watchdog: BUG: soft lockup - CPU#8 stuck for 23s!
[swapper/0:1]
[   60.418913][    C8] Modules linked in:
[   60.418927][    C8] irq event stamp: 2896762
[   60.418945][    C8] hardirqs last  enabled at (2896761): [<c00000000000dec8>]
fast_exc_return_irq+0x28/0x34
[   60.418960][    C8] hardirqs last disabled at (2896762): [<c00000000000924c>]
decrementer_common+0x10c/0x130
[   60.418985][    C8] softirqs last  enabled at (2896760): [<c0000000009a1bf0>]
__do_softirq+0x640/0x8c8
[   60.419009][    C8] softirqs last disabled at (2896753): [<c000000000113cbc>]
irq_exit+0x16c/0x1d0
[   60.419024][    C8] CPU: 8 PID: 1 Comm: swapper/0 Not tainted 5.6.0-rc4-next-
20200303+ #7
[   60.419055][    C8] NIP:  c00000000103dc14 LR: c00000000103db0c CTR:
0000000000000000
[   60.419076][    C8] REGS: c00000003dd4fa30 TRAP: 0901   Not tainted  (5.6.0-
rc4-next-20200303+)
[   60.419107][    C8] MSR:  9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR:
42000222  XER: 00000000
[   60.419134][    C8] CFAR: c00000000103dc1c IRQMASK: 0 
[   60.419134][    C8] GPR00: c00000000103db0c c00000003dd4fcc0 c000000001657d00
05210001000000c0 
[   60.419134][    C8] GPR04: 8000000000000105 000000000000000a 00000000f4d9864c
0000000000000001 
[   60.419134][    C8] GPR08: 0000000000000000 ffffffffffffffff 0000000000000001
00000000000a0000 
[   60.419134][    C8] GPR12: 0000000000000000 c000001fffff9880 
[   60.419220][    C8] NIP [c00000000103dc14] debug_vm_pgtable+0x7a8/0xbb4
hash__pte_update at arch/powerpc/include/asm/book3s/64/hash.h:159
(inlined by) pte_update at arch/powerpc/include/asm/book3s/64/pgtable.h:359
(inlined by) pte_clear at arch/powerpc/include/asm/book3s/64/pgtable.h:477
(inlined by) pte_clear_tests at mm/debug_vm_pgtable.c:259
(inlined by) debug_vm_pgtable at mm/debug_vm_pgtable.c:368
[   60.419241][    C8] LR [c00000000103db0c] debug_vm_pgtable+0x6a0/0xbb4
pmd_basic_tests at mm/debug_vm_pgtable.c:74
(inlined by) debug_vm_pgtable at mm/debug_vm_pgtable.c:363
[   60.419260][    C8] Call Trace:
[   60.419278][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[   60.419302][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[   60.419325][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[   60.419363][    C8] Instruction dump:
[   60.419382][    C8] 7d075078 7ce74b78 7ce0f9ad 40c2fff0 7e449378 7fc3f378
4b03531d 60000000 
[   60.419416][    C8] 48000080 3920ffff 39400001 39000000 <7e00f8a8> 7e075039
40c2fff8 7e074878 
[   98.908889][    C8] rcu: INFO: rcu_sched self-detected stall on CPU
[   98.908933][    C8] rcu:         8-....: (6500 ticks this GP)
idle=522/1/0x4000000000000002 softirq=132/132 fqs=3250 
[   98.908963][    C8]         (t=6501 jiffies g=-719 q=510)
[   98.908984][    C8] NMI backtrace for cpu 8
[   98.909012][    C8] CPU: 8 PID: 1 Comm: swapper/0 Tainted:
G             L    5.6.0-rc4-next-20200303+ #7
[   98.909025][    C8] Call Trace:
[   98.909046][    C8] [c00000003dd4f360] [c000000000970fe0]
dump_stack+0xf4/0x164 (unreliable)
[   98.909070][    C8] [c00000003dd4f3b0] [c00000000097dcf4]
nmi_cpu_backtrace+0x1b4/0x1e0
[   98.909084][    C8] [c00000003dd4f450] [c00000000097df48]
nmi_trigger_cpumask_backtrace+0x228/0x2c0
[   98.909118][    C8] [c00000003dd4f500] [c000000000057bf8]
arch_trigger_cpumask_backtrace+0x28/0x40
[   98.909152][    C8] [c00000003dd4f520] [c000000000202dd4]
rcu_dump_cpu_stacks+0x1c4/0x234
[   98.909184][    C8] [c00000003dd4f5a0] [c000000000201634]
rcu_sched_clock_irq+0xd54/0x1130
[   98.909207][    C8] [c00000003dd4f6c0] [c000000000217068]
update_process_times+0x48/0xb0
[   98.909239][    C8] [c00000003dd4f6f0] [c0000000002358b4]
tick_sched_handle+0x34/0xb0
[   98.909262][    C8] [c00000003dd4f720] [c0000000002361d8]
tick_sched_timer+0x68/0xe0
[   98.909284][    C8] [c00000003dd4f760] [c000000000219768]
__hrtimer_run_queues+0x528/0xa60
[   98.909306][    C8] [c00000003dd4f880] [c00000000021ab58]
hrtimer_interrupt+0x128/0x330
[   98.909329][    C8] [c00000003dd4f930] [c00000000002e1b4]
timer_interrupt+0x264/0x680
[   98.909352][    C8] [c00000003dd4f9c0] [c000000000009264]
decrementer_common+0x124/0x130
[   98.909366][    C8] --- interrupt: 901 at debug_vm_pgtable+0x7a8/0xbb4
[   98.909366][    C8]     LR = debug_vm_pgtable+0x6a0/0xbb4
[   98.909402][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[   98.909435][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[   98.909467][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[  124.418885][    C8] watchdog: BUG: soft lockup - CPU#8 stuck for 22s!
[swapper/0:1]
[  124.418914][    C8] Modules linked in:
[  124.418926][    C8] irq event stamp: 2937938
[  124.418940][    C8] hardirqs last  enabled at (2937937): [<c00000000000dec8>]
fast_exc_return_irq+0x28/0x34
[  124.418964][    C8] hardirqs last disabled at (2937938): [<c00000000000924c>]
decrementer_common+0x10c/0x130
[  124.418980][    C8] softirqs last  enabled at (2937936): [<c0000000009a1bf0>]
__do_softirq+0x640/0x8c8
[  124.419013][    C8] softirqs last disabled at (2937929): [<c000000000113cbc>]
irq_exit+0x16c/0x1d0
[  124.419036][    C8] CPU: 8 PID: 1 Comm: swapper/0 Tainted:
G             L    5.6.0-rc4-next-20200303+ #7
[  124.419059][    C8] NIP:  c00000000103dc14 LR: c00000000103db0c CTR:
0000000000000000
[  124.419080][    C8] REGS: c00000003dd4fa30 TRAP: 0901   Tainted:
G             L     (5.6.0-rc4-next-20200303+)
[  124.419103][    C8] MSR:  9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR:
42000222  XER: 00000000
[  124.419121][    C8] CFAR: c00000000103dc1c IRQMASK: 0 
[  124.419121][    C8] GPR00: c00000000103db0c c00000003dd4fcc0 c000000001657d00
05210001000000c0 
[  124.419121][    C8] GPR04: 8000000000000105 000000000000000a 00000000f4d9864c
0000000000000001 
[  124.419121][    C8] GPR08: 0000000000000000 ffffffffffffffff 0000000000000001
00000000000a0000 
[  124.419121][    C8] GPR12: 0000000000000000 c000001fffff9880 
[  124.419234][    C8] NIP [c00000000103dc14] debug_vm_pgtable+0x7a8/0xbb4
[  124.419254][    C8] LR [c00000000103db0c] debug_vm_pgtable+0x6a0/0xbb4
[  124.419274][    C8] Call Trace:
[  124.419291][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[  124.419324][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[  124.419347][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[  124.419359][    C8] Instruction dump:
[  124.419378][    C8] 7d075078 7ce74b78 7ce0f9ad 40c2fff0 7e449378 7fc3f378
4b03531d 60000000 
[  124.419412][    C8] 48000080 3920ffff 39400001 39000000 <7e00f8a8> 7e075039
40c2fff8 7e074878

> 
> mm/debug_vm_pgtable.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
> index 96dd7d574cef..c310f52c2b80 100644
> --- a/mm/debug_vm_pgtable.c
> +++ b/mm/debug_vm_pgtable.c
> @@ -250,13 +250,14 @@ static void __init pgd_populate_tests(struct mm_struct *mm, pgd_t *pgdp,
> }
> #endif
> 
> -static void __init pte_clear_tests(struct mm_struct *mm, pte_t *ptep)
> +static void __init pte_clear_tests(struct mm_struct *mm, pte_t *ptep,
> +                                  unsigned long vaddr)
> {
>        pte_t pte = READ_ONCE(*ptep);
> 
>        pte = __pte(pte_val(pte) | RANDOM_ORVALUE);
>        WRITE_ONCE(*ptep, pte);
> -       pte_clear(mm, 0, ptep);
> +       pte_clear(mm, vaddr, ptep);
>        pte = READ_ONCE(*ptep);
>        WARN_ON(!pte_none(pte));
> }
> @@ -302,6 +303,7 @@ static unsigned long __init get_random_vaddr(void)
> void __init debug_vm_pgtable(void)
> {
>        struct mm_struct *mm;
> +       spinlock_t *uninitialized_var(ptl);
>        pgd_t *pgdp;
>        p4d_t *p4dp, *saved_p4dp;
>        pud_t *pudp, *saved_pudp;
> @@ -344,7 +346,7 @@ void __init debug_vm_pgtable(void)
>        p4dp = p4d_alloc(mm, pgdp, vaddr);
>        pudp = pud_alloc(mm, p4dp, vaddr);
>        pmdp = pmd_alloc(mm, pudp, vaddr);
> -       ptep = pte_alloc_map(mm, pmdp, vaddr);
> +       ptep = pte_alloc_map_lock(mm, pmdp, vaddr, &ptl);
> 
>        /*
>         * Save all the page table page addresses as the page table
> @@ -364,13 +366,13 @@ void __init debug_vm_pgtable(void)
>        p4d_basic_tests(p4d_aligned, prot);
>        pgd_basic_tests(pgd_aligned, prot);
> 
> -       pte_clear_tests(mm, ptep);
> +       pte_clear_tests(mm, ptep, vaddr);
>        pmd_clear_tests(mm, pmdp);
>        pud_clear_tests(mm, pudp);
>        p4d_clear_tests(mm, p4dp);
>        pgd_clear_tests(mm, pgdp);
> 
> -       pte_unmap(ptep);
> +       pte_unmap_unlock(ptep, ptl);
> 
>        pmd_populate_tests(mm, pmdp, saved_ptep);
>        pud_populate_tests(mm, pudp, saved_pmdp);
> -- 
> 2.20.1

WARNING: multiple messages have this Message-ID (diff)
From: Qian Cai <cai@lca.pw>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Linux Memory Management List <linux-mm@kvack.org>,
	Paul Mackerras <paulus@samba.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	linux-riscv@lists.infradead.org, Will Deacon <will@kernel.org>,
	linux-arch@vger.kernel.org, linux-s390@vger.kernel.org,
	Michael Ellerman <mpe@ellerman.id.au>,
	the arch/x86 maintainers <x86@kernel.org>,
	Mike Rapoport <rppt@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Ingo Molnar <mingo@redhat.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	linux-snps-arc@lists.infradead.org,
	Vasily Gorbik <gor@linux.ibm.com>, Borislav Petkov <bp@alien8.de>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	"Kirill A . Shutemov" <kirill@shutemov.name>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-arm-kernel@lists.infradead.org,
	Christophe Leroy <christophe.leroy@c-s.fr>,
	Vineet Gupta <vgupta@synopsys.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH V14] mm/debug: Add tests validating architecture page table helpers
Date: Tue, 3 Mar 2020 20:39:39 -0500	[thread overview]
Message-ID: <12260F9A-695D-40F8-932F-61D86D77D441@lca.pw> (raw)
Message-ID: <20200304013939.rfPDe5_0HrbUVcUt9ksva_6pt2qf_QxYJKC19bvzAik@z> (raw)
In-Reply-To: <e8516497-f1b9-b222-e219-73b68880ac75@arm.com>


> Below is slightly modified version of your change above and should still
> prevent the bug on powerpc. Will it be possible for you to re-test this
> ? Once confirmed, will send a patch enabling this test on powerpc64
> keeping your authorship. Thank you.

This works fine on radix MMU but I decided to go a bit future to test hash
MMU. The kernel will stuck here below. I did confirm that pte_alloc_map_lock()
was successful, so I don’t understand hash MMU well enough to tell why
it could still take an interrupt at pte_clear_tests() even before we calls
pte_unmap_unlock()?

[   33.881515][    T1] ok 8 - property-entry
[   33.883653][    T1] debug_vm_pgtable: debug_vm_pgtable: Validating
architecture page table helpers
[   60.418885][    C8] watchdog: BUG: soft lockup - CPU#8 stuck for 23s!
[swapper/0:1]
[   60.418913][    C8] Modules linked in:
[   60.418927][    C8] irq event stamp: 2896762
[   60.418945][    C8] hardirqs last  enabled at (2896761): [<c00000000000dec8>]
fast_exc_return_irq+0x28/0x34
[   60.418960][    C8] hardirqs last disabled at (2896762): [<c00000000000924c>]
decrementer_common+0x10c/0x130
[   60.418985][    C8] softirqs last  enabled at (2896760): [<c0000000009a1bf0>]
__do_softirq+0x640/0x8c8
[   60.419009][    C8] softirqs last disabled at (2896753): [<c000000000113cbc>]
irq_exit+0x16c/0x1d0
[   60.419024][    C8] CPU: 8 PID: 1 Comm: swapper/0 Not tainted 5.6.0-rc4-next-
20200303+ #7
[   60.419055][    C8] NIP:  c00000000103dc14 LR: c00000000103db0c CTR:
0000000000000000
[   60.419076][    C8] REGS: c00000003dd4fa30 TRAP: 0901   Not tainted  (5.6.0-
rc4-next-20200303+)
[   60.419107][    C8] MSR:  9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR:
42000222  XER: 00000000
[   60.419134][    C8] CFAR: c00000000103dc1c IRQMASK: 0 
[   60.419134][    C8] GPR00: c00000000103db0c c00000003dd4fcc0 c000000001657d00
05210001000000c0 
[   60.419134][    C8] GPR04: 8000000000000105 000000000000000a 00000000f4d9864c
0000000000000001 
[   60.419134][    C8] GPR08: 0000000000000000 ffffffffffffffff 0000000000000001
00000000000a0000 
[   60.419134][    C8] GPR12: 0000000000000000 c000001fffff9880 
[   60.419220][    C8] NIP [c00000000103dc14] debug_vm_pgtable+0x7a8/0xbb4
hash__pte_update at arch/powerpc/include/asm/book3s/64/hash.h:159
(inlined by) pte_update at arch/powerpc/include/asm/book3s/64/pgtable.h:359
(inlined by) pte_clear at arch/powerpc/include/asm/book3s/64/pgtable.h:477
(inlined by) pte_clear_tests at mm/debug_vm_pgtable.c:259
(inlined by) debug_vm_pgtable at mm/debug_vm_pgtable.c:368
[   60.419241][    C8] LR [c00000000103db0c] debug_vm_pgtable+0x6a0/0xbb4
pmd_basic_tests at mm/debug_vm_pgtable.c:74
(inlined by) debug_vm_pgtable at mm/debug_vm_pgtable.c:363
[   60.419260][    C8] Call Trace:
[   60.419278][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[   60.419302][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[   60.419325][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[   60.419363][    C8] Instruction dump:
[   60.419382][    C8] 7d075078 7ce74b78 7ce0f9ad 40c2fff0 7e449378 7fc3f378
4b03531d 60000000 
[   60.419416][    C8] 48000080 3920ffff 39400001 39000000 <7e00f8a8> 7e075039
40c2fff8 7e074878 
[   98.908889][    C8] rcu: INFO: rcu_sched self-detected stall on CPU
[   98.908933][    C8] rcu:         8-....: (6500 ticks this GP)
idle=522/1/0x4000000000000002 softirq=132/132 fqs=3250 
[   98.908963][    C8]         (t=6501 jiffies g=-719 q=510)
[   98.908984][    C8] NMI backtrace for cpu 8
[   98.909012][    C8] CPU: 8 PID: 1 Comm: swapper/0 Tainted:
G             L    5.6.0-rc4-next-20200303+ #7
[   98.909025][    C8] Call Trace:
[   98.909046][    C8] [c00000003dd4f360] [c000000000970fe0]
dump_stack+0xf4/0x164 (unreliable)
[   98.909070][    C8] [c00000003dd4f3b0] [c00000000097dcf4]
nmi_cpu_backtrace+0x1b4/0x1e0
[   98.909084][    C8] [c00000003dd4f450] [c00000000097df48]
nmi_trigger_cpumask_backtrace+0x228/0x2c0
[   98.909118][    C8] [c00000003dd4f500] [c000000000057bf8]
arch_trigger_cpumask_backtrace+0x28/0x40
[   98.909152][    C8] [c00000003dd4f520] [c000000000202dd4]
rcu_dump_cpu_stacks+0x1c4/0x234
[   98.909184][    C8] [c00000003dd4f5a0] [c000000000201634]
rcu_sched_clock_irq+0xd54/0x1130
[   98.909207][    C8] [c00000003dd4f6c0] [c000000000217068]
update_process_times+0x48/0xb0
[   98.909239][    C8] [c00000003dd4f6f0] [c0000000002358b4]
tick_sched_handle+0x34/0xb0
[   98.909262][    C8] [c00000003dd4f720] [c0000000002361d8]
tick_sched_timer+0x68/0xe0
[   98.909284][    C8] [c00000003dd4f760] [c000000000219768]
__hrtimer_run_queues+0x528/0xa60
[   98.909306][    C8] [c00000003dd4f880] [c00000000021ab58]
hrtimer_interrupt+0x128/0x330
[   98.909329][    C8] [c00000003dd4f930] [c00000000002e1b4]
timer_interrupt+0x264/0x680
[   98.909352][    C8] [c00000003dd4f9c0] [c000000000009264]
decrementer_common+0x124/0x130
[   98.909366][    C8] --- interrupt: 901 at debug_vm_pgtable+0x7a8/0xbb4
[   98.909366][    C8]     LR = debug_vm_pgtable+0x6a0/0xbb4
[   98.909402][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[   98.909435][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[   98.909467][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[  124.418885][    C8] watchdog: BUG: soft lockup - CPU#8 stuck for 22s!
[swapper/0:1]
[  124.418914][    C8] Modules linked in:
[  124.418926][    C8] irq event stamp: 2937938
[  124.418940][    C8] hardirqs last  enabled at (2937937): [<c00000000000dec8>]
fast_exc_return_irq+0x28/0x34
[  124.418964][    C8] hardirqs last disabled at (2937938): [<c00000000000924c>]
decrementer_common+0x10c/0x130
[  124.418980][    C8] softirqs last  enabled at (2937936): [<c0000000009a1bf0>]
__do_softirq+0x640/0x8c8
[  124.419013][    C8] softirqs last disabled at (2937929): [<c000000000113cbc>]
irq_exit+0x16c/0x1d0
[  124.419036][    C8] CPU: 8 PID: 1 Comm: swapper/0 Tainted:
G             L    5.6.0-rc4-next-20200303+ #7
[  124.419059][    C8] NIP:  c00000000103dc14 LR: c00000000103db0c CTR:
0000000000000000
[  124.419080][    C8] REGS: c00000003dd4fa30 TRAP: 0901   Tainted:
G             L     (5.6.0-rc4-next-20200303+)
[  124.419103][    C8] MSR:  9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR:
42000222  XER: 00000000
[  124.419121][    C8] CFAR: c00000000103dc1c IRQMASK: 0 
[  124.419121][    C8] GPR00: c00000000103db0c c00000003dd4fcc0 c000000001657d00
05210001000000c0 
[  124.419121][    C8] GPR04: 8000000000000105 000000000000000a 00000000f4d9864c
0000000000000001 
[  124.419121][    C8] GPR08: 0000000000000000 ffffffffffffffff 0000000000000001
00000000000a0000 
[  124.419121][    C8] GPR12: 0000000000000000 c000001fffff9880 
[  124.419234][    C8] NIP [c00000000103dc14] debug_vm_pgtable+0x7a8/0xbb4
[  124.419254][    C8] LR [c00000000103db0c] debug_vm_pgtable+0x6a0/0xbb4
[  124.419274][    C8] Call Trace:
[  124.419291][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[  124.419324][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[  124.419347][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[  124.419359][    C8] Instruction dump:
[  124.419378][    C8] 7d075078 7ce74b78 7ce0f9ad 40c2fff0 7e449378 7fc3f378
4b03531d 60000000 
[  124.419412][    C8] 48000080 3920ffff 39400001 39000000 <7e00f8a8> 7e075039
40c2fff8 7e074878

> 
> mm/debug_vm_pgtable.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
> index 96dd7d574cef..c310f52c2b80 100644
> --- a/mm/debug_vm_pgtable.c
> +++ b/mm/debug_vm_pgtable.c
> @@ -250,13 +250,14 @@ static void __init pgd_populate_tests(struct mm_struct *mm, pgd_t *pgdp,
> }
> #endif
> 
> -static void __init pte_clear_tests(struct mm_struct *mm, pte_t *ptep)
> +static void __init pte_clear_tests(struct mm_struct *mm, pte_t *ptep,
> +                                  unsigned long vaddr)
> {
>        pte_t pte = READ_ONCE(*ptep);
> 
>        pte = __pte(pte_val(pte) | RANDOM_ORVALUE);
>        WRITE_ONCE(*ptep, pte);
> -       pte_clear(mm, 0, ptep);
> +       pte_clear(mm, vaddr, ptep);
>        pte = READ_ONCE(*ptep);
>        WARN_ON(!pte_none(pte));
> }
> @@ -302,6 +303,7 @@ static unsigned long __init get_random_vaddr(void)
> void __init debug_vm_pgtable(void)
> {
>        struct mm_struct *mm;
> +       spinlock_t *uninitialized_var(ptl);
>        pgd_t *pgdp;
>        p4d_t *p4dp, *saved_p4dp;
>        pud_t *pudp, *saved_pudp;
> @@ -344,7 +346,7 @@ void __init debug_vm_pgtable(void)
>        p4dp = p4d_alloc(mm, pgdp, vaddr);
>        pudp = pud_alloc(mm, p4dp, vaddr);
>        pmdp = pmd_alloc(mm, pudp, vaddr);
> -       ptep = pte_alloc_map(mm, pmdp, vaddr);
> +       ptep = pte_alloc_map_lock(mm, pmdp, vaddr, &ptl);
> 
>        /*
>         * Save all the page table page addresses as the page table
> @@ -364,13 +366,13 @@ void __init debug_vm_pgtable(void)
>        p4d_basic_tests(p4d_aligned, prot);
>        pgd_basic_tests(pgd_aligned, prot);
> 
> -       pte_clear_tests(mm, ptep);
> +       pte_clear_tests(mm, ptep, vaddr);
>        pmd_clear_tests(mm, pmdp);
>        pud_clear_tests(mm, pudp);
>        p4d_clear_tests(mm, p4dp);
>        pgd_clear_tests(mm, pgdp);
> 
> -       pte_unmap(ptep);
> +       pte_unmap_unlock(ptep, ptl);
> 
>        pmd_populate_tests(mm, pmdp, saved_ptep);
>        pud_populate_tests(mm, pudp, saved_pmdp);
> -- 
> 2.20.1

WARNING: multiple messages have this Message-ID (diff)
From: Qian Cai <cai@lca.pw>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
	Linux Memory Management List <linux-mm@kvack.org>,
	Paul Mackerras <paulus@samba.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	linux-riscv@lists.infradead.org, Will Deacon <will@kernel.org>,
	linux-arch@vger.kernel.org, linux-s390@vger.kernel.org,
	the arch/x86 maintainers <x86@kernel.org>,
	Mike Rapoport <rppt@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Ingo Molnar <mingo@redhat.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	linux-snps-arc@lists.infradead.org,
	Vasily Gorbik <gor@linux.ibm.com>, Borislav Petkov <bp@alien8.de>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	"Kirill A . Shutemov" <kirill@shutemov.name>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-arm-kernel@lists.infradead.org,
	Vineet Gupta <vgupta@synopsys.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH V14] mm/debug: Add tests validating architecture page table helpers
Date: Tue, 3 Mar 2020 20:39:39 -0500	[thread overview]
Message-ID: <12260F9A-695D-40F8-932F-61D86D77D441@lca.pw> (raw)
In-Reply-To: <e8516497-f1b9-b222-e219-73b68880ac75@arm.com>


> Below is slightly modified version of your change above and should still
> prevent the bug on powerpc. Will it be possible for you to re-test this
> ? Once confirmed, will send a patch enabling this test on powerpc64
> keeping your authorship. Thank you.

This works fine on radix MMU but I decided to go a bit future to test hash
MMU. The kernel will stuck here below. I did confirm that pte_alloc_map_lock()
was successful, so I don’t understand hash MMU well enough to tell why
it could still take an interrupt at pte_clear_tests() even before we calls
pte_unmap_unlock()?

[   33.881515][    T1] ok 8 - property-entry
[   33.883653][    T1] debug_vm_pgtable: debug_vm_pgtable: Validating
architecture page table helpers
[   60.418885][    C8] watchdog: BUG: soft lockup - CPU#8 stuck for 23s!
[swapper/0:1]
[   60.418913][    C8] Modules linked in:
[   60.418927][    C8] irq event stamp: 2896762
[   60.418945][    C8] hardirqs last  enabled at (2896761): [<c00000000000dec8>]
fast_exc_return_irq+0x28/0x34
[   60.418960][    C8] hardirqs last disabled at (2896762): [<c00000000000924c>]
decrementer_common+0x10c/0x130
[   60.418985][    C8] softirqs last  enabled at (2896760): [<c0000000009a1bf0>]
__do_softirq+0x640/0x8c8
[   60.419009][    C8] softirqs last disabled at (2896753): [<c000000000113cbc>]
irq_exit+0x16c/0x1d0
[   60.419024][    C8] CPU: 8 PID: 1 Comm: swapper/0 Not tainted 5.6.0-rc4-next-
20200303+ #7
[   60.419055][    C8] NIP:  c00000000103dc14 LR: c00000000103db0c CTR:
0000000000000000
[   60.419076][    C8] REGS: c00000003dd4fa30 TRAP: 0901   Not tainted  (5.6.0-
rc4-next-20200303+)
[   60.419107][    C8] MSR:  9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR:
42000222  XER: 00000000
[   60.419134][    C8] CFAR: c00000000103dc1c IRQMASK: 0 
[   60.419134][    C8] GPR00: c00000000103db0c c00000003dd4fcc0 c000000001657d00
05210001000000c0 
[   60.419134][    C8] GPR04: 8000000000000105 000000000000000a 00000000f4d9864c
0000000000000001 
[   60.419134][    C8] GPR08: 0000000000000000 ffffffffffffffff 0000000000000001
00000000000a0000 
[   60.419134][    C8] GPR12: 0000000000000000 c000001fffff9880 
[   60.419220][    C8] NIP [c00000000103dc14] debug_vm_pgtable+0x7a8/0xbb4
hash__pte_update at arch/powerpc/include/asm/book3s/64/hash.h:159
(inlined by) pte_update at arch/powerpc/include/asm/book3s/64/pgtable.h:359
(inlined by) pte_clear at arch/powerpc/include/asm/book3s/64/pgtable.h:477
(inlined by) pte_clear_tests at mm/debug_vm_pgtable.c:259
(inlined by) debug_vm_pgtable at mm/debug_vm_pgtable.c:368
[   60.419241][    C8] LR [c00000000103db0c] debug_vm_pgtable+0x6a0/0xbb4
pmd_basic_tests at mm/debug_vm_pgtable.c:74
(inlined by) debug_vm_pgtable at mm/debug_vm_pgtable.c:363
[   60.419260][    C8] Call Trace:
[   60.419278][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[   60.419302][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[   60.419325][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[   60.419363][    C8] Instruction dump:
[   60.419382][    C8] 7d075078 7ce74b78 7ce0f9ad 40c2fff0 7e449378 7fc3f378
4b03531d 60000000 
[   60.419416][    C8] 48000080 3920ffff 39400001 39000000 <7e00f8a8> 7e075039
40c2fff8 7e074878 
[   98.908889][    C8] rcu: INFO: rcu_sched self-detected stall on CPU
[   98.908933][    C8] rcu:         8-....: (6500 ticks this GP)
idle=522/1/0x4000000000000002 softirq=132/132 fqs=3250 
[   98.908963][    C8]         (t=6501 jiffies g=-719 q=510)
[   98.908984][    C8] NMI backtrace for cpu 8
[   98.909012][    C8] CPU: 8 PID: 1 Comm: swapper/0 Tainted:
G             L    5.6.0-rc4-next-20200303+ #7
[   98.909025][    C8] Call Trace:
[   98.909046][    C8] [c00000003dd4f360] [c000000000970fe0]
dump_stack+0xf4/0x164 (unreliable)
[   98.909070][    C8] [c00000003dd4f3b0] [c00000000097dcf4]
nmi_cpu_backtrace+0x1b4/0x1e0
[   98.909084][    C8] [c00000003dd4f450] [c00000000097df48]
nmi_trigger_cpumask_backtrace+0x228/0x2c0
[   98.909118][    C8] [c00000003dd4f500] [c000000000057bf8]
arch_trigger_cpumask_backtrace+0x28/0x40
[   98.909152][    C8] [c00000003dd4f520] [c000000000202dd4]
rcu_dump_cpu_stacks+0x1c4/0x234
[   98.909184][    C8] [c00000003dd4f5a0] [c000000000201634]
rcu_sched_clock_irq+0xd54/0x1130
[   98.909207][    C8] [c00000003dd4f6c0] [c000000000217068]
update_process_times+0x48/0xb0
[   98.909239][    C8] [c00000003dd4f6f0] [c0000000002358b4]
tick_sched_handle+0x34/0xb0
[   98.909262][    C8] [c00000003dd4f720] [c0000000002361d8]
tick_sched_timer+0x68/0xe0
[   98.909284][    C8] [c00000003dd4f760] [c000000000219768]
__hrtimer_run_queues+0x528/0xa60
[   98.909306][    C8] [c00000003dd4f880] [c00000000021ab58]
hrtimer_interrupt+0x128/0x330
[   98.909329][    C8] [c00000003dd4f930] [c00000000002e1b4]
timer_interrupt+0x264/0x680
[   98.909352][    C8] [c00000003dd4f9c0] [c000000000009264]
decrementer_common+0x124/0x130
[   98.909366][    C8] --- interrupt: 901 at debug_vm_pgtable+0x7a8/0xbb4
[   98.909366][    C8]     LR = debug_vm_pgtable+0x6a0/0xbb4
[   98.909402][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[   98.909435][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[   98.909467][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[  124.418885][    C8] watchdog: BUG: soft lockup - CPU#8 stuck for 22s!
[swapper/0:1]
[  124.418914][    C8] Modules linked in:
[  124.418926][    C8] irq event stamp: 2937938
[  124.418940][    C8] hardirqs last  enabled at (2937937): [<c00000000000dec8>]
fast_exc_return_irq+0x28/0x34
[  124.418964][    C8] hardirqs last disabled at (2937938): [<c00000000000924c>]
decrementer_common+0x10c/0x130
[  124.418980][    C8] softirqs last  enabled at (2937936): [<c0000000009a1bf0>]
__do_softirq+0x640/0x8c8
[  124.419013][    C8] softirqs last disabled at (2937929): [<c000000000113cbc>]
irq_exit+0x16c/0x1d0
[  124.419036][    C8] CPU: 8 PID: 1 Comm: swapper/0 Tainted:
G             L    5.6.0-rc4-next-20200303+ #7
[  124.419059][    C8] NIP:  c00000000103dc14 LR: c00000000103db0c CTR:
0000000000000000
[  124.419080][    C8] REGS: c00000003dd4fa30 TRAP: 0901   Tainted:
G             L     (5.6.0-rc4-next-20200303+)
[  124.419103][    C8] MSR:  9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR:
42000222  XER: 00000000
[  124.419121][    C8] CFAR: c00000000103dc1c IRQMASK: 0 
[  124.419121][    C8] GPR00: c00000000103db0c c00000003dd4fcc0 c000000001657d00
05210001000000c0 
[  124.419121][    C8] GPR04: 8000000000000105 000000000000000a 00000000f4d9864c
0000000000000001 
[  124.419121][    C8] GPR08: 0000000000000000 ffffffffffffffff 0000000000000001
00000000000a0000 
[  124.419121][    C8] GPR12: 0000000000000000 c000001fffff9880 
[  124.419234][    C8] NIP [c00000000103dc14] debug_vm_pgtable+0x7a8/0xbb4
[  124.419254][    C8] LR [c00000000103db0c] debug_vm_pgtable+0x6a0/0xbb4
[  124.419274][    C8] Call Trace:
[  124.419291][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[  124.419324][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[  124.419347][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[  124.419359][    C8] Instruction dump:
[  124.419378][    C8] 7d075078 7ce74b78 7ce0f9ad 40c2fff0 7e449378 7fc3f378
4b03531d 60000000 
[  124.419412][    C8] 48000080 3920ffff 39400001 39000000 <7e00f8a8> 7e075039
40c2fff8 7e074878

> 
> mm/debug_vm_pgtable.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
> index 96dd7d574cef..c310f52c2b80 100644
> --- a/mm/debug_vm_pgtable.c
> +++ b/mm/debug_vm_pgtable.c
> @@ -250,13 +250,14 @@ static void __init pgd_populate_tests(struct mm_struct *mm, pgd_t *pgdp,
> }
> #endif
> 
> -static void __init pte_clear_tests(struct mm_struct *mm, pte_t *ptep)
> +static void __init pte_clear_tests(struct mm_struct *mm, pte_t *ptep,
> +                                  unsigned long vaddr)
> {
>        pte_t pte = READ_ONCE(*ptep);
> 
>        pte = __pte(pte_val(pte) | RANDOM_ORVALUE);
>        WRITE_ONCE(*ptep, pte);
> -       pte_clear(mm, 0, ptep);
> +       pte_clear(mm, vaddr, ptep);
>        pte = READ_ONCE(*ptep);
>        WARN_ON(!pte_none(pte));
> }
> @@ -302,6 +303,7 @@ static unsigned long __init get_random_vaddr(void)
> void __init debug_vm_pgtable(void)
> {
>        struct mm_struct *mm;
> +       spinlock_t *uninitialized_var(ptl);
>        pgd_t *pgdp;
>        p4d_t *p4dp, *saved_p4dp;
>        pud_t *pudp, *saved_pudp;
> @@ -344,7 +346,7 @@ void __init debug_vm_pgtable(void)
>        p4dp = p4d_alloc(mm, pgdp, vaddr);
>        pudp = pud_alloc(mm, p4dp, vaddr);
>        pmdp = pmd_alloc(mm, pudp, vaddr);
> -       ptep = pte_alloc_map(mm, pmdp, vaddr);
> +       ptep = pte_alloc_map_lock(mm, pmdp, vaddr, &ptl);
> 
>        /*
>         * Save all the page table page addresses as the page table
> @@ -364,13 +366,13 @@ void __init debug_vm_pgtable(void)
>        p4d_basic_tests(p4d_aligned, prot);
>        pgd_basic_tests(pgd_aligned, prot);
> 
> -       pte_clear_tests(mm, ptep);
> +       pte_clear_tests(mm, ptep, vaddr);
>        pmd_clear_tests(mm, pmdp);
>        pud_clear_tests(mm, pudp);
>        p4d_clear_tests(mm, p4dp);
>        pgd_clear_tests(mm, pgdp);
> 
> -       pte_unmap(ptep);
> +       pte_unmap_unlock(ptep, ptl);
> 
>        pmd_populate_tests(mm, pmdp, saved_ptep);
>        pud_populate_tests(mm, pudp, saved_pmdp);
> -- 
> 2.20.1


WARNING: multiple messages have this Message-ID (diff)
From: Qian Cai <cai@lca.pw>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Linux Memory Management List <linux-mm@kvack.org>,
	Paul Mackerras <paulus@samba.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	linux-riscv@lists.infradead.org, Will Deacon <will@kernel.org>,
	linux-arch@vger.kernel.org, linux-s390@vger.kernel.org,
	Michael Ellerman <mpe@ellerman.id.au>,
	the arch/x86 maintainers <x86@kernel.org>,
	Mike Rapoport <rppt@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Ingo Molnar <mingo@redhat.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	linux-snps-arc@lists.infradead.org,
	Vasily Gorbik <gor@linux.ibm.com>, Borislav Petkov <bp@alien8.de>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	"Kirill A . Shutemov" <kirill@shutemov.name>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-arm-kernel@lists.infradead.org,
	Christophe Leroy <christophe.leroy@c-s.fr>,
	Vineet Gupta <vgupta@synopsys.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH V14] mm/debug: Add tests validating architecture page table helpers
Date: Tue, 3 Mar 2020 20:39:39 -0500	[thread overview]
Message-ID: <12260F9A-695D-40F8-932F-61D86D77D441@lca.pw> (raw)
In-Reply-To: <e8516497-f1b9-b222-e219-73b68880ac75@arm.com>


> Below is slightly modified version of your change above and should still
> prevent the bug on powerpc. Will it be possible for you to re-test this
> ? Once confirmed, will send a patch enabling this test on powerpc64
> keeping your authorship. Thank you.

This works fine on radix MMU but I decided to go a bit future to test hash
MMU. The kernel will stuck here below. I did confirm that pte_alloc_map_lock()
was successful, so I don’t understand hash MMU well enough to tell why
it could still take an interrupt at pte_clear_tests() even before we calls
pte_unmap_unlock()?

[   33.881515][    T1] ok 8 - property-entry
[   33.883653][    T1] debug_vm_pgtable: debug_vm_pgtable: Validating
architecture page table helpers
[   60.418885][    C8] watchdog: BUG: soft lockup - CPU#8 stuck for 23s!
[swapper/0:1]
[   60.418913][    C8] Modules linked in:
[   60.418927][    C8] irq event stamp: 2896762
[   60.418945][    C8] hardirqs last  enabled at (2896761): [<c00000000000dec8>]
fast_exc_return_irq+0x28/0x34
[   60.418960][    C8] hardirqs last disabled at (2896762): [<c00000000000924c>]
decrementer_common+0x10c/0x130
[   60.418985][    C8] softirqs last  enabled at (2896760): [<c0000000009a1bf0>]
__do_softirq+0x640/0x8c8
[   60.419009][    C8] softirqs last disabled at (2896753): [<c000000000113cbc>]
irq_exit+0x16c/0x1d0
[   60.419024][    C8] CPU: 8 PID: 1 Comm: swapper/0 Not tainted 5.6.0-rc4-next-
20200303+ #7
[   60.419055][    C8] NIP:  c00000000103dc14 LR: c00000000103db0c CTR:
0000000000000000
[   60.419076][    C8] REGS: c00000003dd4fa30 TRAP: 0901   Not tainted  (5.6.0-
rc4-next-20200303+)
[   60.419107][    C8] MSR:  9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR:
42000222  XER: 00000000
[   60.419134][    C8] CFAR: c00000000103dc1c IRQMASK: 0 
[   60.419134][    C8] GPR00: c00000000103db0c c00000003dd4fcc0 c000000001657d00
05210001000000c0 
[   60.419134][    C8] GPR04: 8000000000000105 000000000000000a 00000000f4d9864c
0000000000000001 
[   60.419134][    C8] GPR08: 0000000000000000 ffffffffffffffff 0000000000000001
00000000000a0000 
[   60.419134][    C8] GPR12: 0000000000000000 c000001fffff9880 
[   60.419220][    C8] NIP [c00000000103dc14] debug_vm_pgtable+0x7a8/0xbb4
hash__pte_update at arch/powerpc/include/asm/book3s/64/hash.h:159
(inlined by) pte_update at arch/powerpc/include/asm/book3s/64/pgtable.h:359
(inlined by) pte_clear at arch/powerpc/include/asm/book3s/64/pgtable.h:477
(inlined by) pte_clear_tests at mm/debug_vm_pgtable.c:259
(inlined by) debug_vm_pgtable at mm/debug_vm_pgtable.c:368
[   60.419241][    C8] LR [c00000000103db0c] debug_vm_pgtable+0x6a0/0xbb4
pmd_basic_tests at mm/debug_vm_pgtable.c:74
(inlined by) debug_vm_pgtable at mm/debug_vm_pgtable.c:363
[   60.419260][    C8] Call Trace:
[   60.419278][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[   60.419302][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[   60.419325][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[   60.419363][    C8] Instruction dump:
[   60.419382][    C8] 7d075078 7ce74b78 7ce0f9ad 40c2fff0 7e449378 7fc3f378
4b03531d 60000000 
[   60.419416][    C8] 48000080 3920ffff 39400001 39000000 <7e00f8a8> 7e075039
40c2fff8 7e074878 
[   98.908889][    C8] rcu: INFO: rcu_sched self-detected stall on CPU
[   98.908933][    C8] rcu:         8-....: (6500 ticks this GP)
idle=522/1/0x4000000000000002 softirq=132/132 fqs=3250 
[   98.908963][    C8]         (t=6501 jiffies g=-719 q=510)
[   98.908984][    C8] NMI backtrace for cpu 8
[   98.909012][    C8] CPU: 8 PID: 1 Comm: swapper/0 Tainted:
G             L    5.6.0-rc4-next-20200303+ #7
[   98.909025][    C8] Call Trace:
[   98.909046][    C8] [c00000003dd4f360] [c000000000970fe0]
dump_stack+0xf4/0x164 (unreliable)
[   98.909070][    C8] [c00000003dd4f3b0] [c00000000097dcf4]
nmi_cpu_backtrace+0x1b4/0x1e0
[   98.909084][    C8] [c00000003dd4f450] [c00000000097df48]
nmi_trigger_cpumask_backtrace+0x228/0x2c0
[   98.909118][    C8] [c00000003dd4f500] [c000000000057bf8]
arch_trigger_cpumask_backtrace+0x28/0x40
[   98.909152][    C8] [c00000003dd4f520] [c000000000202dd4]
rcu_dump_cpu_stacks+0x1c4/0x234
[   98.909184][    C8] [c00000003dd4f5a0] [c000000000201634]
rcu_sched_clock_irq+0xd54/0x1130
[   98.909207][    C8] [c00000003dd4f6c0] [c000000000217068]
update_process_times+0x48/0xb0
[   98.909239][    C8] [c00000003dd4f6f0] [c0000000002358b4]
tick_sched_handle+0x34/0xb0
[   98.909262][    C8] [c00000003dd4f720] [c0000000002361d8]
tick_sched_timer+0x68/0xe0
[   98.909284][    C8] [c00000003dd4f760] [c000000000219768]
__hrtimer_run_queues+0x528/0xa60
[   98.909306][    C8] [c00000003dd4f880] [c00000000021ab58]
hrtimer_interrupt+0x128/0x330
[   98.909329][    C8] [c00000003dd4f930] [c00000000002e1b4]
timer_interrupt+0x264/0x680
[   98.909352][    C8] [c00000003dd4f9c0] [c000000000009264]
decrementer_common+0x124/0x130
[   98.909366][    C8] --- interrupt: 901 at debug_vm_pgtable+0x7a8/0xbb4
[   98.909366][    C8]     LR = debug_vm_pgtable+0x6a0/0xbb4
[   98.909402][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[   98.909435][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[   98.909467][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[  124.418885][    C8] watchdog: BUG: soft lockup - CPU#8 stuck for 22s!
[swapper/0:1]
[  124.418914][    C8] Modules linked in:
[  124.418926][    C8] irq event stamp: 2937938
[  124.418940][    C8] hardirqs last  enabled at (2937937): [<c00000000000dec8>]
fast_exc_return_irq+0x28/0x34
[  124.418964][    C8] hardirqs last disabled at (2937938): [<c00000000000924c>]
decrementer_common+0x10c/0x130
[  124.418980][    C8] softirqs last  enabled at (2937936): [<c0000000009a1bf0>]
__do_softirq+0x640/0x8c8
[  124.419013][    C8] softirqs last disabled at (2937929): [<c000000000113cbc>]
irq_exit+0x16c/0x1d0
[  124.419036][    C8] CPU: 8 PID: 1 Comm: swapper/0 Tainted:
G             L    5.6.0-rc4-next-20200303+ #7
[  124.419059][    C8] NIP:  c00000000103dc14 LR: c00000000103db0c CTR:
0000000000000000
[  124.419080][    C8] REGS: c00000003dd4fa30 TRAP: 0901   Tainted:
G             L     (5.6.0-rc4-next-20200303+)
[  124.419103][    C8] MSR:  9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR:
42000222  XER: 00000000
[  124.419121][    C8] CFAR: c00000000103dc1c IRQMASK: 0 
[  124.419121][    C8] GPR00: c00000000103db0c c00000003dd4fcc0 c000000001657d00
05210001000000c0 
[  124.419121][    C8] GPR04: 8000000000000105 000000000000000a 00000000f4d9864c
0000000000000001 
[  124.419121][    C8] GPR08: 0000000000000000 ffffffffffffffff 0000000000000001
00000000000a0000 
[  124.419121][    C8] GPR12: 0000000000000000 c000001fffff9880 
[  124.419234][    C8] NIP [c00000000103dc14] debug_vm_pgtable+0x7a8/0xbb4
[  124.419254][    C8] LR [c00000000103db0c] debug_vm_pgtable+0x6a0/0xbb4
[  124.419274][    C8] Call Trace:
[  124.419291][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[  124.419324][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[  124.419347][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[  124.419359][    C8] Instruction dump:
[  124.419378][    C8] 7d075078 7ce74b78 7ce0f9ad 40c2fff0 7e449378 7fc3f378
4b03531d 60000000 
[  124.419412][    C8] 48000080 3920ffff 39400001 39000000 <7e00f8a8> 7e075039
40c2fff8 7e074878

> 
> mm/debug_vm_pgtable.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
> index 96dd7d574cef..c310f52c2b80 100644
> --- a/mm/debug_vm_pgtable.c
> +++ b/mm/debug_vm_pgtable.c
> @@ -250,13 +250,14 @@ static void __init pgd_populate_tests(struct mm_struct *mm, pgd_t *pgdp,
> }
> #endif
> 
> -static void __init pte_clear_tests(struct mm_struct *mm, pte_t *ptep)
> +static void __init pte_clear_tests(struct mm_struct *mm, pte_t *ptep,
> +                                  unsigned long vaddr)
> {
>        pte_t pte = READ_ONCE(*ptep);
> 
>        pte = __pte(pte_val(pte) | RANDOM_ORVALUE);
>        WRITE_ONCE(*ptep, pte);
> -       pte_clear(mm, 0, ptep);
> +       pte_clear(mm, vaddr, ptep);
>        pte = READ_ONCE(*ptep);
>        WARN_ON(!pte_none(pte));
> }
> @@ -302,6 +303,7 @@ static unsigned long __init get_random_vaddr(void)
> void __init debug_vm_pgtable(void)
> {
>        struct mm_struct *mm;
> +       spinlock_t *uninitialized_var(ptl);
>        pgd_t *pgdp;
>        p4d_t *p4dp, *saved_p4dp;
>        pud_t *pudp, *saved_pudp;
> @@ -344,7 +346,7 @@ void __init debug_vm_pgtable(void)
>        p4dp = p4d_alloc(mm, pgdp, vaddr);
>        pudp = pud_alloc(mm, p4dp, vaddr);
>        pmdp = pmd_alloc(mm, pudp, vaddr);
> -       ptep = pte_alloc_map(mm, pmdp, vaddr);
> +       ptep = pte_alloc_map_lock(mm, pmdp, vaddr, &ptl);
> 
>        /*
>         * Save all the page table page addresses as the page table
> @@ -364,13 +366,13 @@ void __init debug_vm_pgtable(void)
>        p4d_basic_tests(p4d_aligned, prot);
>        pgd_basic_tests(pgd_aligned, prot);
> 
> -       pte_clear_tests(mm, ptep);
> +       pte_clear_tests(mm, ptep, vaddr);
>        pmd_clear_tests(mm, pmdp);
>        pud_clear_tests(mm, pudp);
>        p4d_clear_tests(mm, p4dp);
>        pgd_clear_tests(mm, pgdp);
> 
> -       pte_unmap(ptep);
> +       pte_unmap_unlock(ptep, ptl);
> 
>        pmd_populate_tests(mm, pmdp, saved_ptep);
>        pud_populate_tests(mm, pudp, saved_pmdp);
> -- 
> 2.20.1


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

WARNING: multiple messages have this Message-ID (diff)
From: Qian Cai <cai@lca.pw>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Linux Memory Management List <linux-mm@kvack.org>,
	Paul Mackerras <paulus@samba.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	linux-riscv@lists.infradead.org, Will Deacon <will@kernel.org>,
	linux-arch@vger.kernel.org, linux-s390@vger.kernel.org,
	Michael Ellerman <mpe@ellerman.id.au>,
	the arch/x86 maintainers <x86@kernel.org>,
	Mike Rapoport <rppt@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Ingo Molnar <mingo@redhat.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	linux-snps-arc@lists.infradead.org,
	Vasily Gorbik <gor@linux.ibm.com>, Borislav Petkov <bp@alien8.de>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	"Kirill A . Shutemov" <kirill@shutemov.name>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-arm-kernel@lists.infradead.org,
	Christophe Leroy <christophe.leroy@c-s.fr>,
	Vineet Gupta <vgupta@synopsys.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH V14] mm/debug: Add tests validating architecture page table helpers
Date: Tue, 3 Mar 2020 20:39:39 -0500	[thread overview]
Message-ID: <12260F9A-695D-40F8-932F-61D86D77D441@lca.pw> (raw)
In-Reply-To: <e8516497-f1b9-b222-e219-73b68880ac75@arm.com>


> Below is slightly modified version of your change above and should still
> prevent the bug on powerpc. Will it be possible for you to re-test this
> ? Once confirmed, will send a patch enabling this test on powerpc64
> keeping your authorship. Thank you.

This works fine on radix MMU but I decided to go a bit future to test hash
MMU. The kernel will stuck here below. I did confirm that pte_alloc_map_lock()
was successful, so I don’t understand hash MMU well enough to tell why
it could still take an interrupt at pte_clear_tests() even before we calls
pte_unmap_unlock()?

[   33.881515][    T1] ok 8 - property-entry
[   33.883653][    T1] debug_vm_pgtable: debug_vm_pgtable: Validating
architecture page table helpers
[   60.418885][    C8] watchdog: BUG: soft lockup - CPU#8 stuck for 23s!
[swapper/0:1]
[   60.418913][    C8] Modules linked in:
[   60.418927][    C8] irq event stamp: 2896762
[   60.418945][    C8] hardirqs last  enabled at (2896761): [<c00000000000dec8>]
fast_exc_return_irq+0x28/0x34
[   60.418960][    C8] hardirqs last disabled at (2896762): [<c00000000000924c>]
decrementer_common+0x10c/0x130
[   60.418985][    C8] softirqs last  enabled at (2896760): [<c0000000009a1bf0>]
__do_softirq+0x640/0x8c8
[   60.419009][    C8] softirqs last disabled at (2896753): [<c000000000113cbc>]
irq_exit+0x16c/0x1d0
[   60.419024][    C8] CPU: 8 PID: 1 Comm: swapper/0 Not tainted 5.6.0-rc4-next-
20200303+ #7
[   60.419055][    C8] NIP:  c00000000103dc14 LR: c00000000103db0c CTR:
0000000000000000
[   60.419076][    C8] REGS: c00000003dd4fa30 TRAP: 0901   Not tainted  (5.6.0-
rc4-next-20200303+)
[   60.419107][    C8] MSR:  9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR:
42000222  XER: 00000000
[   60.419134][    C8] CFAR: c00000000103dc1c IRQMASK: 0 
[   60.419134][    C8] GPR00: c00000000103db0c c00000003dd4fcc0 c000000001657d00
05210001000000c0 
[   60.419134][    C8] GPR04: 8000000000000105 000000000000000a 00000000f4d9864c
0000000000000001 
[   60.419134][    C8] GPR08: 0000000000000000 ffffffffffffffff 0000000000000001
00000000000a0000 
[   60.419134][    C8] GPR12: 0000000000000000 c000001fffff9880 
[   60.419220][    C8] NIP [c00000000103dc14] debug_vm_pgtable+0x7a8/0xbb4
hash__pte_update at arch/powerpc/include/asm/book3s/64/hash.h:159
(inlined by) pte_update at arch/powerpc/include/asm/book3s/64/pgtable.h:359
(inlined by) pte_clear at arch/powerpc/include/asm/book3s/64/pgtable.h:477
(inlined by) pte_clear_tests at mm/debug_vm_pgtable.c:259
(inlined by) debug_vm_pgtable at mm/debug_vm_pgtable.c:368
[   60.419241][    C8] LR [c00000000103db0c] debug_vm_pgtable+0x6a0/0xbb4
pmd_basic_tests at mm/debug_vm_pgtable.c:74
(inlined by) debug_vm_pgtable at mm/debug_vm_pgtable.c:363
[   60.419260][    C8] Call Trace:
[   60.419278][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[   60.419302][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[   60.419325][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[   60.419363][    C8] Instruction dump:
[   60.419382][    C8] 7d075078 7ce74b78 7ce0f9ad 40c2fff0 7e449378 7fc3f378
4b03531d 60000000 
[   60.419416][    C8] 48000080 3920ffff 39400001 39000000 <7e00f8a8> 7e075039
40c2fff8 7e074878 
[   98.908889][    C8] rcu: INFO: rcu_sched self-detected stall on CPU
[   98.908933][    C8] rcu:         8-....: (6500 ticks this GP)
idle=522/1/0x4000000000000002 softirq=132/132 fqs=3250 
[   98.908963][    C8]         (t=6501 jiffies g=-719 q=510)
[   98.908984][    C8] NMI backtrace for cpu 8
[   98.909012][    C8] CPU: 8 PID: 1 Comm: swapper/0 Tainted:
G             L    5.6.0-rc4-next-20200303+ #7
[   98.909025][    C8] Call Trace:
[   98.909046][    C8] [c00000003dd4f360] [c000000000970fe0]
dump_stack+0xf4/0x164 (unreliable)
[   98.909070][    C8] [c00000003dd4f3b0] [c00000000097dcf4]
nmi_cpu_backtrace+0x1b4/0x1e0
[   98.909084][    C8] [c00000003dd4f450] [c00000000097df48]
nmi_trigger_cpumask_backtrace+0x228/0x2c0
[   98.909118][    C8] [c00000003dd4f500] [c000000000057bf8]
arch_trigger_cpumask_backtrace+0x28/0x40
[   98.909152][    C8] [c00000003dd4f520] [c000000000202dd4]
rcu_dump_cpu_stacks+0x1c4/0x234
[   98.909184][    C8] [c00000003dd4f5a0] [c000000000201634]
rcu_sched_clock_irq+0xd54/0x1130
[   98.909207][    C8] [c00000003dd4f6c0] [c000000000217068]
update_process_times+0x48/0xb0
[   98.909239][    C8] [c00000003dd4f6f0] [c0000000002358b4]
tick_sched_handle+0x34/0xb0
[   98.909262][    C8] [c00000003dd4f720] [c0000000002361d8]
tick_sched_timer+0x68/0xe0
[   98.909284][    C8] [c00000003dd4f760] [c000000000219768]
__hrtimer_run_queues+0x528/0xa60
[   98.909306][    C8] [c00000003dd4f880] [c00000000021ab58]
hrtimer_interrupt+0x128/0x330
[   98.909329][    C8] [c00000003dd4f930] [c00000000002e1b4]
timer_interrupt+0x264/0x680
[   98.909352][    C8] [c00000003dd4f9c0] [c000000000009264]
decrementer_common+0x124/0x130
[   98.909366][    C8] --- interrupt: 901 at debug_vm_pgtable+0x7a8/0xbb4
[   98.909366][    C8]     LR = debug_vm_pgtable+0x6a0/0xbb4
[   98.909402][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[   98.909435][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[   98.909467][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[  124.418885][    C8] watchdog: BUG: soft lockup - CPU#8 stuck for 22s!
[swapper/0:1]
[  124.418914][    C8] Modules linked in:
[  124.418926][    C8] irq event stamp: 2937938
[  124.418940][    C8] hardirqs last  enabled at (2937937): [<c00000000000dec8>]
fast_exc_return_irq+0x28/0x34
[  124.418964][    C8] hardirqs last disabled at (2937938): [<c00000000000924c>]
decrementer_common+0x10c/0x130
[  124.418980][    C8] softirqs last  enabled at (2937936): [<c0000000009a1bf0>]
__do_softirq+0x640/0x8c8
[  124.419013][    C8] softirqs last disabled at (2937929): [<c000000000113cbc>]
irq_exit+0x16c/0x1d0
[  124.419036][    C8] CPU: 8 PID: 1 Comm: swapper/0 Tainted:
G             L    5.6.0-rc4-next-20200303+ #7
[  124.419059][    C8] NIP:  c00000000103dc14 LR: c00000000103db0c CTR:
0000000000000000
[  124.419080][    C8] REGS: c00000003dd4fa30 TRAP: 0901   Tainted:
G             L     (5.6.0-rc4-next-20200303+)
[  124.419103][    C8] MSR:  9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR:
42000222  XER: 00000000
[  124.419121][    C8] CFAR: c00000000103dc1c IRQMASK: 0 
[  124.419121][    C8] GPR00: c00000000103db0c c00000003dd4fcc0 c000000001657d00
05210001000000c0 
[  124.419121][    C8] GPR04: 8000000000000105 000000000000000a 00000000f4d9864c
0000000000000001 
[  124.419121][    C8] GPR08: 0000000000000000 ffffffffffffffff 0000000000000001
00000000000a0000 
[  124.419121][    C8] GPR12: 0000000000000000 c000001fffff9880 
[  124.419234][    C8] NIP [c00000000103dc14] debug_vm_pgtable+0x7a8/0xbb4
[  124.419254][    C8] LR [c00000000103db0c] debug_vm_pgtable+0x6a0/0xbb4
[  124.419274][    C8] Call Trace:
[  124.419291][    C8] [c00000003dd4fcc0] [c00000000103d994]
debug_vm_pgtable+0x528/0xbb4 (unreliable)
[  124.419324][    C8] [c00000003dd4fdb0] [c000000000010eac]
kernel_init+0x30/0x194
[  124.419347][    C8] [c00000003dd4fe20] [c00000000000b748]
ret_from_kernel_thread+0x5c/0x74
[  124.419359][    C8] Instruction dump:
[  124.419378][    C8] 7d075078 7ce74b78 7ce0f9ad 40c2fff0 7e449378 7fc3f378
4b03531d 60000000 
[  124.419412][    C8] 48000080 3920ffff 39400001 39000000 <7e00f8a8> 7e075039
40c2fff8 7e074878

> 
> mm/debug_vm_pgtable.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
> index 96dd7d574cef..c310f52c2b80 100644
> --- a/mm/debug_vm_pgtable.c
> +++ b/mm/debug_vm_pgtable.c
> @@ -250,13 +250,14 @@ static void __init pgd_populate_tests(struct mm_struct *mm, pgd_t *pgdp,
> }
> #endif
> 
> -static void __init pte_clear_tests(struct mm_struct *mm, pte_t *ptep)
> +static void __init pte_clear_tests(struct mm_struct *mm, pte_t *ptep,
> +                                  unsigned long vaddr)
> {
>        pte_t pte = READ_ONCE(*ptep);
> 
>        pte = __pte(pte_val(pte) | RANDOM_ORVALUE);
>        WRITE_ONCE(*ptep, pte);
> -       pte_clear(mm, 0, ptep);
> +       pte_clear(mm, vaddr, ptep);
>        pte = READ_ONCE(*ptep);
>        WARN_ON(!pte_none(pte));
> }
> @@ -302,6 +303,7 @@ static unsigned long __init get_random_vaddr(void)
> void __init debug_vm_pgtable(void)
> {
>        struct mm_struct *mm;
> +       spinlock_t *uninitialized_var(ptl);
>        pgd_t *pgdp;
>        p4d_t *p4dp, *saved_p4dp;
>        pud_t *pudp, *saved_pudp;
> @@ -344,7 +346,7 @@ void __init debug_vm_pgtable(void)
>        p4dp = p4d_alloc(mm, pgdp, vaddr);
>        pudp = pud_alloc(mm, p4dp, vaddr);
>        pmdp = pmd_alloc(mm, pudp, vaddr);
> -       ptep = pte_alloc_map(mm, pmdp, vaddr);
> +       ptep = pte_alloc_map_lock(mm, pmdp, vaddr, &ptl);
> 
>        /*
>         * Save all the page table page addresses as the page table
> @@ -364,13 +366,13 @@ void __init debug_vm_pgtable(void)
>        p4d_basic_tests(p4d_aligned, prot);
>        pgd_basic_tests(pgd_aligned, prot);
> 
> -       pte_clear_tests(mm, ptep);
> +       pte_clear_tests(mm, ptep, vaddr);
>        pmd_clear_tests(mm, pmdp);
>        pud_clear_tests(mm, pudp);
>        p4d_clear_tests(mm, p4dp);
>        pgd_clear_tests(mm, pgdp);
> 
> -       pte_unmap(ptep);
> +       pte_unmap_unlock(ptep, ptl);
> 
>        pmd_populate_tests(mm, pmdp, saved_ptep);
>        pud_populate_tests(mm, pudp, saved_pmdp);
> -- 
> 2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-03-04  1:39 UTC|newest]

Thread overview: 118+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17  3:17 [PATCH V14] mm/debug: Add tests validating architecture page table helpers Anshuman Khandual
2020-02-17  3:17 ` Anshuman Khandual
2020-02-17  3:17 ` Anshuman Khandual
2020-02-17  3:17 ` Anshuman Khandual
2020-02-17  3:17 ` Anshuman Khandual
2020-02-17  3:17 ` Anshuman Khandual
2020-02-24  1:58 ` Anshuman Khandual
2020-02-24  1:58   ` Anshuman Khandual
2020-02-24  1:58   ` Anshuman Khandual
2020-02-24  1:58   ` Anshuman Khandual
2020-02-24  1:58   ` Anshuman Khandual
2020-02-24  1:58   ` Anshuman Khandual
2020-02-26 14:09 ` Qian Cai
2020-02-26 14:09   ` Qian Cai
2020-02-26 14:09   ` Qian Cai
2020-02-26 14:09   ` Qian Cai
2020-02-26 14:09   ` Qian Cai
2020-02-26 14:09   ` Qian Cai
2020-02-26 14:09   ` Qian Cai
2020-02-26 14:12   ` Qian Cai
2020-02-26 14:12     ` Qian Cai
2020-02-26 14:12     ` Qian Cai
2020-02-26 14:12     ` Qian Cai
2020-02-26 14:12     ` Qian Cai
2020-02-26 14:12     ` Qian Cai
2020-02-26 14:12     ` Qian Cai
2020-02-26 14:44     ` Christophe Leroy
2020-02-26 14:44       ` Christophe Leroy
2020-02-26 14:44       ` Christophe Leroy
2020-02-26 14:44       ` Christophe Leroy
2020-02-26 14:44       ` Christophe Leroy
2020-02-26 14:44       ` Christophe Leroy
2020-02-27  2:34       ` Anshuman Khandual
2020-02-27  2:34         ` Anshuman Khandual
2020-02-27  2:34         ` Anshuman Khandual
2020-02-27  2:34         ` Anshuman Khandual
2020-02-27  2:34         ` Anshuman Khandual
2020-02-27  2:34         ` Anshuman Khandual
2020-02-27  4:03         ` Andrew Morton
2020-02-27  4:03           ` Andrew Morton
2020-02-27  4:03           ` Andrew Morton
2020-02-27  4:03           ` Andrew Morton
2020-02-27  4:03           ` Andrew Morton
2020-02-27  4:03           ` Andrew Morton
2020-02-27  4:07           ` Anshuman Khandual
2020-02-27  4:07             ` Anshuman Khandual
2020-02-27  4:07             ` Anshuman Khandual
2020-02-27  4:07             ` Anshuman Khandual
2020-02-27  4:07             ` Anshuman Khandual
2020-02-27  4:07             ` Anshuman Khandual
2020-02-26 14:45   ` Christophe Leroy
2020-02-26 14:45     ` Christophe Leroy
2020-02-26 14:45     ` Christophe Leroy
2020-02-26 14:45     ` Christophe Leroy
2020-02-26 14:45     ` Christophe Leroy
2020-02-26 14:45     ` Christophe Leroy
2020-02-26 15:51     ` Qian Cai
2020-02-26 15:51       ` Qian Cai
2020-02-26 15:51       ` Qian Cai
2020-02-26 15:51       ` Qian Cai
2020-02-26 15:51       ` Qian Cai
2020-02-26 15:51       ` Qian Cai
2020-02-26 15:51       ` Qian Cai
2020-03-02 19:40       ` Qian Cai
2020-03-02 19:40         ` Qian Cai
2020-03-02 19:40         ` Qian Cai
2020-03-02 19:40         ` Qian Cai
2020-03-02 19:40         ` Qian Cai
2020-03-02 19:40         ` Qian Cai
2020-03-02 19:40         ` Qian Cai
2020-03-03  5:55         ` Anshuman Khandual
2020-03-03  5:55           ` Anshuman Khandual
2020-03-03  5:55           ` Anshuman Khandual
2020-03-03  5:55           ` Anshuman Khandual
2020-03-03  5:55           ` Anshuman Khandual
2020-03-03  5:55           ` Anshuman Khandual
2020-03-04  1:39           ` Qian Cai [this message]
2020-03-04  1:39             ` Qian Cai
2020-03-04  1:39             ` Qian Cai
2020-03-04  1:39             ` Qian Cai
2020-03-04  1:39             ` Qian Cai
2020-03-04  1:39             ` Qian Cai
2020-03-04  6:48             ` Christophe Leroy
2020-03-04  6:48               ` Christophe Leroy
2020-03-04  6:48               ` Christophe Leroy
2020-03-04  6:48               ` Christophe Leroy
2020-03-04  6:48               ` Christophe Leroy
2020-03-04  6:48               ` Christophe Leroy
2020-03-04 11:29               ` Qian Cai
2020-03-04 11:29                 ` Qian Cai
2020-03-04 11:29                 ` Qian Cai
2020-03-04 11:29                 ` Qian Cai
2020-03-04 11:29                 ` Qian Cai
2020-03-04 11:29                 ` Qian Cai
2020-03-05  0:54                 ` Anshuman Khandual
2020-03-05  0:54                   ` Anshuman Khandual
2020-03-05  0:54                   ` Anshuman Khandual
2020-03-05  0:54                   ` Anshuman Khandual
2020-03-05  0:54                   ` Anshuman Khandual
2020-03-05  0:54                   ` Anshuman Khandual
2020-03-05  5:43                   ` Christophe Leroy
2020-03-05  5:43                     ` Christophe Leroy
2020-03-05  5:43                     ` Christophe Leroy
2020-03-05  5:43                     ` Christophe Leroy
2020-03-05  5:43                     ` Christophe Leroy
2020-03-05  5:43                     ` Christophe Leroy
2020-03-05  6:23                     ` Anshuman Khandual
2020-03-05  6:23                       ` Anshuman Khandual
2020-03-05  6:23                       ` Anshuman Khandual
2020-03-05  6:23                       ` Anshuman Khandual
2020-03-05  6:23                       ` Anshuman Khandual
2020-03-05  6:23                       ` Anshuman Khandual
2020-03-03  5:59         ` Christophe Leroy
2020-03-03  5:59           ` Christophe Leroy
2020-03-03  5:59           ` Christophe Leroy
2020-03-03  5:59           ` Christophe Leroy
2020-03-03  5:59           ` Christophe Leroy
2020-03-03  5:59           ` Christophe Leroy

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=12260F9A-695D-40F8-932F-61D86D77D441@lca.pw \
    --to=cai@lca.pw \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=benh@kernel.crashing.org \
    --cc=borntraeger@de.ibm.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=christophe.leroy@c-s.fr \
    --cc=gor@linux.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hpa@zytor.com \
    --cc=kirill@shutemov.name \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=paulus@samba.org \
    --cc=rppt@linux.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=vgupta@synopsys.com \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.