From b30fb5365fe21f60de13d08bd50524f1ead8fe54 Mon Sep 17 00:00:00 2001 From: Nicholas Piggin Date: Sun, 3 Oct 2021 11:22:05 +1000 Subject: cpu: add debug check in cpu_relax If cpu_relax() is called when not at medium SMT priority, it will lose the prior priority and return at medium. Add a debug check to catch this, which would have flagged the previous bug. Signed-off-by: Nicholas Piggin Signed-off-by: Vasant Hegde --- core/cpu.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'core') diff --git a/core/cpu.c b/core/cpu.c index 5c10fc6..0f2da15 100644 --- a/core/cpu.c +++ b/core/cpu.c @@ -80,6 +80,12 @@ unsigned long __attrconst cpu_emergency_stack_top(unsigned int pir) void __nomcount cpu_relax(void) { + if ((mfspr(SPR_PPR32) >> 18) != 0x4) { + printf("cpu_relax called when not at medium SMT priority: " + "PPR[PRI]=0x%lx\n", mfspr(SPR_PPR32) >> 18); + backtrace(); + } + /* Relax a bit to give sibling threads some breathing space */ smt_lowest(); asm volatile("nop; nop; nop; nop;\n" -- cgit v1.1