.. | .. |
---|
177 | 177 | void panic(const char *fmt, ...) |
---|
178 | 178 | { |
---|
179 | 179 | static char buf[1024]; |
---|
180 | | - va_list args2; |
---|
181 | 180 | va_list args; |
---|
182 | 181 | long i, i_next = 0, len; |
---|
183 | 182 | int state = 0; |
---|
.. | .. |
---|
192 | 191 | */ |
---|
193 | 192 | local_irq_disable(); |
---|
194 | 193 | preempt_disable_notrace(); |
---|
195 | | - |
---|
196 | | - console_verbose(); |
---|
197 | | - pr_emerg("Kernel panic - not syncing:\n"); |
---|
198 | | - va_start(args2, fmt); |
---|
199 | | - va_copy(args, args2); |
---|
200 | | - vprintk(fmt, args2); |
---|
201 | | - va_end(args2); |
---|
202 | | -#ifdef CONFIG_DEBUG_BUGVERBOSE |
---|
203 | | - /* |
---|
204 | | - * Avoid nested stack-dumping if a panic occurs during oops processing |
---|
205 | | - */ |
---|
206 | | - if (!test_taint(TAINT_DIE) && oops_in_progress <= 1) |
---|
207 | | - dump_stack(); |
---|
208 | | -#endif |
---|
209 | | - pr_flush(1000, true); |
---|
210 | 194 | |
---|
211 | 195 | /* |
---|
212 | 196 | * It's possible to come here directly from a panic-assertion and |
---|
.. | .. |
---|
229 | 213 | if (old_cpu != PANIC_CPU_INVALID && old_cpu != this_cpu) |
---|
230 | 214 | panic_smp_self_stop(); |
---|
231 | 215 | |
---|
| 216 | + console_verbose(); |
---|
232 | 217 | bust_spinlocks(1); |
---|
| 218 | + va_start(args, fmt); |
---|
233 | 219 | len = vscnprintf(buf, sizeof(buf), fmt, args); |
---|
234 | 220 | va_end(args); |
---|
235 | 221 | |
---|
236 | 222 | if (len && buf[len - 1] == '\n') |
---|
237 | 223 | buf[len - 1] = '\0'; |
---|
| 224 | + |
---|
| 225 | + pr_emerg("Kernel panic - not syncing: %s\n", buf); |
---|
| 226 | +#ifdef CONFIG_DEBUG_BUGVERBOSE |
---|
| 227 | + /* |
---|
| 228 | + * Avoid nested stack-dumping if a panic occurs during oops processing |
---|
| 229 | + */ |
---|
| 230 | + if (!test_taint(TAINT_DIE) && oops_in_progress <= 1) |
---|
| 231 | + dump_stack(); |
---|
| 232 | +#endif |
---|
238 | 233 | |
---|
239 | 234 | /* |
---|
240 | 235 | * If kgdb is enabled, give it a chance to run before we stop all |
---|
.. | .. |
---|
252 | 247 | * Bypass the panic_cpu check and call __crash_kexec directly. |
---|
253 | 248 | */ |
---|
254 | 249 | if (!_crash_kexec_post_notifiers) { |
---|
| 250 | + printk_safe_flush_on_panic(); |
---|
255 | 251 | __crash_kexec(NULL); |
---|
256 | 252 | |
---|
257 | 253 | /* |
---|
.. | .. |
---|
275 | 271 | */ |
---|
276 | 272 | atomic_notifier_call_chain(&panic_notifier_list, 0, buf); |
---|
277 | 273 | |
---|
| 274 | + /* Call flush even twice. It tries harder with a single online CPU */ |
---|
| 275 | + printk_safe_flush_on_panic(); |
---|
278 | 276 | kmsg_dump(KMSG_DUMP_PANIC); |
---|
279 | 277 | |
---|
280 | 278 | /* |
---|
.. | .. |
---|
544 | 542 | |
---|
545 | 543 | static int init_oops_id(void) |
---|
546 | 544 | { |
---|
547 | | -#ifndef CONFIG_PREEMPT_RT |
---|
548 | 545 | if (!oops_id) |
---|
549 | 546 | get_random_bytes(&oops_id, sizeof(oops_id)); |
---|
550 | 547 | else |
---|
551 | | -#endif |
---|
552 | 548 | oops_id++; |
---|
553 | 549 | |
---|
554 | 550 | return 0; |
---|
.. | .. |
---|
559 | 555 | { |
---|
560 | 556 | init_oops_id(); |
---|
561 | 557 | pr_warn("---[ end trace %016llx ]---\n", (unsigned long long)oops_id); |
---|
562 | | - pr_flush(1000, true); |
---|
563 | 558 | } |
---|
564 | 559 | |
---|
565 | 560 | /* |
---|