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

Function vm_map_pmap_enter

freebsd/vm/vm_map.c:2651–2731  ·  view source on GitHub ↗

* vm_map_pmap_enter: * * Preload the specified map's pmap with mappings to the specified * object's memory-resident pages. No further physical pages are * allocated, and no further virtual pages are retrieved from secondary * storage. If the specified flags include MAP_PREFAULT_PARTIAL, then a * limited number of page mappings are created at the low-end of the * specified address range.

Source from the content-addressed store, hash-verified

2649 * the specified address range are mapped.
2650 */
2651static void
2652vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot,
2653 vm_object_t object, vm_pindex_t pindex, vm_size_t size, int flags)
2654{
2655 vm_offset_t start;
2656 vm_page_t p, p_start;
2657 vm_pindex_t mask, psize, threshold, tmpidx;
2658
2659 if ((prot & (VM_PROT_READ | VM_PROT_EXECUTE)) == 0 || object == NULL)
2660 return;
2661 if (object->type == OBJT_DEVICE || object->type == OBJT_SG) {
2662 VM_OBJECT_WLOCK(object);
2663 if (object->type == OBJT_DEVICE || object->type == OBJT_SG) {
2664 pmap_object_init_pt(map->pmap, addr, object, pindex,
2665 size);
2666 VM_OBJECT_WUNLOCK(object);
2667 return;
2668 }
2669 VM_OBJECT_LOCK_DOWNGRADE(object);
2670 } else
2671 VM_OBJECT_RLOCK(object);
2672
2673 psize = atop(size);
2674 if (psize + pindex > object->size) {
2675 if (pindex >= object->size) {
2676 VM_OBJECT_RUNLOCK(object);
2677 return;
2678 }
2679 psize = object->size - pindex;
2680 }
2681
2682 start = 0;
2683 p_start = NULL;
2684 threshold = MAX_INIT_PT;
2685
2686 p = vm_page_find_least(object, pindex);
2687 /*
2688 * Assert: the variable p is either (1) the page with the
2689 * least pindex greater than or equal to the parameter pindex
2690 * or (2) NULL.
2691 */
2692 for (;
2693 p != NULL && (tmpidx = p->pindex - pindex) < psize;
2694 p = TAILQ_NEXT(p, listq)) {
2695 /*
2696 * don't allow an madvise to blow away our really
2697 * free pages allocating pv entries.
2698 */
2699 if (((flags & MAP_PREFAULT_MADVISE) != 0 &&
2700 vm_page_count_severe()) ||
2701 ((flags & MAP_PREFAULT_PARTIAL) != 0 &&
2702 tmpidx >= threshold)) {
2703 psize = tmpidx;
2704 break;
2705 }
2706 if (vm_page_all_valid(p)) {
2707 if (p_start == NULL) {
2708 start = addr + ptoa(tmpidx);

Callers 2

vm_map_insertFunction · 0.85
vm_map_madviseFunction · 0.85

Calls 6

vm_page_find_leastFunction · 0.85
vm_page_count_severeFunction · 0.85
vm_page_all_validFunction · 0.85
vm_page_ps_testFunction · 0.85
pmap_object_init_ptFunction · 0.50
pmap_enter_objectFunction · 0.50

Tested by

no test coverage detected