2 * linux/kernel/printk.c
4 * Copyright (C) 1991, 1992 Linus Torvalds
6 * Modified to make sys_syslog() more flexible: added commands to
7 * return the last 4k of kernel messages, regardless of whether
8 * they've been read or not. Added option to suppress kernel printk's
9 * to the console. Added hook for sending the console messages
10 * elsewhere, in preparation for a serial line console (someday).
12 * Modified for sysctl support, 1/8/97, Chris Horn.
13 * Fixed SMP synchronization, 08/08/99, Manfred Spraul
14 * manfreds@colorfullife.com
15 * Rewrote bits to get rid of console_lock
16 * 01Mar01 Andrew Morton <andrewm@uow.edu.au>
19 #include <linux/kernel.h>
21 #include <linux/tty.h>
22 #include <linux/tty_driver.h>
23 #include <linux/smp_lock.h>
24 #include <linux/console.h>
25 #include <linux/init.h>
26 #include <linux/module.h>
27 #include <linux/interrupt.h> /* For in_interrupt() */
28 #include <linux/config.h>
29 #include <linux/delay.h>
30 #include <linux/smp.h>
31 #include <linux/security.h>
32 #include <linux/bootmem.h>
33 #include <linux/syscalls.h>
35 #include <asm/uaccess.h>
37 #define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
39 /* printk's without a loglevel use this.. */
40 #define DEFAULT_MESSAGE_LOGLEVEL 4 /* KERN_WARNING */
42 /* We show everything that is MORE important than this.. */
43 #define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
44 #define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */
46 DECLARE_WAIT_QUEUE_HEAD(log_wait
);
48 int console_printk
[4] = {
49 DEFAULT_CONSOLE_LOGLEVEL
, /* console_loglevel */
50 DEFAULT_MESSAGE_LOGLEVEL
, /* default_message_loglevel */
51 MINIMUM_CONSOLE_LOGLEVEL
, /* minimum_console_loglevel */
52 DEFAULT_CONSOLE_LOGLEVEL
, /* default_console_loglevel */
55 EXPORT_SYMBOL(console_printk
);
58 * Low lever drivers may need that to know if they can schedule in
59 * their unblank() callback or not. So let's export it.
62 EXPORT_SYMBOL(oops_in_progress
);
65 * console_sem protects the console_drivers list, and also
66 * provides serialisation for access to the entire console
69 static DECLARE_MUTEX(console_sem
);
70 struct console
*console_drivers
;
72 * This is used for debugging the mess that is the VT code by
73 * keeping track if we have the console semaphore held. It's
74 * definitely not the perfect debug tool (we don't know if _WE_
75 * hold it are racing, but it helps tracking those weird code
76 * path in the console code where we end up in places I want
77 * locked without the console sempahore held
79 static int console_locked
;
82 * logbuf_lock protects log_buf, log_start, log_end, con_start and logged_chars
83 * It is also used in interesting ways to provide interlocking in
84 * release_console_sem().
86 static DEFINE_SPINLOCK(logbuf_lock
);
88 static char __log_buf
[__LOG_BUF_LEN
];
89 static char *log_buf
= __log_buf
;
90 static int log_buf_len
= __LOG_BUF_LEN
;
92 #define LOG_BUF_MASK (log_buf_len-1)
93 #define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK])
96 * The indices into log_buf are not constrained to log_buf_len - they
97 * must be masked before subscripting
99 static unsigned long log_start
; /* Index into log_buf: next char to be read by syslog() */
100 static unsigned long con_start
; /* Index into log_buf: next char to be sent to consoles */
101 static unsigned long log_end
; /* Index into log_buf: most-recently-written-char + 1 */
102 static unsigned long logged_chars
; /* Number of chars produced since last read+clear operation */
105 * Array of consoles built from command line options (console=)
107 struct console_cmdline
109 char name
[8]; /* Name of the driver */
110 int index
; /* Minor dev. to use */
111 char *options
; /* Options for the driver */
114 #define MAX_CMDLINECONSOLES 8
116 static struct console_cmdline console_cmdline
[MAX_CMDLINECONSOLES
];
117 static int selected_console
= -1;
118 static int preferred_console
= -1;
120 /* Flag: console code may call schedule() */
121 static int console_may_schedule
;
124 * Setup a list of consoles. Called from init/main.c
126 static int __init
console_setup(char *str
)
128 char name
[sizeof(console_cmdline
[0].name
)];
133 * Decode str into name, index, options.
135 if (str
[0] >= '0' && str
[0] <= '9') {
136 strcpy(name
, "ttyS");
137 strncpy(name
+ 4, str
, sizeof(name
) - 5);
139 strncpy(name
, str
, sizeof(name
) - 1);
140 name
[sizeof(name
) - 1] = 0;
141 if ((options
= strchr(str
, ',')) != NULL
)
144 if (!strcmp(str
, "ttya"))
145 strcpy(name
, "ttyS0");
146 if (!strcmp(str
, "ttyb"))
147 strcpy(name
, "ttyS1");
149 for(s
= name
; *s
; s
++)
150 if ((*s
>= '0' && *s
<= '9') || *s
== ',')
152 idx
= simple_strtoul(s
, NULL
, 10);
155 add_preferred_console(name
, idx
, options
);
159 __setup("console=", console_setup
);
162 * add_preferred_console - add a device to the list of preferred consoles.
164 * The last preferred console added will be used for kernel messages
165 * and stdin/out/err for init. Normally this is used by console_setup
166 * above to handle user-supplied console arguments; however it can also
167 * be used by arch-specific code either to override the user or more
168 * commonly to provide a default console (ie from PROM variables) when
169 * the user has not supplied one.
171 int __init
add_preferred_console(char *name
, int idx
, char *options
)
173 struct console_cmdline
*c
;
177 * See if this tty is not yet registered, and
178 * if we have a slot free.
180 for(i
= 0; i
< MAX_CMDLINECONSOLES
&& console_cmdline
[i
].name
[0]; i
++)
181 if (strcmp(console_cmdline
[i
].name
, name
) == 0 &&
182 console_cmdline
[i
].index
== idx
) {
183 selected_console
= i
;
186 if (i
== MAX_CMDLINECONSOLES
)
188 selected_console
= i
;
189 c
= &console_cmdline
[i
];
190 memcpy(c
->name
, name
, sizeof(c
->name
));
191 c
->name
[sizeof(c
->name
) - 1] = 0;
192 c
->options
= options
;
197 static int __init
log_buf_len_setup(char *str
)
199 unsigned long size
= memparse(str
, &str
);
203 size
= roundup_pow_of_two(size
);
204 if (size
> log_buf_len
) {
205 unsigned long start
, dest_idx
, offset
;
208 new_log_buf
= alloc_bootmem(size
);
210 printk("log_buf_len: allocation failed\n");
214 spin_lock_irqsave(&logbuf_lock
, flags
);
216 log_buf
= new_log_buf
;
218 offset
= start
= min(con_start
, log_start
);
220 while (start
!= log_end
) {
221 log_buf
[dest_idx
] = __log_buf
[start
& (__LOG_BUF_LEN
- 1)];
228 spin_unlock_irqrestore(&logbuf_lock
, flags
);
230 printk("log_buf_len: %d\n", log_buf_len
);
237 __setup("log_buf_len=", log_buf_len_setup
);
240 * Commands to do_syslog:
242 * 0 -- Close the log. Currently a NOP.
243 * 1 -- Open the log. Currently a NOP.
244 * 2 -- Read from the log.
245 * 3 -- Read all messages remaining in the ring buffer.
246 * 4 -- Read and clear all messages remaining in the ring buffer
247 * 5 -- Clear ring buffer.
248 * 6 -- Disable printk's to console
249 * 7 -- Enable printk's to console
250 * 8 -- Set level of messages printed to console
251 * 9 -- Return number of unread characters in the log buffer
252 * 10 -- Return size of the log buffer
254 int do_syslog(int type
, char __user
* buf
, int len
)
256 unsigned long i
, j
, limit
, count
;
261 error
= security_syslog(type
);
266 case 0: /* Close log */
268 case 1: /* Open log */
270 case 2: /* Read from log */
277 if (!access_ok(VERIFY_WRITE
, buf
, len
)) {
281 error
= wait_event_interruptible(log_wait
, (log_start
- log_end
));
285 spin_lock_irq(&logbuf_lock
);
286 while (!error
&& (log_start
!= log_end
) && i
< len
) {
287 c
= LOG_BUF(log_start
);
289 spin_unlock_irq(&logbuf_lock
);
290 error
= __put_user(c
,buf
);
294 spin_lock_irq(&logbuf_lock
);
296 spin_unlock_irq(&logbuf_lock
);
300 case 4: /* Read/clear last kernel messages */
303 case 3: /* Read last kernel messages */
310 if (!access_ok(VERIFY_WRITE
, buf
, len
)) {
315 if (count
> log_buf_len
)
317 spin_lock_irq(&logbuf_lock
);
318 if (count
> logged_chars
)
319 count
= logged_chars
;
324 * __put_user() could sleep, and while we sleep
325 * printk() could overwrite the messages
326 * we try to copy to user space. Therefore
327 * the messages are copied in reverse. <manfreds>
329 for(i
= 0; i
< count
&& !error
; i
++) {
331 if (j
+ log_buf_len
< log_end
)
334 spin_unlock_irq(&logbuf_lock
);
335 error
= __put_user(c
,&buf
[count
-1-i
]);
337 spin_lock_irq(&logbuf_lock
);
339 spin_unlock_irq(&logbuf_lock
);
344 int offset
= count
-error
;
345 /* buffer overflow during copy, correct user buffer. */
346 for(i
=0;i
<error
;i
++) {
347 if (__get_user(c
,&buf
[i
+offset
]) ||
348 __put_user(c
,&buf
[i
])) {
356 case 5: /* Clear ring buffer */
359 case 6: /* Disable logging to console */
360 console_loglevel
= minimum_console_loglevel
;
362 case 7: /* Enable logging to console */
363 console_loglevel
= default_console_loglevel
;
365 case 8: /* Set level of messages printed to console */
367 if (len
< 1 || len
> 8)
369 if (len
< minimum_console_loglevel
)
370 len
= minimum_console_loglevel
;
371 console_loglevel
= len
;
374 case 9: /* Number of chars in the log buffer */
375 error
= log_end
- log_start
;
377 case 10: /* Size of the log buffer */
388 asmlinkage
long sys_syslog(int type
, char __user
* buf
, int len
)
390 return do_syslog(type
, buf
, len
);
394 * Call the console drivers on a range of log_buf
396 static void __call_console_drivers(unsigned long start
, unsigned long end
)
400 for (con
= console_drivers
; con
; con
= con
->next
) {
401 if ((con
->flags
& CON_ENABLED
) && con
->write
)
402 con
->write(con
, &LOG_BUF(start
), end
- start
);
407 * Write out chars from start to end - 1 inclusive
409 static void _call_console_drivers(unsigned long start
,
410 unsigned long end
, int msg_log_level
)
412 if (msg_log_level
< console_loglevel
&&
413 console_drivers
&& start
!= end
) {
414 if ((start
& LOG_BUF_MASK
) > (end
& LOG_BUF_MASK
)) {
416 __call_console_drivers(start
& LOG_BUF_MASK
,
418 __call_console_drivers(0, end
& LOG_BUF_MASK
);
420 __call_console_drivers(start
, end
);
426 * Call the console drivers, asking them to write out
427 * log_buf[start] to log_buf[end - 1].
428 * The console_sem must be held.
430 static void call_console_drivers(unsigned long start
, unsigned long end
)
432 unsigned long cur_index
, start_print
;
433 static int msg_level
= -1;
435 if (((long)(start
- end
)) > 0)
440 while (cur_index
!= end
) {
441 if ( msg_level
< 0 &&
442 ((end
- cur_index
) > 2) &&
443 LOG_BUF(cur_index
+ 0) == '<' &&
444 LOG_BUF(cur_index
+ 1) >= '0' &&
445 LOG_BUF(cur_index
+ 1) <= '7' &&
446 LOG_BUF(cur_index
+ 2) == '>')
448 msg_level
= LOG_BUF(cur_index
+ 1) - '0';
450 start_print
= cur_index
;
452 while (cur_index
!= end
) {
453 char c
= LOG_BUF(cur_index
);
459 * printk() has already given us loglevel tags in
460 * the buffer. This code is here in case the
461 * log buffer has wrapped right round and scribbled
464 msg_level
= default_message_loglevel
;
466 _call_console_drivers(start_print
, cur_index
, msg_level
);
468 start_print
= cur_index
;
473 _call_console_drivers(start_print
, end
, msg_level
);
476 static void emit_log_char(char c
)
478 LOG_BUF(log_end
) = c
;
480 if (log_end
- log_start
> log_buf_len
)
481 log_start
= log_end
- log_buf_len
;
482 if (log_end
- con_start
> log_buf_len
)
483 con_start
= log_end
- log_buf_len
;
484 if (logged_chars
< log_buf_len
)
489 * Zap console related locks when oopsing. Only zap at most once
490 * every 10 seconds, to leave time for slow consoles to print a
493 static void zap_locks(void)
495 static unsigned long oops_timestamp
;
497 if (time_after_eq(jiffies
, oops_timestamp
) &&
498 !time_after(jiffies
, oops_timestamp
+ 30*HZ
))
501 oops_timestamp
= jiffies
;
503 /* If a crash is occurring, make sure we can't deadlock */
504 spin_lock_init(&logbuf_lock
);
505 /* And make sure that we print immediately */
506 init_MUTEX(&console_sem
);
509 #if defined(CONFIG_PRINTK_TIME)
510 static int printk_time
= 1;
512 static int printk_time
= 0;
515 static int __init
printk_time_setup(char *str
)
523 __setup("time", printk_time_setup
);
526 * This is printk. It can be called from any context. We want it to work.
528 * We try to grab the console_sem. If we succeed, it's easy - we log the output and
529 * call the console drivers. If we fail to get the semaphore we place the output
530 * into the log buffer and return. The current holder of the console_sem will
531 * notice the new output in release_console_sem() and will send it to the
532 * consoles before releasing the semaphore.
534 * One effect of this deferred printing is that code which calls printk() and
535 * then changes console_loglevel may break. This is because console_loglevel
536 * is inspected when the actual printing occurs.
538 asmlinkage
int printk(const char *fmt
, ...)
544 r
= vprintk(fmt
, args
);
550 asmlinkage
int vprintk(const char *fmt
, va_list args
)
555 static char printk_buf
[1024];
556 static int log_level_unknown
= 1;
558 if (unlikely(oops_in_progress
))
561 /* This stops the holder of console_sem just where we want him */
562 spin_lock_irqsave(&logbuf_lock
, flags
);
564 /* Emit the output into the temporary buffer */
565 printed_len
= vscnprintf(printk_buf
, sizeof(printk_buf
), fmt
, args
);
568 * Copy the output into log_buf. If the caller didn't provide
569 * appropriate log level tags, we insert them here
571 for (p
= printk_buf
; *p
; p
++) {
572 if (log_level_unknown
) {
573 /* log_level_unknown signals the start of a new line */
578 unsigned long long t
;
579 unsigned long nanosec_rem
;
582 * force the log level token to be
583 * before the time output.
585 if (p
[0] == '<' && p
[1] >='0' &&
586 p
[1] <= '7' && p
[2] == '>') {
591 loglev_char
= default_message_loglevel
595 nanosec_rem
= do_div(t
, 1000000000);
602 for (tp
= tbuf
; tp
< tbuf
+ tlen
; tp
++)
604 printed_len
+= tlen
- 3;
606 if (p
[0] != '<' || p
[1] < '0' ||
607 p
[1] > '7' || p
[2] != '>') {
609 emit_log_char(default_message_loglevel
615 log_level_unknown
= 0;
621 log_level_unknown
= 1;
624 if (!cpu_online(smp_processor_id()) &&
625 system_state
!= SYSTEM_RUNNING
) {
627 * Some console drivers may assume that per-cpu resources have
628 * been allocated. So don't allow them to be called by this
629 * CPU until it is officially up. We shouldn't be calling into
630 * random console drivers on a CPU which doesn't exist yet..
632 spin_unlock_irqrestore(&logbuf_lock
, flags
);
635 if (!down_trylock(&console_sem
)) {
638 * We own the drivers. We can drop the spinlock and let
639 * release_console_sem() print the text
641 spin_unlock_irqrestore(&logbuf_lock
, flags
);
642 console_may_schedule
= 0;
643 release_console_sem();
646 * Someone else owns the drivers. We drop the spinlock, which
647 * allows the semaphore holder to proceed and to call the
648 * console drivers with the output which we just produced.
650 spin_unlock_irqrestore(&logbuf_lock
, flags
);
655 EXPORT_SYMBOL(printk
);
656 EXPORT_SYMBOL(vprintk
);
659 * acquire_console_sem - lock the console system for exclusive use.
661 * Acquires a semaphore which guarantees that the caller has
662 * exclusive access to the console system and the console_drivers list.
664 * Can sleep, returns nothing.
666 void acquire_console_sem(void)
672 console_may_schedule
= 1;
674 EXPORT_SYMBOL(acquire_console_sem
);
676 int try_acquire_console_sem(void)
678 if (down_trylock(&console_sem
))
681 console_may_schedule
= 0;
684 EXPORT_SYMBOL(try_acquire_console_sem
);
686 int is_console_locked(void)
688 return console_locked
;
690 EXPORT_SYMBOL(is_console_locked
);
693 * release_console_sem - unlock the console system
695 * Releases the semaphore which the caller holds on the console system
696 * and the console driver list.
698 * While the semaphore was held, console output may have been buffered
699 * by printk(). If this is the case, release_console_sem() emits
700 * the output prior to releasing the semaphore.
702 * If there is output waiting for klogd, we wake it up.
704 * release_console_sem() may be called from any context.
706 void release_console_sem(void)
709 unsigned long _con_start
, _log_end
;
710 unsigned long wake_klogd
= 0;
713 spin_lock_irqsave(&logbuf_lock
, flags
);
714 wake_klogd
|= log_start
- log_end
;
715 if (con_start
== log_end
)
716 break; /* Nothing to print */
717 _con_start
= con_start
;
719 con_start
= log_end
; /* Flush */
720 spin_unlock(&logbuf_lock
);
721 call_console_drivers(_con_start
, _log_end
);
722 local_irq_restore(flags
);
725 console_may_schedule
= 0;
727 spin_unlock_irqrestore(&logbuf_lock
, flags
);
728 if (wake_klogd
&& !oops_in_progress
&& waitqueue_active(&log_wait
))
729 wake_up_interruptible(&log_wait
);
731 EXPORT_SYMBOL(release_console_sem
);
733 /** console_conditional_schedule - yield the CPU if required
735 * If the console code is currently allowed to sleep, and
736 * if this CPU should yield the CPU to another task, do
739 * Must be called within acquire_console_sem().
741 void __sched
console_conditional_schedule(void)
743 if (console_may_schedule
)
746 EXPORT_SYMBOL(console_conditional_schedule
);
748 void console_print(const char *s
)
750 printk(KERN_EMERG
"%s", s
);
752 EXPORT_SYMBOL(console_print
);
754 void console_unblank(void)
759 * console_unblank can no longer be called in interrupt context unless
760 * oops_in_progress is set to 1..
762 if (oops_in_progress
) {
763 if (down_trylock(&console_sem
) != 0)
766 acquire_console_sem();
769 console_may_schedule
= 0;
770 for (c
= console_drivers
; c
!= NULL
; c
= c
->next
)
771 if ((c
->flags
& CON_ENABLED
) && c
->unblank
)
773 release_console_sem();
775 EXPORT_SYMBOL(console_unblank
);
778 * Return the console tty driver structure and its associated index
780 struct tty_driver
*console_device(int *index
)
783 struct tty_driver
*driver
= NULL
;
785 acquire_console_sem();
786 for (c
= console_drivers
; c
!= NULL
; c
= c
->next
) {
789 driver
= c
->device(c
, index
);
793 release_console_sem();
798 * Prevent further output on the passed console device so that (for example)
799 * serial drivers can disable console output before suspending a port, and can
800 * re-enable output afterwards.
802 void console_stop(struct console
*console
)
804 acquire_console_sem();
805 console
->flags
&= ~CON_ENABLED
;
806 release_console_sem();
808 EXPORT_SYMBOL(console_stop
);
810 void console_start(struct console
*console
)
812 acquire_console_sem();
813 console
->flags
|= CON_ENABLED
;
814 release_console_sem();
816 EXPORT_SYMBOL(console_start
);
819 * The console driver calls this routine during kernel initialization
820 * to register the console printing procedure with printk() and to
821 * print any messages that were printed by the kernel before the
822 * console driver was initialized.
824 void register_console(struct console
* console
)
829 if (preferred_console
< 0)
830 preferred_console
= selected_console
;
833 * See if we want to use this console driver. If we
834 * didn't select a console we take the first one
835 * that registers here.
837 if (preferred_console
< 0) {
838 if (console
->index
< 0)
840 if (console
->setup
== NULL
||
841 console
->setup(console
, NULL
) == 0) {
842 console
->flags
|= CON_ENABLED
| CON_CONSDEV
;
843 preferred_console
= 0;
848 * See if this console matches one we selected on
851 for(i
= 0; i
< MAX_CMDLINECONSOLES
&& console_cmdline
[i
].name
[0]; i
++) {
852 if (strcmp(console_cmdline
[i
].name
, console
->name
) != 0)
854 if (console
->index
>= 0 &&
855 console
->index
!= console_cmdline
[i
].index
)
857 if (console
->index
< 0)
858 console
->index
= console_cmdline
[i
].index
;
859 if (console
->setup
&&
860 console
->setup(console
, console_cmdline
[i
].options
) != 0)
862 console
->flags
|= CON_ENABLED
;
863 console
->index
= console_cmdline
[i
].index
;
864 if (i
== preferred_console
)
865 console
->flags
|= CON_CONSDEV
;
869 if (!(console
->flags
& CON_ENABLED
))
872 if (console_drivers
&& (console_drivers
->flags
& CON_BOOT
)) {
873 unregister_console(console_drivers
);
874 console
->flags
&= ~CON_PRINTBUFFER
;
878 * Put this console in the list - keep the
879 * preferred driver at the head of the list.
881 acquire_console_sem();
882 if ((console
->flags
& CON_CONSDEV
) || console_drivers
== NULL
) {
883 console
->next
= console_drivers
;
884 console_drivers
= console
;
886 console
->next
= console_drivers
->next
;
887 console_drivers
->next
= console
;
889 if (console
->flags
& CON_PRINTBUFFER
) {
891 * release_console_sem() will print out the buffered messages
894 spin_lock_irqsave(&logbuf_lock
, flags
);
895 con_start
= log_start
;
896 spin_unlock_irqrestore(&logbuf_lock
, flags
);
898 release_console_sem();
900 EXPORT_SYMBOL(register_console
);
902 int unregister_console(struct console
* console
)
904 struct console
*a
,*b
;
907 acquire_console_sem();
908 if (console_drivers
== console
) {
909 console_drivers
=console
->next
;
912 for (a
=console_drivers
->next
, b
=console_drivers
;
922 /* If last console is removed, we re-enable picking the first
923 * one that gets registered. Without that, pmac early boot console
924 * would prevent fbcon from taking over.
926 if (console_drivers
== NULL
)
927 preferred_console
= selected_console
;
930 release_console_sem();
933 EXPORT_SYMBOL(unregister_console
);
936 * tty_write_message - write a message to a certain tty, not just the console.
938 * This is used for messages that need to be redirected to a specific tty.
939 * We don't put it into the syslog queue right now maybe in the future if
942 void tty_write_message(struct tty_struct
*tty
, char *msg
)
944 if (tty
&& tty
->driver
->write
)
945 tty
->driver
->write(tty
, msg
, strlen(msg
));
950 * printk rate limiting, lifted from the networking subsystem.
952 * This enforces a rate limit: not more than one kernel message
953 * every printk_ratelimit_jiffies to make a denial-of-service
956 int __printk_ratelimit(int ratelimit_jiffies
, int ratelimit_burst
)
958 static DEFINE_SPINLOCK(ratelimit_lock
);
959 static unsigned long toks
= 10*5*HZ
;
960 static unsigned long last_msg
;
963 unsigned long now
= jiffies
;
965 spin_lock_irqsave(&ratelimit_lock
, flags
);
966 toks
+= now
- last_msg
;
968 if (toks
> (ratelimit_burst
* ratelimit_jiffies
))
969 toks
= ratelimit_burst
* ratelimit_jiffies
;
970 if (toks
>= ratelimit_jiffies
) {
973 toks
-= ratelimit_jiffies
;
974 spin_unlock_irqrestore(&ratelimit_lock
, flags
);
976 printk(KERN_WARNING
"printk: %d messages suppressed.\n", lost
);
980 spin_unlock_irqrestore(&ratelimit_lock
, flags
);
983 EXPORT_SYMBOL(__printk_ratelimit
);
985 /* minimum time in jiffies between messages */
986 int printk_ratelimit_jiffies
= 5*HZ
;
988 /* number of messages we send before ratelimiting */
989 int printk_ratelimit_burst
= 10;
991 int printk_ratelimit(void)
993 return __printk_ratelimit(printk_ratelimit_jiffies
,
994 printk_ratelimit_burst
);
996 EXPORT_SYMBOL(printk_ratelimit
);