Skip to contentSkip to conversation

riscv: remove the assert of lock for cpu_running

PATCH In review Zong Li 2 participants 4 messages Apr 10, 2020 – Apr 12, 2020 RISC-V

lore
Share & tools
lore

Zong Li

author
#0 lore raw

PATCH 1/1 riscv: remove the assert of lock for cpu_running

The cpu_running is not a lock-class, it lacks the dep_map member in completion. It causes the error as follow:

arch/riscv/kernel/smpboot.c: In function '__cpu_up':
./include/linux/lockdep.h:364:52: error: 'struct completion' has no member named 'dep_map'
364 | #define lockdep_is_held(lock) lock_is_held(&(lock)->dep_map)
| ^~
./include/asm-generic/bug.h:113:25: note: in definition of macro 'WARN_ON'

  113 |  int __ret_warn_on = !!(condition);    \
      |                         ^~~~~~~~~
./include/linux/lockdep.h:390:27: note: in expansion of macro 'lockdep_is_held'
  390 |   WARN_ON(debug_locks && !lockdep_is_held(l)); \
      |                           ^~~~~~~~~~~~~~~

arch/riscv/kernel/smpboot.c:118:2: note: in expansion of macro 'lockdep_assert_held'
118 | lockdep_assert_held(&cpu_running);

---
 arch/riscv/kernel/smpboot.c | 1 -
 1 file changed, 1 deletion(-)
arch/riscv/kernel/smpboot.c +0 -1
index 8bc01f0ca73b..bbc1baa2d90c 100644
@@ -115,7 +115,6 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 		  task_stack_page(tidle) + THREAD_SIZE);
 	WRITE_ONCE(__cpu_up_task_pointer[hartid], tidle);
 
-	lockdep_assert_held(&cpu_running);
 	wait_for_completion_timeout(&cpu_running,
 					    msecs_to_jiffies(1000));
 
Signature · 1 line
2.26.0
Acked-by on v1 1/1
#1 lore raw

Haha, are you working on lockdep ? Me too, here is my patch, not finished.

It's still warning at begin, I've no time to debug, and it's similar to csky's:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/csky?id=000591f1ca3312d9a29e15a9e3fe5c4171f75586

If you are working on LOCKDEP, I'll wait your patch :)

commit 096d7a4b26d21aa7c71c86f200241144569e697a (riscv-lockdep)

Author: Guo Ren <[email protected]>
Date:   Fri Apr 10 16:38:37 2020 +0800

riscv: Enable LOCKDEP_SUPPORT

Lockdep is needed by proving the spinlocks and rwlocks.

arch/riscv/Kconfig +3 -0
index 8672e77a5b7a..bfe76c76a107 100644
@@ -163,6 +163,9 @@ config PGTABLE_LEVELS
        default 3 if 64BIT
        default 2
 
+config LOCKDEP_SUPPORT
+       def_bool y
+
 source "arch/riscv/Kconfig.socs"
 
 menu "Platform type"
arch/riscv/kernel/entry.S +61 -0

79 lines not on this page · raw message

arch/riscv/kernel/smpboot.c +1 -1
index 8bc01f0ca73b..54fd70eb50bd 100644
@@ -115,7 +115,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
                  task_stack_page(tidle) + THREAD_SIZE);
        WRITE_ONCE(__cpu_up_task_pointer[hartid], tidle);
 
-       lockdep_assert_held(&cpu_running);
+//     lockdep_assert_held(&cpu_running);
        wait_for_completion_timeout(&cpu_running,
                                            msecs_to_jiffies(1000));
 
Quoted 38 lines · Zong Li

The cpu_running is not a lock-class, it lacks the dep_map member in completion. It causes the error as follow:

arch/riscv/kernel/smpboot.c: In function '__cpu_up':
./include/linux/lockdep.h:364:52: error: 'struct completion' has no member named 'dep_map'
364 | #define lockdep_is_held(lock) lock_is_held(&(lock)->dep_map)
| ^~
./include/asm-generic/bug.h:113:25: note: in definition of macro 'WARN_ON'

  113 |  int __ret_warn_on = !!(condition);    \
      |                         ^~~~~~~~~
./include/linux/lockdep.h:390:27: note: in expansion of macro 'lockdep_is_held'
  390 |   WARN_ON(debug_locks && !lockdep_is_held(l)); \
      |                           ^~~~~~~~~~~~~~~

arch/riscv/kernel/smpboot.c:118:2: note: in expansion of macro 'lockdep_assert_held'
118 | lockdep_assert_held(&cpu_running);

---
 arch/riscv/kernel/smpboot.c | 1 -
 1 file changed, 1 deletion(-)
arch/riscv/kernel/smpboot.c +0 -2
index 8bc01f0ca73b..bbc1baa2d90c 100644
@@ -115,7 +115,6 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
                  task_stack_page(tidle) + THREAD_SIZE);
        WRITE_ONCE(__cpu_up_task_pointer[hartid], tidle);
 
-       lockdep_assert_held(&cpu_running);
        wait_for_completion_timeout(&cpu_running,
                                            msecs_to_jiffies(1000));
 
--

2.26.0

Signature · 4 lines
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/
author
#2 lore raw
Quoted 4 lines · Guo Ren

Haha, are you working on lockdep ? Me too, here is my patch, not finished.

No, I just went to add a lock assert at somewhere, so enabled lockdep to test it on incomplete lockdep support, then I found this error. If you are working on lockdep, it might be better to fix this problem on your side instead of here.

Quoted 175 lines

It's still warning at begin, I've no time to debug, and it's similar to csky's:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/csky?id=000591f1ca3312d9a29e15a9e3fe5c4171f75586

If you are working on LOCKDEP, I'll wait your patch :)

commit 096d7a4b26d21aa7c71c86f200241144569e697a (riscv-lockdep)

Author: Guo Ren <[email protected]>
Date:   Fri Apr 10 16:38:37 2020 +0800

riscv: Enable LOCKDEP_SUPPORT

Lockdep is needed by proving the spinlocks and rwlocks.

arch/riscv/Kconfig +3 -0
index 8672e77a5b7a..bfe76c76a107 100644
@@ -163,6 +163,9 @@ config PGTABLE_LEVELS
        default 3 if 64BIT
        default 2
 
+config LOCKDEP_SUPPORT
+       def_bool y
+
 source "arch/riscv/Kconfig.socs"
 
 menu "Platform type"
arch/riscv/kernel/entry.S +61 -0
index 208702d8c18e..41588ee74cb2 100644
@@ -175,6 +175,24 @@ ENTRY(handle_exception)
 .option pop
 
        la ra, ret_from_exception
+#ifdef CONFIG_TRACE_IRQFLAGS
+       call trace_hardirqs_off
+       la ra, ret_from_exception
+       REG_L s0, PT_SP(sp)
+       REG_L s1, PT_STATUS(sp)
+       REG_L s2, PT_EPC(sp)
+       REG_L s3, PT_BADADDR(sp)
+       REG_L s4, PT_CAUSE(sp)
+       REG_L s5, PT_TP(sp)
+       REG_L a0, PT_A0(sp)
+       REG_L a1, PT_A1(sp)
+       REG_L a2, PT_A2(sp)
+       REG_L a3, PT_A3(sp)
+       REG_L a4, PT_A4(sp)
+       REG_L a5, PT_A5(sp)
+       REG_L a6, PT_A6(sp)
+       REG_L a7, PT_A7(sp)
+#endif
        /*
         * MSB of cause differentiates between
         * interrupts and exceptions
@@ -191,6 +209,24 @@ ENTRY(handle_exception)
         */
        andi t0, s1, SR_PIE
        beqz t0, 1f
+#ifdef CONFIG_TRACE_IRQFLAGS
+       call trace_hardirqs_on
+       la ra, ret_from_exception
+       REG_L s0, PT_SP(sp)
+       REG_L s1, PT_STATUS(sp)
+       REG_L s2, PT_EPC(sp)
+       REG_L s3, PT_BADADDR(sp)
+       REG_L s4, PT_CAUSE(sp)
+       REG_L s5, PT_TP(sp)
+       REG_L a0, PT_A0(sp)
+       REG_L a1, PT_A1(sp)
+       REG_L a2, PT_A2(sp)
+       REG_L a3, PT_A3(sp)
+       REG_L a4, PT_A4(sp)
+       REG_L a5, PT_A5(sp)
+       REG_L a6, PT_A6(sp)
+       REG_L a7, PT_A7(sp)
+#endif
        csrs CSR_STATUS, SR_IE
 
 1:
@@ -291,6 +327,31 @@ resume_userspace:
        csrw CSR_SCRATCH, tp
 
 restore_all:
+#ifdef CONFIG_TRACE_IRQFLAGS
+       REG_L s1, PT_STATUS(sp)
+       andi t0, s1, SR_PIE
+       beqz t0, 1f
+       call trace_hardirqs_on
+       j 2f
+1:
+       call trace_hardirqs_off
+2:
+       la ra, ret_from_exception
+       REG_L s0, PT_SP(sp)
+       REG_L s1, PT_STATUS(sp)
+       REG_L s2, PT_EPC(sp)
+       REG_L s3, PT_BADADDR(sp)
+       REG_L s4, PT_CAUSE(sp)
+       REG_L s5, PT_TP(sp)
+       REG_L a0, PT_A0(sp)
+       REG_L a1, PT_A1(sp)
+       REG_L a2, PT_A2(sp)
+       REG_L a3, PT_A3(sp)
+       REG_L a4, PT_A4(sp)
+       REG_L a5, PT_A5(sp)
+       REG_L a6, PT_A6(sp)
+       REG_L a7, PT_A7(sp)
+#endif
        RESTORE_ALL
 #ifdef CONFIG_RISCV_M_MODE
        mret
arch/riscv/kernel/smpboot.c +1 -1
index 8bc01f0ca73b..54fd70eb50bd 100644
@@ -115,7 +115,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
                  task_stack_page(tidle) + THREAD_SIZE);
        WRITE_ONCE(__cpu_up_task_pointer[hartid], tidle);
 
-       lockdep_assert_held(&cpu_running);
+//     lockdep_assert_held(&cpu_running);
        wait_for_completion_timeout(&cpu_running,
                                            msecs_to_jiffies(1000));
 
Quoted 35 lines · Zong Li

The cpu_running is not a lock-class, it lacks the dep_map member in completion. It causes the error as follow:

arch/riscv/kernel/smpboot.c: In function '__cpu_up':
./include/linux/lockdep.h:364:52: error: 'struct completion' has no member named 'dep_map'
364 | #define lockdep_is_held(lock) lock_is_held(&(lock)->dep_map)
| ^~
./include/asm-generic/bug.h:113:25: note: in definition of macro 'WARN_ON'

  113 |  int __ret_warn_on = !!(condition);    \
      |                         ^~~~~~~~~
./include/linux/lockdep.h:390:27: note: in expansion of macro 'lockdep_is_held'
  390 |   WARN_ON(debug_locks && !lockdep_is_held(l)); \
      |                           ^~~~~~~~~~~~~~~

arch/riscv/kernel/smpboot.c:118:2: note: in expansion of macro 'lockdep_assert_held'
118 | lockdep_assert_held(&cpu_running);

---
 arch/riscv/kernel/smpboot.c | 1 -
 1 file changed, 1 deletion(-)
arch/riscv/kernel/smpboot.c +0 -2
index 8bc01f0ca73b..bbc1baa2d90c 100644
@@ -115,7 +115,6 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
                  task_stack_page(tidle) + THREAD_SIZE);
        WRITE_ONCE(__cpu_up_task_pointer[hartid], tidle);
 
-       lockdep_assert_held(&cpu_running);
        wait_for_completion_timeout(&cpu_running,
                                            msecs_to_jiffies(1000));
 
--
Quoted 3 lines

2.26.0

--
Best Regards
Guo Ren

ML: https://lore.kernel.org/linux-csky/

#3 lore raw

Ok, I'll continue riscv locdep work and include your patch.

Quoted 187 lines · Zong Li
Quoted 4 lines · Guo Ren

Haha, are you working on lockdep ? Me too, here is my patch, not finished.

No, I just went to add a lock assert at somewhere, so enabled lockdep to test it on incomplete lockdep support, then I found this error. If you are working on lockdep, it might be better to fix this problem on your side instead of here.

Quoted 175 lines

It's still warning at begin, I've no time to debug, and it's similar to csky's:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/csky?id=000591f1ca3312d9a29e15a9e3fe5c4171f75586

If you are working on LOCKDEP, I'll wait your patch :)

commit 096d7a4b26d21aa7c71c86f200241144569e697a (riscv-lockdep)

Author: Guo Ren <[email protected]>
Date:   Fri Apr 10 16:38:37 2020 +0800

riscv: Enable LOCKDEP_SUPPORT

Lockdep is needed by proving the spinlocks and rwlocks.

arch/riscv/Kconfig +3 -0
index 8672e77a5b7a..bfe76c76a107 100644
@@ -163,6 +163,9 @@ config PGTABLE_LEVELS
        default 3 if 64BIT
        default 2
 
+config LOCKDEP_SUPPORT
+       def_bool y
+
 source "arch/riscv/Kconfig.socs"
 
 menu "Platform type"
arch/riscv/kernel/entry.S +61 -0
index 208702d8c18e..41588ee74cb2 100644
@@ -175,6 +175,24 @@ ENTRY(handle_exception)
 .option pop
 
        la ra, ret_from_exception
+#ifdef CONFIG_TRACE_IRQFLAGS
+       call trace_hardirqs_off
+       la ra, ret_from_exception
+       REG_L s0, PT_SP(sp)
+       REG_L s1, PT_STATUS(sp)
+       REG_L s2, PT_EPC(sp)
+       REG_L s3, PT_BADADDR(sp)
+       REG_L s4, PT_CAUSE(sp)
+       REG_L s5, PT_TP(sp)
+       REG_L a0, PT_A0(sp)
+       REG_L a1, PT_A1(sp)
+       REG_L a2, PT_A2(sp)
+       REG_L a3, PT_A3(sp)
+       REG_L a4, PT_A4(sp)
+       REG_L a5, PT_A5(sp)
+       REG_L a6, PT_A6(sp)
+       REG_L a7, PT_A7(sp)
+#endif
        /*
         * MSB of cause differentiates between
         * interrupts and exceptions
@@ -191,6 +209,24 @@ ENTRY(handle_exception)
         */
        andi t0, s1, SR_PIE
        beqz t0, 1f
+#ifdef CONFIG_TRACE_IRQFLAGS
+       call trace_hardirqs_on
+       la ra, ret_from_exception
+       REG_L s0, PT_SP(sp)
+       REG_L s1, PT_STATUS(sp)
+       REG_L s2, PT_EPC(sp)
+       REG_L s3, PT_BADADDR(sp)
+       REG_L s4, PT_CAUSE(sp)
+       REG_L s5, PT_TP(sp)
+       REG_L a0, PT_A0(sp)
+       REG_L a1, PT_A1(sp)
+       REG_L a2, PT_A2(sp)
+       REG_L a3, PT_A3(sp)
+       REG_L a4, PT_A4(sp)
+       REG_L a5, PT_A5(sp)
+       REG_L a6, PT_A6(sp)
+       REG_L a7, PT_A7(sp)
+#endif
        csrs CSR_STATUS, SR_IE
 
 1:
@@ -291,6 +327,31 @@ resume_userspace:
        csrw CSR_SCRATCH, tp
 
 restore_all:
+#ifdef CONFIG_TRACE_IRQFLAGS
+       REG_L s1, PT_STATUS(sp)
+       andi t0, s1, SR_PIE
+       beqz t0, 1f
+       call trace_hardirqs_on
+       j 2f
+1:
+       call trace_hardirqs_off
+2:
+       la ra, ret_from_exception
+       REG_L s0, PT_SP(sp)
+       REG_L s1, PT_STATUS(sp)
+       REG_L s2, PT_EPC(sp)
+       REG_L s3, PT_BADADDR(sp)
+       REG_L s4, PT_CAUSE(sp)
+       REG_L s5, PT_TP(sp)
+       REG_L a0, PT_A0(sp)
+       REG_L a1, PT_A1(sp)
+       REG_L a2, PT_A2(sp)
+       REG_L a3, PT_A3(sp)
+       REG_L a4, PT_A4(sp)
+       REG_L a5, PT_A5(sp)
+       REG_L a6, PT_A6(sp)
+       REG_L a7, PT_A7(sp)
+#endif
        RESTORE_ALL
 #ifdef CONFIG_RISCV_M_MODE
        mret
arch/riscv/kernel/smpboot.c +1 -1
index 8bc01f0ca73b..54fd70eb50bd 100644
@@ -115,7 +115,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
                  task_stack_page(tidle) + THREAD_SIZE);
        WRITE_ONCE(__cpu_up_task_pointer[hartid], tidle);
 
-       lockdep_assert_held(&cpu_running);
+//     lockdep_assert_held(&cpu_running);
        wait_for_completion_timeout(&cpu_running,
                                            msecs_to_jiffies(1000));
 
Quoted 35 lines · Zong Li

The cpu_running is not a lock-class, it lacks the dep_map member in completion. It causes the error as follow:

arch/riscv/kernel/smpboot.c: In function '__cpu_up':
./include/linux/lockdep.h:364:52: error: 'struct completion' has no member named 'dep_map'
364 | #define lockdep_is_held(lock) lock_is_held(&(lock)->dep_map)
| ^~
./include/asm-generic/bug.h:113:25: note: in definition of macro 'WARN_ON'

  113 |  int __ret_warn_on = !!(condition);    \
      |                         ^~~~~~~~~
./include/linux/lockdep.h:390:27: note: in expansion of macro 'lockdep_is_held'
  390 |   WARN_ON(debug_locks && !lockdep_is_held(l)); \
      |                           ^~~~~~~~~~~~~~~

arch/riscv/kernel/smpboot.c:118:2: note: in expansion of macro 'lockdep_assert_held'
118 | lockdep_assert_held(&cpu_running);

---
 arch/riscv/kernel/smpboot.c | 1 -
 1 file changed, 1 deletion(-)
arch/riscv/kernel/smpboot.c +0 -2
index 8bc01f0ca73b..bbc1baa2d90c 100644
@@ -115,7 +115,6 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
                  task_stack_page(tidle) + THREAD_SIZE);
        WRITE_ONCE(__cpu_up_task_pointer[hartid], tidle);
 
-       lockdep_assert_held(&cpu_running);
        wait_for_completion_timeout(&cpu_running,
                                            msecs_to_jiffies(1000));
 
--
Quoted 3 lines

2.26.0

--
Best Regards
Guo Ren

ML: https://lore.kernel.org/linux-csky/

Signature · 4 lines
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/