summaryrefslogtreecommitdiffstats
path: root/sys/sys/pcpu.h
diff options
context:
space:
mode:
authorjb <jb@FreeBSD.org>2006-11-01 04:54:51 +0000
committerjb <jb@FreeBSD.org>2006-11-01 04:54:51 +0000
commitd2bd8073567b9878a0f047164ede93eea2930207 (patch)
tree4ca8e0db1a4d979ac84b80de999f6b12bfe9e7f3 /sys/sys/pcpu.h
parent978ee47c81472fd20aa0071b93d9fe4c7c9bbd7e (diff)
downloadFreeBSD-src-d2bd8073567b9878a0f047164ede93eea2930207.zip
FreeBSD-src-d2bd8073567b9878a0f047164ede93eea2930207.tar.gz
Add a cnputs() function to write a string to the console with
a lock to prevent interspersed strings written from different CPUs at the same time. To avoid putting a buffer on the stack or having to malloc one, space is incorporated in the per-cpu structure. The buffer size if 128 bytes; chosen because it's the next power of 2 size up from 80 characters. String writes to the console are buffered up the end of the line or until the buffer fills. Then the buffer is flushed to all console devices. Existing low level console output via cnputc() is unaffected by this change. ithread calls to log() are also unaffected to avoid blocking those threads. A minor change to the behaviour in a panic situation is that console output will still be buffered, but won't be written to a tty as before. This should prevent interspersed panic output as a number of CPUs panic before we end up single threaded running ddb. Reviewed by: scottl, jhb MFC after: 2 weeks
Diffstat (limited to 'sys/sys/pcpu.h')
-rw-r--r--sys/sys/pcpu.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h
index 00a3cac..fa54bc4 100644
--- a/sys/sys/pcpu.h
+++ b/sys/sys/pcpu.h
@@ -48,6 +48,9 @@
struct pcb;
struct thread;
+/* Size of the per-cpu console buffer for printf(). */
+#define PCPU_CONS_BUFR 128
+
/*
* This structure maps out the global data that needs to be kept on a
* per-cpu basis. The members are accessed via the PCPU_GET/SET/PTR
@@ -71,6 +74,8 @@ struct pcpu {
int pc_ktr_idx; /* Index into trace table */
char *pc_ktr_buf;
#endif
+ char pc_cons_bufr[PCPU_CONS_BUFR];
+ /* Console buffer */
PCPU_MD_FIELDS;
struct vmmeter pc_cnt; /* VM stats counters */
struct device *pc_device;
OpenPOWER on IntegriCloud