diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-09-19 16:51:43 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-09-19 16:51:43 +0000 |
commit | c479a90eb8129ad770ff6daba981e9f20af69e6f (patch) | |
tree | e3c313c0b77fbcc1f434ec162a95a06a9e05a773 /sys/alpha/osf1 | |
parent | 745da316335f104d267ad6c4b565be45311e5d6e (diff) | |
download | FreeBSD-src-c479a90eb8129ad770ff6daba981e9f20af69e6f.zip FreeBSD-src-c479a90eb8129ad770ff6daba981e9f20af69e6f.tar.gz |
Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(),
as they both interact with the tty code (!MPSAFE) and may sleep if the
tty buffer is full (per comment).
Modify all consumers of uprintf() and tprintf() to hold Giant around
calls into these functions. In most cases, this means adding an
acquisition of Giant immediately around the function. In some cases
(nfs_timer()), it means acquiring Giant higher up in the callout.
With these changes, UFS no longer panics on SMP when either blocks are
exhausted or inodes are exhausted under load due to races in the tty
code when running without Giant.
NB: Some reduction in calls to uprintf() in the svr4 code is probably
desirable.
NB: In the case of nfs_timer(), calling uprintf() while holding a mutex,
or even in a callout at all, is a bad idea, and will generate warnings
and potential upset. This needs to be fixed, but was a problem before
this change.
NB: uprintf()/tprintf() sleeping is generally a bad ideas, as is having
non-MPSAFE tty code.
MFC after: 1 week
Diffstat (limited to 'sys/alpha/osf1')
-rw-r--r-- | sys/alpha/osf1/osf1_ioctl.c | 4 | ||||
-rw-r--r-- | sys/alpha/osf1/osf1_misc.c | 4 | ||||
-rw-r--r-- | sys/alpha/osf1/osf1_signal.c | 30 |
3 files changed, 32 insertions, 6 deletions
diff --git a/sys/alpha/osf1/osf1_ioctl.c b/sys/alpha/osf1/osf1_ioctl.c index 09d970d..c45646f 100644 --- a/sys/alpha/osf1/osf1_ioctl.c +++ b/sys/alpha/osf1/osf1_ioctl.c @@ -33,6 +33,8 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> +#include <sys/lock.h> +#include <sys/mutex.h> #include <sys/systm.h> #include <sys/fcntl.h> #include <sys/filio.h> @@ -110,9 +112,11 @@ osf1_ioctl(td, uap) break; } #ifdef IOCTL_DEBUG + mtx_lock(&Giant); uprintf( "OSF/1 IOCTL: group = %c, cmd = %d, len = %d, dir = %s\n", group, cmd, len, dirstr); + mtx_unlock(&Giant); #endif a.fd = uap->fd; diff --git a/sys/alpha/osf1/osf1_misc.c b/sys/alpha/osf1/osf1_misc.c index 63ce5ee..eacf78a 100644 --- a/sys/alpha/osf1/osf1_misc.c +++ b/sys/alpha/osf1/osf1_misc.c @@ -209,8 +209,10 @@ osf1_getsysinfo(td, uap) rpb_size = (unsigned long)&hwrpb->rpb_tbhint - (unsigned long)hwrpb; if(uap->nbytes < rpb_size){ + mtx_lock(&Giant); uprintf("nbytes = %ld, sizeof(struct rpb) = %ld\n", uap->nbytes, rpb_size); + mtx_unlock(&Giant); error = EINVAL; } else { @@ -254,7 +256,9 @@ osf1_setsysinfo(td, uap) break; } default: + mtx_lock(&Giant); uprintf("osf1_setsysinfo called with op=%ld\n", uap->op); + mtx_unlock(&Giant); /*error = EINVAL;*/ } return (error); diff --git a/sys/alpha/osf1/osf1_signal.c b/sys/alpha/osf1/osf1_signal.c index 355cb1c..f275195 100644 --- a/sys/alpha/osf1/osf1_signal.c +++ b/sys/alpha/osf1/osf1_signal.c @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #endif #include <sys/param.h> +#include <sys/lock.h> +#include <sys/mutex.h> #include <sys/systm.h> #include <sys/sysproto.h> #include <sys/signalvar.h> @@ -145,9 +147,12 @@ osf1_to_bsd_sigaction(osa, bsa) { bsa->sa_handler = osa->osa_handler; - if (osf1_sigdbg) + if (osf1_sigdbg) { + mtx_lock(&Giant); uprintf("%s(%d): handler @0x%lx \n", __FILE__, __LINE__, (unsigned long)osa->osa_handler); + mtx_unlock(&Giant); + } osf1_to_bsd_sigset(&osa->osa_mask, &bsa->sa_mask); bsa->sa_flags = 0; if ((osa->osa_flags & OSF1_SA_ONSTACK) != 0) @@ -225,9 +230,12 @@ osf1_sigaction(td, uap) struct sigaction *nbsap; int error; - if (osf1_sigdbg && uap->sigtramp) + if (osf1_sigdbg && uap->sigtramp) { + mtx_lock(&Giant); uprintf("osf1_sigaction: trampoline handler at %p\n", uap->sigtramp); + mtx_unlock(&Giant); + } td->td_md.osf_sigtramp = uap->sigtramp; if (uap->nsa != NULL) { if ((error = copyin(uap->nsa, &osa, sizeof(osa))) != 0) @@ -315,8 +323,10 @@ osf1_signal(td, uap) #endif error = kern_sigaction(td, signum, &nbsa, &obsa, 0); if (error != 0) { + mtx_lock(&Giant); DPRINTF("signal: sigaction failed: %d\n", error); + mtx_unlock(&Giant); td->td_retval[0] = -1; return (error); } @@ -352,8 +362,11 @@ osf1_signal(td, uap) SIGEMPTYSET(sa.sa_mask); sa.sa_flags = 0; error = kern_sigaction(td, signum, &sa, NULL, 0); - if (error != 0) + if (error != 0) { + mtx_lock(&Giant); DPRINTF(("sigignore: sigaction failed\n")); + mtx_unlock(&Giant); + } return (error); } @@ -544,8 +557,11 @@ osf1_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) /* * Set up the registers to return to sigcode. */ - if (osf1_sigdbg) + if (osf1_sigdbg) { + mtx_lock(&Giant); uprintf("attempting to call osf1 sigtramp\n"); + mtx_unlock(&Giant); + } frame->tf_regs[FRAME_PC] = (u_int64_t)td->td_md.osf_sigtramp; frame->tf_regs[FRAME_A0] = sig; frame->tf_regs[FRAME_A1] = code; @@ -627,7 +643,9 @@ osf1_osigstack(td, uap) } */ *uap; { -/* uprintf("osf1_osigstack: oss = %p, nss = %p",uap->oss, uap->nss); - uprintf(" stack ptr = %p\n",p->p_sigacts->ps_sigstk.ss_sp);*/ +/* mtx_lock(&Giant); + uprintf("osf1_osigstack: oss = %p, nss = %p",uap->oss, uap->nss); + uprintf(" stack ptr = %p\n",p->p_sigacts->ps_sigstk.ss_sp); + mtx_unlock(&Giant); */ return(osigstack(td, (struct osigstack_args *)uap)); } |