<div dir="ltr">Thank you, Glenn. The problem is fixed by disabling interrupt. <br><br>-Namhoon<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 27, 2015 at 7:13 AM, Glenn Elliott <span dir="ltr"><<a href="mailto:gelliott@cs.unc.edu" target="_blank">gelliott@cs.unc.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
> On Jan 27, 2015, at 6:54 AM, Namhoon Kim <<a href="mailto:namhoonk@cs.unc.edu">namhoonk@cs.unc.edu</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I am trying to implement mixed-criticality scheduling plugin. My implementation is based on P-RES plugin from wip-reservations branch.<br>
><br>
> The kernel output a warning message "BUG: using smp_processor_id() in preemptible [00000000] code: mc2spin/945" when a user program calls sys_complete_job system call. Does anyone know about this message?<br>
><br>
> Here's the kernel log.<br>
><br>
> 6246 P3: polling_replenish(945): next_replenishment=51360000000<br>
> 6247 P3: GMP reservation R945 state 3->1 at 51200049993<br>
> 6248 P3: NEXT_EVENT ADDED at 51220000000<br>
> 6249 P3: EVENT FOUND at 51220000000, NEW EVENT 51220000000<br>
> 6250 P3: (mc2spin/945:6) UPDATE_TIMER LV = 2<br>
> 6255 P3: (mc2spin/945:6) scheduled.<br>
> 6256 P3: (mc2spin/945:6) migrate from 0<br>
> 6257 P3: (mc2spin/945:6) stack_in_use=-1<br>
> 6258 P3: (mc2spin/945:6) mc2_complete_job returns at 51200117663<br>
> 6348 P3: ^A3BUG: using smp_processor_id() in preemptible [00000000] code: mc2spin/945<br>
> 6358 P3: caller is mc2_complete_job+0x1c/0x3b8<br>
> 6359 P3: ^AdCPU: 3 PID: 945 Comm: mc2spin Not tainted 3.10.31-litmus #418<br>
> 6360 P3: [<800155d8>] (unwind_backtrace+0x0/0x104) from [<800128ac>] (show_stack+0x20/0x24)<br>
> 6361 P3: [<800128ac>] (show_stack+0x20/0x24) from [<8070c37c>] (dump_stack+0x20/0x28)<br>
> 6362 P3: [<8070c37c>] (dump_stack+0x20/0x28) from [<80314e70>] (debug_smp_processor_id+0xcc/0xf0)<br>
> 6363 P3: [<80314e70>] (debug_smp_processor_id+0xcc/0xf0) from [<802feff0>] (mc2_complete_job+0x1c/0x3b8)<br>
> 6364 P3: [<802feff0>] (mc2_complete_job+0x1c/0x3b8) from [<802ebc8c>] (sys_complete_job+0x54/0x64)<br>
> 6365 P3: [<802ebc8c>] (sys_complete_job+0x54/0x64) from [<8000e8c0>] (ret_fast_syscall+0x0/0x30)<br>
> 6366 P3: (mc2spin/945:6) mc2_complete_job at 51221827554 (deadline: 51245000000) (cur->budget: 0)<br>
> 6367 P3: (mc2spin/945:7) next_release=51245000000<br>
> 6368 P3: EVENT FOUND at 51360000000, NEW EVENT 51360000000<br>
> 6369 P3: (mc2spin/945:7) CLIENT DEPART with budget 0<br>
> 6370 P3: (mc2spin/945:7) descheduled.<br>
> 6371 P3: EVENT FOUND at 51360000000, NEW EVENT 51360000000<br>
> 6399 P3: (mc2spin/945:7) try_to_wake_up() state:1<br>
> 6401 P3: (mc2spin/945:7) thread wakes up at 51245016173<br>
> 6403 P3: EVENT FOUND at 51360000000, NEW EVENT 51360000000<br>
> 6405 P3: (mc2spin/945:7) mc2_resume()<br>
> 6408 P3: (mc2spin/945:7) try_to_wake_up() done state:0<br>
><br>
> Thanks,<br>
><br>
> Namhoon<br>
<br>
</div></div>I believe smp_processor_id() may only be called safely while interrupts are disabled, e.g., a critical section protected by a spinlock or after irq_disable(). The CPU # is somewhat useless with preemption enabled, since the scheduler may migrate the calling thread immediately after.<br>
<br>
-Glenn<br>
_______________________________________________<br>
litmus-dev mailing list<br>
<a href="mailto:litmus-dev@lists.litmus-rt.org">litmus-dev@lists.litmus-rt.org</a><br>
<a href="https://lists.litmus-rt.org/listinfo/litmus-dev" target="_blank">https://lists.litmus-rt.org/listinfo/litmus-dev</a><br>
</blockquote></div><br></div>