MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vm_map_sync

Function vm_map_sync

freebsd/vm/vm_map.c:3713–3810  ·  view source on GitHub ↗

* vm_map_sync * * Push any dirty cached pages in the address range to their pager. * If syncio is TRUE, dirty pages are written synchronously. * If invalidate is TRUE, any cached pages are freed as well. * * If the size of the region from start to end is zero, we are * supposed to flush all modified pages within the region containing * start. Unfortunately, a region can be split or coales

Source from the content-addressed store, hash-verified

3711 * Returns an error if any part of the specified range is not mapped.
3712 */
3713int
3714vm_map_sync(
3715 vm_map_t map,
3716 vm_offset_t start,
3717 vm_offset_t end,
3718 boolean_t syncio,
3719 boolean_t invalidate)
3720{
3721 vm_map_entry_t entry, first_entry, next_entry;
3722 vm_size_t size;
3723 vm_object_t object;
3724 vm_ooffset_t offset;
3725 unsigned int last_timestamp;
3726 int bdry_idx;
3727 boolean_t failed;
3728
3729 vm_map_lock_read(map);
3730 VM_MAP_RANGE_CHECK(map, start, end);
3731 if (!vm_map_lookup_entry(map, start, &first_entry)) {
3732 vm_map_unlock_read(map);
3733 return (KERN_INVALID_ADDRESS);
3734 } else if (start == end) {
3735 start = first_entry->start;
3736 end = first_entry->end;
3737 }
3738
3739 /*
3740 * Make a first pass to check for user-wired memory, holes,
3741 * and partial invalidation of largepage mappings.
3742 */
3743 for (entry = first_entry; entry->start < end; entry = next_entry) {
3744 if (invalidate) {
3745 if ((entry->eflags & MAP_ENTRY_USER_WIRED) != 0) {
3746 vm_map_unlock_read(map);
3747 return (KERN_INVALID_ARGUMENT);
3748 }
3749 bdry_idx = (entry->eflags &
3750 MAP_ENTRY_SPLIT_BOUNDARY_MASK) >>
3751 MAP_ENTRY_SPLIT_BOUNDARY_SHIFT;
3752 if (bdry_idx != 0 &&
3753 ((start & (pagesizes[bdry_idx] - 1)) != 0 ||
3754 (end & (pagesizes[bdry_idx] - 1)) != 0)) {
3755 vm_map_unlock_read(map);
3756 return (KERN_INVALID_ARGUMENT);
3757 }
3758 }
3759 next_entry = vm_map_entry_succ(entry);
3760 if (end > entry->end &&
3761 entry->end != next_entry->start) {
3762 vm_map_unlock_read(map);
3763 return (KERN_INVALID_ADDRESS);
3764 }
3765 }
3766
3767 if (invalidate)
3768 pmap_remove(map->pmap, start, end);
3769 failed = FALSE;
3770

Callers 1

kern_msyncFunction · 0.85

Calls 6

vm_map_lookup_entryFunction · 0.85
vm_map_entry_succFunction · 0.85
vm_object_referenceFunction · 0.85
vm_object_syncFunction · 0.85
vm_object_deallocateFunction · 0.85
pmap_removeFunction · 0.50

Tested by

no test coverage detected