kernel/printk/internal.h

Source file repositories/reference/linux-study-clean/kernel/printk/internal.h

File Facts

System
Linux kernel
Corpus path
kernel/printk/internal.h
Extension
.h
Size
9516 bytes
Lines
313
Domain
Core OS
Bucket
Scheduler, Processes, Timers, Sync, And Syscalls
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct console_flush_type {
	bool	nbcon_atomic;
	bool	nbcon_offload;
	bool	legacy_direct;
	bool	legacy_offload;
};

extern bool console_irqwork_blocked;

/*
 * Identify which console flushing methods should be used in the context of
 * the caller.
 */
static inline void printk_get_console_flush_type(struct console_flush_type *ft)
{
	memset(ft, 0, sizeof(*ft));

	switch (nbcon_get_default_prio()) {
	case NBCON_PRIO_NORMAL:
		if (have_nbcon_console && !have_boot_console) {
			if (printk_kthreads_running && !console_irqwork_blocked)
				ft->nbcon_offload = true;
			else
				ft->nbcon_atomic = true;
		}

		/* Legacy consoles are flushed directly when possible. */
		if (have_legacy_console || have_boot_console) {
			if (!is_printk_legacy_deferred())
				ft->legacy_direct = true;
			else if (!console_irqwork_blocked)
				ft->legacy_offload = true;
		}
		break;

	case NBCON_PRIO_EMERGENCY:
		if (have_nbcon_console && !have_boot_console)
			ft->nbcon_atomic = true;

		/* Legacy consoles are flushed directly when possible. */
		if (have_legacy_console || have_boot_console) {
			if (!is_printk_legacy_deferred())
				ft->legacy_direct = true;
			else if (!console_irqwork_blocked)
				ft->legacy_offload = true;
		}
		break;

	case NBCON_PRIO_PANIC:
		/*
		 * In panic, the nbcon consoles will directly print. But
		 * only allowed if there are no boot consoles.
		 */
		if (have_nbcon_console && !have_boot_console)
			ft->nbcon_atomic = true;

		if (have_legacy_console || have_boot_console) {
			/*
			 * This is the same decision as NBCON_PRIO_NORMAL
			 * except that offloading never occurs in panic.
			 *
			 * Note that console_flush_on_panic() will flush
			 * legacy consoles anyway, even if unsafe.
			 */
			if (!is_printk_legacy_deferred())
				ft->legacy_direct = true;

			/*
			 * In panic, if nbcon atomic printing occurs,
			 * the legacy consoles must remain silent until
			 * explicitly allowed.
			 */
			if (ft->nbcon_atomic && !legacy_allow_panic_sync)
				ft->legacy_direct = false;
		}
		break;

	default:
		WARN_ON_ONCE(1);
		break;
	}
}

extern struct printk_buffers printk_shared_pbufs;

/**
 * struct printk_buffers - Buffers to read/format/output printk messages.
 * @outbuf:	After formatting, contains text to output.
 * @scratchbuf:	Used as temporary ringbuffer reading and string-print space.
 */

Annotation

Implementation Notes