Open-CAS / open-cas-linux

Open CAS Linux
https://open-cas.com
BSD 3-Clause "New" or "Revised" License
224 stars 82 forks source link

Using smp_processor_id() in preemptible code #1482

Open mmichal10 opened 4 months ago

mmichal10 commented 4 months ago

Description

Starting a cache instance (commit eb97598e484b89dfecf55a9a39ecb5244aaaab03) on kernel 6.9.7-1.el9.elrepo.x86_64 causes multiple instances of the following error to appear in dmesg:

[445101.703624] BUG: using smp_processor_id() in preemptible [00000000] code: cas_cl_cache1/109077
[445101.703629] caller is _cas_cleaner_thread+0xf5/0x200 [cas_cache]
[445101.704106] cache1: Policy 'always' initialized successfully
[445101.704414] CPU: 10 PID: 109077 Comm: cas_cl_cache1 Kdump: loaded Tainted: G           OE      6.9.7-1.el9.elrepo.x86_64 #1
[445101.704698] BUG: using smp_processor_id() in preemptible [00000000] code: cas_mngt_1/109076
[445101.705219] Hardware name: Red Hat KVM/RHEL-AV, BIOS 1.16.0-1.module_el8.7.0+1140+ff0772f9 04/01/2014
[445101.705221] Call Trace:
[445101.705224]  <TASK>
[445101.705226]  dump_stack_lvl+0x62/0x80
[445101.705629] caller is cas_rpool_try_get+0x1b/0xb0 [cas_cache]
[445101.706071]  check_preemption_disabled+0xcc/0xf0
[445101.707017]  _cas_cleaner_thread+0xf5/0x200 [cas_cache]
[445101.707301]  ? preempt_count_add+0x4d/0xa0
[445101.707512]  ? __pfx__cas_cleaner_thread+0x10/0x10 [cas_cache]
[445101.707816]  kthread+0xeb/0x120
[445101.707981]  ? __pfx_kthread+0x10/0x10
[445101.708171]  ret_from_fork+0x2d/0x50
[445101.708360]  ? __pfx_kthread+0x10/0x10
[445101.708550]  ret_from_fork_asm+0x1a/0x30
[445101.708751]  </TASK>
[445101.708870] CPU: 7 PID: 109076 Comm: cas_mngt_1 Kdump: loaded Tainted: G           OE      6.9.7-1.el9.elrepo.x86_64 #1

The broken code:

(gdb) list *(_cas_cleaner_thread+0xf5)
0xff15 is in _cas_cleaner_thread (/root/OCL-michalm/modules/cas_cache/threads.c:96).
91                      if (atomic_read(&info->stop))
92                              break;
93
94                      atomic_set(&info->kicked, 0);
95                      init_completion(&info->sync_compl);
96                      ocf_cleaner_run(c, cache_priv->io_queues[smp_processor_id()]);
97                      wait_for_completion(&info->sync_compl);
98
99                      /*
100                      * In case of nop cleaning policy we don't want to perform cleaning
mmichal10 commented 4 months ago

OCL doesn't support preemptive kernels. Verify the configuration of the kernel