@@ -394,6 +394,9 @@ static struct latched_seq clear_seq = {
394
394
/* the maximum size of a formatted record (i.e. with prefix added per line) */
395
395
#define CONSOLE_LOG_MAX 1024
396
396
397
+ /* the maximum size for a dropped text message */
398
+ #define DROPPED_TEXT_MAX 64
399
+
397
400
/* the maximum size allowed to be reserved for a record */
398
401
#define LOG_LINE_MAX (CONSOLE_LOG_MAX - PREFIX_MAX)
399
402
@@ -1923,18 +1926,18 @@ static int console_trylock_spinning(void)
1923
1926
1924
1927
/*
1925
1928
* Call the specified console driver, asking it to write out the specified
1926
- * text and length. For non-extended consoles, if any records have been
1929
+ * text and length. If @dropped_text is non-NULL and any records have been
1927
1930
* dropped, a dropped message will be written out first.
1928
1931
*/
1929
- static void call_console_driver (struct console * con , const char * text , size_t len )
1932
+ static void call_console_driver (struct console * con , const char * text , size_t len ,
1933
+ char * dropped_text )
1930
1934
{
1931
- static char dropped_text [64 ];
1932
1935
size_t dropped_len ;
1933
1936
1934
1937
trace_console_rcuidle (text , len );
1935
1938
1936
- if (con -> dropped && !( con -> flags & CON_EXTENDED ) ) {
1937
- dropped_len = snprintf (dropped_text , sizeof ( dropped_text ) ,
1939
+ if (con -> dropped && dropped_text ) {
1940
+ dropped_len = snprintf (dropped_text , DROPPED_TEXT_MAX ,
1938
1941
"** %lu printk messages dropped **\n" ,
1939
1942
con -> dropped );
1940
1943
con -> dropped = 0 ;
@@ -2296,6 +2299,7 @@ EXPORT_SYMBOL(_printk);
2296
2299
#else /* CONFIG_PRINTK */
2297
2300
2298
2301
#define CONSOLE_LOG_MAX 0
2302
+ #define DROPPED_TEXT_MAX 0
2299
2303
#define printk_time false
2300
2304
2301
2305
#define prb_read_valid (rb , seq , r ) false
@@ -2319,7 +2323,10 @@ static ssize_t msg_print_ext_body(char *buf, size_t size,
2319
2323
struct dev_printk_info * dev_info ) { return 0 ; }
2320
2324
static void console_lock_spinning_enable (void ) { }
2321
2325
static int console_lock_spinning_disable_and_check (void ) { return 0 ; }
2322
- static void call_console_driver (struct console * con , const char * text , size_t len ) { }
2326
+ static void call_console_driver (struct console * con , const char * text , size_t len ,
2327
+ char * dropped_text )
2328
+ {
2329
+ }
2323
2330
static bool suppress_message_printing (int level ) { return false; }
2324
2331
2325
2332
#endif /* CONFIG_PRINTK */
@@ -2644,6 +2651,14 @@ static void __console_unlock(void)
2644
2651
* Print one record for the given console. The record printed is whatever
2645
2652
* record is the next available record for the given console.
2646
2653
*
2654
+ * @text is a buffer of size CONSOLE_LOG_MAX.
2655
+ *
2656
+ * If extended messages should be printed, @ext_text is a buffer of size
2657
+ * CONSOLE_EXT_LOG_MAX. Otherwise @ext_text must be NULL.
2658
+ *
2659
+ * If dropped messages should be printed, @dropped_text is a buffer of size
2660
+ * DROPPED_TEXT_MAX. Otherwise @dropped_text must be NULL.
2661
+ *
2647
2662
* @handover will be set to true if a printk waiter has taken over the
2648
2663
* console_lock, in which case the caller is no longer holding the
2649
2664
* console_lock. Otherwise it is set to false.
@@ -2653,18 +2668,17 @@ static void __console_unlock(void)
2653
2668
*
2654
2669
* Requires the console_lock.
2655
2670
*/
2656
- static bool console_emit_next_record (struct console * con , bool * handover )
2671
+ static bool console_emit_next_record (struct console * con , char * text , char * ext_text ,
2672
+ char * dropped_text , bool * handover )
2657
2673
{
2658
- static char ext_text [CONSOLE_EXT_LOG_MAX ];
2659
- static char text [CONSOLE_LOG_MAX ];
2660
2674
static int panic_console_dropped ;
2661
2675
struct printk_info info ;
2662
2676
struct printk_record r ;
2663
2677
unsigned long flags ;
2664
2678
char * write_text ;
2665
2679
size_t len ;
2666
2680
2667
- prb_rec_init_rd (& r , & info , text , sizeof ( text ) );
2681
+ prb_rec_init_rd (& r , & info , text , CONSOLE_LOG_MAX );
2668
2682
2669
2683
* handover = false;
2670
2684
@@ -2686,13 +2700,13 @@ static bool console_emit_next_record(struct console *con, bool *handover)
2686
2700
goto skip ;
2687
2701
}
2688
2702
2689
- if (con -> flags & CON_EXTENDED ) {
2690
- write_text = & ext_text [ 0 ] ;
2691
- len = info_print_ext_header (ext_text , sizeof ( ext_text ) , r .info );
2692
- len += msg_print_ext_body (ext_text + len , sizeof ( ext_text ) - len ,
2703
+ if (ext_text ) {
2704
+ write_text = ext_text ;
2705
+ len = info_print_ext_header (ext_text , CONSOLE_EXT_LOG_MAX , r .info );
2706
+ len += msg_print_ext_body (ext_text + len , CONSOLE_EXT_LOG_MAX - len ,
2693
2707
& r .text_buf [0 ], r .info -> text_len , & r .info -> dev_info );
2694
2708
} else {
2695
- write_text = & text [ 0 ] ;
2709
+ write_text = text ;
2696
2710
len = record_print_text (& r , console_msg_format & MSG_FORMAT_SYSLOG , printk_time );
2697
2711
}
2698
2712
@@ -2710,7 +2724,7 @@ static bool console_emit_next_record(struct console *con, bool *handover)
2710
2724
console_lock_spinning_enable ();
2711
2725
2712
2726
stop_critical_timings (); /* don't trace print latency */
2713
- call_console_driver (con , write_text , len );
2727
+ call_console_driver (con , write_text , len , dropped_text );
2714
2728
start_critical_timings ();
2715
2729
2716
2730
con -> seq ++ ;
@@ -2746,6 +2760,9 @@ static bool console_emit_next_record(struct console *con, bool *handover)
2746
2760
*/
2747
2761
static bool console_flush_all (bool do_cond_resched , u64 * next_seq , bool * handover )
2748
2762
{
2763
+ static char dropped_text [DROPPED_TEXT_MAX ];
2764
+ static char ext_text [CONSOLE_EXT_LOG_MAX ];
2765
+ static char text [CONSOLE_LOG_MAX ];
2749
2766
bool any_usable = false;
2750
2767
struct console * con ;
2751
2768
bool any_progress ;
@@ -2763,7 +2780,16 @@ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handove
2763
2780
continue ;
2764
2781
any_usable = true;
2765
2782
2766
- progress = console_emit_next_record (con , handover );
2783
+ if (con -> flags & CON_EXTENDED ) {
2784
+ /* Extended consoles do not print "dropped messages". */
2785
+ progress = console_emit_next_record (con , & text [0 ],
2786
+ & ext_text [0 ], NULL ,
2787
+ handover );
2788
+ } else {
2789
+ progress = console_emit_next_record (con , & text [0 ],
2790
+ NULL , & dropped_text [0 ],
2791
+ handover );
2792
+ }
2767
2793
if (* handover )
2768
2794
return false;
2769
2795
0 commit comments