arch/powerpc/mm/book3s64/slice.c
Source file repositories/reference/linux-study-clean/arch/powerpc/mm/book3s64/slice.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/mm/book3s64/slice.c- Extension
.c- Size
- 23139 bytes
- Lines
- 820
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/mm.hlinux/pagemap.hlinux/err.hlinux/spinlock.hlinux/export.hlinux/hugetlb.hlinux/sched/mm.hlinux/security.hasm/mman.hasm/mmu.hasm/spu.hasm/hugetlb.hasm/mmu_context.h
Detected Declarations
function slice_print_maskfunction slice_print_maskfunction slice_range_to_maskfunction slice_area_is_freefunction slice_low_has_vmafunction slice_high_has_vmafunction slice_mask_for_freefunction slice_check_range_fitsfunction slice_flush_segmentsfunction slice_convertfunction slice_scan_availablefunction slice_find_area_bottomupfunction slice_find_area_topdownfunction slice_find_areafunction slice_copy_maskfunction slice_or_maskfunction slice_andnot_maskfunction slice_get_unmapped_areafunction file_to_psizefunction file_to_psizefunction arch_get_unmapped_areafunction arch_get_unmapped_area_topdownfunction get_slice_psizefunction slice_init_new_context_execfunction slice_setup_new_execfunction slice_set_range_psizefunction is_hugepage_only_rangefunction vma_mmu_pagesizeexport slice_get_unmapped_areaexport get_slice_psize
Annotated Snippet
static void slice_print_mask(const char *label, const struct slice_mask *mask) {}
#define slice_dbg(fmt...)
#endif
static inline notrace bool slice_addr_is_low(unsigned long addr)
{
u64 tmp = (u64)addr;
return tmp < SLICE_LOW_TOP;
}
static void slice_range_to_mask(unsigned long start, unsigned long len,
struct slice_mask *ret)
{
unsigned long end = start + len - 1;
ret->low_slices = 0;
if (SLICE_NUM_HIGH)
bitmap_zero(ret->high_slices, SLICE_NUM_HIGH);
if (slice_addr_is_low(start)) {
unsigned long mend = min(end,
(unsigned long)(SLICE_LOW_TOP - 1));
ret->low_slices = (1u << (GET_LOW_SLICE_INDEX(mend) + 1))
- (1u << GET_LOW_SLICE_INDEX(start));
}
if (SLICE_NUM_HIGH && !slice_addr_is_low(end)) {
unsigned long start_index = GET_HIGH_SLICE_INDEX(start);
unsigned long align_end = ALIGN(end, (1UL << SLICE_HIGH_SHIFT));
unsigned long count = GET_HIGH_SLICE_INDEX(align_end) - start_index;
bitmap_set(ret->high_slices, start_index, count);
}
}
static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
unsigned long len)
{
struct vm_area_struct *vma;
if ((mm_ctx_slb_addr_limit(&mm->context) - len) < addr)
return 0;
vma = find_vma(mm, addr);
return (!vma || (addr + len) <= vm_start_gap(vma));
}
static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
{
return !slice_area_is_free(mm, slice << SLICE_LOW_SHIFT,
1ul << SLICE_LOW_SHIFT);
}
static int slice_high_has_vma(struct mm_struct *mm, unsigned long slice)
{
unsigned long start = slice << SLICE_HIGH_SHIFT;
unsigned long end = start + (1ul << SLICE_HIGH_SHIFT);
/* Hack, so that each addresses is controlled by exactly one
* of the high or low area bitmaps, the first high area starts
* at 4GB, not 0 */
if (start == 0)
start = (unsigned long)SLICE_LOW_TOP;
return !slice_area_is_free(mm, start, end - start);
}
static void slice_mask_for_free(struct mm_struct *mm, struct slice_mask *ret,
unsigned long high_limit)
{
unsigned long i;
ret->low_slices = 0;
if (SLICE_NUM_HIGH)
bitmap_zero(ret->high_slices, SLICE_NUM_HIGH);
for (i = 0; i < SLICE_NUM_LOW; i++)
if (!slice_low_has_vma(mm, i))
ret->low_slices |= 1u << i;
if (slice_addr_is_low(high_limit - 1))
return;
for (i = 0; i < GET_HIGH_SLICE_INDEX(high_limit); i++)
if (!slice_high_has_vma(mm, i))
__set_bit(i, ret->high_slices);
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/mm.h`, `linux/pagemap.h`, `linux/err.h`, `linux/spinlock.h`, `linux/export.h`, `linux/hugetlb.h`, `linux/sched/mm.h`.
- Detected declarations: `function slice_print_mask`, `function slice_print_mask`, `function slice_range_to_mask`, `function slice_area_is_free`, `function slice_low_has_vma`, `function slice_high_has_vma`, `function slice_mask_for_free`, `function slice_check_range_fits`, `function slice_flush_segments`, `function slice_convert`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: integration 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.