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

Function phys_pager_allocate

freebsd/vm/phys_pager.c:76–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76vm_object_t
77phys_pager_allocate(void *handle, struct phys_pager_ops *ops, void *data,
78 vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t foff, struct ucred *cred)
79{
80 vm_object_t object, object1;
81 vm_pindex_t pindex;
82 bool init;
83
84 /*
85 * Offset should be page aligned.
86 */
87 if (foff & PAGE_MASK)
88 return (NULL);
89
90 pindex = OFF_TO_IDX(foff + PAGE_MASK + size);
91 init = true;
92
93 if (handle != NULL) {
94 mtx_lock(&phys_pager_mtx);
95 /*
96 * Look up pager, creating as necessary.
97 */
98 object1 = NULL;
99 object = vm_pager_object_lookup(&phys_pager_object_list, handle);
100 if (object == NULL) {
101 /*
102 * Allocate object and associate it with the pager.
103 */
104 mtx_unlock(&phys_pager_mtx);
105 object1 = vm_object_allocate(OBJT_PHYS, pindex);
106 mtx_lock(&phys_pager_mtx);
107 object = vm_pager_object_lookup(&phys_pager_object_list,
108 handle);
109 if (object != NULL) {
110 /*
111 * We raced with other thread while
112 * allocating object.
113 */
114 if (pindex > object->size)
115 object->size = pindex;
116 init = false;
117 } else {
118 object = object1;
119 object1 = NULL;
120 object->handle = handle;
121 object->un_pager.phys.ops = ops;
122 object->un_pager.phys.data_ptr = data;
123 if (ops->phys_pg_populate != NULL)
124 vm_object_set_flag(object, OBJ_POPULATE);
125 TAILQ_INSERT_TAIL(&phys_pager_object_list,
126 object, pager_object_list);
127 }
128 } else {
129 if (pindex > object->size)
130 object->size = pindex;
131 }
132 mtx_unlock(&phys_pager_mtx);
133 vm_object_deallocate(object1);

Callers 2

shm_allocFunction · 0.85
phys_pager_allocFunction · 0.85

Calls 6

vm_pager_object_lookupFunction · 0.85
vm_object_allocateFunction · 0.85
vm_object_set_flagFunction · 0.85
vm_object_deallocateFunction · 0.85
mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected