arch/s390/mm/gmap_helpers.c
Source file repositories/reference/linux-study-clean/arch/s390/mm/gmap_helpers.c
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/mm/gmap_helpers.c- Extension
.c- Size
- 9615 bytes
- Lines
- 317
- Domain
- Architecture Layer
- Bucket
- arch/s390
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/mm_types.hlinux/mmap_lock.hlinux/mm.hlinux/hugetlb.hlinux/swap.hlinux/leafops.hlinux/pagewalk.hlinux/ksm.hasm/gmap_helpers.h
Detected Declarations
function try_get_locked_ptefunction gmap_helper_zap_one_pagefunction gmap_helper_discardfunction gmap_helper_try_set_pte_unusedfunction find_zeropage_pte_entryfunction walk_page_range_vmafunction for_each_vmafunction gmap_helper_disable_cow_sharingexport try_get_locked_pteexport gmap_helper_zap_one_pageexport gmap_helper_discardexport gmap_helper_try_set_pte_unusedexport gmap_helper_disable_cow_sharing
Annotated Snippet
fault = handle_mm_fault(vma, addr,
FAULT_FLAG_UNSHARE | FAULT_FLAG_REMOTE,
NULL);
if (fault & VM_FAULT_OOM)
return -ENOMEM;
/*
* See break_ksm(): even after handle_mm_fault() returned 0, we
* must start the lookup from the current address, because
* handle_mm_fault() may back out if there's any difficulty.
*
* VM_FAULT_SIGBUS and VM_FAULT_SIGSEGV are unexpected but
* maybe they could trigger in the future on concurrent
* truncation. In that case, the shared zeropage would be gone
* and we can simply retry and make progress.
*/
cond_resched();
goto retry;
}
return 0;
}
/**
* gmap_helper_disable_cow_sharing() - disable all COW sharing
*
* Disable most COW-sharing of memory pages for the whole process:
* (1) Disable KSM and unmerge/unshare any KSM pages.
* (2) Disallow shared zeropages and unshare any zerpages that are mapped.
*
* Not that we currently don't bother with COW-shared pages that are shared
* with parent/child processes due to fork().
*/
int gmap_helper_disable_cow_sharing(void)
{
struct mm_struct *mm = current->mm;
int rc;
mmap_assert_write_locked(mm);
if (!mm->context.allow_cow_sharing)
return 0;
mm->context.allow_cow_sharing = 0;
/* Replace all shared zeropages by anonymous pages. */
rc = __gmap_helper_unshare_zeropages(mm);
/*
* Make sure to disable KSM (if enabled for the whole process or
* individual VMAs). Note that nothing currently hinders user space
* from re-enabling it.
*/
if (!rc)
rc = ksm_disable(mm);
if (rc)
mm->context.allow_cow_sharing = 1;
return rc;
}
EXPORT_SYMBOL_GPL(gmap_helper_disable_cow_sharing);
Annotation
- Immediate include surface: `linux/export.h`, `linux/mm_types.h`, `linux/mmap_lock.h`, `linux/mm.h`, `linux/hugetlb.h`, `linux/swap.h`, `linux/leafops.h`, `linux/pagewalk.h`.
- Detected declarations: `function try_get_locked_pte`, `function gmap_helper_zap_one_page`, `function gmap_helper_discard`, `function gmap_helper_try_set_pte_unused`, `function find_zeropage_pte_entry`, `function walk_page_range_vma`, `function for_each_vma`, `function gmap_helper_disable_cow_sharing`, `export try_get_locked_pte`, `export gmap_helper_zap_one_page`.
- Atlas domain: Architecture Layer / arch/s390.
- 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.