@@ -1157,6 +1157,17 @@ static unsigned int __init add_to_rb(struct printk_ringbuffer *rb,
11571157
11581158static char setup_text_buf [PRINTKRB_RECORD_MAX ] __initdata ;
11591159
1160+ static void print_log_buf_usage_stats (void )
1161+ {
1162+ unsigned int descs_count = log_buf_len >> PRB_AVGBITS ;
1163+ size_t meta_data_size ;
1164+
1165+ meta_data_size = descs_count * (sizeof (struct prb_desc ) + sizeof (struct printk_info ));
1166+
1167+ pr_info ("log buffer data + meta data: %u + %zu = %zu bytes\n" ,
1168+ log_buf_len , meta_data_size , log_buf_len + meta_data_size );
1169+ }
1170+
11601171void __init setup_log_buf (int early )
11611172{
11621173 struct printk_info * new_infos ;
@@ -1186,20 +1197,25 @@ void __init setup_log_buf(int early)
11861197 if (!early && !new_log_buf_len )
11871198 log_buf_add_cpu ();
11881199
1189- if (!new_log_buf_len )
1200+ if (!new_log_buf_len ) {
1201+ /* Show the memory stats only once. */
1202+ if (!early )
1203+ goto out ;
1204+
11901205 return ;
1206+ }
11911207
11921208 new_descs_count = new_log_buf_len >> PRB_AVGBITS ;
11931209 if (new_descs_count == 0 ) {
11941210 pr_err ("new_log_buf_len: %lu too small\n" , new_log_buf_len );
1195- return ;
1211+ goto out ;
11961212 }
11971213
11981214 new_log_buf = memblock_alloc (new_log_buf_len , LOG_ALIGN );
11991215 if (unlikely (!new_log_buf )) {
12001216 pr_err ("log_buf_len: %lu text bytes not available\n" ,
12011217 new_log_buf_len );
1202- return ;
1218+ goto out ;
12031219 }
12041220
12051221 new_descs_size = new_descs_count * sizeof (struct prb_desc );
@@ -1262,7 +1278,7 @@ void __init setup_log_buf(int early)
12621278 prb_next_seq (& printk_rb_static ) - seq );
12631279 }
12641280
1265- pr_info ( "log_buf_len: %u bytes\n" , log_buf_len );
1281+ print_log_buf_usage_stats ( );
12661282 pr_info ("early log buf free: %u(%u%%)\n" ,
12671283 free , (free * 100 ) / __LOG_BUF_LEN );
12681284 return ;
@@ -1271,6 +1287,8 @@ void __init setup_log_buf(int early)
12711287 memblock_free (new_descs , new_descs_size );
12721288err_free_log_buf :
12731289 memblock_free (new_log_buf , new_log_buf_len );
1290+ out :
1291+ print_log_buf_usage_stats ();
12741292}
12751293
12761294static bool __read_mostly ignore_loglevel ;
@@ -1320,11 +1338,11 @@ static void boot_delay_msec(int level)
13201338{
13211339 unsigned long long k ;
13221340 unsigned long timeout ;
1341+ bool suppress = !is_printk_force_console () &&
1342+ suppress_message_printing (level );
13231343
1324- if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING )
1325- || suppress_message_printing (level )) {
1344+ if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING ) || suppress )
13261345 return ;
1327- }
13281346
13291347 k = (unsigned long long )loops_per_msec * boot_delay ;
13301348
@@ -2274,13 +2292,19 @@ int vprintk_store(int facility, int level,
22742292 if (dev_info )
22752293 flags |= LOG_NEWLINE ;
22762294
2295+ if (is_printk_force_console ())
2296+ flags |= LOG_FORCE_CON ;
2297+
22772298 if (flags & LOG_CONT ) {
22782299 prb_rec_init_wr (& r , reserve_size );
22792300 if (prb_reserve_in_last (& e , prb , & r , caller_id , PRINTKRB_RECORD_MAX )) {
22802301 text_len = printk_sprint (& r .text_buf [r .info -> text_len ], reserve_size ,
22812302 facility , & flags , fmt , args );
22822303 r .info -> text_len += text_len ;
22832304
2305+ if (flags & LOG_FORCE_CON )
2306+ r .info -> flags |= LOG_FORCE_CON ;
2307+
22842308 if (flags & LOG_NEWLINE ) {
22852309 r .info -> flags |= LOG_NEWLINE ;
22862310 prb_final_commit (& e );
@@ -2948,6 +2972,7 @@ bool printk_get_next_message(struct printk_message *pmsg, u64 seq,
29482972 struct printk_info info ;
29492973 struct printk_record r ;
29502974 size_t len = 0 ;
2975+ bool force_con ;
29512976
29522977 /*
29532978 * Formatting extended messages requires a separate buffer, so use the
@@ -2966,9 +2991,13 @@ bool printk_get_next_message(struct printk_message *pmsg, u64 seq,
29662991
29672992 pmsg -> seq = r .info -> seq ;
29682993 pmsg -> dropped = r .info -> seq - seq ;
2994+ force_con = r .info -> flags & LOG_FORCE_CON ;
29692995
2970- /* Skip record that has level above the console loglevel. */
2971- if (may_suppress && suppress_message_printing (r .info -> level ))
2996+ /*
2997+ * Skip records that are not forced to be printed on consoles and that
2998+ * has level above the console loglevel.
2999+ */
3000+ if (!force_con && may_suppress && suppress_message_printing (r .info -> level ))
29723001 goto out ;
29733002
29743003 if (is_extended ) {
0 commit comments