Skip to contentSkip to conversation

riscv: Fix TRACE_IRQFLAGS call points in entry.S

PATCH In review Yipeng Zou 2 participants 5 messages Sep 9, 2022 – Sep 14, 2022 RISC-V

lore
Share & tools
lore

Yipeng Zou

author
#0 lore raw

PATCH 1/1 riscv: Fix TRACE_IRQFLAGS call points in entry.S

TRACE_IRQFLAGS need trace all {Enable,Disable} hard interrupts points in entry.S.
We miss a path(work_notifysig) that cause an WARN as shown below.

[   50.362431] ------------[ cut here ]------------
[   50.363607] DEBUG_LOCKS_WARN_ON(!lockdep_hardirqs_enabled())
[   50.367229] WARNING: CPU: 3 PID: 74 at kernel/locking/lockdep.c:5510 check_flags+0x10a/0x1e0
[   50.368905] Modules linked in:
[   50.369440] CPU: 3 PID: 74 Comm: rcS Tainted: G
[   50.370225] Hardware name: riscv-virtio,qemu (DT)
[   50.370632] epc : check_flags+0x10a/0x1e0
[   50.371015]  ra : check_flags+0x10a/0x1e0
[   50.371751] epc : ffffffff808e2670 ra : ffffffff808e2670 sp : ff20000000c3bca0
[   50.372721]  gp : ffffffff817e2188 tp : ff60000002fe1800 t0 : ffffffff8162a2a8
[   50.373321]  t1 : 0000000000000001 t2 : 2d2d2d2d2d2d2d2d s0 : ff20000000c3bcc0
[   50.373903]  s1 : ffffffff817e3340 a0 : 0000000000000030 a1 : ffffffff81693fa8
[   50.374476]  a2 : 0000000000000010 a3 : fffffffffffffffe a4 : 083151a422b8df00
[   50.375039]  a5 : 083151a422b8df00 a6 : ffffffff8006891e a7 : 083151a422b8df00
[   50.376028]  s2 : ffffffff817e54e0 s3 : ffffffff81695070 s4 : ff600000027d7800
[   50.376978]  s5 : ffffffff80c22770 s6 : 0000000200000022 s7 : ffffffffffffffff
[   50.377779]  s8 : ffffffff82301ed0 s9 : 0000000000001000 s10: 00000000001a9905
[   50.378335]  s11: 000000000014f3e8 t3 : ffffffff822d714f t4 : ffffffff822d714f
[   50.378955]  t5 : ffffffff822d7150 t6 : ff20000000c3ba98
[   50.379783] status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003
[   50.380810] [<ffffffff808e27be>] lock_is_held_type+0x78/0x14e
[   50.381477] [<ffffffff8003e850>] __might_resched+0x26/0x22c
[   50.382006] [<ffffffff8003ea92>] __might_sleep+0x3c/0x66
[   50.382477] [<ffffffff8002324e>] get_signal+0xaa/0x912
[   50.382947] [<ffffffff80005368>] do_notify_resume+0x82/0x434
[   50.383839] [<ffffffff80003bec>] ret_from_exception+0x0/0x10
Fixes 3c4697982982 ("riscv: Enable LOCKDEP_SUPPORT & fixup TRACE_IRQFLAGS_SUPPORT")
---
 arch/riscv/kernel/entry.S | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/riscv/kernel/entry.S +5 -1
index b9eda3fcbd6d..f4d23995a4f1 100644
@@ -370,16 +370,20 @@ resume_kernel:
 
 work_pending:
 	/* Enter slow path for supplementary processing */
-	la ra, ret_from_exception
 	andi s1, s0, _TIF_NEED_RESCHED
 	bnez s1, work_resched
 work_notifysig:
+#ifdef CONFIG_TRACE_IRQFLAGS
+	call __trace_hardirqs_on
+#endif
+	la ra, ret_from_exception
 	/* Handle pending signals and notify-resume requests */
 	csrs CSR_STATUS, SR_IE /* Enable interrupts for do_notify_resume() */
 	move a0, sp /* pt_regs */
 	move a1, s0 /* current_thread_info->flags */
 	tail do_notify_resume
 work_resched:
+	la ra, ret_from_exception
 	tail schedule
 
 /* Slow paths for ptrace. */
Signature · 7 lines
2.17.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#1 lore raw

I think it would be fixed by GENERIC_ENTRY. You could have a try.

https://lore.kernel.org/linux-riscv/[email protected]/

Quoted 67 lines · Yipeng Zou

TRACE_IRQFLAGS need trace all {Enable,Disable} hard interrupts points in entry.S.
We miss a path(work_notifysig) that cause an WARN as shown below.

[   50.362431] ------------[ cut here ]------------
[   50.363607] DEBUG_LOCKS_WARN_ON(!lockdep_hardirqs_enabled())
[   50.367229] WARNING: CPU: 3 PID: 74 at kernel/locking/lockdep.c:5510 check_flags+0x10a/0x1e0
[   50.368905] Modules linked in:
[   50.369440] CPU: 3 PID: 74 Comm: rcS Tainted: G
[   50.370225] Hardware name: riscv-virtio,qemu (DT)
[   50.370632] epc : check_flags+0x10a/0x1e0
[   50.371015]  ra : check_flags+0x10a/0x1e0
[   50.371751] epc : ffffffff808e2670 ra : ffffffff808e2670 sp : ff20000000c3bca0
[   50.372721]  gp : ffffffff817e2188 tp : ff60000002fe1800 t0 : ffffffff8162a2a8
[   50.373321]  t1 : 0000000000000001 t2 : 2d2d2d2d2d2d2d2d s0 : ff20000000c3bcc0
[   50.373903]  s1 : ffffffff817e3340 a0 : 0000000000000030 a1 : ffffffff81693fa8
[   50.374476]  a2 : 0000000000000010 a3 : fffffffffffffffe a4 : 083151a422b8df00
[   50.375039]  a5 : 083151a422b8df00 a6 : ffffffff8006891e a7 : 083151a422b8df00
[   50.376028]  s2 : ffffffff817e54e0 s3 : ffffffff81695070 s4 : ff600000027d7800
[   50.376978]  s5 : ffffffff80c22770 s6 : 0000000200000022 s7 : ffffffffffffffff
[   50.377779]  s8 : ffffffff82301ed0 s9 : 0000000000001000 s10: 00000000001a9905
[   50.378335]  s11: 000000000014f3e8 t3 : ffffffff822d714f t4 : ffffffff822d714f
[   50.378955]  t5 : ffffffff822d7150 t6 : ff20000000c3ba98
[   50.379783] status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003
[   50.380810] [<ffffffff808e27be>] lock_is_held_type+0x78/0x14e
[   50.381477] [<ffffffff8003e850>] __might_resched+0x26/0x22c
[   50.382006] [<ffffffff8003ea92>] __might_sleep+0x3c/0x66
[   50.382477] [<ffffffff8002324e>] get_signal+0xaa/0x912
[   50.382947] [<ffffffff80005368>] do_notify_resume+0x82/0x434
[   50.383839] [<ffffffff80003bec>] ret_from_exception+0x0/0x10
Fixes 3c4697982982 ("riscv: Enable LOCKDEP_SUPPORT & fixup TRACE_IRQFLAGS_SUPPORT")
---
 arch/riscv/kernel/entry.S | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/riscv/kernel/entry.S +5 -2
index b9eda3fcbd6d..f4d23995a4f1 100644
@@ -370,16 +370,20 @@ resume_kernel:
 
 work_pending:
        /* Enter slow path for supplementary processing */
-       la ra, ret_from_exception
        andi s1, s0, _TIF_NEED_RESCHED
        bnez s1, work_resched
 work_notifysig:
+#ifdef CONFIG_TRACE_IRQFLAGS
+       call __trace_hardirqs_on
+#endif
+       la ra, ret_from_exception
        /* Handle pending signals and notify-resume requests */
        csrs CSR_STATUS, SR_IE /* Enable interrupts for do_notify_resume() */
        move a0, sp /* pt_regs */
        move a1, s0 /* current_thread_info->flags */
        tail do_notify_resume
 work_resched:
+       la ra, ret_from_exception
        tail schedule
 
 /* Slow paths for ptrace. */
--

2.17.1

Signature · 7 lines
Best Regards
 Guo Ren

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
author
#2 lore raw
Quoted 3 lines · Guo Ren

I think it would be fixed by GENERIC_ENTRY. You could have a try.

https://lore.kernel.org/linux-riscv/[email protected]/

I test your patch and yes the WARNING was gone.

But I'm just wondering about the other stable branches, will your patch be merged into these branches?

Quoted 67 lines · Yipeng Zou
Quoted 66 lines

TRACE_IRQFLAGS need trace all {Enable,Disable} hard interrupts points in entry.S.
We miss a path(work_notifysig) that cause an WARN as shown below.

[   50.362431] ------------[ cut here ]------------
[   50.363607] DEBUG_LOCKS_WARN_ON(!lockdep_hardirqs_enabled())
[   50.367229] WARNING: CPU: 3 PID: 74 at kernel/locking/lockdep.c:5510 check_flags+0x10a/0x1e0
[   50.368905] Modules linked in:
[   50.369440] CPU: 3 PID: 74 Comm: rcS Tainted: G
[   50.370225] Hardware name: riscv-virtio,qemu (DT)
[   50.370632] epc : check_flags+0x10a/0x1e0
[   50.371015]  ra : check_flags+0x10a/0x1e0
[   50.371751] epc : ffffffff808e2670 ra : ffffffff808e2670 sp : ff20000000c3bca0
[   50.372721]  gp : ffffffff817e2188 tp : ff60000002fe1800 t0 : ffffffff8162a2a8
[   50.373321]  t1 : 0000000000000001 t2 : 2d2d2d2d2d2d2d2d s0 : ff20000000c3bcc0
[   50.373903]  s1 : ffffffff817e3340 a0 : 0000000000000030 a1 : ffffffff81693fa8
[   50.374476]  a2 : 0000000000000010 a3 : fffffffffffffffe a4 : 083151a422b8df00
[   50.375039]  a5 : 083151a422b8df00 a6 : ffffffff8006891e a7 : 083151a422b8df00
[   50.376028]  s2 : ffffffff817e54e0 s3 : ffffffff81695070 s4 : ff600000027d7800
[   50.376978]  s5 : ffffffff80c22770 s6 : 0000000200000022 s7 : ffffffffffffffff
[   50.377779]  s8 : ffffffff82301ed0 s9 : 0000000000001000 s10: 00000000001a9905
[   50.378335]  s11: 000000000014f3e8 t3 : ffffffff822d714f t4 : ffffffff822d714f
[   50.378955]  t5 : ffffffff822d7150 t6 : ff20000000c3ba98
[   50.379783] status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003
[   50.380810] [<ffffffff808e27be>] lock_is_held_type+0x78/0x14e
[   50.381477] [<ffffffff8003e850>] __might_resched+0x26/0x22c
[   50.382006] [<ffffffff8003ea92>] __might_sleep+0x3c/0x66
[   50.382477] [<ffffffff8002324e>] get_signal+0xaa/0x912
[   50.382947] [<ffffffff80005368>] do_notify_resume+0x82/0x434
[   50.383839] [<ffffffff80003bec>] ret_from_exception+0x0/0x10
Fixes 3c4697982982 ("riscv: Enable LOCKDEP_SUPPORT & fixup TRACE_IRQFLAGS_SUPPORT")
---
  arch/riscv/kernel/entry.S | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
arch/riscv/kernel/entry.S +5 -2
index b9eda3fcbd6d..f4d23995a4f1 100644
@@ -370,16 +370,20 @@ resume_kernel:
 
  work_pending:
         /* Enter slow path for supplementary processing */
-       la ra, ret_from_exception
         andi s1, s0, _TIF_NEED_RESCHED
         bnez s1, work_resched
  work_notifysig:
+#ifdef CONFIG_TRACE_IRQFLAGS
+       call __trace_hardirqs_on
+#endif
+       la ra, ret_from_exception
         /* Handle pending signals and notify-resume requests */
         csrs CSR_STATUS, SR_IE /* Enable interrupts for do_notify_resume() */
         move a0, sp /* pt_regs */
         move a1, s0 /* current_thread_info->flags */
         tail do_notify_resume
  work_resched:
+       la ra, ret_from_exception
         tail schedule
 
  /* Slow paths for ptrace. */
--

2.17.1

Signature · 8 lines
Regards,
Yipeng Zou


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#3 lore raw
Quoted 8 lines · Yipeng Zou
Quoted 3 lines · Guo Ren

I think it would be fixed by GENERIC_ENTRY. You could have a try.

https://lore.kernel.org/linux-riscv/[email protected]/

I test your patch and yes the WARNING was gone.

Thx, could you give me a Tested-by?

Quoted 3 lines

But I'm just wondering about the other stable branches, will your patch be merged into these branches?

No, your patch is still worth for stable branches.

Quoted 72 lines
Quoted 64 lines · Yipeng Zou
Quoted 62 lines

TRACE_IRQFLAGS need trace all {Enable,Disable} hard interrupts points in entry.S.
We miss a path(work_notifysig) that cause an WARN as shown below.

[   50.362431] ------------[ cut here ]------------
[   50.363607] DEBUG_LOCKS_WARN_ON(!lockdep_hardirqs_enabled())
[   50.367229] WARNING: CPU: 3 PID: 74 at kernel/locking/lockdep.c:5510 check_flags+0x10a/0x1e0
[   50.368905] Modules linked in:
[   50.369440] CPU: 3 PID: 74 Comm: rcS Tainted: G
[   50.370225] Hardware name: riscv-virtio,qemu (DT)
[   50.370632] epc : check_flags+0x10a/0x1e0
[   50.371015]  ra : check_flags+0x10a/0x1e0
[   50.371751] epc : ffffffff808e2670 ra : ffffffff808e2670 sp : ff20000000c3bca0
[   50.372721]  gp : ffffffff817e2188 tp : ff60000002fe1800 t0 : ffffffff8162a2a8
[   50.373321]  t1 : 0000000000000001 t2 : 2d2d2d2d2d2d2d2d s0 : ff20000000c3bcc0
[   50.373903]  s1 : ffffffff817e3340 a0 : 0000000000000030 a1 : ffffffff81693fa8
[   50.374476]  a2 : 0000000000000010 a3 : fffffffffffffffe a4 : 083151a422b8df00
[   50.375039]  a5 : 083151a422b8df00 a6 : ffffffff8006891e a7 : 083151a422b8df00
[   50.376028]  s2 : ffffffff817e54e0 s3 : ffffffff81695070 s4 : ff600000027d7800
[   50.376978]  s5 : ffffffff80c22770 s6 : 0000000200000022 s7 : ffffffffffffffff
[   50.377779]  s8 : ffffffff82301ed0 s9 : 0000000000001000 s10: 00000000001a9905
[   50.378335]  s11: 000000000014f3e8 t3 : ffffffff822d714f t4 : ffffffff822d714f
[   50.378955]  t5 : ffffffff822d7150 t6 : ff20000000c3ba98
[   50.379783] status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003
[   50.380810] [<ffffffff808e27be>] lock_is_held_type+0x78/0x14e
[   50.381477] [<ffffffff8003e850>] __might_resched+0x26/0x22c
[   50.382006] [<ffffffff8003ea92>] __might_sleep+0x3c/0x66
[   50.382477] [<ffffffff8002324e>] get_signal+0xaa/0x912
[   50.382947] [<ffffffff80005368>] do_notify_resume+0x82/0x434
[   50.383839] [<ffffffff80003bec>] ret_from_exception+0x0/0x10
Fixes 3c4697982982 ("riscv: Enable LOCKDEP_SUPPORT & fixup TRACE_IRQFLAGS_SUPPORT")
---
  arch/riscv/kernel/entry.S | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
arch/riscv/kernel/entry.S +5 -1
index b9eda3fcbd6d..f4d23995a4f1 100644
@@ -370,16 +370,20 @@ resume_kernel:
 
  work_pending:
         /* Enter slow path for supplementary processing */
-       la ra, ret_from_exception
         andi s1, s0, _TIF_NEED_RESCHED
         bnez s1, work_resched
  work_notifysig:
+#ifdef CONFIG_TRACE_IRQFLAGS
+       call __trace_hardirqs_on
+#endif
+       la ra, ret_from_exception
         /* Handle pending signals and notify-resume requests */
         csrs CSR_STATUS, SR_IE /* Enable interrupts for do_notify_resume() */
         move a0, sp /* pt_regs */
         move a1, s0 /* current_thread_info->flags */
         tail do_notify_resume
  work_resched:
+       la ra, ret_from_exception
         tail schedule
 
Quoted 4 lines
Quoted 4 lines
arch/riscv/kernel/entry.S +0 -1
  /* Slow paths for ptrace. */
--

2.17.1

--
Regards,
Yipeng Zou

Signature · 7 lines
Best Regards
 Guo Ren

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
author
#4 lore raw
Quoted 8 lines · Guo Ren
Quoted 6 lines · Yipeng Zou
Quoted 3 lines · Guo Ren

I think it would be fixed by GENERIC_ENTRY. You could have a try.

https://lore.kernel.org/linux-riscv/[email protected]/

I test your patch and yes the WARNING was gone.

Thx, could you give me a Tested-by?

sure, i will reply it late.

Quoted 3 lines
Quoted 2 lines

But I'm just wondering about the other stable branches, will your patch be merged into these branches?

No, your patch is still worth for stable branches.

ok. got it.

Quoted 72 lines
Quoted 71 lines
Quoted 63 lines · Yipeng Zou
Quoted 62 lines

TRACE_IRQFLAGS need trace all {Enable,Disable} hard interrupts points in entry.S.
We miss a path(work_notifysig) that cause an WARN as shown below.

[   50.362431] ------------[ cut here ]------------
[   50.363607] DEBUG_LOCKS_WARN_ON(!lockdep_hardirqs_enabled())
[   50.367229] WARNING: CPU: 3 PID: 74 at kernel/locking/lockdep.c:5510 check_flags+0x10a/0x1e0
[   50.368905] Modules linked in:
[   50.369440] CPU: 3 PID: 74 Comm: rcS Tainted: G
[   50.370225] Hardware name: riscv-virtio,qemu (DT)
[   50.370632] epc : check_flags+0x10a/0x1e0
[   50.371015]  ra : check_flags+0x10a/0x1e0
[   50.371751] epc : ffffffff808e2670 ra : ffffffff808e2670 sp : ff20000000c3bca0
[   50.372721]  gp : ffffffff817e2188 tp : ff60000002fe1800 t0 : ffffffff8162a2a8
[   50.373321]  t1 : 0000000000000001 t2 : 2d2d2d2d2d2d2d2d s0 : ff20000000c3bcc0
[   50.373903]  s1 : ffffffff817e3340 a0 : 0000000000000030 a1 : ffffffff81693fa8
[   50.374476]  a2 : 0000000000000010 a3 : fffffffffffffffe a4 : 083151a422b8df00
[   50.375039]  a5 : 083151a422b8df00 a6 : ffffffff8006891e a7 : 083151a422b8df00
[   50.376028]  s2 : ffffffff817e54e0 s3 : ffffffff81695070 s4 : ff600000027d7800
[   50.376978]  s5 : ffffffff80c22770 s6 : 0000000200000022 s7 : ffffffffffffffff
[   50.377779]  s8 : ffffffff82301ed0 s9 : 0000000000001000 s10: 00000000001a9905
[   50.378335]  s11: 000000000014f3e8 t3 : ffffffff822d714f t4 : ffffffff822d714f
[   50.378955]  t5 : ffffffff822d7150 t6 : ff20000000c3ba98
[   50.379783] status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003
[   50.380810] [<ffffffff808e27be>] lock_is_held_type+0x78/0x14e
[   50.381477] [<ffffffff8003e850>] __might_resched+0x26/0x22c
[   50.382006] [<ffffffff8003ea92>] __might_sleep+0x3c/0x66
[   50.382477] [<ffffffff8002324e>] get_signal+0xaa/0x912
[   50.382947] [<ffffffff80005368>] do_notify_resume+0x82/0x434
[   50.383839] [<ffffffff80003bec>] ret_from_exception+0x0/0x10
Fixes 3c4697982982 ("riscv: Enable LOCKDEP_SUPPORT & fixup TRACE_IRQFLAGS_SUPPORT")
---
   arch/riscv/kernel/entry.S | 6 +++++-
   1 file changed, 5 insertions(+), 1 deletion(-)
arch/riscv/kernel/entry.S +5 -1
index b9eda3fcbd6d..f4d23995a4f1 100644
@@ -370,16 +370,20 @@ resume_kernel:
 
   work_pending:
          /* Enter slow path for supplementary processing */
-       la ra, ret_from_exception
          andi s1, s0, _TIF_NEED_RESCHED
          bnez s1, work_resched
   work_notifysig:
+#ifdef CONFIG_TRACE_IRQFLAGS
+       call __trace_hardirqs_on
+#endif
+       la ra, ret_from_exception
          /* Handle pending signals and notify-resume requests */
          csrs CSR_STATUS, SR_IE /* Enable interrupts for do_notify_resume() */
          move a0, sp /* pt_regs */
          move a1, s0 /* current_thread_info->flags */
          tail do_notify_resume
   work_resched:
+       la ra, ret_from_exception
          tail schedule
 
Quoted 4 lines
Quoted 4 lines
arch/riscv/kernel/entry.S +0 -1
   /* Slow paths for ptrace. */
--

2.17.1

--
Regards,
Yipeng Zou

Signature · 8 lines
Regards,
Yipeng Zou


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv