arch/powerpc/platforms/pseries/hotplug-memory.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/pseries/hotplug-memory.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/pseries/hotplug-memory.c- Extension
.c- Size
- 20520 bytes
- Lines
- 924
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- 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/of.hlinux/of_address.hlinux/memblock.hlinux/memory.hlinux/memory_hotplug.hlinux/slab.hasm/firmware.hasm/machdep.hasm/sparsemem.hasm/fadump.hasm/drmem.hpseries.h
Detected Declarations
function Copyrightfunction find_aa_indexfunction update_lmb_associativity_indexfunction get_lmb_rangefunction dlpar_change_lmb_statefunction dlpar_online_lmbfunction dlpar_offline_lmbfunction pseries_remove_memblockfunction pseries_remove_mem_nodefunction lmb_is_removablefunction dlpar_remove_lmbfunction dlpar_memory_remove_by_countfunction for_each_drmem_lmbfunction for_each_drmem_lmbfunction for_each_drmem_lmbfunction dlpar_memory_remove_by_indexfunction dlpar_memory_remove_by_icfunction remove_by_countfunction for_each_drmem_lmb_in_rangefunction for_each_drmem_lmb_in_rangefunction for_each_drmem_lmb_in_rangefunction pseries_remove_memblockfunction pseries_remove_mem_nodefunction dlpar_remove_lmbfunction dlpar_memory_remove_by_countfunction dlpar_memory_remove_by_indexfunction dlpar_memory_remove_by_icfunction dlpar_add_lmbfunction dlpar_memory_add_by_countfunction for_each_drmem_lmbfunction for_each_drmem_lmbfunction for_each_drmem_lmbfunction dlpar_memory_add_by_indexfunction dlpar_memory_add_by_icfunction for_each_drmem_lmb_in_rangefunction for_each_drmem_lmb_in_rangefunction for_each_drmem_lmb_in_rangefunction dlpar_memoryfunction pseries_add_mem_nodefunction pseries_memory_notifierfunction pseries_memory_hotplug_init
Annotated Snippet
if (lmb->drc_index == drc_index) {
start = lmb;
break;
}
}
if (!start)
return -EINVAL;
end = &start[n_lmbs];
limit = &drmem_info->lmbs[drmem_info->n_lmbs];
if (end > limit)
return -EINVAL;
*start_lmb = start;
*end_lmb = end;
return 0;
}
static int dlpar_change_lmb_state(struct drmem_lmb *lmb, bool online)
{
struct memory_block *mem_block;
int rc;
mem_block = lmb_to_memblock(lmb);
if (!mem_block) {
pr_err("Failed memory block lookup for LMB 0x%x\n", lmb->drc_index);
return -EINVAL;
}
if (online && dev_offline(&mem_block->dev))
rc = device_online(&mem_block->dev);
else if (!online && !dev_offline(&mem_block->dev))
rc = device_offline(&mem_block->dev);
else
rc = 0;
memory_block_put(mem_block);
return rc;
}
static int dlpar_online_lmb(struct drmem_lmb *lmb)
{
return dlpar_change_lmb_state(lmb, true);
}
#ifdef CONFIG_MEMORY_HOTREMOVE
static int dlpar_offline_lmb(struct drmem_lmb *lmb)
{
return dlpar_change_lmb_state(lmb, false);
}
static int pseries_remove_memblock(unsigned long base, unsigned long memblock_size)
{
unsigned long start_pfn;
int sections_per_block;
int i;
start_pfn = base >> PAGE_SHIFT;
lock_device_hotplug();
if (!pfn_valid(start_pfn))
goto out;
sections_per_block = memory_block_size / MIN_MEMORY_BLOCK_SIZE;
for (i = 0; i < sections_per_block; i++) {
__remove_memory(base, MIN_MEMORY_BLOCK_SIZE);
base += MIN_MEMORY_BLOCK_SIZE;
}
out:
/* Update memory regions for memory remove */
memblock_remove(base, memblock_size);
unlock_device_hotplug();
return 0;
}
static int pseries_remove_mem_node(struct device_node *np)
{
int ret;
struct resource res;
/*
* Check to see if we are actually removing memory
*/
if (!of_node_is_type(np, "memory"))
Annotation
- Immediate include surface: `linux/of.h`, `linux/of_address.h`, `linux/memblock.h`, `linux/memory.h`, `linux/memory_hotplug.h`, `linux/slab.h`, `asm/firmware.h`, `asm/machdep.h`.
- Detected declarations: `function Copyright`, `function find_aa_index`, `function update_lmb_associativity_index`, `function get_lmb_range`, `function dlpar_change_lmb_state`, `function dlpar_online_lmb`, `function dlpar_offline_lmb`, `function pseries_remove_memblock`, `function pseries_remove_mem_node`, `function lmb_is_removable`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: integration 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.