summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_prf.c
diff options
context:
space:
mode:
authorjb <jb@FreeBSD.org>2006-11-30 04:17:05 +0000
committerjb <jb@FreeBSD.org>2006-11-30 04:17:05 +0000
commitda35e3e55f3d5d5ed5bc5018536e8b0a54ddc767 (patch)
tree6035effd6306a4201ed68eedced59e87c3965546 /sys/kern/subr_prf.c
parent5727c5a0587e28c774bfc229e96707fe6fbd96ad (diff)
downloadFreeBSD-src-da35e3e55f3d5d5ed5bc5018536e8b0a54ddc767.zip
FreeBSD-src-da35e3e55f3d5d5ed5bc5018536e8b0a54ddc767.tar.gz
Turn console printf buffering into a kernel option and only on
by default for sun4v where it is absolutely required. This change moves the buffer from struct pcpu to the stack to avoid using the critical section which created a LOR in a couple of cases due to interaction with the tty code and kqueue. The LOR can't be fixed with the critical section and the pcpu buffer can't be used without the critical section. Putting the buffer on the stack was my initial solution, but it was pointed out that the stress on the stack might cause problems depending on the call path. We don't have a way of creating tests for those possible cases, so it's best to leave this as an option for the time being. In time we may get enough data to enable this option more generally.
Diffstat (limited to 'sys/kern/subr_prf.c')
-rw-r--r--sys/kern/subr_prf.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index c53bf98..d7c87a9 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -38,6 +38,7 @@
__FBSDID("$FreeBSD$");
#include "opt_ddb.h"
+#include "opt_printf.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -291,18 +292,24 @@ printf(const char *fmt, ...)
va_list ap;
struct putchar_arg pca;
int retval;
-
- critical_enter();
+#ifdef PRINTF_BUFR_SIZE
+ char bufr[PRINTF_BUFR_SIZE];
+#endif
va_start(ap, fmt);
pca.tty = NULL;
pca.flags = TOCONS | TOLOG;
pca.pri = -1;
- pca.p_bufr = (char *) PCPU_PTR(cons_bufr);
+#ifdef PRINTF_BUFR_SIZE
+ pca.p_bufr = bufr;
pca.p_next = pca.p_bufr;
- pca.n_bufr = PCPU_CONS_BUFR;
- pca.remain = PCPU_CONS_BUFR;
+ pca.n_bufr = sizeof(bufr);
+ pca.remain = sizeof(bufr);
*pca.p_next = '\0';
+#else
+ /* Don't buffer console output. */
+ pca.p_bufr = NULL;
+#endif
retval = kvprintf(fmt, putchar, &pca, 10, ap);
va_end(ap);
@@ -314,8 +321,6 @@ printf(const char *fmt, ...)
if (!panicstr)
msgbuftrigger = 1;
- critical_exit();
-
return (retval);
}
@@ -324,17 +329,23 @@ vprintf(const char *fmt, va_list ap)
{
struct putchar_arg pca;
int retval;
-
- critical_enter();
+#ifdef PRINTF_BUFR_SIZE
+ char bufr[PRINTF_BUFR_SIZE];
+#endif
pca.tty = NULL;
pca.flags = TOCONS | TOLOG;
pca.pri = -1;
- pca.p_bufr = (char *) PCPU_PTR(cons_bufr);
+#ifdef PRINTF_BUFR_SIZE
+ pca.p_bufr = bufr;
pca.p_next = pca.p_bufr;
- pca.n_bufr = PCPU_CONS_BUFR;
- pca.remain = PCPU_CONS_BUFR;
+ pca.n_bufr = sizeof(bufr);
+ pca.remain = sizeof(bufr);
*pca.p_next = '\0';
+#else
+ /* Don't buffer console output. */
+ pca.p_bufr = NULL;
+#endif
retval = kvprintf(fmt, putchar, &pca, 10, ap);
@@ -345,8 +356,6 @@ vprintf(const char *fmt, va_list ap)
if (!panicstr)
msgbuftrigger = 1;
- critical_exit();
-
return (retval);
}
OpenPOWER on IntegriCloud