LoongArch: Fix calling smp_processor_id() in preemptible code#11259
LoongArch: Fix calling smp_processor_id() in preemptible code#11259kernel-patches-daemon-bpf[bot] wants to merge 1 commit intobpf-next_basefrom
Conversation
|
Upstream branch: 309d880 |
73579ec to
9848291
Compare
|
Upstream branch: 44dd647 |
20362ad to
5c99a68
Compare
9848291 to
c7dcbca
Compare
|
Upstream branch: 05c9b2e |
5c99a68 to
95ddda2
Compare
c7dcbca to
69a44ca
Compare
|
Upstream branch: 4faa189 |
95ddda2 to
06e11b2
Compare
69a44ca to
f264dc7
Compare
|
Upstream branch: 748f9c6 |
06e11b2 to
587df77
Compare
f264dc7 to
59120bd
Compare
|
Upstream branch: 6dd780f |
587df77 to
3e2ca4a
Compare
59120bd to
94aca0b
Compare
|
Upstream branch: 099bded |
3e2ca4a to
f8e86b7
Compare
94aca0b to
980a66f
Compare
|
Upstream branch: bd2e02e |
f8e86b7 to
460d0b8
Compare
980a66f to
026b5c1
Compare
|
Upstream branch: bd2e02e |
460d0b8 to
3cddc26
Compare
026b5c1 to
b72a510
Compare
|
Upstream branch: 0c55d48 |
3cddc26 to
235e5a6
Compare
b72a510 to
ebefa82
Compare
|
Upstream branch: e95e85b |
Fix the warning:
BUG: using smp_processor_id() in preemptible [00000000] code: sys
temd/1
caller is larch_insn_text_copy+0x40/0xf0
Simply changing it to raw_smp_processor_id() is not enough: if preempt
and CPU hotplug happens after raw_smp_processor_id() but before
stop_machine(), the CPU where raw_smp_processor_id() has run may be
offline when stop_machine() and no CPU will run copy_to_kernel_nofault()
in text_copy_cb(). Thus guard the larch_insn_text_copy() calls with
cpus_read_lock() and change stop_machine() to stop_machine_cpuslocked()
to prevent this.
I've considered moving the locks inside larch_insn_text_copy() but
doing so seems not an easy hack. In bpf_arch_text_poke() obviously the
memcpy() call must be guarded by text_mutex, so we have to leave the
acquire of text_mutex out of larch_insn_text_copy. But in the entire
kernel the acquire of mutexes is always after cpus_read_lock(), so we
cannot put cpus_read_lock() into larch_insn_text_copy() while leaving
the text_mutex acquire out (or we risk a deadlock due to inconsistent
lock acquire order). So let's fix the bug first and leave the
posssible refactor as future work.
Fixes: 9fbd18c ("LoongArch: BPF: Add dynamic code modification support")
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
235e5a6 to
10bfb77
Compare
Pull request for series with
subject: LoongArch: Fix calling smp_processor_id() in preemptible code
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1060482