linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: Do not use smp_processor_id() in preemptible code
@ 2020-07-03  4:11 Xingxing Su
  2020-07-05  9:48 ` Thomas Bogendoerfer
  0 siblings, 1 reply; 2+ messages in thread
From: Xingxing Su @ 2020-07-03  4:11 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Huacai Chen, Jiaxun Yang
  Cc: linux-mips, linux-kernel, Xuefeng Li, Tiezhu Yang

Use preempt_disable() to fix the following bug under CONFIG_DEBUG_PREEMPT.

[   21.915305] BUG: using smp_processor_id() in preemptible [00000000] code: qemu-system-mip/1056
[   21.923996] caller is do_ri+0x1d4/0x690
[   21.927921] CPU: 0 PID: 1056 Comm: qemu-system-mip Not tainted 5.8.0-rc2 #3
[   21.934913] Stack : 0000000000000001 ffffffff81370000 ffffffff8071cd60 a80f926d5ac95694
[   21.942984]         a80f926d5ac95694 0000000000000000 98000007f0043c88 ffffffff80f2fe40
[   21.951054]         0000000000000000 0000000000000000 0000000000000001 0000000000000000
[   21.959123]         ffffffff802d60cc 98000007f0043dd8 ffffffff81f4b1e8 ffffffff81f60000
[   21.967192]         ffffffff81f60000 ffffffff80fe0000 ffff000000000000 0000000000000000
[   21.975261]         fffffffff500cce1 0000000000000001 0000000000000002 0000000000000000
[   21.983331]         ffffffff80fe1a40 0000000000000006 ffffffff8077f940 0000000000000000
[   21.991401]         ffffffff81460000 98000007f0040000 98000007f0043c80 000000fffba8cf20
[   21.999471]         ffffffff8071cd60 0000000000000000 0000000000000000 0000000000000000
[   22.007541]         0000000000000000 0000000000000000 ffffffff80212ab4 a80f926d5ac95694
[   22.015610]         ...
[   22.018086] Call Trace:
[   22.020562] [<ffffffff80212ab4>] show_stack+0xa4/0x138
[   22.025732] [<ffffffff8071cd60>] dump_stack+0xf0/0x150
[   22.030903] [<ffffffff80c73f5c>] check_preemption_disabled+0xf4/0x100
[   22.037375] [<ffffffff80213b84>] do_ri+0x1d4/0x690
[   22.042198] [<ffffffff8020b828>] handle_ri_int+0x44/0x5c
[   24.359386] BUG: using smp_processor_id() in preemptible [00000000] code: qemu-system-mip/1072
[   24.368204] caller is do_ri+0x1a8/0x690
[   24.372169] CPU: 4 PID: 1072 Comm: qemu-system-mip Not tainted 5.8.0-rc2 #3
[   24.379170] Stack : 0000000000000001 ffffffff81370000 ffffffff8071cd60 a80f926d5ac95694
[   24.387246]         a80f926d5ac95694 0000000000000000 98001007ef06bc88 ffffffff80f2fe40
[   24.395318]         0000000000000000 0000000000000000 0000000000000001 0000000000000000
[   24.403389]         ffffffff802d60cc 98001007ef06bdd8 ffffffff81f4b818 ffffffff81f60000
[   24.411461]         ffffffff81f60000 ffffffff80fe0000 ffff000000000000 0000000000000000
[   24.419533]         fffffffff500cce1 0000000000000001 0000000000000002 0000000000000000
[   24.427603]         ffffffff80fe0000 0000000000000006 ffffffff8077f940 0000000000000020
[   24.435673]         ffffffff81460020 98001007ef068000 98001007ef06bc80 000000fffbbbb370
[   24.443745]         ffffffff8071cd60 0000000000000000 0000000000000000 0000000000000000
[   24.451816]         0000000000000000 0000000000000000 ffffffff80212ab4 a80f926d5ac95694
[   24.459887]         ...
[   24.462367] Call Trace:
[   24.464846] [<ffffffff80212ab4>] show_stack+0xa4/0x138
[   24.470029] [<ffffffff8071cd60>] dump_stack+0xf0/0x150
[   24.475208] [<ffffffff80c73f5c>] check_preemption_disabled+0xf4/0x100
[   24.481682] [<ffffffff80213b58>] do_ri+0x1a8/0x690
[   24.486509] [<ffffffff8020b828>] handle_ri_int+0x44/0x5c

Signed-off-by: Xingxing Su <suxingxing@loongson.cn>
---
 arch/mips/kernel/traps.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 7c32c95..a46ce94 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -723,12 +723,14 @@ static int simulate_loongson3_cpucfg(struct pt_regs *regs,
 		perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, 0);
 
 		/* Do not emulate on unsupported core models. */
-		if (!loongson3_cpucfg_emulation_enabled(&current_cpu_data))
+		preempt_disable();
+		if (!loongson3_cpucfg_emulation_enabled(&current_cpu_data)) {
+			preempt_enable();
 			return -1;
-
+		}
 		regs->regs[rd] = loongson3_cpucfg_read_synthesized(
 			&current_cpu_data, sel);
-
+		preempt_enable();
 		return 0;
 	}
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] MIPS: Do not use smp_processor_id() in preemptible code
  2020-07-03  4:11 [PATCH] MIPS: Do not use smp_processor_id() in preemptible code Xingxing Su
@ 2020-07-05  9:48 ` Thomas Bogendoerfer
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Bogendoerfer @ 2020-07-05  9:48 UTC (permalink / raw)
  To: Xingxing Su
  Cc: Huacai Chen, Jiaxun Yang, linux-mips, linux-kernel, Xuefeng Li,
	Tiezhu Yang

On Fri, Jul 03, 2020 at 12:11:58PM +0800, Xingxing Su wrote:
> Use preempt_disable() to fix the following bug under CONFIG_DEBUG_PREEMPT.
> 
> [   21.915305] BUG: using smp_processor_id() in preemptible [00000000] code: qemu-system-mip/1056
> [   21.923996] caller is do_ri+0x1d4/0x690
> [   21.927921] CPU: 0 PID: 1056 Comm: qemu-system-mip Not tainted 5.8.0-rc2 #3
> [   21.934913] Stack : 0000000000000001 ffffffff81370000 ffffffff8071cd60 a80f926d5ac95694
> [   21.942984]         a80f926d5ac95694 0000000000000000 98000007f0043c88 ffffffff80f2fe40
> [   21.951054]         0000000000000000 0000000000000000 0000000000000001 0000000000000000
> [   21.959123]         ffffffff802d60cc 98000007f0043dd8 ffffffff81f4b1e8 ffffffff81f60000
> [   21.967192]         ffffffff81f60000 ffffffff80fe0000 ffff000000000000 0000000000000000
> [   21.975261]         fffffffff500cce1 0000000000000001 0000000000000002 0000000000000000
> [   21.983331]         ffffffff80fe1a40 0000000000000006 ffffffff8077f940 0000000000000000
> [   21.991401]         ffffffff81460000 98000007f0040000 98000007f0043c80 000000fffba8cf20
> [   21.999471]         ffffffff8071cd60 0000000000000000 0000000000000000 0000000000000000
> [   22.007541]         0000000000000000 0000000000000000 ffffffff80212ab4 a80f926d5ac95694
> [   22.015610]         ...
> [   22.018086] Call Trace:
> [   22.020562] [<ffffffff80212ab4>] show_stack+0xa4/0x138
> [   22.025732] [<ffffffff8071cd60>] dump_stack+0xf0/0x150
> [   22.030903] [<ffffffff80c73f5c>] check_preemption_disabled+0xf4/0x100
> [   22.037375] [<ffffffff80213b84>] do_ri+0x1d4/0x690
> [   22.042198] [<ffffffff8020b828>] handle_ri_int+0x44/0x5c
> [   24.359386] BUG: using smp_processor_id() in preemptible [00000000] code: qemu-system-mip/1072
> [   24.368204] caller is do_ri+0x1a8/0x690
> [   24.372169] CPU: 4 PID: 1072 Comm: qemu-system-mip Not tainted 5.8.0-rc2 #3
> [   24.379170] Stack : 0000000000000001 ffffffff81370000 ffffffff8071cd60 a80f926d5ac95694
> [   24.387246]         a80f926d5ac95694 0000000000000000 98001007ef06bc88 ffffffff80f2fe40
> [   24.395318]         0000000000000000 0000000000000000 0000000000000001 0000000000000000
> [   24.403389]         ffffffff802d60cc 98001007ef06bdd8 ffffffff81f4b818 ffffffff81f60000
> [   24.411461]         ffffffff81f60000 ffffffff80fe0000 ffff000000000000 0000000000000000
> [   24.419533]         fffffffff500cce1 0000000000000001 0000000000000002 0000000000000000
> [   24.427603]         ffffffff80fe0000 0000000000000006 ffffffff8077f940 0000000000000020
> [   24.435673]         ffffffff81460020 98001007ef068000 98001007ef06bc80 000000fffbbbb370
> [   24.443745]         ffffffff8071cd60 0000000000000000 0000000000000000 0000000000000000
> [   24.451816]         0000000000000000 0000000000000000 ffffffff80212ab4 a80f926d5ac95694
> [   24.459887]         ...
> [   24.462367] Call Trace:
> [   24.464846] [<ffffffff80212ab4>] show_stack+0xa4/0x138
> [   24.470029] [<ffffffff8071cd60>] dump_stack+0xf0/0x150
> [   24.475208] [<ffffffff80c73f5c>] check_preemption_disabled+0xf4/0x100
> [   24.481682] [<ffffffff80213b58>] do_ri+0x1a8/0x690
> [   24.486509] [<ffffffff8020b828>] handle_ri_int+0x44/0x5c
> 
> Signed-off-by: Xingxing Su <suxingxing@loongson.cn>
> ---
>  arch/mips/kernel/traps.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)

applied to mips-fixes.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-05  9:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-03  4:11 [PATCH] MIPS: Do not use smp_processor_id() in preemptible code Xingxing Su
2020-07-05  9:48 ` Thomas Bogendoerfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).