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

Function kmem_bootstrap_free

freebsd/vm/vm_kern.c:841–876  ·  view source on GitHub ↗

* kmem_bootstrap_free: * * Free pages backing preloaded data (e.g., kernel modules) to the * system. Currently only supported on platforms that create a * vm_phys segment for preloaded data. */

Source from the content-addressed store, hash-verified

839 * vm_phys segment for preloaded data.
840 */
841void
842kmem_bootstrap_free(vm_offset_t start, vm_size_t size)
843{
844#if defined(__i386__) || defined(__amd64__)
845 struct vm_domain *vmd;
846 vm_offset_t end, va;
847 vm_paddr_t pa;
848 vm_page_t m;
849
850 end = trunc_page(start + size);
851 start = round_page(start);
852
853#ifdef __amd64__
854 /*
855 * Preloaded files do not have execute permissions by default on amd64.
856 * Restore the default permissions to ensure that the direct map alias
857 * is updated.
858 */
859 pmap_change_prot(start, end - start, VM_PROT_RW);
860#endif
861 for (va = start; va < end; va += PAGE_SIZE) {
862 pa = pmap_kextract(va);
863 m = PHYS_TO_VM_PAGE(pa);
864
865 vmd = vm_pagequeue_domain(m);
866 vm_domain_free_lock(vmd);
867 vm_phys_free_pages(m, 0);
868 vm_domain_free_unlock(vmd);
869
870 vm_domain_freecnt_inc(vmd, 1);
871 vm_cnt.v_page_count++;
872 }
873 pmap_remove(kernel_pmap, start, end);
874 (void)vmem_add(kernel_arena, start, end - start, M_WAITOK);
875#endif
876}
877
878/*
879 * Allow userspace to directly trigger the VM drain routine for testing

Callers 1

preload_delete_nameFunction · 0.50

Calls 8

PHYS_TO_VM_PAGEFunction · 0.85
vm_pagequeue_domainFunction · 0.85
vm_phys_free_pagesFunction · 0.85
vm_domain_freecnt_incFunction · 0.85
vmem_addFunction · 0.85
pmap_change_protFunction · 0.50
pmap_kextractFunction · 0.50
pmap_removeFunction · 0.50

Tested by

no test coverage detected