arch/powerpc/platforms/pseries/cmm.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/pseries/cmm.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/pseries/cmm.c- Extension
.c- Size
- 15772 bytes
- Lines
- 633
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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/ctype.hlinux/delay.hlinux/errno.hlinux/fs.hlinux/gfp.hlinux/kthread.hlinux/module.hlinux/oom.hlinux/reboot.hlinux/sched.hlinux/stringify.hlinux/swap.hlinux/sysfs.hlinux/device.hlinux/balloon.hasm/firmware.hasm/hvcall.hasm/mmu.hlinux/uaccess.hlinux/memory.hasm/plpar_wrappers.hpseries.h
Detected Declarations
function plpar_page_set_loanedfunction plpar_page_set_activefunction cmm_alloc_pagesfunction cmm_free_pagesfunction cmm_oom_notifyfunction cmm_get_mppfunction cmm_threadfunction show_oom_pagesfunction store_oom_pagesfunction cmm_release_devicefunction cmm_unregister_sysfsfunction cmm_reboot_notifierfunction cmm_memory_cbfunction cmm_migratepagefunction cmm_initfunction cmm_exitfunction cmm_set_disablemodule init cmm_init
Annotated Snippet
static const struct bus_type cmm_subsys = {
.name = "cmm",
.dev_name = "cmm",
};
static void cmm_release_device(struct device *dev)
{
}
/**
* cmm_sysfs_register - Register with sysfs
*
* Return value:
* 0 on success / other on failure
**/
static int cmm_sysfs_register(struct device *dev)
{
int i, rc;
if ((rc = subsys_system_register(&cmm_subsys, NULL)))
return rc;
dev->id = 0;
dev->bus = &cmm_subsys;
dev->release = cmm_release_device;
if ((rc = device_register(dev)))
goto subsys_unregister;
for (i = 0; i < ARRAY_SIZE(cmm_attrs); i++) {
if ((rc = device_create_file(dev, cmm_attrs[i])))
goto fail;
}
if (!simulate)
return 0;
rc = device_create_file(dev, &dev_attr_simulate_loan_target_kb.attr);
if (rc)
goto fail;
return 0;
fail:
while (--i >= 0)
device_remove_file(dev, cmm_attrs[i]);
device_unregister(dev);
subsys_unregister:
bus_unregister(&cmm_subsys);
return rc;
}
/**
* cmm_unregister_sysfs - Unregister from sysfs
*
**/
static void cmm_unregister_sysfs(struct device *dev)
{
int i;
for (i = 0; i < ARRAY_SIZE(cmm_attrs); i++)
device_remove_file(dev, cmm_attrs[i]);
device_unregister(dev);
bus_unregister(&cmm_subsys);
}
/**
* cmm_reboot_notifier - Make sure pages are not still marked as "loaned"
*
**/
static int cmm_reboot_notifier(struct notifier_block *nb,
unsigned long action, void *unused)
{
if (action == SYS_RESTART) {
if (cmm_thread_ptr)
kthread_stop(cmm_thread_ptr);
cmm_thread_ptr = NULL;
cmm_free_pages(atomic_long_read(&loaned_pages));
}
return NOTIFY_DONE;
}
static struct notifier_block cmm_reboot_nb = {
.notifier_call = cmm_reboot_notifier,
};
/**
* cmm_memory_cb - Handle memory hotplug notifier calls
* @self: notifier block struct
* @action: action to take
* @arg: struct memory_notify data for handler
*
Annotation
- Immediate include surface: `linux/ctype.h`, `linux/delay.h`, `linux/errno.h`, `linux/fs.h`, `linux/gfp.h`, `linux/kthread.h`, `linux/module.h`, `linux/oom.h`.
- Detected declarations: `function plpar_page_set_loaned`, `function plpar_page_set_active`, `function cmm_alloc_pages`, `function cmm_free_pages`, `function cmm_oom_notify`, `function cmm_get_mpp`, `function cmm_thread`, `function show_oom_pages`, `function store_oom_pages`, `function cmm_release_device`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.