Skip to contentSkip to conversation

2.6.21-rc5-mm4: ia64: scheduling while atomic - utrace?

DISCUSSION Lee Schermerhorn 2 participants 2 messages Apr 5, 2007 ptrace support

lore
Share & tools
lore
#0 lore raw

Running a 'usex -e' load [http://people.redhat.com/~anderson/usex/] on 2.6.21-rc5-mm4 on ia64, I see the following:

BUG: scheduling while atomic: strace/0x40000001/20162

Call Trace:
 [<a000000100014ec0>] show_stack+0x80/0xa0
                                sp=e000076042dc7610 bsp=e000076042dc1260
 [<a000000100014f10>] dump_stack+0x30/0x60
                                sp=e000076042dc77e0 bsp=e000076042dc1248
 [<a0000001006f76e0>] schedule+0x1d00/0x22a0
                                sp=e000076042dc77e0 bsp=e000076042dc1108
 [<a000000100099750>] __cond_resched+0x50/0xa0
                                sp=e000076042dc7800 bsp=e000076042dc10e8
 [<a0000001006f8e30>] cond_resched+0xb0/0xe0
                                sp=e000076042dc7800 bsp=e000076042dc10d0
 [<a0000001001561d0>] get_user_pages+0x1b0/0x7c0
                                sp=e000076042dc7800 bsp=e000076042dc1028
 [<a0000001001568a0>] access_process_vm+0xc0/0x440
                                sp=e000076042dc7820 bsp=e000076042dc0f78
 [<a00000010002fcc0>] ia64_sync_user_rbs+0x80/0x100
                                sp=e000076042dc7830 bsp=e000076042dc0f38
 [<a00000010002fdf0>] do_gpregs_writeback+0xb0/0xe0
                                sp=e000076042dc7840 bsp=e000076042dc0f10
 [<a00000010000cad0>] unw_init_running+0x70/0xa0
                                sp=e000076042dc7850 bsp=e000076042dc0ee8
 [<a00000010002ed70>] do_regset_call+0x110/0x140
                                sp=e000076042dc7c30 bsp=e000076042dc0e88
 [<a00000010002eea0>] gpregs_writeback+0x40/0x60
                                sp=e000076042dc7e30 bsp=e000076042dc0e60
 [<a000000100123900>] ptrace_report+0xe0/0x1e0
                                sp=e000076042dc7e30 bsp=e000076042dc0e28
 [<a000000100123aa0>] ptrace_report_syscall+0xa0/0xe0
                                sp=e000076042dc7e30 bsp=e000076042dc0e00
 [<a000000100123b10>] ptrace_report_syscall_exit+0x30/0x60
                                sp=e000076042dc7e30 bsp=e000076042dc0dc8
 [<a000000100122cb0>] utrace_report_syscall+0xf0/0x540
                                sp=e000076042dc7e30 bsp=e000076042dc0d48
 [<a000000100031800>] syscall_trace_leave+0x60/0xc0
                                sp=e000076042dc7e30 bsp=e000076042dc0cf0
 [<a00000010000c1c0>] ia64_trace_syscall+0x100/0x110
                                sp=e000076042dc7e30 bsp=e000076042dc0cf0

Looks like get_ptrace_state(), called from ptrace_report_syscall calls rcu_read_lock() which disables preemption. Corresponding rcu_read_unlock() will be from put_ptrace_state() from ptrace_report() at end of report. However, ia64 needs to sync register backing store, and this requires access to process vm. get_user_pages' use of cond_sched() is tripping the "scheduling while atomic" bug.

May be related to:

	http://marc.info/?a=102883379600003&r=1&w=4

Lee

#1 lore raw

Thanks for the report. I introduced this bug recently when I changed around some of the locking but forgot about the writeback issue. I don't think this is directly related to any other crash you might have seen.

I've moved the call out of the lock-holding region, where it didn't need to be. I'm updating my patch series now; I've appended the incremental patch.

Thanks,
Roland

---
 kernel/ptrace.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
kernel/ptrace.c +10 -10
index fb6c3fb..c31d744 100644  
@@ -1473,16 +1473,6 @@ ptrace_report(struct utrace_attached_eng
 	 */
 	utrace_set_flags(tsk, engine, engine->flags | UTRACE_ACTION_QUIESCE);
 
-	/*
-	 * If regset 0 has a writeback call, do it now.  On register window
-	 * machines, this makes sure the user memory backing the register
-	 * data is up to date by the time wait_task_inactive returns to
-	 * ptrace_start in our tracer doing a PTRACE_PEEKDATA or the like.
-	 */
-	regset = utrace_regset(tsk, engine, utrace_native_view(tsk), 0);
-	if (regset->writeback)
-		(*regset->writeback)(tsk, regset, 0);
-
 	BUG_ON(code == 0);
 	tsk->exit_code = code;
 	do_notify(tsk, state->parent, CLD_TRAPPED);
@@ -1494,6 +1484,16 @@ ptrace_report(struct utrace_attached_eng
 
 	NO_LOCKS;
 
+	/*
+	 * If regset 0 has a writeback call, do it now.  On register window
+	 * machines, this makes sure the user memory backing the register
+	 * data is up to date by the time wait_task_inactive returns to
+	 * ptrace_start in our tracer doing a PTRACE_PEEKDATA or the like.
+	 */
+	regset = utrace_regset(tsk, engine, utrace_native_view(tsk), 0);
+	if (regset->writeback)
+		(*regset->writeback)(tsk, regset, 0);
+
 	return UTRACE_ACTION_RESUME;
 }