arch/x86/kernel/cpu/mce/core.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/cpu/mce/core.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/cpu/mce/core.c- Extension
.c- Size
- 72013 bytes
- Lines
- 2945
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/thread_info.hlinux/capability.hlinux/miscdevice.hlinux/ratelimit.hlinux/rcupdate.hlinux/kobject.hlinux/uaccess.hlinux/kdebug.hlinux/kernel.hlinux/percpu.hlinux/string.hlinux/device.hlinux/syscore_ops.hlinux/delay.hlinux/ctype.hlinux/sched.hlinux/sysfs.hlinux/types.hlinux/slab.hlinux/init.hlinux/kmod.hlinux/poll.hlinux/nmi.hlinux/cpu.hlinux/ras.hlinux/smp.hlinux/fs.hlinux/mm.hlinux/debugfs.hlinux/irq_work.hlinux/export.hlinux/set_memory.h
Detected Declarations
struct mce_bank_devfunction mce_prep_record_commonfunction mce_prep_record_per_cpufunction mce_prep_recordfunction mce_logfunction mce_register_decode_chainfunction mce_unregister_decode_chainfunction __print_mcefunction print_mcefunction wait_for_panicfunction mce_panicfunction msr_to_offsetfunction ex_handler_msr_mcefunction mce_rdmsrqfunction mce_wrmsrqfunction globalfunction mce_availablefunction mce_schedule_workfunction mce_irq_work_cbfunction mce_usable_addressfunction mce_is_memory_errorfunction whole_pagefunction mce_is_correctablefunction mce_early_notifierfunction uc_decode_notifierfunction mce_default_notifierfunction mce_read_auxfunction smca_should_log_poll_errorfunction ser_should_log_poll_errorfunction should_log_poll_errorfunction clear_bankfunction machine_check_pollfunction processorfunction contextfunction quirk_zen_ifufunction mce_no_way_outfunction mce_timed_outfunction mce_reignfunction mce_startfunction mce_endfunction mce_clear_statefunction crash_nmi_callbackfunction __mc_scan_banksfunction kill_me_nowfunction kill_me_maybefunction kill_me_neverfunction queue_task_workfunction unexpected_machine_check
Annotated Snippet
static const struct bus_type mce_subsys = {
.name = "machinecheck",
.dev_name = "machinecheck",
};
DEFINE_PER_CPU(struct device *, mce_device);
static inline struct mce_bank_dev *attr_to_bank(struct device_attribute *attr)
{
return container_of(attr, struct mce_bank_dev, attr);
}
static ssize_t show_bank(struct device *s, struct device_attribute *attr,
char *buf)
{
u8 bank = attr_to_bank(attr)->bank;
struct mce_bank *b;
if (bank >= per_cpu(mce_num_banks, s->id))
return -EINVAL;
b = &per_cpu(mce_banks_array, s->id)[bank];
if (!b->init)
return -ENODEV;
return sprintf(buf, "%llx\n", b->ctl);
}
static ssize_t set_bank(struct device *s, struct device_attribute *attr,
const char *buf, size_t size)
{
u8 bank = attr_to_bank(attr)->bank;
struct mce_bank *b;
u64 new;
if (kstrtou64(buf, 0, &new) < 0)
return -EINVAL;
if (bank >= per_cpu(mce_num_banks, s->id))
return -EINVAL;
b = &per_cpu(mce_banks_array, s->id)[bank];
if (!b->init)
return -ENODEV;
b->ctl = new;
mutex_lock(&mce_sysfs_mutex);
mce_restart();
mutex_unlock(&mce_sysfs_mutex);
return size;
}
static ssize_t set_ignore_ce(struct device *s,
struct device_attribute *attr,
const char *buf, size_t size)
{
u64 new;
if (kstrtou64(buf, 0, &new) < 0)
return -EINVAL;
mutex_lock(&mce_sysfs_mutex);
if (mca_cfg.ignore_ce ^ !!new) {
if (new) {
/* disable ce features */
mce_timer_delete_all();
on_each_cpu(mce_disable_cmci, NULL, 1);
mca_cfg.ignore_ce = true;
} else {
/* enable ce features */
mca_cfg.ignore_ce = false;
on_each_cpu(mce_enable_ce, (void *)1, 1);
}
}
mutex_unlock(&mce_sysfs_mutex);
return size;
}
static ssize_t set_cmci_disabled(struct device *s,
struct device_attribute *attr,
const char *buf, size_t size)
{
u64 new;
if (kstrtou64(buf, 0, &new) < 0)
return -EINVAL;
Annotation
- Immediate include surface: `linux/thread_info.h`, `linux/capability.h`, `linux/miscdevice.h`, `linux/ratelimit.h`, `linux/rcupdate.h`, `linux/kobject.h`, `linux/uaccess.h`, `linux/kdebug.h`.
- Detected declarations: `struct mce_bank_dev`, `function mce_prep_record_common`, `function mce_prep_record_per_cpu`, `function mce_prep_record`, `function mce_log`, `function mce_register_decode_chain`, `function mce_unregister_decode_chain`, `function __print_mce`, `function print_mce`, `function wait_for_panic`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.