arch/x86/xen/multicalls.c
Source file repositories/reference/linux-study-clean/arch/x86/xen/multicalls.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/xen/multicalls.c- Extension
.c- Size
- 7369 bytes
- Lines
- 300
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: implementation source
- Status
- source 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 or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/percpu.hlinux/hardirq.hlinux/debugfs.hlinux/jump_label.hlinux/printk.hasm/xen/hypercall.hxen-ops.h
Detected Declarations
struct mc_bufferstruct callbackstruct mc_debug_datafunction get_mc_debugfunction xen_parse_mc_debugfunction mc_debug_enablefunction print_debug_datafunction xen_mc_flushfunction __xen_mc_entryfunction xen_mc_extend_argsfunction xen_mc_callback
Annotated Snippet
struct mc_buffer {
unsigned mcidx, argidx, cbidx;
struct multicall_entry entries[MC_BATCH];
unsigned char args[MC_ARGS];
struct callback {
void (*fn)(void *);
void *data;
} callbacks[MC_BATCH];
};
struct mc_debug_data {
struct multicall_entry entries[MC_BATCH];
void *caller[MC_BATCH];
size_t argsz[MC_BATCH];
unsigned long *args[MC_BATCH];
};
static DEFINE_PER_CPU(struct mc_buffer, mc_buffer);
static struct mc_debug_data mc_debug_data_early __initdata;
static struct mc_debug_data __percpu *mc_debug_data_ptr;
DEFINE_PER_CPU(unsigned long, xen_mc_irq_flags);
static struct static_key mc_debug __ro_after_init;
static bool mc_debug_enabled __initdata;
static struct mc_debug_data * __ref get_mc_debug(void)
{
if (!mc_debug_data_ptr)
return &mc_debug_data_early;
return this_cpu_ptr(mc_debug_data_ptr);
}
static int __init xen_parse_mc_debug(char *arg)
{
mc_debug_enabled = true;
static_key_slow_inc(&mc_debug);
return 0;
}
early_param("xen_mc_debug", xen_parse_mc_debug);
static int __init mc_debug_enable(void)
{
unsigned long flags;
struct mc_debug_data __percpu *mcdb;
if (!mc_debug_enabled)
return 0;
mcdb = alloc_percpu(struct mc_debug_data);
if (!mcdb) {
pr_err("xen_mc_debug inactive\n");
static_key_slow_dec(&mc_debug);
return -ENOMEM;
}
/* Be careful when switching to percpu debug data. */
local_irq_save(flags);
xen_mc_flush();
mc_debug_data_ptr = mcdb;
local_irq_restore(flags);
pr_info("xen_mc_debug active\n");
return 0;
}
early_initcall(mc_debug_enable);
/* Number of parameters of hypercalls used via multicalls. */
static const uint8_t hpcpars[] = {
[__HYPERVISOR_mmu_update] = 4,
[__HYPERVISOR_stack_switch] = 2,
[__HYPERVISOR_fpu_taskswitch] = 1,
[__HYPERVISOR_update_descriptor] = 2,
[__HYPERVISOR_update_va_mapping] = 3,
[__HYPERVISOR_mmuext_op] = 4,
};
static void print_debug_data(struct mc_buffer *b, struct mc_debug_data *mcdb,
int idx)
{
unsigned int arg;
unsigned int opidx = mcdb->entries[idx].op & 0xff;
unsigned int pars = 0;
pr_err(" call %2d: op=%lu result=%ld caller=%pS ", idx + 1,
mcdb->entries[idx].op, b->entries[idx].result,
mcdb->caller[idx]);
if (opidx < ARRAY_SIZE(hpcpars))
Annotation
- Immediate include surface: `linux/percpu.h`, `linux/hardirq.h`, `linux/debugfs.h`, `linux/jump_label.h`, `linux/printk.h`, `asm/xen/hypercall.h`, `xen-ops.h`.
- Detected declarations: `struct mc_buffer`, `struct callback`, `struct mc_debug_data`, `function get_mc_debug`, `function xen_parse_mc_debug`, `function mc_debug_enable`, `function print_debug_data`, `function xen_mc_flush`, `function __xen_mc_entry`, `function xen_mc_extend_args`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: source implementation candidate.
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.