Bug 217179

Summary: Running Dhrystone test in v6.3-rc1 triggers BUG
Product: Other Reporter: Tobias Klausmann (klausman)
Component: OtherAssignee: other_other
Status: NEEDINFO ---    
Severity: normal    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: Subsystem:
Regression: No Bisected commit-id:
Attachments: Patch to fix BUG on run of Dhrystone benchmark

Description Tobias Klausmann 2023-03-11 12:51:43 UTC
just ran the new Dhrystone test on one of my machines post-boot (using
`echo y > /sys/module/test_dhry/parameters/run`) and:

```
BUG: using smp_processor_id() in preemptible [00000000] code: bash/1903
caller is dhry_benchmark+0x39/0x90
CPU: 5 PID: 1903 Comm: bash Not tainted 6.3.0-rc1 #13
Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./B450 Pro4 R2.0, BIOS H4.84 04/08/2021
Call Trace:
 <TASK>
 dump_stack_lvl+0x32/0x50
 check_preemption_disabled+0xe6/0x100
 dhry_benchmark+0x39/0x90
 dhry_run_set+0x33/0x40
 param_attr_store+0x98/0x100
 module_attr_store+0x18/0x30
 kernfs_fop_write_iter+0x14e/0x220
 vfs_write+0x29a/0x460
 ksys_write+0x74/0x100
 do_syscall_64+0x3a/0xc0
 entry_SYSCALL_64_after_hwframe+0x72/0xdc
RIP: 0033:0x7f5eec252190
Code: 40 00 48 8b 15 71 9c 0d 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 80 3d 51 24 0e
00 00 74 17 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 58 c3 0f 1f 80 00 00 00 00 48 83 ec 28 48 89
RSP: 002b:00007ffc4b1dea68 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007f5eec252190
RDX: 0000000000000002 RSI: 000055d3c05b4540 RDI: 0000000000000001
RBP: 000055d3c05b4540 R08: 00007f5eec32d3d0 R09: 00007f5eec32d3d0
R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000002
R13: 00007f5eec32d760 R14: 0000000000000002 R15: 00007f5eec3289e0
 </TASK>
CPU5: Dhrystones per Second: 34361907 (19557 DMIPS)
```

Test completes fine (with a credible result) and the machine keeps
running.

Running it through decode_stacktrache.sh yields:

```
 $ scripts/decode_stacktrace.sh vmlinux < log
BUG: using smp_processor_id() in preemptible [00000000] code: bash/1903
caller is dhry_benchmark (lib/dhry_run.c:49)
CPU: 5 PID: 1903 Comm: bash Not tainted 6.3.0-rc1 #13
Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./B450 Pro4 R2.0, BIOS H4.84 04/08/2021
Call Trace:
<TASK>
dump_stack_lvl (lib/dump_stack.c:107 (discriminator 1))
check_preemption_disabled (./arch/x86/include/asm/preempt.h:85 lib/smp_processor_id.c:53)
dhry_benchmark (lib/dhry_run.c:49)
dhry_run_set (lib/dhry_run.c:70)
param_attr_store (kernel/params.c:586)
module_attr_store (kernel/params.c:922)
kernfs_fop_write_iter (fs/kernfs/file.c:338)
vfs_write (fs/read_write.c:492 fs/read_write.c:584)
ksys_write (fs/read_write.c:638)
do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80)
entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120)
RIP: 0033:0x7f5eec252190
Code: 40 00 48 8b 15 71 9c 0d 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 80 3d 51 24 0e

Code starting with the faulting instruction
===========================================
   0:   40 00 48 8b             rex add %cl,-0x75(%rax)
   4:   15 71 9c 0d 00          adc    $0xd9c71,%eax
   9:   f7 d8                   neg    %eax
   b:   64 89 02                mov    %eax,%fs:(%rdx)
   e:   48 c7 c0 ff ff ff ff    mov    $0xffffffffffffffff,%rax
  15:   eb b7                   jmp    0xffffffffffffffce
  17:   0f 1f 00                nopl   (%rax)
  1a:   80                      .byte 0x80
  1b:   3d                      .byte 0x3d
  1c:   51                      push   %rcx
  1d:   24 0e                   and    $0xe,%al
00 00 74 17 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 58 c3 0f 1f 80 00 00 00 00 48 83 ec 28 48 89
RSP: 002b:00007ffc4b1dea68 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007f5eec252190
RDX: 0000000000000002 RSI: 000055d3c05b4540 RDI: 0000000000000001
RBP: 000055d3c05b4540 R08: 00007f5eec32d3d0 R09: 00007f5eec32d3d0
R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000002
R13: 00007f5eec32d760 R14: 0000000000000002 R15: 00007f5eec3289e0
</TASK>
CPU5: Dhrystones per Second: 34361907 (19557 DMIPS)
```
Comment 1 Artem S. Tashkinov 2023-03-12 04:46:18 UTC
Almost no one is subscribed to Other Other so your best bet will be to bisect:

https://docs.kernel.org/admin-guide/bug-bisect.html
Comment 2 Tobias Klausmann 2023-03-13 13:24:20 UTC
There isn't anything to bisect here. All the code was introduced in one commit, d5528cc16893f1f64b07936b1e88aa023128debb. Without that commit, there is no test to run.
Comment 3 Tobias Klausmann 2023-03-13 15:56:13 UTC
Created attachment 303936 [details]
Patch to fix BUG on run of Dhrystone benchmark

This patch fixes the issue for me, but I don't know if it is the right approach.