arch/um/drivers/mconsole_kern.c
Source file repositories/reference/linux-study-clean/arch/um/drivers/mconsole_kern.c
File Facts
- System
- Linux kernel
- Corpus path
arch/um/drivers/mconsole_kern.c- Extension
.c- Size
- 19005 bytes
- Lines
- 872
- Domain
- Architecture Layer
- Bucket
- arch/um
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/console.hlinux/ctype.hlinux/string.hlinux/interrupt.hlinux/list.hlinux/mm.hlinux/module.hlinux/notifier.hlinux/panic_notifier.hlinux/reboot.hlinux/sched/debug.hlinux/proc_fs.hlinux/slab.hlinux/syscalls.hlinux/utsname.hlinux/socket.hlinux/un.hlinux/workqueue.hlinux/mutex.hlinux/fs.hlinux/mount.hlinux/file.hlinux/uaccess.hasm/switch_to.hinit.hirq_kern.hirq_user.hkern_util.hmconsole.hmconsole_kern.hos.hlinux/sysrq.h
Detected Declarations
struct unplugged_pagesstruct mconsole_outputfunction do_unlink_socketfunction mc_work_procfunction mconsole_interruptfunction mconsole_versionfunction mconsole_logfunction mconsole_procfunction mconsole_helpfunction mconsole_haltfunction mconsole_rebootfunction mconsole_cadfunction mconsole_gofunction mconsole_stopfunction mconsole_register_devfunction list_for_eachfunction mem_configfunction mem_get_configfunction mem_idfunction mem_removefunction mem_mc_initfunction mconsole_get_configfunction mconsole_configfunction mconsole_removefunction console_writefunction list_for_eachfunction mc_add_consolefunction with_consolefunction sysrq_procfunction mconsole_sysrqfunction mconsole_sysrqfunction stack_procfunction mconsole_stackfunction mount_procfunction mconsole_initfunction mconsole_proc_writefunction create_proc_mconsolefunction lock_notifyfunction unlock_notifyfunction mconsole_setupfunction notify_panicfunction add_notifierexport mconsole_notify_socket
Annotated Snippet
struct unplugged_pages {
struct list_head list;
void *pages[UNPLUGGED_PER_PAGE];
};
static DEFINE_MUTEX(plug_mem_mutex);
static unsigned long long unplugged_pages_count;
static LIST_HEAD(unplugged_pages);
static int unplug_index = UNPLUGGED_PER_PAGE;
static int mem_config(char *str, char **error_out)
{
unsigned long long diff;
int err = -EINVAL, i, add;
char *ret;
if (str[0] != '=') {
*error_out = "Expected '=' after 'mem'";
goto out;
}
str++;
if (str[0] == '-')
add = 0;
else if (str[0] == '+') {
add = 1;
}
else {
*error_out = "Expected increment to start with '-' or '+'";
goto out;
}
str++;
diff = memparse(str, &ret);
if (*ret != '\0') {
*error_out = "Failed to parse memory increment";
goto out;
}
diff /= PAGE_SIZE;
mutex_lock(&plug_mem_mutex);
for (i = 0; i < diff; i++) {
struct unplugged_pages *unplugged;
void *addr;
if (add) {
if (list_empty(&unplugged_pages))
break;
unplugged = list_entry(unplugged_pages.next,
struct unplugged_pages, list);
if (unplug_index > 0)
addr = unplugged->pages[--unplug_index];
else {
list_del(&unplugged->list);
addr = unplugged;
unplug_index = UNPLUGGED_PER_PAGE;
}
free_page((unsigned long) addr);
unplugged_pages_count--;
}
else {
struct page *page;
page = alloc_page(GFP_ATOMIC);
if (page == NULL)
break;
unplugged = page_address(page);
if (unplug_index == UNPLUGGED_PER_PAGE) {
list_add(&unplugged->list, &unplugged_pages);
unplug_index = 0;
}
else {
struct list_head *entry = unplugged_pages.next;
addr = unplugged;
unplugged = list_entry(entry,
struct unplugged_pages,
list);
err = os_drop_memory(addr, PAGE_SIZE);
if (err) {
printk(KERN_ERR "Failed to release "
"memory - errno = %d\n", err);
*error_out = "Failed to release memory";
goto out_unlock;
}
unplugged->pages[unplug_index++] = addr;
Annotation
- Immediate include surface: `linux/console.h`, `linux/ctype.h`, `linux/string.h`, `linux/interrupt.h`, `linux/list.h`, `linux/mm.h`, `linux/module.h`, `linux/notifier.h`.
- Detected declarations: `struct unplugged_pages`, `struct mconsole_output`, `function do_unlink_socket`, `function mc_work_proc`, `function mconsole_interrupt`, `function mconsole_version`, `function mconsole_log`, `function mconsole_proc`, `function mconsole_help`, `function mconsole_halt`.
- Atlas domain: Architecture Layer / arch/um.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.