Lines Matching +full:no +full:- +full:dump +full:- +full:oops
1 // SPDX-License-Identifier: GPL-2.0-only
86 * console_mutex protects console_list updates and console->flags updates.
93 * console_sem protects updates to console->seq
149 return -EINVAL; in __control_devkmsg()
169 return -EINVAL; in __control_devkmsg()
211 return -EINVAL; in devkmsg_sysctl_set_loglvl()
234 return -EINVAL; in devkmsg_sysctl_set_loglvl()
243 * console_list_lock - Lock the console list
245 * For console list or console->flags updates
255 * Detecting if this context is really in the read-side critical in console_list_lock()
267 * console_list_unlock - Unlock the console list
278 * console_srcu_read_lock - Register a new reader for the
279 * SRCU-protected console list
294 * console_srcu_read_unlock - Unregister an old reader from
295 * the SRCU-protected console list
323 * because spindump/WARN/etc from under console ->lock will in __down_trylock_console_sem()
324 * deadlock in printk()->down_trylock_console_sem() otherwise. in __down_trylock_console_sem()
367 static int preferred_console = -1;
384 * own meta-data (@info).
386 * Every record meta-data carries the timestamp in microseconds, as well as
388 * messages use LOG_KERN; userspace-injected messages always carry a matching
397 * pairs), to provide userspace with a machine-readable message context.
399 * Examples for well-defined, commonly used property names are:
405 * SUBSYSTEM=pci driver-core subsystem name
407 * Valid characters in property names are [a-zA-Z0-9.-_]. Property names
423 * userspace, it is a kernel-private implementation detail that might
434 * non-prinatable characters are escaped in the "\xff" notation.
514 _DEFINE_PRINTKRB(printk_rb_static, CONFIG_LOG_BUF_SHIFT - PRB_AVGBITS,
522 * We cannot access per-CPU data (e.g. per-CPU flush irq_work) before
524 * it's safe to access per-CPU data.
536 write_seqcount_latch_begin(&ls->latch); in latched_seq_write()
537 ls->val[0] = val; in latched_seq_write()
538 write_seqcount_latch(&ls->latch); in latched_seq_write()
539 ls->val[1] = val; in latched_seq_write()
540 write_seqcount_latch_end(&ls->latch); in latched_seq_write()
551 seq = read_seqcount_latch(&ls->latch); in latched_seq_read_nolock()
553 val = ls->val[idx]; in latched_seq_read_nolock()
554 } while (read_seqcount_latch_retry(&ls->latch, seq)); in latched_seq_read_nolock()
593 *text_len -= *trunc_msg_len; in truncate_msg()
624 return -EPERM; in check_syslog_permissions()
639 u64 ts_usec = info->ts_nsec; in info_print_ext_header()
642 u32 id = info->caller_id; in info_print_ext_header()
653 (info->facility << 3) | info->level, info->seq, in info_print_ext_header()
654 ts_usec, info->flags & LOG_CONT ? 'c' : '-', caller); in info_print_ext_header()
664 /* escape non-printable characters */ in msg_add_ext_text()
669 p += scnprintf(p, e - p, "\\x%02x", c); in msg_add_ext_text()
675 return p - buf; in msg_add_ext_text()
688 len += msg_add_ext_text(buf + len, size - len, key, strlen(key), '='); in msg_add_dict_text()
689 len += msg_add_ext_text(buf + len, size - len, val, val_len, '\n'); in msg_add_dict_text()
705 len += msg_add_dict_text(buf + len, size - len, "SUBSYSTEM", in msg_print_ext_body()
706 dev_info->subsystem); in msg_print_ext_body()
707 len += msg_add_dict_text(buf + len, size - len, "DEVICE", in msg_print_ext_body()
708 dev_info->device); in msg_print_ext_body()
713 /* /dev/kmsg - userspace message inject/listen interface */
739 struct file *file = iocb->ki_filp; in devkmsg_write()
740 struct devkmsg_user *user = file->private_data; in devkmsg_write()
745 return -EINVAL; in devkmsg_write()
753 if (!___ratelimit(&user->rs, current->comm)) in devkmsg_write()
759 return -ENOMEM; in devkmsg_write()
764 return -EFAULT; in devkmsg_write()
768 * Extract and skip the syslog prefix <[0-9]*>. Coming from userspace in devkmsg_write()
772 * If no prefix or no userspace facility is specified, we in devkmsg_write()
774 * kernel-generated messages from userspace-injected ones. in devkmsg_write()
799 struct devkmsg_user *user = file->private_data; in devkmsg_read()
800 char *outbuf = &user->pbufs.outbuf[0]; in devkmsg_read()
802 .pbufs = &user->pbufs, in devkmsg_read()
806 ret = mutex_lock_interruptible(&user->lock); in devkmsg_read()
810 if (!printk_get_next_message(&pmsg, atomic64_read(&user->seq), true, false)) { in devkmsg_read()
811 if (file->f_flags & O_NONBLOCK) { in devkmsg_read()
812 ret = -EAGAIN; in devkmsg_read()
827 printk_get_next_message(&pmsg, atomic64_read(&user->seq), true, in devkmsg_read()
835 atomic64_set(&user->seq, pmsg.seq); in devkmsg_read()
836 ret = -EPIPE; in devkmsg_read()
840 atomic64_set(&user->seq, pmsg.seq + 1); in devkmsg_read()
843 ret = -EINVAL; in devkmsg_read()
848 ret = -EFAULT; in devkmsg_read()
853 mutex_unlock(&user->lock); in devkmsg_read()
861 * entire variable length messages (records). Non-standard values are
867 struct devkmsg_user *user = file->private_data; in devkmsg_llseek()
871 return -ESPIPE; in devkmsg_llseek()
876 atomic64_set(&user->seq, prb_first_valid_seq(prb)); in devkmsg_llseek()
881 * like issued by 'dmesg -c'. Reading /dev/kmsg itself in devkmsg_llseek()
882 * changes no global state, and does not clear anything. in devkmsg_llseek()
884 atomic64_set(&user->seq, latched_seq_read_nolock(&clear_seq)); in devkmsg_llseek()
888 atomic64_set(&user->seq, prb_next_seq(prb)); in devkmsg_llseek()
891 ret = -EINVAL; in devkmsg_llseek()
898 struct devkmsg_user *user = file->private_data; in devkmsg_poll()
904 if (prb_read_valid_info(prb, atomic64_read(&user->seq), &info, NULL)) { in devkmsg_poll()
906 if (info.seq != atomic64_read(&user->seq)) in devkmsg_poll()
921 return -EPERM; in devkmsg_open()
923 /* write-only does not need any file context */ in devkmsg_open()
924 if ((file->f_flags & O_ACCMODE) != O_WRONLY) { in devkmsg_open()
933 return -ENOMEM; in devkmsg_open()
935 ratelimit_default_init(&user->rs); in devkmsg_open()
936 ratelimit_set_flags(&user->rs, RATELIMIT_MSG_ON_RELEASE); in devkmsg_open()
938 mutex_init(&user->lock); in devkmsg_open()
940 atomic64_set(&user->seq, prb_first_valid_seq(prb)); in devkmsg_open()
942 file->private_data = user; in devkmsg_open()
948 struct devkmsg_user *user = file->private_data; in devkmsg_release()
950 ratelimit_state_exit(&user->rs); in devkmsg_release()
952 mutex_destroy(&user->lock); in devkmsg_release()
1017 VMCOREINFO_LENGTH(printk_info_subsystem, sizeof(dev_info->subsystem)); in log_buf_vmcoreinfo_setup()
1019 VMCOREINFO_LENGTH(printk_info_device, sizeof(dev_info->device)); in log_buf_vmcoreinfo_setup()
1058 return -EINVAL; in log_buf_len_setup()
1083 cpu_extra = (num_possible_cpus() - 1) * __LOG_CPU_MAX_BUF_LEN; in log_buf_add_cpu()
1112 prb_rec_init_wr(&dest_r, r->info->text_len); in add_to_rb()
1117 memcpy(&dest_r.text_buf[0], &r->text_buf[0], r->info->text_len); in add_to_rb()
1118 dest_r.info->text_len = r->info->text_len; in add_to_rb()
1119 dest_r.info->facility = r->info->facility; in add_to_rb()
1120 dest_r.info->level = r->info->level; in add_to_rb()
1121 dest_r.info->flags = r->info->flags; in add_to_rb()
1122 dest_r.info->ts_nsec = r->info->ts_nsec; in add_to_rb()
1123 dest_r.info->caller_id = r->info->caller_id; in add_to_rb()
1124 memcpy(&dest_r.info->dev_info, &r->info->dev_info, sizeof(dest_r.info->dev_info)); in add_to_rb()
1160 * Some archs call setup_log_buf() multiple times - first is very in setup_log_buf()
1161 * early, e.g. from setup_arch(), and second - when percpu_areas in setup_log_buf()
1229 free -= text_size; in setup_log_buf()
1246 free -= text_size; in setup_log_buf()
1251 prb_next_seq(&printk_rb_static) - seq); in setup_log_buf()
1324 k--; in boot_delay_msec()
1377 len = print_syslog((info->facility << 3) | info->level, buf); in info_print_prefix()
1380 len += print_time(info->ts_nsec, buf + len); in info_print_prefix()
1382 len += print_caller(info->caller_id, buf + len); in info_print_prefix()
1397 * - Add prefix for each line.
1398 * - Drop truncated lines that no longer fit into the buffer.
1399 * - Add the trailing newline that has been removed in vprintk_store().
1400 * - Add a string terminator.
1403 * return value is @r->text_buf_size - 1;
1412 size_t text_len = r->info->text_len; in record_print_text()
1413 size_t buf_size = r->text_buf_size; in record_print_text()
1414 char *text = r->text_buf; in record_print_text()
1429 prefix_len = info_print_prefix(r->info, syslog, time, prefix); in record_print_text()
1435 * @len: number of bytes prepared in r->text_buf in record_print_text()
1440 line_len = next - text; in record_print_text()
1453 /* Drop even the current line if no space. */ in record_print_text()
1457 text_len = buf_size - len - prefix_len - 1 - 1; in record_print_text()
1468 * there is no newline, but it will be added immediately below. in record_print_text()
1496 text_len -= line_len + 1; in record_print_text()
1505 r->text_buf[len] = 0; in record_print_text()
1524 return ((prefix_len * line_count) + info->text_len + 1); in get_record_print_text_size()
1532 * does not require an upper bound, -1 can be used for @max_seq.
1565 len -= get_record_print_text_size(&info, line_count, syslog, time); in find_first_fitting_seq()
1582 return -ENOMEM; in syslog_print()
1626 if (r.info->seq != syslog_seq) { in syslog_print()
1628 syslog_seq = r.info->seq; in syslog_print()
1641 if (n - syslog_partial <= size) { in syslog_print()
1643 syslog_seq = r.info->seq + 1; in syslog_print()
1644 n -= syslog_partial; in syslog_print()
1662 len = -EFAULT; in syslog_print()
1667 size -= n; in syslog_print()
1687 return -ENOMEM; in syslog_print_all()
1692 * into the user-provided buffer for this dump. in syslog_print_all()
1694 seq = find_first_fitting_seq(latched_seq_read_nolock(&clear_seq), -1, in syslog_print_all()
1705 seq--; in syslog_print_all()
1710 len = -EFAULT; in syslog_print_all()
1753 return -EINVAL; in do_syslog()
1757 return -EFAULT; in do_syslog()
1767 return -EINVAL; in do_syslog()
1771 return -EFAULT; in do_syslog()
1794 return -EINVAL; in do_syslog()
1798 /* Implicitly re-enable logging to console */ in do_syslog()
1805 /* No unread messages. */ in do_syslog()
1816 * Short-cut for poll(/"proc/kmsg") which simply checks in do_syslog()
1820 error = prb_next_seq(prb) - syslog_seq; in do_syslog()
1832 error -= syslog_partial; in do_syslog()
1841 error = -EINVAL; in do_syslog()
1854 * Special console_lock variants that help to reduce the risk of soft-lockups.
1869 * console_lock_spinning_enable - mark beginning of code where another
1881 * Non-panic CPUs abandon the flush anyway. in console_lock_spinning_enable()
1883 * Just keep the lockdep annotation. The panic-CPU should avoid in console_lock_spinning_enable()
1901 * console_lock_spinning_disable_and_check - mark end of code where another
1906 * It has two functions. First, it is a signal that it is no longer
1966 * console_trylock_spinning - try to get console_lock by busy waiting
2047 * additional NMI context per CPU is also separately tracked. Until per-CPU
2060 * a WARN), but a higher value is used in case some printk-internal errors
2111 (*(recursion_ptr))--; \
2124 while (m--) { in printk_delay()
2138 * printk_parse_prefix - Parse level and control flags.
2168 *level = kern_level - '0'; in printk_parse_prefix()
2192 if (text_len && text[text_len - 1] == '\n') { in printk_sprint()
2193 text_len--; in printk_sprint()
2203 text_len -= prefix_len; in printk_sprint()
2274 text_len = printk_sprint(&r.text_buf[r.info->text_len], reserve_size, in vprintk_store()
2276 r.info->text_len += text_len; in vprintk_store()
2279 r.info->flags |= LOG_FORCE_CON; in vprintk_store()
2282 r.info->flags |= LOG_NEWLINE; in vprintk_store()
2312 r.info->text_len = text_len + trunc_msg_len; in vprintk_store()
2313 r.info->facility = facility; in vprintk_store()
2314 r.info->level = level & 7; in vprintk_store()
2315 r.info->flags = flags & 0x1f; in vprintk_store()
2316 r.info->ts_nsec = ts_nsec; in vprintk_store()
2317 r.info->caller_id = caller_id; in vprintk_store()
2319 memcpy(&r.info->dev_info, dev_info, sizeof(r.info->dev_info)); in vprintk_store()
2334 * This acts as a one-way switch to allow legacy consoles to print from
2357 pr_info("allow messages from non-panic CPUs in panic()\n"); in debug_non_panic_cpus_setup()
2364 "allow messages from non-panic CPUs in panic()");
2380 * non-panic CPUs are generating any messages, they will be in vprintk_emit()
2409 * The caller may be holding system-critical or in vprintk_emit()
2410 * timing-sensitive locks. Disable preemption during in vprintk_emit()
2487 early_console->write(early_console, buf, n); in early_printk()
2500 c->user_specified = true; in set_user_specified()
2513 return -EINVAL; in __add_preferred_console()
2522 return -EINVAL; in __add_preferred_console()
2529 i < MAX_CMDLINECONSOLES && (c->name[0] || c->devname[0]); in __add_preferred_console()
2531 if ((name && strcmp(c->name, name) == 0 && c->index == idx) || in __add_preferred_console()
2532 (devname && strcmp(c->devname, devname) == 0)) { in __add_preferred_console()
2540 return -E2BIG; in __add_preferred_console()
2544 strscpy(c->name, name); in __add_preferred_console()
2546 strscpy(c->devname, devname); in __add_preferred_console()
2547 c->options = options; in __add_preferred_console()
2551 c->index = idx; in __add_preferred_console()
2624 idx = -1; in console_setup()
2636 * add_preferred_console - add a device to the list of preferred consoles.
2643 * above to handle user-supplied console arguments; however it can also
2644 * be used by arch-specific code either to override the user or more
2654 * match_devname_and_update_preferred_console - Update a preferred console
2681 return -EINVAL; in match_devname_and_update_preferred_console()
2683 for (i = 0; i < MAX_CMDLINECONSOLES && (c->name[0] || c->devname[0]); in match_devname_and_update_preferred_console()
2685 if (!strcmp(devname, c->devname)) { in match_devname_and_update_preferred_console()
2688 strscpy(c->name, name); in match_devname_and_update_preferred_console()
2689 c->index = idx; in match_devname_and_update_preferred_console()
2694 return -ENOENT; in match_devname_and_update_preferred_console()
2722 MODULE_PARM_DESC(console_no_auto_verbose, "Disable console loglevel raise to highest on oops/panic/…
2725 * console_suspend_all - suspend the console subsystem
2740 console_srcu_write_flags(con, con->flags | CON_SUSPENDED); in console_suspend_all()
2762 console_srcu_write_flags(con, con->flags & ~CON_SUSPENDED); in console_resume_all()
2767 * contexts must be able to see they are no longer suspended so in console_resume_all()
2782 * console_cpu_notify - print deferred console messages after CPU hotplug
2807 * console_lock - block the console subsystem from printing
2809 * Acquires a lock which guarantees that no consoles will
2829 * console_trylock - try to block the console subsystem from printing
2831 * Try to acquire a lock which guarantees that no consoles will
2864 * Prepend the message in @pmsg->pbufs->outbuf. This is achieved by shifting
2870 * If there is not enough space in @pmsg->pbufs->outbuf, the existing
2873 * If @pmsg->pbufs->outbuf is modified, @pmsg->outbuf_len is updated.
2878 struct printk_buffers *pbufs = pmsg->pbufs; in console_prepend_message()
2879 const size_t scratchbuf_sz = sizeof(pbufs->scratchbuf); in console_prepend_message()
2880 const size_t outbuf_sz = sizeof(pbufs->outbuf); in console_prepend_message()
2881 char *scratchbuf = &pbufs->scratchbuf[0]; in console_prepend_message()
2882 char *outbuf = &pbufs->outbuf[0]; in console_prepend_message()
2899 if (pmsg->outbuf_len + len >= outbuf_sz) { in console_prepend_message()
2901 pmsg->outbuf_len = outbuf_sz - (len + 1); in console_prepend_message()
2902 outbuf[pmsg->outbuf_len] = 0; in console_prepend_message()
2905 memmove(outbuf + len, outbuf, pmsg->outbuf_len + 1); in console_prepend_message()
2907 pmsg->outbuf_len += len; in console_prepend_message()
2911 * Prepend the message in @pmsg->pbufs->outbuf with a "dropped message".
2912 * @pmsg->outbuf_len is updated appropriately.
2924 * Prepend the message in @pmsg->pbufs->outbuf with a "replay message".
2925 * @pmsg->outbuf_len is updated appropriately.
2938 * @pmsg will contain the formatted result. @pmsg->pbufs must point to a
2949 * Returns false if no record is available. Otherwise true and all fields
2956 struct printk_buffers *pbufs = pmsg->pbufs; in printk_get_next_message()
2957 const size_t scratchbuf_sz = sizeof(pbufs->scratchbuf); in printk_get_next_message()
2958 const size_t outbuf_sz = sizeof(pbufs->outbuf); in printk_get_next_message()
2959 char *scratchbuf = &pbufs->scratchbuf[0]; in printk_get_next_message()
2960 char *outbuf = &pbufs->outbuf[0]; in printk_get_next_message()
2970 * Formatting normal messages is done in-place, so read the ringbuffer in printk_get_next_message()
2981 pmsg->seq = r.info->seq; in printk_get_next_message()
2982 pmsg->dropped = r.info->seq - seq; in printk_get_next_message()
2983 force_con = r.info->flags & LOG_FORCE_CON; in printk_get_next_message()
2989 if (!force_con && may_suppress && suppress_message_printing(r.info->level)) in printk_get_next_message()
2994 len += msg_print_ext_body(outbuf + len, outbuf_sz - len, in printk_get_next_message()
2995 &r.text_buf[0], r.info->text_len, &r.info->dev_info); in printk_get_next_message()
3000 pmsg->outbuf_len = len; in printk_get_next_message()
3033 * Used as the printk buffers for non-panic, serialized console printing.
3044 * console_lock, in which case the caller is no longer holding both the
3049 * Returns false if the given console has no next record to print, otherwise
3065 if (!printk_get_next_message(&pmsg, con->seq, is_extended, true)) in console_emit_next_record()
3068 con->dropped += pmsg.dropped; in console_emit_next_record()
3072 con->seq = pmsg.seq + 1; in console_emit_next_record()
3076 if (con->dropped && !is_extended) { in console_emit_next_record()
3077 console_prepend_dropped(&pmsg, con->dropped); in console_emit_next_record()
3078 con->dropped = 0; in console_emit_next_record()
3087 * is no need for concern about printk reentrance, handovers, in console_emit_next_record()
3091 con->write(con, outbuf, pmsg.outbuf_len); in console_emit_next_record()
3092 con->seq = pmsg.seq + 1; in console_emit_next_record()
3111 con->write(con, outbuf, pmsg.outbuf_len); in console_emit_next_record()
3116 con->seq = pmsg.seq + 1; in console_emit_next_record()
3148 * console_lock, in which case the caller is no longer holding the
3153 * that everything was not flushed (either there were no usable consoles or
3200 printk_seq = con->seq; in console_flush_all()
3274 * Re-check if there is a new record to flush. If the trylock in __console_flush_and_unlock()
3281 * console_unlock - unblock the legacy console subsystem from printing
3305 * console_conditional_schedule - yield the CPU if required
3328 * callback. If not, there is no reason to continue and take the in console_unblank()
3339 if ((flags & CON_ENABLED) && c->unblank) { in console_unblank()
3353 * In that case, attempt a trylock as best-effort. in console_unblank()
3356 /* Semaphores are not NMI-safe. */ in console_unblank()
3381 if ((flags & CON_ENABLED) && c->unblank) in console_unblank()
3382 c->unblank(); in console_unblank()
3420 c->seq = seq; in __console_rewind_all()
3427 * console_flush_on_panic - flush console content on panic
3430 * Immediately output all pending messages no matter what.
3442 * - if it is contended, it must be ignored anyway in console_flush_on_panic()
3443 * - console_lock() and console_trylock() block and fail in console_flush_on_panic()
3444 * respectively in panic for non-panic CPUs in console_flush_on_panic()
3445 * - semaphores are not NMI-safe in console_flush_on_panic()
3485 if (!c->device) in console_device()
3487 driver = c->device(c, index); in console_device()
3500 * re-enable output afterwards.
3506 console_srcu_write_flags(console, console->flags & ~CON_ENABLED); in console_suspend()
3525 console_srcu_write_flags(console, console->flags | CON_ENABLED); in console_resume()
3526 is_nbcon = console->flags & CON_NBCON; in console_resume()
3589 printk_seq = con->seq; in legacy_kthread_should_wakeup()
3635 sched_set_normal(printk_legacy_kthread, -20); in legacy_kthread_create()
3641 * printk_kthreads_shutdown - shutdown all threaded printers
3656 if (con->flags & CON_NBCON) in printk_kthreads_shutdown()
3700 if (con->flags & CON_NBCON) in printk_kthreads_check_locked()
3713 * registered because there is no way to synchronize the hardware in printk_kthreads_check_locked()
3715 * It can only be known that there will be no new boot consoles when in printk_kthreads_check_locked()
3728 if (!(con->flags & CON_NBCON)) in printk_kthreads_check_locked()
3757 pr_info("debug: skip boot console de-registration.\n"); in keep_bootcon_setup()
3768 if (!newcon->setup) in console_call_setup()
3773 err = newcon->setup(newcon, options); in console_call_setup()
3795 i < MAX_CMDLINECONSOLES && (c->name[0] || c->devname[0]); in try_enable_preferred_console()
3798 if (!c->name[0]) in try_enable_preferred_console()
3800 if (c->user_specified != user_specified) in try_enable_preferred_console()
3802 if (!newcon->match || in try_enable_preferred_console()
3803 newcon->match(newcon, c->name, c->index, c->options) != 0) { in try_enable_preferred_console()
3805 BUILD_BUG_ON(sizeof(c->name) != sizeof(newcon->name)); in try_enable_preferred_console()
3806 if (strcmp(c->name, newcon->name) != 0) in try_enable_preferred_console()
3808 if (newcon->index >= 0 && in try_enable_preferred_console()
3809 newcon->index != c->index) in try_enable_preferred_console()
3811 if (newcon->index < 0) in try_enable_preferred_console()
3812 newcon->index = c->index; in try_enable_preferred_console()
3817 err = console_call_setup(newcon, c->options); in try_enable_preferred_console()
3821 newcon->flags |= CON_ENABLED; in try_enable_preferred_console()
3823 newcon->flags |= CON_CONSDEV; in try_enable_preferred_console()
3829 * without matching. Accept the pre-enabled consoles only when match() in try_enable_preferred_console()
3832 if (newcon->flags & CON_ENABLED && c->user_specified == user_specified) in try_enable_preferred_console()
3835 return -ENOENT; in try_enable_preferred_console()
3841 if (newcon->index < 0) in try_enable_default_console()
3842 newcon->index = 0; in try_enable_default_console()
3847 newcon->flags |= CON_ENABLED; in try_enable_default_console()
3849 if (newcon->device) in try_enable_default_console()
3850 newcon->flags |= CON_CONSDEV; in try_enable_default_console()
3860 if (newcon->flags & (CON_PRINTBUFFER | CON_BOOT)) { in get_init_console_seq()
3880 * guarantee safe access to console->seq. in get_init_console_seq()
3895 * If there was a handover, this context no in get_init_console_seq()
3905 if (!(con->flags & CON_BOOT) || in get_init_console_seq()
3906 !(con->flags & CON_ENABLED)) { in get_init_console_seq()
3910 if (con->flags & CON_NBCON) in get_init_console_seq()
3913 seq = con->seq; in get_init_console_seq()
3939 * early_printk) - sometimes before setup_arch() completes - be careful
3940 * of what kernel features are used - they may not be initialised yet.
3942 * There are two types of consoles - bootconsoles (early_printk) and
3945 * - Any number of bootconsoles can be registered at any time.
3946 * - As soon as a "real" console is registered, all bootconsoles
3948 * - Once a "real" console is registered, any attempt to register a
3953 bool use_device_lock = (newcon->flags & CON_NBCON) && newcon->write_atomic; in register_console()
3965 con->name, con->index)) { in register_console()
3969 if (con->flags & CON_BOOT) in register_console()
3976 if ((newcon->flags & CON_BOOT) && realcon_registered) { in register_console()
3978 newcon->name, newcon->index); in register_console()
3982 if (newcon->flags & CON_NBCON) { in register_console()
4004 if (hlist_empty(&console_list) || !console_first()->device || in register_console()
4005 console_first()->flags & CON_BOOT) { in register_console()
4014 if (err == -ENOENT) in register_console()
4018 if (err || newcon->flags & CON_BRL) { in register_console()
4019 if (newcon->flags & CON_NBCON) in register_console()
4031 ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV)) { in register_console()
4032 newcon->flags &= ~CON_PRINTBUFFER; in register_console()
4035 newcon->dropped = 0; in register_console()
4038 if (newcon->flags & CON_NBCON) { in register_console()
4043 newcon->seq = init_seq; in register_console()
4046 if (newcon->flags & CON_BOOT) in register_console()
4060 newcon->device_lock(newcon, &flags); in register_console()
4063 * Put this console in the list - keep the in register_console()
4068 newcon->flags |= CON_CONSDEV; in register_console()
4069 hlist_add_head_rcu(&newcon->node, &console_list); in register_console()
4071 } else if (newcon->flags & CON_CONSDEV) { in register_console()
4073 console_srcu_write_flags(console_first(), console_first()->flags & ~CON_CONSDEV); in register_console()
4074 hlist_add_head_rcu(&newcon->node, &console_list); in register_console()
4077 hlist_add_behind_rcu(&newcon->node, console_list.first); in register_console()
4081 * No need to synchronize SRCU here! The caller does not rely in register_console()
4088 newcon->device_unlock(newcon, flags); in register_console()
4094 * we get the "console xxx enabled" message on all the consoles - in register_console()
4095 * boot consoles, real consoles, etc - this is to ensure that end in register_console()
4101 ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV) && in register_console()
4106 if (con->flags & CON_BOOT) in register_console()
4121 bool use_device_lock = (console->flags & CON_NBCON) && console->write_atomic; in unregister_console_locked()
4140 res = -ENODEV; in unregister_console_locked()
4141 else if (console_is_usable(console, console->flags, true)) in unregister_console_locked()
4145 console_srcu_write_flags(console, console->flags & ~CON_ENABLED); in unregister_console_locked()
4155 console->device_lock(console, &flags); in unregister_console_locked()
4157 hlist_del_init_rcu(&console->node); in unregister_console_locked()
4160 console->device_unlock(console, flags); in unregister_console_locked()
4168 * The above makes no sense as there is no guarantee that the next in unregister_console_locked()
4171 if (!hlist_empty(&console_list) && console->flags & CON_CONSDEV) in unregister_console_locked()
4172 console_srcu_write_flags(console_first(), console_first()->flags | CON_CONSDEV); in unregister_console_locked()
4186 if (c->flags & CON_BOOT) in unregister_console_locked()
4189 if (c->flags & CON_NBCON) in unregister_console_locked()
4202 if (console->flags & CON_NBCON) in unregister_console_locked()
4207 if (console->exit) in unregister_console_locked()
4208 res = console->exit(console); in unregister_console_locked()
4228 * console_force_preferred_locked - force a registered console preferred
4247 * Delete, but do not re-initialize the entry. This allows the console in console_force_preferred_locked()
4251 hlist_del_rcu(&con->node); in console_force_preferred_locked()
4256 * list pointer can be re-initialized. in console_force_preferred_locked()
4260 con->flags |= CON_CONSDEV; in console_force_preferred_locked()
4261 WARN_ON(!con->device); in console_force_preferred_locked()
4264 console_srcu_write_flags(cur_pref_con, cur_pref_con->flags & ~CON_CONSDEV); in console_force_preferred_locked()
4265 hlist_add_head_rcu(&con->node, &console_list); in console_force_preferred_locked()
4306 * be discarded after the initcalls have been run. To make sure that no code
4311 * be a brief interval in which no messages are logged to the console, which
4326 if (!(con->flags & CON_BOOT)) in printk_late_init()
4331 init_section_contains(con->write, 0) || in printk_late_init()
4332 init_section_contains(con->read, 0) || in printk_late_init()
4333 init_section_contains(con->device, 0) || in printk_late_init()
4334 init_section_contains(con->unblank, 0) || in printk_late_init()
4335 init_section_contains(con->data, 0)) { in printk_late_init()
4341 con->name, con->index); in printk_late_init()
4398 * console->seq. Releasing console_lock flushes more in __pr_flush()
4403 * are no legacy or boot consoles. However, such a in __pr_flush()
4430 printk_seq = c->seq; in __pr_flush()
4434 diff += seq - printk_seq; in __pr_flush()
4443 /* Note: @diff is 0 if there are no usable consoles. */ in __pr_flush()
4450 slept_jiffies = jiffies - begin_jiffies; in __pr_flush()
4452 remaining_jiffies -= min(slept_jiffies, remaining_jiffies); in __pr_flush()
4461 * pr_flush() - Wait for printing threads to catch up.
4466 * A value of 0 for @timeout_ms means no waiting will occur. A value of -1
4481 * Delayed printk version, for scheduler-internal messages:
4535 * wake_up_klogd - Wake kernel logging daemon
4550 * defer_console_output - Wake kernel logging daemon and trigger
4596 * every 5s to make a denial-of-service attack impossible.
4607 * printk_timed_ratelimit - caller-controlled printk ratelimiting
4618 unsigned long elapsed = jiffies - *caller_jiffies; in printk_timed_ratelimit()
4632 * kmsg_dump_register - register a kernel log dumper.
4635 * Adds a kernel log dumper to the system. The dump callback in the
4637 * set. Returns zero on success and %-EINVAL or %-EBUSY otherwise.
4642 int err = -EBUSY; in kmsg_dump_register()
4644 /* The dump callback needs to be set */ in kmsg_dump_register()
4645 if (!dumper->dump) in kmsg_dump_register()
4646 return -EINVAL; in kmsg_dump_register()
4650 if (!dumper->registered) { in kmsg_dump_register()
4651 dumper->registered = 1; in kmsg_dump_register()
4652 list_add_tail_rcu(&dumper->list, &dump_list); in kmsg_dump_register()
4662 * kmsg_dump_unregister - unregister a kmsg dumper.
4665 * Removes a dump device from the system. Returns zero on success and
4666 * %-EINVAL otherwise.
4671 int err = -EINVAL; in kmsg_dump_unregister()
4674 if (dumper->registered) { in kmsg_dump_unregister()
4675 dumper->registered = 0; in kmsg_dump_unregister()
4676 list_del_rcu(&dumper->list); in kmsg_dump_unregister()
4695 return "Oops"; in kmsg_dump_reason_str()
4707 * kmsg_dump_desc - dump kernel log to kernel message dumpers.
4708 * @reason: the reason (oops, panic etc) for dumping
4709 * @desc: a short string to describe what caused the panic or oops. Can be NULL
4710 * if no additional description is available.
4712 * Call each of the registered dumper's dump() callback, which can
4725 enum kmsg_dump_reason max_reason = dumper->max_reason; in kmsg_dump_desc()
4739 dumper->dump(dumper, &detail); in kmsg_dump_desc()
4745 * kmsg_dump_get_line - retrieve one kmsg log line
4746 * @iter: kmsg dump iterator
4758 * A return value of FALSE indicates that there are no more records to
4771 if (iter->cur_seq < min_seq) in kmsg_dump_get_line()
4772 iter->cur_seq = min_seq; in kmsg_dump_get_line()
4778 if (!prb_read_valid(prb, iter->cur_seq, &r)) in kmsg_dump_get_line()
4782 if (!prb_read_valid_info(prb, iter->cur_seq, in kmsg_dump_get_line()
4791 iter->cur_seq = r.info->seq + 1; in kmsg_dump_get_line()
4801 * kmsg_dump_get_buffer - copy kmsg log lines
4802 * @iter: kmsg dump iterator
4816 * A return value of FALSE indicates that there are no more records to
4834 if (iter->cur_seq < min_seq) in kmsg_dump_get_buffer()
4835 iter->cur_seq = min_seq; in kmsg_dump_get_buffer()
4837 if (prb_read_valid_info(prb, iter->cur_seq, &info, NULL)) { in kmsg_dump_get_buffer()
4838 if (info.seq != iter->cur_seq) { in kmsg_dump_get_buffer()
4840 iter->cur_seq = info.seq; in kmsg_dump_get_buffer()
4845 if (iter->cur_seq >= iter->next_seq) in kmsg_dump_get_buffer()
4850 * into the user-provided buffer for this dump. Pass in size-1 in kmsg_dump_get_buffer()
4852 * not write more than size-1 bytes of text into @buf. in kmsg_dump_get_buffer()
4854 seq = find_first_fitting_seq(iter->cur_seq, iter->next_seq, in kmsg_dump_get_buffer()
4855 size - 1, syslog, time); in kmsg_dump_get_buffer()
4858 * Next kmsg_dump_get_buffer() invocation will dump block of in kmsg_dump_get_buffer()
4866 if (r.info->seq >= iter->next_seq) in kmsg_dump_get_buffer()
4872 prb_rec_init_rd(&r, &info, buf + len, size - len); in kmsg_dump_get_buffer()
4875 iter->next_seq = next_seq; in kmsg_dump_get_buffer()
4885 * kmsg_dump_rewind - reset the iterator
4886 * @iter: kmsg dump iterator
4890 * times within the same dumper.dump() callback.
4894 iter->cur_seq = latched_seq_read_nolock(&clear_seq); in kmsg_dump_rewind()
4895 iter->next_seq = prb_next_seq(prb); in kmsg_dump_rewind()
4900 * console_try_replay_all - try to replay kernel log on consoles
4928 static atomic_t printk_cpu_sync_owner = ATOMIC_INIT(-1);
4937 * __printk_cpu_sync_wait() - Busy wait until the printk cpu-reentrant
4946 } while (atomic_read(&printk_cpu_sync_owner) != -1); in __printk_cpu_sync_wait()
4951 * __printk_cpu_sync_try_get() - Try to acquire the printk cpu-reentrant
4954 * If no processor has the lock, the calling processor takes the lock and
4987 old = atomic_cmpxchg_acquire(&printk_cpu_sync_owner, -1, in __printk_cpu_sync_try_get()
4989 if (old == -1) { in __printk_cpu_sync_try_get()
5007 * __printk_cpu_sync_put() - Release the printk cpu-reentrant spinning lock.
5044 -1); /* LMM(__printk_cpu_sync_put:B) */ in __printk_cpu_sync_put()