Date: Mon, 24 Jul 2006 20:20:06 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 102310 for review Message-ID: <200607242020.k6OKK6Lw031273@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=102310 Change 102310 by jhb@jhb_mutex on 2006/07/24 20:19:06 Synchronize syscall() routines: - Add KTR_SYSC tracing to amd64/ia32, ia64/ia32, and ia64. - Add PTRACESTOP invocations to amd64/ia32, ia64/ia32, and powerpc. Expand and synchronize locking checks for all platforms to keep the WITNESS_WARN, add KASSERT()'s checking td_critnest and td_locks, and remove mtx_assert()'s for sched_lock and Giant. Affected files ... .. //depot/projects/smpng/sys/amd64/amd64/trap.c#45 edit .. //depot/projects/smpng/sys/amd64/ia32/ia32_syscall.c#12 edit .. //depot/projects/smpng/sys/arm/arm/trap.c#18 edit .. //depot/projects/smpng/sys/i386/i386/trap.c#94 edit .. //depot/projects/smpng/sys/ia64/ia32/ia32_trap.c#7 edit .. //depot/projects/smpng/sys/ia64/ia64/trap.c#81 edit .. //depot/projects/smpng/sys/powerpc/powerpc/trap.c#49 edit .. //depot/projects/smpng/sys/sparc64/sparc64/trap.c#68 edit Differences ... ==== //depot/projects/smpng/sys/amd64/amd64/trap.c#45 (text+ko) ==== @@ -874,6 +874,19 @@ } /* + * Check for misbehavior. + */ + KASSERT(td->td_critnest == 0, + ("System call %s returning in a critical section", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???")); + KASSERT(td->td_locks == 0, + ("System call %s returning with %d locks held", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???", + td->td_locks)); + WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"); + + /* * Handle reschedule and other end-of-syscall issues */ userret(td, &frame); @@ -894,9 +907,4 @@ STOPEVENT(p, S_SCX, code); PTRACESTOP_SC(p, td, S_PT_SCX); - - WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", - (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"); - mtx_assert(&sched_lock, MA_NOTOWNED); - mtx_assert(&Giant, MA_NOTOWNED); } ==== //depot/projects/smpng/sys/amd64/ia32/ia32_syscall.c#12 (text+ko) ==== @@ -171,6 +171,9 @@ if (KTRPOINT(td, KTR_SYSCALL)) ktrsyscall(code, narg, args64); #endif + CTR4(KTR_SYSC, "syscall enter thread %p pid %d proc %s code %d", td, + td->td_proc->p_pid, td->td_proc->p_comm, code); + /* * Try to run the syscall without Giant if the syscall * is MP safe. @@ -184,6 +187,8 @@ STOPEVENT(p, S_SCE, narg); + PTRACESTOP_SC(p, td, S_PT_SCE); + AUDIT_SYSCALL_ENTER(code, td); error = (*callp->sy_call)(td, args64); AUDIT_SYSCALL_EXIT(error, td); @@ -238,10 +243,25 @@ } /* + * Check for misbehavior. + */ + KASSERT(td->td_critnest == 0, + ("System call %s returning in a critical section", + (code >= 0 && code < SYS_MAXSYSCALL) ? freebsd32_syscallnames[code] : "???")); + KASSERT(td->td_locks == 0, + ("System call %s returning with %d locks held", + (code >= 0 && code < SYS_MAXSYSCALL) ? freebsd32_syscallnames[code] : "???", + td->td_locks)); + WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", + (code >= 0 && code < SYS_MAXSYSCALL) ? freebsd32_syscallnames[code] : "???"); + + /* * Handle reschedule and other end-of-syscall issues */ userret(td, &frame); + CTR4(KTR_SYSC, "syscall exit thread %p pid %d proc %s code %d", td, + td->td_proc->p_pid, td->td_proc->p_comm, code); #ifdef KTRACE if (KTRPOINT(td, KTR_SYSRET)) ktrsysret(code, error, td->td_retval[0]); @@ -254,10 +274,7 @@ */ STOPEVENT(p, S_SCX, code); - WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", - (code >= 0 && code < SYS_MAXSYSCALL) ? freebsd32_syscallnames[code] : "???"); - mtx_assert(&sched_lock, MA_NOTOWNED); - mtx_assert(&Giant, MA_NOTOWNED); + PTRACESTOP_SC(p, td, S_PT_SCX); } ==== //depot/projects/smpng/sys/arm/arm/trap.c#18 (text+ko) ==== @@ -979,8 +979,17 @@ } if (locked && (callp->sy_narg & SYF_MPSAFE) == 0) mtx_unlock(&Giant); - - + + KASSERT(td->td_critnest == 0, + ("System call %s returning in a critical section", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???")); + KASSERT(td->td_locks == 0, + ("System call %s returning with %d locks held", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???", + td->td_locks)); + WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"); + userret(td, frame); CTR4(KTR_SYSC, "syscall exit thread %p pid %d proc %s code %d", td, td->td_proc->p_pid, td->td_proc->p_comm, code); @@ -991,8 +1000,6 @@ if (KTRPOINT(td, KTR_SYSRET)) ktrsysret(code, error, td->td_retval[0]); #endif - mtx_assert(&sched_lock, MA_NOTOWNED); - mtx_assert(&Giant, MA_NOTOWNED); } void ==== //depot/projects/smpng/sys/i386/i386/trap.c#94 (text+ko) ==== @@ -1065,6 +1065,19 @@ } /* + * Check for misbehavior. + */ + KASSERT(td->td_critnest == 0, + ("System call %s returning in a critical section", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???")); + KASSERT(td->td_locks == 0, + ("System call %s returning with %d locks held", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???", + td->td_locks)); + WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"); + + /* * Handle reschedule and other end-of-syscall issues */ userret(td, &frame); @@ -1085,10 +1098,5 @@ STOPEVENT(p, S_SCX, code); PTRACESTOP_SC(p, td, S_PT_SCX); - - WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", - (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"); - mtx_assert(&sched_lock, MA_NOTOWNED); - mtx_assert(&Giant, MA_NOTOWNED); } ==== //depot/projects/smpng/sys/ia64/ia32/ia32_trap.c#7 (text+ko) ==== @@ -112,6 +112,9 @@ if (KTRPOINT(td, KTR_SYSCALL)) ktrsyscall(code, narg, args64); #endif + CTR4(KTR_SYSC, "syscall enter thread %p pid %d proc %s code %d", td, + td->td_proc->p_pid, td->td_proc->p_comm, code); + /* * Try to run the syscall without Giant if the syscall * is MP safe. @@ -125,6 +128,8 @@ STOPEVENT(p, S_SCE, narg); + PTRACESTOP_SC(p, td, S_PT_SCE); + error = (*callp->sy_call)(td, args64); } @@ -176,6 +181,24 @@ trapsignal(td, &ksi); } + /* + * Check for misbehavior. + */ + KASSERT(td->td_critnest == 0, + ("System call %s returning in a critical section", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???")); + KASSERT(td->td_locks == 0, + ("System call %s returning with %d locks held", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???", + td->td_locks)); + WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"); + + /* + * End of syscall tracing. + */ + CTR4(KTR_SYSC, "syscall exit thread %p pid %d proc %s code %d", td, + td->td_proc->p_pid, td->td_proc->p_comm, code); #ifdef KTRACE if (KTRPOINT(td, KTR_SYSRET)) ktrsysret(code, error, td->td_retval[0]); @@ -188,10 +211,7 @@ */ STOPEVENT(p, S_SCX, code); - WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", - (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"); - mtx_assert(&sched_lock, MA_NOTOWNED); - mtx_assert(&Giant, MA_NOTOWNED); + PTRACESTOP_SC(p, td, S_PT_SCX); } /* ==== //depot/projects/smpng/sys/ia64/ia64/trap.c#81 (text+ko) ==== @@ -1007,6 +1007,8 @@ if (KTRPOINT(td, KTR_SYSCALL)) ktrsyscall(code, (callp->sy_narg & SYF_ARGMASK), args); #endif + CTR4(KTR_SYSC, "syscall enter thread %p pid %d proc %s code %d", td, + td->td_proc->p_pid, td->td_proc->p_comm, code); td->td_retval[0] = 0; td->td_retval[1] = 0; @@ -1046,8 +1048,26 @@ } } + /* + * Check for misbehavior. + */ + KASSERT(td->td_critnest == 0, + ("System call %s returning in a critical section", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???")); + KASSERT(td->td_locks == 0, + ("System call %s returning with %d locks held", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???", + td->td_locks)); + WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"); + + /* + * Handle reschedule and other end-of-syscall issues + */ userret(td, tf); + CTR4(KTR_SYSC, "syscall exit thread %p pid %d proc %s code %d", td, + td->td_proc->p_pid, td->td_proc->p_comm, code); #ifdef KTRACE if (KTRPOINT(td, KTR_SYSRET)) ktrsysret(code, error, td->td_retval[0]); @@ -1062,10 +1082,5 @@ PTRACESTOP_SC(p, td, S_PT_SCX); - WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", - (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"); - mtx_assert(&sched_lock, MA_NOTOWNED); - mtx_assert(&Giant, MA_NOTOWNED); - return (error); } ==== //depot/projects/smpng/sys/powerpc/powerpc/trap.c#49 (text+ko) ==== @@ -420,6 +420,8 @@ STOPEVENT(p, S_SCE, narg); + PTRACESTOP_SC(p, td, S_PT_SCE); + error = (*callp->sy_call)(td, params); CTR3(KTR_SYSC, "syscall: p=%s %s ret=%x", p->p_comm, @@ -467,6 +469,19 @@ if ((callp->sy_narg & SYF_MPSAFE) == 0) mtx_unlock(&Giant); + /* + * Check for misbehavior. + */ + KASSERT(td->td_critnest == 0, + ("System call %s returning in a critical section", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???")); + KASSERT(td->td_locks == 0, + ("System call %s returning with %d locks held", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???", + td->td_locks)); + WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"); + #ifdef KTRACE if (KTRPOINT(td, KTR_SYSRET)) ktrsysret(code, error, td->td_retval[0]); @@ -477,10 +492,7 @@ */ STOPEVENT(p, S_SCX, code); - WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", - (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"); - mtx_assert(&sched_lock, MA_NOTOWNED); - mtx_assert(&Giant, MA_NOTOWNED); + PTRACESTOP_SC(p, td, S_PT_SCX); } static int ==== //depot/projects/smpng/sys/sparc64/sparc64/trap.c#68 (text+ko) ==== @@ -648,6 +648,19 @@ mtx_unlock(&Giant); /* + * Check for misbehavior. + */ + KASSERT(td->td_critnest == 0, + ("System call %s returning in a critical section", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???")); + KASSERT(td->td_locks == 0, + ("System call %s returning with %d locks held", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???", + td->td_locks)); + WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", + (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"); + + /* * Handle reschedule and other end-of-syscall issues */ userret(td, tf); @@ -664,9 +677,4 @@ STOPEVENT(p, S_SCX, code); PTRACESTOP_SC(p, td, S_PT_SCX); - - WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning", - (code >= 0 && code < SYS_MAXSYSCALL) ? syscallnames[code] : "???"); - mtx_assert(&sched_lock, MA_NOTOWNED); - mtx_assert(&Giant, MA_NOTOWNED); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607242020.k6OKK6Lw031273>