From c479a90eb8129ad770ff6daba981e9f20af69e6f Mon Sep 17 00:00:00 2001 From: rwatson Date: Mon, 19 Sep 2005 16:51:43 +0000 Subject: 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 --- sys/kern/subr_prf.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sys/kern/subr_prf.c') diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index 9141822..a457ee9 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -129,6 +129,10 @@ uprintf(const char *fmt, ...) struct putchar_arg pca; int retval; + GIANT_REQUIRED; + + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "uprintf"); + if (td == NULL || td == PCPU_GET(idlethread)) return (0); @@ -165,6 +169,10 @@ tprintf(struct proc *p, int pri, const char *fmt, ...) struct putchar_arg pca; struct session *sess = NULL; + GIANT_REQUIRED; + + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "tprintf"); + if (pri != -1) flags |= TOLOG; if (p != NULL) { -- cgit v1.1